[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ccaac82f-0c43-491e-ab8a-1da8bf8c7477@csgroup.eu>
Date: Fri, 6 Sep 2024 20:40:49 +0200
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Arnd Bergmann <arnd@...db.de>,
Vincenzo Frascino <vincenzo.frascino@....com>, linux-kernel@...r.kernel.org,
Linux-Arch <linux-arch@...r.kernel.org>, linux-mm@...ck.org
Cc: Andy Lutomirski <luto@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
"Jason A . Donenfeld" <Jason@...c4.com>,
Michael Ellerman <mpe@...erman.id.au>, Nicholas Piggin <npiggin@...il.com>,
Naveen N Rao <naveen@...nel.org>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>, Theodore Ts'o <tytso@....edu>,
Andrew Morton <akpm@...ux-foundation.org>,
Steven Rostedt <rostedt@...dmis.org>, Masami Hiramatsu
<mhiramat@...nel.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Subject: Re: [PATCH 3/9] x86: vdso: Introduce asm/vdso/page.h
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
Powered by blists - more mailing lists