From patchwork Tue Nov 25 17:44:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 41502 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E0A4825E72 for ; Tue, 25 Nov 2014 17:46:37 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf901983wiv.9 for ; Tue, 25 Nov 2014 09:46:37 -0800 (PST) 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:cc:subject :precedence:list-id:list-unsubscribe:list-post:list-help :list-subscribe:mime-version:content-type:content-transfer-encoding :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=wwPJNrjvqnwNJQbzDBbCYrCI3SqRqlth49a1Jlohppg=; b=Et6kUsLdkH60tr8b7xfyNT22fUeuCoYCsSWIyEKTsxvCNfEjGytvvYKnrpxoISqJ11 llSTWQDEvnvWsdUCNiTNRYCpL6LNG7V072lAQbsx7cSq+7FzRUN+wprRGkQLN/UngyEU zjDv2E12dHMUNT9VE1We+/wZ1d4WSEsixL+Sq2Naf5mWGTHg4zfBdHJBWWjtLa3Gt7FI x52cGiYVEMckJCbnQ7SERP4s2kb+l9zYwbsRJOGbSLS0OyyWsKAhWtQ8oZ7PEcW5CxkR R9ssquU5ds/FxlqymbhC6y+mMJ2QpaZumKckKLz6UX8G8kDG5EzFfCr9dPj1Hl2M+Y+n dcow== X-Gm-Message-State: ALoCoQm9jImzHT9AtrRGAw8OQr/3dmfVTbwNPa4XHnFBcOz3lPOIvcSgBtW0nWp4Yn8GR/35c8A/ X-Received: by 10.112.14.2 with SMTP id l2mr3151915lbc.5.1416937597198; Tue, 25 Nov 2014 09:46:37 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.227 with SMTP id v3ls654143lav.91.gmail; Tue, 25 Nov 2014 09:46:36 -0800 (PST) X-Received: by 10.152.243.37 with SMTP id wv5mr29630421lac.10.1416937596856; Tue, 25 Nov 2014 09:46:36 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id b4si2087820lak.12.2014.11.25.09.46.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Nov 2014 09:46:36 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gd6so1014765lab.5 for ; Tue, 25 Nov 2014 09:46:36 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr28691266lbc.23.1416937596720; Tue, 25 Nov 2014 09:46:36 -0800 (PST) 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.112.184.201 with SMTP id ew9csp480135lbc; Tue, 25 Nov 2014 09:46:35 -0800 (PST) X-Received: by 10.224.13.145 with SMTP id c17mr39195001qaa.96.1416937594406; Tue, 25 Nov 2014 09:46:34 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id q95si2053883qgq.67.2014.11.25.09.46.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 25 Nov 2014 09:46:34 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) 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 1XtKAI-00074q-MG; Tue, 25 Nov 2014 17:44:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XtKAH-00074l-C9 for xen-devel@lists.xenproject.org; Tue, 25 Nov 2014 17:44:37 +0000 Received: from [85.158.137.68] by server-15.bemta-3.messagelabs.com id FE/CF-17735-400C4745; Tue, 25 Nov 2014 17:44:36 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-16.tower-31.messagelabs.com!1416937475!13789997!1 X-Originating-IP: [209.85.212.181] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26728 invoked from network); 25 Nov 2014 17:44:36 -0000 Received: from mail-wi0-f181.google.com (HELO mail-wi0-f181.google.com) (209.85.212.181) by server-16.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 25 Nov 2014 17:44:36 -0000 Received: by mail-wi0-f181.google.com with SMTP id r20so2287821wiv.14 for ; Tue, 25 Nov 2014 09:44:35 -0800 (PST) X-Received: by 10.180.95.74 with SMTP id di10mr34315443wib.54.1416937475601; Tue, 25 Nov 2014 09:44:35 -0800 (PST) Received: from chilopoda.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id mw7sm3733874wib.14.2014.11.25.09.44.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Nov 2014 09:44:34 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 25 Nov 2014 17:44:29 +0000 Message-Id: <1416937469-8162-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.3 Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH for-4.5] xen/arm: Fix virtual timer on ARMv8 Model 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: , MIME-Version: 1.0 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: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) 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: ARMv8 model may not disable correctly the timer interrupt when Xen context switch to an idle vCPU. Therefore Xen may receive a spurious timer interrupt. As the idle domain doesn't have vGIC, Xen will crash when trying to inject the interrupt with the following stack trace. (XEN) [<0000000000228388>] _spin_lock_irqsave+0x28/0x94 (PC) (XEN) [<0000000000228380>] _spin_lock_irqsave+0x20/0x94 (LR) (XEN) [<0000000000250510>] vgic_vcpu_inject_irq+0x40/0x1b0 (XEN) [<000000000024bcd0>] vtimer_interrupt+0x4c/0x54 (XEN) [<0000000000247010>] do_IRQ+0x1a4/0x220 (XEN) [<0000000000244864>] gic_interrupt+0x50/0xec (XEN) [<000000000024fbac>] do_trap_irq+0x20/0x2c (XEN) [<0000000000255240>] hyp_irq+0x5c/0x60 (XEN) [<0000000000241084>] context_switch+0xb8/0xc4 (XEN) [<000000000022482c>] schedule+0x684/0x6d0 (XEN) [<000000000022785c>] __do_softirq+0xcc/0xe8 (XEN) [<00000000002278d4>] do_softirq+0x14/0x1c (XEN) [<0000000000240fac>] idle_loop+0x134/0x154 (XEN) [<000000000024c160>] start_secondary+0x14c/0x15c (XEN) [<0000000000000001>] 0000000000000001 While we receive spurious virtual timer interrupt, this could be safely ignore for the time being. A proper fix need to be found for Xen 4.6. Signed-off-by: Julien Grall --- This patch is a bug fix candidate for Xen 4.5. Any ARMv8 model may randomly crash when running Xen. This patch don't inject the virtual timer interrupt if the current VCPU is the idle one. Entering in this function with the idle VCPU is already a bug itself. For now, I think this patch is the safest way to resolve the problem. Meanwhile, I'm investigating with ARM to see wheter the bug comes from Xen or the model. --- xen/arch/arm/time.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index a6436f1..83c74cb 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -169,6 +169,14 @@ static void timer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs) static void vtimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs) { + /* + * ARMv8 model may not disable correctly the timer interrupt when + * Xen context switch to an idle vCPU. Therefore Xen may receive + * timer interrupt. + */ + if ( is_idle_vcpu(current) ) + return; + current->arch.virt_timer.ctl = READ_SYSREG32(CNTV_CTL_EL0); WRITE_SYSREG32(current->arch.virt_timer.ctl | CNTx_CTL_MASK, CNTV_CTL_EL0); vgic_vcpu_inject_irq(current, current->arch.virt_timer.irq);