From patchwork Wed Nov 10 22:07:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 12613177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E708AC433EF for ; Wed, 10 Nov 2021 22:09:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 928276128E for ; Wed, 10 Nov 2021 22:09:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 928276128E 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 28E6F6B00A6; Wed, 10 Nov 2021 17:08:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2296A6B00AA; Wed, 10 Nov 2021 17:08:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4C4B6B00A8; Wed, 10 Nov 2021 17:08:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id CF91C6B009E for ; Wed, 10 Nov 2021 17:08:39 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8B73E1803670B for ; Wed, 10 Nov 2021 22:08:39 +0000 (UTC) X-FDA: 78794410758.17.0A81EEF Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2055.outbound.protection.outlook.com [40.107.94.55]) by imf04.hostedemail.com (Postfix) with ESMTP id 7902150000B0 for ; Wed, 10 Nov 2021 22:08:28 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iDbEz2taQ1o9kave821SvDrYxYG6L0gmU+qYIJ6lfp4RJDZeCNM46FNT5bUkm9bScUOsiy6XTmJoufeSiDPISL8anf9CXs4mlrewQ768SVZKjDdleB/WJl6tmKrq5V2WRdzWKmvN+4FzHN0FW6LqncExfnyv1BucUEpGHTjKB1lBenqKpTg/z73yEAsEfjNjq0styrE4wBZL9bOwA77mWyUeKFqZpSNsVXA9SF/d3LmVMgeC0ts5igfPVBBvDYVresZLl1I3MA3qkBuQlESr2d9z83R38JTCEbWeYMNGOQsnsucL4ciAWpQ8s13Fh63YC8rOA4TsxdWtNBvyNvmS4g== 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=5yYGZkXYbkKsCZF4e6t1+n+SfDJC4kr8FCySTr9HpfQ=; b=DZ3K1ahMBIgpya35INtRsJ6zJPCexprO/WtL1m/HpansYPCjWY9GrNLyMHdNZJiocwG8X/hUb+VozLwc1WUf6c7qZpqgowuFF7cvjWjJgiAqkV4d4pI5GncpHGW+Zfm502EHI8w33YxQtI8evb9ysycORVvKTUYdnwn/cGsTf0OyhETRKlmn55t0mJlynKVJ+7SM0qF/xD/NhS/BaYLQTOY90DU/Rwmg7unt8eXgYt0ffWUAjLhZZ8065dfc1FeoO0OvJheAq8fH3PVte91Y089klczGB5qSt6JNZYKP0EQXZlmJ9JtSlyUIo7acGBoA1zIjvLqroWkG5wqkZ+oHMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=5yYGZkXYbkKsCZF4e6t1+n+SfDJC4kr8FCySTr9HpfQ=; b=yoZOpMZQBhBSUefpf1N2q2yxnGJRVktklMKEqsebPfIU3FxdGCN07psIe3u/pNgjH/7aivzqyosuaw97AZhlO4G04AAgYwZ+QKGsRxu/DleV+ZXSKCreYRMyVzLfBMoeBxo3F9J1YF6Hkji2Pygf5D410eTt5zgSUJ9IC4PVZQ0= Received: from DM6PR21CA0020.namprd21.prod.outlook.com (2603:10b6:5:174::30) by MN2PR12MB4797.namprd12.prod.outlook.com (2603:10b6:208:a4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Wed, 10 Nov 2021 22:08:34 +0000 Received: from DM6NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::29) by DM6PR21CA0020.outlook.office365.com (2603:10b6:5:174::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.2 via Frontend Transport; Wed, 10 Nov 2021 22:08:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; 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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT044.mail.protection.outlook.com (10.13.173.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 22:08:34 +0000 Received: from sbrijesh-desktop.amd.com (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.17; Wed, 10 Nov 2021 16:08:30 -0600 From: Brijesh Singh To: , , , , , , CC: Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , "Vitaly Kuznetsov" , 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 , "Dr . David Alan Gilbert" , , , , Brijesh Singh Subject: [PATCH v7 24/45] KVM: SVM: Update the SEV-ES save area mapping Date: Wed, 10 Nov 2021 16:07:10 -0600 Message-ID: <20211110220731.2396491-25-brijesh.singh@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211110220731.2396491-1-brijesh.singh@amd.com> References: <20211110220731.2396491-1-brijesh.singh@amd.com> MIME-Version: 1.0 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-Office365-Filtering-Correlation-Id: e04016d0-08a0-468c-14af-08d9a496a387 X-MS-TrafficTypeDiagnostic: MN2PR12MB4797: 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: JuSoO/X4FzRmwYOzObxHIKNZbtTslYraPeDHE8DM5suqM72pW6r+qmyWsUZyg1cxTJn+oPJOOBhmQlcEp2oEARbjWdHFEyhnF3spxJcc4x4coQnpyGPKEcEwDkSPDX4dCPwGfC582x1GqabiIENoB/2kXkdfvPgdMuax6C7Or6sz/6d3KmzYqzUFtvMeCgry2Ck8rjan1g5hAywwOBL8k+UlnCMd6VfZu9OTJ+OJiWy2+u9YxAvtkZ65SOxQBYZL2hZLvVC3MLmcym2BrwzObH4VLasuGmSUsIyZ16giiqqrq0N9rJ1ekNc/DJV/AUB/J/bki12Ee9WljJxQO4RWHEyRY7HRGAb5pd0005fHY/Lw3b4Azjid9PqjJK0x1wSx7LZPpvKXOamDQE/gWFcJH/EsP0SgHdX5js+l/7B4D7DuqgNXNR3kyi3nHW/F5ME9Ac+E8JaF0Jaf0efrDvUMDcFcSfRTDRVqEPdgSMvuCdD57VoDGKTKtco5KjLKdjCDrAfTDljq1exbqVMGhwkl9WjEwZT7x6FdjPmU3fHkjvhaGEiX1wyzPaAM33VWI1AqIK+/oCzU0gkjqY4QmCQshtvsTAbH3jd3iiEavLpSJcPYwFs2CkzdMc+8QIhfuixB36V1yMkr09Wt8ZyYldsJEVV+zdNznTL4dQIe8m8RkDuFRbEl8SCw6MBYZ2mjyLc3AXy/hKji48nmRoUYqTmGECvZBCTFRknyxMox51XhGT36B/bilZd5gtcckbbM/kcg X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(16526019)(7416002)(186003)(7406005)(82310400003)(36756003)(36860700001)(44832011)(426003)(81166007)(110136005)(316002)(7696005)(83380400001)(336012)(2616005)(86362001)(70586007)(2906002)(356005)(70206006)(8936002)(8676002)(508600001)(15650500001)(1076003)(6666004)(47076005)(5660300002)(4326008)(54906003)(26005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 22:08:34.4075 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e04016d0-08a0-468c-14af-08d9a496a387 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: DM6NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4797 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7902150000B0 X-Stat-Signature: y894wxkphmoenwyst3mbuycyuh7xxrse Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=yoZOpMZQ; spf=pass (imf04.hostedemail.com: domain of brijesh.singh@amd.com designates 40.107.94.55 as permitted sender) smtp.mailfrom=brijesh.singh@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1636582108-782768 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 5ff1fa364a31..7d90321e7775 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -290,7 +290,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; @@ -303,9 +309,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; @@ -316,7 +332,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; @@ -325,12 +341,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; @@ -342,16 +358,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 { @@ -410,7 +444,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