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

Re: [Xen-devel] [Patch 1/3 v2] x86/irq: local_irq_restore() should not blindly popf


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxx>
  • From: Keir Fraser <keir.xen@xxxxxxxxx>
  • Date: Mon, 21 Oct 2013 19:18:19 +0100
  • Cc: Jan Beulich <JBeulich@xxxxxxxx>
  • Delivery-date: Mon, 21 Oct 2013 18:18:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>
  • Thread-index: Ac7OiesSYB563xAlSEuCnNvNAhzFJw==
  • Thread-topic: [Xen-devel] [Patch 1/3 v2] x86/irq: local_irq_restore() should not blindly popf

On 21/10/2013 17:33, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx> wrote:

> local_irq_restore() should only be concerned with possibly changing the
> interrupt flag.  A blind popf could corrupt other system flags.
> 
> While playing in this area, fixup an opencoded use of X86_EFLAGS_IF.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> CC: Keir Fraser <keir@xxxxxxx>
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> 
> ---
> 
> This is rather more RFC.  It boots and runs VMs, so I am fairly sure it is
> functionally correct, but I cant help feeling there might be a neater way to
> do the inline assembly.  Suggestions welcome.
> ---
>  xen/include/asm-x86/system.h |   11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h
> index 6ab7d56..ff52671 100644
> --- a/xen/include/asm-x86/system.h
> +++ b/xen/include/asm-x86/system.h
> @@ -3,6 +3,7 @@
>  
>  #include <xen/lib.h>
>  #include <xen/bitops.h>
> +#include <asm/processor.h>
>  
>  #define read_segment_register(name)                             \
>  ({  u16 __sel;                                                  \
> @@ -159,15 +160,19 @@ static always_inline unsigned long __cmpxchg(
>  #define local_irq_restore(x)                                     \
>  ({                                                               \
>      BUILD_BUG_ON(sizeof(x) != sizeof(long));                     \
> -    asm volatile ( "push" __OS " %0 ; popf" __OS                 \
> -                   : : "g" (x) : "memory", "cc" );               \
> +    asm volatile (                                               \
> +    "pushf" __OS "\n\t"                                          \
> +    "and" __OS " %0, (%%" __OP "sp)\n\t"                         \
> +    "orw %1, (%%" __OP "sp)\n\t"                                 \
> +    "popf" __OS "\n\t" : : "g" ( ~X86_EFLAGS_IF ),               \

Would this be better as a constant constraint ("i")?

> +                           "g" ( x & X86_EFLAGS_IF ) );          \
>  })
>  
>  static inline int local_irq_is_enabled(void)
>  {
>      unsigned long flags;
>      local_save_flags(flags);
> -    return !!(flags & (1<<9)); /* EFLAGS_IF */
> +    return !!(flags & X86_EFLAGS_IF);
>  }
>  
>  #define BROKEN_ACPI_Sx          0x0001



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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