Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5769392pxv; Wed, 7 Jul 2021 11:18:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc9x2Lhdc7Qj+yjUwSsthZM3megoib14ydkePEsY53hqfNPaLAMezNcAoU2ueh0bRbC2LE X-Received: by 2002:a17:906:d54e:: with SMTP id cr14mr22682753ejc.38.1625681925765; Wed, 07 Jul 2021 11:18:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1625681925; cv=pass; d=google.com; s=arc-20160816; b=J37jqTUSugpO0xmblAYtFEHBRTzz4qN0f1hPNrLPKpxW7vKmObBe5OXyWSSehssE+p GlPnu1c5Tp/ORurqD+pF0nvZNAXWE1wAvJ/qvKxBt9DaTKOUlD2PB722mSozmfJHRs9a PQyQKVYNHL9WP85UIeIxZoXeSZQvjdOYvK9WrC4SqeKDAjVMAIWmEFFEy2tp2Os6An1b S4rnLlFLDVn1g6s/Bu/LU3de0gvBbSozqb/9XmwWcJx79mHh4t34Nd7RxFOQP65UylY8 NPqom+6Wc7XpcdWJv8TU/3w/bjwWYBYtjs2qtFmaDNSQ+v0jtXdKsOfRhOBLgz5sFsrQ 00Vg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fcyoz5aUvbLHR2AC0SIalCexZMW2z/HEutwVqkx1aPs=; b=v6EH5qYzDjN3r86WQ0FN51N8W8VBjInvSby+yV4n0d902FoGOHYguMNZ6EGEZF4iuY wVuhyAtyvEY7yMa+qmcgGzu//5yOYSsa/4RN+DVQDaQ0Fr5gXr3EOWeeuRZo3Y+yRPZm wLWeX9cYd4cJNnlsg9VyB6mQxAS9auv2UHadS7DLZLj9jK+tUIGWB5DFj9QWaTEzl73B 6L0yQhV3+t4YykhOzohaSUtinSP0g3diMtT++J0urzEypF9ySlC5JYSCtRruJp7n3MP9 wobpsy5sbSZokvtdg4W8F/sW06K5+tEEuAL8hTlj3JapPEkE880Nbj16yCZvHCGWSnSw ot9w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=LtciZA8i; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id js17si14542317ejc.297.2021.07.07.11.18.22; Wed, 07 Jul 2021 11:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=LtciZA8i; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232408AbhGGST7 (ORCPT + 99 others); Wed, 7 Jul 2021 14:19:59 -0400 Received: from mail-mw2nam10on2073.outbound.protection.outlook.com ([40.107.94.73]:17601 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231755AbhGGST2 (ORCPT ); Wed, 7 Jul 2021 14:19:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VrJinAzbDw6leG9de3XeUW1Fk3fAPcjLTAq4Z61V7r+xqrXWCEwdTw0+HSQVKIIcuJZrmHPiq9ui84Zm7/ZBJ0248SW18Jd1WxRb10ONWlaR3AWR4a/IwhDdXPVWHQohYB6q4zM7ZBsVT4JvNW9b66nqU/EaOc6xTa3sBbSphd8az/RJSqZaHgabzaEVqSMAFQkCU9syEd1r2/IAGvsM00qFbRcuUWFFUOtvv/LtjUyDSxQzqIw8WNDGvEvVDrGpjiVa7ta4cexG+qIXJSednLibJv+Ba5vdPRtnNMFUF/TMpsxXXeKAOAZjS6ZmE6hl6ztaNdBt3CUvo9kefDHtNQ== 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=fcyoz5aUvbLHR2AC0SIalCexZMW2z/HEutwVqkx1aPs=; b=jCsSMuIE0AeN/CqP4Vj9EnHgkUBMUXwsGioRonbp0Bj/rcKPFUGEru3xNwyO/GNr2Sv7onL27OOZAE9gsujsv7a4AxrwmvenICAzuCmkYaXE83m/+aImgdzM8DoG05qB3i7J7gT90SgT5TCcR/PXwpbOLL/nlVXl3ik8OSiHhFTqZKRB2QAY2wGNRV/PZlTLSf6FQ6hjUpXJtBAexTZ2Acdua0rI0DAa5xKKRo2lXQCCQQpehK9wysTLHgCCSiFeQOO4s1YledtspsE0evoUdSL40qzQxGyWmOIYi2FQf0cfrOJaBpPotgFjor/UqVy1SPX3klSmmDMPqi8uC7LVqw== 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=fcyoz5aUvbLHR2AC0SIalCexZMW2z/HEutwVqkx1aPs=; b=LtciZA8iMEl0eG5qIibvgzoNzN7BEDPWUwu1LhIIn7XiNfsFRTfd4jrJXd+Hj3X5TKn72x/xXfq+VbdefKd5BNkeuSZyKIT8rs+wn3q+adZIkNDmp93xEEBmJiUxtWOZ/0cHv67ilxeljhsALCiDm+k3qHvYx7/J96WGtEWeGkA= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=amd.com; Received: from BYAPR12MB2711.namprd12.prod.outlook.com (2603:10b6:a03:63::10) by BY5PR12MB4644.namprd12.prod.outlook.com (2603:10b6:a03:1f9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Wed, 7 Jul 2021 18:16:08 +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:08 +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 16/36] KVM: SVM: define new SEV_FEATURES field in the VMCB Save State Area Date: Wed, 7 Jul 2021 13:14:46 -0500 Message-Id: <20210707181506.30489-17-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> Content-Type: text/plain 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:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce648527-c3be-43ca-f235-08d941734a88 X-MS-TrafficTypeDiagnostic: BY5PR12MB4644: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nOW+guXPaU4CbIQglm1gr8l6aFQ0J30BHFyjTeXdAR1tHk9GqpnmTgf3HYvhXGXiObt2UQRlCcOMucUk1JSbfrqz1nbVt7Riw7cFJwOYwx2xeSUjSsZdxzzyWAhASw9UmNwW3zqM0NqnbXWCZdiZSzud5HMw7Kv79tXp8l9AvufI5hqHS50Gh1mWP8d/tmg9EmnomlWnNC/JeXjarIfo2md3MLjzVrDQ8V2IbxlgECYhI7QDKra9kN0watHKNfhV68HmFkLMh4diNiH3nUtXr6xJsYA3Zc1JzlG1FoNDC4xll0bHGUCvp/1zBe6GFRN30POpD/J4P8xqxXiGka6N8sGP6IDEKr4THMnN1yWTt1M6ZMFrSrj79PXuQvQtEuoISqJUBPWboU65cc57L4HTnRLc06JkE3l13d/7qlGrP9gbQtutJ4nEPNTIn/XsaBtHseRpe02p7SZkolcXvJ3/FsXIUCq5h3BbpoLrJt1PeoO04cIkNbA6AaT9n8//HCKZck9E2yyVYUvg7tRj4a6Woi8sNlowUnvutU8sBWE5yynZr15VDD4HvgJhDMDMfvb8/E1AZKiOekKX2BGhKhCk0nipSr7SOVR20lULwYRChNcy+sXkKPwPJqfNXoULygC/h6K2kUDuiDLVm+ddppi26FauxIxs5tAJEMeFRxCGzFd1dPNIa3hfnXuNFD9rTqjf8nW4XsFGbAkkvkVUX+6DaQ== 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)(136003)(346002)(366004)(396003)(39860400002)(376002)(186003)(6666004)(2906002)(1076003)(4326008)(83380400001)(316002)(6486002)(7406005)(26005)(52116002)(7416002)(66556008)(8936002)(38350700002)(5660300002)(956004)(36756003)(38100700002)(478600001)(66476007)(44832011)(7696005)(2616005)(8676002)(66946007)(86362001)(54906003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?elEEzqqobmjRDWRowTxGWfU4vclYhzMTKwsc582m/kvcL1dzLiCvFwO0fNIw?= =?us-ascii?Q?yXpFVBGDxNzlpzFvTj9MuKZSyoCLWb8w5fzTm2RFz6TMYY4/KKV9TIbqZADr?= =?us-ascii?Q?TrgrjOcjgta2iea0VdmZ7kfoxpQrkvLNbJjPhmaNWLIfdI7087gYfdHSgIrK?= =?us-ascii?Q?0/sAMmNjkStwGe81kGye/ochMS9S7Kc9sVdy622+4Otow+wfJ0Adv5Rz1S3C?= =?us-ascii?Q?q2CQ7EkSfcFOoFbLxc6YKVvlX9HsT6YQGqwgdKGvThXFfdYqLw0mSmZGfsTz?= =?us-ascii?Q?pD1ggsNNNF3hBhiUlAc8uaKAlcySJHmUWgv/VwqGbTse+Ont1KjgPe0csGoU?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Em7Th0K7dfUUieW7qhqHdV5nZJk0R+vRl2nbW?= =?us-ascii?Q?8NmF6dQ+QAwoeRYP4lHQ46T2bo1qG+2J0nEJTSykXfoWgbx9bb2nTbi092j/?= =?us-ascii?Q?pZxUYnOcB1RMub+HAfd4QX1l?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce648527-c3be-43ca-f235-08d941734a88 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:07.9068 (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: WdpX41fwvi2sL+vKOklu6bxRBNYFLmx8TQ69M5uzahzvkHsx+mm5bNLbwvB1FgVfRSsftp/yjgOSqn4uNoamFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4644 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 | 15 +++++++++++++-- arch/x86/kvm/svm/svm.c | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 772e60efe243..ff614cdcf628 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -212,6 +212,15 @@ struct __attribute__ ((__packed__)) vmcb_control_area { #define SVM_NESTED_CTL_SEV_ENABLE BIT(1) #define SVM_NESTED_CTL_SEV_ES_ENABLE BIT(2) +#define SVM_SEV_FEATURES_SNP_ACTIVE BIT(0) +#define SVM_SEV_FEATURES_VTOM BIT(1) +#define SVM_SEV_FEATURES_REFLECT_VC BIT(2) +#define SVM_SEV_FEATURES_RESTRICTED_INJECTION BIT(3) +#define SVM_SEV_FEATURES_ALTERNATE_INJECTION BIT(4) +#define SVM_SEV_FEATURES_DEBUG_SWAP BIT(5) +#define SVM_SEV_FEATURES_PREVENT_HOST_IBS BIT(6) +#define SVM_SEV_FEATURES_BTB_ISOLATION BIT(7) + struct vmcb_seg { u16 selector; u16 attrib; @@ -230,7 +239,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; @@ -295,7 +305,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 e088086f3de6..293c9e03da5a 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3184,8 +3184,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", -- 2.17.1