From patchwork Tue Jul 23 21:35:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169566 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9377103ilk; Tue, 23 Jul 2019 14:37:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPGMg8aC8NB73gN8oMi2fx56iAenqCY89h5/Ig6wl+NplnCgum89X8iG1Vd0NxCjZwFxLg X-Received: by 2002:a02:b016:: with SMTP id p22mr35749418jah.121.1563917859102; Tue, 23 Jul 2019 14:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563917859; cv=none; d=google.com; s=arc-20160816; b=kTh3tpNYqJ+F2vauvWh/H10OJ6LwVEb+5vaswnhSl1VWoLDcX+dKeaY45+TFPP5G8e cO5AwGdD4YeARprIQjUEMCyDemtHu93TirWucOODuafQbS+JJpHI6fWnwnfodWmR2lUX /XrT3+ciDpxSXMYvcSNOoz0JIxKhXNfAbWCiuP7P7T1hYV08/1UgLIwuW7xGr0DlzzeS Z2VrjjnBbzgcmN9cFllPNaSusP4za61qx55riBR/IjH2+So6zvkvrmZMPxiAWlBe77RO 0AGLdcrfXJFLZ4CruvHmFSzQDPGFJ1ERnWjM5V0QWTznakGQFYUI6VLNF94Fbb9oZRR+ Hpfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=LF4hW/6/Zxe5Hv3wfgcnaBbCFNL8gJuXb+VF1+Fk9Wg=; b=sw7NGsVfG8lmiFMC0N/AvKBmtGtCSmQyoPGxjxUuIgAe4ooy/W/7vWHOes48fUbfiD FJF1yPJ2fpsjRll0q8ro2HFWq2Ik08KEOIWkYb/cOYAM2rRpqjvzt4n7NwaP+M2rmqMz L7BnefzbZA70fsLQiuDjMi+nU7DLviSrAc8jZK6TJ8z5ix5B9BhPlyxYy122UQ4hTZWk PMExNp6Vthl2GIErMQlMp+MeFWwDJSRMunySv6bkO1r//3yZJThejHFEZJSyIrsjX5no X+GJmusOX08W8HGENP1iOL1/h1JD3g+epjU8uofSSqtYAvVkzH066GANtNJSfDERfSHf Co7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r1si72554080jac.1.2019.07.23.14.37.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2019 14:37:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hq2S8-0001wp-J0; Tue, 23 Jul 2019 21:36:08 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hq2S6-0001vh-BJ for xen-devel@lists.xenproject.org; Tue, 23 Jul 2019 21:36:06 +0000 X-Inumbo-ID: dfec0d65-ad91-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id dfec0d65-ad91-11e9-8980-bc764e045a96; Tue, 23 Jul 2019 21:36:05 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B43DE1509; Tue, 23 Jul 2019 14:36:04 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0DAAD3F71F; Tue, 23 Jul 2019 14:36:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 23 Jul 2019 22:35:51 +0100 Message-Id: <20190723213553.22300-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190723213553.22300-1-julien.grall@arm.com> References: <20190723213553.22300-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 5/7] xen/arm: traps: Avoid BUG_ON() in do_trap_brk() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , Stefano Stabellini , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, do_trap_brk() is using a BUG_ON() to check the hardware has been correctly configured during boot. Any error when configuring the hardware could result to a guest 'brk' trapping in the hypervisor and crash it. This is pretty harsh to kill Xen when actually killing the guest would be enough as misconfiguring this trap would not lead to exposing sensitive data. Replace the BUG_ON() with crashing the guest. Signed-off-by: Julien Grall Reviewed-by: Volodymyr Babchuk Reviewed-by: Stefano Stabellini --- xen/arch/arm/traps.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 132686ee0f..ef37ca6bde 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1304,10 +1304,15 @@ int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc) #ifdef CONFIG_ARM_64 static void do_trap_brk(struct cpu_user_regs *regs, const 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. + /* + * HCR_EL2.TGE and MDCR_EL2.TDR are currently not set. So we should + * never receive software breakpoing exception for EL1 and EL0 here. */ - BUG_ON(!hyp_mode(regs)); + if ( !hyp_mode(regs) ) + { + domain_crash(current->domain); + return; + } switch ( hsr.brk.comment ) {