Thread (21 messages) 21 messages, 5 authors, 2024-08-29

Re: [PATCH 2/4] random: vDSO: Don't use PAGE_SIZE and PAGE_MASK

From: Christophe Leroy <hidden>
Date: 2024-08-27 08:16:30
Also in: linux-arch, lkml


Le 27/08/2024 à 09:49, Jason A. Donenfeld a écrit :
On Tue, Aug 27, 2024 at 09:31:48AM +0200, Christophe Leroy wrote:
quoted
-	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.
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help