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: <2b7ca78e-18f8-41bf-979d-8d502f6f8fe1@quicinc.com>
Date: Wed, 23 Apr 2025 21:15:37 +0800
From: Jie Luo <quic_luoj@...cinc.com>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
CC: Yury Norov <yury.norov@...il.com>,
        Rasmus Villemoes
	<linux@...musvillemoes.dk>,
        Julia Lawall <Julia.Lawall@...ia.fr>,
        "Nicolas
 Palix" <nicolas.palix@...g.fr>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>, Marc Zyngier <maz@...nel.org>,
        Oliver Upton
	<oliver.upton@...ux.dev>,
        Joey Gouly <joey.gouly@....com>,
        Suzuki K Poulose
	<suzuki.poulose@....com>,
        Zenghui Yu <yuzenghui@...wei.com>, <linux-kernel@...r.kernel.org>,
        <cocci@...ia.fr>, <linux-arm-kernel@...ts.infradead.org>,
        <kvmarm@...ts.linux.dev>, <andrew@...n.ch>,
        <quic_kkumarcs@...cinc.com>, <quic_linchen@...cinc.com>,
        <quic_leiwei@...cinc.com>, <quic_suruchia@...cinc.com>,
        <quic_pavir@...cinc.com>
Subject: Re: [PATCH v3 3/6] arm64: tlb: Convert the opencoded field modify



On 4/18/2025 2:11 AM, Russell King (Oracle) wrote:
> On Thu, Apr 17, 2025 at 06:47:10PM +0800, Luo Jie wrote:
>> Replaced below code with the wrapper FIELD_MODIFY(MASK, &reg, val)
>> - reg &= ~MASK;
>> - reg |= FIELD_PREP(MASK, val);
>> The semantic patch that makes this change is available
>> in scripts/coccinelle/misc/field_modify.cocci.
>>
>> More information about semantic patching is available at
>> https://coccinelle.gitlabpages.inria.fr/website
>>
>> Signed-off-by: Luo Jie <quic_luoj@...cinc.com>
>> ---
>>   arch/arm64/include/asm/tlbflush.h | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
>> index eba1a98657f1..0d250ef4161c 100644
>> --- a/arch/arm64/include/asm/tlbflush.h
>> +++ b/arch/arm64/include/asm/tlbflush.h
>> @@ -112,8 +112,7 @@ static inline unsigned long get_trans_granule(void)
>>   	    level >= 0 && level <= 3) {					\
>>   		u64 ttl = level & 3;					\
>>   		ttl |= get_trans_granule() << 2;			\
>> -		arg &= ~TLBI_TTL_MASK;					\
>> -		arg |= FIELD_PREP(TLBI_TTL_MASK, ttl);			\
>> +		FIELD_MODIFY(TLBI_TTL_MASK, &arg, ttl);			\
> 
> This could equally be:
> 		arg = u64_replace_bits(arg, ttl, TLBI_TTL_MASK);
> 
> which already exists, so doesn't require a new macro to be introduced.
> 
Looks like the new macro FIELD_MODIFY() is accepted by Yury, maybe we
can keep to use FIELD_MODIFY() with this change for better readability?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ