2018-06-26 13:01:30

by LiuYang

[permalink] [raw]
Subject: [PATCH] KVM: VMX: modify macro definition 'R' to 'R ' because of gcc-5+

GCC 5.4.0 enables raw strings by default and they have higher priority
than macros, thus R is interpreted incorrectly.
Fix it by putting a space between macro R and a string literal.

Signed-off-by: LiuYang <[email protected]>
---
arch/x86/kvm/vmx.c | 54 +++++++++++++++++++++++++++---------------------------
1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index d48ec60..3e4ffaa 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4169,30 +4169,30 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)

asm(
/* Store host registers */
- "push %%"R"dx; push %%"R"bp;"
- "push %%"R"cx \n\t" /* placeholder for guest rcx */
- "push %%"R"cx \n\t"
- "cmp %%"R"sp, %c[host_rsp](%0) \n\t"
+ "push %%"R "dx; push %%"R "bp;"
+ "push %%"R "cx \n\t" /* placeholder for guest rcx */
+ "push %%"R "cx \n\t"
+ "cmp %%"R "sp, %c[host_rsp](%0) \n\t"
"je 1f \n\t"
- "mov %%"R"sp, %c[host_rsp](%0) \n\t"
+ "mov %%"R "sp, %c[host_rsp](%0) \n\t"
__ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t"
"1: \n\t"
/* Reload cr2 if changed */
- "mov %c[cr2](%0), %%"R"ax \n\t"
- "mov %%cr2, %%"R"dx \n\t"
- "cmp %%"R"ax, %%"R"dx \n\t"
+ "mov %c[cr2](%0), %%"R "ax \n\t"
+ "mov %%cr2, %%"R "dx \n\t"
+ "cmp %%"R "ax, %%"R "dx \n\t"
"je 2f \n\t"
- "mov %%"R"ax, %%cr2 \n\t"
+ "mov %%"R "ax, %%cr2 \n\t"
"2: \n\t"
/* Check if vmlaunch of vmresume is needed */
"cmpl $0, %c[launched](%0) \n\t"
/* Load guest registers. Don't clobber flags. */
- "mov %c[rax](%0), %%"R"ax \n\t"
- "mov %c[rbx](%0), %%"R"bx \n\t"
- "mov %c[rdx](%0), %%"R"dx \n\t"
- "mov %c[rsi](%0), %%"R"si \n\t"
- "mov %c[rdi](%0), %%"R"di \n\t"
- "mov %c[rbp](%0), %%"R"bp \n\t"
+ "mov %c[rax](%0), %%"R "ax \n\t"
+ "mov %c[rbx](%0), %%"R "bx \n\t"
+ "mov %c[rdx](%0), %%"R "dx \n\t"
+ "mov %c[rsi](%0), %%"R "si \n\t"
+ "mov %c[rdi](%0), %%"R "di \n\t"
+ "mov %c[rbp](%0), %%"R "bp \n\t"
#ifdef CONFIG_X86_64
"mov %c[r8](%0), %%r8 \n\t"
"mov %c[r9](%0), %%r9 \n\t"
@@ -4203,7 +4203,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
"mov %c[r14](%0), %%r14 \n\t"
"mov %c[r15](%0), %%r15 \n\t"
#endif
- "mov %c[rcx](%0), %%"R"cx \n\t" /* kills %0 (ecx) */
+ "mov %c[rcx](%0), %%"R "cx \n\t" /* kills %0 (ecx) */

/* Enter guest mode */
"jne .Llaunched \n\t"
@@ -4212,15 +4212,15 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t"
".Lkvm_vmx_return: "
/* Save guest registers, load host registers, keep flags */
- "mov %0, %c[wordsize](%%"R"sp) \n\t"
+ "mov %0, %c[wordsize](%%"R "sp) \n\t"
"pop %0 \n\t"
- "mov %%"R"ax, %c[rax](%0) \n\t"
- "mov %%"R"bx, %c[rbx](%0) \n\t"
+ "mov %%"R "ax, %c[rax](%0) \n\t"
+ "mov %%"R "bx, %c[rbx](%0) \n\t"
"pop"Q" %c[rcx](%0) \n\t"
- "mov %%"R"dx, %c[rdx](%0) \n\t"
- "mov %%"R"si, %c[rsi](%0) \n\t"
- "mov %%"R"di, %c[rdi](%0) \n\t"
- "mov %%"R"bp, %c[rbp](%0) \n\t"
+ "mov %%"R "dx, %c[rdx](%0) \n\t"
+ "mov %%"R "si, %c[rsi](%0) \n\t"
+ "mov %%"R "di, %c[rdi](%0) \n\t"
+ "mov %%"R "bp, %c[rbp](%0) \n\t"
#ifdef CONFIG_X86_64
"mov %%r8, %c[r8](%0) \n\t"
"mov %%r9, %c[r9](%0) \n\t"
@@ -4231,10 +4231,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
"mov %%r14, %c[r14](%0) \n\t"
"mov %%r15, %c[r15](%0) \n\t"
#endif
- "mov %%cr2, %%"R"ax \n\t"
- "mov %%"R"ax, %c[cr2](%0) \n\t"
+ "mov %%cr2, %%"R "ax \n\t"
+ "mov %%"R "ax, %c[cr2](%0) \n\t"

- "pop %%"R"bp; pop %%"R"dx \n\t"
+ "pop %%"R "bp; pop %%"R "dx \n\t"
"setbe %c[fail](%0) \n\t"
: : "c"(vmx), "d"((unsigned long)HOST_RSP),
[launched]"i"(offsetof(struct vcpu_vmx, launched)),
@@ -4260,7 +4260,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
[cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
[wordsize]"i"(sizeof(ulong))
: "cc", "memory"
- , R"ax", R"bx", R"di", R"si"
+ , R "ax", R "bx", R "di", R "si"
#ifdef CONFIG_X86_64
, "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
#endif
--
2.7.4



2018-06-27 13:03:35

by Radim Krčmář

[permalink] [raw]
Subject: Re: [PATCH] KVM: VMX: modify macro definition 'R' to 'R ' because of gcc-5+

2018-06-26 20:59+0800, LiuYang:
> GCC 5.4.0 enables raw strings by default and they have higher priority
> than macros, thus R is interpreted incorrectly.
> Fix it by putting a space between macro R and a string literal.
>
> Signed-off-by: LiuYang <[email protected]>
> ---

This got fixed in 2012 by b188c81f2e1a ("KVM: VMX: Make use of asm.h").

Please refresh the tree, thanks.