Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp376825rdb; Thu, 19 Oct 2023 07:08:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9u/qLdIT31nmxosdZ04rPtD2maJ9f3wH46pR1bjpY/p4csRHQeVM/LH/ZWkUIsktvadC3 X-Received: by 2002:a17:90b:4a45:b0:27d:1538:e324 with SMTP id lb5-20020a17090b4a4500b0027d1538e324mr2259863pjb.32.1697724514417; Thu, 19 Oct 2023 07:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697724514; cv=none; d=google.com; s=arc-20160816; b=T4LHkOCCVUX6mztRZmZuETl+LxRAdmLOnF2P7yHBLdCq70arK7Di8HwKi6XYu1D6UI qxAHlToeN0MrieLx4RSyVw7cLnNo6HVaaWa7lxsYVgGjxK8z+8Ezr5rHTuvpqaf92gyP SMnyeQMwC3xxKr85DpjlirVg5r4RLV5ut56QbS4Y01KsBe432iuMdQyIkYwbkvwdX8+V gbSd7TiyuEX/8xvB5Hk2w22kTkrIyNMENBFkr+aSbpL9jJvlImmxcHLOVJraTlh6aIPP Mqb7hnAqS+XgTTRgIUcm4qGPX5Xt0gwJhbdZzPJX91+DaLj3weQvLOE1fPcS2GYQYEj4 sWJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=FD0Cxl6Rq/wr1XDJOlzmk1Cj7VjUh6g83mpZ8g11YFY=; fh=e1nfvWPuMqo4AAewW5YsDRtbO+rg/GGfn+rLaPsWmzE=; b=LOeFCAG9Q5Wj14H8R4tI8MxqEcy38xy7dN6w70w+KP2m19GR2BPWxoMBn+5m9Icg4g WL5tj4US1RRsxjrTSFG+s0F3zE0M85Tjcd84SfFatwVTyr07rBPa+KQ4A28iGmlZ1yFu 50xAEvvkuIaUwB9ErnOiWVAiawjzVrngZbZNSYNKPXJW/yxgTEKx2euMYT5+/CR7b8gs NEsB7wCvk2Z1Y2wiziB6cmjuaMu9ZPRWW1NAzo7NcIHf796vMLFFyxCun2x3h/QnQSV4 LV0NoQ9UmFBWhaqcf7F3QzER2bwTfjUt17kxSOlgJqxzuRjl06FCyRIamJ2sPzYWgBFD FpKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+IPTom2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bv127-20020a632e85000000b005b368301d97si3644301pgb.305.2023.10.19.07.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:08:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+IPTom2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 6BEDD828F49F; Thu, 19 Oct 2023 07:08:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345967AbjJSOH7 (ORCPT + 99 others); Thu, 19 Oct 2023 10:07:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235408AbjJSOH4 (ORCPT ); Thu, 19 Oct 2023 10:07:56 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3613D13E for ; Thu, 19 Oct 2023 07:07:53 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA561C433C7; Thu, 19 Oct 2023 14:07:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697724472; bh=cwYxbU4uV9qhjaZqQV147ceVMlmQJtz8w9Ywna095cw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=q+IPTom2FPEiR0CZOXFr3hpsQMqHhZzSOfLuZ4fMGMzkkSPKthZCqwsjdryEL38wI EYAFnimwk7YdRuLJgSdmc5r9H9T8bRXGen40+CloRUQh22n2QkZ5NXTTw/96DvgsN5 kra9MsUIjAP/3HEJmQPF3BdgTGFN13EIXt8s5k2eaFZ1XxllTK9SJzcPY/FDr8N09M hxAKwYCqOo1FfX3gjdBRRQJWK2Z+4nwOZZoFTTuav/9ou2GZrJZ0Flea0bVczYbNIf RjJWhKGQbsbxTPl6zAK3dlnwaohLFrBuHiRVf/kjqOiblmbv3FF+J/eXQ7ydnTpkFD EWUbgOYWu8Daw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qtTgk-005nGE-3v; Thu, 19 Oct 2023 15:07:50 +0100 Date: Thu, 19 Oct 2023 15:07:48 +0100 Message-ID: <86h6mmn1sb.wl-maz@kernel.org> From: Marc Zyngier To: Miguel Luis Cc: Catalin Marinas , Will Deacon , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Jing Zhang , Eric Auger , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "kvmarm@lists.linux.dev" Subject: Re: [PATCH v4 2/3] arm64: Add missing _EL2 encodings In-Reply-To: <21F82E44-6D93-4F4C-8991-F14948673F54@oracle.com> References: <20231016111743.30331-1-miguel.luis@oracle.com> <20231016111743.30331-3-miguel.luis@oracle.com> <86jzrin8nq.wl-maz@kernel.org> <21F82E44-6D93-4F4C-8991-F14948673F54@oracle.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/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: miguel.luis@oracle.com, catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, jingzhangos@google.com, eric.auger@redhat.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:08:25 -0700 (PDT) On Thu, 19 Oct 2023 14:23:09 +0100, Miguel Luis wrote: >=20 > Hi Marc, >=20 > > On 19 Oct 2023, at 11:39, Marc Zyngier wrote: > >=20 > > On Mon, 16 Oct 2023 12:17:41 +0100, > > Miguel Luis wrote: > >>=20 > >> Some _EL2 encodings are missing. Add them. > >>=20 > >> Signed-off-by: Miguel Luis > >> --- > >> arch/arm64/include/asm/sysreg.h | 39 +++++++++++++++++++++++++++++++++ > >> 1 file changed, 39 insertions(+) > >>=20 > >> diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/= sysreg.h > >> index ba5db50effec..8653fb67a339 100644 > >> --- a/arch/arm64/include/asm/sysreg.h > >> +++ b/arch/arm64/include/asm/sysreg.h > >=20 > > [...] > >=20 > >> +#define SYS_SDER32_EL2 sys_reg(3, 4, 1, 3, 1) > >=20 > > [...] > >=20 > >> +#define SYS_VSTTBR_EL2 sys_reg(3, 4, 2, 6, 0) > >> +#define SYS_VSTCR_EL2 sys_reg(3, 4, 2, 6, 2) > >=20 > > [...] > >=20 > >> +#define SYS_CNTHVS_TVAL_EL2 sys_reg(3, 4, 14, 4, 0) > >> +#define SYS_CNTHVS_CTL_EL2 sys_reg(3, 4, 14, 4, 1) > >> +#define SYS_CNTHVS_CVAL_EL2 sys_reg(3, 4, 14, 4, 2) > >> +#define SYS_CNTHPS_TVAL_EL2 sys_reg(3, 4, 14, 5, 0) > >> +#define SYS_CNTHPS_CTL_EL2 sys_reg(3, 4, 14, 5, 1) > >> +#define SYS_CNTHPS_CVAL_EL2 sys_reg(3, 4, 14, 5, 2) > >=20 > > While the secure definitions seem correct, what is the rationale > > behind their presence here? They cannot be trapped from non-secure, > > and the pseudocode is pretty explicit: > >=20 > > if !IsCurrentSecurityState(SS_Secure) then > > UNDEFINED; > >=20 > > Given that, they cannot be trapped, handled or accessed from a KVM > > guest, as Linux on arm64 *always* runs non-secure. > >=20 >=20 > Thank you for clarifying. >=20 > Those definitions were needed for the refinement on patch 3 which clearly > didn=E2=80=99t considered that statement beforehand. >=20 > Yet, should we keep them here so they could be used? But that's the whole point: they *cannot* be used. You can't use a secure system register in non-secure, and we *always* run in non-secure, no ifs no buts. If a guest ever uses one of those, it will get an UNDEF exception directly, without any SW intervention, because that's just illegal. KVM will never see it. As far as Linux is concerned, this is purely dead code. M. --=20 Without deviation from the norm, progress is not possible.