From patchwork Tue Oct 1 16:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 13818408 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E47ACCEACE5 for ; Tue, 1 Oct 2024 16:07:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0FA02800A0; Tue, 1 Oct 2024 12:07:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94B35280068; Tue, 1 Oct 2024 12:07:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79F522800A0; Tue, 1 Oct 2024 12:07:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5808C280068 for ; Tue, 1 Oct 2024 12:07:16 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E07B214165F for ; Tue, 1 Oct 2024 16:07:15 +0000 (UTC) X-FDA: 82625512830.10.437F92A Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf25.hostedemail.com (Postfix) with ESMTP id E7301A0026 for ; Tue, 1 Oct 2024 16:07:13 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=KbYTT5pI; spf=pass (imf25.hostedemail.com: domain of debug@rivosinc.com designates 209.85.215.170 as permitted sender) smtp.mailfrom=debug@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727798706; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FOwX8zEWq9u2vqkDVwGK82xZureIgOdXeRz6EPpdBWc=; b=Qey8O6jFU520tTHgolGEpMpLQP/ubjYaTq249fsdZjf4llh/qgeNxPZfAYjh1tUhvFMZZ4 tDOd15Yr0sVVQb5fRoux7f6+Sz4LQN6m1qv2S+Tys7gXVj8AB1f8ACxZ/dguJccS4S9gQd vSMKa2WY+Qx70CeF2ePF/lIhhJL4UVM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727798706; a=rsa-sha256; cv=none; b=f1yYNqufY61z5T4vtOVU1VH3NYvR5jU0LiSrJDWX6HXEpCX2Gzjw0SXKoCuEpNeaqZ3JWI XJqfaqGKFMnBR5GOL0ln9xwjvGvn3gGcMZnXDhO20nUGsaw6ntTCJoiJoQlJA2g0lozHoS eQM4aphjzxZUXRg7nun/N69t4BZDEp4= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=KbYTT5pI; spf=pass (imf25.hostedemail.com: domain of debug@rivosinc.com designates 209.85.215.170 as permitted sender) smtp.mailfrom=debug@rivosinc.com; dmarc=none Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7d916b6a73aso3651901a12.1 for ; Tue, 01 Oct 2024 09:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1727798832; x=1728403632; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FOwX8zEWq9u2vqkDVwGK82xZureIgOdXeRz6EPpdBWc=; b=KbYTT5pIVh4q5ujfOWKaiqYg5S1JYhKEXZXrVGeHN9qKjNUKI2kZUs/Y0z4mrPY4wP H/l/qL8EegH1LY5v+ra5+9+5YBEgTjZCHu0Wkd7diZfyahBt9AsTS42TyoJ5PSzoye0y hSV2NEsxgJYamiJGIc4d2xqUx6xa9XnGa9QVdb/fbALqtj1G+AwKHawHmNwwz+5WYtLq fkm8iWX1aXBlVpW/O83XySVZTyqdA55IqKpMMRLuIBuq8DysFqeNQw+y6w5NeNCyas45 B1e8xe0IQJcVTKlw9ypjdOvjIlbS+B2xpdVJ0SaX1BQUVDY4d1gMR9yfbhOR26pa9DGw ILuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727798832; x=1728403632; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FOwX8zEWq9u2vqkDVwGK82xZureIgOdXeRz6EPpdBWc=; b=ZMZsCFTb710Sbs/hWakHAlKqwnsdiDz13eao/Ao/2KC1plJbDI8JJmjmrxrIify9me L0rQIipUPeEEIFT3UdE+aJEnZFUjUqgxoqhe630VwkqDoA23hH/Uvs6LNNlXYTZBES56 nFlg5JKxztq1pt3sq/w17xFh3ujy7W7yd0BS1Ph0FrXDlx1M78RkAw1zoqvRUtqi2qcn 72RYxr1JGmzSkL64AZuV7Hl0lE7ZJnBhcLNyJM2KPKwHRnxwfbTDjZ1VqHHtrNwWxxFg 8MFVQEYUyuCx3iBJSRv+PskmBIcJeMkRwVmrTaL2dBRZRXwMF962lY9sVIqsl8RwtTgR KVAQ== X-Forwarded-Encrypted: i=1; AJvYcCXGAGbxYEWb7Hu3YQ2ghezrFoJSQ7tHIxg8gQHRLiO1p8+LwvfxieJHs3/Jc99jcFZyuKcxHnaIXQ==@kvack.org X-Gm-Message-State: AOJu0Yzi/ub8ZMSNqkgHd6/778gyiDfkwPj/4Fz0iQuurIs6VoB794XX Yktgk3TCC+hMmlw2FB5Od9Z62n7WNmDdtrD8y1ebnvny5SiI5LHbvC+7lUZVOak= X-Google-Smtp-Source: AGHT+IG+QoJp6SaYR4NX7gvJQsxk2XpCmBA5X0cJPckGFJwiDNphfS2kILfudd4XZsrEP9ImoMA9pw== X-Received: by 2002:a17:90b:4a86:b0:2e0:a9e8:b9c1 with SMTP id 98e67ed59e1d1-2e1846aff84mr236832a91.22.1727798832417; Tue, 01 Oct 2024 09:07:12 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e06e1d7d47sm13843973a91.28.2024.10.01.09.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:07:12 -0700 (PDT) From: Deepak Gupta Date: Tue, 01 Oct 2024 09:06:10 -0700 Subject: [PATCH 05/33] riscv: Call riscv_user_isa_enable() only on the boot hart MIME-Version: 1.0 Message-Id: <20241001-v5_user_cfi_series-v1-5-3ba65b6e550f@rivosinc.com> References: <20241001-v5_user_cfi_series-v1-0-3ba65b6e550f@rivosinc.com> In-Reply-To: <20241001-v5_user_cfi_series-v1-0-3ba65b6e550f@rivosinc.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Christian Brauner , Peter Zijlstra , Oleg Nesterov , Eric Biederman , Kees Cook , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, alistair.francis@wdc.com, richard.henderson@linaro.org, jim.shu@sifive.com, andybnac@gmail.com, kito.cheng@sifive.com, charlie@rivosinc.com, atishp@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, alexghiti@rivosinc.com, samitolvanen@google.com, broonie@kernel.org, rick.p.edgecombe@intel.com, Deepak Gupta , Samuel Holland , Andrew Jones , Conor Dooley X-Mailer: b4 0.14.0 X-Stat-Signature: bbmcpyy84ycqh9m49reuu1rdewaqwcwz X-Rspamd-Queue-Id: E7301A0026 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727798833-318225 X-HE-Meta: U2FsdGVkX19LJ+c72ganKN9dE+E37J9ObwDWQc/4HE6GcU55V31BBdr7o7ms+tMqUbmHaGExsPY+Pd6Q+64VGmxoXcGZ2qcbxWUq44xhI0XTGwRbTubPKlNdCWgeb5emiRJnp2n2b8vSB57YuZneoz+JUUGVO0lMo0s5dzgs1buEp8BpxRvMwrpH3xteV40vT7ELItsS0hBbIh1AJiI6BWYrPIYOswAjwdv9vyr2kKZZO2arm+SS0dpR9WLmGcjmLEKh3Pw6ocftiBhlqLTgPFM9S/d5kxr7W+PAGQ5Qfxkvu9Q0Qusp9/xrgxHgG5Hj5sudl+nVkGfrFW0AxQKpHgu4Bu/PrAEMJLg0DZ2McNR4oY9JUFRsafNla9epLfoBpYkrWCmVnVT/GyswB2TqLA7alyaCmwQ8g0gFtJ24OzVGg0ZJZG3xCJgsfu4jvusMYpLyKs2y5wkP0cMOLbUjuZPJhQ2VKXExd4KDT3XlSgfNwC6F4QAg3USCVPY1IhIBay20RhknPXY0iHK/ljhxaLFJOGxHejUo688SqHlev47XksNd3RF/7KALQf7YyNofjdQsAPbMGqoVcMTkQiGepEyEfVDzWAVULuMerLKNqELCVR91HWpwrJp3+mvT4Pn9WgHsS1A8tBc7YRe7ziEte/NI5EJpaflb0mPzxa6Y4JQOtaYBOb9uXl5nFotSo6W9SHko2EotNHDB0hd5tFoK0olK0jRCib8cEsg+XfIDVOMrrBovn2ggUjiLmmV2U5/SRUf1eDa0/W7RmGaOjGpNNxDFClOOO9cMYbWNTfmH1AuYDECQh+0H51mm3pW7O8y4NNUc28hP8fNKLtufTiSAW/qSvWZMn37IOEShJHs/dQJ9RyExaPmT0LFXFGWWpx0Tn4ON/18pkPBPGuLbAMuOL2pEE8bmnF1VWzWnPNVsLIKaOprUkGnT4iuX3IrIo2uhoPO2Lr66jjoHHqiwSuf Hth/9nIb /93rRe/NNgzg5vaIYNuFZvO3ECut6vIE8h3qOH+B5FTWC69CNzPh0qcIc5DZRIJHvZPTAKP9xPXbBBhXT1Si2TPi3wkiosy+Sm5u2rwxMaw5UNO1jVAnfK6rNt+u8IziTEZtW7ItWCHT67z1IxnReMJXvPfo6rGqVLixXykTc/TQ1nrhbOZkmBRSZxoNu0kOHxV6uyeEauUkQZxxpEJFU5d0bVXAVjO8wjxFCD8HDluxS7h0jRqqoN3SDzRZwOm6UV4lS9tgSL7/vsLsGFSIZ7HDVF1z6NkTYNaC2oTgu4K3/BEEJYfvhqSbK3NNxLS1Mkd9o/suTRfDGKiVGA9wAGHtKru3dawr2Ef3pw8UxEqbbQbQXqPCW/vGZ6SUboOeDqEAPiPndmScs0/zWlnAk3qCVMsYhZmBoI7LlpeSEA/kHFJtauyKtZaSs45eR44xWk6RwJI/2VU33is7lSUFF/u9EjcFskjNZPUEEje0/aqNCySLrmjc0VLblDovTqT5bmWl32KxRDTEa9jMKyL83tdhC5zm8bXdCXtk5zVm9giqySuFFkMshNW7pXVMpn+469jcFqUERFkJd6izn40nK/VGmf/2PXgww9cikZOI6hex8RLK3FcmGptXzuLAEYs3JdNUoWvGug92MQRcx7n1rmY/2EMCWx98sYfKNTBnoCrOaBQDaqOE2hQJawg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Samuel Holland Now that the [ms]envcfg CSR value is maintained per thread, not per hart, riscv_user_isa_enable() only needs to be called once during boot, to set the value for the init task. This also allows it to be marked as __init. Reviewed-by: Andrew Jones Reviewed-by: Conor Dooley Reviewed-by: Deepak Gupta Signed-off-by: Samuel Holland --- arch/riscv/include/asm/cpufeature.h | 2 +- arch/riscv/kernel/cpufeature.c | 4 ++-- arch/riscv/kernel/smpboot.c | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm/cpufeature.h index 45f9c1171a48..ce9a995730c1 100644 --- a/arch/riscv/include/asm/cpufeature.h +++ b/arch/riscv/include/asm/cpufeature.h @@ -31,7 +31,7 @@ DECLARE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo); /* Per-cpu ISA extensions. */ extern struct riscv_isainfo hart_isa[NR_CPUS]; -void riscv_user_isa_enable(void); +void __init riscv_user_isa_enable(void); #define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, _validate) { \ .name = #_name, \ diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index c0986291696a..7117366d80db 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -920,12 +920,12 @@ unsigned long riscv_get_elf_hwcap(void) return hwcap; } -void riscv_user_isa_enable(void) +void __init riscv_user_isa_enable(void) { if (riscv_has_extension_unlikely(RISCV_ISA_EXT_ZICBOZ)) current->thread_info.envcfg |= ENVCFG_CBZE; else if (any_cpu_has_zicboz) - pr_warn_once("Zicboz disabled as it is unavailable on some harts\n"); + pr_warn("Zicboz disabled as it is unavailable on some harts\n"); } #ifdef CONFIG_RISCV_ALTERNATIVE diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 0f8f1c95ac38..e36d20205bd7 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -233,8 +233,6 @@ asmlinkage __visible void smp_callin(void) numa_add_cpu(curr_cpuid); set_cpu_online(curr_cpuid, true); - riscv_user_isa_enable(); - /* * Remote cache and TLB flushes are ignored while the CPU is offline, * so flush them both right now just in case.