From patchwork Mon Jun 12 04:25:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13275500 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 146ECC7EE23 for ; Mon, 12 Jun 2023 04:36:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FCEF6B0074; Mon, 12 Jun 2023 00:36:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AD708E0003; Mon, 12 Jun 2023 00:36:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84E268E0002; Mon, 12 Jun 2023 00:36:31 -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 773C16B0074 for ; Mon, 12 Jun 2023 00:36:31 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 53775A025A for ; Mon, 12 Jun 2023 04:36:31 +0000 (UTC) X-FDA: 80892834582.09.65F982F Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2078.outbound.protection.outlook.com [40.107.243.78]) by imf16.hostedemail.com (Postfix) with ESMTP id 60F9C180010 for ; Mon, 12 Jun 2023 04:36:28 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=CCLbG9z3; spf=pass (imf16.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.243.78 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=1686544588; 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=8zzsL1kp415Jf3ZR08yu8zyJesz2ZChIlRl31hCycZw=; b=2iDK9mTTeQKqSIwTn1AkxstaNlzYacXdZPyU7aSdUhHEX+HBmLcMlp2NTt07UC1asyQpWM uESLSzmW26zleHeG+Vch25DvvoJSJTOKhM8WtoMuJOvJ56arigt1cFx8zTVVI6U4943HOC ovaGBwyxH0cqZMqQrgSXR3GD69a8lRc= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=CCLbG9z3; spf=pass (imf16.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.243.78 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=1686544588; a=rsa-sha256; cv=pass; b=XObIIcY3mvUIdmBVzBcZvtpWyMdedJg3GKK8+i9pTDC9UoWuGeqEWgy0IVc7xxD6v4JDrF bsCzB+NsrVlbTIDfm0v+X9Hg1+WevGn/NyxYa2ucdAnhMVIS5I9tSXgXNl9zjxd60m7eUI rP/ta0JLCiLhdDqI2ug6kPytBnTgmCg= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aahd68F4z6eqQpVYMaVh/MPQMKXnZj26w881Lwf7SaB75uRx10IY8xu3WA5/FEGSw9ZujGD4lexTM3YT6Ojjo/XSpcLXPTNPMFJporWCTM9jHtNg7/IjCs27kcja0/hHokN0XwjoOvRXeNYldl9L0s/zRpv8857Zw52rDaBevtXqiuh3spAbxHMhIctdjwKbAWQaOMl7Sc7Bmm0keKsM9hX8/k84QgiweANvAJlp3SY9vfIVbeuCrPFm3Qlrz8Pdk5P8kfc7dcjlrPzQPvi1uXu7xG/zDVR3Ov6andOEnMGIU2Ol/vA0Hyub9m/yvktqYVNI/5vVpxlxTlJ0HDoyBg== 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=8zzsL1kp415Jf3ZR08yu8zyJesz2ZChIlRl31hCycZw=; b=a/lPMdcbBRzc4VqfQFS20DGcFuOLpP0uSeDSb1fMhhgprQqbTc28iCpq4CBbas98UmbachZCh67xu9V8IKbrUqO1/vhfl/fslswGCr2XDOri5+TP+BK0gDPB/g6bQBXa7ijEa2Lp2hsKYcsVjuCTixTpxoIY4KawGs72E2FBsilKTxmFxS0eUwLSoXjyGe9hMgb3qWunMpjys7dpx6cZ9NYLdeeaoocaDQUsnwHf2EjzUbivsDVxNhLuIyZU4LQ9umnU0wAEFsSL6VpbaVpHcvo/9r8aMY0gIl5k27FYakIBGc/hH5+/oR1G6HgkpXn9Y06X3bTHWEijmO1IhXiGZw== 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=8zzsL1kp415Jf3ZR08yu8zyJesz2ZChIlRl31hCycZw=; b=CCLbG9z3lgeW6i036KK2b+Gr/4qgTdYKCS/3bTcpPclaYrO+KVyAzusr2saz/EMG+PX0z5wfCUzKMU27fG72t9NtvLcyC1ozo7gVJ53Dbi8wGYbN1AK+/qL7ZUfKscgQP7MRWjdYpluIENvxp9p0qETLleywb4QY4EakS72cH1Q= Received: from DM6PR06CA0031.namprd06.prod.outlook.com (2603:10b6:5:120::44) by SJ2PR12MB8012.namprd12.prod.outlook.com (2603:10b6:a03:4c7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Mon, 12 Jun 2023 04:36:21 +0000 Received: from DM6NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::3f) by DM6PR06CA0031.outlook.office365.com (2603:10b6:5:120::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.33 via Frontend Transport; Mon, 12 Jun 2023 04:36:20 +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 DM6NAM11FT048.mail.protection.outlook.com (10.13.173.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.33 via Frontend Transport; Mon, 12 Jun 2023 04:36:20 +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.23; Sun, 11 Jun 2023 23:36:19 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh Subject: [PATCH RFC v9 25/51] KVM: SVM: Add GHCB handling for Hypervisor Feature Support requests Date: Sun, 11 Jun 2023 23:25:33 -0500 Message-ID: <20230612042559.375660-26-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230612042559.375660-1-michael.roth@amd.com> References: <20230612042559.375660-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: DM6NAM11FT048:EE_|SJ2PR12MB8012:EE_ X-MS-Office365-Filtering-Correlation-Id: 39aef988-d67f-4a0e-fab2-08db6afe9227 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iBTBvJS9Nb8tlWWoAQnxaDXixIBqez+9IO+HO5ryNUfCBF2WURY5vMhy9JgbF/23bcMk0AfTwEW88A5S5sbysRN4IovXi4gO2GdM15lvoIwI1mbNeA24a728lUOyXzsV+hHotS2g4nJiY1UO/f/0JLabwzp1VmBipz59JA/aoWqJadTdEwoLuriBsrEtq1ZvDNMs+nRAduPQOKS1URtwaqAJiE3ejswPf/D+jPEpsxiDSwNL6uqaPuZNQcJgN9rBgc4nuEwmu1fuAOuyjWTmHL4vSzHlWRkhom56pfQV6QNtahHAqrxb6clq0lXwipp1JPVhPccMw6WrNH1Rx5CQCNjEzxRG80m6cugGj3ayzFTe3nPAXZil3+LmPuYJoxF1aQSWWQ+MdsSp8BskFfOSpLhYp5dOqdO9xqgkFbS2eXt1xzToWFta3hV9A3E+oVhsOyAhThk2iJhBrBVtjILQZ2uX0vvlVU/bq734/b7QKSkxh6kJ0bQ01Up2iDEfI6r0KtrICrgKKWLlhFc+rUzoy91X+pw+gfMc18nqL5gTnDQus3toKW+DXjcFPTS3CVAmCcu4duTUINzchqkxDLuNhh5zHlQomp8d4/RjswOnDbn3jVc4RFmVOOs7Vdi2qjjCSCsMirKNCjW42ABpNrgScgB4oaBEjYFCoroDgPB2Byvh5uLL1mVrpfq0ZEQkmJfxLmBV9DQDrzNjiDo3hhdGB58GW+kZF1F2JreCIQtuc3ITPvIXLzLR9uCrWaKHZbBHVhwoF5Gg/XK/E1vABfvmBg== 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:(13230028)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199021)(40470700004)(46966006)(36840700001)(316002)(40480700001)(54906003)(36860700001)(40460700003)(82740400003)(356005)(478600001)(81166007)(70586007)(41300700001)(8676002)(8936002)(70206006)(2616005)(4326008)(16526019)(426003)(186003)(336012)(47076005)(6666004)(26005)(83380400001)(1076003)(82310400005)(7406005)(86362001)(7416002)(5660300002)(44832011)(2906002)(6916009)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 04:36:20.8606 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39aef988-d67f-4a0e-fab2-08db6afe9227 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: DM6NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8012 X-Rspamd-Queue-Id: 60F9C180010 X-Rspam-User: X-Stat-Signature: uaicx4imwxrissqtp43rpd6u3e99dqbc X-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22265BDGY99dSkw76tNGKan55xq+gQR2YrfXU0SlxxWmd9xEnQYeMnawYjVXbNrsBCQfv01WrfufrleGbU2DCA2+5EbBf4W2DHQ0JXTn+E9yVtI9/Hg3QdhgUn4d3fpPVzTVTWeAGk03Ieh5QbYCfoxK1Z9sT5WWuxlwp1I80YR+40JGmznbcpl56VNmVLSGD0fG+x87io/E8FRd0NeGBQ7uikYh113raq3Vhn7GlfxsTScE1tkWf+IExM2XBVmqAKpb97imnkmRLzJabf9Ze6BMN+IID6xkB+5WMCv0kpO1OIw8KjOae/C63U0SQ== 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 a4fb53fd15d7..aaea4afcda98 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 b88295aa7124..2bceb0060880 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2538,6 +2538,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; @@ -2804,6 +2805,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; @@ -2928,6 +2936,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 50be41fa16a0..1ab117daebd9 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -711,9 +711,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;