From patchwork Wed May 1 07:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13650282 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 5D2E0C4345F for ; Wed, 1 May 2024 07:47:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDEC56B0088; Wed, 1 May 2024 03:47:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D8F3B6B0089; Wed, 1 May 2024 03:47:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C08496B008A; Wed, 1 May 2024 03:47:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9DB4C6B0088 for ; Wed, 1 May 2024 03:47:36 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5EB45120739 for ; Wed, 1 May 2024 07:47:36 +0000 (UTC) X-FDA: 82069047312.14.4E2E0AA Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2087.outbound.protection.outlook.com [40.107.95.87]) by imf25.hostedemail.com (Postfix) with ESMTP id 8099AA0005 for ; Wed, 1 May 2024 07:47:33 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=h4UPymRT; spf=pass (imf25.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.95.87 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=1714549653; 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=9iPsbHUVqfnQYObn0gY0+/pNGlt+1qkXCH3qvnDFpWw=; b=5F1jjW0SCEjEJOYVEYaNJYqddWG+5YmkNQsb8iZxbHNli4QdNV1FPCcmypu978HvdOtBGO C4J6AmSPOmjM0FUuJzLKpuhojNXUu3vjWsUdFDFu++jzfe15sXGhp7En5fKoqnRHji6UUm 5445ttZ9E51OEF/amW39lLwFomqGnGg= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=h4UPymRT; spf=pass (imf25.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.95.87 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=1714549653; a=rsa-sha256; cv=pass; b=HbvsCuiuArcMDyuHGDwm/egF325w6X6a5GlvwVpCr41JsO0oH3H8wdwdPicGKx06xnf4kO 7KJJheTAxZlXp/bvXTzWaS5+dPPkp8Rm+US+zkY/SwLWA1/fRqqVC+mCZXtGLYqdnppOAa i9YUusltHZsyjLivVGW7qT8iSk8H/5I= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DMszF3FLlATSC6frTe+TXMCtCDB1s78s3cOvR2/vVBnlItfSFVA2dxSMH27SLAMm8nWyX7NUSZ/vdK8Ok8hfBdJYh6Vs9JZIzl9kZICXA694zOIEwKKjJ3slZTc6UQIi/v83eFySD7OB5bdr/hWTmeh6mvwKm6DBGZxIwOWtNWjy1RvyUrJ/shL9DX5UPjknwy1uSIeVpxY1pcRcx2OzDU9ydP2WMl0B0IQEYezls7bvWvXjuRBRGnetiTe0+84lFU6TUVPJT2eQXE1XQ8WKzbuoGl2yLHilSc7VNBCm4EeRG1Sw8BfBjVZpLTqPHhE81d8Ts6I9vOF9NtefI0Ti3A== 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=9iPsbHUVqfnQYObn0gY0+/pNGlt+1qkXCH3qvnDFpWw=; b=EIPrSxv//dapJ6UYk+iYGPFZ9ECVvgbLu2I3V0CnYqXtYH6d19MlVh2zsUQAum1TZT1jPKPl1if9xcyYUONxxXQCIFbzjsOfiKdIkJMpoMD8Ow7Vn1fDP77jYuplyH/ZpWGzKWPBbh+kR8CkmUzgUiAbq1DY7RrFOMU892EL26KsXBVBf5WlLO7/oWtc/j/4ecdUfstQFK/ffN2HlEceOG9rIZkwXR0Xb+tH2el7NPA4Vs2kGBZY0LU9nFZmBGSzRLFfZy0VJyLBmK2NWZoDrYOAS4H6+0xocaPTOAD7pMgOnEIpcAjGiRctJM8fiFQ/GIHP5N7xj/WtN3yNmuJpUg== 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=9iPsbHUVqfnQYObn0gY0+/pNGlt+1qkXCH3qvnDFpWw=; b=h4UPymRTBoVrMvfgdEZxtmFAXdNpf9jyYNioFA8C0rEF8BV/RF9TRnvyxmSPZTcRB96NKZkew3UGw/0hGZAK8PF/8QSXPGsbF249dp1IPE4UBKwdGlRI23xo2RYyB3bDLDeOlkec7hUJUbYShSl3MKUPMj1EiMv6VF+F4wjOyl8= Received: from CY5PR22CA0092.namprd22.prod.outlook.com (2603:10b6:930:65::7) by SN7PR12MB6690.namprd12.prod.outlook.com (2603:10b6:806:272::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Wed, 1 May 2024 07:47:30 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:930:65:cafe::7a) by CY5PR22CA0092.outlook.office365.com (2603:10b6:930:65::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.28 via Frontend Transport; Wed, 1 May 2024 07:47:30 +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 CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Wed, 1 May 2024 07:47:30 +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; Wed, 1 May 2024 02:47:29 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , Brijesh Singh Subject: [PATCH 2/4] KVM: SEV: Add GHCB handling for Hypervisor Feature Support requests Date: Wed, 1 May 2024 02:10:46 -0500 Message-ID: <20240501071048.2208265-3-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240501071048.2208265-1-michael.roth@amd.com> References: <20240501071048.2208265-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: CY4PEPF0000EE37:EE_|SN7PR12MB6690:EE_ X-MS-Office365-Filtering-Correlation-Id: ed4c0486-2ae0-40c4-37f8-08dc69b2f442 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|82310400014|36860700004; X-Microsoft-Antispam-Message-Info: ZkOUr4mIdgIC8ZCNd/VafdF+FM90bq+xPZGJUZpp8F9Rwc1ykHoWAP4RI9ZmXEn0bbfEZcMWAf7fBzjv83cfsP/OD0tJVy3ys0TG8rcwmqHsBQKbRjgO0bowjIxBrqqiZuRRy+WAnbZMcm1NXAGJTJ2VDDG+mWYmB3onu2co7qTobU6l6qkmY6UxHZra3QxDBUv5Jf+9Pt5vcp0AbyzGAJnYvmmob1OCXSIKRX2QiWq1uENTnQVTYQS5kyQNI1PukgD/we/+j0aM/QLqpFNPFyRc5mFT2xz/ZjdLk12w5r425FIvpd+RnueAfqELdHUv6O7qJPciL5zz2XicOVDtj0EFRnhCusBS7+LniFg8GvRs7M0AoixdDAxOJyL2AVzSOdcvVr0KnI8Ajxfpy83VilYUd+hRFHlCfY8JT2KsD4OjlIlD/LV+xQ/jTHREMFT4T7DCiJw9p7TbTxWxKr0OcqrjyLqxtEa7BslQDLzSP9MVS5TFG2Zwwt19z2C9DL4Bn5VDQKBAXIBwefkcSd/tGK94sOPRINwWdyHUJYovJiEVDGIuonxvd9JHBQGSZ0L1YjwhTZ+wDEI4vl8hQWWAKXnxwVPXgAli99mc41GWFCyPhEElHAI5WVPl/WFI5ON7NhCCwup57y0vJYDYAj2fs0arodEYEx0ybJejpMaUHsAJbyt7XFnkGPDehOV4r0z0dhaGJ6QR242WbqiXtTtqFzWt2KRGMZHboB7YYwYwNgZSRUMkOsMpAroeH+HG4BjracRrqyAgXHK7ABBIg1u9gdL+g5J4wRnf8+4vzphGPUPn1cIK4/lfQ7hVCgOoe7F4eqHfGkilHS02JzeY+31ccNw2qJrwgcWU+AXU7FQOF4FXvG1ht64sd9G3FRg0jm64xRiX1HtrAbIF69EGTNwI80orMiaficGu3236JVILX7G96uYwm759re3OXJwFV338o2l35isYzaITltrB8JX0hO5lAk7pTmKhf4sA2WMxOEz4WJE2AGl7ZIKceJYVAQqxfXjRnvh2POEvpuWCmFONA/S8mSCneyA3rARCqa8FXQ2zzdJzcrjqWrI2qUrGa1t4SqGRaivsDJRbFpbnxgZpQaYzyx4Oof6+7rWbibtQ3pJ9XXvE4A4dnE8pZHyWKqydhWNmWfXVhYo2zmlSUNOax3HIM2z+98zl73R2SboTOOtoZDAwl1fwXp/rFgSktWvmfIXWVbigeE+EsY21O5d/QVTFeHRat1bOK1rhWmfP1Y9qpqhTNrIFRhWwDC5SCviO9sJqLdHD93wP+Vqod1xxr+cptYYPsYIFq36PP71pV8u3txgfAqgmQ1s7wv+6LgKYBtx/FwxhRsEDgndflog4S9fiWFcPzlhlBS/YKbku5IM= 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)(1800799015)(376005)(7416005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2024 07:47:30.1819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed4c0486-2ae0-40c4-37f8-08dc69b2f442 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: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6690 X-Rspam-User: X-Rspamd-Queue-Id: 8099AA0005 X-Rspamd-Server: rspam06 X-Stat-Signature: m7zw5pd8fyog1r63sfzu99n3s1pzxeef X-HE-Tag: 1714549653-61372 X-HE-Meta: U2FsdGVkX18TLm5funHn0Ne+rcX5I4+FpctJqGKaSRN761QU4f7xxT8wjXJUCJkqiuIxTZRvlRSo8Rq/o7gUIesEAAdKmIFXUB8BwXoq9k2UcXqck4AAr8UBO0lL1rK1jt9ff6ggQT7ZiWGMtz9c4rvGdrTNv3bCu4up1KD5Gl2PvywqywFBZOX2P9Co7VzVtFvjFXUX1QdBti82/p+ZMHZKEAT7tAQZUSO1GwZ5qmUk/yUpAXMvdwHPvdORjdKaGfa+8rkGdF6rMcdeneXR+zFtNKDMPgGFo8oOTc3DG9yoqYc6wF1N+TtGYrYlq/mIJIk7Sub45N/R1dpuC9EmPw3m5GHBf11vNpGu9+LxTRO/KXwFll/Y1NYmyou1asxSmBTNgqSSpCQWHJ5XXsKbCKFk+a2Pe7Ghvohks42n9B1zALqOOs30fXPcB+S0+jETo36hpEOiI5ehjCIN1RQPHVdIWvstd2LMUJcHsf+Qz5BSQoWoMo8C4EK4i5yjC88fHHUVDJhyR/7PNTOk886LeP0TT984KNACvsS2BDVx8JISUfPMZFS5mrFk2MPE9AX+5Xq1bCEclpnLspu6/AHW+I8etVRH7Gd8AHWCJXrJ8ImLSp/HAIZHAOEYuLJ9SaUTB0OV4BfUJWdHcajGJvpsSiVDi8bdX4xXlD+pvwIUurvvfOXrwOVFyxr2FRPC9FQxMCeFv9B44fSBZ97pZa9hesr60H/6Mt5JNHVtd2Y6+b2mUbwuwjUk/5kdC88wTA3FI2h2izjuIXJJj4XqUCixkWf2Pr+hIGxZ02t5T9ha0+lhFhg5E36rHF/nlQPjTdx9qHURas3/MyuUeojsExAwTXV4Es93lYlYA77E80K7w2xS/EM25EjHkva4c/aWKksael3F7RYsnmpKDErlxabEZZzuBjcQ/k9KlQ51QOCSI08RxUE6vrySaHvlcFHzsCyxjvZ3Y7G2P//vRZk4m0s 0qW9/ftR 4z24XKYmQ+1GrcxIg6lVP5auYI24XowmfqTXfQmGVQfBNY2xF/BgcS6EHu3rOCOwRo6yjNyckBASoGFCd7f6XEDUB3Q3rSPzv5b5JhUV8ksLNy8+2H75yL0IM0qGqBx/pGqeKq0uwhdVSowzzltur4F42LlBEiPTHXTHsko2pd6ev/5Zlwy7cnpYHqGSw4fi11/tVPHY4NEx9ffJpt+jrCUz4qp+DpqJefogUPpsT3unrZvQNlWSO7uPxhMi/Vl2LdRmb2x3r4qfZMIkHlOredSd0arkCMYieeCpkQ1z+oFpPRSsjeKOGSWxbiiuvbHTbaquN/KtCvQ/ptDHCNawg555IQDajhvVe9pbUhf7yTi0vroYVf6IrqWbL1A== 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 | 14 ++++++++++++++ 2 files changed, 16 insertions(+) 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..37d396636b71 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -36,6 +36,8 @@ #define GHCB_VERSION_MAX 1ULL #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",