Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D60BC433EF for ; Wed, 13 Jul 2022 18:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=IB8Sof7/nAEDPt/BZGbocNEggMa1JS30rSQvFcSv+zc=; b=cWU HwbdPZPaKn2CwPaNZ4LT78m60o3j915ixEPsUoMCSMa49lHwbSp+CjKK8JJPyTfOce09Mth5B+4M6 Hx7/Du9cwq3AZ3W4vF1tp92WUOGM1CAinV4Xlp0mgkBcY94hKYNQNf0ufw7vWMtH9aweBB4GoD3s7 DNRGHlDcx9m4SgkGUmisP0qDwXOx8xF15EAEX6wzy/+tQGr7cDy5mVy5i0X1Tmtagflhe2Fun0GH0 13vNSTAkLlPD7s9ZRp6uok3o3uZ2jcnBb32SlijlLCzOCsBmC4L1PZBMJVTXepnLnuuinzYlNC5SW EkEsLkaMKdkbxrqa9rfd+erdzYm5WPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBgx2-006R43-4d; Wed, 13 Jul 2022 18:19:08 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBgwz-006R35-6w for linux-arm-kernel@lists.infradead.org; Wed, 13 Jul 2022 18:19:06 +0000 Received: by mail-yb1-xb49.google.com with SMTP id r16-20020a257610000000b0066f5239588eso6273599ybc.12 for ; Wed, 13 Jul 2022 11:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=Zg5CmvpC1VDovVTtnZIdz0GbfJvsMpUMcXXu76tfq6s=; b=pUkxy2t4fQ8idoShGLy+98ltsv5LqUGQLF3DSIWcQKsgjk9vPttj0yKMjyT3ySZrwz cA+4GkqIGOfo0Indvz5TStvEoTXFs1KGkKVKG2dK7ruDemhdE70+RC3qzgHYha6AFIrD /HhAQzXj4kXiSTNsOgtf7JsZ9UuSyTatqCVE1Ir1JYP2UGn2+ckEF8mmiCwviU06oklv qEAWlET6tku4/9MVFqMxTn6rkQe+VB8oz3Xo3/igVvK9dKtRklJu4jYxLB9a9ixMO1cU jjnq4BmI1CTTw+uLhk0JOiaNC6Ddm2km0Q2D8OYe71sdusBk5uILtuyameuAuVLeoLh9 39rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Zg5CmvpC1VDovVTtnZIdz0GbfJvsMpUMcXXu76tfq6s=; b=H6rMbo1Gj9t3zpmtc4rS0DCY3Pifg58mcDn1t5rAM2vUnhbFpV2pSbezYFC7SnCmCV 5pHK2A/G4ezV9gms91SimbFbKUCx6qaoXErt8yUlyqtJqT7HcSEMuRag7ZHjzkgQCu/i ktHYb/KTiC+gccunEYdl8HI+VviZataclp5lo3XLJZ/MqtHk1mE+CODxyJfoTI8KaQJb S9SDskqvw89iWHsI8Xi36OIrO9N/KJgzFNvwLpYPaqldMHVqFHsLfAai2FjmMKvFJlEW 1wDsQ9cI76tbP05PA7aJPzSIlZYLzxlswB/ieUeJA2NJ8mKlG411PGlISTAGdZJxMRt9 kg+Q== X-Gm-Message-State: AJIora/OBQWi32v9AGCpKjJdF0plneUAArJECH9WAFsfys8s+I578woH gHhdsPFvpFORvcrGu6VwZ6LX2/w= X-Google-Smtp-Source: AGRyM1t5NatxGw+4FVoxldy6aJi+ii9wFJWWrdnShIqYyWJtBPkqoMwiNrBA7xnNS26By3tByhtYIqQ= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:476f:a969:638e:e0f5]) (user=pcc job=sendgmr) by 2002:a25:9208:0:b0:66e:b73f:cdf4 with SMTP id b8-20020a259208000000b0066eb73fcdf4mr5028843ybo.300.1657736342437; Wed, 13 Jul 2022 11:19:02 -0700 (PDT) Date: Wed, 13 Jul 2022 11:18:52 -0700 Message-Id: <20220713181852.3652212-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.144.g8ac04bfd2-goog Subject: [PATCH] arm64: use sanitized feature registers for conditional ZCR_EL1 and SMCR_EL1 reads From: Peter Collingbourne To: Marc Zyngier Cc: Peter Collingbourne , linux-arm-kernel@lists.infradead.org, Will Deacon , Catalin Marinas , Mark Rutland , Ard Biesheuvel , broonie@kernel.org, danielmentz@google.com, saravanak@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220713_111905_272007_BD46E7F1 X-CRM114-Status: GOOD ( 14.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With arm64.nosve we would still read ZCR_EL1 in __cpuinfo_store_cpu because the condition for reading it was based on the unsanitized feature register value info->reg_id_aa64pfr0. Fix the problem by moving the reads to init_cpu_features after we have computed the sanitized value. Fix the SMCR_EL1 read for SME similarly. Fixes: 504ee23611c4 ("arm64: Add the arm64.nosve command line option") Signed-off-by: Peter Collingbourne --- arch/arm64/kernel/cpufeature.c | 11 +++++++---- arch/arm64/kernel/cpuinfo.c | 8 -------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index e5afa9eba85d..71d290fec36f 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -999,15 +999,18 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info) if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) init_32bit_cpu_features(&info->aarch32); - if (id_aa64pfr0_sve(info->reg_id_aa64pfr0)) { + if (IS_ENABLED(CONFIG_ARM64_SVE) && + id_aa64pfr0_sve(read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1))) { + info->reg_zcr = read_zcr_features(); init_cpu_ftr_reg(SYS_ZCR_EL1, info->reg_zcr); vec_init_vq_map(ARM64_VEC_SVE); } - if (id_aa64pfr1_sme(info->reg_id_aa64pfr1)) { + if (IS_ENABLED(CONFIG_ARM64_SME) && + id_aa64pfr1_sme(read_sanitised_ftr_reg(SYS_ID_AA64PFR1_EL1))) { + info->reg_smcr = read_smcr_features(); init_cpu_ftr_reg(SYS_SMCR_EL1, info->reg_smcr); - if (IS_ENABLED(CONFIG_ARM64_SME)) - vec_init_vq_map(ARM64_VEC_SME); + vec_init_vq_map(ARM64_VEC_SME); } if (id_aa64pfr1_mte(info->reg_id_aa64pfr1)) diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 8eff0a34ffd4..66bc6f25d3b4 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -418,14 +418,6 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info) if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) __cpuinfo_store_cpu_32bit(&info->aarch32); - if (IS_ENABLED(CONFIG_ARM64_SVE) && - id_aa64pfr0_sve(info->reg_id_aa64pfr0)) - info->reg_zcr = read_zcr_features(); - - if (IS_ENABLED(CONFIG_ARM64_SME) && - id_aa64pfr1_sme(info->reg_id_aa64pfr1)) - info->reg_smcr = read_smcr_features(); - cpuinfo_detect_icache_policy(info); } -- 2.37.0.144.g8ac04bfd2-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel