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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <207733c7c25e4e09b0774eb21322e7e5@AcuMS.aculab.com>
Date: Sun, 29 Sep 2024 21:16:49 +0000
From: David Laight <David.Laight@...LAB.COM>
To: "'marius.cristea@...rochip.com'" <marius.cristea@...rochip.com>,
	"arnd@...db.de" <arnd@...db.de>
CC: "linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v1] asm-generic: introduce be56 unaligned accessors

From: marius.cristea@...rochip.com
> Sent: 27 September 2024 09:36
> 
> The PAC194X, IIO driver, is using some unaligned 56 bit registers.
> Provide some helper accessors in preparation for the new driver.

Someone please shoot the hardware engineer ;-)

Do separate unaligned access of the first 4 bytes and last four bytes.
It can't matter if the middle byte is accessed twice.

Or, for reads read 8 bytes from 'p & ~1ul' and then fixup
the value.

	David

> 
> Signed-off-by: Marius Cristea <marius.cristea@...rochip.com>
> ---
>  include/asm-generic/unaligned.h | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h
> index a84c64e5f11e..d171a9f2377a 100644
> --- a/include/asm-generic/unaligned.h
> +++ b/include/asm-generic/unaligned.h
> @@ -152,4 +152,31 @@ static inline u64 get_unaligned_be48(const void *p)
>  	return __get_unaligned_be48(p);
>  }
> 
> +static inline void __put_unaligned_be56(const u64 val, u8 *p)
> +{
> +	*p++ = (val >> 48) & 0xff;
> +	*p++ = (val >> 40) & 0xff;
> +	*p++ = (val >> 32) & 0xff;
> +	*p++ = (val >> 24) & 0xff;
> +	*p++ = (val >> 16) & 0xff;
> +	*p++ = (val >> 8) & 0xff;
> +	*p++ = val & 0xff;
> +}
> +
> +static inline void put_unaligned_be56(const u64 val, void *p)
> +{
> +	__put_unaligned_be56(val, p);
> +}
> +
> +static inline u64 __get_unaligned_be56(const u8 *p)
> +{
> +	return (u64)p[0] << 48 | (u64)p[1] << 40 | (u64)p[2] << 32 |
> +		(u64)p[3] << 24 | p[4] << 16 | p[5] << 8 | p[6];
> +}
> +
> +static inline u64 get_unaligned_be56(const void *p)
> +{
> +	return __get_unaligned_be56(p);
> +}
> +
>  #endif /* __ASM_GENERIC_UNALIGNED_H */
> 
> base-commit: b82c1d235a30622177ce10dcb94dfd691a49922f
> --
> 2.43.0
> 

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ