From patchwork Wed Nov 8 11:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 162980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp844469vqo; Wed, 8 Nov 2023 03:25:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKwCf3aETnQ5oTDZk2yfUjDlzwdev18MA5GGY2TxEriVgIqPPryBQmUVcRXQD28NzB/0sf X-Received: by 2002:a05:6870:a912:b0:1e9:bfe7:e842 with SMTP id eq18-20020a056870a91200b001e9bfe7e842mr1551441oab.32.1699442716387; Wed, 08 Nov 2023 03:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699442716; cv=none; d=google.com; s=arc-20160816; b=diesn3EWJ6bk5ES8GYSq19XIhLg4wgE/WqjsAWJk/yYhM3o3oJcJseEwNwylb3K0bD P8aibnBxs77X+KokVfU7z6QSgcqqeC6ruby6NbuZ5e/HzsisB5o2139SntnaQciG4gr7 a6rdYui32ZudCFBfGbGdee8rLHswDz0lbuqG+zF01WjXOpwi9478hPHbk9yLyMgjDC3O QXwAN34pVImjyc3Vfm98q9Tqx07Pf8EW0YKb8qdQgcHQswwKqRIhyubGyQLmG7Mk7GRo urR/NIcJDZ2pbl6rGX8NIoU+zveDL8R0QmyyH5OpV6fz2KDWp05Iik5uH4wjoQKGoMqd bnLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r3WKjqld4qql+FLcnzKJq/fsWtORZpLYW1PJ8L9F7HI=; fh=Qdq7NqGm5JR9LpctBpXjoRI38Lb2mCk6xy26GEDp1Bg=; b=ro4ZBkugGbCJ9pu7iuWC1Bn76//9K5p0Z9rvbkxl6KOfbOZ7r4Kalq/b31BYTeqpI5 9oOnFfSupWLeTk3068Pj6tQQhyRHEd5ILWMqiUHiiioL4IsOpXrtuw9toxWKqHAy+PI+ 9YsCTm9uooYrjNbLgGz5ifBORKWV6r8oW83l6bmwHKRQm2cHzBm2lIs6yjC97A2O00PY T5SI7aL81VGaJOZq0NPBFDfIyELdkiIHooc+zzEYMVW+PV2uB4WZF3rWWS0OhPFB9cY0 PXFf8hWewVu4WnRSoD1eitoy46/q+izq251njwoS33Rmulw1+kXd/NuaV0/w7jCBl44E o0zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=lRDOzF+2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bq10-20020a056a02044a00b00563da455862si4632015pgb.311.2023.11.08.03.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:25:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=lRDOzF+2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4764681A1BD1; Wed, 8 Nov 2023 03:25:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344373AbjKHLYo (ORCPT + 32 others); Wed, 8 Nov 2023 06:24:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235583AbjKHLY2 (ORCPT ); Wed, 8 Nov 2023 06:24:28 -0500 Received: from smtp-fw-52003.amazon.com (smtp-fw-52003.amazon.com [52.119.213.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A871FC2; Wed, 8 Nov 2023 03:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1699442667; x=1730978667; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r3WKjqld4qql+FLcnzKJq/fsWtORZpLYW1PJ8L9F7HI=; b=lRDOzF+2/uSWtu6g6xiZPogGFIFZOEPhkU35BDMtOA7U8brSCvQ0mnZX jD8hivVkW40ZS2DOg3FS40/NOB5hG3A4n2gQbMg/ocMKnrcgInsI44svG MLXztXFUWmKvEOTR2olymytYWaNwqvRsY2Z8rlBbsWNEtaQ+AKlJonGxq w=; X-IronPort-AV: E=Sophos;i="6.03,286,1694736000"; d="scan'208";a="618316712" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-m6i4x-54a853e6.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-52003.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 11:24:26 +0000 Received: from smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev (iad7-ws-svc-p70-lb3-vlan3.iad.amazon.com [10.32.235.38]) by email-inbound-relay-iad-1a-m6i4x-54a853e6.us-east-1.amazon.com (Postfix) with ESMTPS id 2BB5348ECD; Wed, 8 Nov 2023 11:24:21 +0000 (UTC) Received: from EX19MTAEUC001.ant.amazon.com [10.0.10.100:34530] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.22.222:2525] with esmtp (Farcaster) id ada2ae65-467f-4b1a-8aba-0d7dc7fba03f; Wed, 8 Nov 2023 11:24:21 +0000 (UTC) X-Farcaster-Flow-ID: ada2ae65-467f-4b1a-8aba-0d7dc7fba03f Received: from EX19D004EUC001.ant.amazon.com (10.252.51.190) by EX19MTAEUC001.ant.amazon.com (10.252.51.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 8 Nov 2023 11:24:19 +0000 Received: from dev-dsk-nsaenz-1b-189b39ae.eu-west-1.amazon.com (10.13.235.138) by EX19D004EUC001.ant.amazon.com (10.252.51.190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 8 Nov 2023 11:24:14 +0000 From: Nicolas Saenz Julienne To: CC: , , , , , , , , , , , , , , , Nicolas Saenz Julienne Subject: [RFC 29/33] KVM: VMX: Save instruction length on EPT violation Date: Wed, 8 Nov 2023 11:18:02 +0000 Message-ID: <20231108111806.92604-30-nsaenz@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231108111806.92604-1-nsaenz@amazon.com> References: <20231108111806.92604-1-nsaenz@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.13.235.138] X-ClientProxiedBy: EX19D031UWC003.ant.amazon.com (10.13.139.252) To EX19D004EUC001.ant.amazon.com (10.252.51.190) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 08 Nov 2023 03:25:12 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781994845751914758 X-GMAIL-MSGID: 1781994845751914758 Save the length of the instruction that triggered an EPT violation in struct kvm_vcpu_arch. This will be used to populate Hyper-V VSM memory intercept messages. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/vmx/vmx.c | 1 + 2 files changed, 3 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 1f5a85d461ce..1a854776d91e 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -967,6 +967,8 @@ struct kvm_vcpu_arch { /* set at EPT violation at this point */ unsigned long exit_qualification; + u32 exit_instruction_len; + /* pv related host specific info */ struct { bool pv_unhalted; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 6e502ba93141..9c83ee3a293d 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5773,6 +5773,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu) PFERR_GUEST_FINAL_MASK : PFERR_GUEST_PAGE_MASK; vcpu->arch.exit_qualification = exit_qualification; + vcpu->arch.exit_instruction_len = vmcs_read32(VM_EXIT_INSTRUCTION_LEN); /* * Check that the GPA doesn't exceed physical memory limits, as that is