Re: [PATCH 3/9] x86: vdso: Introduce asm/vdso/page.h

From: Christophe Leroy
Date: Sun Sep 08 2024 - 09:53:17 EST


Hi Arnd,

Le 06/09/2024 à 21:19, Arnd Bergmann a écrit :
On Fri, Sep 6, 2024, at 11:20, Vincenzo Frascino wrote:
On 04/09/2024 15:52, Arnd Bergmann wrote:
On Tue, Sep 3, 2024, at 15:14, Vincenzo Frascino wrote:
Looking at the definition of PAGE_SIZE and PAGE_MASK for each architecture they
all depend on CONFIG_PAGE_SHIFT but they are slightly different, e.g.:

x86:
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)

powerpc:
#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)

hence I left to the architecture the responsibility of redefining the constants
for the VSDO.

ASM_CONST() is a powerpc-specific macro that is defined the
same way as _AC(). We could probably just replace all ASM_CONST()
as a cleanup, but for this purpose, just remove the custom PAGE_SIZE
and PAGE_SHIFT macros. This can be a single patch fro all
architectures.


I'm not worried about _AC versus ASM_CONST, but I am by the 1UL versus 1.

The two functions below don't provide the same result:

#define PAGE_SIZE (1 << 12)
#define PAGE_MASK (~(PAGE_SIZE - 1))

unsigned long long f(unsigned long long x)
{
return x & PAGE_MASK;
}

#define PAGE_SIZE_2 (1UL << 12)
#define PAGE_MASK_2 (~(PAGE_SIZE_2 - 1))

unsigned long long g(unsigned long long x)
{
return x & PAGE_MASK_2;
}

00000000 <f>:
0: 54 84 00 26 clrrwi r4,r4,12
4: 4e 80 00 20 blr

00000008 <g>:
8: 54 84 00 26 clrrwi r4,r4,12
c: 38 60 00 00 li r3,0
10: 4e 80 00 20 blr


This can be a problem on 32 bits platforms with 64 bits phys_addr_t

Christophe