From: "Jan Beulich" Subject: Re: [PATCH 2/3] x86/traps: Use write_atomic() when updating potentially-live descriptors Date: Wed, 11 Feb 2015 10:46:04 +0000 Message-ID: <54DB40FC020000780005EF55@mail.emea.novell.com> References: <1423588332-23819-1-git-send-email-andrew.cooper3@citrix.com> <1423588332-23819-3-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423588332-23819-3-git-send-email-andrew.cooper3@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Tim Deegan , Xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 10.02.15 at 18:12, 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