[RFC PATCH v1 07/11] riscv: Export have_user_pmlen* booleans

Andrew Jones andrew.jones at oss.qualcomm.com
Tue Feb 24 15:32:40 PST 2026


On Sat, Feb 21, 2026 at 06:50:43PM +0800, Guodong Xu wrote:
> On Fri, Feb 6, 2026 at 8:24 AM Andrew Jones
> <andrew.jones at oss.qualcomm.com> wrote:
> >
> > A following patch will need to access have_user_pmlen_7 from
> > another file.
> 
> The variables are made non-static here but without an extern
> declaration in a header.
> 
> How about adding the declarations to asm/processor.h, inside the
> protection of the CONFIG_RISCV_ISA_SUPM block?

Yes, I guess asm/processor.h is a random enough collection of stuff that
have_user_pmlen_7 fits in there as well as anywhere else. Maybe I'll add
a getter function instead, though

 bool riscv_have_user_pmlen(u32 len)

Thanks,
drew

> 
> sys_hwprobe.c already includes asm/processor.h, so no new includes
> would be needed.
> 
> PS: I spotted one more of your patch [10/11] refers to it, which adds
> another bare extern in cpufeature.c.
> 
> BR,
> Guodong
> 
> 
> 
> >
> > Signed-off-by: Andrew Jones <andrew.jones at oss.qualcomm.com>
> > ---
> >  arch/riscv/kernel/process.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
> > index 31a392993cb4..4fa14aff7f8d 100644
> > --- a/arch/riscv/kernel/process.c
> > +++ b/arch/riscv/kernel/process.c
> > @@ -274,8 +274,8 @@ enum {
> >         PMLEN_16 = 16,
> >  };
> >
> > -static bool have_user_pmlen_7;
> > -static bool have_user_pmlen_16;
> > +bool riscv_have_user_pmlen_7;
> > +bool riscv_have_user_pmlen_16;
> >
> >  /*
> >   * Control the relaxed ABI allowing tagged user addresses into the kernel.
> > @@ -306,10 +306,10 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg)
> >         pmlen = FIELD_GET(PR_PMLEN_MASK, arg);
> >         if (pmlen == PMLEN_0) {
> >                 pmm = ENVCFG_PMM_PMLEN_0;
> > -       } else if (pmlen <= PMLEN_7 && have_user_pmlen_7) {
> > +       } else if (pmlen <= PMLEN_7 && riscv_have_user_pmlen_7) {
> >                 pmlen = PMLEN_7;
> >                 pmm = ENVCFG_PMM_PMLEN_7;
> > -       } else if (pmlen <= PMLEN_16 && have_user_pmlen_16) {
> > +       } else if (pmlen <= PMLEN_16 && riscv_have_user_pmlen_16) {
> >                 pmlen = PMLEN_16;
> >                 pmm = ENVCFG_PMM_PMLEN_16;
> >         } else {
> > @@ -407,8 +407,8 @@ static int __init tagged_addr_init(void)
> >          * Assume the supported PMLEN values are the same on all harts.
> >          */
> >         csr_clear(CSR_ENVCFG, ENVCFG_PMM);
> > -       have_user_pmlen_7 = try_to_set_pmm(ENVCFG_PMM_PMLEN_7);
> > -       have_user_pmlen_16 = try_to_set_pmm(ENVCFG_PMM_PMLEN_16);
> > +       riscv_have_user_pmlen_7 = try_to_set_pmm(ENVCFG_PMM_PMLEN_7);
> > +       riscv_have_user_pmlen_16 = try_to_set_pmm(ENVCFG_PMM_PMLEN_16);
> >
> >         if (!register_sysctl("abi", tagged_addr_sysctl_table))
> >                 return -EINVAL;
> > --
> > 2.43.0
> >



More information about the linux-riscv mailing list