[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <55a7d3ba-b384-4fb0-8fbb-e05ddf0d1fb8@csgroup.eu>
Date: Tue, 27 Aug 2024 10:16:18 +0200
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: "Jason A. Donenfeld" <Jason@...c4.com>
Cc: Theodore Ts'o <tytso@....edu>, Arnd Bergmann <arnd@...db.de>,
Andy Lutomirski <luto@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Vincenzo Frascino <vincenzo.frascino@....com>, Ingo Molnar
<mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, linux-arch@...r.kernel.org
Subject: Re: [PATCH 2/4] random: vDSO: Don't use PAGE_SIZE and PAGE_MASK
Le 27/08/2024 à 09:49, Jason A. Donenfeld a écrit :
> On Tue, Aug 27, 2024 at 09:31:48AM +0200, Christophe Leroy wrote:
>> - ssize_t ret = min_t(size_t, INT_MAX & PAGE_MASK /* = MAX_RW_COUNT */, len);
>> + const unsigned long page_size = 1UL << CONFIG_PAGE_SHIFT;
>> + const unsigned long page_mask = ~(page_size - 1);
>> + ssize_t ret = min_t(size_t, INT_MAX & page_mask /* = MAX_RW_COUNT */, len);
>
> I'm really not a fan of making the code less idiomatic...
Ok, I have another idea, let's give it a try.
>
>> An easy solution would be to define PAGE_SIZE and PAGE_MASK in vDSO
>> when they do not exist already, but this can be misleading.
>
> Why would what tglx and I suggested be misleading? That seems pretty
> normal... Are you worried they might mismatch somehow? (If so, why?)
All architectures have their own definition, they are all based on
CONFIG_PAGE_SHIFT and should give the same value but with some
subtleties. The best would be to have an asm-generic definition of
PAGE_SIZE and PAGE_MASK that all architectures use, but that's another
level of work.
tglx or yourself suggested to put in a one of the vdso headers instead
of directly in getrandom.c. This is too fragile because PAGE_SIZE might
be absent in that header but arrive in getrandom.c through another header.
Christophe
Powered by blists - more mailing lists