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

Re: [Xen-devel] [PATCH 2/3] x86/traps: Use write_atomic() when updating potentially-live descriptors



>>> On 10.02.15 at 18:12, <andrew.cooper3@xxxxxxxxxx> wrote:
> --- a/xen/include/asm-x86/desc.h
> +++ b/xen/include/asm-x86/desc.h
> @@ -116,7 +116,8 @@ static inline void _write_gate_lower(volatile idt_entry_t 
> *gate,
>                                       const idt_entry_t *new)
>  {
>      ASSERT(gate->b == new->b);
> -    gate->a = new->a;
> +    /* TODO: untangle the #include hierachy and use write_atomic() here. */
> +    asm volatile ("movq %1,%0" : "=m" (gate->a) : "r" (new->a));

Considering the volatile modifier I don't think this is needed.

> --- a/xen/include/asm-x86/processor.h
> +++ b/xen/include/asm-x86/processor.h
> @@ -444,9 +444,12 @@ struct __packed __cacheline_aligned tss_struct {
>   * descriptor table entry. */
>  static always_inline void set_ist(idt_entry_t *idt, unsigned long ist)
>  {
> +    u64 new_a = (idt->a & ~(7UL << 32)) | (ist << 32);
> +
>      /* IST is a 3 bit field, 32 bits into the IDT entry. */
>      ASSERT(ist <= IST_MAX);
> -    idt->a = (idt->a & ~(7UL << 32)) | (ist << 32);
> +    /* TODO: untangle the #include hierachy and use write_atomic() here. */
> +    asm volatile ("movq %1,%0" : "=m" (idt->a) : "r" (new_a));

And I would then recommend using _write_gate_lower() here
instead of open coding anything.

Jan


_______________________________________________
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®.