Message ID | 20221214194056.161492-57-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 95746C4332F for <linux-mm@archiver.kernel.org>; Wed, 14 Dec 2022 20:05:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 350238E0013; Wed, 14 Dec 2022 15:05:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FFC98E0002; Wed, 14 Dec 2022 15:05:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12C9B8E0013; Wed, 14 Dec 2022 15:05:03 -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 F1C238E0002 for <linux-mm@kvack.org>; Wed, 14 Dec 2022 15:05:02 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 98A73AB642 for <linux-mm@kvack.org>; Wed, 14 Dec 2022 20:05:02 +0000 (UTC) X-FDA: 80241990444.18.87007FE Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by imf08.hostedemail.com (Postfix) with ESMTP id AEACB160016 for <linux-mm@kvack.org>; Wed, 14 Dec 2022 20:04:59 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Ds3YocRQ; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf08.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.94.50 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; 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=1671048299; 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=VdFV0whZydjkEkUMB3fvnv3WDNrdWPRikxIjb+Jw6Mo=; b=MMvIaSbhCrUzU76icfH13HASIOG+w8syckAm9zERWmqedTpfa+PaEPKC8tf9zfsG5FghfJ qkAWHq7KXIMLtyLSrchse0PPfI6Y2Jkb1SO7cjCsYfFNsx4sXkN7043iRnvq5ywJEN8Wsx rcl0UViX0rUEKTet737CCx6uwq+pzho= ARC-Authentication-Results: i=2; imf08.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Ds3YocRQ; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf08.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.94.50 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1671048299; a=rsa-sha256; cv=pass; b=CNjy2+DZjQv41c+yciHbDlL0Cj26jNvw0KQXalVDCqPYmtcLJoHLvHhEH0VBNYpKcD/tZ8 9abC6ElVT0EaRDyXZluonHI9pFoTpjRKTjj/Yjvr2mt8olR7u58ka85rVUZWH1THWODGfE uekl3ApMZa79KGmbUb2gukTzu43uEEw= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OcKuM5j5YFDCdqLl92inJmcuyfRUfl+v2sfewlyfr9A6/MMAJjL7pUgKu3eP58I2Cq11NCR9IgUnT9oLk5u61wc5uwoyUqoztZ1TYYLRQ2/0kXV8llcX8zitihrkwGbiFdTpwjUWgylK8RCdYjQUz1Hwd7rkD2cS25S98+99rwkVS8bilEWXRWlVRqpbN16LJWr5jA0r9fkks5NC5XUluaGgYrzevNuD1+k9tqUfHTc7pE6rKZyvnqZmVom5VLiLs6utzqgSpsTy2Zy4fNaCUO/LtQb88jLqrEHlx+Z4ReJMCjKAFcDHcwyt99Q4HJVFw64bVDpR+DFNaZ8hL5A5Wg== 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=VdFV0whZydjkEkUMB3fvnv3WDNrdWPRikxIjb+Jw6Mo=; b=moqoiGlNCA/m7nJ5hlhiqxYvP/Zc/Py2eBAADvdtqoCQiSvENk39YvXjQwyg813rl7bfEYDc+d/4RFOamRVSlfeYaVi+7IQ5eH4cme2rJ7iVtDQ99kpkcfdQLNdrn+m20TOHNBXnVPUwKv9I+u3MXav9o82wwxZq8flGdK2a7y9LVZE5BPWE7pRCOXdwy3P+8cdMCVsV8rWem63zR8ptkwsBGeW6pvA12nxhNp9jwFSod4nkA7UHKChHhPGOW8fj5mfT7+YRIHcIsS4K4NChT8kjcKmMSLwrMtueIrsX12WveHcUcIIzNi98Mu+oLloNUbOW2kiiA09MMvA44DgdKQ== 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=VdFV0whZydjkEkUMB3fvnv3WDNrdWPRikxIjb+Jw6Mo=; b=Ds3YocRQWIfYpbAEHhD8te0koL9WdvXfvVhslOM448dLZHI3ZbPahwQC8r9TlZKvKR+C34KgEi4Gyq/zsJg1jSTeBU+Qd7S7+n0lioYaGok5xsetHs7WF7BTsOyPcR07iLytIEexuWJEEEzFZXylEMqnuaFyFjhJW8kxSi1PjtQ= Received: from MW4P221CA0021.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::26) by PH7PR12MB5904.namprd12.prod.outlook.com (2603:10b6:510:1d8::19) 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 20:04:57 +0000 Received: from CO1NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::55) by MW4P221CA0021.outlook.office365.com (2603:10b6:303:8b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 20:04:57 +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 CO1NAM11FT107.mail.protection.outlook.com (10.13.175.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 20:04:56 +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 14:04:55 -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 56/64] KVM: x86/mmu: Generate KVM_EXIT_MEMORY_FAULT for implicit conversions for SNP Date: Wed, 14 Dec 2022 13:40:48 -0600 Message-ID: <20221214194056.161492-57-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: CO1NAM11FT107:EE_|PH7PR12MB5904:EE_ X-MS-Office365-Filtering-Correlation-Id: c4a67f0b-5239-46a7-ec86-08dade0e793a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zk3MkAaPPMkQ+VUyCTDwmYxwIBeFVs1VuJYW8UkrvbPQKJT4Ec8uXWa+ndJWwQD6H1JLcZ6nNPQfuZA133g3v7o3BkG0NIRxlXD0jIiL31FmVej6AGIggJNofojZNsp9kRduFJj9TSAWdjJiX2p0bswZNq2N3MQ3KPPRrj/bJUjMKSVE4Bmv2CIbgR24cFNyFMZR8qlTmRNzYCf9t5KriTICu3su2qNINB3REr9A4kBsjucuRX6XTzKG7GDY1dWkwYbDoKsXVGnWchMGMxifJ4UJeNxo9vZUIQDNUzIvLHf6b6s7LlF1sj1n5dKzceSQWAV+3jTiqPJkvS+Q94i2ew4RVygP9MtfoyyXb4aWaewiojFReYMYvToKZelNTWLRTNDZ0WtIRG8jE66CLIO/anbImS2U4iQhKfTprFEgmupBBLk7bla8+j5F9ZHFZbAYhRkY4s1TDiSbGJlOg1+JSA/PisdOsU4qhtKCbwdws/5QSUUV5BjxNZpVaziG1EuQyhkPZoRsVGyR3u0q5BUWI9kF3uU6RbNaaHC8x1as1oCQ/0DpsRytsgwFCk8OPRt2DFwabjcAYKt8pFd3yjZr9A7JKSFoQQUtIwXv4AlpO0K4XThPx73EUvjWjnUPdaGHuaLMXbafagFGSgbDu3BMoqXdI6pQjaJtaOaCWYdtvhgTd7NLWmJPwOP8rdMYplSkIGpOV0j1pYRcpyd6jE23BBxw0rem0O6vugfRxGYpMZ4= 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)(396003)(39860400002)(346002)(376002)(136003)(451199015)(40470700004)(36840700001)(46966006)(40480700001)(7416002)(356005)(81166007)(2906002)(44832011)(36860700001)(478600001)(186003)(26005)(6666004)(8936002)(5660300002)(70586007)(70206006)(8676002)(4326008)(36756003)(7406005)(47076005)(336012)(40460700003)(426003)(82740400003)(2616005)(41300700001)(82310400005)(54906003)(86362001)(83380400001)(16526019)(316002)(6916009)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 20:04:56.9284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4a67f0b-5239-46a7-ec86-08dade0e793a 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: CO1NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5904 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AEACB160016 X-Stat-Signature: e5fiumfuzpwcck7p58xisoq6e543uhdo X-Rspam-User: X-HE-Tag: 1671048299-662753 X-HE-Meta: U2FsdGVkX18pbQgsYape2GF8CyAS9YfkcaL1KOTzS2tVTNSelv7B5jJdcI6ReO7o6Br/4AfMOaiDPYtHRqNdEgCjYq/k5pHYZGKOgLHIf1Q//M6P4m44MHg0HKtii0QN/pPa+U4TVwCVdfS3+p3rYbfiXRDHGW9WVNhN183B1FLud1YXCGXa8xgJnXGf+P5EC4W3g+JxNLmo1HAD4KGw4CGHc+a+nok5+bLMwdE7alllMj3ubp4U2i3UncO14YU8eVxrza/KbvHqjLi4xY+Tc8oW/yXYIlRERUSND+njjo2ZvAh/xsRUtqAKHo4hFk6CzkbxVQ21kG0aNPlqPv0msxhQeBT3I4lWma2SdHJysWGTlKTxYLCv6uBg51bRNGNXovmZtCufE43K6i9KZgsjvu0WKZU0Tll9lpflkF/2wcu8Jj6dAssqG39YpFjVmmfWKtfH648ewTWVgah84wFEDH76cdcMSqS8mgPxf7nR9PGk9l1fu2WkjEaDZ/pvrfM3OyX7ybuhBT7D9Na+rdI/AAzSKhJl59QRUmLouooEB+S3kqHp1BZqrMPM8jJfaN0aaUXj1pP/QPRkT2K7G0BNhRMyaFpOTyUixPiJuqwkBujeQjGDxWkI7n4fvIEqm4yjE/qBbt9sM+TOOx9zAsFQuGfaPAMuskYdK/ZY8/kRe3y39/qIxrYFTq0TscIfkAMx0LPWdNeW6hdPEBEPNVCdsasH2Bo7WVfmHStA8LQpBt2nrq+CO+75Datc5I4g7+ctsqyfWaDIC0IeEUnKv7IZVkZ4X0ec6UfeXfBkNgKh/OoPD6K+R02u2lza3DZUyFhM1hncQaoa3huyq9yaEfKW6B2SPBDiw8nzNeSsMORZzSuvb9EsS/jHvLv5alWPtPhYVFxR/sQkM8+0tEQ872bPkzQSW8uPaBGwo4neKsjjhX4fE9R4+q8GB6awbAbimgDYXqO6f1dFV+Omw/6FTz3 Pnz8m7Cp u/n6jbeJLdBTMGzGe6j1mCvMM1Q+LLdIlX/UtwvdbzJO3+8Iqnw8uSGU3BA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000330, 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 885a3f1da910..0dd3d9debe48 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -4446,7 +4446,10 @@ int sev_fault_is_private(struct kvm *kvm, gpa_t gpa, u64 error_code, bool *priva * source is the only indicator of whether the fault should be treated * as private or not. */ - *private_fault = kvm_mem_is_private(kvm, gfn); + if (sev_snp_guest(kvm)) + *private_fault = (error_code & PFERR_GUEST_ENC_MASK) ? true : false; + else + *private_fault = kvm_mem_is_private(kvm, gfn); return 1;
SEV-SNP will set PFERR_GUEST_ENC_MASK for NPT faults for encrypted/private memory. Generally such accesses will be preceded at some point by a GHCB request to the hypervisor to put the page in the expected private/shared state, so the KVM MMU wouldn't normally need to generate KVM_EXIT_MEMORY_FAULTs to handle the updates at access time. However, implicit conversions are also supported for SNP guests, and in those cases an KVM_EXIT_MEMORY_FAULT will be needed to put the page in the expected private/shared state. Check for this PFERR_GUEST_ENC_MASK bit when determining whether a #NPF should be handled with restrictedmem pages or not. Signed-off-by: Michael Roth <michael.roth@amd.com> --- arch/x86/kvm/svm/sev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)