kvm: vmx: Scrub hardware GPRs at VM-exit
PATCH 1/1 kvm: vmx: Scrub hardware GPRs at VM-exit
Guest GPR values are live in the hardware GPRs at VM-exit. Do not leave any guest values in hardware GPRs after the guest GPR values are saved to the vcpu_vmx structure.
This is a partial mitigation for CVE 2017-5715 and CVE 2017-5753. Specifically, it defeats the Project Zero PoC for CVE 2017-5715.
--- arch/x86/kvm/vmx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx.c +13 -1
@@ -9649,6 +9649,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)/* Save guest registers, load host registers, keep flags */ "mov %0, %c[wordsize](%%" _ASM_SP") \n\t" "pop %0 \n\t" +"setbe %c[fail](%0)\n\t" "mov %%" _ASM_AX", %c[rax](%0) \n\t" "mov %%" _ASM_BX", %c[rbx](%0) \n\t" __ASM_SIZE(pop) " %c[rcx](%0) \n\t"
@@ -9665,12 +9666,23 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)"mov %%r13, %c[r13](%0) \n\t" "mov %%r14, %c[r14](%0) \n\t" "mov %%r15, %c[r15](%0) \n\t" +"xor %%r8d, %%r8d \n\t" +"xor %%r9d, %%r9d \n\t" +"xor %%r10d, %%r10d \n\t" +"xor %%r11d, %%r11d \n\t" +"xor %%r12d, %%r12d \n\t" +"xor %%r13d, %%r13d \n\t" +"xor %%r14d, %%r14d \n\t" + "xor %%r15d, %%r15d \n\t"#endif "mov %%cr2, %%" _ASM_AX" \n\t" "mov %%" _ASM_AX", %c[cr2](%0) \n\t" +"xor %%eax, %%eax \n\t" +"xor %%ebx, %%ebx \n\t" +"xor %%esi, %%esi \n\t" +"xor %%edi, %%edi \n\t" "pop %%" _ASM_BP"; pop %%" _ASM_DX" \n\t" -"setbe %c[fail](%0) \n\t" ".pushsection .rodata \n\t" ".global vmx_return \n\t" "vmx_return: " _ASM_PTR" 2b \n\t"
Signature · 1 line
2.15.1.620.gb9897f4670-goog
Quoted 44 lines · Jim Mattson
Guest GPR values are live in the hardware GPRs at VM-exit. Do not leave any guest values in hardware GPRs after the guest GPR values are saved to the
vcpu_vmxstructure.This is a partial mitigation for CVE 2017-5715 and CVE 2017-5753. Specifically, it defeats the Project Zero PoC for CVE 2017-5715.
Suggested-by Eric Northup <[email protected]>Signed-off-by Jim Mattson <[email protected]>Reviewed-by Eric Northup <[email protected]>Reviewed-by Benjamin Serebrin <[email protected]>Reviewed-by Andrew Honig <[email protected]>--- arch/x86/kvm/vmx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)arch/x86/kvm/vmx.c +9
-0@@ -9649,6 +9649,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)/* Save guest registers, load host registers, keep flags */ "mov %0, %c[wordsize](%%" _ASM_SP") \n\t" "pop %0 \n\t" +"setbe %c[fail](%0)\n\t" "mov %%" _ASM_AX", %c[rax](%0) \n\t" "mov %%" _ASM_BX", %c[rbx](%0) \n\t" __ASM_SIZE(pop) " %c[rcx](%0) \n\t"@@ -9665,12 +9666,23 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)"mov %%r13, %c[r13](%0) \n\t" "mov %%r14, %c[r14](%0) \n\t" "mov %%r15, %c[r15](%0) \n\t" +"xor %%r8d, %%r8d \n\t" +"xor %%r9d, %%r9d \n\t" +"xor %%r10d, %%r10d \n\t" +"xor %%r11d, %%r11d \n\t" +"xor %%r12d, %%r12d \n\t" +"xor %%r13d, %%r13d \n\t" +"xor %%r14d, %%r14d \n\t" + "xor %%r15d, %%r15d \n\t"#endif "mov %%cr2, %%" _ASM_AX" \n\t" "mov %%" _ASM_AX", %c[cr2](%0) \n\t"
arch/x86/kvm/vmx.c static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) · line 9688
Quoted 10 lines
arch/x86/kvm/vmx.c +4
-1+"xor %%eax, %%eax \n\t" +"xor %%ebx, %%ebx \n\t" +"xor %%esi, %%esi \n\t" +"xor %%edi, %%edi \n\t" "pop %%" _ASM_BP"; pop %%" _ASM_DX" \n\t" -"setbe %c[fail](%0) \n\t" ".pushsection .rodata \n\t" ".global vmx_return \n\t" "vmx_return: " _ASM_PTR" 2b \n\t"
Shouldn't this be done on AMD as well, or is the answer "microcode update" there?
Jan
2018-01-07 11:40 GMT+01:00 Jan Kiszka <[email protected]>:
Quoted 59 lines · Jim Mattson
Quoted 44 lines
Guest GPR values are live in the hardware GPRs at VM-exit. Do not leave any guest values in hardware GPRs after the guest GPR values are saved to the
vcpu_vmxstructure.This is a partial mitigation for CVE 2017-5715 and CVE 2017-5753. Specifically, it defeats the Project Zero PoC for CVE 2017-5715.
Suggested-by Eric Northup <[email protected]>Signed-off-by Jim Mattson <[email protected]>Reviewed-by Eric Northup <[email protected]>Reviewed-by Benjamin Serebrin <[email protected]>Reviewed-by Andrew Honig <[email protected]>--- arch/x86/kvm/vmx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)arch/x86/kvm/vmx.c +9
-0@@ -9649,6 +9649,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)/* Save guest registers, load host registers, keep flags */ "mov %0, %c[wordsize](%%" _ASM_SP") \n\t" "pop %0 \n\t" +"setbe %c[fail](%0)\n\t" "mov %%" _ASM_AX", %c[rax](%0) \n\t" "mov %%" _ASM_BX", %c[rbx](%0) \n\t" __ASM_SIZE(pop) " %c[rcx](%0) \n\t"@@ -9665,12 +9666,23 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)"mov %%r13, %c[r13](%0) \n\t" "mov %%r14, %c[r14](%0) \n\t" "mov %%r15, %c[r15](%0) \n\t" +"xor %%r8d, %%r8d \n\t" +"xor %%r9d, %%r9d \n\t" +"xor %%r10d, %%r10d \n\t" +"xor %%r11d, %%r11d \n\t" +"xor %%r12d, %%r12d \n\t" +"xor %%r13d, %%r13d \n\t" +"xor %%r14d, %%r14d \n\t" + "xor %%r15d, %%r15d \n\t"#endif "mov %%cr2, %%" _ASM_AX" \n\t" "mov %%" _ASM_AX", %c[cr2](%0) \n\t" arch/x86/kvm/vmx.c static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) · line 9688
Quoted 10 lines
arch/x86/kvm/vmx.c +4
-1+"xor %%eax, %%eax \n\t" +"xor %%ebx, %%ebx \n\t" +"xor %%esi, %%esi \n\t" +"xor %%edi, %%edi \n\t" "pop %%" _ASM_BP"; pop %%" _ASM_DX" \n\t" -"setbe %c[fail](%0) \n\t" ".pushsection .rodata \n\t" ".global vmx_return \n\t" "vmx_return: " _ASM_PTR" 2b \n\t" Shouldn't this be done on AMD as well, or is the answer "microcode update" there?
Quoted 1 line
Jan
Paolo added it, already in linus tree Linux 4.15-rc7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cb5b30698fdc8f6b4646012e3acb4ddce430788
Jack
Quoted 60 lines · Jack Wang
2018-01-07 11:40 GMT+01:00 Jan Kiszka <[email protected]>:
Quoted 59 lines · Jim Mattson
Quoted 44 lines
Guest GPR values are live in the hardware GPRs at VM-exit. Do not leave any guest values in hardware GPRs after the guest GPR values are saved to the
vcpu_vmxstructure.This is a partial mitigation for CVE 2017-5715 and CVE 2017-5753. Specifically, it defeats the Project Zero PoC for CVE 2017-5715.
Suggested-by Eric Northup <[email protected]>Signed-off-by Jim Mattson <[email protected]>Reviewed-by Eric Northup <[email protected]>Reviewed-by Benjamin Serebrin <[email protected]>Reviewed-by Andrew Honig <[email protected]>--- arch/x86/kvm/vmx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)arch/x86/kvm/vmx.c +9
-0@@ -9649,6 +9649,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)/* Save guest registers, load host registers, keep flags */ "mov %0, %c[wordsize](%%" _ASM_SP") \n\t" "pop %0 \n\t" +"setbe %c[fail](%0)\n\t" "mov %%" _ASM_AX", %c[rax](%0) \n\t" "mov %%" _ASM_BX", %c[rbx](%0) \n\t" __ASM_SIZE(pop) " %c[rcx](%0) \n\t"@@ -9665,12 +9666,23 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)"mov %%r13, %c[r13](%0) \n\t" "mov %%r14, %c[r14](%0) \n\t" "mov %%r15, %c[r15](%0) \n\t" +"xor %%r8d, %%r8d \n\t" +"xor %%r9d, %%r9d \n\t" +"xor %%r10d, %%r10d \n\t" +"xor %%r11d, %%r11d \n\t" +"xor %%r12d, %%r12d \n\t" +"xor %%r13d, %%r13d \n\t" +"xor %%r14d, %%r14d \n\t" + "xor %%r15d, %%r15d \n\t"#endif "mov %%cr2, %%" _ASM_AX" \n\t" "mov %%" _ASM_AX", %c[cr2](%0) \n\t" arch/x86/kvm/vmx.c static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) · line 9688
Quoted 10 lines
arch/x86/kvm/vmx.c +4
-1+"xor %%eax, %%eax \n\t" +"xor %%ebx, %%ebx \n\t" +"xor %%esi, %%esi \n\t" +"xor %%edi, %%edi \n\t" "pop %%" _ASM_BP"; pop %%" _ASM_DX" \n\t" -"setbe %c[fail](%0) \n\t" ".pushsection .rodata \n\t" ".global vmx_return \n\t" "vmx_return: " _ASM_PTR" 2b \n\t" Shouldn't this be done on AMD as well, or is the answer "microcode update" there?
Quoted 3 lines
Quoted 1 line
Jan
Paolo added it, already in linus tree Linux 4.15-rc7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cb5b30698fdc8f6b4646012e3acb4ddce430788
Thanks, I didn't noticed this.
Jan
Paolo Bonzini
maintainerQuoted 7 lines · Jan Kiszka
Quoted 6 lines
Quoted 4 lines
Shouldn't this be done on AMD as well, or is the answer "microcode update" there?
Jan
Paolo added it, already in linus tree Linux 4.15-rc7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cb5b30698fdc8f6b4646012e3acb4ddce430788Thanks, I didn't noticed this.
Yeah, they were posted in a separate thread. (Actually Ashok Raj's patch was mine, :) but I went with Jim's VMX part and attribution because he actually tested it with Google's reproducer).
Paolo
2018-01-08 15:53 GMT+01:00 Paolo Bonzini <[email protected]>:
Quoted 7 lines · Jan Kiszka
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Shouldn't this be done on AMD as well, or is the answer "microcode update" there?
Jan
Paolo added it, already in linus tree Linux 4.15-rc7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cb5b30698fdc8f6b4646012e3acb4ddce430788
Quoted 7 lines
Quoted 1 line
Thanks, I didn't noticed this.
Yeah, they were posted in a separate thread. (Actually Ashok Raj's patch was mine, :) but I went with Jim's VMX part and attribution because he actually tested it with Google's reproducer).
Paolo
Thanks Paolo, should we mark it for stable as this bug is so well known, the change seems easy to backport?
Thanks,
Jack
Paolo Bonzini
maintainerQuoted 10 lines · Jack Wang
2018-01-08 15:53 GMT+01:00 Paolo Bonzini <[email protected]>:
Quoted 9 lines · Jan Kiszka
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Shouldn't this be done on AMD as well, or is the answer "microcode update" there?
Jan
Paolo added it, already in linus tree Linux 4.15-rc7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cb5b30698fdc8f6b4646012e3acb4ddce430788Thanks, I didn't noticed this.
Quoted 7 lines
Quoted 5 lines
Yeah, they were posted in a separate thread. (Actually Ashok Raj's patch was mine, :) but I went with Jim's VMX part and attribution because he actually tested it with Google's reproducer).
Paolo
Thanks Paolo, should we mark it for stable as this bug is so well known, the change seems easy to backport?
Yes, I will mark it for stable.
Paolo
2018-01-09 9:43 GMT+01:00 Paolo Bonzini <[email protected]>:
Quoted 15 lines · Jack Wang
Quoted 14 lines
2018-01-08 15:53 GMT+01:00 Paolo Bonzini <[email protected]>:
Quoted 13 lines · Jan Kiszka
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Shouldn't this be done on AMD as well, or is the answer "microcode update" there?
Jan
Paolo added it, already in linus tree Linux 4.15-rc7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cb5b30698fdc8f6b4646012e3acb4ddce430788Thanks, I didn't noticed this.
Yeah, they were posted in a separate thread. (Actually Ashok Raj's patch was mine, :) but I went with Jim's VMX part and attribution because he actually tested it with Google's reproducer).
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Paolo
Thanks Paolo, should we mark it for stable as this bug is so well known, the change seems easy to backport?
Yes, I will mark it for stable.
Paolo
Thanks!
Jack
Cc chandu,
2018-01-08 22:53 GMT+08:00 Paolo Bonzini <[email protected]>:
Quoted 12 lines · Jan Kiszka
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Shouldn't this be done on AMD as well, or is the answer "microcode update" there?
Jan
Paolo added it, already in linus tree Linux 4.15-rc7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cb5b30698fdc8f6b4646012e3acb4ddce430788Thanks, I didn't noticed this.
Yeah, they were posted in a separate thread. (Actually Ashok Raj's patch was mine, :) but I went with Jim's VMX part and attribution because he actually tested it with Google's reproducer).
We cooperate with AMD guys to test the Scrub hardware GPRs against latest AMD EPYC, we observe the performance of Redis drop ~11% in the guest (Centos 7.4, 3.10.0-693).
redis(redis_version:3.2.10)
Redis command line:
redis-server > /dev/null 2>&1 &
redis-benchmark -t ping,set,get -d 128 -c 100 -r 1000000 -n 10000000 -q -P 20 redis-benchmark -t ping,set,get -d 1024 -c 100 -r 1000000 -n 10000000 -q -P 20 redis-benchmark -t ping,set,get -d 2048 -c 100 -r 1000000 -n 10000000 -q -P 20
Regards,
Wanpeng Li