From patchwork Fri Aug 20 15:19:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 12449405 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 EF65EC432BE for ; Fri, 20 Aug 2021 15:21:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D156611C8 for ; Fri, 20 Aug 2021 15:21:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D156611C8 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 84E908D0002; Fri, 20 Aug 2021 11:21:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D1F98D0001; Fri, 20 Aug 2021 11:21:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33A418D0002; Fri, 20 Aug 2021 11:21:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 1382E6B008C for ; Fri, 20 Aug 2021 11:21:19 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C02AC18481CA5 for ; Fri, 20 Aug 2021 15:21:18 +0000 (UTC) X-FDA: 78495822636.09.F645F94 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2079.outbound.protection.outlook.com [40.107.95.79]) by imf13.hostedemail.com (Postfix) with ESMTP id 5CB48101D0D7 for ; Fri, 20 Aug 2021 15:21:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RRWn31ejX2RVtiMUhkGn34Yfr6NibhzvMhYMF4CoLSs9GVx733OqPJoUwUQhwJRaCCTd2gmA6QkD6MaraQpk9v4U/kIXs5gUMZqJbQhlHX9bIS6BrzP9xGmSlSiQQ/Kynb7ulRgIV+zefjNKuSgc2lpjR9ZDM3GeDMpkUfz/3XV0Ml3iYHueS7TnvVF8sg1h9PGsj/i+L0PzPCcNYlulz5PEWvJVfEqnb250+NMFFugp9iKKXLhxRZJuAxuT2JvaEYt/f2qmlTVOBTUtSUKS9AgzWCGU6qyN+5QufwKKp03LEc25jfczKp5E2cThrW+mLio+Ue+R4hi+XnJxIL5cyA== 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=nFyCnzIPinv/+8QkBlkc8Nj8XYKgOu+lQrVr+RAOJiI=; b=VSFf22ZCWH9mWdd0sg0rApZqmicA+1nB0iAQ1MrZEUxOBHyqMZRw6hdIeq5sfmb5UNiGTDf0lEb5kaxKEbx0Nj7iUZ41gWbRFZpVJatEDMrlf+tch9wchoW1mQBphgHm97+hiBRb96CLPfeb65/lDIKWQW6SvhgvbnMiKXPLbfm1ElHKcDR6g7SSYgTKBcz/f+NmD3uWeBYZwgBpvWjBfdsU2hbVT9qUVuvnid/97zyj/xSe/w+XZmka7noDbAdybBnFuWO1sFE2dsjVhOsH9eWc6K5avjmahiwdKoSmSMxumy0p+HIvwXEyex9002qUo4JWbcGKQ+8BP4HxwSIaxA== 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=nFyCnzIPinv/+8QkBlkc8Nj8XYKgOu+lQrVr+RAOJiI=; b=Y1SF+QF5kLcZpXiXZKClKuARjIO47aONJPH0zdAL+49fUB4tglklY1541ASBYeH16j1FjHLcrBRoOt+VyQLPIg58b50n6O2T6qozVSg6hx2o9FCjygVnLs1Jjqf0+9V+2DiMAD4nt365ZJ046l4ulXhXZ+k2jSyi3QlDU/xPiIA= 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:10 +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:10 +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 18/38] KVM: SVM: Define sev_features and vmpl field in the VMSA Date: Fri, 20 Aug 2021 10:19:13 -0500 Message-Id: <20210820151933.22401-19-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:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15f3c0ec-bd06-40f8-835d-08d963ee23d0 X-MS-TrafficTypeDiagnostic: SN1PR12MB2446: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RHryrdF+ULNnpOzaM1PMg+YLfM7aDgpjZEsjY2HIysl1AQ8DDHNJvsM3swyWFdqU8toKjaf+Nm6Dw/Jt5e1fHgYcLArvbsAMReD+uWDNZ0tpWez+eTS9nbclofNHN38xCpWU45gAIe0Ug1cScU/Q47EiNEVAp5176xMqXzHi56I7sL9R/ylZmHJtZtKbN1Zcr0lLeM47XSPF5wV30GY0RiT+/qRCU9bVm+OqbyztKOYoTVS5Mx5qv+WEyK824ZFhBXAO0cP01pyzCUwXpxdwXPPciKtn9pH3/FxzfEY/9RkIzODgvK2bNznn2cIjXndUB9ivkm+ecFODwR2hOSN9N8kBXDiAdwMxyoQCelgTCCRURaRW7hAC8bB0p+S7S85kSjRV322t4CZNBP2myuxBuTAyBj7tSOUbivbBwj7KqKdO8avY6GQh2LIchhvlCGNe1LyLtDfWEdM04CtMEVRWBpr4oFw0hFKwlukhfwujJsDQqSaDmcKusmpFO3WOiHfhCjTJosDQTZiYzPuvx2moNzY9tXBgdRHq42e+KxYeeQ2V/0Z6ogSdEPR9hgKxjHs5N645UWYl6QB6Ju4GcVJPjl7T7u88JG2cc6fjs2thWiA6AeDhi3mntbJN7/S6VdZFpmHxU7Px10muCz85OhtcWRwc+G7sOGx9FJLVNZbbzYX4f0BrIGxqwtXEGAGXfflIzN4YIeQYFExKP+ljFJSv1A== 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)(2906002)(316002)(66946007)(86362001)(66476007)(44832011)(36756003)(956004)(6666004)(5660300002)(7406005)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AT+CxfuEhLBhrPt7gaJCXNW7xLlJIoI9P96cDb32EocBHtS+fxkQK75sUl0FpJqoC/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2oi162WQyJdgM1nwo+AlV8O7Dh5XeR1DB0cfVAfB+XtsZ3vf38cMaVPOTPxlDnu/yKAQfmDsV9HcikYcQyTci8LtBFlYVpslnVhBM13jdRXMrIpnGbj2vF+dfu6bwQUS/0BP/BPRygOQUfhPat5njSSPVUIXYVOFaNkwOxBTuaFMDy/TUqhNXqMR9wSj9VbXyzpo3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15f3c0ec-bd06-40f8-835d-08d963ee23d0 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:10.6168 (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: bX7mwwalk8LbosEIEv7VT1pKlp+RfQ7KDEMnEOWCZ8MLNg3Ld6jQH22FTbuu3CL0uAdaWmTEICP4Gs9pc3HJ1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2446 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5CB48101D0D7 X-Stat-Signature: 8ahibcgxod7qhhqh1bsc3m1iiq94yxze Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Y1SF+QF5; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf13.hostedemail.com: domain of brijesh.singh@amd.com designates 40.107.95.79 as permitted sender) smtp.mailfrom=brijesh.singh@amd.com X-HE-Tag: 1629472878-17245 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: The hypervisor uses the sev_features field (offset 3B0h) in the Save State Area to control the SEV-SNP guest features such as SNPActive, vTOM, ReflectVC etc. An SEV-SNP guest can read the SEV_FEATURES fields through the SEV_STATUS MSR. While at it, update the dump_vmcb() to log the VMPL level. See APM2 Table 15-34 and B-4 for more details. Signed-off-by: Brijesh Singh --- arch/x86/include/asm/svm.h | 6 ++++-- arch/x86/kvm/svm/svm.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index e322676039f4..5ac691c27dcc 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -236,7 +236,8 @@ struct vmcb_save_area { struct vmcb_seg ldtr; struct vmcb_seg idtr; struct vmcb_seg tr; - u8 reserved_1[43]; + u8 reserved_1[42]; + u8 vmpl; u8 cpl; u8 reserved_2[4]; u64 efer; @@ -301,7 +302,8 @@ struct vmcb_save_area { u64 sw_exit_info_1; u64 sw_exit_info_2; u64 sw_scratch; - u8 reserved_11[56]; + u64 sev_features; + u8 reserved_11[48]; u64 xcr0; u8 valid_bitmap[16]; u64 x87_state_gpa; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index e8ccab50ebf6..25773bf72158 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3237,8 +3237,8 @@ static void dump_vmcb(struct kvm_vcpu *vcpu) "tr:", save01->tr.selector, save01->tr.attrib, save01->tr.limit, save01->tr.base); - pr_err("cpl: %d efer: %016llx\n", - save->cpl, save->efer); + pr_err("vmpl: %d cpl: %d efer: %016llx\n", + save->vmpl, save->cpl, save->efer); pr_err("%-15s %016llx %-13s %016llx\n", "cr0:", save->cr0, "cr2:", save->cr2); pr_err("%-15s %016llx %-13s %016llx\n",