From patchwork Wed Jul 7 18:14:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 12363469 Return-Path: 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,USER_AGENT_GIT autolearn=unavailable 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 CF7CCC07E95 for ; Wed, 7 Jul 2021 18:32:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 76F8961CBE for ; Wed, 7 Jul 2021 18:32:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76F8961CBE 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 662856B0080; Wed, 7 Jul 2021 14:32:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 638C96B0081; Wed, 7 Jul 2021 14:32:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48BA36B0082; Wed, 7 Jul 2021 14:32:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id 222EF6B0080 for ; Wed, 7 Jul 2021 14:32:25 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7D480235A9 for ; Wed, 7 Jul 2021 18:32:24 +0000 (UTC) X-FDA: 78336637008.37.A056FF2 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2059.outbound.protection.outlook.com [40.107.94.59]) by imf12.hostedemail.com (Postfix) with ESMTP id B09FE10000B4 for ; Wed, 7 Jul 2021 18:32:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mlmiLKHXbqrZBwsy3oHqBXLNUypX3wbEJHCovvSIFvWjf4fi3ufrNzCceA2Wzo5sSdmuUGO5S1Cgs7KMfDbtZdHFR9gNX3EuclD5ZRQbeM3FcEvHXdhlhhyS6aOllA5qQT1fEp7Qj0HzwB68CblPVj4qc5VwniweS0z+lI7w3zeCs7WuN3gfAir5MlXkuCFsDFhiWfo8jn7DaG0z3caJCdHC6F7GsReBhxm+6H5+qsC6p9kTYISz3f7k8hYzTbiO0umScOCIHIOorukMrnCR555pU78hoGtrYfVj7EnsG3z70eH3SnBcLLE4klRPheHUE+6iCZ/UFvID5qCtp3nBpA== 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=EBt8/TPmDL1A3YsvTSKCK8gVuH33bPFiojteShvsYIs=; b=oHiIlk1N5+8I42QkBW+36XUSoZX/f1f95MX4ff8ZhdspuDPc645fdMh3w5nKnqMpaQWnvRET5yyojVc8ETbETpbijmVIp08QN838O+pl6Oy50ITkLG2cbPOrF/yIxtWuV2dd0dCjX63Goz+h+9JOY3hG5NEfvuMqqVEsBk3w74TefX+P9F2pqB9LWwmouzOak10sxK4VZyoA0yuhCbn9ULd+jKFQk5Z8jp49S1pzaWrxAfH7W8PvIjdSqYFW3Fhh+l0rbaImvdRgLc1CqagRMGTmYCtUygOBVFGCl4/GKgBRtdPrc9fgGpSrKskdo+CyIoqbjJysvx061LcmfkvAxw== 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=EBt8/TPmDL1A3YsvTSKCK8gVuH33bPFiojteShvsYIs=; b=3o2BsnyCm83F1JLQAVX5jAVACu6AkmMBeEMPMYljUVX1OknDtnGMFDFcl7O/yBl5FO+qFmPNIGirGulmpb69a8milc3WZa29iRjH5Sx0LJNC8A44b2RUFlyKnQq3c+6TDpIGSK09I5/7H1V2gleLiariX3yzfURvldkp53ZslFI= Received: from BYAPR12MB2711.namprd12.prod.outlook.com (2603:10b6:a03:63::10) by BY5PR12MB5016.namprd12.prod.outlook.com (2603:10b6:a03:1c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 18:16:16 +0000 Received: from BYAPR12MB2711.namprd12.prod.outlook.com ([fe80::40e3:aade:9549:4bed]) by BYAPR12MB2711.namprd12.prod.outlook.com ([fe80::40e3:aade:9549:4bed%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 18:16:15 +0000 From: Brijesh Singh To: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com, Brijesh Singh Subject: [PATCH Part1 RFC v4 19/36] KVM: SVM: Update the SEV-ES save area mapping Date: Wed, 7 Jul 2021 13:14:49 -0500 Message-Id: <20210707181506.30489-20-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707181506.30489-1-brijesh.singh@amd.com> References: <20210707181506.30489-1-brijesh.singh@amd.com> X-ClientProxiedBy: SA0PR11CA0104.namprd11.prod.outlook.com (2603:10b6:806:d1::19) To BYAPR12MB2711.namprd12.prod.outlook.com (2603:10b6:a03:63::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SA0PR11CA0104.namprd11.prod.outlook.com (2603:10b6:806:d1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Wed, 7 Jul 2021 18:16:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f7626f0-7dc4-426f-1441-08d941734f36 X-MS-TrafficTypeDiagnostic: BY5PR12MB5016: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xppIfKs2pOnKfOktzBjj1xJSEnGuPnYKzrLx4DYqBgYbz4T4qmrSQ/fhNmDtfrvQHMkUEY6I8ZpdqNzER9rWcwQEf+IIs1OxwNaY9LA9hxl4Znokhm6oBwTc4YOr8+/0yWzt9Pwgooa7iqmrzLSLZI01MwE3EQeOmhSNfVhdaZi6qeCM6yzmPPHhco/0JhK2mq8m2sx5IVBf0T1uv5EyNurrHBHzNNTCBx7q/o+Fiotr3kYMWlP/vZ+tlnFi6PusnyIqW6UgRiE31G1Dap0gGHsypyejIuPWbXHQmPvNsECrRb0uA1HWE5cXQVdm5u8rl1yNGwKr2uMq4zxXnvWw0TUy/QBN9FXLY/KWSxY0+AD8H7Q9FqreyV4A169By36p27Yu9tsLR1ai3+dKkYXlhNHbSwAsXxBUwj5BfwuiDOfhvazKDUE0mLzz6PKkD0nkcR9vospQUIpaKzLPDHuAyKRKrc3LW2z/BxcVDlCJZ5sxcyAegRxo1sjFlQUnAXB9k5knTa77lSm2G9l1/1FpRsSb19BYzD8a6mqZd1AU/561vrI6KRl8VRQumMwa8FpiJtbJeLCgzibZ04YmxgBV40aB8RXIeoHxwHbYMHYfChEMFOlHmflE/WqUt8KUGY5h41pym8tagle2dzmylPzJm2PAZVP7rMa5MkWORDxMsgQUQsO61O8lgik+CgAVJZa2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2711.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(376002)(366004)(39860400002)(136003)(66556008)(66476007)(186003)(7416002)(52116002)(15650500001)(86362001)(26005)(956004)(8936002)(478600001)(7406005)(7696005)(8676002)(83380400001)(5660300002)(2616005)(38350700002)(38100700002)(44832011)(2906002)(1076003)(54906003)(6666004)(66946007)(316002)(4326008)(36756003)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CjuuH2n2QqJtX/wL5NuM/FbuX46iOMvf7bmWRwU0ymJtTOMazz/i7oR4MR46L+RWiudxttra4dy8LtAHybAl+8mbzAw8l0ZsG/o4YvWZmtSpFa7Mg+jCuf80A6pi8lug9ybeOOjeoRs2Boc+jhOEnR0vR5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i0Acr+tf1wFqbltrctJgH1xBQmtudYLTeL75t7c9y6auAoUEsu0K2Z8r28l+s698wa2Wski4InKJXBpx4GZq44d5M7wsA8LycBN+GO47O7sQrXjsdIq X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f7626f0-7dc4-426f-1441-08d941734f36 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2711.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 18:16:15.7753 (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: 9cgIoGoN1kIUd02ou6hr2S0erUi/bG7vjBgIecEhZ7SkT6+H265v9j38rvSCyApa+ccEQwTEBmzZYnGwdQqFsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB5016 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=3o2BsnyC; spf=pass (imf12.hostedemail.com: domain of brijesh.singh@amd.com designates 40.107.94.59 as permitted sender) smtp.mailfrom=brijesh.singh@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam05 X-Stat-Signature: spxkt1n4pc3w9qe8a5o8xbmmdro945wm X-Rspamd-Queue-Id: B09FE10000B4 X-Rspam-User: nil X-HE-Tag: 1625682739-625076 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: From: Tom Lendacky This is the final step in defining the multiple save areas to keep them separate and ensuring proper operation amongst the different types of guests. Update the SEV-ES/SEV-SNP save area to match the APM. This save area will be used for the upcoming SEV-SNP AP Creation NAE event support. Signed-off-by: Tom Lendacky Signed-off-by: Brijesh Singh --- arch/x86/include/asm/svm.h | 66 +++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index f679018685b6..5e72faa00cf2 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -291,7 +291,13 @@ struct sev_es_save_area { struct vmcb_seg ldtr; struct vmcb_seg idtr; struct vmcb_seg tr; - u8 reserved_1[43]; + u64 vmpl0_ssp; + u64 vmpl1_ssp; + u64 vmpl2_ssp; + u64 vmpl3_ssp; + u64 u_cet; + u8 reserved_1[2]; + u8 vmpl; u8 cpl; u8 reserved_2[4]; u64 efer; @@ -304,9 +310,19 @@ struct sev_es_save_area { u64 dr6; u64 rflags; u64 rip; - u8 reserved_4[88]; + u64 dr0; + u64 dr1; + u64 dr2; + u64 dr3; + u64 dr0_addr_mask; + u64 dr1_addr_mask; + u64 dr2_addr_mask; + u64 dr3_addr_mask; + u8 reserved_4[24]; u64 rsp; - u8 reserved_5[24]; + u64 s_cet; + u64 ssp; + u64 isst_addr; u64 rax; u64 star; u64 lstar; @@ -317,7 +333,7 @@ struct sev_es_save_area { u64 sysenter_esp; u64 sysenter_eip; u64 cr2; - u8 reserved_6[32]; + u8 reserved_5[32]; u64 g_pat; u64 dbgctl; u64 br_from; @@ -326,12 +342,12 @@ struct sev_es_save_area { u64 last_excp_to; u8 reserved_7[80]; u32 pkru; - u8 reserved_9[20]; - u64 reserved_10; /* rax already available at 0x01f8 */ + u8 reserved_8[20]; + u64 reserved_9; /* rax already available at 0x01f8 */ u64 rcx; u64 rdx; u64 rbx; - u64 reserved_11; /* rsp already available at 0x01d8 */ + u64 reserved_10; /* rsp already available at 0x01d8 */ u64 rbp; u64 rsi; u64 rdi; @@ -343,16 +359,34 @@ struct sev_es_save_area { u64 r13; u64 r14; u64 r15; - u8 reserved_12[16]; - u64 sw_exit_code; - u64 sw_exit_info_1; - u64 sw_exit_info_2; - u64 sw_scratch; + u8 reserved_11[16]; + u64 guest_exit_info_1; + u64 guest_exit_info_2; + u64 guest_exit_int_info; + u64 guest_nrip; u64 sev_features; - u8 reserved_13[48]; + u64 vintr_ctrl; + u64 guest_exit_code; + u64 virtual_tom; + u64 tlb_id; + u64 pcpu_id; + u64 event_inj; u64 xcr0; - u8 valid_bitmap[16]; - u64 x87_state_gpa; + u8 reserved_12[16]; + + /* Floating point area */ + u64 x87_dp; + u32 mxcsr; + u16 x87_ftw; + u16 x87_fsw; + u16 x87_fcw; + u16 x87_fop; + u16 x87_ds; + u16 x87_cs; + u64 x87_rip; + u8 fpreg_x87[80]; + u8 fpreg_xmm[256]; + u8 fpreg_ymm[256]; } __packed; struct ghcb_save_area { @@ -409,7 +443,7 @@ struct ghcb { #define EXPECTED_VMCB_SAVE_AREA_SIZE 740 #define EXPECTED_GHCB_SAVE_AREA_SIZE 1032 -#define EXPECTED_SEV_ES_SAVE_AREA_SIZE 1032 +#define EXPECTED_SEV_ES_SAVE_AREA_SIZE 1648 #define EXPECTED_VMCB_CONTROL_AREA_SIZE 272 #define EXPECTED_GHCB_SIZE PAGE_SIZE