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: <20210126135712.GA29956@willie-the-truck>
Date:   Tue, 26 Jan 2021 13:57:13 +0000
From:   Will Deacon <will@...nel.org>
To:     Jia He <justin.he@....com>
Cc:     Catalin Marinas <catalin.marinas@....com>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Anshuman Khandual <anshuman.khandual@....com>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Mark Rutland <mark.rutland@....com>,
        "Gustavo A. R. Silva" <gustavoars@...nel.org>,
        Richard Henderson <richard.henderson@...aro.org>,
        Dave Martin <Dave.Martin@....com>,
        Steven Price <steven.price@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Mike Rapoport <rppt@...nel.org>,
        Ard Biesheuvel <ardb@...nel.org>,
        Gavin Shan <gshan@...hat.com>,
        Kefeng Wang <wangkefeng.wang@...wei.com>,
        Mark Brown <broonie@...nel.org>, Marc Zyngier <maz@...nel.org>,
        Cristian Marussi <cristian.marussi@....com>
Subject: Re: [RFC PATCH 1/2] arm64/cpuinfo: Move init_cpu_features() ahead of
 setup.c::early_fixmap_init()

On Wed, Jan 13, 2021 at 09:40:46AM +0800, Jia He wrote:
> Move init_cpu_features() ahead of setup_arch()->early_fixmap_init(), which
> is the preparation work for checking the condition to assign
> arm64_use_ng_mappings as cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0).
> 
> Besides, jump_label_init() is also moved ahead because
> cpus_have_const_cap() depends on static key enable api.
> 
> Percpu helpers should be avoided in cpuinfo_store_boot_cpu() before percpu
> init at main.c::setup_per_cpu_areas()
> 
> Signed-off-by: Jia He <justin.he@....com>
> ---
>  arch/arm64/include/asm/cpu.h |  1 +
>  arch/arm64/kernel/cpuinfo.c  | 13 ++++++++++---
>  arch/arm64/kernel/setup.c    | 14 +++++++++-----
>  arch/arm64/kernel/smp.c      |  3 +--
>  4 files changed, 21 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h
> index 7faae6ff3ab4..59f36f5e3c04 100644
> --- a/arch/arm64/include/asm/cpu.h
> +++ b/arch/arm64/include/asm/cpu.h
> @@ -63,6 +63,7 @@ DECLARE_PER_CPU(struct cpuinfo_arm64, cpu_data);
>  
>  void cpuinfo_store_cpu(void);
>  void __init cpuinfo_store_boot_cpu(void);
> +void __init save_boot_cpuinfo_data(void);
>  
>  void __init init_cpu_features(struct cpuinfo_arm64 *info);
>  void update_cpu_features(int cpu, struct cpuinfo_arm64 *info,
> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> index 77605aec25fe..f8de5b8bae20 100644
> --- a/arch/arm64/kernel/cpuinfo.c
> +++ b/arch/arm64/kernel/cpuinfo.c
> @@ -413,9 +413,16 @@ void cpuinfo_store_cpu(void)
>  
>  void __init cpuinfo_store_boot_cpu(void)
>  {
> -	struct cpuinfo_arm64 *info = &per_cpu(cpu_data, 0);
> -	__cpuinfo_store_cpu(info);
> +	__cpuinfo_store_cpu(&boot_cpu_data);
>  
> -	boot_cpu_data = *info;
>  	init_cpu_features(&boot_cpu_data);
>  }
> +
> +void __init save_boot_cpuinfo_data(void)
> +{
> +	struct cpuinfo_arm64 *info;
> +
> +	set_my_cpu_offset(per_cpu_offset(smp_processor_id()));
> +	info = &per_cpu(cpu_data, 0);
> +	*info = boot_cpu_data;
> +}
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 1a57a76e1cc2..e078ab068f3b 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -297,16 +297,20 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)
>  	 */
>  	arm64_use_ng_mappings = kaslr_requires_kpti();
>  
> -	early_fixmap_init();
> -	early_ioremap_init();
> -
> -	setup_machine_fdt(__fdt_pointer);
> -
>  	/*
>  	 * Initialise the static keys early as they may be enabled by the
>  	 * cpufeature code and early parameters.
>  	 */
>  	jump_label_init();

I don't think your patch changes this, but afaict jump_label_init() uses
per-cpu variables via cpus_read_lock(), yet we don't initialise our offset
until later on. Any idea how that works?

Will

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ