All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>
Subject: Re: [Xen-devel] [PATCH] x86/HVM: adjust hvm_interrupt_blocked()
Date: Mon, 4 Sep 2023 15:55:48 +0200	[thread overview]
Message-ID: <3af0be91-36a4-e0ca-1974-ae030ba07908@suse.com> (raw)
In-Reply-To: <ZPBusqv7NGaJnOoT@MacBook-MacBook-Pro-de-Roger.local>

On 31.08.2023 12:42, Roger Pau Monné wrote:
> On Fri, Oct 12, 2018 at 09:58:46AM -0600, Jan Beulich wrote:
>> First of all, hvm_intsrc_mce was not considered here at all, yet nothing
>> blocks #MC (other than an already in-progress #MC, but dealing with this
>> is not the purpose of this patch).
>>
>> Additionally STI-shadow only blocks maskable interrupts, but not NMI.
> 
> I've found the Table 25-3 on Intel SDM vol3 quite helpful:
> 
> "Execution of STI with RFLAGS.IF = 0 blocks maskable interrupts on the
> instruction boundary following its execution.1 Setting this bit
> indicates that this blocking is in effect."
> 
> And:
> 
> "Execution of a MOV to SS or a POP to SS blocks or suppresses certain
> debug exceptions as well as interrupts (maskable and nonmaskable) on
> the instruction boundary following its execution."
> 
> Might be worth adding to the commit message IMO.

Hmm, to be honest I'm not sure why reproducing some of one vendor's doc
would be useful here.

>> --- a/xen/arch/x86/hvm/hvm.c
>> +++ b/xen/arch/x86/hvm/hvm.c
>> @@ -3771,19 +3771,24 @@ enum hvm_intblk hvm_interrupt_blocked(st
>>              return intr;
>>      }
>>  
>> -    if ( (intack.source != hvm_intsrc_nmi) &&
>> -         !(guest_cpu_user_regs()->eflags & X86_EFLAGS_IF) )
>> -        return hvm_intblk_rflags_ie;
>> +    if ( intack.source == hvm_intsrc_mce )
>> +        return hvm_intblk_none;
> 
> I've been wondering, why do we handle #MC here, instead of doing the
> same as for other Traps/Exceptions and use hvm_inject_hw_exception()
> directly?

I'm afraid I can only guess here, but I suspect a connection to how
vMCE "works" (and the point in time when v->arch.mce_pending would be
set).

>>      intr_shadow = hvm_funcs.get_interrupt_shadow(v);
>>  
>> -    if ( intr_shadow & (HVM_INTR_SHADOW_STI|HVM_INTR_SHADOW_MOV_SS) )
>> +    if ( intr_shadow & HVM_INTR_SHADOW_MOV_SS )
>>          return hvm_intblk_shadow;
>>  
>>      if ( intack.source == hvm_intsrc_nmi )
>>          return ((intr_shadow & HVM_INTR_SHADOW_NMI) ?
>>                  hvm_intblk_nmi_iret : hvm_intblk_none);
>>  
>> +    if ( intr_shadow & HVM_INTR_SHADOW_STI )
>> +        return hvm_intblk_shadow;
>> +
>> +    if ( !(guest_cpu_user_regs()->eflags & X86_EFLAGS_IF) )
>> +        return hvm_intblk_rflags_ie;
> 
> I do wonder whether this code would be clearer using a `switch (
> intack.source )` construct, but that's out of the scope.

If it would help, I could switch to using switch(), but the order
of checks isn't really a sequence of comparisons against intack.source.

Jan


      parent reply	other threads:[~2023-09-04 13:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12 15:58 [PATCH] x86/HVM: adjust hvm_interrupt_blocked() Jan Beulich
2018-10-12 16:37 ` Andrew Cooper
2018-10-25  9:10   ` Jan Beulich
2018-10-25 11:30   ` Jan Beulich
2018-10-26 12:56   ` Jan Beulich
2023-08-31 10:42 ` [Xen-devel] " Roger Pau Monné
2023-08-31 10:57   ` Roger Pau Monné
2023-09-04 13:40     ` Jan Beulich
2023-09-05 10:36       ` Roger Pau Monné
2023-09-04 13:55   ` Jan Beulich [this message]

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=3af0be91-36a4-e0ca-1974-ae030ba07908@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.