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] [day] [month] [year] [list]
Message-ID: <ab75a444-22a1-47f5-b3c0-253660395b5a@arm.com>
Date: Fri, 11 Apr 2025 17:28:50 +0100
From: Robin Murphy <robin.murphy@....com>
To: Arnd Bergmann <arnd@...db.de>, Arnd Bergmann <arnd@...nel.org>,
 Will Deacon <will@...nel.org>, Joerg Roedel <joro@...tes.org>
Cc: Mostafa Saleh <smostafa@...gle.com>, Jason Gunthorpe <jgg@...pe.ca>,
 Kevin Tian <kevin.tian@...el.com>, Rob Clark <robdclark@...omium.org>,
 linux-arm-kernel@...ts.infradead.org, iommu@...ts.linux.dev,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iommu/io-pgtable-arm: dynamically allocate selftest
 device struct

On 11/04/2025 2:44 pm, Arnd Bergmann wrote:
> On Fri, Apr 11, 2025, at 15:19, Robin Murphy wrote:
>> On 11/04/2025 1:54 pm, Arnd Bergmann wrote:
>>> @@ -1433,15 +1434,17 @@ static int __init arm_lpae_do_selftests(void)
>>>    	};
>>>    
>>>    	int i, j, k, pass = 0, fail = 0;
>>> -	struct device dev;
>>
>> Could we not simply make this static? Per the comment it's only here to
>> serve a NUMA node lookup buried deep in the pagetable allocator (TBH my
>> first thought was to just put an int on the stack and contrive a pointer
>> as the inverse of dev_to_node(), but I decided that would probably be
>> too contentious...)
> 
> A static device would work here, but that has other (small)
> downsides:
> 
>   - static devices are discouraged for any real purpose because
>     of the problematic lifetime rules. I think Greg would still
>     want to eliminate these entirely.
> 
>   - there is slightly more memory usage: the __init function
>     gets eliminated after boot, while a static allocation says
>     around. It could perhaps be made __initdata.
> 
>   - If we ever need anything beyond the NUMA node from it, the
>     dynamic allocation is probably close enough to make that
>     work.
> 
>>> +	struct platform_device *pdev;
>>>    	struct io_pgtable_cfg cfg = {
>>>    		.tlb = &dummy_tlb_ops,
>>>    		.coherent_walk = true,
>>> -		.iommu_dev = &dev,
>>>    	};
>>>    
>>> -	/* __arm_lpae_alloc_pages() merely needs dev_to_node() to work */
>>> -	set_dev_node(&dev, NUMA_NO_NODE);
>>> +	pdev = platform_device_alloc("io-pgtable-test", 0);
>>
>> Otherwise, this would seem to be another perfect case for the new
>> faux_device.
> 
> Good point, that is clearly better than platform_device in this
> case. Shall I send a new version with that?

Sure, I'm happy to consciously err on the side of caution and 
robustness, just making sure :)

Thanks,
Robin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ