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

Jason A. Donenfeld Jason at zx2c4.com
Tue Aug 27 17:49:58 AEST 2024


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...

> 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?) 

Jason


More information about the Linuxppc-dev mailing list