From patchwork Fri Mar 24 05:51:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 74356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp401546vqo; Thu, 23 Mar 2023 23:04:34 -0700 (PDT) X-Google-Smtp-Source: AK7set/taGs9+36k3pqFxb7HsBDjrKU6q4Ndgg0vjZm5i0Ds2Gdwbcu/Q8cNBc11GvyVbE6bspeb X-Received: by 2002:a17:907:6e17:b0:902:874:9c31 with SMTP id sd23-20020a1709076e1700b0090208749c31mr9451978ejc.35.1679637874279; Thu, 23 Mar 2023 23:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679637874; cv=none; d=google.com; s=arc-20160816; b=ea7qzRJDB2CSGajIRIPB7VEweJsFB2uu0fqeBq6/5XpEPnN01tbFlcVKUujjFcoxEu lNGtUtdcHv2xxWYzLe3VAXubwY3jM7XTLrDk40XSz6Xas07clIP91jRx5FYf7UwHNAyF 0SVFhvugmtLYF+hTTPyGx/VxDZBmKxGYtkkF9MIdyAE5D3Qi3+s+eHA+rADluD2ndLzC cGjvj8e+rNOEZvH3pFW5AU6BRTFYK+CI1afu+p+e2zluq1jWzKVjcM+3lM8i1Pt38r1v WOAODIdl2QRbRLvqUO+tRIc9UNHQmboMH+a3H1SSn+z011Sd8QaLzvAesH4I9wz6W39d ja1w== 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=YhvNIM/dCDp4h+SycBoI6mV96sl07LpvQ/iAqV3+ZJ0=; b=OYbGoBZiUo14K7fNFxc3n49/bElln80Ve3lDTj51yD6m/5YSs2iUgQqKJxVri2IL5/ AfAZ65gcTrqxInEDOGyxbyB4dLuS+zg/2DOI/hBdJzL1CPdvamBqXE47fUwFTQ9kG7vs 5TLzV0mVdkP1Wzc8cMN0jUqsfNTUit23s0By+ZJrwYO0s4g3npY5ISaErwxYzFnRdCiT MlhgKzHlR10SXy6O2wCmITBE/0BeM44sllp17/6Pr8KZfYy+9DgXQ824ln0cg6wyATBV L2Y4POTcHlD7ROZCuOdVRPAYbXe3TKKNDFqxBiALJ3V+gWDZgcP2TjPJjWyiDNm3W8Nr cQMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z7-20020a1709063a0700b008cdeb3c9cd3si22657377eje.791.2023.03.23.23.04.10; Thu, 23 Mar 2023 23:04:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231299AbjCXFvj (ORCPT + 99 others); Fri, 24 Mar 2023 01:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbjCXFvi (ORCPT ); Fri, 24 Mar 2023 01:51:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 87107DBE8 for ; Thu, 23 Mar 2023 22:51:36 -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 476A411FB; Thu, 23 Mar 2023 22:52:20 -0700 (PDT) Received: from a077893.blr.arm.com (unknown [10.162.40.17]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E58253F766; Thu, 23 Mar 2023 22:51:33 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Mark Brown , Marc Zyngier , linux-kernel@vger.kernel.org Subject: [PATCH] arm64: Disable EL2 traps for BRBE instructions executed in EL1 Date: Fri, 24 Mar 2023 11:21:27 +0530 Message-Id: <20230324055127.2228330-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761227963848611120?= X-GMAIL-MSGID: =?utf-8?q?1761227963848611120?= This disables EL2 traps for BRBE instructions executed in EL1. This would enable BRBE to be configured and used successfully in the guest kernel. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This patch applies on v6.3-rc3, after the following patch series from Mark https://lore.kernel.org/all/20230306-arm64-fgt-reg-gen-v3-0-decba93cbaab@kernel.org/ arch/arm64/include/asm/el2_setup.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h index 037724b19c5c..06bf321a17be 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -161,6 +161,16 @@ msr_s SYS_HFGWTR_EL2, x0 msr_s SYS_HFGITR_EL2, xzr + mrs x1, id_aa64dfr0_el1 + ubfx x1, x1, #ID_AA64DFR0_EL1_BRBE_SHIFT, #4 + cbz x1, .Lskip_brbe_\@ + + mov x0, xzr + orr x0, x0, #HFGITR_EL2_nBRBIALL + orr x0, x0, #HFGITR_EL2_nBRBINJ + msr_s SYS_HFGITR_EL2, x0 + +.Lskip_brbe_\@: mrs x1, id_aa64pfr0_el1 // AMU traps UNDEF without AMU ubfx x1, x1, #ID_AA64PFR0_EL1_AMU_SHIFT, #4 cbz x1, .Lskip_fgt_\@