lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhSdy018QJ2hdqL2BSZXV81-CVbTf_g6chJSHM4UH2EhLUpCA@mail.gmail.com>
Date:   Wed, 8 Sep 2021 14:05:18 +0530
From:   Anup Patel <anup@...infault.org>
To:     Vineet Gupta <vgupta@...nel.org>
Cc:     Paul Walmsley <paul.walmsley@...ive.com>,
        Palmer Dabbelt <palmer@...belt.com>,
        Albert Ou <aou@...s.berkeley.edu>,
        Anup Patel <anup.patel@....com>,
        Jisheng Zhang <jszhang@...nel.org>,
        Guo Ren <guoren@...ux.alibaba.com>,
        Kefeng Wang <wangkefeng.wang@...wei.com>,
        linux-riscv <linux-riscv@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org List" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] riscv: mm: don't advertise 1 num_asid for 0 asid bits

On Wed, Sep 8, 2021 at 1:33 AM Vineet Gupta <vgupta@...nel.org> wrote:
>
> Even if mmu doesn't support ASID, current code calculates @num_asids=1
> which is misleading, so avoid setting any asid related variables in such
> a case.
>
> Also while here, print the number of asid bits discovered even for the
> disabled case.
>
> Verified this on Hifive Unmatched.
>
> Signed-off-by: Vineet Gupta <vgupta@...nel.org>
> ---
>  arch/riscv/mm/context.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c
> index ee3459cb6750..c8c6f8831a3b 100644
> --- a/arch/riscv/mm/context.c
> +++ b/arch/riscv/mm/context.c
> @@ -233,8 +233,10 @@ static int __init asids_init(void)
>         local_flush_tlb_all();
>
>         /* Pre-compute ASID details */
> -       num_asids = 1 << asid_bits;
> -       asid_mask = num_asids - 1;
> +       if (asid_bits) {
> +               num_asids = 1 << asid_bits;
> +               asid_mask = num_asids - 1;
> +       }
>
>         /*
>          * Use ASID allocator only if number of HW ASIDs are
> @@ -255,7 +257,7 @@ static int __init asids_init(void)
>                 pr_info("ASID allocator using %lu bits (%lu entries)\n",
>                         asid_bits, num_asids);
>         } else {
> -               pr_info("ASID allocator disabled\n");
> +               pr_info("ASID allocator disabled: %lu bits\n", asid_bits);

May be use:

pr_info("ASID allocator disabled (%lu bits)\n", asid_bits);

for consistency with the ASID enabled case.

Otherwise, it looks good to me.

Reviewed-by: Anup Patel <anup@...infault.org>

>         }
>
>         return 0;
> --
> 2.30.2
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

Regards,
Anup

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ