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: <CAJZ5v0igyOYnqAWRVeC0JrsFSDaZAaia8SLnWi0LV2OS2z9-DQ@mail.gmail.com>
Date: Mon, 22 Apr 2024 20:56:55 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Peter Zijlstra <peterz@...radead.org>, linux-pm@...r.kernel.org, 
	loongarch@...ts.linux.dev, linux-acpi@...r.kernel.org, 
	linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-arm-kernel@...ts.infradead.org, kvmarm@...ts.linux.dev, x86@...nel.org, 
	Russell King <linux@...linux.org.uk>, "Rafael J . Wysocki" <rafael@...nel.org>, 
	Miguel Luis <miguel.luis@...cle.com>, James Morse <james.morse@....com>, 
	Salil Mehta <salil.mehta@...wei.com>, Jean-Philippe Brucker <jean-philippe@...aro.org>, 
	Catalin Marinas <catalin.marinas@....com>, Will Deacon <will@...nel.org>, 
	Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, linuxarm@...wei.com, justin.he@....com, 
	jianyong.wu@....com
Subject: Re: [PATCH v7 04/16] ACPI: processor: Move checks and availability of
 acpi_processor earlier

On Thu, Apr 18, 2024 at 3:56 PM Jonathan Cameron
<Jonathan.Cameron@...wei.com> wrote:
>
> Make the per_cpu(processors, cpu) entries available earlier so that
> they are available in arch_register_cpu() as ARM64 will need access
> to the acpi_handle to distinguish between acpi_processor_add()
> and earlier registration attempts (which will fail as _STA cannot
> be checked).
>
> Reorder the remove flow to clear this per_cpu() after
> arch_unregister_cpu() has completed, allowing it to be used in
> there as well.
>
> Note that on x86 for the CPU hotplug case, the pr->id prior to
> acpi_map_cpu() may be invalid. Thus the per_cpu() structures
> must be initialized after that call or after checking the ID
> is valid (not hotplug path).
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
> ---
> v7: Swap order with acpi_unmap_cpu() in acpi_processor_remove()
>     to keep it in reverse order of the setup path. (thanks Salil)
>     Fix an issue with placement of CONFIG_ACPI_HOTPLUG_CPU guards.
> v6: As per discussion in v5 thread, don't use the cpu->dev and
>     make this data available earlier by moving the assignment checks
>     int acpi_processor_get_info().
> ---
>  drivers/acpi/acpi_processor.c | 78 +++++++++++++++++++++--------------
>  1 file changed, 46 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
> index ba0a6f0ac841..ac7ddb30f10e 100644
> --- a/drivers/acpi/acpi_processor.c
> +++ b/drivers/acpi/acpi_processor.c
> @@ -183,8 +183,36 @@ static void __init acpi_pcc_cpufreq_init(void) {}
>  #endif /* CONFIG_X86 */
>
>  /* Initialization */
> +static DEFINE_PER_CPU(void *, processor_device_array);
> +
> +static void acpi_processor_set_per_cpu(struct acpi_processor *pr,
> +                                      struct acpi_device *device)
> +{
> +       BUG_ON(pr->id >= nr_cpu_ids);
> +       /*
> +        * Buggy BIOS check.
> +        * ACPI id of processors can be reported wrongly by the BIOS.
> +        * Don't trust it blindly
> +        */
> +       if (per_cpu(processor_device_array, pr->id) != NULL &&
> +           per_cpu(processor_device_array, pr->id) != device) {
> +               dev_warn(&device->dev,
> +                        "BIOS reported wrong ACPI id %d for the processor\n",
> +                        pr->id);
> +               /* Give up, but do not abort the namespace scan. */
> +               return;

In this case the caller should make acpi_pricessor_add() return 0, I
think, because otherwise it will attempt to acpi_bind_one() "pr" to
"device" which will confuse things.

So I would make this return false to indicate that.

Or just fold it into the caller and do the error handling there.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ