Message ID | 20221214194056.161492-13-michael.roth@amd.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10B8BC4332F for <linux-mm@archiver.kernel.org>; Wed, 14 Dec 2022 19:48:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94F8F8E0006; Wed, 14 Dec 2022 14:48:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FFC78E0002; Wed, 14 Dec 2022 14:48:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7531F8E0006; Wed, 14 Dec 2022 14:48:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6475B8E0002 for <linux-mm@kvack.org>; Wed, 14 Dec 2022 14:48:16 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2CD05804FF for <linux-mm@kvack.org>; Wed, 14 Dec 2022 19:48:16 +0000 (UTC) X-FDA: 80241948192.17.BCCC17C Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2063.outbound.protection.outlook.com [40.107.220.63]) by imf30.hostedemail.com (Postfix) with ESMTP id 520D780015 for <linux-mm@kvack.org>; Wed, 14 Dec 2022 19:48:13 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=wMCYzGlE; spf=pass (imf30.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.220.63 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671047293; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bvB+CkWgMZwu/G1uEl2VsVd+ebjzmKgx1a7uwFu23Fo=; b=LOEW1sUCDmznDJFqqCsbZVHM9jxphkng1qgIweJ6tBqp8s0v0RAk0GZ++sirxeFj8pVl4e g1W1BTaulSM9UWjezgup+f0bHy0hEuUHjgCET9yhjAzxovuEPTaIP7BS9ZKejI1kNKz5Xd F+Vo9LnGWpL1h6XqxeVocpt4mG/XttM= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=wMCYzGlE; spf=pass (imf30.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.220.63 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1671047293; a=rsa-sha256; cv=pass; b=flji211z3IQW8hTh8qhGl1R/IgJ8MkgB6OjWoS560m0Mr4Tvck6LfIl7ZoG6CPhyQl4rjs Y/zITlMKfDgDGftF3OQsUUVMwAVVy9kRSTSE8ZvJCd6ldPY2MSe3I7fzpxZJH36ejvPAm1 GyrNhc7faQYXF9rB7HWH+lg0akl6R+c= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nNYgM4jKtD6mSHe802fG/uBL3josC4nq5IsMjw9gKyIfbCMdfwGp6M/dG07GmgQrgmWWrcmspDkQZ9DfkzG9Hq68eciYtHZY7dACYOYX3a8pFeDn7RW/UgWi3dzKf6d4TJrw1+tDZM9W2IiALPz526nSY+Lq3kHermfw1ypO5ApFu3lBUxPuiMAiRhqqZbfaDmecs7n8jN666sAE03epZCNeUbYInmlZOH7JLq+AKHE5tioiljtyx8eEvEpUNK6mndfgQQI6Aftle7N+iMiyct4QBPX5SQKxv+ewE7HiT0Zc+TBdOqK8i3z4UGw01l3YgzhTQGN4IBNVA7UeoF7kiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bvB+CkWgMZwu/G1uEl2VsVd+ebjzmKgx1a7uwFu23Fo=; b=U3+SMpquxa/ms2WEmLQ+/28sfaQZVRCxiHz1esLRSHrDPnTtZHQlK75UJ7PWtlHxQKOoWIq8MKWKxMp21RWS8xUgyn3XqbU4jtrM53S6l8UioFruxkmCoMn4C345DW9h2meVtnMdMDntSSWjF+oq1PislNhPUoKLYJ48LQwMM5C411tCLPJ9XHAxDHVJ9IkOr2Yg4oi+OgYgwerMGAxYxS1QYcS2ZJIiWk1nE1J7jE7wYEUqcktipWN/Hsdg/PCgKuHrjpYPK4iFyALqCcdU8bf669Wm1iipltpxm8J9A9/p64wePHTRyNQQvcgAbVKKPKQ6TZm9yiZatKxKxJ+T/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bvB+CkWgMZwu/G1uEl2VsVd+ebjzmKgx1a7uwFu23Fo=; b=wMCYzGlEkNAmAOfTxWcOgeZ+c6S/yOGUw55OkgyBzWzL+P83maWjcDuA6oMm3/fswc2NNzmxVOJdDrpwANg5CwOsAU84sB03Bm81CQTHU6iWC9mQTGpa2Z9YCu8B0msjbie3LasSAAwTVZiQ3HdnLnsJsOAicwjP7fE+9fYn+x4= Received: from MN2PR15CA0002.namprd15.prod.outlook.com (2603:10b6:208:1b4::15) by DM4PR12MB5868.namprd12.prod.outlook.com (2603:10b6:8:67::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Wed, 14 Dec 2022 19:48:08 +0000 Received: from BL02EPF0000EE3E.namprd05.prod.outlook.com (2603:10b6:208:1b4:cafe::16) by MN2PR15CA0002.outlook.office365.com (2603:10b6:208:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Wed, 14 Dec 2022 19:48:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0000EE3E.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Wed, 14 Dec 2022 19:48:08 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 14 Dec 2022 13:48:07 -0600 From: Michael Roth <michael.roth@amd.com> To: <kvm@vger.kernel.org> CC: <linux-coco@lists.linux.dev>, <linux-mm@kvack.org>, <linux-crypto@vger.kernel.org>, <x86@kernel.org>, <linux-kernel@vger.kernel.org>, <tglx@linutronix.de>, <mingo@redhat.com>, <jroedel@suse.de>, <thomas.lendacky@amd.com>, <hpa@zytor.com>, <ardb@kernel.org>, <pbonzini@redhat.com>, <seanjc@google.com>, <vkuznets@redhat.com>, <wanpengli@tencent.com>, <jmattson@google.com>, <luto@kernel.org>, <dave.hansen@linux.intel.com>, <slp@redhat.com>, <pgonda@google.com>, <peterz@infradead.org>, <srinivas.pandruvada@linux.intel.com>, <rientjes@google.com>, <dovmurik@linux.ibm.com>, <tobin@ibm.com>, <bp@alien8.de>, <vbabka@suse.cz>, <kirill@shutemov.name>, <ak@linux.intel.com>, <tony.luck@intel.com>, <marcorr@google.com>, <sathyanarayanan.kuppuswamy@linux.intel.com>, <alpergun@google.com>, <dgilbert@redhat.com>, <jarkko@kernel.org>, <ashish.kalra@amd.com>, <harald@profian.com> Subject: [PATCH RFC v7 12/64] KVM: SEV: Implement .fault_is_private callback Date: Wed, 14 Dec 2022 13:40:04 -0600 Message-ID: <20221214194056.161492-13-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221214194056.161492-1-michael.roth@amd.com> References: <20221214194056.161492-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000EE3E:EE_|DM4PR12MB5868:EE_ X-MS-Office365-Filtering-Correlation-Id: 169c56e7-7792-4b86-c9ad-08dade0c1fe1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0rbxraxPtDOWCByVgnfIbq8jdZLNqlzmDssuqU1uERFzIEah+DD1EZlKHt0YFddi3klzPC8YufYVegkczH0/OoLAovcGGWpX6un7nwaBjQeD+NBh+qAR0Xis9A6HXa/6tcfPdrs4/RtKBAX4qQaoXLzDbhXcTIxS096xBe96WpIKaRc7WqB4tl4gXXtkaNvoA7HsP2V6EULZm5jnbOAnU9iFRpCzr4cHESv3/OwC0PblOTqMQnWHIabEf1qPiqeHubdJAo8bbb4vEQFPDZDHSV/klCI6orxIxPJnrf3O9LpatoRY4lerVZ3U+Lc3Az30Gp+YJPlBQPR2Giz2qg4fJEGme/n4o8MKQwb84dMitq/UlxlY6kxe5WWUhLkmlYoUBQmn788MIKlwB71EaklUkwwBSzWaVAjaHHMjmvvDgRzuU8MnQnTknz6yRU6E6NjZr+2vnga/r3x3jUxqyTz05p9Mo/iNjHhEM1vxlCC/dGVMsTHCN61DPTWjnvLWL1jaQwIVbFwtPzoM+sGC6vThAyAGcrpwsbpMkjTQJ6e5J9y7y7ZfCm0nHhhukxOzzGB+1NdJnZDCudHbznfbb8hDDUGRnta+sbFCmaeUTb6XsGrDWM8dOHFsxPmww5nL+NWRyhLNP/3oBkHvRZ1LA1BzVWiMDV88ejNVNi4nyZI0c6c0lTkIHRbYgJoXybYvfvHqpW014xCKZ/MZIL6lWnJxu4ezLtPhMV3Uv+ZrofeVrY6h251qdCXAEurvSP6aOmu7nFOCxOLh12jrdWUo6QIF6w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199015)(46966006)(40470700004)(36840700001)(36756003)(356005)(7406005)(41300700001)(8936002)(6666004)(478600001)(40460700003)(86362001)(82310400005)(81166007)(82740400003)(40480700001)(36860700001)(2616005)(5660300002)(16526019)(44832011)(1076003)(336012)(70206006)(186003)(6916009)(8676002)(426003)(4326008)(70586007)(7416002)(316002)(83380400001)(26005)(2906002)(47076005)(54906003)(142923001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 19:48:08.1273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 169c56e7-7792-4b86-c9ad-08dade0c1fe1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0000EE3E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5868 X-Stat-Signature: urqyzfag78peq6m61ecqdu784gfqkakb X-Rspam-User: X-Rspamd-Queue-Id: 520D780015 X-Rspamd-Server: rspam06 X-HE-Tag: 1671047293-117884 X-HE-Meta: U2FsdGVkX1+3HbHj7XgHs+FXzTd0kp9yT3fhHFmhA7iq0pWZlgD7Pt8lpuum3mI7jnVb17hgQqnE9ONyJbkD/ycNRE7v3gvFO1qo4beTefYSAAgFW978f6M/uL55zl3Izg+ZkWPZaAlqIrK1TgF78CLYJTsdCRuqc8/RnSkm1WdZVc1O6/pfW9MwxAhY9k7JXr1LWNKNkT4S3ESZnU64fzAxfm6B+3jd+tpCb2mhtZNZRwQ6wPc2NVDBZahFuNWwizlSxWWdbw+T+ixXHwh43v6VJoXbJnFfevbJI8CJjOojkt0g2gCV4NGgz5uIAHI/tGMsy7vRcU5BtNrdJpGkJaeNAgt+uazDbn57YzZ/49brlBB9QbLxFIQz5fsmkVWh36nLFfqMK6J3wnYzjYl0Mb8uiUiealpNj08u9GNy0FIAaEzm061tX6QoJ4Jo5w32qbhgS8IfzRxSbaqP8E5iZVobzKXGN+Dv7yBJy8hLjqgZ730ea7xRCDlTEWBPnW5zfom79BMOz43lGAAG1sk4ZI/O6dwCGMQr535MpbMcSL0cnzGa/EPKq+V3zdPAxihyFsCVp8sWQ5mm/dfqnOSuSkdaxAc7IstMWjxnxXA6XKOMvJbfxcb8fTxs3JfDBDtQdebyKwQogxcVc1NnnFR8i58UcqZt+ncIrn/fHi2KAc7wBs25I2eXW4xJ1tDizqWAJGXg0yRupLbTEfmlT8XMgILbZ21cFEe6b13dj8CFYWmS6XAs0Ca/FBFTW536Ndq42ph/evaNzpAEx2vtQTQHb7RVlvPGg5q90XJKQwDKeAZGIKaAWrZR4uNQ5Rt3pwaGqcWWxb6cvW8gEegQzFAOfcB8IMT+ydMiuy7EICoHhjhJ5l2DKlMcjQMfVBJlbxFWvXtI5BEhbjG+Fon/p/JHeuD+49HbB7RNHLN1uWbWkg3BJ8SF9VfIU0BWdSqfxfyCx88FJ4Vu9DbmN5jrFMp BB0IJEvk Hl0jz5RXznsWf4aUx2KKq4BQx9ZOha4Vd2oCV/JGpZBmTo3XvVYgvlKvkeA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
Add AMD Secure Nested Paging (SEV-SNP) Hypervisor Support
|
expand
|
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index ae4920aeb281..6579ed218f6a 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3179,3 +3179,26 @@ void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector) ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, 1); } + +int sev_fault_is_private(struct kvm *kvm, gpa_t gpa, u64 error_code, bool *private_fault) +{ + gfn_t gfn = gpa_to_gfn(gpa); + + if (!kvm_is_upm_enabled(kvm) || !sev_guest(kvm)) + goto out_unhandled; + + /* + * For SEV, the hypervisor is not aware of implicit conversions in the + * guest, so it relies purely on explicit conversions via + * KVM_EXIT_HYPERCALL, so the resulting handling by userspace should + * update the backing memory source accordingly. Therefore, the backing + * source is the only indicator of whether the fault should be treated + * as private or not. + */ + *private_fault = kvm_mem_is_private(kvm, gfn); + + return 1; + +out_unhandled: + return 0; +} diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 7f3e4d91c0c6..fc7885869f7e 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4830,6 +4830,8 @@ static struct kvm_x86_ops svm_x86_ops __initdata = { .vcpu_deliver_sipi_vector = svm_vcpu_deliver_sipi_vector, .vcpu_get_apicv_inhibit_reasons = avic_vcpu_get_apicv_inhibit_reasons, + + .fault_is_private = sev_fault_is_private, }; /* diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 4826e6cc611b..c760ec51a910 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -683,6 +683,8 @@ void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector); void sev_es_prepare_switch_to_guest(struct sev_es_save_area *hostsa); void sev_es_unmap_ghcb(struct vcpu_svm *svm); +int sev_fault_is_private(struct kvm *kvm, gpa_t gpa, u64 error_code, bool *private_fault); + /* vmenter.S */ void __svm_sev_es_vcpu_run(struct vcpu_svm *svm, bool spec_ctrl_intercepted);
KVM MMU will use this to determine whether an #NPF should be serviced with restricted memory or not. Signed-off-by: Michael Roth <michael.roth@amd.com> --- arch/x86/kvm/svm/sev.c | 23 +++++++++++++++++++++++ arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/svm/svm.h | 2 ++ 3 files changed, 27 insertions(+)