Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3538352rdg; Tue, 17 Oct 2023 20:00:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZxPyAkmRP47D5AYzV4AYwTPoQYNDqst5M8Q3mhFNoscCaLQLpFrt/6VFpryZSdM0Q7YI/ X-Received: by 2002:a05:6808:210d:b0:3ad:c5e7:8e11 with SMTP id r13-20020a056808210d00b003adc5e78e11mr5373994oiw.0.1697598057178; Tue, 17 Oct 2023 20:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697598057; cv=none; d=google.com; s=arc-20160816; b=Hey7jT38O6euB/lT0rDXzHLZb4NwKKSyBm2nK6XV3PvZ56CR+U112Vj8bmrToX12kE o4UgAWMZ/OgNE/TyyMhDZcLdJ3sFC+JeobUY0JacqmIvROPFSPqnzecX2WrunAKJxe+/ eviPTVYqhuM0dGkKCFuxT6Xp+qpFiCWd3PNogmkiN5uMSYN7G1AUc30bQBAVc+rEDPoJ kUTlgat+4W/lK6k0obEwAsIaq69sztUXZb+3XMSVnZZgJ2YsOiND8L9pc3pvoWctqVv0 WUVwQ0PJXT6aJ+OdIzQGlC2ZrF2Jp5EEzPST6WuAkyj2sXv894+PbBsz83oMYuVjpQKr izMw== 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 :message-id:date:subject:cc:to:from; bh=5daQhkWFykKz57qRi0eKaM9pEoBZ7YPpXT9+h5jIfP8=; fh=z9cjnRzrIGlx7Ryd7rpMud4EUYoDOGLEW4lkG6DFBe8=; b=gqGCXMwV4q+IR8gBrxSNUz9H3S9T6x5OMhfUV9XycNAwN5HWUbqm47sf1KdOdrnre5 ob7DlnlzuDHe3h0XTTN6K27rAprVV2o9uVHEbRsBeOsjNh7Tw1n3BSpmc5jvWcuYw+dt CzdvYy4uUJYGwq03LzqDCYH/1lnkp1HiinzHmsJa8CGiYPunDV0LHEwHidQpvdIQtjoT V4Xq54zLTDHofJUycVxRbd/ZUQ6tl/K54AoAmgKiHy3v4Wvq2gOOHx9ip0g1HS5XLt2h n/e9l+Cw9Lvz5+CSrIOKO3xW0QMGz5YWLe9ZC7HEx53Srobrjl1Kb1Nk7Sip9e/nPFt0 jQLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id r11-20020a65498b000000b005ad176a9d2bsi1143834pgs.240.2023.10.17.20.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 20:00:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B375D8067E09; Tue, 17 Oct 2023 20:00:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229456AbjJRDAY (ORCPT + 99 others); Tue, 17 Oct 2023 23:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjJRDAX (ORCPT ); Tue, 17 Oct 2023 23:00:23 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BF26BAB for ; Tue, 17 Oct 2023 20:00:20 -0700 (PDT) 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 316B22F4; Tue, 17 Oct 2023 20:01:01 -0700 (PDT) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.41.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 846AF3F5A1; Tue, 17 Oct 2023 20:00:17 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Oliver Upton , Marc Zyngier , linux-kernel@vger.kernel.org Subject: [PATCH] arm64: Independently update HDFGRTR_EL2 and HDFGWTR_EL2 Date: Wed, 18 Oct 2023 08:30:07 +0530 Message-Id: <20231018030007.1968317-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 20:00:39 -0700 (PDT) Currently PMSNEVFR_EL1 system register read, and write access EL2 traps are disabled, via setting the same bit (i.e 62) in HDFGRTR_EL2, and HDFGWTR_EL2 respectively. Although very similar, bit fields are not exact same in these two EL2 trap configure registers particularly when it comes to read-only or write-only accesses such as ready-only 'HDFGRTR_EL2.nBRBIDR' which needs to be set while enabling BRBE on NVHE platforms. Using the exact same bit mask fields for both these trap register risk writing into their RESERVED areas, which is undesirable. Cc: Catalin Marinas Cc: Will Deacon Cc: Oliver Upton Cc: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This applies on v6.6-rc6. I guess it should be okay to use 'x2' as it is in the clobbered register list for init_el2_state() function. But please do let me know otherwise. arch/arm64/include/asm/el2_setup.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h index 899b5c10f84c..c534afb1a30d 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -206,16 +206,19 @@ cbz x1, .Lskip_fgt_\@ mov x0, xzr + mov x2, xzr mrs x1, id_aa64dfr0_el1 ubfx x1, x1, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4 cmp x1, #3 b.lt .Lset_debug_fgt_\@ + /* Disable PMSNEVFR_EL1 read and write traps */ - orr x0, x0, #(1 << 62) + orr x0, x0, #HDFGRTR_EL2_nPMSNEVFR_EL1_MASK + orr x2, x2, #HDFGWTR_EL2_nPMSNEVFR_EL1_MASK .Lset_debug_fgt_\@: msr_s SYS_HDFGRTR_EL2, x0 - msr_s SYS_HDFGWTR_EL2, x0 + msr_s SYS_HDFGWTR_EL2, x2 mov x0, xzr mrs x1, id_aa64pfr1_el1 -- 2.25.1