From patchwork Sat Dec 30 17:23:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13506948 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 C6AEAC47073 for ; Sat, 30 Dec 2023 17:26:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E2916B0127; Sat, 30 Dec 2023 12:26:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 591C46B012C; Sat, 30 Dec 2023 12:26:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40ACC6B012F; Sat, 30 Dec 2023 12:26:14 -0500 (EST) 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 2E2ED6B0127 for ; Sat, 30 Dec 2023 12:26:14 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EF729C0A00 for ; Sat, 30 Dec 2023 17:26:13 +0000 (UTC) X-FDA: 81624163026.29.DA450D6 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2065.outbound.protection.outlook.com [40.107.244.65]) by imf21.hostedemail.com (Postfix) with ESMTP id 037E21C0021 for ; Sat, 30 Dec 2023 17:26:10 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=NBQZU7Vc; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf21.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.244.65 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1703957171; a=rsa-sha256; cv=pass; b=Af/tSgYBjmpuBUXDUub1kF/yorg6sFsEWtctQo+ifPqkcE7Pz5s4bZPqv6pxontlUBQblE y3VHqsg3sN3w53C7iFHF3lrTFXGsxaNQ2PjlHc1MDyGgD/iOZRNt0PClV4PRiMyoRgimIC YlgDim6laFk0li2TSmj6oMteB2zsgZ0= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=NBQZU7Vc; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf21.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.244.65 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=1703957171; 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=2RVrwGGLj4xe2sLdaXtOuRwJrX3AUVc/sPFfImKyRLo=; b=r4p68Vrl/+KgevxXpSUH3hYRthHjP9h8mmjz5c50jx7nQWsYnKZvzXPvBXlzrBEimcTq8g 05XDY8/ZLeKrh/1Ska9HiZb3m/G2W4FOuOsIhJ/oYQCiIhxyWde6kjun96tJ11W1RQW5Rn OTlzi12p2WBe8qlSY03wBUWIey1hCeM= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F8vhlaJePMPsr5E9I8HPkyl+tZuBw0TEmS5WA+6LUOmxJna5BbxvtTDC8cwuxDMjh6TnUA+iNOCoOCQnUXPX3ykdZ+hqe9a9ot4sJsDG9BmF90foARyG/QDZNBjaDbSPJIq+vDTpFN9ECbnD3e8i/dgUs+gYxV+Rm7t2cuELt4fht8PQMU4NU3zmmPCZb9JDOiGdXWNdDBsshkKRIda3bhtYEIYjcPzWM/Y/j3IuLzO6l01YOKO1S1T+zcXs4MNB/qPFMKjL/N576X0BUWkQiOXJWFoRXyAi5yfWupub7sx9kKT5mUcbU/QS14e6EMZIdEpv7tcVWCBC7nTSJHFRQA== 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=2RVrwGGLj4xe2sLdaXtOuRwJrX3AUVc/sPFfImKyRLo=; b=U6PBiPTYBl7uEH6538mWZOLg008zUlUy0nfm+C94DaqJX3DC2UdyFrbLKYwdj9piFODgicmCq0tUyy7xZM+NyLbbUrq2dbkjKHOor486SvMqHDZFZscdzQ5OjWGrW2ZeVg0cy5yv+R9s1ZqvV0+ZlnGJCSYbTAjSYe0tCafYjogIQKeWOj13KkJkw505IhzJ2okBYyw6i4SWmIAZpdHPs0bmZdKU0bmFXCoTKV9uARkDbaTxdJafTdQCingrsKNT60Frsrt18xsKo3cyCdbPXuZHMtzab9Y2pi0O+6WzZ/5QjhkXnXJCy5vy8o38lo6QnQ2+LGDBY7VL5iPBt4pwIA== 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=2RVrwGGLj4xe2sLdaXtOuRwJrX3AUVc/sPFfImKyRLo=; b=NBQZU7VcmN0jOnE1+VpmQL0NG9K3UorJ975ltT1uUy9emYeLXAwLNwevdkKtmobLtu2HXtS1/0QMKlWj6bpxGt4blMxeNBBcR51o39mTS0GXJvdE7E0XpjKkmW0PdBu30OMQ6JPqqVQ4whfKOiUmJhR9fk0q7HXf5zPWRY5szEM= Received: from MN2PR15CA0018.namprd15.prod.outlook.com (2603:10b6:208:1b4::31) by DM4PR12MB5343.namprd12.prod.outlook.com (2603:10b6:5:389::17) 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:05 +0000 Received: from MN1PEPF0000ECDA.namprd02.prod.outlook.com (2603:10b6:208:1b4:cafe::7a) by MN2PR15CA0018.outlook.office365.com (2603:10b6:208:1b4::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27 via Frontend Transport; Sat, 30 Dec 2023 17:26:05 +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 MN1PEPF0000ECDA.mail.protection.outlook.com (10.167.242.134) 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:05 +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:05 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh Subject: [PATCH v11 13/35] KVM: SEV: Add GHCB handling for Hypervisor Feature Support requests Date: Sat, 30 Dec 2023 11:23:29 -0600 Message-ID: <20231230172351.574091-14-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: MN1PEPF0000ECDA:EE_|DM4PR12MB5343:EE_ X-MS-Office365-Filtering-Correlation-Id: 9caab47c-5e8b-4698-b86f-08dc095c676b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xgDdBeLqhaDTBjrZShZVY6RgaPNpFjQLJxcJ7CDVaREERQ3OI5/AHP601bnNhFBjJ3owssLAcqA2gjTKlzTxhnnKoy3qnh3Vpo8IuXiMaIjmlenumXEn8ymTytsuoQDN7JZQx4ISxTl/SFGPPME38KTkoIRhTXNBXHGaOQBjnbSPvhIW+Xqyi3Fjcpja9HpUMrMGN+RIQltXiBDPhcGpBh/FExXuhjNrI2gL23cUtmFvj7vv/7Qzkl10UI0pENPabnQsFmLXiW57u5likMC18ncKBthWp6TJxFLnkVmx9alED6m8BMMPOlr9okKNWmy8O9GJ1IyGeHceoMAJwG6m9nHH4uU0Ak/H4fXp0ptRH3vRdDEn+HdYx0xwxixZTRc97aDpQJcWFnGln9o8L8n7HoPvBoNm8Yg3hSIGH4F36J5wJqb0X0CGVd3hh8LfmHzDqmczmvxyYZ+rZEEFcrDQAISp/MGQtS4I+PxO4rcD8XFeXxy6Wo/haOzEil/o40LN3Px5qZbE9lxlyo2I6HajI82hWCpNNNoy5KPmEt/ImuH7ebYeM41PwSCq2DfGPq+v+JewiXzb0fgj2zg2GuVeGqf2L127xVn2H5Hq/vmSfY6d777cVE86wpzqyNZN7o4/+Gz2tuIfrhqGoRkeV5CCzhH7biwF63IT7CYegmTIsThnfz63nNO6pFYVHlb3qGVQITw3JRpGbBZeuzfS23q2a71kbPoYnhKV8jXwBxEm2xCyyAzvGBrQzOvVmpYJPPzLztr2QH4z+QbSVwduQL0bGA== 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)(396003)(39860400002)(136003)(376002)(346002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(82310400011)(36840700001)(40470700004)(46966006)(36860700001)(82740400003)(81166007)(356005)(41300700001)(36756003)(54906003)(44832011)(40480700001)(1076003)(70206006)(86362001)(336012)(8676002)(6916009)(83380400001)(8936002)(2616005)(16526019)(26005)(4326008)(426003)(70586007)(316002)(2906002)(47076005)(6666004)(5660300002)(478600001)(7416002)(7406005)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2023 17:26:05.6053 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9caab47c-5e8b-4698-b86f-08dc095c676b 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: MN1PEPF0000ECDA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5343 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rsp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MPbXDTzoin5vFmNqXr7g9UwS6Nt/OAy+b79zv74pyo3aKNM0vd6KSgAZ6g9TEwN6tAJH7EYlEmkdp4vXmkWVUwRZ9iwqdWIjBIhmaY3CA9ri4vdQSM3n7gKPHGyr6KHP7R7LDv7wBa6E5lA0PR9py4d//yUGNix1HVLjTC2zawr874+ivOkkoVAwIl+3pr4Xs9WnDfN7EUem5naWbnLKmEDu1iOG3GWy+gpYY9NP6PteqZeCMGZ2kE9OT0ajjuWNZy/4aCajwKgMiB6PAM3OgKf8ZYry8aq7tv6vEWscSSitv6RvZvTqGzCjLI9Fx94mrGL688v74d/VZXZ0zWNU1IVXa1Kir2YvIKWOEoXvPmrjmpDjHOnYQ2+A== 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 | 12 ++++++++++++ arch/x86/kvm/svm/svm.h | 3 ++- 3 files changed, 16 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 b09bdaed586e..d6e206d21750 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2574,6 +2574,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; @@ -2834,6 +2835,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; @@ -2958,6 +2965,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", diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index eecb2b744d79..d0f8167ada7c 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -665,9 +665,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;