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: <Z3cEGw0qFqj8peoQ@zaid-VirtualBox>
Date: Thu, 2 Jan 2025 13:24:43 -0800
From: Zaid Alali <zaidal@...amperecomputing.com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: rafael@...nel.org, lenb@...nel.org, james.morse@....com,
	tony.luck@...el.com, bp@...en8.de, robert.moore@...el.com,
	dan.j.williams@...el.com, Benjamin.Cheatham@....com,
	Avadhut.Naik@....com, viro@...iv.linux.org.uk, arnd@...db.de,
	ira.weiny@...el.com, dave.jiang@...el.com,
	sthanneeru.opensrc@...ron.com, linux-acpi@...r.kernel.org,
	linux-kernel@...r.kernel.org, acpica-devel@...ts.linux.dev
Subject: Re: [PATCH v2 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse
 warning

On Tue, Dec 24, 2024 at 03:28:55PM +0000, Jonathan Cameron wrote:
> On Thu,  5 Dec 2024 13:18:48 -0800
> Zaid Alali <zaidal@...amperecomputing.com> wrote:
> 
> > This patch fixes the kernel test robot warning reported here:
> > https://lore.kernel.org/all/202410241620.oApALow5-lkp@intel.com/
> > 
> > Signed-off-by: Zaid Alali <zaidal@...amperecomputing.com>
> > ---
> >  drivers/acpi/apei/einj-core.c | 41 +++++++++++++++++++++--------------
> >  1 file changed, 25 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> > index 04731a5b01fa..74dfb3daba50 100644
> > --- a/drivers/acpi/apei/einj-core.c
> > +++ b/drivers/acpi/apei/einj-core.c
> > @@ -215,20 +215,22 @@ static void check_vendor_extension(u64 paddr,
> >  {
> >  	int	offset = v5param->vendor_extension;
> >  	struct	vendor_error_type_extension *v;
> > +	void __iomem *p;
> >  	u32	sbdf;
> >  
> >  	if (!offset)
> >  		return;
> > -	v = acpi_os_map_iomem(paddr + offset, sizeof(*v));
> > -	if (!v)
> > +	p = acpi_os_map_iomem(paddr + offset, sizeof(*v));
> > +	if (!p)
> >  		return;
> > +	v = __io_virt(p);
> 
> That's a nasty forced cast. Far as I can tell all this code
> should not be assuming it can just cast away the __iomem
> 
> I think it should be fixed by using readl() etc or
> memcpy_fromio()
> 
> Maybe it is safe to just ignore the marking for all current ACPI
> platforms, I'm not sure.  This isn't a high performance path so
> personally I'd just do it the generic way even if it is not
> strictly necessary.
> 
> Jonathan
> 
Hi Jonathan,

Thank you for taking the time to review the patches!
These iomem warnings were there before the new patches, since the code has to
access iomem location for read/write to communicate with firmware.

I agree with you on ignoring the marking for ACPI platforms. I can also change
the code to use memcpy_fromio() to create local copies of iomem locations, and
write them back later instead. However, it will add a little more
complexity to the code, because iomem mapping and subsequent reads/writes
happen in different functions.

please let me know if you have any more thoughts on this.

Thanks,
Zaid Alali



> 
> 
> >  	get_oem_vendor_struct(paddr, offset, v);
> >  	sbdf = v->pcie_sbdf;
> >  	sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n",
> >  		sbdf >> 24, (sbdf >> 16) & 0xff,
> >  		(sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7,
> >  		 v->vendor_id, v->device_id, v->rev_id);
> > -	acpi_os_unmap_iomem(v, sizeof(*v));
> > +	acpi_os_unmap_iomem(p, sizeof(*v));
> >  }
> >  
> >  static void *einj_get_parameter_address(void)
> > @@ -253,9 +255,11 @@ static void *einj_get_parameter_address(void)
> >  	}
> >  	if (pa_v5) {
> >  		struct set_error_type_with_address *v5param;
> > +		void __iomem *p;
> >  
> > -		v5param = acpi_os_map_iomem(pa_v5, sizeof(*v5param));
> > -		if (v5param) {
> > +		p = acpi_os_map_iomem(pa_v5, sizeof(*v5param));
> > +		if (p) {
> > +			v5param = __io_virt(p);
> >  			acpi5 = 1;
> >  			check_vendor_extension(pa_v5, v5param);
> >  			return v5param;
> > @@ -263,12 +267,14 @@ static void *einj_get_parameter_address(void)
> >  	}
> >  	if (param_extension && pa_v4) {
> >  		struct einj_parameter *v4param;
> > +		void __iomem *p;
> >  
> > -		v4param = acpi_os_map_iomem(pa_v4, sizeof(*v4param));
> > -		if (!v4param)
> > +		p = acpi_os_map_iomem(pa_v4, sizeof(*v4param));
> > +		if (!p)
> >  			return NULL;
> > +		v4param = __io_virt(p);
> >  		if (v4param->reserved1 || v4param->reserved2) {
> > -			acpi_os_unmap_iomem(v4param, sizeof(*v4param));
> > +			acpi_os_unmap_iomem(p, sizeof(*v4param));
> >  			return NULL;
> >  		}
> >  		return v4param;
> > @@ -325,6 +331,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
> >  	u32 table_size;
> >  	int rc = -EIO;
> >  	struct acpi_generic_address *trigger_param_region = NULL;
> > +	void __iomem *p;
> >  
> >  	r = request_mem_region(trigger_paddr, sizeof(*trigger_tab),
> >  			       "APEI EINJ Trigger Table");
> > @@ -335,11 +342,12 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
> >  			    sizeof(*trigger_tab) - 1);
> >  		goto out;
> >  	}
> > -	trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab));
> > -	if (!trigger_tab) {
> > +	p = ioremap_cache(trigger_paddr, sizeof(*trigger_tab));
> > +	if (!p) {
> >  		pr_err("Failed to map trigger table!\n");
> >  		goto out_rel_header;
> >  	}
> > +	trigger_tab = __io_virt(p);
> >  	rc = einj_check_trigger_header(trigger_tab);
> >  	if (rc) {
> >  		pr_warn(FW_BUG "Invalid trigger error action table.\n");
> > @@ -361,12 +369,13 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
> >  		       (unsigned long long)trigger_paddr + table_size - 1);
> >  		goto out_rel_header;
> >  	}
> > -	iounmap(trigger_tab);
> > -	trigger_tab = ioremap_cache(trigger_paddr, table_size);
> > -	if (!trigger_tab) {
> > +	iounmap(p);
> > +	p = ioremap_cache(trigger_paddr, table_size);
> > +	if (!p) {
> >  		pr_err("Failed to map trigger table!\n");
> >  		goto out_rel_entry;
> >  	}
> > +	trigger_tab = __io_virt(p);
> >  	trigger_entry = (struct acpi_whea_header *)
> >  		((char *)trigger_tab + sizeof(struct acpi_einj_trigger));
> >  	apei_resources_init(&trigger_resources);
> > @@ -424,8 +433,8 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
> >  out_rel_header:
> >  	release_mem_region(trigger_paddr, sizeof(*trigger_tab));
> >  out:
> > -	if (trigger_tab)
> > -		iounmap(trigger_tab);
> > +	if (p)
> > +		iounmap(p);
> >  
> >  	return rc;
> >  }
> > @@ -860,7 +869,7 @@ static void __exit einj_remove(struct platform_device *pdev)
> >  			sizeof(struct set_error_type_with_address) :
> >  			sizeof(struct einj_parameter);
> >  
> > -		acpi_os_unmap_iomem(einj_param, size);
> > +		acpi_os_unmap_iomem((void __iomem *)einj_param, size);
> >  		if (vendor_errors.size)
> >  			acpi_os_unmap_memory(vendor_errors.data, vendor_errors.size);
> >  	}
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ