From patchwork Sat Dec 30 17:23:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13506950 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F51BC46CD2 for ; Sat, 30 Dec 2023 17:26:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FC7D6B0148; Sat, 30 Dec 2023 12:26:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 283556B014A; Sat, 30 Dec 2023 12:26:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AEC46B0149; Sat, 30 Dec 2023 12:26:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EA1056B0135 for ; Sat, 30 Dec 2023 12:26:54 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id ADC4DC0A0F for ; Sat, 30 Dec 2023 17:26:54 +0000 (UTC) X-FDA: 81624164748.30.28DB4FD Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2053.outbound.protection.outlook.com [40.107.92.53]) by imf09.hostedemail.com (Postfix) with ESMTP id C08EC140011 for ; Sat, 30 Dec 2023 17:26:50 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b="ghD/ytMb"; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf09.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.92.53 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703957210; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NvaO1Gf3fjP+sj6QpMn7AJa5hldQPwteKxYTA1dD8gs=; b=fL20TqSFSG/2W8OMcOMZTU77e43nj12NWiWyymmsfsKjUJuNGbq6Y4uvK5lyfBBJA5YG7i fONLooyG9+Znjl6sVefrYODecclSr9YcbqJjPH95Q7IcuybFmuZ80GJ/eoqKYvomo0vZMS 5ScKx4WzulMPMm87Xp0h907odAtksZI= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b="ghD/ytMb"; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf09.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.92.53 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1703957210; a=rsa-sha256; cv=pass; b=hxllEa+fyysBs13tHKvdkFepKTI+6M7nk97tz7D2vCdFHZ38EoDrv/OwKm6xtZgOGGUKU+ gqYYNIsaszn2F/8KhoZumk+dR1hiyjJCib8SBORW0Am76WHUcy9Wtsgc4oZy+q3eIL4gjw n5X8BH0MfCECffsLlKlRsiWCPgQaSiA= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XOOQBoSDaS2i9M/e0MmJJc6geprrKt0CAXVE9m/csAxYyvfSk6a5qLmUTGcplCgvV3q8aAsxyKif7Rg/Ijxj9hdx975SNkvCDjn4WSgDwdVkljyKWekYF6J1iZp5UUPv2jD5kjhDFf3MjDK/13K2AbVIwzY35btjWNZfkEu5DNyEyvuo2IWkHzUabjjobO76J+b9AY9xdD9Xu+PpfBvO0w5DYSjIYn8KRaH69m0K14B8a8yl+RZ1UM9PmOWLxpFLijS88g+9Osgb59OYOhbPNVXcJ7tPw6xR/YX9K4yh9cGDWJ9Tbc9PQ8ONIdwM1pLbucknJ/mpIzr/sKn2fVcHdQ== 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=NvaO1Gf3fjP+sj6QpMn7AJa5hldQPwteKxYTA1dD8gs=; b=KJ0zxmVdSyr0Sol5TIBBJKc3P8mYnvVcZJnBVTN3JPlsSZYq+FAZ3aPDbelBX+XLhmb8k4OkvDbghMCvDOwqtwhA4R8y+VreHhgT6UeUYCOWbOQtDzBDdLX7p5q2kQEM8GLfs93dXmNB3QfIpTuiHJ/+8KMaxwqRC8qM9a+kzrFXZgdaGmSIWrNWnrcXPP8Cr7bOQgbcz9/hkOWWePGCXoyZ149LlrBwIRwT9pa1lYc39dMZE3jol1SqHhdcmJAoqLNuxYuonOLUnuz/Cs3EucIQ2Z4OhLLSkqIEC7CWwK7NwTvpDJDPUj9kadeIcyuHLnU4F1mj8edOUmg9B9dAVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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 (0) 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=NvaO1Gf3fjP+sj6QpMn7AJa5hldQPwteKxYTA1dD8gs=; b=ghD/ytMbYDgNGvtX4Gxh8gkkG5cfIwF9qz91+yQFg+YivayYftCiJ9c+B0ODV7iT+iujzOrDkqfUDKWiMLfn4L21eBgdniU/rJ2eZvi+1DcNuHeWZD39jzA1cNmNeev21g9ujtkQ/C+HoiLnxxYUmyiIX8zDWt3kPtN+pUqR3rc= Received: from BLAPR03CA0178.namprd03.prod.outlook.com (2603:10b6:208:32f::32) by LV8PR12MB9333.namprd12.prod.outlook.com (2603:10b6:408:1fa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.22; Sat, 30 Dec 2023 17:26:47 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:32f:cafe::24) by BLAPR03CA0178.outlook.office365.com (2603:10b6:208:32f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.20 via Frontend Transport; Sat, 30 Dec 2023 17:26:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7159.9 via Frontend Transport; Sat, 30 Dec 2023 17:26:47 +0000 Received: from localhost (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.2507.34; Sat, 30 Dec 2023 11:26:46 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh , Pavan Kumar Paluri Subject: [PATCH v11 15/35] KVM: SEV: Add KVM_SNP_INIT command Date: Sat, 30 Dec 2023 11:23:31 -0600 Message-ID: <20231230172351.574091-16-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231230172351.574091-1-michael.roth@amd.com> References: <20231230172351.574091-1-michael.roth@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-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|LV8PR12MB9333:EE_ X-MS-Office365-Filtering-Correlation-Id: 87b25a2e-5618-45eb-651e-08dc095c8036 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CSkg04oOoKxMzMw+bohGzZ6b2sG8YMXN2ClWKGht6gTc6Q77ID0JfYU6LAcuKpBcdYvySOeXZc5nyK5ctFWH/EZj8t3n6H1t2wFYrtZ/svhg+OW3vuNUl37+iD6s8riRz8p6TS1FuJrLVzqYEO5J9ga/GY1uwnahmaJQMkhDGfg19YvFObDlc+DGOY0krFNaz+pzAKqie3d9TPv7x2BVMquzvRQtQhPjmBuy0tjASS5w+lMltACghoKFY6hieYHFBjVhxWPti7sgRVi7Ftcu2rIfxU1WWmbvcU+U4Tqpyz//6jRvX3EdJ3T/HHn0w+bPYn3LkGWNLq0iFvlXaOv5FI3KY//LwPx/4NRixp/WlLMSf+bYbAXe0GqwD25eLn1rIaFshi6d1Za36si7+mBMmIXclAwDdfmsUVqOH5RAQ4vS3i135nMwImjktlFcmpff56BKlSOojCNFmBd0K7pQKQwC45IVFZ5zrkZSYZUv6Np2DQHJ9QRKbBqvD0okgUAL35/Xzh8PSXQBqFdWLWtcCIoYIN2KDS4cvMG2bLZMomytJlvEOKFC43Gsc4lscT8rkwVEDwsYNtuHsWnj96EJpjov7KwLbGUQMtlfViAmgJMBw6V+cVHX6b1M3THrp/5ajEDte1mEX8z/DMgM3UBvBqR+dt0OWfMUCAtdQwCHdQ8R3SBAFEauW8iDYeY2Twf2IIqBE7rf1ZtTKsh3IzFxV2oVg2/yT0utcfDEFkGDzT0GLkrDKyjpKEKz5o++SXOp65C/vRHgYO424NH4JuMCiw== 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:(13230031)(4636009)(346002)(136003)(39860400002)(396003)(376002)(230922051799003)(1800799012)(451199024)(64100799003)(82310400011)(186009)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(336012)(426003)(16526019)(2616005)(26005)(83380400001)(1076003)(86362001)(81166007)(36756003)(82740400003)(356005)(47076005)(4326008)(44832011)(5660300002)(7416002)(7406005)(6666004)(36860700001)(54906003)(8936002)(8676002)(70586007)(70206006)(316002)(6916009)(2906002)(41300700001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2023 17:26:47.1988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87b25a2e-5618-45eb-651e-08dc095c8036 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: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9333 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C08EC140011 X-Stat-Signature: awjgembobegucad8jd4j9ho54kw3a7zg X-Rspam-User: X-HE-Tag: 1703957210-744031 X-HE-Meta: U2FsdGVkX18SC2ZEL6rkqhAsskOvPyoT76rtoXzruT7IDrC5Ypxl76j9sCGQu/qKFUsY0ybHGg0iDXlNJqLOHaDLpqZbf53rpiWoY5uhsSV8JVz/v6GP8hFj6Dq9ZTEUdwtBdWBNNJOPUeyTB0UlHOWAdJi8ffoPVuePOs6ZSBKCjTfZGyiN3JUTeh2zH11eZ6I533AwdpyvnRqDzNUuvkblZ2+Z7o2+X5/DPyBA+MI7GPw5qxV/WIHeOhGnPhoi435p6+G0r/OB0HN4HWd7Ien1RWGFOFh2zZ/SIUfaXLbdMe6q8mh516tSS6N4f5wk/qjpo1tRTpr13E1nXI1ha8SsCTNaWOFb9Ecig7KMNkN2J7sdBMoTg6KgL2EDkzRSX4pGKk5tkV29Ila5ZFqccO8H6XUQzQzdHK1dNSKjHIj3QaSOavbcruH93M6c00iOcwWJjErVtUSJm0280LjG96l2589BCC7jlI71xYk8NuY3XRkPJ+IOfhPx4yjvRB1HzZMOjWcf86idvJcRTMKvjdMDeV7U/pdNCDXQasSg+CRHAjuwP07cggwRQYaEUVp040imvKm5oZ52vlGA+p22OubVjEguo6htiYsLu2qVCBMhDJXL8blTXTyvQcZI8y1MIsbf0jPdwlG3qxWSZbkrOvr90gtQYXRGhB6l5VgdEXV6NnvvvWhgyzA6ZJ56zxJzlzDkxKk1MruKY3CBgy8yMzLnaTpj9OJfIzTsRh643CWpeka/yrNsixBXXCh4Nm/3ZQ3dwd48ZdqYC5DayMt2lRApl0YWxPK1WpTt+hibbdzuMKTF+VnxLi2Wz0vr7L+aJkACD9olNURYyBeA84ihzKYkuqssTK4WgewRNnpje4f8OT0Cpk8+yMJIK9qaGLSO1eDDDO36/6kNydwnCgx4p3TAw++KjuErOzAQomFpLMbi2WK376mxqpS8y1z2hASPLB2a+o81gGJhoA6rZCw 6z6RB4h0 LMr7tcSh+0U3/OVaX2xhHJ0rSN6m2dfXLBmGiMLcYX431S7Z9a5LXjOBr4a3GsjVoZoShvyLbNBzS9E8iSCBa2A0n0MyI19IhX2USsp7uMOst3KdEAgd4Q5KGysVZ1iVivXYRmTt04Bbq14LFmUxKDVhmEtFAtEoQSvLWctfdXwZ5Ywd3moeJSoZVwXmVWjCb2jrmvIlIiyMC+CadaNGtmnoYnsrEQ0bHlS1AC56m3aOyMPvQlR6vf9s4j7HNI/+mbmV8eeuZwJz0FfjbfTLQnFVqLQMK/Z3OwLgKfRve0tSbPfzmu3yPmp2km8w8s5GAbOXbJn9IoH37yssmbQl1TwhwTc2tlRLkEr2jjtWbq1vHXqW5kfXVG38ctBkEYMVuZ2WS 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: List-Subscribe: List-Unsubscribe: From: Brijesh Singh The KVM_SNP_INIT command is used by the hypervisor to initialize the SEV-SNP platform context. In a typical workflow, this command should be the first command issued. When creating SEV-SNP guest, the VMM must use this command instead of the KVM_SEV_INIT or KVM_SEV_ES_INIT. The flags value must be zero, it will be extended in future SNP support to communicate the optional features (such as restricted INT injection etc). Co-developed-by: Pavan Kumar Paluri Signed-off-by: Pavan Kumar Paluri Signed-off-by: Brijesh Singh Signed-off-by: Ashish Kalra Signed-off-by: Michael Roth --- .../virt/kvm/x86/amd-memory-encryption.rst | 27 +++++++++++++ arch/x86/include/asm/svm.h | 1 + arch/x86/kvm/svm/sev.c | 39 ++++++++++++++++++- arch/x86/kvm/svm/svm.h | 4 ++ include/uapi/linux/kvm.h | 13 +++++++ 5 files changed, 83 insertions(+), 1 deletion(-) diff --git a/Documentation/virt/kvm/x86/amd-memory-encryption.rst b/Documentation/virt/kvm/x86/amd-memory-encryption.rst index 995780088eb2..b1a19c9a577a 100644 --- a/Documentation/virt/kvm/x86/amd-memory-encryption.rst +++ b/Documentation/virt/kvm/x86/amd-memory-encryption.rst @@ -434,6 +434,33 @@ issued by the hypervisor to make the guest ready for execution. Returns: 0 on success, -negative on error +18. KVM_SNP_INIT +---------------- + +The KVM_SNP_INIT command can be used by the hypervisor to initialize SEV-SNP +context. In a typical workflow, this command should be the first command issued. + +Parameters (in/out): struct kvm_snp_init + +Returns: 0 on success, -negative on error + +:: + + struct kvm_snp_init { + __u64 flags; + }; + +The flags bitmap is defined as:: + + /* enable the restricted injection */ + #define KVM_SEV_SNP_RESTRICTED_INJET (1<<0) + + /* enable the restricted injection timer */ + #define KVM_SEV_SNP_RESTRICTED_TIMER_INJET (1<<1) + +If the specified flags is not supported then return -EOPNOTSUPP, and the supported +flags are returned. + References ========== diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 87a7b917d30e..ba8ce15b27d7 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -286,6 +286,7 @@ static_assert((X2AVIC_MAX_PHYSICAL_ID & AVIC_PHYSICAL_MAX_INDEX_MASK) == X2AVIC_ #define AVIC_HPA_MASK ~((0xFFFULL << 52) | 0xFFF) #define SVM_SEV_FEAT_DEBUG_SWAP BIT(5) +#define SVM_SEV_FEAT_SNP_ACTIVE BIT(0) struct vmcb_seg { u16 selector; diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 18c09863377b..43b8ae7b74f8 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -250,6 +250,25 @@ static void sev_unbind_asid(struct kvm *kvm, unsigned int handle) sev_decommission(handle); } +static int verify_snp_init_flags(struct kvm *kvm, struct kvm_sev_cmd *argp) +{ + struct kvm_snp_init params; + int ret = 0; + + if (copy_from_user(¶ms, (void __user *)(uintptr_t)argp->data, sizeof(params))) + return -EFAULT; + + if (params.flags & ~SEV_SNP_SUPPORTED_FLAGS) + ret = -EOPNOTSUPP; + + params.flags = SEV_SNP_SUPPORTED_FLAGS; + + if (copy_to_user((void __user *)(uintptr_t)argp->data, ¶ms, sizeof(params))) + ret = -EFAULT; + + return ret; +} + static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; @@ -264,12 +283,19 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) return ret; sev->active = true; - sev->es_active = argp->id == KVM_SEV_ES_INIT; + sev->es_active = (argp->id == KVM_SEV_ES_INIT || argp->id == KVM_SEV_SNP_INIT); + sev->snp_active = argp->id == KVM_SEV_SNP_INIT; asid = sev_asid_new(sev); if (asid < 0) goto e_no_asid; sev->asid = asid; + if (sev->snp_active) { + ret = verify_snp_init_flags(kvm, argp); + if (ret) + goto e_free; + } + init_args.probe = false; ret = sev_platform_init(&init_args); if (ret) @@ -287,6 +313,7 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) sev_asid_free(sev); sev->asid = 0; e_no_asid: + sev->snp_active = false; sev->es_active = false; sev->active = false; return ret; @@ -625,6 +652,10 @@ static int sev_es_sync_vmsa(struct vcpu_svm *svm) if (sev_es_debug_swap_enabled) save->sev_features |= SVM_SEV_FEAT_DEBUG_SWAP; + /* Enable the SEV-SNP feature */ + if (sev_snp_guest(svm->vcpu.kvm)) + save->sev_features |= SVM_SEV_FEAT_SNP_ACTIVE; + pr_debug("Virtual Machine Save Area (VMSA):\n"); print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, save, sizeof(*save), false); @@ -1883,6 +1914,12 @@ int sev_mem_enc_ioctl(struct kvm *kvm, void __user *argp) } switch (sev_cmd.id) { + case KVM_SEV_SNP_INIT: + if (!sev_snp_enabled) { + r = -ENOTTY; + goto out; + } + fallthrough; case KVM_SEV_ES_INIT: if (!sev_es_enabled) { r = -ENOTTY; diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index a3e27c82866b..07a9eb5b6ce5 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -76,6 +76,9 @@ enum { /* TPR and CR2 are always written before VMRUN */ #define VMCB_ALWAYS_DIRTY_MASK ((1U << VMCB_INTR) | (1U << VMCB_CR2)) +/* Supported init feature flags */ +#define SEV_SNP_SUPPORTED_FLAGS 0x0 + struct kvm_sev_info { bool active; /* SEV enabled guest */ bool es_active; /* SEV-ES enabled guest */ @@ -91,6 +94,7 @@ struct kvm_sev_info { struct list_head mirror_entry; /* Use as a list entry of mirrors */ struct misc_cg *misc_cg; /* For misc cgroup accounting */ atomic_t migration_in_progress; + u64 snp_init_flags; }; struct kvm_svm { diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index c3308536482b..73702e9b9d76 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1869,6 +1869,9 @@ enum sev_cmd_id { /* Guest Migration Extension */ KVM_SEV_SEND_CANCEL, + /* SNP specific commands */ + KVM_SEV_SNP_INIT, + KVM_SEV_NR_MAX, }; @@ -1965,6 +1968,16 @@ struct kvm_sev_receive_update_data { __u32 trans_len; }; +/* enable the restricted injection */ +#define KVM_SEV_SNP_RESTRICTED_INJET (1 << 0) + +/* enable the restricted injection timer */ +#define KVM_SEV_SNP_RESTRICTED_TIMER_INJET (1 << 1) + +struct kvm_snp_init { + __u64 flags; +}; + #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2)