From patchwork Wed Dec 14 19:40:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13073427 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 6CD76C4332F for ; Wed, 14 Dec 2022 19:56:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E5838E0005; Wed, 14 Dec 2022 14:56:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06ED38E0002; Wed, 14 Dec 2022 14:56:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2A018E0005; Wed, 14 Dec 2022 14:56:38 -0500 (EST) 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 D1F8C8E0002 for ; Wed, 14 Dec 2022 14:56:38 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B61DBC0F74 for ; Wed, 14 Dec 2022 19:56:38 +0000 (UTC) X-FDA: 80241969276.23.16E3F6B Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by imf21.hostedemail.com (Postfix) with ESMTP id 0A5201C000A for ; Wed, 14 Dec 2022 19:56:35 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Jbr58qUq; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf21.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.236.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=1671047796; a=rsa-sha256; cv=pass; b=U0oz86F+kMxFKzsNryzsPQJ0ne8Sl/D1AJDXd4JnYruTqeZ9MZeh2YpBMzKYmyJ/QCbtrX bxXEhYHFwDXaD58IZ44VpWcMi/8pOCMvb+VVPf5q55hf/8cbqgDtVTXK7r3JPNEYM0PHtQ eUcZieR0Oh1OZtxSxs5SmpavnxBhTto= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Jbr58qUq; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf21.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.236.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=1671047796; 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=L3Ryree9hpK7wmsj8Cmnp5OW6S0cIpM4e4m1hjfhEpw=; b=L2zjAGuFTnHpGpgeE2ZbbNaWmffSzHwy/wpqSkVOr9HQXiJPppMyJPDxQvXAyg69ucM17O 8YGaIRvpt96/5iI3zHNIPqsI+CnJuUZBVERfp0lEowZ94JoobXn/O0jSAbUUkEzmUTno2Y F9vFrX1bm6uxu3UXGq7CeICXQyrYXKo= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mOQCV37goZZCAOTG9koypOxO5JfZ7m2k/sSCYkcb4e3ggQq/xi+X6FzIWWSjowHdCcxE1OolhM271qtxAqpxpif3BC5sAbHf0H9HH+RMHvlzORjPSEEpD1gWqmOFsjagO1LXUUsUpy9f53eybiTWXRo2wiowsS3MbjoZXsRsKHGc5OaLb3hm11w343/yrNTBz7DneGgzbjWva6sQOV3g03GLSBQuQynwL3ghNbUrWynciMHAt64MdBuvroLfDAT+MfVJRyxsSuFXJvtU6+y66sAKqKnk5/CjSbxEHu/Pl/q0iOUo9UjypcDgamxhXKineotqXoU443QsoY4YNsBLVA== 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=L3Ryree9hpK7wmsj8Cmnp5OW6S0cIpM4e4m1hjfhEpw=; b=Jh0K9ol7GcTMsYdDeH1ViSaipL4eVGi7nF/Ky7MULlenhph/4rr9ye/VavxKhzS9IX69FiimiBxp+OAxjYIfnwnav7WkUUlU2kgquz3apf67dhts+Hn2fYBM4sKinO3V5FKVaby18ZrrgkF/lpmff5IfgfosOPjQBDp1vXulU4SUioJAkWfkBg/wW2Y7ZhEtoxR2GCOJolzi4EwMod+h0eJWs1I0YwK5LpbZgCqbmen3Id8vKSOhWph0ikuE/f2TVa3gMK+d+Y0Xi5LHW70eYMgaHY4v7p6LbK6LhVZ6s5LdlZWSt73MV6neYJLnieLn3wSdHvfnT0AN6pLy8jGw+Q== 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=L3Ryree9hpK7wmsj8Cmnp5OW6S0cIpM4e4m1hjfhEpw=; b=Jbr58qUqG8ReQtJFf78Pa5npdAXdqxCr5rHBCorOV4BWJNvEqm2nURKA6XyCvYQX9O6j7NjrcaLpqxc8bUSu9tABPuVPj6sDE4Q54jNx7/qswm6a5BPIO5tGlJUfpW6eIQYnmc13ILyXOYe9VnqF0lFKLt7tUFBU9Q/g3lR8xQI= Received: from MW4PR03CA0350.namprd03.prod.outlook.com (2603:10b6:303:dc::25) by DS7PR12MB5791.namprd12.prod.outlook.com (2603:10b6:8:76::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Wed, 14 Dec 2022 19:56:33 +0000 Received: from CO1NAM11FT079.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::c) by MW4PR03CA0350.outlook.office365.com (2603:10b6:303:dc::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 19:56:33 +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 CO1NAM11FT079.mail.protection.outlook.com (10.13.175.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 19:56:32 +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.2375.34; Wed, 14 Dec 2022 13:56:31 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh Subject: [PATCH RFC v7 34/64] KVM: SVM: Provide the Hypervisor Feature support VMGEXIT Date: Wed, 14 Dec 2022 13:40:26 -0600 Message-ID: <20221214194056.161492-35-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221214194056.161492-1-michael.roth@amd.com> References: <20221214194056.161492-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: CO1NAM11FT079:EE_|DS7PR12MB5791:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f41c332-1e03-4a2a-de9e-08dade0d4cc5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X9TGCmotSEQWS7JgXPr55j/UvtgVE/sOQYryrLs8BzQ+DQsvo8UjjWH1AuuOoUKze/L2tVehcsRjAdvyjBsfIL5WGZk/vIcUIAubZpPuSoHv4U2K4uIS2MFuBYNy3L8FQevq3lWnQFiQpalS+WhEed8Ie/zumaIf0HnGeo5i5zVbL4Q7aEHB0KlEZcaSoCMaKKXChRHDLSKhXPi2Ag0CSh2APNgwOuklqKahR84a+tUjD7Bx3BhFHab0DqXkKgOQgn/SzWUeCozPNUGYgzlAoHn0sbivcxJPoqJ8GZLPWX/LlnOJkQC3h6GqPqyRSjJUFbc0d40Qq44X9Ll93ZoeNCrrc2Q8MquNjkr4SEX+SBOOO+gHzRRvpWiLKktevVyzUxJ/cWmIu0DT94mYTPgPzXA243eHPKG0BdfklMNPTEtUGwbeQdEyvS002STdk66nWe8lGDhSfcQ3Al732ehqDXTxjyKTbbJQQFrp0MFd4mmYKNQlyFjvbRv6MOaM5YdFcWLXfpYAw+eVfqspOnCln90R36LXzab02fYWZffjAo45CX3rNAzM8xace6SAYvrVKVns/3JWPuwv6YPULmjo+SuoJs2I2uxUtsDOEz6VI6kvrFDQW6TG36bdw+V6BJ8HUMpbQV0VKu45bbLuDg1ORGK5dRNfXk248j6xh57B1jPGp5DVQWXb8++xCW/+2hAifzNs1P7IaYh/QDCK/83qdZsbTQhMh23kWzpR0tRFQFw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(346002)(39860400002)(396003)(451199015)(46966006)(40470700004)(36840700001)(82310400005)(36756003)(86362001)(40460700003)(8676002)(4326008)(316002)(70586007)(356005)(82740400003)(81166007)(36860700001)(26005)(426003)(336012)(54906003)(2906002)(44832011)(83380400001)(16526019)(40480700001)(6666004)(7416002)(70206006)(478600001)(7406005)(186003)(6916009)(8936002)(1076003)(2616005)(5660300002)(41300700001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 19:56:32.8761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f41c332-1e03-4a2a-de9e-08dade0d4cc5 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: CO1NAM11FT079.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5791 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0A5201C000A X-Stat-Signature: 5omnsfhrdwsi9y6af8p8nbx6w5qg7au8 X-HE-Tag: 1671047795-187570 X-HE-Meta: U2FsdGVkX1+vgX4nl/eRbrSgEbEoqCAyfDWTfSMP8U/wy8H3IacD41RUGfqmH18XsQ0FrYWV86WqS4Lnus0vbWUaEzZAvrk1NWqby6NDAr4SXPwMJNv474hizzc08aMfphhi6Il7f9os4rmE3DDmQBTnvU8SOfjpoxopVPBPoYxdWKe7gnH8XfOOyUYoK+pJPEHHBrUo85JINwPbJHsKuISAXqob+N2Ap4X2QcvWamM/g1wxC6f2TFnk/NUg8WaeLo7WflgVZZwLuidKMjCcpwsQ9QTXnG2GoZ4+VLO+VRNaHSy85qloMpqDVK4Lbe99trpzAJyOpyUuWjm+8RpTP8YKWeuLLPdsVrzu0uLpEJD4imImyw8LRMXpLXbfgBaSGz1XP1fEvyNLjE8ZAnOVId6kkYbFqCLoFxK6YMd1x0rDx8gx1/YF/bF59RsnQozNFxBUtDBpthK54NvqTkatQh5x/UA9wvYdttqo7CbzDh3S7jo2C59vbJBNFLBQsm3zVnvAUFhEDgIz6vpv19wVp/CBBqnuq85Bf/MtoiuXehhF4q4Po9bAWCiy97oS0OYKkEul/0858VuryVdcaTF8P2XIHM9pvCmX+8+l3qo0iNltxbafIW894HH8UGAx95QUp//vFuGrnlyuAlnBsXj5V/yVc/sgV7a3PPn2OsihJakedNao9plhOcanLdzIzWrEveriPrlo+xPV9DQhSNnZeYt7NfIVN/Kj6wONG19WYl0bJ0cmP7qhXBNGjN4VgE0R1/agTN4Siy5vwHBIaxdofC+oBH4UuD+MhdgF/wKGSmjskHTkr3pp08HCyT0ZVY5oOhqB/Y1uz135S1KJQ0+zhBLgcZ3Q6vV2tzKD0mjPQ2Jt8rDkCQwWsGnIWHyPKrDy2Y5vP101WF4zCYbTTPGGBgx1e7Tu4FcT9HiSzkPZ5zo3KhhZCkNGIFgCvgQlsa8jujz/CDmemaqOrNLr0HD TffBd0Cr 82lww 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 Signed-off-by: Michael Roth --- 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 e15548d88f2a..539de6b93420 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 244c58bd3de7..82ff96b4f04a 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2667,6 +2667,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; @@ -2933,6 +2934,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; @@ -3057,6 +3065,12 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) ret = 1; break; } + case SVM_VMGEXIT_HV_FEATURES: { + ghcb_set_sw_exit_info_2(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 cb9da04e745a..1f3098dff3d5 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -654,9 +654,10 @@ void avic_set_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 0 extern unsigned int max_sev_asid;