[bug report] ACPI: CPPC: Implement support for SystemIO registers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Steven Noonan,

The patch a2c8f92bea5f: "ACPI: CPPC: Implement support for SystemIO
registers" from Dec 24, 2021, leads to the following Smatch static
checker warning:

	drivers/acpi/cppc_acpi.c:935 cpc_read()
	warn: passing casted pointer 'val' to 'acpi_os_read_port()' 64 vs 32.

drivers/acpi/cppc_acpi.c
    916 static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val)
    917 {
    918         int ret_val = 0;
    919         void __iomem *vaddr = NULL;
    920         int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
    921         struct cpc_reg *reg = &reg_res->cpc_entry.reg;
    922 
    923         if (reg_res->type == ACPI_TYPE_INTEGER) {
    924                 *val = reg_res->cpc_entry.int_value;
    925                 return ret_val;
    926         }
    927 
    928         *val = 0;
    929 
    930         if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
    931                 u32 width = 8 << (reg->access_width - 1);
    932                 acpi_status status;
    933 
    934                 status = acpi_os_read_port((acpi_io_address)reg->address,
--> 935                                            (u32 *)val, width);
                                                   ^^^^^^^^^^
This code will not work on big endian systems.  You need to pass a real
&u32_tmp and then to *val = u32_tmp;

    936                 if (ACPI_FAILURE(status)) {
    937                         pr_debug("Error: Failed to read SystemIO port %llx\n",
    938                                  reg->address);
    939                         return -EFAULT;
    940                 }
    941 
    942                 return 0;
    943         } else if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0)
    944                 vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id);
    945         else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
    946                 vaddr = reg_res->sys_mem_vaddr;
    947         else if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE)
    948                 return cpc_read_ffh(cpu, reg, val);
    949         else
    950                 return acpi_os_read_memory((acpi_physical_address)reg->address,
    951                                 val, reg->bit_width);
    952 

regards,
dan carpenter



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux