On Sun, Jan 14, 2018 at 7:22 PM, Uros Bizjak <ubiz...@gmail.com> wrote: > On Sun, Jan 14, 2018 at 6:44 PM, Woodhouse, David <d...@amazon.co.uk> wrote: >> This won't make the list; I'll send a more coherent and less HTML-afflicted >> version later. >> >> The bare 'ax' naming made it painful to instantiate the external thunks for >> 32-bit and 64-bot code because we had to put the e/r back again inside the >> .irp reg ax bx... code. >> >> We could probably have lived with that but it would be painful to change now >> that Linux and Xen patches with the current ABI are all lined up. I >> appreciate they weren't in GCC yet so we get little sympathy but these are >> strange times and we had to move fast. >> >> I'd really like *not* to change it now. Having the thunk name actually >> include the name of the register it's using does seem nicer anyway... > > That's unfortunate... I suspect that in the future, one will need > #ifdef __x86_64__ around eventual calls to thunks from c code because > of this decision, since thunks for x86_64 target will have different > names than thunks for x86_32 target. I don't know if the (single?) > case of mixing 32 and 64 bit assembly in the highly specialized part > of the kernel really warrants this decision. Future programmers will > be grateful if kernel people can re-consider their choice in > not-yet-release ABI.
A quick look through latest x86/pti update [1] shows: +#ifdef CONFIG_X86_32 +#define INDIRECT_THUNK(reg) extern asmlinkage void __x86_indirect_thunk_e ## reg(void); +#else +#define INDIRECT_THUNK(reg) extern asmlinkage void __x86_indirect_thunk_r ## reg(void); +INDIRECT_THUNK(8) +INDIRECT_THUNK(9) +INDIRECT_THUNK(10) +INDIRECT_THUNK(11) +INDIRECT_THUNK(12) +INDIRECT_THUNK(13) +INDIRECT_THUNK(14) +INDIRECT_THUNK(15) +#endif +INDIRECT_THUNK(ax) +INDIRECT_THUNK(bx) +INDIRECT_THUNK(cx) +INDIRECT_THUNK(dx) +INDIRECT_THUNK(si) +INDIRECT_THUNK(di) +INDIRECT_THUNK(bp) +INDIRECT_THUNK(sp) and: +/* + * Despite being an assembler file we can't just use .irp here + * because __KSYM_DEPS__ only uses the C preprocessor and would + * only see one instance of "__x86_indirect_thunk_\reg" rather + * than one per register with the correct names. So we do it + * the simple and nasty way... + */ +#define EXPORT_THUNK(reg) EXPORT_SYMBOL(__x86_indirect_thunk_ ## reg) +#define GENERATE_THUNK(reg) THUNK reg ; EXPORT_THUNK(reg) + +GENERATE_THUNK(_ASM_AX) +GENERATE_THUNK(_ASM_BX) +GENERATE_THUNK(_ASM_CX) +GENERATE_THUNK(_ASM_DX) +GENERATE_THUNK(_ASM_SI) +GENERATE_THUNK(_ASM_DI) +GENERATE_THUNK(_ASM_BP) +GENERATE_THUNK(_ASM_SP) +#ifdef CONFIG_64BIT +GENERATE_THUNK(r8) +GENERATE_THUNK(r9) +GENERATE_THUNK(r10) +GENERATE_THUNK(r11) +GENERATE_THUNK(r12) +GENERATE_THUNK(r13) +GENERATE_THUNK(r14) +GENERATE_THUNK(r15) I have a feeling that using e.g. __x86_indirect_thunk_ax would be more convenient in both cases. [1] https://www.spinics.net/lists/kernel/msg2697606.html Uros.