From: Ian Campbell Subject: Re: [PATCH v3] xen/arm: Correctly support WARN_ON Date: Mon, 22 Sep 2014 16:29:56 +0100 Message-ID: <1411399796.26552.6.camel@kazak.uk.xensource.com> References: <1410391997-15481-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XW5Yv-0004oJ-Eh for xen-devel@lists.xenproject.org; Mon, 22 Sep 2014 15:30:01 +0000 In-Reply-To: <1410391997-15481-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: xen-devel@lists.xenproject.org, tim@xen.org, stefano.stabellini@citrix.com List-Id: xen-devel@lists.xenproject.org On Wed, 2014-09-10 at 16:33 -0700, Julien Grall wrote: > Currently the hypervisor will hang if it hits a WARN_ON. > > The implemention uses an undefined instruction, made ourself because ARM "implementation" > doesn't provide one, to implement BUG/ASSERT/WARN_ON, and sets up the > different tables (one for each type) which contain useful information. > > This is based on the x86 implementation (include/asm-x86/bug.h). Unfortunately > the structure can't be shared because many ARM{32,64} gcc versions doesn't s/doesn't/don't/ > correctly support %c. The support of executing a function in an exception handler s/of/for/ > is also keep unimplemented on ARM. Therefore, dump_execution_state is > implement as WARN() "implemented". > +#ifdef CONFIG_ARM_64 > +static void do_trap_brk(struct cpu_user_regs *regs, union hsr hsr) > +{ > + /* HCR_EL2.TGE and MDCR_EL2.TDE are not set so we never receive > + * software breakpoint exception for EL1 and EL0 here > + */ > + /* It's not possible to use BUG_ON here, because we would recurse */ > + if ( unlikely(READ_SYSREG(HCR_EL2) & HCR_TGE) || > + unlikely(READ_SYSREG(MDCR_EL2) & HDCR_TDE) ) > + panic("Unable to handle brk exception from EL1/EL0"); Either of those bits being set doesn't imply that *this* trap came from EL1/EL0. The correct check would be BUG_ON(!hyp_mode(regs)) which I think won't recurse because the resulting BRK will pass the check the second time, although if you want to if (!hyp_mode(regs)) panic(...) instead that's fine too. Ian.