diff --git a/patches.suse/x86-virt-mark-flags-and-memory-as-clobbered-by-vmxoff.patch b/patches.suse/x86-virt-mark-flags-and-memory-as-clobbered-by-vmxoff.patch new file mode 100644 index 0000000..c4a667b --- /dev/null +++ b/patches.suse/x86-virt-mark-flags-and-memory-as-clobbered-by-vmxoff.patch @@ -0,0 +1,52 @@ +From: "David P. Reed" +Date: Wed, 30 Dec 2020 16:26:56 -0800 +Subject: x86/virt: Mark flags and memory as clobbered by VMXOFF +Git-commit: 53666664a3052e4ea3ddcb183460dfbc30f1d056 +Patch-mainline: v5.12-rc1 +References: git-fixes + +Explicitly tell the compiler that VMXOFF modifies flags (like all VMX +instructions), and mark memory as clobbered since VMXOFF must not be +reordered and also may have memory side effects (though the kernel +really shouldn't be accessing the root VMCS anyways). + +Practically speaking, adding the clobbers is most likely a nop; the +primary motivation is to properly document VMXOFF's behavior. + +For the flags clobber, both Clang and GCC automatically mark flags as +clobbered; this is noted in commit 4b1e54786e48 ("KVM/x86: Use assembly +instruction mnemonics instead of .byte streams"), which intentionally +removed the previous clobber. But, neither Clang nor GCC documents +this behavior, and there's no downside to including the clobber. + +For the memory clobber, the RFLAGS.IF and CR4.VMXE manipulations that +immediately follow VMXOFF have compiler barriers of their own, i.e. +VMXOFF can't get reordered after clearing CR4.VMXE, which is really +what's of interest. + +Cc: Randy Dunlap +Signed-off-by: David P. Reed +[sean: rewrote changelog, dropped comment adjustments] +Signed-off-by: Sean Christopherson +Message-Id: <20201231002702.2223707-4-seanjc@google.com> +Signed-off-by: Paolo Bonzini +Acked-by: Nikolay Borisov +--- + arch/x86/include/asm/virtext.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h +index fda3e7747c22..2cc585467667 100644 +--- a/arch/x86/include/asm/virtext.h ++++ b/arch/x86/include/asm/virtext.h +@@ -44,7 +44,8 @@ static inline int cpu_has_vmx(void) + static inline void cpu_vmxoff(void) + { + asm_volatile_goto("1: vmxoff\n\t" +- _ASM_EXTABLE(1b, %l[fault]) :::: fault); ++ _ASM_EXTABLE(1b, %l[fault]) ++ ::: "cc", "memory" : fault); + fault: + cr4_clear_bits(X86_CR4_VMXE); + } + diff --git a/series.conf b/series.conf index 8bdc4dd..4783572 100644 --- a/series.conf +++ b/series.conf @@ -59737,6 +59737,7 @@ patches.suse/kvm-do-not-assume-pte-is-writable-after-follow_pfn.patch patches.suse/x86-virt-eat-faults-on-vmxoff-in-reboot-flows.patch patches.suse/x86-reboot-force-all-cpus-to-exit-vmx-root-if-vmx-is-supported.patch + patches.suse/x86-virt-mark-flags-and-memory-as-clobbered-by-vmxoff.patch patches.suse/kvm-use-kvm_pfn_t-for-local-pfn-variable-in-hva_to_p.patch patches.suse/media-v4l-ioctl-Fix-memory-leak-in-video_usercopy.patch patches.suse/media-vsp1-Fix-an-error-handling-path-in-the-probe-f.patch