From patchwork Tue Aug 6 12:54:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ravi Bangoria X-Patchwork-Id: 13754818 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2067.outbound.protection.outlook.com [40.107.212.67]) (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 111231C68B6; Tue, 6 Aug 2024 12:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722948932; cv=fail; b=Z9ifxgsSKdajYmHu88nsVp0eZuWWGiYPCE3WlJ00AES3I+l9RbojgaA8solzL7TRMI0xjmOzCrsdqXwDAJyL/EdGQQOblmq/qoKsHVsJaVnOK/X+tVphBZFVvd6mqyMec5J9HM8ayvGzw9u2dba4+zy6og1MNMIAKaxHw7+LOv8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722948932; c=relaxed/simple; bh=k4NMd9/Oef2ZoLEoL8QQaXmxAC2WZcEykKDVWYdf/Ok=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pMFXn46KDp0DU+/q5XxtJsLIb1uQRr/ywfX2Q/MN6nX06MCx4hzD5Ye6XJzNsaNlUzjRYam2hhnobRAnPAoOpmEPkJ6Dpq5t1NS88y+i+456H++yFrh5QzHjPqwCzPX7HlfZd3uc20iK3ccJ20ZxgFQCHn2Nxsdpm4T/p7sqL28= 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=ThmMHlx3; arc=fail smtp.client-ip=40.107.212.67 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ThmMHlx3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iSW30tHM6xfD2dwWMFgJsTw+oH3aQVPqkyNpuagalT/iTDGEW1GwxMctPSsFs/9Hwlvyv5CWr+PyYv3eeTaFGaA1DkIiPJIHzmTuC44ZIwLGuNK7v8zOWASLVRuiYynq4i+siWAqYfR5rZBlUu64o4+0c4Vbe8jvg9+yY0zywLWgegzlo+BvnkblqwO5AizfnrgosMEeGVuSBhrOaP7CuPiJQHextMGs+SMiMVs57GXgF+xQNRp6B+EyYjknUO50ncnvg1j27iA16ReFr/CYpB5m6u1DVoRFoYvrfocC78o96zzfxl0xOgjVwNPwvnDV13JDW/tVljNUNzKlgKGE3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=nlu7IB+HJKWz/T/yFB5c1oCldbQ3ZFftyFTeoVgbgpg=; b=ELwCtbvao9NAAjzFpBpbRzhtA0U/yUYulRuk+HQKKENxzbPLOVPxpCcPknnW/1HhUD3pqwoy31qt4ugfhLETlt66YJDxHZeErp9u35T8FvrxwrEib3TKpFQIauHVoY0Xl/P8x9MSnVSyIWPQ02KWyPRWBbsVmqr9fU+gq3g1sL2Yx46l7XvA4rOeMX7KLdxwPm00ABGcHsQq4QRuDk5VCKBNcF7YoWAi5CsrOdmndHnuNCpzd2PbBV22JFPkJvtiGNElgfZEPQ2sDj4jy+lz2zOvabluIXA1i22xXdjD5LKYO5h0Sj+kLtT/Y7fkYfCwxov6WFHg372SeMaoH/ucww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linutronix.de 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=nlu7IB+HJKWz/T/yFB5c1oCldbQ3ZFftyFTeoVgbgpg=; b=ThmMHlx3BPbqntefzqlM1XhbASUvp0qrHP1x36A1x3+bzAYuRV8kI72bgG2B8UoRnNNvUaU2xhiAeoYfRBKm2S+A3QUuQUlTA10+gQd1SGdn1+icxNmAFPneLODTXtUSx3HgUc+X97Afo9QOt6rccTZWFRvjHPuRnlI97cEpo4o= Received: from SJ0PR05CA0091.namprd05.prod.outlook.com (2603:10b6:a03:334::6) by IA1PR12MB8189.namprd12.prod.outlook.com (2603:10b6:208:3f0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Tue, 6 Aug 2024 12:55:27 +0000 Received: from SJ5PEPF000001CE.namprd05.prod.outlook.com (2603:10b6:a03:334:cafe::23) by SJ0PR05CA0091.outlook.office365.com (2603:10b6:a03:334::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.10 via Frontend Transport; Tue, 6 Aug 2024 12:55:27 +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 SJ5PEPF000001CE.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7849.8 via Frontend Transport; Tue, 6 Aug 2024 12:55:26 +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.39; Tue, 6 Aug 2024 07:55:19 -0500 From: Ravi Bangoria To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 3/4] KVM: SVM: Don't advertise Bus Lock Detect to guest if SVM support is missing Date: Tue, 6 Aug 2024 12:54:41 +0000 Message-ID: <20240806125442.1603-4-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240806125442.1603-1-ravi.bangoria@amd.com> References: <20240806125442.1603-1-ravi.bangoria@amd.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ5PEPF000001CE:EE_|IA1PR12MB8189:EE_ X-MS-Office365-Filtering-Correlation-Id: a7ff212b-c720-4d93-8a76-08dcb6170b5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: M52xhugRWgzKHd3FrOdv8p4CkTLS+KqPQABgIM5SEP8XajOY24gBNbpWqbxg45/WEND3ajHfE5IjBdMlAkSO5M4UtMxbyWVXNH9zCh9irp+WbLJV32CzOW7Kx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VCKKVxDsycaXRg5BUAoUiOy+qLxkuePISVn6trjOLTUw39jb27e7lPu8x8KcJvIJR0oUZrQr52puE9aaD0CBNA7zLqKJqCe5nsBP/NRLgwhLyKvdE9AUa7egYr8SB2aPvLdz6PRXkmCcEc3hp4SeICqmJaDR3QQq11Gu6UZ8lHed+Jrm+EjOEMZ8oaYR8LTUd+IHP1KutG+hywhyc7kC7Ioelpeq9eqo0b3A/pnEXJPNvvmquELfw== 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:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 12:55:26.9347 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7ff212b-c720-4d93-8a76-08dcb6170b5a 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: SJ5PEPF000001CE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8189 If host supports Bus Lock Detect, KVM advertises it to guests even if SVM support is absent. Additionally, guest wouldn't be able to use it despite guest CPUID bit being set. Fix it by unconditionally clearing the feature bit in KVM cpu capability. Reported-by: Jim Mattson Closes: https://lore.kernel.org/r/CALMp9eRet6+v8Y1Q-i6mqPm4hUow_kJNhmVHfOV8tMfuSS=tVg@mail.gmail.com Fixes: 76ea438b4afc ("KVM: X86: Expose bus lock debug exception to guest") Cc: stable@vger.kernel.org Signed-off-by: Ravi Bangoria Reviewed-by: Jim Mattson Reviewed-by: Tom Lendacky --- arch/x86/kvm/svm/svm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index c115d26844f7..85631112c872 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -5223,6 +5223,9 @@ static __init void svm_set_cpu_caps(void) /* CPUID 0x8000001F (SME/SEV features) */ sev_set_cpu_caps(); + + /* Don't advertise Bus Lock Detect to guest if SVM support is absent */ + kvm_cpu_cap_clear(X86_FEATURE_BUS_LOCK_DETECT); } static __init int svm_hardware_setup(void)