Message ID | 20210602141057.27107-26-brijesh.singh@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=1WO3=K4=kvack.org=owner-linux-mm@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FA7BC4708F for <linux-mm@archiver.kernel.org>; Wed, 2 Jun 2021 14:12:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1EA4A61242 for <linux-mm@archiver.kernel.org>; Wed, 2 Jun 2021 14:12:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EA4A61242 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B441E8E002B; Wed, 2 Jun 2021 10:12:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B18A28E002A; Wed, 2 Jun 2021 10:12:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 920228E002B; Wed, 2 Jun 2021 10:12:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 5E0FE8E001E for <linux-mm@kvack.org>; Wed, 2 Jun 2021 10:12:05 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EEFF3181AC9B6 for <linux-mm@kvack.org>; Wed, 2 Jun 2021 14:12:04 +0000 (UTC) X-FDA: 78208972968.19.F9FB31B Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2059.outbound.protection.outlook.com [40.107.93.59]) by imf02.hostedemail.com (Postfix) with ESMTP id CBC9C4211089 for <linux-mm@kvack.org>; Wed, 2 Jun 2021 14:11:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Art7wraoDaqeAqMgiqBcDNlWm14HnU+hoE7DGcAmGlBA4Ff1ZFSH4NtlvgZSlOm2StJHtN9oNyzH4mIZ3rhdnkMdXYaeepTkl7QkswW69Whe7cpDYEkEoLdm6PMpDXWLABTspZA5bPmqLhXzV48xqnVttOlmeYzw2TRIqD0niI8PAJwHXNeAYd2rLHm/V1Y7ojiVGmVMk7BjEzk/7kKTXjtjNRgB2EAmiFlMg3drs4BBiZfb7HB6xGhMzp/kU57FzKOZbHBP+VAyZCUb/NODMZ6ye5lkGZFZDGSLjTAkM2K17U7Clzy3cL1VSOfaSnYSqkFlaylxmwNtfl94ST/85w== 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-SenderADCheck; bh=v5fkC3xFRR9pL5wKKPvCx+W+UqhkeLVogvMDzAl06Y4=; b=NTpPqR7xcS5REFAIAASFCcftPuKGGTDOEzookQjtxAMEl19KCsGRNCiStceKc1woK494979+8oOlStut4z+hEZi4y6298vMZj1R3Qrpt1MxbJ4thjVy6gQ6RkWaie+nXaxSODgFEfJXUAenTSdFAjM6W+VyaZ/W32gl28vI09xBdjn60rD7387r9N0jcCJPcTkhq/MtbeXr+Xv1V5WwYgrPLQ9fABSaGBwnoaq3YP+M7IKnCTv1Jb/aZqHouSUT0g6/tTJXo2yriIPtZvjVPhZu/dErsu9ZiK+W9WXrXp1HiQAVRg2IkFDw0WSgDq6JiIaL1gyincfZYiUq2nhsP7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=v5fkC3xFRR9pL5wKKPvCx+W+UqhkeLVogvMDzAl06Y4=; b=izPf25QUEskrCDiP4GRL6CTU5PgSbJwW1QP4H93m2NxHRHftn8FIfXHF/aGr8w0q498EAOgRqWvZUB0ym9YxjBFO4CSxn2yvePcFadNB/nVFX7GjixBVdeXNL5/dTo4SZQ/NM4F6CL1IHfKFgmthcXoyl+DQZ8gbNqxC3kXtK6E= Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SA0PR12MB4592.namprd12.prod.outlook.com (2603:10b6:806:9b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.22; Wed, 2 Jun 2021 14:12:01 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94%6]) with mapi id 15.20.4173.030; Wed, 2 Jun 2021 14:12:01 +0000 From: Brijesh Singh <brijesh.singh@amd.com> To: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org Cc: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Joerg Roedel <jroedel@suse.de>, Tom Lendacky <thomas.lendacky@amd.com>, "H. Peter Anvin" <hpa@zytor.com>, Ard Biesheuvel <ardb@kernel.org>, Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com>, Vitaly Kuznetsov <vkuznets@redhat.com>, Wanpeng Li <wanpengli@tencent.com>, Jim Mattson <jmattson@google.com>, Andy Lutomirski <luto@kernel.org>, Dave Hansen <dave.hansen@linux.intel.com>, Sergio Lopez <slp@redhat.com>, Peter Gonda <pgonda@google.com>, Peter Zijlstra <peterz@infradead.org>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, David Rientjes <rientjes@google.com>, tony.luck@intel.com, npmccallum@redhat.com, Borislav Petkov <bp@suse.de>, Brijesh Singh <brijesh.singh@amd.com> Subject: [PATCH Part2 RFC v3 25/37] KVM: X86: Introduce kvm_mmu_map_tdp_page() for use by SEV Date: Wed, 2 Jun 2021 09:10:45 -0500 Message-Id: <20210602141057.27107-26-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210602141057.27107-1-brijesh.singh@amd.com> References: <20210602141057.27107-1-brijesh.singh@amd.com> Content-Type: text/plain X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SA0PR11CA0056.namprd11.prod.outlook.com (2603:10b6:806:d0::31) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SA0PR11CA0056.namprd11.prod.outlook.com (2603:10b6:806:d0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.20 via Frontend Transport; Wed, 2 Jun 2021 14:11:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d5f1e87-fa01-400d-0055-08d925d06391 X-MS-TrafficTypeDiagnostic: SA0PR12MB4592: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: <SA0PR12MB4592EA9255DC355B01A4C3CAE53D9@SA0PR12MB4592.namprd12.prod.outlook.com> X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EJRSFYg09H95Dzg/B9PnbGw7fD0db1V98XtuCo79Sw5a4uhfzROMRqYI46d5WJzrP6v05RyKYK8yfm+GoHiRb/DgbGQHytsNSA2La26R7J0v+4YFt4ZrRzFC0FAjj19KTHb+CmW0/k1EdnaME9jprlqoutiXEw14vGRpfor0ohHGUEYvqqCHFRzSF2cE+KH/pEGZsD/+h4dYUbcxg+WWWY1tLgKeguKfYpHK7cmWMjtsFzOhIAg8vMDz8mc8rhgxM0dY7g9nFlvrWmn/5jQVi9gHp++abeahbqCwfIuySG5UI9ZJq6mPDkbel3ss48Mzulk26tHstMJokf5RyQQQuBHyJbYHchQcjT9JXviOfoUy+UV/400KmjcS8Ta6tSG0VLMbTZrQob/WZafmbOB0njjlASc3cVvB4bR7v41EzlVud+N6NU/ms02thn3lxId9vVFc7JH1BX+KQZTmhmpI3fpL7BiytxYeYe5WiTwIDQSYDWvAWSVIFOm5WnDI4n1CKkUxXDLHP0/aAgs2o6ucTNapaJU7hYTtcB6PlOKtW1Beih/owJXGnV05HYNhvAiN/8k1LQogx89AI22RLuiWzpyu0NNWTP2puSN1h7xtc09HR6a8z3PQskyreCgqPRGH6uVT1aG8fEL6x1FzPbtaLQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(346002)(136003)(39860400002)(366004)(376002)(956004)(8936002)(8676002)(36756003)(478600001)(54906003)(83380400001)(1076003)(44832011)(2616005)(6666004)(38350700002)(38100700002)(5660300002)(66476007)(66556008)(2906002)(66946007)(4326008)(26005)(86362001)(186003)(7696005)(52116002)(16526019)(6486002)(7416002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: adJ5PMZfXgw5n1+KQdL7qyk+dCbssm1N3BreEqOi3DFCHQFeN9HGyji15AjvEo4DAgMAJ4SJBjdj3+fsA3dMRgesRAQcXVDx8bixtuqjCLrNOeR/ji1bT46Fvp1F5AgKSL2ydzD4hlw9MfAeErMAABKrPrCAWEVUm2mSbCnwR+v+Ax7CHVMETwBngsQthuzG8xDVRu9D9WidPW8aQ+3bDaa6YLYSv6qkt1xnRbUsNBxNktN2uPfY+Paxdvl1pHWxIpCBdoRIq6cSbdgaVMNgjGN7I2XVhdpPeKY7z/zJvYXZ7PYsZwuyH00FgYW6f6nDl0IVLpD9pIGjxIVDChywK1Tle3W+R8eQRBcR07trPMFcuIO8l9Pvs+mjOd0JswqKrZJVjd2caYwxCOY6S3RvvH624isfJnOxIWRA9uwNStdJPtomAXdK1The1rFyePbxAXaJqCRgQ0gNWLil0XLtRcnM4rzktZOXgO6eSdrL+uaEqZYgSEnV6kANL9PFV1u87COQoqwd5V4C0qAXco2MsP2Zo+jybgGKCdzKnoipBvUGEYFeSuQcjN4gvK1KFIDJNSwcyfQi9xXUX7qUaq0Y2EobfVx6TsUveWpTf2kiP847xfQShePYLJfUWkLgpmOUW0Cc/ZnP7xalQCmeHcT3A0U7y2n9XYQ9bTWGgl09mjuYmyBxSGZuhVM3RZ/7ty1WMkvFaYmJRufvuJQZxbtOYZczk/i5H7sZuG94BGB1BluujCQEIevEBdUHu+mkt9Tt9egKcv28070mG32IykVZ/GXmVQjnF9/AkFDqCqNJCifyBTrZ/b3Z5tiTBUFzfv7pkYytmEk/sYcrAhFPfewNvFhvjARTibh9Xi4XJfgESY7n+nFB3o+ZibBIJDVmUbMng2oh+SlApqLWDkgJQWhMmOdu3HIkVxBf53F7ePcyE33x+7h/TDfraFsKn+oLIOTsUytaL+7QliHJO3B9lOwrUWqkmkOfA7DA+f1T+70V9nQO5QAzH3hyytb2OObAPtarNbIpxDtOjBGyn8HbcG9BvccnzXW0cL5XFLGucDcMFjTVeTELOW0eLU6dT/2n0r/Odm+oRMMD45r8cCaZ0rL5hWBiKCUJxtq9iJQJ6IOB6EHPVFyRA8+zmLfTZEs8rPALONzOvmcJASNc1M/8dzmmBbGI50lpshODc4e2HwA+RHcFTl9WujfLkXPgMQO+932v9a+DqgElLAlk8LBGSuCTq3uzkepHuY/kC6WHgdKt4Lc8ztj+pzJKh1vAXq6fUfwU75phA/VBGDnTI1oZlulafomYga/H5I4KslsvQh6WVElHq5rPmJ5oOt1w/xJUbDke X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d5f1e87-fa01-400d-0055-08d925d06391 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 14:12:00.7286 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /u1gjgtONsnUEdEe96xsGtiZ5n0q63g8/1r9vc6iY3vrZWnp1JUhmZnOHRqdMNoWfu4zDgOCB/wKtm3lwht8WQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4592 X-Rspamd-Queue-Id: CBC9C4211089 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=izPf25QU; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf02.hostedemail.com: domain of brijesh.singh@amd.com designates 40.107.93.59 as permitted sender) smtp.mailfrom=brijesh.singh@amd.com X-Rspamd-Server: rspam03 X-Stat-Signature: ko98z3m6kgrn5h78pjo6rbupcd3oxnam X-HE-Tag: 1622643116-157834 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/mmu.h b/arch/x86/kvm/mmu.h index 88d0ed5225a4..005ce139c97d 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -114,6 +114,8 @@ static inline void kvm_mmu_load_pgd(struct kvm_vcpu *vcpu) int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, bool prefault); +int kvm_mmu_map_tdp_page(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, int max_level); + static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u32 err, bool prefault) { diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 7991ffae7b31..df8923fb664f 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3842,6 +3842,26 @@ int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, max_level, true); } +int kvm_mmu_map_tdp_page(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, int max_level) +{ + int r; + + /* + * Loop on the page fault path to handle the case where an mmu_notifier + * invalidation triggers RET_PF_RETRY. In the normal page fault path, + * KVM needs to resume the guest in case the invalidation changed any + * of the page fault properties, i.e. the gpa or error code. For this + * path, the gpa and error code are fixed by the caller, and the caller + * expects failure if and only if the page fault can't be fixed. + */ + do { + r = direct_page_fault(vcpu, gpa, error_code, false, max_level, true); + } while (r == RET_PF_RETRY); + + return r; +} +EXPORT_SYMBOL_GPL(kvm_mmu_map_tdp_page); + static void nonpaging_init_context(struct kvm_vcpu *vcpu, struct kvm_mmu *context) {
Introduce a helper to directly fault-in a TDP page without going through the full page fault path. This allows SEV-SNP to build the netsted page table while handling the page state change VMGEXIT. A guest may issue a page state change VMGEXIT before accessing the page. Create a fault so that VMGEXIT handler can get the TDP page level and keep the TDP and RMP page level in sync. Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> --- arch/x86/kvm/mmu.h | 2 ++ arch/x86/kvm/mmu/mmu.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+)