Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp237346lqr; Wed, 5 Jun 2024 04:51:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5CP/MM0Q2ko++TJjQTmNXljqVAAtkzbVWrcdTACpCHX3L9IGW9G6mDwA4buzCOHKGDqb5+rm0RhYNSG6uzapx11fc9l4CNMT3k9I1Cg== X-Google-Smtp-Source: AGHT+IFJ10PmsBcJeHdA7e0xvSXSh8pimrbnndseBcWB3lMw3BIUl/8jqH7BbZQiIyIj13YrXXIH X-Received: by 2002:a17:90a:744a:b0:2c2:863b:8903 with SMTP id 98e67ed59e1d1-2c2863b8a0amr1302373a91.26.1717588275455; Wed, 05 Jun 2024 04:51:15 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c28067fea2si405757a91.108.2024.06.05.04.51.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 04:51:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=NyztrFS4; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-202296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 539E0B23677 for ; Wed, 5 Jun 2024 11:49:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADFF61922CA; Wed, 5 Jun 2024 11:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NyztrFS4" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2073.outbound.protection.outlook.com [40.107.92.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30C2C27459; Wed, 5 Jun 2024 11:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.73 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588153; cv=fail; b=NLDbaxvSe9IBdcFut9W0pi0IRhOMf7h5ujtTDUG29veHKOgM+FVuVdpMmbm5wv2f6W58ZdIAFS5ipv9MtT+vTT/Sc4NIs58EBTu09C2r/cuEsIwPPhwSHE6OSAvYef4O8aYwR41bHmOvbEPzg/2aRm9QkHUdk/cMXxPfe3MDQ5Y= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588153; c=relaxed/simple; bh=Pl7VrNg6r8jRG6Euk3BO2Gu1aJujI21dQ3wxD2mES9s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DVVxbdx3S8xuEtpffZp+xbAvYE0tYAhBWTr4lF/23L/lACk7WM+U/pld7kc2shZ1Zms76cjKb8tIHbdqak638Yw++/9Fa6mKSptr5EIB4d1y8BL/H4c1ZRVkoq7ur/ttPyiAlcwxk22KKJk8kSlFz+a5WPllKdwvjpibZLnH+tc= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=NyztrFS4; arc=fail smtp.client-ip=40.107.92.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DP+K8rCun5C1/BClJCcwE5M98iQ8j2aEP16M216RCycYBVPtF1zob7jdN1NX0YJxp2oDwyl1AjbkC9xOq/xapZX0xSFDf3xGVYSmLsDwj8mqwy6XmlyZFDVJRmVAdSa/PHrwn1BQlJU1XE8BhSs+OTxwhlz82at0ElPirZm4ewnnxBfclfumphjBQpPAGKorjpG12HRUfCXlYbXwz8Vbvn2OAXcPGt1FdZp7fnr2leqT0yju9A3JGA0vUWl8Az1Q3liEIzJAdS/rN3+i/oIXtn5V20yaL0X0t8eJlRnDt9fSD/7kk59OBIvQCtjp8Z608KI2zIQRPFkaDfa3PHpAXQ== 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=c/6aNdu5QBu/Ycn53szS9/KFT6NBIsdQArj1nrSV/Yg=; b=jXYqhe6a+cs+89/r63rfCxk4LlmDcFF2FPQC2aDjlCEDfswDB8Zm9bVfdVoiv/4i5zhSoU0MWDz6PyRsjd7GHydVkdLLMqGCR3RzsemkSoz0Yp1fRpGUo+/pGUhw+w+z9X3JVpAuO5l9nYukyhB04DxihJbuWl4jBWhm4s4dPQPsl394CqEYFe+BeL8ajFlFI/iXXR7JoSF3WegyhALO5ylyYtXbfuL9DxG5rPtCb2L/n8cv2pynfiiNP4a4B2RX1YmxGKI7q8bva4+Iy8TVcWDb4wIbm+DVQ/Ugdf5hTRrlIiIfT3Z2ZYPM7fGvSTA5V3o4wRC1gNl+lOc8gXLugA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com 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=c/6aNdu5QBu/Ycn53szS9/KFT6NBIsdQArj1nrSV/Yg=; b=NyztrFS4t86xSX7J8w+dwB2qaaoUFEA3CjVpbcjZlLu3RMLzOipoyg2mvolot0qJPvqtbsQSb7wJH5n3gYkFNts++ejVka6u7eEwArTQQktutFIKJFwwv1FPP5h9GXuqukoqceBzAK/BtUqO9pnVj1Gf/ZOBcNBbYuBrP3vh6bg= Received: from BLAPR03CA0082.namprd03.prod.outlook.com (2603:10b6:208:329::27) by SA3PR12MB8048.namprd12.prod.outlook.com (2603:10b6:806:31e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.32; Wed, 5 Jun 2024 11:49:08 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:208:329:cafe::28) by BLAPR03CA0082.outlook.office365.com (2603:10b6:208:329::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31 via Frontend Transport; Wed, 5 Jun 2024 11:49:07 +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 BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.0 via Frontend Transport; Wed, 5 Jun 2024 11:49:07 +0000 Received: from BLR-L-RBANGORI.amd.com (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, 5 Jun 2024 06:48:58 -0500 From: Ravi Bangoria To: , , , CC: , , , , , , , , , , , , Subject: [PATCH] KVM: SNP: Fix LBR Virtualization for SNP guest Date: Wed, 5 Jun 2024 11:48:10 +0000 Message-ID: <20240605114810.1304-1-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240531044644.768-4-ravi.bangoria@amd.com> References: <20240531044644.768-4-ravi.bangoria@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: BN3PEPF0000B06B:EE_|SA3PR12MB8048:EE_ X-MS-Office365-Filtering-Correlation-Id: 4138d9ad-737c-424e-c688-08dc855581b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|36860700004|1800799015|7416005|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IKsR7EzsyxHMqOrHWiCNMqqvA6DoUKj7dcJ2H/v6WkUDZsIJBtoBQ/P0qdw1?= =?us-ascii?Q?ATMKCiQo05qlHiBO1pAr5yZTDcOp7f0j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ZtyGQ7xDaPnYXtmZtOMtAvXpSX8C7t2wjxPCkFMfqvN9TmMhmtcz4aZDgl1j?= =?us-ascii?Q?Q43tt2JJmU3/ibZhnGnUVdTabrOT0pWKhS3ygSZHtxfLNGe/Ag7FjNEUBbDH?= =?us-ascii?Q?iB3ZnR94s/4XKD4CdkNjDHIPBtkaxX8BasI6WewxAJRMLG4CHOjdjWpbcf+i?= =?us-ascii?Q?HmDvR4hByFm8gpOYTmcc0SA03TCxhfy284AKHIBk4GBr+vIpExXMZYdMD5Ws?= =?us-ascii?Q?UaPD8pZM7QGzGfJSyR+/kW4gVgIyXIDF7IRIxlMiUuUX+T5nxJuhHV8fX9I7?= =?us-ascii?Q?eyvlV0Y2CgQufZl3Ng3Xu6W6/HOR0DEOvcZPsIa09JR/dCWYUCnNrL7uFblS?= =?us-ascii?Q?tV8el5/LPD8FOyE42XvoXaBPh5QZP1jmRsT9rL+NDuP6tYvF6PRLovnXl4s+?= =?us-ascii?Q?cZwlE8bKAE17wd3Cg6sYYflx8JC42sL5fQ6VaGv8fZYrqplM8w=3D=3D?= 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)(82310400017)(36860700004)(1800799015)(7416005)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 11:49:07.4161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4138d9ad-737c-424e-c688-08dc855581b7 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: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8048 SEV-ES and thus SNP guest mandates LBR Virtualization to be _always_ ON. Although commit b7e4be0a224f ("KVM: SEV-ES: Delegate LBR virtualization to the processor") did the correct change for SEV-ES guests, it missed the SNP. Fix it. Reported-by: Srikanth Aithal Fixes: b7e4be0a224f ("KVM: SEV-ES: Delegate LBR virtualization to the processor") Signed-off-by: Ravi Bangoria --- - SNP support was not present while I prepared the original patches and that lead to this confusion. Sorry about that. arch/x86/kvm/svm/sev.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 7d401f8a3001..57291525e084 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2395,6 +2395,14 @@ static int snp_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp) } svm->vcpu.arch.guest_state_protected = true; + /* + * SEV-ES (and thus SNP) guest mandates LBR Virtualization to + * be _always_ ON. Enable it only after setting + * guest_state_protected because KVM_SET_MSRS allows dynamic + * toggling of LBRV (for performance reason) on write access to + * MSR_IA32_DEBUGCTLMSR when guest_state_protected is not set. + */ + svm_enable_lbrv(vcpu); } return 0; -- 2.45.1