Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp989406pxb; Fri, 13 Aug 2021 10:43:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVAat7kMyfUx9x0D2NPqe9btTUd5za4PSXn6Se/EwaUuZLwxIZMD/uUWyi+qZyOOXpv8tW X-Received: by 2002:a17:906:9a51:: with SMTP id aj17mr3643814ejc.296.1628876599013; Fri, 13 Aug 2021 10:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628876599; cv=none; d=google.com; s=arc-20160816; b=ReQ0PgiyfwjnnlK7GWDLKt8whbTNwKSZGd7KReIh4HTD111aWMxJ2mji0sjjcy2ElU 7GrAPjztbuqyE1JfyOTNtP2DlzSJityeFmsPFgalOnts3kG6xfsyDU6j80K0ADk3uhPy OGOgxz8hA4Xv2SbvVg4H10vCXG6h7RzdYaHu1atrSO3hu1/Fo0ue+E/wYlLzFv6Q3GW6 bosoIsqEpvjYWrU8gREFx5wu4CAuVnSRHIL/2Gz02WTb5rjyotMQainfQEzLxXHBMnnc +KB1xyBmUyivJXBqoMAR9zJI9FmEJXyiKphv90xRts5mMG29jaHKapnKLJukFAY66l67 L8Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=dP4j4YPuFzbYW0924AR+DF+j7uHa46nB+1Fg7Qcfzxk=; b=lljQRFq3k2Rp1TRmSYrUrckBJiS2lMfrL9xafSX3tIfbedMeGcYpir6xk0d3fRMOXZ +XC+G47FJ8MpWG986BDOCIejn5Twc0vOYURUuZOXFvtptBSg6MV3pkgsrDVEH/Q8Jva4 rjDxvTj7EG7KBd8BnZ69QI1e090DtptN9M5RPrp2zIyGgXbJBNl9SFfH7mrDlOmCS6OV pMPSR1z68SuaxxS+UkkkMBACTf56Iz4hRmG6uer0/7uZ9zu/7kja7qECN+ZG8fkOWFrl hcI10fnUw8wKMA8RsqJjb+Y11eRF9q8QcvbFIJxcWm5AEsfHMNNAg4k+YoMUAs1Em1nm IYqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si2810020edq.486.2021.08.13.10.42.54; Fri, 13 Aug 2021 10:43:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229654AbhHMRl4 (ORCPT + 99 others); Fri, 13 Aug 2021 13:41:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:41946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbhHMRl4 (ORCPT ); Fri, 13 Aug 2021 13:41:56 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3241D60F51; Fri, 13 Aug 2021 17:41:29 +0000 (UTC) Received: from 109-170-232-56.xdsl.murphx.net ([109.170.232.56] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mEbBP-004qe7-2x; Fri, 13 Aug 2021 18:41:27 +0100 Date: Fri, 13 Aug 2021 18:41:36 +0100 Message-ID: <87im091bu7.wl-maz@kernel.org> From: Marc Zyngier To: Robin Murphy Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Will Deacon , Catalin Marinas , Mark Rutland , Ard Biesheuvel , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, kernel-team@android.com Subject: Re: [PATCH 2/5] arm64: Handle UNDEF in the EL2 stub vectors In-Reply-To: <2f6bf17f-d235-8311-13d5-dcb3d00e23c4@arm.com> References: <20210812190213.2601506-1-maz@kernel.org> <20210812190213.2601506-3-maz@kernel.org> <2f6bf17f-d235-8311-13d5-dcb3d00e23c4@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 109.170.232.56 X-SA-Exim-Rcpt-To: robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, zajec5@gmail.com, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, ardb@kernel.org, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Aug 2021 14:08:23 +0100, Robin Murphy wrote: > > On 2021-08-12 20:02, Marc Zyngier wrote: > > As we want to handle the silly case where HVC has been disabled > > from EL3, augment our ability to handle exception at EL2. > > > > Check for unknown exceptions (usually UNDEF) coming from EL2, > > and treat them as a failing HVC call into the stubs. While > > this isn't great and obviously doesn't catter for the gigantic > > range of possible exceptions, it isn't any worse than what we > > have today. > > > > Just don't try and use it for anything else. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kernel/hyp-stub.S | 19 ++++++++++++++++++- > > 1 file changed, 18 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S > > index 43d212618834..026a34515b21 100644 > > --- a/arch/arm64/kernel/hyp-stub.S > > +++ b/arch/arm64/kernel/hyp-stub.S > > @@ -46,7 +46,16 @@ SYM_CODE_END(__hyp_stub_vectors) > > .align 11 > > SYM_CODE_START_LOCAL(elx_sync) > > - cmp x0, #HVC_SET_VECTORS > > + mrs x4, spsr_el2 > > + and x4, x4, #PSR_MODE_MASK > > + orr x4, x4, #1 > > + cmp x4, #PSR_MODE_EL2h > > + b.ne 0f > > + mrs x4, esr_el2 > > + eor x4, x4, #ESR_ELx_IL > > + cbz x4, el2_undef > > Hmm, might it be neater to check ESR_EL2.ISS to see if we landed here > for any reason *other* than a successfully-executed HVC? We absolutely could. However, the sixpence question (yes, that's the Brexit effect for you) is "what do you do with exceptions that are neither UNDEF now HVC?". We are taking a leap of faith by assuming that the only thing that will UNDEF at EL2 while the stubs are installed is HVC. If anything else occurs, I have no idea what to do with it. I guess we could always ignore it instead of treating it as a HVC (as it is done at the moment). Thanks, M. -- Without deviation from the norm, progress is not possible.