From patchwork Wed Mar 19 12:32:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 26577 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E75B20534 for ; Wed, 19 Mar 2014 12:34:38 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id n16sf32941959oag.5 for ; Wed, 19 Mar 2014 05:34:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=vtCnK2mK1nrSEKP9VvsQSZlhne0HTMbSXUFm42I6g58=; b=N/wRUDuW7sazZwI09qrM/+0XsVOpN5J9RNXd5sZMriAbn8VtU+YgpYy5dzJQJb4Y/F s96g8XRQG4NhmFEfZRBZwUe/yN4SMKyJIaCH8Oh6JHSoA5Au0JnFbiCpG2JdtmhasrJD stMks4fzTCU4RNTzTRqS6ldchdQCVsk/fP2UiKQ9gV7Pc0QL41barzSJE8MJkawf0mP/ +W7Hf30sWx4k2eiLGSeU2swe8c8oUp9ZKhjr67Dd6k6LeuC795AFGLsuJGghJYUVBNEN FST2r4UXXBTR5G048rGKp8+tDAO1FCLDo9ZGvK0EGOoNH92BpYPcUFdogByXuMlUqyJv JtGA== X-Gm-Message-State: ALoCoQljhEtxliLg0tHAl+vcAQT/peuG5MWzVPhzWUSI2mhdQiE6W47Hh/yq3HQ9eENOBHybdoFe X-Received: by 10.50.20.71 with SMTP id l7mr10746063ige.5.1395232477723; Wed, 19 Mar 2014 05:34:37 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.210 with SMTP id g76ls2414044qge.69.gmail; Wed, 19 Mar 2014 05:34:37 -0700 (PDT) X-Received: by 10.220.250.203 with SMTP id mp11mr2146724vcb.2.1395232477550; Wed, 19 Mar 2014 05:34:37 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id fv9si7634879vcb.95.2014.03.19.05.34.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Mar 2014 05:34:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id lc6so8788840vcb.7 for ; Wed, 19 Mar 2014 05:34:37 -0700 (PDT) X-Received: by 10.52.69.146 with SMTP id e18mr25333529vdu.15.1395232477451; Wed, 19 Mar 2014 05:34:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp295267vck; Wed, 19 Mar 2014 05:34:37 -0700 (PDT) X-Received: by 10.140.102.215 with SMTP id w81mr1425614qge.109.1395232476967; Wed, 19 Mar 2014 05:34:36 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id i32si12010676qgf.50.2014.03.19.05.34.36 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 19 Mar 2014 05:34:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WQFfs-0007X2-6O; Wed, 19 Mar 2014 12:32:48 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WQFfl-0007QD-Pu for xen-devel@lists.xensource.com; Wed, 19 Mar 2014 12:32:42 +0000 Received: from [85.158.143.35:59099] by server-3.bemta-4.messagelabs.com id A2/CD-13602-86E89235; Wed, 19 Mar 2014 12:32:40 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1395232356!3212920!5 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19162 invoked from network); 19 Mar 2014 12:32:40 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 19 Mar 2014 12:32:40 -0000 X-IronPort-AV: E=Sophos;i="4.97,685,1389744000"; d="scan'208";a="112829426" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 19 Mar 2014 12:32:37 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.2.342.4; Wed, 19 Mar 2014 08:32:35 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1WQFfa-0005Tm-MP; Wed, 19 Mar 2014 12:32:30 +0000 From: Stefano Stabellini To: Date: Wed, 19 Mar 2014 12:32:02 +0000 Message-ID: <1395232325-19226-7-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@citrix.com, jtd@galois.com, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v4 07/10] xen/arm: call gic_clear_lrs on entry to the hypervisor X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: This change is needed by other patches later on. It is going to make sure that the calculation in Xen of the highest priority interrupt currently inflight is correct and accurate and not based on stale data. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- xen/arch/arm/gic.c | 12 +++++------- xen/arch/arm/traps.c | 10 ++++++++++ xen/include/asm-arm/gic.h | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index a5a4da3..3f061cf 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -67,8 +67,6 @@ static DEFINE_PER_CPU(u8, gic_cpu_id); /* Maximum cpu interface per GIC */ #define NR_GIC_CPU_IF 8 -static void gic_clear_lrs(struct vcpu *v); - static unsigned int gic_cpu_mask(const cpumask_t *cpumask) { unsigned int cpu; @@ -130,7 +128,6 @@ void gic_restore_state(struct vcpu *v) GICH[GICH_HCR] = GICH_HCR_EN; isb(); - gic_clear_lrs(v); gic_restore_pending_irqs(v); } @@ -701,14 +698,15 @@ out: return; } -static void gic_clear_lrs(struct vcpu *v) +void gic_clear_lrs(struct vcpu *v) { struct pending_irq *p; int i = 0, irq; uint32_t lr; bool_t inflight; + unsigned long flags; - ASSERT(!local_irq_is_enabled()); + spin_lock_irqsave(&v->arch.vgic.lock, flags); while ((i = find_next_bit((const long unsigned int *) &this_cpu(lr_mask), nr_lrs, i)) < nr_lrs) { @@ -744,6 +742,8 @@ static void gic_clear_lrs(struct vcpu *v) i++; } + + spin_unlock_irqrestore(&v->arch.vgic.lock, flags); } static void gic_restore_pending_irqs(struct vcpu *v) @@ -786,8 +786,6 @@ int gic_events_need_delivery(void) void gic_inject(void) { - gic_clear_lrs(current); - if ( vcpu_info(current, evtchn_upcall_pending) ) vgic_vcpu_inject_irq(current, current->domain->arch.evtchn_irq); diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 21c7b26..dd936be 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -68,6 +68,7 @@ static int debug_stack_lines = 40; integer_param("debug_stack_lines", debug_stack_lines); +static void enter_hypervisor_head(void); void __cpuinit init_traps(void) { @@ -1543,6 +1544,8 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) { union hsr hsr = { .bits = READ_SYSREG32(ESR_EL2) }; + enter_hypervisor_head(); + switch (hsr.ec) { case HSR_EC_WFI_WFE: if ( !check_conditional_instr(regs, hsr) ) @@ -1620,11 +1623,13 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) asmlinkage void do_trap_irq(struct cpu_user_regs *regs) { + enter_hypervisor_head(); gic_interrupt(regs, 0); } asmlinkage void do_trap_fiq(struct cpu_user_regs *regs) { + enter_hypervisor_head(); gic_interrupt(regs, 1); } @@ -1642,6 +1647,11 @@ asmlinkage void leave_hypervisor_tail(void) } } +static void enter_hypervisor_head(void) +{ + gic_clear_lrs(current); +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 4834cd6..5a9dc77 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -220,6 +220,7 @@ extern unsigned int gic_number_lines(void); /* IRQ translation function for the device tree */ int gic_irq_xlate(const u32 *intspec, unsigned int intsize, unsigned int *out_hwirq, unsigned int *out_type); +void gic_clear_lrs(struct vcpu *v); #endif /* __ASSEMBLY__ */ #endif