mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Isaku Yamahata <isaku.yamahata@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
	Isaku Yamahata <isaku.yamahata@intel.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	frederic@kernel.org, paulmck@kernel.org, rjw@rjwysocki.net,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	jpoimboe@kernel.org, isaku.yamahata@gmail.com
Subject: Re: [RFC][PATCH 9/9] arch/idle: Change arch_cpu_idle() IRQ behaviour
Date: Tue, 24 May 2022 07:55:37 -0700	[thread overview]
Message-ID: <20220524145537.GA3181491@ls.amr.corp.intel.com> (raw)
In-Reply-To: <20220520125819.GS2578@worktop.programming.kicks-ass.net>

On Fri, May 20, 2022 at 02:58:19PM +0200,
Peter Zijlstra <peterz@infradead.org> wrote:

> On Fri, May 20, 2022 at 01:13:22PM +0300, Kirill A. Shutemov wrote:
> 
> > So you want to call call the HLT hypercall with .irq_disabled=false and
> > .do_sti=false, but actual RFLAGS.IF in the guest is 0 and avoid CLI on
> > wake up expecting it to be cleared already, right?
> 
> Yep, just like MWAIT can, avoids pointless IF flipping.
> 
> > My reading of the spec is "don't do that". But actual behaviour is up to
> > VMM and TDX module implementation. VMM doens't have access to the guest
> > register file, so it *may* work, I donno.
> 
> Yeah, it totally *can* work, but I've no idea if they done the right
> thing.

There are two cases when interrupt arrives.

- If interrupts arrives after the CPU start executing VMM (or the TDX module),
  VMM can know if interrupt for vCPU arrives. VMM will unblock vcpu scheduling.
  The HLT hypercall returns back to guest.

- If interrupts arrives and vcpu recognizes it before the CPU starts executing
  VMM (or TDX module), the interrupt request is recorded in vRVI (VMCS.RVI)
  due to vRFLAGS.IF=0.  After that, CPU exits from guest to VMM due to HLT
  hypercall.
  Before KVM blocking vcpu scheduling, due to irq_disable=false TDX KVM checks
  if deliverable interrupt events is pending by TDX SEAMCALL (because CPU state
  is protected, VMM can't peek vRVI and vPPR directly.  Note that vRFLAGS.IF is
  ignored in this check).  If vcpu has deliverable pending interrupt, HLT
  hypercall returns.

  Anyway this scenario isn't tested, I need to test it.
-- 
Isaku Yamahata <isaku.yamahata@gmail.com>

  reply	other threads:[~2022-05-24 14:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 21:27 [RFC][PATCH 0/9] Rework cpuidle vs instrumentation Peter Zijlstra
2022-05-19 21:27 ` [RFC][PATCH 1/9] x86/perf/amd: Remove tracing from perf_lopwr_cb() Peter Zijlstra
2022-05-19 21:27 ` [RFC][PATCH 2/9] x86/idle: Replace x86_idle with a static_call Peter Zijlstra
2022-05-30 11:07   ` Frederic Weisbecker
2022-05-19 21:27 ` [RFC][PATCH 3/9] cpuidle: Move IRQ state validation Peter Zijlstra
2022-05-30 11:36   ` Frederic Weisbecker
2022-05-30 12:00     ` Peter Zijlstra
2022-05-19 21:27 ` [RFC][PATCH 4/9] idle: Fix rcu_idle_*() usage Peter Zijlstra
2022-05-23  9:46   ` Gautham R. Shenoy
2022-05-31  9:33     ` Peter Zijlstra
2022-05-19 21:27 ` [RFC][PATCH 5/9] rcu: Fix rcu_idle_exit() Peter Zijlstra
2022-05-20 21:00   ` Paul E. McKenney
2022-05-19 21:27 ` [RFC][PATCH 6/9] acpi_idle: Remove tracing Peter Zijlstra
2022-05-19 21:27 ` [RFC][PATCH 7/9] cpuidle: Annotate poll_idle() Peter Zijlstra
2022-05-19 21:27 ` [RFC][PATCH 8/9] objtool/idle: Validate __cpuidle code as noinstr Peter Zijlstra
2022-05-19 21:27 ` [RFC][PATCH 9/9] arch/idle: Change arch_cpu_idle() IRQ behaviour Peter Zijlstra
2022-05-19 22:03   ` Peter Zijlstra
2022-05-20  2:20     ` Kirill A. Shutemov
2022-05-20  7:06       ` Peter Zijlstra
2022-05-20 10:13         ` Kirill A. Shutemov
2022-05-20 12:58           ` Peter Zijlstra
2022-05-24 14:55             ` Isaku Yamahata [this message]
2022-05-23 10:02   ` Gautham R. Shenoy

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=20220524145537.GA3181491@ls.amr.corp.intel.com \
    --to=isaku.yamahata@gmail.com \
    --cc=frederic@kernel.org \
    --cc=isaku.yamahata@intel.com \
    --cc=jpoimboe@kernel.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --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®