[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250723231403.6ef5c162@pumpkin>
Date: Wed, 23 Jul 2025 23:14:03 +0100
From: David Laight <david.laight.linux@...il.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, kernel test robot <lkp@...el.com>,
Eric Biggers <ebiggers@...gle.com>, Yuzhuo Jing <yuzhuo@...gle.com>, Andy
Lutomirski <luto@...nel.org>, Vincenzo Frascino
<vincenzo.frascino@....com>, Arnaldo Carvalho de Melo <acme@...hat.com>, Al
Viro <viro@...iv.linux.org.uk>, Christophe Leroy
<christophe.leroy@...roup.eu>, "Jason A. Donenfeld" <Jason@...c4.com>,
linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev
Subject: Re: [PATCH v3 1/3] vdso: Switch get/put unaligned from packed
struct to memcpy
On Tue, 22 Jul 2025 10:00:51 -0700
Ian Rogers <irogers@...gle.com> wrote:
...
> Oh, the actual warning is "leaves the object uninitialized". It is
> possible to silence this by changing:
>
> const U16 __get_unaligned_ctrl_type __always_unused;
>
> to something like:
>
> const U16 __get_unaligned_ctrl_type __always_unused = 0;
>
> You then get complained at that the code is using 0 instead of NULL
> when instead of U16 the type of the __get_unaligned_t is a pointer.
> Basically I've entered into an analysis tool wac-a-mole and I don't
> have a combination to make them all happy.
Can you embed the variable inside a struct and then initialise with {} ?
Does this code actually work all the time?
There have always been 'problems' because gcc remembers the alignment
of pointers through (void *) casts.
So if your misaligned pointer has a type that should be aligned
them memcpy(&dest, (void *)misaligned_int_ptr, 4) will still do an
aligned read.
You also really need the compiler to optimise the memcpy into two
memory reads, some shifts, masks and ors, and a single write to a
register.
I'm not at all sure that is going to happen.
(Especially since I've never seen it optimised to only two reads
even when reading 'packed' variables.
David
>
> Thanks,
> Ian
>
Powered by blists - more mailing lists