From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD7C926C384 for ; Fri, 5 Dec 2025 17:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957488; cv=none; b=V9aBuhvApAJ2QISrWlfPwHj3zkJ2q7E+HU1ucVoM/WTAZ2irVdm6KXUFkfbsVsVcTP5lAUNbDKxgU5PFU/RPmKaJkzQv/CZvEmUXh2501AGhhBIqinvruaCjdpxFXSS8s94e017Ufp0/jGyNBxNHNZOjypV7dsrcFYiGfrfLOj0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957488; c=relaxed/simple; bh=QQUI98YqAhUSes4ECcGZ5WZF/olfwYiYRiq2OFls8Qw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tJP4ghFQnBVzuzGqX4B19xbdusIsg3tRsKltoB0+vM4rYpto4k8o3Al02XXifyw5+cyg5endXoKOuP8irCcHu/s6DNqlIBqKCmuHHih0lsbSS+FdHqK7UMS6o9oeKPNQmmvzs8AEAk76s0xeuFmrcdUuSvaoFfBJq8fSpfiixWc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Z0gsakCl; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Z0gsakCl" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3493fe3185cso3118726a91.1 for ; Fri, 05 Dec 2025 09:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764957486; x=1765562286; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=tDQiNiNXKii8zF9sreLIimeyJDUOVZ5atq+rFjJQob0=; b=Z0gsakClYn64shX11i2bpjwg1ATLT9VzXGedfY4CmP2FFTMFyv/QtI4+OfIlGqZYdA CdZnds5KTOBEORevV361FHY0BXYOUZHLHYDU6wmvQ1oncWjU4vgEsdlEdFd9qG5U+k7y 6z4yqOBXzpC/Wx9PDF8uBKIhIZu1KWXUtslirEoHzTNRL+hQmBSjUDBEIv291YpzP6tn H+tFZq+H3pLKrcc3galoXNKILVa6uLKWqdTAsyIQ/qLXjkCMb59DmpTq7pHsdKaHj1fr dyk6RFzXcgyUeYTfuZxiy2wKq/93UlbrFCBd7jCvB+OmNh4M/eE+giiOcYa15uUixr4f M5Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764957486; x=1765562286; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tDQiNiNXKii8zF9sreLIimeyJDUOVZ5atq+rFjJQob0=; b=OyMmAu6MNJrGlB+Ukp55SYhxCeHKn2hYUErndkyPU481ebhVqyPgiq8dLHCQXex9Wx Fi2dlrRw2LKrSvcCVDcvhHaFskg6U0hi9ePgjau9RjrP0VXPn+sLP8sC1GBxV8q5C/AQ nXjn5uQbMzDnP8jDscHsLtfrJ8R05lc9xZ3VqPoU7biDVgYleqwMqjsEF0U47XoQIGbm P4kDPUKoqH10V6R3BbCi9Swga2Y6H9b9Sze56BmAYVF9mNO+3VDhTlf00BgIubrqzfeH GUr10B3SQE+sqTPcmJuZ8Gh9PdqkUthaj0g5RIUIEW5Uu52AqN6HvNRLkB1/3OFlciBl GJ9A== X-Forwarded-Encrypted: i=1; AJvYcCXE76yvLOb0ixUnJL8gn96eDVbrQzh2RQRGNz8P7xfqxy7Y+v2Unp0Cl4reV0ILxrXgjyf84c50dewEtUg=@vger.kernel.org X-Gm-Message-State: AOJu0YyEXG3vjNgfW0rbSHw5eJTUEA9+velsLAZvtkVxcZ3elfwWlcKf ernin3Mo3gUkdDJB4X/WlQf/Yah3wZC9pLJaU10RbUaHuiIpDFPCGckpioHRMD4xjAU/wl8DNva BHYS2qQ== X-Google-Smtp-Source: AGHT+IHzbaz1BIdk1fZM5ksjlas4j5qybmB0Dj9jOYXU6Ro6xEDlHzInuS5qOStSUPAiO2JLwXWaiXq5Vv4= X-Received: from pjsa5.prod.google.com ([2002:a17:90a:be05:b0:343:7bc8:fb4e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:d603:b0:343:a298:90ac with SMTP id 98e67ed59e1d1-34943730cfdmr7270744a91.0.1764957486054; Fri, 05 Dec 2025 09:58:06 -0800 (PST) Date: Fri, 5 Dec 2025 09:58:04 -0800 In-Reply-To: <45cbc005e14ea2a4b9ec803a91af63e364aeb71a.1757416809.git.houwenlong.hwl@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <45cbc005e14ea2a4b9ec803a91af63e364aeb71a.1757416809.git.houwenlong.hwl@antgroup.com> Message-ID: Subject: Re: [PATCH 4/7] KVM: x86: Consolidate KVM_GUESTDBG_SINGLESTEP check into the kvm_inject_emulated_db() From: Sean Christopherson To: Hou Wenlong Cc: kvm@vger.kernel.org, Lai Jiangshan , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Wed, Sep 10, 2025, Hou Wenlong wrote: > Use kvm_inject_emulated_db() in kvm_vcpu_do_singlestep() to consolidate > 'KVM_GUESTDBG_SINGLESTEP' check into kvm_inject_emulated_db() during > emulation. > > No functional change intended. > > Suggested-by: Lai Jiangshan > Signed-off-by: Hou Wenlong > --- > arch/x86/kvm/x86.c | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 5af652916a19..83960214d5d8 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8632,7 +8632,10 @@ static int kvm_inject_emulated_db(struct kvm_vcpu *vcpu, unsigned long dr6) > { > struct kvm_run *kvm_run = vcpu->run; > > - if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) { > + /* Data breakpoints are not supported in emulation for now. */ > + WARN_ON((dr6 & DR6_BS) && (dr6 & DR_TRAP_BITS)); If we keep this, it should be a WARN_ON_ONCE(). We've had at least one case where a sanity check in the emulator caused major problems because a WARN_ON() spammed the kernel log to the point where it overloaded things :-) But I think the WARN will be subject to false positives. KVM doesn't emulate data #DBs, but it does emulate code #DBs, and fault-like code #DBs can be coincident with trap-like single-step #DBs. Ah, but kvm_vcpu_check_code_breakpoint() doesn't account for RFLAGS.TF. That should probably be addressed in this series, especially since it's consolidating KVM_GUESTDBG_SINGLESTEP handling.