From nobody Mon Feb 9 22:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1763719082; cv=pass; d=zohomail.com; s=zohoarc; b=Aso6sVRv3lppWBH24pPGDY/Ooyan3X2DzRpVbApE8nt/LE/KpbW7ZNFHM3YJ/jBjHRQYqX8hcesoFgk/qqSInolYeu1O6qr55u1U84bWbHOW5hz3WsJFjZgRYuT9LQX3zwhaaSYIegpqIUyh1RGaxrcSFEdw2an7yXL387sooTI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763719082; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I8R6BVjSDZP6lhstmdFD8xZnLsbVMFiBgo3iX6PFKJg=; b=Q0DJC+pMnzfONRVWlp1DidCmM0sTxZ3YIAZNkA8mVaSSSlnzvJODLawDvn4cjTOpUYQztyWeE3gntIrN2BMBpAHANTrxIfmq2XWn8gohMHXCk5Zq6GLH2cIxEOFiYXmr0iHJjGC8R6jlN6/EvkpR+Rzc4xyrF5xcHoJcNXUp1bw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1763719082640418.63705900142156; Fri, 21 Nov 2025 01:58:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vMNta-0008PW-HC; Fri, 21 Nov 2025 04:57:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vMMeR-0005Eh-8J for qemu-devel@nongnu.org; Fri, 21 Nov 2025 03:37:55 -0500 Received: from mail-westus2azlp170120002.outbound.protection.outlook.com ([2a01:111:f403:c007::2] helo=MW6PR02CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vMMeP-0000P7-3A for qemu-devel@nongnu.org; Fri, 21 Nov 2025 03:37:54 -0500 Received: from BL0PR01CA0008.prod.exchangelabs.com (2603:10b6:208:71::21) by IA0PR12MB8932.namprd12.prod.outlook.com (2603:10b6:208:492::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9343.10; Fri, 21 Nov 2025 08:37:47 +0000 Received: from BN2PEPF000044A5.namprd04.prod.outlook.com (2603:10b6:208:71:cafe::2f) by BL0PR01CA0008.outlook.office365.com (2603:10b6:208:71::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9343.13 via Frontend Transport; Fri, 21 Nov 2025 08:37:22 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BN2PEPF000044A5.mail.protection.outlook.com (10.167.243.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9343.9 via Frontend Transport; Fri, 21 Nov 2025 08:37:47 +0000 Received: from purico-abeahost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Fri, 21 Nov 2025 00:37:44 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MSdEJUDJPYcJdFlVyomXI6RjRvm4B95u3hfMFd7RkEyKNGhkz5G8rj10mmGAOfCAFWw69Skr1effKVHqZ2zpAUHiBRF0Y/AOLVA7DsCGvkscD2oSpXh5ag/xeXoVAVE5rKuy9jbOBWmFMTJS760cgDD+jwkhf72s7tMewCWVI+dFpSPoZrH8mHuqQMaacJ12eE/pMv6U2gl0XRCxCgiqAbkr3BdeY7NodkZdIjDZxMS08yr+PAu3yAq+YQM8xYfyXALIoT3FSK6F+iW6pQNQGVGZutKrCnqwrmsP1Sy+MkQGhUsE7YPNCsuDe3MeGU1Cns9+/a+gR2FYe5INEEe+1Q== 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=I8R6BVjSDZP6lhstmdFD8xZnLsbVMFiBgo3iX6PFKJg=; b=L0yvaaik8ZZWvefM9QVdImU1yBmn6X13Sa1aduI/4e+MSKBgjI8KIHQrlN5MqyuSatqsYUr//nDOctvnUsyJ2ML7e/R7EOniTAsvAgjeiS1CDEMm26gWLkJW80W8XsClcMalCy1iXmfTHLRai6WjTko5kbmFDAv9falaKJUj3Y+xYdYBS5JUR+syDfDKCuZamO4Wz8bHm4m9ZH+Tr6ZFD3EwOUA3W/MMAY793t6qdadIVJ3r46j3DVKe95m8X0d/XErF8frtPihDvIXFPPt4Ki6Vo5C5kKAj6y6ej2SJQ3KPWENn1pp9tpOUlonLKs30G/9GGxieNIPMaf4Qo4Jjcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.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=I8R6BVjSDZP6lhstmdFD8xZnLsbVMFiBgo3iX6PFKJg=; b=2evXGuiOFx8kAbo4rEQghn7q4DfpOrTjzN2t1WLyPbZGUHraHDp10RVU3o5PGj0zKH8CEj36n8s8bTBaCtZoytT4DT+hoZkOvKSFTI2hMILgo/uclXeLQf/V85q//iyJ4Qjc6F1ZGsJOgSEBKtRO8iyTXvCQ7Q/c0hz8trToK6c= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=satlexmb07.amd.com; pr=C From: Shivansh Dhiman To: , , , CC: , , , , , , Subject: [PATCH 4/5] i386: Add Bus Lock Detect support Date: Fri, 21 Nov 2025 08:34:51 +0000 Message-ID: <20251121083452.429261-5-shivansh.dhiman@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251121083452.429261-1-shivansh.dhiman@amd.com> References: <20251121083452.429261-1-shivansh.dhiman@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A5:EE_|IA0PR12MB8932:EE_ X-MS-Office365-Filtering-Correlation-Id: 407bcec0-b86a-4d27-96e4-08de28d93fb6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RpM065m7BHYvTgzB77PVxapBkS1YERvooB9XZ/T9NsykhERKn96isHv7hpDk?= =?us-ascii?Q?w5wwom4LajYfQlMQnJW+87SXx/eW9Z4ZDRbWGXLJRzWy1tqHz/0W+fJbIckP?= =?us-ascii?Q?ssasocZk8P4A8TjGV7KSbPncogarPu0lnVd6BEwk3+US0WjTIFMQR5DZwVXU?= =?us-ascii?Q?xZt2sJ5H6yiHgNzEHFqVKUvXadae+TMPWEC0xa6pz6jNHnMyEl7vxJweXoNE?= =?us-ascii?Q?lJuLctp8FYPfT7nx9s4y7/oqQugOwJfQ/Qul11Mxdiq9wEHwRjzZrgMmOmr3?= =?us-ascii?Q?uV/81P2Lg5ZA8akTgAk5gB1HT0UKivkYgp6UnHKZBUipAxv4xC+kQo4sYE/d?= =?us-ascii?Q?cDv/KaihVPyEUc9DroQTLxQEfCULDnI7FrVsl3wBLijB03CIEJRRnIkECFeh?= =?us-ascii?Q?R4LITA9Cn+3rJ5NYuVfeHnLeJTfXWCe9wnPuwVqCaxjvNTBJAJEOP8KJjkGs?= =?us-ascii?Q?tmXhdBNULAZrs1hTa4K6o5zThA8IQasE3eQORZumtHqpWr2toLSAR787M9Pw?= =?us-ascii?Q?xV9E3iJK7crCm6+ufW5OmSIGoNYfQLHIW4FfGyoXmMTN9YGIo0AWc0U2P0ze?= =?us-ascii?Q?a0P7x/MoEHeq4/s+Wd9ZvlzfEFdBeMGCRop91U+Vxvf6Ry9swAspFxOeDTkF?= =?us-ascii?Q?/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yQa8FeJO3+x8AuBZJSc1?= =?us-ascii?Q?JQG60xBHtEV1CudmUC4=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014)(13003099007); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2025 08:37:47.4705 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 407bcec0-b86a-4d27-96e4-08de28d93fb6 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8932 Received-SPF: permerror client-ip=2a01:111:f403:c007::2; envelope-from=Shivansh.Dhiman@amd.com; helo=MW6PR02CU001.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 21 Nov 2025 04:57:37 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1763719084121018900 Content-Type: text/plain; charset="utf-8" From: Ravi Bangoria Bus Lock Detect is enumerated with cpuid Fn0000_0007_ECX_x0=20 bit [24 / BUSLOCKTRAP]. It can be enabled through MSR_IA32_DEBUGCTLMSR. When enabled, hardware clears DR6[11] and raises a #DB exception on occurrence of Bus Lock if CPL > 0. More detail about the feature can be found in AMD APM[1]. Qemu supports remote debugging through host gdb (the "gdbstub" facility) where some of the remote debugging features like instruction and data breakpoints relies on the same hardware infrastructure (#DB, DR6 etc.) that Bus Lock Detect also uses. Instead of handling internally, KVM forwards #DB to Qemu when remote debugging is ON and #DB is being intercepted. It's Qemu's responsibility to re-inject the exception to guest when some of the exception source bits (in DR6) are not being handled by Qemu remote debug handler. Bus Lock Detect is one such case. [1]: AMD64 Architecture Programmer's Manual Pub. 40332, Rev. 4.07 - June 2023, Vol 2, 13.1.3.6 Bus Lock Trap https://bugzilla.kernel.org/attachment.cgi?id=3D304653 Signed-off-by: Ravi Bangoria Signed-off-by: Shivansh Dhiman --- target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0fecca26dc4a..852b3a33b54d 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -276,6 +276,7 @@ typedef enum X86Seg { | CR4_SMEP_MASK | CR4_SMAP_MASK | CR4_PKE_MASK | CR4_PKS_M= ASK \ | CR4_LAM_SUP_MASK | CR4_FRED_MASK)) =20 +#define DR6_BLD (1 << 11) #define DR6_BD (1 << 13) #define DR6_BS (1 << 14) #define DR6_BT (1 << 15) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ed3d40bf073e..00c44c2de650 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5864,14 +5864,14 @@ static int kvm_handle_debug(X86CPU *cpu, } else if (kvm_find_sw_breakpoint(cs, arch_info->pc)) { ret =3D EXCP_DEBUG; } - if (ret =3D=3D 0) { + if (ret =3D=3D 0 || !(arch_info->dr6 & DR6_BLD)) { cpu_synchronize_state(cs); assert(env->exception_nr =3D=3D -1); =20 /* pass to guest */ kvm_queue_exception(env, arch_info->exception, arch_info->exception =3D=3D EXCP01_DB, - arch_info->dr6); + ret =3D=3D 0 ? arch_info->dr6 ^ DR6_BLD : DR6_= BLD); env->has_error_code =3D 0; } =20 --=20 2.43.0