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: <CAAhV-H4qJROB+EXORsbc9Y0i_Myp543-3PmDsA=GQAtTu4v9Mw@mail.gmail.com>
Date:   Thu, 29 Sep 2022 16:31:37 +0800
From:   Huacai Chen <chenhuacai@...nel.org>
To:     Jianmin Lv <lvjianmin@...ngson.cn>
Cc:     WANG Xuerui <kernel@...0n.name>, linux-kernel@...r.kernel.org,
        loongarch@...ts.linux.dev
Subject: Re: [PATCH] LoongArch: Fix cpu name after s3/s4

Hi, Jianmin,

How about do it like this?

diff --git a/arch/loongarch/kernel/cpu-probe.c
b/arch/loongarch/kernel/cpu-probe.c
index 1bc9fec4e474..1734362d1fa9 100644
--- a/arch/loongarch/kernel/cpu-probe.c
+++ b/arch/loongarch/kernel/cpu-probe.c
@@ -265,7 +265,9 @@ static inline void cpu_probe_loongson(struct
cpuinfo_loongarch *c, unsigned int
        uint64_t *vendor = (void *)(&cpu_full_name[VENDOR_OFFSET]);
        uint64_t *cpuname = (void *)(&cpu_full_name[CPUNAME_OFFSET]);

-       __cpu_full_name[cpu] = cpu_full_name;
+       if (!__cpu_full_name[cpu])
+               __cpu_full_name[cpu] = cpu_full_name;
+
        *vendor = iocsr_read64(LOONGARCH_IOCSR_VENDOR);
        *cpuname = iocsr_read64(LOONGARCH_IOCSR_CPUNAME);

Huacai

On Thu, Sep 29, 2022 at 3:36 PM Jianmin Lv <lvjianmin@...ngson.cn> wrote:
>
> On coming back from s3/s4, the cpu name will be overwritten
> in cpu_probe path of seconary cpu, so we adjust the postion
> of using cpu name existed in cpu hardware register, and only
> use it while failing to get cpu name from SMBIOS.
>
> Signed-off-by: Jianmin Lv <lvjianmin@...ngson.cn>
>
> diff --git a/arch/loongarch/include/asm/cpu-info.h b/arch/loongarch/include/asm/cpu-info.h
> index b6c4f96079df..937dce2a930a 100644
> --- a/arch/loongarch/include/asm/cpu-info.h
> +++ b/arch/loongarch/include/asm/cpu-info.h
> @@ -64,6 +64,7 @@ extern void cpu_probe(void);
>
>  extern const char *__cpu_family[];
>  extern const char *__cpu_full_name[];
> +extern char cpu_full_name[];
>  #define cpu_family_string()    __cpu_family[raw_smp_processor_id()]
>  #define cpu_full_name_string() __cpu_full_name[raw_smp_processor_id()]
>
> diff --git a/arch/loongarch/kernel/cpu-probe.c b/arch/loongarch/kernel/cpu-probe.c
> index 529ab8f44ec6..a548b2197224 100644
> --- a/arch/loongarch/kernel/cpu-probe.c
> +++ b/arch/loongarch/kernel/cpu-probe.c
> @@ -180,14 +180,13 @@ static void cpu_probe_common(struct cpuinfo_loongarch *c)
>  #define VENDOR_OFFSET  0
>  #define CPUNAME_OFFSET 9
>
> -static char cpu_full_name[MAX_NAME_LEN] = "        -        ";
> +char cpu_full_name[MAX_NAME_LEN] = "        -        ";
>
>  static inline void cpu_probe_loongson(struct cpuinfo_loongarch *c, unsigned int cpu)
>  {
>         uint64_t *vendor = (void *)(&cpu_full_name[VENDOR_OFFSET]);
>         uint64_t *cpuname = (void *)(&cpu_full_name[CPUNAME_OFFSET]);
>
> -       __cpu_full_name[cpu] = cpu_full_name;
>         *vendor = iocsr_read64(LOONGARCH_IOCSR_VENDOR);
>         *cpuname = iocsr_read64(LOONGARCH_IOCSR_CPUNAME);
>
> diff --git a/arch/loongarch/kernel/env.c b/arch/loongarch/kernel/env.c
> index 82b478a5c665..955d82aa298e 100644
> --- a/arch/loongarch/kernel/env.c
> +++ b/arch/loongarch/kernel/env.c
> @@ -44,6 +44,9 @@ static int __init init_cpu_fullname(void)
>         if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) {
>                 for (cpu = 0; cpu < NR_CPUS; cpu++)
>                         __cpu_full_name[cpu] = loongson_sysconf.cpuname;
> +       } else {
> +               for (cpu = 0; cpu < NR_CPUS; cpu++)
> +                       __cpu_full_name[cpu] = cpu_full_name;
>         }
>         return 0;
>  }
> --
> 2.31.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ