From patchwork Fri Jul 12 09:39:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ravi Bangoria X-Patchwork-Id: 13731535 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2055.outbound.protection.outlook.com [40.107.220.55]) (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 7939814F9ED; Fri, 12 Jul 2024 09:41:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720777284; cv=fail; b=W6t08N+txQgAJ3rCVxGEKYPAq4Ux/hots6NtJgfsUTtpWbvW/eLx0mxaEykiV1mcd2GFWoHLSOCUVRDXIUjZBnxEj9j6xa0p0Q7Djv+iVnj86oTYqCMPDOTZEnuz38CpEIKB4JPs++ILTJPikWbfmSVXvXSiTm0AGM7cVVm93VY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720777284; c=relaxed/simple; bh=IoVvaE3xZ9R5+M+fDsytf4UsGiS2efyI9wsyZjQMncc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RtC0alSOKCyjHvg3rDFSItHTt/aJZDJVcYBbsZXk/T4kl7oINTmti7OD0mLbPeWLe3UCnv1Mz7rV/UNsdmPZ2jYDKT2qtVxJhf8Ok/gVte0pAYEZ/kkT/PWe79GxHM6b+fAUitEfZjbG+9+i1FMpoSCxWjZDlXv5gORQ9BIb+2g= 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=VAAqt6Fd; arc=fail smtp.client-ip=40.107.220.55 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="VAAqt6Fd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Krrf+ZqsMwEiPy5ANt1EtHO/jwIOlTgjXMz3WckwGBHMPNT8+IumcM+bjtPhcUpEj2nraQxamUW8AZ7HQ7hG5SszKajO34YHc1Tpf8YbX7Uk1f4OyWI+AbHaQd1WyzS4pRer9Uz7XVq91AIOhz0X4Nw1QxHUn2o9VAgIpxB7OTXrdjSUkS0gSzw+EvVokC8DSHfcL8jD4BEsaNhlYr/s3HLYAGMyTB+9rZiqe2JVS4/bGSGiCs7JqIrY8uF6MJOSzjn6i1accPX6LLn18MuiLkZsQFXB7WOFmJBLzkaRuvVCITpy1jMB3nAS0sG/UxI4dTYgPInvAwTNdFikDMlVAQ== 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=mrVvy5wSsYvWEH/zMIUOCM18ZLpeaOVIvu30TvxsVbA=; b=oUIRJBlw7QAJtkm6p4SYwk5VbCY3mgrRdMiN9raVcBHT1DBveHVzTSnbGIKsG/ew5lKM4kbLT2KltStC4VB4w3NB9cAgGF9eOvb4/ZbwznodFsZm7Pue6oA8eM/xswKwmaUo423Vz8lLQxxX/cOrLx4k5nc6XV/3cuH3iwQbGKIukrym7p+1Wp0W5f4J2MpqGVsaMsDWrB1tvH41KwC6hdyJIUxlnldUOsr5CEZ12G2KA4wc/gGGScqc8qF6qi4b5Uryng+wak1SHdHw3hbzIHOwBvCGjdzQmFnk033CRLyO6iWEuVO+L2xsGl2HXcSzIj/kAtcCG/yEtJ0vigvpQg== 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=mrVvy5wSsYvWEH/zMIUOCM18ZLpeaOVIvu30TvxsVbA=; b=VAAqt6FdbSLiSLHl6fwS/ry7XPUq9jNRNW7/kGF0YbfkuadSvYJXoJ3TXJ28+KodwLGvzkGN3K9rAz0bMPbtOGhvImv/b4w/A+a2mb1gmxHtc/motw1LTCkHFSOdneT7dDp14BkgDNwK7QU406/lwRNuaJljdVnq0v4iI8bm9eY= Received: from DM6PR13CA0066.namprd13.prod.outlook.com (2603:10b6:5:134::43) by LV3PR12MB9412.namprd12.prod.outlook.com (2603:10b6:408:211::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22; Fri, 12 Jul 2024 09:41:19 +0000 Received: from DS3PEPF0000C37D.namprd04.prod.outlook.com (2603:10b6:5:134:cafe::b5) by DM6PR13CA0066.outlook.office365.com (2603:10b6:5:134::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.20 via Frontend Transport; Fri, 12 Jul 2024 09:41:19 +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 DS3PEPF0000C37D.mail.protection.outlook.com (10.167.23.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Fri, 12 Jul 2024 09:41:19 +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; Fri, 12 Jul 2024 04:41:11 -0500 From: Ravi Bangoria To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 3/4] KVM: SVM: Don't advertise Bus Lock Detect to guest if SVM support is missing Date: Fri, 12 Jul 2024 09:39:42 +0000 Message-ID: <20240712093943.1288-4-ravi.bangoria@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712093943.1288-1-ravi.bangoria@amd.com> References: <20240712093943.1288-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: DS3PEPF0000C37D:EE_|LV3PR12MB9412:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f9915ff-1382-4908-5be1-08dca256c85d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: wNYvxpjsWQPQjF02Xbc55SgTukK7RsbBfSzHZBg8VZHer7qkv4xU6zYezbLwES+xqM/9Pqc7g2aaxR7Vv/JfjKPtZSL1Sv3/B5HBe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Pw8zDXoQaeATgWcsaWqulE7XUO388vsM5cztu0IjpvG38V3VUEgYTMWpPd2XmFt/WNoz79wvbfqYzzNdQrN+MnKkNvrO4UnDjEYXN/asFi965Y6eYhNw3Igqkb0iW8N6JLfu/e5gsN5OxOLz93V2Vz5OsAqdD8T3J1cT1RsIzErktONQRh4r+C1+4gRVFG6VBNxRKPJN6ExIkE5rTezu2/rG89nXEcnQphpice2FutVR3W9MkRJtA== 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)(376014)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 09:41:19.1279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f9915ff-1382-4908-5be1-08dca256c85d 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: DS3PEPF0000C37D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9412 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 --- 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 c95d3900fe56..4a1d0a8478a5 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -5211,6 +5211,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)