]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86,kvm,vmx: Preserve CR4 across VM entry
authorAndy Lutomirski <luto@amacapital.net>
Wed, 8 Oct 2014 16:02:13 +0000 (09:02 -0700)
committerZefan Li <lizefan@huawei.com>
Mon, 2 Feb 2015 09:04:51 +0000 (17:04 +0800)
commit4e2c6422ab866ca9ea23714b32be9fbfad77743e
tree177a1b4275239a3651fe07dc6f4fd0c2f797d850
parent9e9aab5dbf6f13478cd996692ed9679af2404fc7
x86,kvm,vmx: Preserve CR4 across VM entry

commit d974baa398f34393db76be45f7d4d04fbdbb4a0a upstream.

CR4 isn't constant; at least the TSD and PCE bits can vary.

TBH, treating CR0 and CR3 as constant scares me a bit, too, but it looks
like it's correct.

This adds a branch and a read from cr4 to each vm entry.  Because it is
extremely likely that consecutive entries into the same vcpu will have
the same host cr4 value, this fixes up the vmcs instead of restoring cr4
after the fact.  A subsequent patch will add a kernel-wide cr4 shadow,
reducing the overhead in the common case to just two memory reads and a
branch.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Petr Matousek <pmatouse@redhat.com>
Cc: Gleb Natapov <gleb@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[lizf: Backported to 3.4:
 - adjust context
 - add parameter struct vcpu_vmx *vmx to vmx_set_constant_host_state()]
Signed-off-by: Zefan Li <lizefan@huawei.com>
arch/x86/kvm/vmx.c