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: Tue, 26 Mar 2024 13:32:09 +0000
From: John Garry <john.g.garry@...cle.com>
To: Damien Le Moal <dlemoal@...nel.org>, Yihang Li <liyihang9@...wei.com>,
        yanaijie@...wei.com, jejb@...ux.ibm.com, martin.petersen@...cle.com,
        chenxiang66@...ilicon.com
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        linuxarm@...wei.com, prime.zeng@...wei.com, yangxingui@...wei.com
Subject: Re: [PATCH v2] scsi: libsas: Allocation SMP request is aligned to
 ARCH_DMA_MINALIGN

On 26/03/2024 13:14, Damien Le Moal wrote:
> On 3/26/24 21:43, Yihang Li wrote:
>> This series [1] reducing the kmalloc() minimum alignment on arm64 to 8
>> (from 128). In libsas, this will cause SMP requests to be 8-byte-aligned
>> through kmalloc() allocation. However, for the hisi_sas hardware, all
>> commands address must be 16-byte-aligned. 
> Otherwise, the commands fail to
>> be executed.
>>
>> ARCH_DMA_MINALIGN represents the minimum (static) alignment for safe DMA
>> operations, so use ARCH_DMA_MINALIGN as the alignment for SMP request.
>>
>> Link: https://lkml.kernel.org/r/20230612153201.554742-1-catalin.marinas@arm.com [1]
>> Signed-off-by: Yihang Li <liyihang9@...wei.com>
>> ---
>> Changes since v1:
>> - Directly modify alloc_smp_req() instead of using handler callback.
>> ---
>>   drivers/scsi/libsas/sas_expander.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
>> index a2204674b680..941abc7298df 100644
>> --- a/drivers/scsi/libsas/sas_expander.c
>> +++ b/drivers/scsi/libsas/sas_expander.c
>> @@ -135,7 +135,10 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size,
>>   
>>   static inline void *alloc_smp_req(int size)
>>   {
>> -	u8 *p = kzalloc(size, GFP_KERNEL);
>> +	u8 *p;
>> +
>> +	size = ALIGN(size, ARCH_DMA_MINALIGN);


If this is a hisi_sas requirement, then why use ARCH_DMA_MINALIGN and 
not 16B as minimum alignment?

Or are we really talking about an arch requirement?

>> +	p = kzalloc(size, GFP_KERNEL);
> 
> Nit: why not:
> 
> 	p = kzalloc(ALIGN(size, ARCH_DMA_MINALIGN), GFP_KERNEL);
> 
>>   	if (p)
>>   		p[0] = SMP_REQUEST;
>>   	return p;
> 
> Otherwise looks OK to me.
> 
> John,
> 
> Unrelated to this patch, but I wonder if the GFP_KERNEL used here shouldn't be
> GFP_NOIO... Is this ever called in the IO path or error recovery ?
> 

These should not be called in the IO path - as they are management 
functions. But I am quite confident that they can be called in SCSI 
error handling (for libsas).

Thanks,
John

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ