From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 74D3337A4B7 for ; Fri, 15 May 2026 14:20:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778854825; cv=none; b=Cy1gDbJtjdtIvqc7eHlPurXqW4ruogTm2de0qsZzwXwyBFp1t+O5PcV3bvreZqwRqdvnGX4nZEOvJCBSEq4geIVZRu9oWN02R3IdahnukzUEFOTThgltO2oaQbTSUOifG6gd6tFfIM26EHlpza2srfBYMecipBKfr8Q2w9FSBIc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778854825; c=relaxed/simple; bh=a0CQFFjGAoUgHIzygwskRfunGgt/LgtQR7hlrZcl7VQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=TwxSGmS17HA/Yefvq11RjfyrpknlQFRSCXSnQWVDed2pkeuT44Ft/o/pelYJj3V4lpwK4d3XJ5E1MyKRyEGhjvo0yi1G+JVuIHWN6DVnvNNCqHb3TDTl0oeBR6NwEseq0vt0oVT8kCM2dQvp5azQv7GU438q6SITzSPM94OHdaU= 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=KwXp+sZN; arc=none smtp.client-ip=209.85.215.202 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="KwXp+sZN" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c8281d4cef8so3787956a12.2 for ; Fri, 15 May 2026 07:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778854824; x=1779459624; 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=DZQSM9XuzaJrMJ765GqHAyC1jvYGH24il9g4f0fClRs=; b=KwXp+sZNujmDTLsESupr5knNExmhAsumWVZbpACAxpzteBDHj7dZTyFpbuPe5KKW/z ls/9gDxsNEen3sDQpGg/Hd5biTEWFTD/p+uXY+Xdrhn6zF4fddQCEmm3DV+ugnr+bTUE gDDw1AVU6E0XShykwHQNdonpBNiOjvKULEZaswR33OGNltTM8KOpu99Y0PnW45z576c7 QJ8/Cy/CALrGeLIRyGfb6FYa2WnLHhIRn7+KnlTrxJFdwkZ8Iv7ftc8phnQ5tzmHYh1h a7d8ocfSLhubNHClmviXUdOKy1WllS8LxLmDGcB2wam37/12YfMqbJYhiHbTRWN1TbuD ou1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778854824; x=1779459624; 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=DZQSM9XuzaJrMJ765GqHAyC1jvYGH24il9g4f0fClRs=; b=aV+6SBZrnOu1JpBOX3Rg4X2kmLez+t5/tlZYRDGcXIK4F0IK8+014iDnORE96Ov8h7 /6e3FYN7015hRz5pAx9AHCAru3WYhIMFdxQXN6CnIt4xYyyslGICZbeC8z5tQbyTpFbb eB5C6flv7ctKWEephrKQLDffM8EB95WJSFDqGpArCDIb2B9df6HzwYIjWtt5IpLp4H7J nDE8ecIKqzdK1HjLgdY1TYYDJG4ugLlDLsb/sL+pAckcZzcS0jhnUk+PnPImAaKAGmvp ja/0kEX5KsLIlcgTVlYX/UVxErkbNb1AoZD4FzZH6da9FKLTl7Fzl8CWwsdvjj1ZllgM yGtA== X-Gm-Message-State: AOJu0YxJvvTxfWUsn8ynNRM6kG9Rq5JJFNrVFwsRBoOmn1TV5IaILhaO 1yUzAhAou/4lWO+cLdg1G7jPbTbpxZS0yBW6o8PwUJBtnWMN/SXfCDe4S9YQCGifFvTEOWsG+M0 sNUGyRg== X-Received: from pgww18.prod.google.com ([2002:a05:6a02:2c92:b0:c79:67fe:6d9e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:3298:b0:3a2:e0d3:37d1 with SMTP id adf61e73a8af0-3b22ec5f790mr5156353637.41.1778854823479; Fri, 15 May 2026 07:20:23 -0700 (PDT) Date: Fri, 15 May 2026 07:20:22 -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: <20260107235724.28101-1-aidan@aktech.ai> <20260107235724.28101-2-aidan@aktech.ai> Message-ID: Subject: Re: [PATCH v1 1/1] KVM: x86: Merge pending debug causes when vectoring #DB From: Sean Christopherson To: Aidan Khoury Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Aidan Khoury , Nick Peterson Content-Type: text/plain; charset="us-ascii" On Thu, May 14, 2026, Sean Christopherson wrote: > On Thu, May 14, 2026, Sean Christopherson wrote: > > On Wed, May 13, 2026, Sean Christopherson wrote: > > > On Wed, Jan 07, 2026, Aidan Khoury wrote: > > > So while I don't exactly love the idea, I think this? Compile tested only at > > > this point, I'll try to properly test it tomorrow. > > > > Confirmed the below works, once I remembered how to configure debug breakpoints. > > I'll plan on sending a v2 on your behalf, along with a KVM-Unit-Test testcase. > > Ugh, and of course the test fails on AMD. I'll still send the KVM patch, but > I'll hold off on the KUT mini-series until I've done at least a little digging > through the APM (I'm not exactly brimming with confidence that SVM can handle > this correctly). Ok, I'm not crazy, AMD SVM simply doesn't support this. E.g. from an old paper on making a VMM/hypervisor truly transparent: Similarly, native x86 CPUs hold off debug exceptions for a one-instruction window following MOV %SS instructions. AMD's SVM provides no information about pending debug exceptions if an exit occurs in such a window [2]. We constructed a simple SVM detector based on this discrepancy in less than 100 lines of C and assembly. The easy solution for the test is to skip it on AMD, but before we do any of this, why do you care? I.e. what prompted this patch? If this is purely an academic exercise, then no small part of me thinks it might be better for KVM to take an erratum. I.e. consistency might be better in this case, maybe? [*] https://www.usenix.org/legacy/event/hotos07/tech/full_papers/garfinkel/garfinkel_html/paper.html#tex2html2