[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5821ce60ca08414382bf2f0702b7ffb5@AcuMS.aculab.com>
Date: Fri, 22 Oct 2021 19:27:06 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Peter Zijlstra' <peterz@...radead.org>,
"x86@...nel.org" <x86@...nel.org>,
"jpoimboe@...hat.com" <jpoimboe@...hat.com>,
"andrew.cooper3@...rix.com" <andrew.cooper3@...rix.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"alexei.starovoitov@...il.com" <alexei.starovoitov@...il.com>,
"ndesaulniers@...gle.com" <ndesaulniers@...gle.com>
Subject: RE: [PATCH v2 06/14] x86/asm: Fix register order
From: Peter Zijlstra
> Sent: 20 October 2021 11:45
>
> Ensure the register order is correct; this allows for easy translation
> between register number and trampoline and vice-versa.
There is an alternate cpp pattern that can be used to have the
same effect.
Possibly less error prone.
Stealing some text from 2 patches you'd have:
asm/GEN-for-each-reg.h would contain:
#define GEN_FOR_EACH_REG(GEN) \
GEN(rax) \
GEN(rcx) \
GEN(rdx) \
GEN(rbx) \
GEN(rsp) \
GEN(rbp) \
GEN(rsi) \
GEN(rdi) \
GEN(r8) \
GEN(r9) \
GEN(r10)
and the user would contain:
#include <asm/GEN-for-each-reg.h>
#define GEN(reg) \
extern asmlinkage void __x86_indirect_thunk_ ## reg (void);
GEN_FOR_EACH_REG(GEN)
#undef GEN
#define GEN(reg) \
extern asmlinkage void __x86_indirect_alt_call_ ## reg (void);
GEN_FOR_EACH_REG(GEN)
#undef GEN
It is probably possible to use ... and _VA_LIST_.
Something like:
#define GEN_FOR_EACH_REG(GEN, ...) \
GEN(rax, _VA_LIST_) \
...
#define GEN_THUNK(reg, thunk) \
extern asmlinkage void thunk ## reg (void);
GEN_FOR_EACH_REG(GEN_THUNK, __x86_indirect_thunk_)
GEN_FOR_EACH_REG(GEN_THUNK, __x86_indirect_alt_call_)
#undef GEN_THUNK
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists