From patchwork Fri Aug 20 15:19:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 12449415 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,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 B3AE8C43216 for ; Fri, 20 Aug 2021 15:21:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BD9D61167 for ; Fri, 20 Aug 2021 15:21:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5BD9D61167 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C66F28D0008; Fri, 20 Aug 2021 11:21:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1BC88D0001; Fri, 20 Aug 2021 11:21:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 97D3D8D0008; Fri, 20 Aug 2021 11:21:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 7B7DA8D0001 for ; Fri, 20 Aug 2021 11:21:22 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 361C882F7DB1 for ; Fri, 20 Aug 2021 15:21:22 +0000 (UTC) X-FDA: 78495822804.22.994DCD6 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060.outbound.protection.outlook.com [40.107.220.60]) by imf29.hostedemail.com (Postfix) with ESMTP id B82E0900024A for ; Fri, 20 Aug 2021 15:21:21 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kqyAtshYbmi7T+x/SbYBtYY2C2e0V2kA3oc5StZGUzOUa8Q5TFWYhScyfCqoS8uff3ciXjI/wqJRIxw+qIHQVVWgzhZIr8iEfqtFp8h4AqK3BRXloAw03G2vJYgshVMpBgPolrFhOhMAD7hZj4LraFxELWzyK4SJmtpqvmMAXqnDwTK6rRfWMgfj9jf3XiKiqidIDtuG/PN6DgtzPSEmhjqmmy9moLCJEbMI+p2Zx45ghaHDfPCE9Yt5JKEcncxb7KBvbboxw5lDnET7YxxwDQRjaBCAgUT0gjrCWiZyGWzV2E1VWG8gPG9C0FzxcqR9wvTMXUJXDZLK84w1La+zqQ== 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=IdF8q6VgRdbV2LwEZioEQ3Z8CB40ZABdJHS8hah9rwk=; b=coqUL0OpMF4iJHhHpCa5Hk9QQrgVyWwGwnZsDaIRhrC9rhnv3nTUVXKMlH5hyzWFVgiw+SHNzNdv4hnXJRt6P8CiFk6p2lAKxh/g4SagAlHH18LGVmJGStpKC7Ru5dAMv1d44g99dI3bBmkYP+rOu+qZbb4XNBuFN/HMoseQhTHPbs9M7bIzz7QO/5VqZt5/b4brQiHm6iCrPQ+eQozwEcs3xqbAlyOVD20zuea+FXJIqArZMIeY0qFxy2CgArkZb6bb+suCUEX6rKFp5u2ZkKf8oxUikuOLmv9Bb57HvyO2ulojT42lRfUh6cvP+UUU1xDc5U3mB5vnC+/VbKQdfw== 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=IdF8q6VgRdbV2LwEZioEQ3Z8CB40ZABdJHS8hah9rwk=; b=gGgNGWLG8PF4tKkOCrkO00BqQ+0ly4tMIejyUZeGIXI0B3kQc0/yiJXKH/D2uTj5FBjKEfQ9M1sAUzf5HqRs7thDQWS1FFCUqXjZqI9I+oZ3WcTxwCA2xsqYyRkp22Ae/TYVi1My1KqRBdFnp25/LrMUASvnXETuBWMbBLFCifY= Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN1PR12MB2446.namprd12.prod.outlook.com (2603:10b6:802:26::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.22; Fri, 20 Aug 2021 15:21:14 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3%6]) with mapi id 15.20.4436.019; Fri, 20 Aug 2021 15:21:14 +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 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 , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com, Brijesh Singh Subject: [PATCH Part1 v5 21/38] KVM: SVM: Update the SEV-ES save area mapping Date: Fri, 20 Aug 2021 10:19:16 -0500 Message-Id: <20210820151933.22401-22-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210820151933.22401-1-brijesh.singh@amd.com> References: <20210820151933.22401-1-brijesh.singh@amd.com> X-ClientProxiedBy: SA9P223CA0002.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::7) 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 SA9P223CA0002.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Fri, 20 Aug 2021 15:21:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c95f397-8919-4ade-0939-08d963ee263d X-MS-TrafficTypeDiagnostic: SN1PR12MB2446: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K/5bz6kCVimcW3YTTPpm3g1h1plGJF90Af2n2rdYLwMOIxGMr1GKPxv7yiKylG4SuCnlhpW+2evHBaBvkxpQy65mV4Q4xd0dIuQ+oIXWyvkQFZGF073wG3w0JlMHhmJB5msk/Oe3a1n/Y9JJAdotPr6bmFIzcg/RAaw9K0u6afCFkiLArPvUE+SM7YJGjwHYOXAgoT4HXbVf2NBaVTeHzhz2n8jSbysElYOdWKORRXxYJapcXFF8tZ++DAuBAVbgVr787s02INHskA29Z+aARB0ba+8L24u89wBkB5yoLfL8IaDQPZwrDxrWl13PPPDWOoSHCHODy1KQX5xcccxmTKtrCIY5BcMDvhnkIzcb+VHMnCPKUkGlm4CNegvCubV1OkHX351f3czsFsfYBtq1pi/UtSCXUNIEmoGYXsJuzX9o4/sWluukx0xYiHjWLTawk6gtUTXp+/N52es3eB74troZlmV6IHc4K5/3z1W6xbm2PeF6SdocdPckAYBvoeL3L26a//3LbhGqDF+qoaEU3EZLTGbfCd3VOcwt0X7k9xMsSIjDj7KamTW7KAtXeb5JG9MZqfFyrWir9CcJpeAIinfnLVfxb5a005iWjEQWNZ1wcC2gXawqWh6RKAs6nI5kOHSbi3e8E+YC2YiKd2ODwOXpZhPaz/DF0BSsK6RKfri+7WtokBgFWnS88cGf43zZVgS+5XnHBDCxqG3LnL9Xfg== 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)(366004)(136003)(396003)(376002)(39860400002)(346002)(66556008)(478600001)(54906003)(4326008)(1076003)(6486002)(7416002)(38350700002)(52116002)(83380400001)(2616005)(7696005)(38100700002)(8676002)(26005)(8936002)(15650500001)(2906002)(316002)(66946007)(86362001)(66476007)(44832011)(36756003)(956004)(5660300002)(7406005)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2FXOLvxhGqVxBElcDxHVuIphjZye7E/EWnVLv6JpAxtFPsLYiVzepP4RypfQGRsYzx2qI4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oBBAiERpdiHrQ1C46yKX4TbA6RtHy91XS16kuBzAAmgvBQTsJoX72U4Ny124t24dO+OmyRMvVp2UYHOYVNX0osulQzPq/LxHyMjoQImleyRivq9ennE1po+0i5LSL793ail1pZw8YLh5tsWGTrBxcYUhoAQOBxCvZsgpKTqWRu1aX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c95f397-8919-4ade-0939-08d963ee263d X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2021 15:21:14.6695 (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: d62xoTtOu42FjijsElMdcr8L7VYsXbkPr6KT7DoP2gfuL/g0dz2dyzMMnXikDfZFCjmQ0EZ59qg4ln1rtijkUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2446 X-Rspamd-Queue-Id: B82E0900024A Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=gGgNGWLG; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf29.hostedemail.com: domain of brijesh.singh@amd.com designates 40.107.220.60 as permitted sender) smtp.mailfrom=brijesh.singh@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: qa68k8jawzbwyoxs1uo9sozxs4nnwr39 X-HE-Tag: 1629472881-808672 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 748fe1c82a2b..44a3f920f886 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -288,7 +288,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; @@ -301,9 +307,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; @@ -314,7 +330,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; @@ -323,12 +339,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; @@ -340,16 +356,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 { @@ -406,7 +440,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 1024 #define EXPECTED_GHCB_SIZE PAGE_SIZE