From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 EFC1C3CB8FC for ; Wed, 13 May 2026 23:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778714057; cv=none; b=bkD0Fd4fzzaZuO6Wk9dd/rr4Wykz4K0JXKjDWJAs/ha4aqhmJq0CJR6P+luLJpssExNIWKcOk2aSjb/6a9Io+rEqHK5J4gXe1UtRg4rKA/snWeNRLqX7Id7vHgzp8USZeuiOcEoK1rtNi9Tcgxa0dDi1KU5JNWUYf8uNmfhpOpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778714057; c=relaxed/simple; bh=sa3MU5hP47nUdEGWyqAw1QOWRSRun/RHMRIVSWeqHIo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=I35VTMJ8E2GVlT8x8NCfVAB9jAvqsOMKdV3CNczAqzRkNn8w+FMM39UBcXRBL6jwakBNkV6+ZM1XFzjGM7JNnhtJWs/t93reQ58VrSt3u1sZ0z9JPU4/KTqJXX2pMUCHkIIP0kyOD6PbfirYkZqTL3uq70J4drZtSlfSIPTvQbI= 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=EyY0YC7v; arc=none smtp.client-ip=209.85.216.74 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="EyY0YC7v" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3662eec51e0so4152285a91.3 for ; Wed, 13 May 2026 16:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778714055; x=1779318855; 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=YZROrOwy5J7pzI1auvv9ygqqn1CxMDUVxMMwN7QUYwo=; b=EyY0YC7vSNmq8ALtwiwezfZ9xFheIpTvLlOk08vGUxMDTTAUP2OiroHad2jDaTKOTs 20XNCCjQYXq4aVSAvq0SlQdb7DazS5SFBMwtXoI/qrdxoP/ed1ET4Qrh+cW1G6SszvQ0 QA6uJgo9NJztNrnPpcPZBExV2qLmV/+XAGERG1a1MAKlvf2x9jRWEBF/fVkLDGGHRbN1 v/LjVMAc02KcS/wIkQGKfKSXVNk94IKsY3uMBbrpdWjcCrA/2Lm9y6tX9SjLvyMvnkk8 OxM39W9Ub6NT7HfwJaELfZAoYwq7OrCCL9Desq8u2zos4ByP5GCdyiMxE396QJfsibEy 0GCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778714055; x=1779318855; 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=YZROrOwy5J7pzI1auvv9ygqqn1CxMDUVxMMwN7QUYwo=; b=i4PL69wtR7uuz5/6508MUNpzWiGHH73U8rfEFLgHTwKEkyqPwUDQFSLt1my+WhTTG9 lntxDSFOngo78aHnWi5pTiUjwRKaktuuKmfJhNH8BJGxwPAaMLNjrOdIzFUELFKO3vFK rEeiNcR2slLdoft8U7suWRcsB/G5OY2UFldsEIusSkd04KEBiq3tzD0R+MDGTpfRWL0V EcIiSCQ7EJ46PCyEtbXW5v6YAsNhrU7+ELjRrphsYtDAjatqcQWAi6jbxWqolAp+3zae zG4JmZYVaczQ7DqlRzfKgdPIiZgYXD4XHVl+oaaL7hVsCAq6LWeCRT6KfQfKzbGAGs6x i2EQ== X-Forwarded-Encrypted: i=1; AFNElJ9w1OHXYaDeYbuU0kc3ytrx82+++UiIMVtnindm5y0Tf/zsGcwGrDfQ10TOKO9053l8EdPvawp/P0I8EVE=@vger.kernel.org X-Gm-Message-State: AOJu0YyXlTwlgdKcRbDaDpf4AeTwruELxH7yZRFVAOQFWX0u2W039Q55 MwyY2IevS97E50cPhAks8w2q96JdjlzpDBhqVwJVNv3MVWRpmFapAAgEHMLLnYCvdO7SY9Zql2W 2h9XUWQ== X-Received: from pfbfa8.prod.google.com ([2002:a05:6a00:2d08:b0:839:9ad:ee32]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:5493:b0:3aa:c93b:6266 with SMTP id adf61e73a8af0-3afaf61979amr5920299637.19.1778714054962; Wed, 13 May 2026 16:14:14 -0700 (PDT) Date: Wed, 13 May 2026 16:14:14 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH v2 9/9] KVM: selftests: Verify 'BS' bit checking in pending debug exception state during VM-Entry From: Sean Christopherson To: Hou Wenlong Cc: kvm@vger.kernel.org, Lai Jiangshan , Paolo Bonzini , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Thu, Dec 18, 2025, Hou Wenlong wrote: > In the x86's debug_regs test, add a test case to cover the scenario > where single-step with STI in VMX sets the 'BS' bit in pending debug > exceptions state for #DB interception and instruction emulation in both > cases. ... > +static void guest_db_handler(struct ex_regs *regs) > +{ > + static int count; > + unsigned long target_rips[2] = { > + CAST_TO_RIP(fep_sti_start), > + CAST_TO_RIP(fep_sti_end), > + }; > + > + __GUEST_ASSERT(regs->rip == target_rips[count], "STI: unexpected rip 0x%lx (should be 0x%lx)", > + regs->rip, target_rips[count]); > + regs->rflags &= ~X86_EFLAGS_TF; > + count++; > +} > + > +static void guest_irq_handler(struct ex_regs *regs) > +{ > + unsigned long target_rip = CAST_TO_RIP(fep_bd_start); > + > + __GUEST_ASSERT(regs->rip == target_rip, "IRQ: unexpected rip 0x%lx (should be 0x%lx)", > + regs->rip, target_rip); This is wrong, and the test fails with your series applied verbatim. The IRQ will arrive at fep_sti_start, because RFLAGS.IF=0 from the CLI at the end of the ss_start block, and remains that way across fep_bd_start. And to make things even more confusing, the IRQ arrives on the CLI even though it's in an STI shadow due to #DBs not being subjected to _STI_ shadows on Intel, only to MOV-SS/POP-SS shadows. I.e. the #DB lands on CLI, pushes RFLAGS.IF=1 on the stack, and then the subsequent IRET from guest_db_handler() fully unmasks IRQs, and voila.