public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Manali Shukla <manali.shukla@amd.com>
Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	pbonzini@redhat.com,  shuah@kernel.org, nikunj@amd.com,
	thomas.lendacky@amd.com,  vkuznets@redhat.com, bp@alien8.de
Subject: Re: [PATCH v1 5/5] selftests: KVM: SVM: Add Idle HLT intercept test
Date: Thu, 7 Mar 2024 10:24:42 -0800	[thread overview]
Message-ID: <ZeoGaujrJHGe5IsN@google.com> (raw)
In-Reply-To: <ZeoF2vfrUMCja0x7@google.com>

On Thu, Mar 07, 2024, Sean Christopherson wrote:
> On Thu, Mar 07, 2024, Manali Shukla wrote: From: Manali Shukla <Manali.Shukla@amd.com>
> > +	xapic_enable();
> > +
> > +	icr_val = (APIC_DEST_SELF | APIC_INT_ASSERT | VINTR_VECTOR);
> > +
> > +	for (i = 0; i < NUM_ITERATIONS; i++) {
> > +		xapic_write_reg(APIC_ICR, icr_val);
> > +		asm volatile("sti; hlt; cli");
> 
> Please add safe_halt() and cli() helpers in processor.h.  And then do:

Doh, saw something shiny and forgot to finish my though.  For safe_halt(), copy
the thing verbatim from KVM-Unit-Tests, as not everyone is familiar with the
sti=>hlt trick.

/*
 * Execute HLT in an STI interrupt shadow to ensure that a pending IRQ that's
 * intended to be a wake event arrives *after* HLT is executed.  Modern CPUs,
 * except for a few oddballs that KVM is unlikely to run on, block IRQs for one
 * instruction after STI, *if* RFLAGS.IF=0 before STI.  Note, Intel CPUs may
 * block other events beyond regular IRQs, e.g. may block NMIs and SMIs too.
 */
static inline void safe_halt(void)
{
	asm volatile("sti; hlt");
}

  reply	other threads:[~2024-03-07 18:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07  5:46 [PATCH v1 0/5] Add support for the Idle HLT intercept feature Manali Shukla
2024-03-07  5:46 ` [PATCH v1 1/5] x86/cpufeatures: Add CPUID feature bit for Idle HLT intercept Manali Shukla
2024-03-07  5:46 ` [PATCH v1 2/5] KVM: SVM: Add Idle HLT intercept support Manali Shukla
2024-03-07  5:46 ` [PATCH v1 3/5] tools: Add KVM exit reason for the Idle HLT Manali Shukla
2024-03-07 14:30   ` Sean Christopherson
2024-03-12  6:10     ` Manali Shukla
2024-03-07  5:46 ` [PATCH v1 4/5] selftests: Add an interface to read the data of named vcpu stat Manali Shukla
2024-03-07  5:46 ` [PATCH v1 5/5] selftests: KVM: SVM: Add Idle HLT intercept test Manali Shukla
2024-03-07 18:22   ` Sean Christopherson
2024-03-07 18:24     ` Sean Christopherson [this message]
2024-03-14  5:35     ` Manali Shukla
2024-03-14 15:06       ` Sean Christopherson
2024-03-22 16:03         ` Manali Shukla

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=ZeoGaujrJHGe5IsN@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=manali.shukla@amd.com \
    --cc=nikunj@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=vkuznets@redhat.com \
    /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