[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86: correct asm() constraints when dealing with immediate selector values
commit 026007376e9807da94930c38500acbd62605545b Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Tue Jun 28 17:00:29 2022 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Tue Jun 28 17:00:29 2022 +0200 x86: correct asm() constraints when dealing with immediate selector values asm() constraints need to fit both the intended insn(s) which the respective operands are going to be used with as well as the actual kind of value specified. "m" (alone) together with a constant, however, leads to gcc saying error: memory input <N> is not directly addressable while clang complains error: invalid lvalue in asm input for constraint 'm' And rightly so - in order to access a memory operand, an address needs to be specified to the insn. In some cases it might be possible for a compiler to synthesize a memory operand holding the requested constant, but I think any solution there would have sharp edges. If "m" alone doesn't work with constants, it is at best pointless (and perhaps misleading or even risky - the compiler might decide to actually pick "m" and not try very hard to find a suitable register) to specify it alongside "r". And indeed clang does, oddly enough despite its objection to "m" alone. Which means there the change also improves the generated code. While there also switch the two operand case to using named operands. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- xen/arch/x86/cpu/amd.c | 2 +- xen/arch/x86/x86_64/traps.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c index 94b9e31016..f1d11a1cb7 100644 --- a/xen/arch/x86/cpu/amd.c +++ b/xen/arch/x86/cpu/amd.c @@ -736,7 +736,7 @@ void __init detect_zen2_null_seg_behaviour(void) uint64_t base; wrmsrl(MSR_FS_BASE, 1); - asm volatile ( "mov %0, %%fs" :: "rm" (0) ); + asm volatile ( "mov %0, %%fs" :: "r" (0) ); rdmsrl(MSR_FS_BASE, base); if (base == 0) diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index 9d7f1f818b..f8cb8d9a94 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -274,7 +274,8 @@ void do_double_fault(struct cpu_user_regs *regs) console_force_unlock(); - asm ( "lsll %1, %0" : "=r" (cpu) : "rm" (PER_CPU_SELECTOR) ); + asm ( "lsll %[sel], %[limit]" : [limit] "=r" (cpu) + : [sel] "r" (PER_CPU_SELECTOR) ); /* Find information saved during fault and dump it to the console. */ printk("*** DOUBLE FAULT ***\n"); -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |