From patchwork Thu Apr 18 19:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13635381 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 BFCEBC4345F for ; Thu, 18 Apr 2024 19:51:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 489016B00B3; Thu, 18 Apr 2024 15:51:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 411D46B00BA; Thu, 18 Apr 2024 15:51:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23DD76B00BB; Thu, 18 Apr 2024 15:51:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 030BE6B00B3 for ; Thu, 18 Apr 2024 15:51:26 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A0C671412CA for ; Thu, 18 Apr 2024 19:51:26 +0000 (UTC) X-FDA: 82023696972.07.75A9E25 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) by imf23.hostedemail.com (Postfix) with ESMTP id C376214000C for ; Thu, 18 Apr 2024 19:51:22 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=hDogTjb0; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.220.40 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713469882; 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=fgJgGQzmEQFn3qDjiul4utVDj7Am85Us4DHS4OSv5bE=; b=ga7pexnluZoHohz/WfQstDaU/H0CqRaBspRvNuyWLhWxFEfdgvqwY+54Oa5IEyy2FmMOpC czN1iOl7T6dVVyl4v9ZmZIEeUFF9GS8/o2epUOYGzxlSTqBKwGGRaQerTYbqEO/aXYnVpp hQxMXqcSnEdGu+F5iI+MEuQVfD/+UC4= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=hDogTjb0; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.220.40 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1713469882; a=rsa-sha256; cv=pass; b=qqeT9ALO2kxHCzBKg4lL1doeKbKct1S8a6d33hBi/Y/wY53AB64+SMq9Rnp+LpPXsF7e9N C8QsI3ZQ12zIL26nAkXC8xF/3oVKcfTL+8CNwjr1BslaEelcyikKw8PJFyUim01QvWuImL wNvXgKlIcw4biyqwOq4nKpNmKkMx8b0= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hMRTPctqWgVWvSivLiqkJKycroy+E8Z0/5F4prDNQ5Bc56oLApdTCE0qoP6hhGbrdA9lAs2bkUpNUi34EEQ5asZ8Z2H1Y7CGYt+w0qurFZmXa+xl54rxS5cGQLB8U/ZDGDduqd6JCpuZ/Gg1AaZK8sx0Ca/70bWwneRvFFZqGzL2Jned7ktjhT8kbrdDpdF5aznqocSHLFcMPaEux80zyYWVgBnNc5HvCztzCqv5Frd+5AeY62LdxCrv+N1FGuqZNmLz0Oyfkyfb/V9KCy8DRIZmocFGkrmnp0eQGHumyHG1OLiqbdiMwd1SJfqXWcvL08qHX/8xFeC6fbMIx2p1Uw== 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=fgJgGQzmEQFn3qDjiul4utVDj7Am85Us4DHS4OSv5bE=; b=B3dnVOG/UNjiqgWzkJvkU6k9biN7AqFOl7/eTRPUk6XkIAChcgMD2Y0a7q0B3PQnsVc3gpjcpaLb9ZIic3I/YYWsfe3qz2kOFuZHxuKV4ibkWljX+Qi3v/u3uDwdkT/dwaRyThiP0x+1PENDvhA6+/pXa2yB9gcq8RQbtWUSBvapk0WwoNZHNbX5uLb1IIkcJHBqo7yGTbIteLJC3cSLBOCrKGztVayms9uJN2i98hsW3Luahw1GgRpre5cKhyMXjQfdYupIWi3Xw2nRPJhcCAj5KxFQN04Y+6rYKn200NCfKTaBCSds9NsttECNjTfQ5uYe/RwDgKy6IZaDabLWcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=temperror 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=fgJgGQzmEQFn3qDjiul4utVDj7Am85Us4DHS4OSv5bE=; b=hDogTjb0ne+THYWLgia0Z0VZWrfoIPit4JmAppWiVKdADQmPQZ5j6FVrkhGkVIRLpx7ESAkk1mouP5P+iLk5lNjQMV7iht7lIcLvbaWvH8UmG72igRjPLnBhVCPEP0sZeoUtoO/i/MfMdDpuohUQsB0JIGYXZB72HQTlxz9cFqk= Received: from DS0PR17CA0019.namprd17.prod.outlook.com (2603:10b6:8:191::8) by CY5PR12MB6323.namprd12.prod.outlook.com (2603:10b6:930:20::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.42; Thu, 18 Apr 2024 19:51:19 +0000 Received: from CY4PEPF0000E9D0.namprd03.prod.outlook.com (2603:10b6:8:191:cafe::9d) by DS0PR17CA0019.outlook.office365.com (2603:10b6:8:191::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.33 via Frontend Transport; Thu, 18 Apr 2024 19:51:14 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D0.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Thu, 18 Apr 2024 19:51:13 +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.35; Thu, 18 Apr 2024 14:51:09 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh Subject: [PATCH v13 07/26] KVM: SEV: Add GHCB handling for Hypervisor Feature Support requests Date: Thu, 18 Apr 2024 14:41:14 -0500 Message-ID: <20240418194133.1452059-8-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240418194133.1452059-1-michael.roth@amd.com> References: <20240418194133.1452059-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D0:EE_|CY5PR12MB6323:EE_ X-MS-Office365-Filtering-Correlation-Id: 39a99669-ed62-42ac-23e6-08dc5fe0e6e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4YNuoQaOceV26QYVqgjC1m+cXuqXQmc1V3yqqi2w/W0XpmlnRXIjE97Y/44StPx/BwmWVrk9ZuVe5juyGnhCz4hi8EQq1tA/MpzI1mBganR8l943hScPPl3wrxMr/Ruhe994xveIktg+LiLl+f6hK0gsxqIx4qN9ilmtAv+oBaha4OzfF4l7tiE0rtkpZYkgtqZBt38BKWQOLtcFhQL+PwJid6/Zb7xeewnm5aj/xZJiBok8nyJgP6IX1TOUro7I+fv6DYag4kBqcgnwYyloe7Ix2FB3FzRt7wJVUU2Te4neRb4EJANLj+UaKzy36304q40sTkGxd48ohx9Q1fwHwJAMOY1COK3e5pHJW3cS0HBeKa7YuR4LweLJPnKGwkF7EOuq4XQvVKUqHxs9evX3s3nJqk3OTwGTrBRlfhQC7jyC6WlQ6lh4GBVZTWj+XIQPkLuEnqEYoXyYDgUM3BJsVhyZ+Pd8IYB100089nwUtiLOCCQslznkRXqCpBUDY3rFZX/9lT9yG76LfpjachvVbzpQmA1n5+hNaW2p0wYhVvV/BZ4Q65SyDMQZzf9/w2KRTucvlBzrQCDyd1eALphiTnUWWrVlyMFZZkXGi0etnrCYtkcO9IM9P/jHux+KAUGsqaLznt2j7b3LoBevWw7SRzwmCAR4g22gR4TBIHsf4qdl82xXFw9u+jGecIOuji/OzBNd/WKaCea+sqKBlLQ9sgwVREOL0VojoWvUCx2kUcSaNE8z68XgtQ/oFBDOnbWi 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)(36860700004)(82310400014)(1800799015)(7416005)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2024 19:51:13.0025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39a99669-ed62-42ac-23e6-08dc5fe0e6e9 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: CY4PEPF0000E9D0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6323 X-Stat-Signature: r4yaxark4djogo1xzsbjg9wuwfw997h7 X-Rspamd-Queue-Id: C376214000C X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1713469882-44715 X-HE-Meta: U2FsdGVkX1/p1yq+VM87+L7fQ1AlMWWSKp5YeqCh2+FRofIzfAWrV8Z+4su0GoK2zBnAIURb29Jv2z39eFEsEnmPBpgM/WER1mByOcKNjliWOH7y9uxAOsVVIbHJJWe8vd0XZtCCfoQK0MO+LZH1zQl3asCq2VJbcWKnLNlGxca+tShJhop+/U535Y+UEPImA8KlX97IMhMaJlxRxRrE+haPmWuHvq230DItpBk2vji3dCOv+yyEO7L/5hzgqD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INxPoq1bryTXUmRwA4rgkgx/BE84k1rhv1H+ZoY494Q== 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 Version 2 of the GHCB specification introduced advertisement of features that are supported by the Hypervisor. Now that KVM supports version 2 of the GHCB specification, bump the maximum supported protocol version. Signed-off-by: Brijesh Singh Signed-off-by: Ashish Kalra Signed-off-by: Michael Roth --- arch/x86/include/asm/sev-common.h | 2 ++ arch/x86/kvm/svm/sev.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h index 01261f7054ad..5a8246dd532f 100644 --- a/arch/x86/include/asm/sev-common.h +++ b/arch/x86/include/asm/sev-common.h @@ -101,6 +101,8 @@ enum psc_op { /* GHCB Hypervisor Feature Request/Response */ #define GHCB_MSR_HV_FT_REQ 0x080 #define GHCB_MSR_HV_FT_RESP 0x081 +#define GHCB_MSR_HV_FT_POS 12 +#define GHCB_MSR_HV_FT_MASK GENMASK_ULL(51, 0) #define GHCB_MSR_HV_FT_RESP_VAL(v) \ /* GHCBData[63:12] */ \ (((u64)(v) & GENMASK_ULL(63, 12)) >> 12) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 6e31cb408dd8..1d2264e93afe 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -33,9 +33,11 @@ #include "cpuid.h" #include "trace.h" -#define GHCB_VERSION_MAX 1ULL +#define GHCB_VERSION_MAX 2ULL #define GHCB_VERSION_MIN 1ULL +#define GHCB_HV_FT_SUPPORTED GHCB_HV_FT_SNP + /* enable/disable SEV support */ static bool sev_enabled = true; module_param_named(sev, sev_enabled, bool, 0444); @@ -2701,6 +2703,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm) case SVM_VMGEXIT_AP_HLT_LOOP: case SVM_VMGEXIT_AP_JUMP_TABLE: case SVM_VMGEXIT_UNSUPPORTED_EVENT: + case SVM_VMGEXIT_HV_FEATURES: break; default: reason = GHCB_ERR_INVALID_EVENT; @@ -2961,6 +2964,12 @@ static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm) GHCB_MSR_INFO_MASK, GHCB_MSR_INFO_POS); break; + case GHCB_MSR_HV_FT_REQ: + set_ghcb_msr_bits(svm, GHCB_HV_FT_SUPPORTED, + GHCB_MSR_HV_FT_MASK, GHCB_MSR_HV_FT_POS); + set_ghcb_msr_bits(svm, GHCB_MSR_HV_FT_RESP, + GHCB_MSR_INFO_MASK, GHCB_MSR_INFO_POS); + break; case GHCB_MSR_TERM_REQ: { u64 reason_set, reason_code; @@ -3085,6 +3094,11 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) ret = 1; break; } + case SVM_VMGEXIT_HV_FEATURES: + ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, GHCB_HV_FT_SUPPORTED); + + ret = 1; + break; case SVM_VMGEXIT_UNSUPPORTED_EVENT: vcpu_unimpl(vcpu, "vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",