riscv: Add a getter for user PMLEN support

Querying whether a given user PMLEN is supported is needed for
RVA23U64 base detection from outside arch/riscv/kernel/process.c.
Add riscv_have_user_pmlen() to expose this.

Link: https://lore.kernel.org/linux-riscv/rfuwa7a3ebe76udmnwyrssjy7shkkgxntvhwzn6oquysj4tuyp@xzvpylcfhz53/
Signed-off-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
[Guodong: replace exported booleans with getter per Andrew's suggestion]
Signed-off-by: Guodong Xu <guodong.xu@oss.qualcomm.com>
Link: https://patch.msgid.link/20260920-rva23u64-hwprobe-v2-v8-8-5f14bc5c23d3@oss.qualcomm.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
This commit is contained in:
Andrew Jones 2026-09-20 03:18:28 -04:00 committed by Paul Walmsley
parent ca0c312bdf
commit 55458c7347
2 changed files with 16 additions and 0 deletions

View File

@ -226,6 +226,10 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg);
long get_tagged_addr_ctrl(struct task_struct *task);
#define SET_TAGGED_ADDR_CTRL(arg) set_tagged_addr_ctrl(current, arg)
#define GET_TAGGED_ADDR_CTRL() get_tagged_addr_ctrl(current)
bool riscv_have_user_pmlen(u8 len);
#else
static inline bool riscv_have_user_pmlen(u8 len) { return false; }
#endif
#endif /* __ASSEMBLER__ */

View File

@ -302,6 +302,18 @@ enum {
static bool have_user_pmlen_7;
static bool have_user_pmlen_16;
bool riscv_have_user_pmlen(u8 len)
{
switch (len) {
case PMLEN_7:
return have_user_pmlen_7;
case PMLEN_16:
return have_user_pmlen_16;
default:
return false;
}
}
/*
* Control the relaxed ABI allowing tagged user addresses into the kernel.
*/