From patchwork Thu Jan 25 02:43:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 767867 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEF5263AE for ; Thu, 25 Jan 2024 02:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706150782; cv=none; b=K1cw6qwQE1AqDoIfNpqz/gfR56FbWNagjcHOLjccgyLTB+o6/J5pjN3jy7ODM/mj/KyHFi1ScxsoNcmjPg9OAPHaDFME1qPAAE35+lVLO4GEdgjUqjO7A9WSmHvy0hceYtcCaja9fc/qTuZEQvGrOa2puYekQ3KNzbBT1UagvQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706150782; c=relaxed/simple; bh=nWrOFZipsJqfNDePJcXhHHGoeze+P6BxU0hJsS9aP3A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Sl6oIFdu3gYWGAQyJvivYynZfC/tN70uQbEWL6AWl9w4Cfpsep0Z5EmIYEh5+12n40HSl6Gwc2ZLHNyaP/QplnYKbWfa4y1/mlXTEyYWjwN7UqJJ9pmkze9PMdITwtmeQWj835+mSJYDS4Axutv5EuQM7TygBoQPp1ar8re4rrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=QcC0FwF/; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="QcC0FwF/" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6da9c834646so6185669b3a.3 for ; Wed, 24 Jan 2024 18:46:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706150776; x=1706755576; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FKSVHKa3mRAgIIIeJXoSUXtw02GrlSmtx2NJveLUUYI=; b=QcC0FwF/GgpqSv4XD7W1c5vVrJ9FWV0GZCMWbXj6ZtPUbh01iytqWMZMkHUTM+cuaG +MseupCXmy+h1/JgzWkepJ9GOOtmiIkAvv6YdEC9DLEjB3uN78Yow9PeZkvbDza8c76b AZwIXHOsJHMK+1bzkjvYD7rqrWtHt43cJZ/42AmnSMe4+OeBOFfJA4dg2TLiHrC8MFBh mfLN7jueUz3lFUZSNrwwtgvBu0Ay26vvxRdYAox24OB3w8voN/jB+qcGUhOkFlC+yd2s VeZw4lyfPXK4Rbx863ND7Q4PChb25vNGcDxXo2sZYAl5AxUlAroMWriY2AWTHhncfLfY LMww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706150776; x=1706755576; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FKSVHKa3mRAgIIIeJXoSUXtw02GrlSmtx2NJveLUUYI=; b=n7/Es+lADT8vtcLOMsD7q3JT7npdLYKxURi17ejwU0/6f5eeQtHqGJc7BRgE6z7G8C N9CiDdUXpFmtKAwd6OJ+46PKKNqrrR+ClUQZzIsaMJZqix6pQkMIQCviTf6sIsPYMe3U Aa/ChrZex4XFCkgVUD+b13UyFUKyPwJZRvv7nrbyUwJXw3rxXuhx+VxhhgwkTxIBkrkL EqCA1VjyiSgG4UHn3rj9OG+ZzkwotEx8E5CidfpOs0f6lW0Q4exfFy+TsEn6YQBscVfj dv+8ZbELJs9XLFkonYQEINmgoXD5J0+jkEpZoWSLO4X3CAU49eJZYIQ/Qszx/MTwd6u3 DHrw== X-Gm-Message-State: AOJu0Yxu8l1RNlcmyRXr3P55rfEo4D9SiHGZZLVNlm3htSy0SxGOfBB0 4fu/A7ija5WAI6l2pvn3d5HbrQTt9EXVLUfNJS+FqSD+huPLk99yWeF81dGdljI= X-Google-Smtp-Source: AGHT+IFEoJ2DwLLEuPzE6jCj/HxXa/UjvOQsFM+DPmD0dDe4OQGS/TLv5NPp7Oaj0P2Retg/+xRAOw== X-Received: by 2002:a05:6a00:80d:b0:6dd:81dd:8635 with SMTP id m13-20020a056a00080d00b006dd81dd8635mr228374pfk.46.1706150775551; Wed, 24 Jan 2024 18:46:15 -0800 (PST) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id b20-20020aa78114000000b006dbd787aa8csm7826557pfi.67.2024.01.24.18.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 18:46:15 -0800 (PST) From: Deepak Gupta To: rick.p.edgecombe@intel.com, broonie@kernel.org, Szabolcs.Nagy@arm.com, kito.cheng@sifive.com, keescook@chromium.org Cc: Deepak Gupta , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Oleg Nesterov , Andrew Morton , Arnd Bergmann , Eric Biederman , Shuah Khan , Christian Brauner , Guo Ren , Sami Tolvanen , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Evan Green , Conor Dooley , Andrew Jones , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Xiao Wang , Anup Patel , Mayuresh Chitale , Greentime Hu , Heiko Stuebner , Jisheng Zhang , Kemeng Shi , Alexandre Ghiti , "Matthew Wilcox (Oracle)" , David Hildenbrand , Qinglin Pan , Charlie Jenkins , Andy Chiu , Baoquan He , Vincent Chen , Greg Ungerer , Sia Jee Heng , Ley Foon Tan , Haorong Lu , Costa Shulyupin , Yunhui Cui , Chen Jiahao , Russell Currey , Michael Ellerman , Benjamin Gray , Baruch Siach , Qing Zhang , Alejandro Colomar , Catalin Marinas , Florent Revest , Stefan Roesch , Joey Gouly , Josh Triplett , Ondrej Mosnacek , Miguel Ojeda , John Hubbard , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 01/28] riscv: abstract envcfg CSR Date: Wed, 24 Jan 2024 18:43:52 -0800 Message-ID: <20240125024611.1321941-1-debug@rivosinc.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch abstracts envcfg CSR in kernel (as is done for other homonyn CSRs). CSR_ENVCFG is used as alias for CSR_SENVCFG or CSR_MENVCFG depending on how kernel is compiled. Additionally it changes CBZE enabling to start using CSR_ENVCFG instead of CSR_SENVCFG. Signed-off-by: Deepak Gupta --- arch/riscv/include/asm/csr.h | 2 ++ arch/riscv/kernel/cpufeature.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 306a19a5509c..b3400517b0a9 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -415,6 +415,7 @@ # define CSR_STATUS CSR_MSTATUS # define CSR_IE CSR_MIE # define CSR_TVEC CSR_MTVEC +# define CSR_ENVCFG CSR_MENVCFG # define CSR_SCRATCH CSR_MSCRATCH # define CSR_EPC CSR_MEPC # define CSR_CAUSE CSR_MCAUSE @@ -439,6 +440,7 @@ # define CSR_STATUS CSR_SSTATUS # define CSR_IE CSR_SIE # define CSR_TVEC CSR_STVEC +# define CSR_ENVCFG CSR_SENVCFG # define CSR_SCRATCH CSR_SSCRATCH # define CSR_EPC CSR_SEPC # define CSR_CAUSE CSR_SCAUSE diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index b3785ffc1570..98623393fd1f 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -725,7 +725,7 @@ arch_initcall(check_unaligned_access_all_cpus); void riscv_user_isa_enable(void) { if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_ZICBOZ)) - csr_set(CSR_SENVCFG, ENVCFG_CBZE); + csr_set(CSR_ENVCFG, ENVCFG_CBZE); } #ifdef CONFIG_RISCV_ALTERNATIVE