mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nikunj A. Dadhania" <nikunj@amd.com>
To: Sean Christopherson <seanjc@google.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>, <x86@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Shuah Khan <shuah@kernel.org>,
	<kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-kselftest@vger.kernel.org>,
	"Saenz Julienne, Nicolas" <nsaenz@amazon.es>,
	Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Shivansh Dhiman <shivansh.dhiman@amd.com>,
	Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Subject: Re: [PATCH] KVM: SVM: Always intercept ICEBP, add INT1 selftests
Date: Fri, 10 Jul 2026 16:51:57 +0530	[thread overview]
Message-ID: <92849e86-2a87-4bf6-bf42-6a3430252fc4@amd.com> (raw)
In-Reply-To: <85o6hu4k7f.fsf@amd.com>



On 6/1/2026 4:10 PM, Nikunj A Dadhania wrote:
> Sean Christopherson <seanjc@google.com> writes:
> 
>> +AMD folks
>>
>> On Thu, May 07, 2026, Sean Christopherson wrote:
>>> On Thu, May 07, 2026, Andrew Cooper wrote:
>>>> On 07/05/2026 3:08 pm, Sean Christopherson wrote:
>>>>> On Thu, May 07, 2026, David Woodhouse wrote:
>>>>>> From: David Woodhouse <dwmw@amazon.co.uk>
>>>>>>
>>>>>> ICEBP (INT1, opcode 0xF1) generates a #DB that is architecturally a
>>>>>> trap, but on SVM it was not always intercepted. Unconditionally
>>>>>> intercept ICEBP on SVM to match VMX behaviour and ensure correct
>>>>>> event delivery semantics.
>>>>>>
>>>>>> Add two selftests exercising ICEBP:
>>>>>>
>>>>>>  - int1_ept_test: verifies that ICEBP works correctly when the
>>>>>>    exception stack page is not present (EPT/NPT fault during #DB
>>>>>>    delivery). The IST stack is evicted via MADV_DONTNEED before
>>>>>>    executing INT1.
>>>>>>
>>>>>>  - int1_task_gate_test: verifies ICEBP delivery through a 32-bit
>>>>>>    task gate, exercising the legacy task-switch path for #DB.
>>>>>>
>>>>>> Tested on Intel Sapphire Rapids and AMD Genoa. Without the SVM fix,
>>>>>> int1_task_gate_test fails on AMD with EIP pointing at ICEBP instead
>>>>>> of after it. With the fix, both tests pass on both platforms.
>>>>> Hmm, but KVM unconditionally intercepts task switches.  Is this effectively working
>>>>> around a bug in task_switch_interception()?
>>>>
>>>> Not really.  It's a bug/misfeature in AMD CPUs.
>>>>
>>>> When you get TASK_SWITCH (which always has fault semantics), you look at
>>>> the vectoring event type to decide whether it was logically caused by a
>>>> trap, and therefore whether to move %rip forwards before entering the
>>>> new task.
>>>>
>>>> AMD CPUs don't distinguish instruction-induced #DBs (i.e. ICEBP) from
>>>> exception-induced #DBs (all others), and also don't report an
>>>> instruction length for an ICEBP-induced TASK_SWITCH.
>>>
>>> Heh, that explains why I couldn't find an equivalent of INTR_TYPE_PRIV_SW_EXCEPTION
>>> in the SVM code.
>>
>> Dragging in a comment/concern Andrew raised offlist.  If AMD doesn't provide or
>> *allow* the equivalent of INTR_TYPE_PRIV_SW_EXCEPTION, i.e. type 5, then what
>> happens when KVM needs to inject an INT1 #DB with FRED enabled?
> 
> I'm checking internally to get clarification on this. Will follow up
> once I have more details.

Following up on my earlier response — this has been addressed in the
AMD FRED Virtualization specification. Type 5 (privileged software
exception) is now supported in both EXITINTINFO and EVENTINJ for
FRED-enabled guests.

Details are documented in the AMD FRED Virtualization spec (Rev 1.10):
https://docs.amd.com/v/u/en-US/69191-PUB

Regards,
Nikunj



  reply	other threads:[~2026-07-10 11:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 11:22 David Woodhouse
2026-05-07 14:08 ` Sean Christopherson
2026-05-07 14:21   ` Andrew Cooper
2026-05-07 15:16     ` Sean Christopherson
2026-05-07 15:57       ` Sean Christopherson
2026-06-01 10:40         ` Nikunj A Dadhania
2026-07-10 11:21           ` Nikunj A. Dadhania [this message]
2026-05-12 21:10 ` Paolo Bonzini
2026-05-12 21:33   ` David Woodhouse
2026-07-31 20:10 ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92849e86-2a87-4bf6-bf42-6a3430252fc4@amd.com \
    --to=nikunj@amd.com \
    --cc=Neeraj.Upadhyay@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=mingo@redhat.com \
    --cc=nsaenz@amazon.es \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=shivansh.dhiman@amd.com \
    --cc=shuah@kernel.org \
    --cc=tglx@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®