From: Ian Campbell Subject: Re: [PATCH v3] xen/arm: do not use is_running to decide whether we can write directly to the LR registers Date: Mon, 22 Apr 2013 12:59:57 +0100 Message-ID: <1366631997.22143.50.camel@zakaz.uk.xensource.com> References: <1366392243-27155-1-git-send-email-stefano.stabellini@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1366392243-27155-1-git-send-email-stefano.stabellini@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , "Tim (Xen.org)" List-Id: xen-devel@lists.xenproject.org On Fri, 2013-04-19 at 18:24 +0100, Stefano Stabellini wrote: > During context switch is_running is set for the next vcpu before the > gic state is actually saved. > This leads to possible nasty races when interrupts need to be injected > after is_running is set to the next vcpu but before the currently > running gic state has been saved from the previous vcpu. > > Use current instead of is_running to check which one is the currently > running vcpu: set_current is called right before __context_switch and > schedule_tail with interrupt disabled. > > Re-enabled interrupts after ctxt_switch_from, so that all the context > switch saving functions don't have to worry about receiving interrupts > while saving state. > > Changes in v3: > - Add a comment in the code to explain why gic_save_state doesn't need a > spinlock; > - add an assert in gic_save_state to make sure that interrupts are > disabled. > > Changes in v2: > - rework the patch to run ctxt_switch_from with interrupt disabled, > rather than introducing a gic_running internal variable. > > Signed-off-by: Stefano Stabellini Acked + applied, thanks.