[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] x86/HVM: adjust hvm_interrupt_blocked()


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 4 Sep 2023 15:55:48 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n0P1Z8DGaDzApWPE0F5c87R3dy5CngDY71J0Rx6DZRk=; b=fxhvbjM+GEKf6alLdzHOdWKEbCRE2TrcnlpgUuiW0h7ePo89jQikv8LiGRDyIThuHoloGqfr7I3uQ4PShwn82W00iTA/tyIG/x5/VBgFAP+/w23j39XZBmRrAUeOuORH/hqUHOptp/dhvkKdjDprHAORtqP17dSXtpAftM2UWtAPEmDM0DH3JcfW/3exJhRhMyzWme9bbIwVK6BAVcjiXM7JE5kYhleY8508lp9zGRJ8IOSx8o8KRUSOcX1xLinLy2YgiUwRlPZvnqGJVV4ds6OZcxi3t3mAVc9AWDUgffDgKtQpKg16jHtCcabNZoBFud9qQG1C5aelfdfoTiZOzQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bhgnukQIT3x+izTNuZKFOkC57LekWn1HsTpG9jTtcvVztDqmXCLg0Vw7P0A+vzUwOX/0P2jFcgHEx+TKJgShZVcqFgjFynREfjgqDxdjkaSwc3UTyZC84GOdaaQuSyoxQsawMxIzrKXmh099xiSjO+Wr+xj6er4cR2YULl+islouFq+oXnUMpzFAXSGs23on1Lb64rltQW9ozy4iSjAP3gTw5HI1oG/91C5/rYEOgjLxNyTwN3wl12zDrUsuxPIMzf/mfe3Pq7Cj9JwgkDmhAWGYFHEi/lItdF0oc9ymamoKK1DHTAxxhW/3MaclJkvvAABBvVGM3Y2+sKYa00P9ng==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wei.liu2@xxxxxxxxxx>
  • Delivery-date: Mon, 04 Sep 2023 13:55:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.