Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2559551rdb; Mon, 4 Dec 2023 00:22:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IELgEGKMFXVbLGmM4Oo84mae64kSesF1Xduf1l4FZWXlJNSPeMES9ctjbtjeg/Y1YHzv7No X-Received: by 2002:a17:902:b945:b0:1d0:6ffe:a2c with SMTP id h5-20020a170902b94500b001d06ffe0a2cmr3417760pls.138.1701678160260; Mon, 04 Dec 2023 00:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701678160; cv=none; d=google.com; s=arc-20160816; b=bzmfNAWSsIzC1HVWUCRY4qVn0NdcSB9j4EfeV/kH0MrPWaiN60N1dkJTeyyQj8RJ0g vNCe7shyiP7fXFHkThci7o13iZvnT8C6klXJCx1KAxS1nMtAVlmKLIMIkaYMFq4zmtox 414TA7POynaXNeGzRM8s7uJN3oc7Yeeq0dmgpP3RnZjYl+j3Mivxkuyq/2g6xyiuYZ8n ODRZoBsxuH0kMFrGntfIwWhOyuvZOHQ5RScQ7wgiswATIXeAozOtiSW+X88TqhZ4jWX1 uYMf5Og0uml7Gj5lYJ8fE1ZdoxOfYOnHTLwBtdqhn0g4pOW0sPRHgBu3EIjYm6+J6JmG Ciyg== 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:dkim-signature; bh=uSBmb45mSFy7En58dn/lrQ1egRVGz0khEw4lmwwMqEY=; fh=MualLUEgSTyoTxSPxizY4L9ZPpNq/c8zmiKP0BtA4kU=; b=DiMMz34LksRZ058TPHHsrhqI4Hl0t5G4dze4u78znaAZo82co2wx7UINppS6O2lEi3 8pYcTeBXhWzaYU6DIzHss7xR84GW7SSXKyXV8slMrfv4Ca844YziRJ0Xk/a2b2G8sF4t w8RJfBIuDoMjHRH4VMgxIu37glIO/3I/cbLcVmviGJLeCsmkMKdoRBLxqq6PBR9cS8gu 1LH4p2CJBj6tH2eMqrh7EsKpqw6Jmfh7WdWIbCsXv0x2fVDiO5Ns2M6BZ67THR25eoD7 I/gNCdlJlic6l2SyyA1eya4IPCMN9uOJugD6+xpRb1eZkF7PuKLIvq2uCQ60RaaSUr6B TAMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gLvzMSTe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id b4-20020a170902d88400b001d0b24e1648si672989plz.578.2023.12.04.00.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:22:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gLvzMSTe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id E977F806290B; Mon, 4 Dec 2023 00:22:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231408AbjLDIWX (ORCPT + 99 others); Mon, 4 Dec 2023 03:22:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjLDIWW (ORCPT ); Mon, 4 Dec 2023 03:22:22 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 221A4CB for ; Mon, 4 Dec 2023 00:22:29 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A425BC433C7; Mon, 4 Dec 2023 08:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701678148; bh=d5xd1DNNe8JHTchZ1N0VUvsvu4Wgsp0ilZmuF8NZBgQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gLvzMSTejitY38rVbVjqGTXEH+MOT+PcFUG93c0YgGr336/kcmHuZtMyWAJUur9dj ylPSMIrRC6wrFF6JH8llfP4lnxofw9JWIRKnnRbtGCKoUGUmv+BvE3zqzIXchLcyIJ mN17ecVhBQKZ+dWBJT03lM6eIzrvq3+6DCrCLjqF0YaafhQ/cwUi5brHnGaFs86F8I 4b4iOCkO3HIr/O4KlY6DcVzLuCyIZfchlvHG3+jOPQHbJfDpNjrPmWxRBahk/mvnEW MFOGWM7jIeEf4pzDdJPtfQVNnDvtINBdxCPnCpYJn/bidcPDKIQxzXDyMbQL9ojseN 70ErEzj5WRZbw== 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 1rA4Di-0018lj-9m; Mon, 04 Dec 2023 08:22:26 +0000 Date: Mon, 04 Dec 2023 08:22:25 +0000 Message-ID: <86v89ebcn2.wl-maz@kernel.org> From: Marc Zyngier To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, Mark Brown , James Clark , Rob Herring , Suzuki Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org, Oliver Upton , James Morse , kvmarm@lists.linux.dev Subject: Re: [PATCH V15 2/8] KVM: arm64: Prevent guest accesses into BRBE system registers/instructions In-Reply-To: <20231201053906.1261704-3-anshuman.khandual@arm.com> References: <20231201053906.1261704-1-anshuman.khandual@arm.com> <20231201053906.1261704-3-anshuman.khandual@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/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=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, broonie@kernel.org, james.clark@arm.com, robh@kernel.org, suzuki.poulose@arm.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-perf-users@vger.kernel.org, oliver.upton@linux.dev, james.morse@arm.com, 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 00:22:38 -0800 (PST) On Fri, 01 Dec 2023 05:39:00 +0000, Anshuman Khandual wrote: > > Currently BRBE feature is not supported in a guest environment. This hides > BRBE feature availability via masking ID_AA64DFR0_EL1.BRBE field. This also > blocks guest accesses into BRBE system registers and instructions as if the > underlying hardware never implemented FEAT_BRBE feature. > > Cc: Marc Zyngier > Cc: Oliver Upton > Cc: James Morse > Cc: Suzuki K Poulose > Cc: Catalin Marinas > Cc: Will Deacon > Cc: kvmarm@lists.linux.dev > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > arch/arm64/kvm/sys_regs.c | 130 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 130 insertions(+) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 4735e1b37fb3..42701065b3cd 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -1583,6 +1583,9 @@ static u64 read_sanitised_id_aa64dfr0_el1(struct kvm_vcpu *vcpu, > /* Hide SPE from guests */ > val &= ~ID_AA64DFR0_EL1_PMSVer_MASK; > > + /* Hide BRBE from guests */ > + val &= ~ID_AA64DFR0_EL1_BRBE_MASK; > + > return val; > } > > @@ -2042,6 +2045,8 @@ static const struct sys_reg_desc sys_reg_descs[] = { > { SYS_DESC(SYS_DC_CISW), access_dcsw }, > { SYS_DESC(SYS_DC_CIGSW), access_dcgsw }, > { SYS_DESC(SYS_DC_CIGDSW), access_dcgsw }, > + { SYS_DESC(OP_BRB_IALL), undef_access }, > + { SYS_DESC(OP_BRB_INJ), undef_access }, > > DBG_BCR_BVR_WCR_WVR_EL1(0), > DBG_BCR_BVR_WCR_WVR_EL1(1), > @@ -2072,6 +2077,131 @@ static const struct sys_reg_desc sys_reg_descs[] = { > { SYS_DESC(SYS_DBGCLAIMCLR_EL1), trap_raz_wi }, > { SYS_DESC(SYS_DBGAUTHSTATUS_EL1), trap_dbgauthstatus_el1 }, > > + /* > + * BRBE branch record sysreg address space is interleaved between > + * corresponding BRBINF_EL1, BRBSRC_EL1, and BRBTGT_EL1. > + */ > + { SYS_DESC(SYS_BRBINF0_EL1), undef_access }, > + { SYS_DESC(SYS_BRBSRC0_EL1), undef_access }, > + { SYS_DESC(SYS_BRBTGT0_EL1), undef_access }, > + { SYS_DESC(SYS_BRBINF16_EL1), undef_access }, > + { SYS_DESC(SYS_BRBSRC16_EL1), undef_access }, > + { SYS_DESC(SYS_BRBTGT16_EL1), undef_access }, Surely we can do better than this wall of text. Please look at what we do for the debug registers, and adopt a similar pattern. This should result in one line per group of 3 registers. What is the plan for KVM support beyond this? M. -- Without deviation from the norm, progress is not possible.