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]
Date:   Thu, 16 Dec 2021 18:40:47 +0100
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Huang Rui <ray.huang@....com>
Cc:     "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        Shuah Khan <skhan@...uxfoundation.org>,
        Borislav Petkov <bp@...e.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        Giovanni Gherdovich <ggherdovich@...e.cz>,
        Linux PM <linux-pm@...r.kernel.org>,
        Deepak Sharma <deepak.sharma@....com>,
        Alex Deucher <alexander.deucher@....com>,
        Mario Limonciello <mario.limonciello@....com>,
        Steven Noonan <steven@...vesoftware.com>,
        Nathan Fontenot <nathan.fontenot@....com>,
        Jinzhou Su <Jinzhou.Su@....com>,
        Xiaojian Du <Xiaojian.Du@....com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        "the arch/x86 maintainers" <x86@...nel.org>
Subject: Re: [PATCH v5 03/22] ACPI: CPPC: implement support for SystemIO registers

On Tue, Nov 30, 2021 at 1:37 PM Huang Rui <ray.huang@....com> wrote:
>
> From: Steven Noonan <steven@...vesoftware.com>
>
> According to the ACPI v6.2 (and later) specification, SystemIO can be
> used for _CPC registers. This teaches cppc_acpi how to handle such
> registers.
>
> This patch was tested using the amd_pstate driver on my Zephyrus G15
> (model GA503QS) using the current version 410 BIOS, which uses
> a SystemIO register for the HighestPerformance element in _CPC.
>
> Signed-off-by: Steven Noonan <steven@...vesoftware.com>
> Signed-off-by: Huang Rui <ray.huang@....com>
> ---
>  drivers/acpi/cppc_acpi.c | 46 +++++++++++++++++++++++++++++++++++++---
>  1 file changed, 43 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index a85c351589be..ca62c3dc9899 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -746,9 +746,24 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
>                                                 goto out_free;
>                                         cpc_ptr->cpc_regs[i-2].sys_mem_vaddr = addr;
>                                 }
> +                       } else if (gas_t->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
> +                               if (gas_t->access_width < 1 || gas_t->access_width > 3) {
> +                                       /* 1 = 8-bit, 2 = 16-bit, and 3 = 32-bit. SystemIO doesn't

The comment format is not in agreement with the kernel coding style.

> +                                        * implement 64-bit registers.
> +                                        */
> +                                       pr_debug("Invalid access width %d for SystemIO register\n",
> +                                               gas_t->access_width);
> +                                       goto out_free;
> +                               }
> +                               if (gas_t->address & ~0xFFFFULL) {

It would be good to define a symbol for this mask and use it here
instead of the raw vaue.

> +                                       /* SystemIO registers use 16-bit integer addresses */
> +                                       pr_debug("Invalid IO port %llu for SystemIO register\n",
> +                                               gas_t->address);
> +                                       goto out_free;
> +                               }
>                         } else {
>                                 if (gas_t->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE || !cpc_ffh_supported()) {
> -                                       /* Support only PCC ,SYS MEM and FFH type regs */
> +                                       /* Support only PCC, SystemMemory, SystemIO, and FFH type regs. */
>                                         pr_debug("Unsupported register type: %d\n", gas_t->space_id);
>                                         goto out_free;
>                                 }
> @@ -923,7 +938,20 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val)
>         }
>
>         *val = 0;
> -       if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0)
> +
> +       if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
> +               u32 width = 8 << (reg->access_width - 1);
> +               acpi_status status;
> +
> +               status = acpi_os_read_port((acpi_io_address)reg->address, (u32 *)val, width);
> +
> +               if (status != AE_OK) {

Please use ACPI_FAILURE() here and in the analogous check and below.

> +                       pr_debug("Error: Failed to read SystemIO port %llx\n", reg->address);
> +                       return -EFAULT;
> +               }
> +
> +               return 0;
> +       } else if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0)
>                 vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id);
>         else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
>                 vaddr = reg_res->sys_mem_vaddr;
> @@ -962,7 +990,19 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
>         int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
>         struct cpc_reg *reg = &reg_res->cpc_entry.reg;
>
> -       if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0)
> +       if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
> +               u32 width = 8 << (reg->access_width - 1);
> +               acpi_status status;
> +
> +               status = acpi_os_write_port((acpi_io_address)reg->address, (u32)val, width);
> +
> +               if (status != AE_OK) {
> +                       pr_debug("Error: Failed to write SystemIO port %llx\n", reg->address);
> +                       return -EFAULT;
> +               }
> +
> +               return 0;
> +       } else if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0)
>                 vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id);
>         else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
>                 vaddr = reg_res->sys_mem_vaddr;
> --

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ