From patchwork Mon Oct 16 13:27:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13423298 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 6A03ACDB465 for ; Mon, 16 Oct 2023 13:35:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F6FE8D007C; Mon, 16 Oct 2023 09:35:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 080568D0001; Mon, 16 Oct 2023 09:35:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E63098D007C; Mon, 16 Oct 2023 09:35:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D4E858D0001 for ; Mon, 16 Oct 2023 09:35:13 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9FE19C08C5 for ; Mon, 16 Oct 2023 13:35:13 +0000 (UTC) X-FDA: 81351420906.15.63C47E5 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2057.outbound.protection.outlook.com [40.107.94.57]) by imf17.hostedemail.com (Postfix) with ESMTP id 7FA0040014 for ; Mon, 16 Oct 2023 13:35:10 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=5HD2mmZZ; spf=pass (imf17.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.94.57 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1697463310; a=rsa-sha256; cv=pass; b=G08lAqroLl1HTmzvbhR04BSOWgS5DWJsjvKhG+b6KtSyEbUH1Hd6LXiRcmACWKWFhr1Y3t pDLOQt2MoOnIFOSpZq1F48wnjjAOE2PkHRbfDK/U85YkRendQs9rccJr8SIQUFdh7Q4aep LzxRF3qt1GoSDBwZp61J5FudaTHunfQ= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=5HD2mmZZ; spf=pass (imf17.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.94.57 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); 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=1697463310; 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=4RrXZlIvfGDBBifiC396TqziXB7qceYDwH3mF86alNY=; b=mmFyycK0rM75jHKwyCH2cTbRwoTZxwRyMg+EhfZEOZ90xXf1HD7AfMzIx8L5cJf+I/vj06 sQvSaf7jEfYOjyhykXniLRo7mLRv4RZmA1UVpqwfQjnH197gldoPObGnycPtgSJIG/4olO vtRkE9hYOfzBau7GdlrW8LFYMJgMLJ4= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=biTCQeeeEbCa8G9YHtphd5jyCPv9k5KZnrbkvnyx3+zqz0l/8KYNFxd++Nmf1kmov5KicE6N3hJOb3tNgR+oUm6WIPxYCS5nnst06uTk0NdX5G+9lvxKIl0utIrHyooWmm8GXwqVKYDVbvPIiTS1TcWiMtUy/3zC6ijRh4pTgbIXjszxHPNT4nFPVR1ctUaMYhSez0sEwBa50Z0bHllEQYMF+rzdPq95OKHIZf0N1SLgkf0gZBabZOUg4YeFmcP3k4xaMoXVMUKozlVH/21NF7D9LOPZuEx0d00TSqkPqENGu3cAjWdOl4YVzgIVC5CBfGSOQ5did7YMq1fs6cqb2A== 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=4RrXZlIvfGDBBifiC396TqziXB7qceYDwH3mF86alNY=; b=j923pFthXTaAEjuQ7u+bEhyPqNgHubXTA6ji3Sh5C9nkwmFjyhW0GGAy239v9ivVuV1vHKn0Z42MD0QDQx+eyzx1Ggo0v5DSwwBGkOJD+DZSH33Eshh4KS4zPwkyvE0J16UNgwgQ0wEOf40famIYfN7Q4F5J3miU7eMuAKCJH4TPqPXDFdmkQvu6DijY214CrKU+Ylhw8sUQ3KnwrFvODuFkPMAS7841zOtbTTPmUuQJTAclSGpKSEFqI0GKW8j4TN1cmSN4625rn/gaXQq83ofgMb/7pKl+OYM91SL7hzlgtr6upr4+U4tko9330Ip6YOxHHJSVJYB6gYijfBw4lw== 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 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=4RrXZlIvfGDBBifiC396TqziXB7qceYDwH3mF86alNY=; b=5HD2mmZZs6AL1xBA68EY7Z1L1XG5lbVuY9WkoYO+/tE6BK/5LuzSArO3Zaaa29WL9AjYjf4tNTq2QRtd9UOwEvZdkrcOzT/MH8hKJxltO9pEF4gtc56vIaLnimm6PIFbCX2Oycs+MMxogD5DETXMjnG+P+775kx55KEdqJa19NU= Received: from SJ0PR03CA0026.namprd03.prod.outlook.com (2603:10b6:a03:33a::31) by CY8PR12MB7587.namprd12.prod.outlook.com (2603:10b6:930:9a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.35; Mon, 16 Oct 2023 13:35:07 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:a03:33a:cafe::2c) by SJ0PR03CA0026.outlook.office365.com (2603:10b6:a03:33a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.47 via Frontend Transport; Mon, 16 Oct 2023 13:35:06 +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 MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Mon, 16 Oct 2023 13:35:06 +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.27; Mon, 16 Oct 2023 08:35:03 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh Subject: [PATCH v10 22/50] KVM: SEV: Add GHCB handling for Hypervisor Feature Support requests Date: Mon, 16 Oct 2023 08:27:51 -0500 Message-ID: <20231016132819.1002933-23-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231016132819.1002933-1-michael.roth@amd.com> References: <20231016132819.1002933-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: MWH0EPF000989EA:EE_|CY8PR12MB7587:EE_ X-MS-Office365-Filtering-Correlation-Id: bcf3b2a8-e7a2-4d30-5360-08dbce4cb5f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 43bZGeIWh4pS92moqTSgzAOgkeBILxAwBnRMrN5fEjrRQD75vpDqjNa1/TcLwkD+4BaMkyIMQ5xQrqXM6ceV/Lv7MTEci43qIVcsIlaW/fKaM9RPohFx3N1q1F5knQsm8O1B8LZ1pNW/n8l7Khp80fDmx6pEI1lO6iI3zybK/UHZOzLqKTLbLNp/pdBab8b+48bj8D6l0Vy0+2UG1op1IMDdD7nPvpy0tpVN1lj1xRfKPFSPOp35VDJBaqj0eifYnD7rRLGd5C4raybrCbvikTj0GCBIgQeVAT2bokMIo3UznHwcGxyNOGAclNA4sKAJnUiH0iJQM3j+eih4L5Yp2po1Jw7bgLL/RKvhzTBBmrRBbVOqLKQx5azUEnsQpWl6JrHXJrFlYKkUaOSaHxlyCOhVAe/s3JGiLD8DStW5p5rBxqKC6Ae+gUdPWPk0vKkod9vZDxO8JtE01SLOEyLKVWzJsxLhEC8pSsJgTtrbKYlYCEJPEWgnTHBtRGv9Z2ktzlWXjaDywwZhN8HTP3ffqc1LXaFrdOJ6U+Y9NH2+oYnU7eXGxyxuYtQHNM1FqpzcIkoPtykU2c10UDzuZv/20HxJfolBrATMWGJQnU8lJ4D/pVTpBCPcin7AqULU5E1NTWEtEoyuWaZ9f8pp6fDdFKZMTQ4fFnfbRodHdqOfHpiMYmbedcylIS6DKqMi6nUfpbAYESvekC6wRvs6mkLVGI8rrBpVWwjKQiQaVstExg3BtF5SycOsuTckVLbYQfVdc3x5llJGwZett4fUvzmw0A== 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)(136003)(396003)(39860400002)(346002)(376002)(230922051799003)(1800799009)(451199024)(82310400011)(186009)(64100799003)(40470700004)(46966006)(36840700001)(40480700001)(5660300002)(44832011)(40460700003)(6666004)(2906002)(1076003)(26005)(36756003)(2616005)(426003)(336012)(83380400001)(16526019)(82740400003)(356005)(81166007)(86362001)(36860700001)(47076005)(7416002)(7406005)(478600001)(41300700001)(6916009)(316002)(54906003)(70586007)(70206006)(4326008)(8936002)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 13:35:06.7044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bcf3b2a8-e7a2-4d30-5360-08dbce4cb5f2 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: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7587 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7FA0040014 X-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BPfd+8uyewON6ufT7LcmdPl7pFFU75rtxTJc1EMuAQcKG8S40UnJumdOOnGtYAq859DXN1aVrj/hPkkBgc1aClWeqa8LP4nX24AM+ga92IaejkjTaXu7gCksRbR9ttodyEq6bF2uG8pFo5MCzLRThLUgwCqYGuYO2PlejSS4eT6BH5Jwlwbxe1popioK0lonTG8Bs5eCFDH+A5Kp6BfTWDn0nSekSdddXdgdhrtIhHHRumEiKN5usiyZhM+O5St8An7F/6pQ+lQWPPRZAvgFJmunJfgG3RMLKUry2X9QJn6HEwAEhhAh627YQQnYD37DbwQQS0= 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: 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 --- arch/x86/include/asm/sev-common.h | 2 ++ arch/x86/kvm/svm/sev.c | 14 ++++++++++++++ arch/x86/kvm/svm/svm.h | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h index 57ced29264ce..9ba88973a187 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 4f895a7201ed..088b32657f46 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2568,6 +2568,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; @@ -2828,6 +2829,13 @@ 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; @@ -2952,6 +2960,12 @@ 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", diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index b74231511493..c13070d00910 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -663,9 +663,10 @@ void avic_refresh_virtual_apic_mode(struct kvm_vcpu *vcpu); /* sev.c */ -#define GHCB_VERSION_MAX 1ULL +#define GHCB_VERSION_MAX 2ULL #define GHCB_VERSION_MIN 1ULL +#define GHCB_HV_FT_SUPPORTED GHCB_HV_FT_SNP extern unsigned int max_sev_asid;