* [PATCH] fix checking of cr0 validity
@ 2010-01-21 13:28 Gleb Natapov
2010-01-23 18:47 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2010-01-21 13:28 UTC (permalink / raw)
To: avi, mtosatti; +Cc: kvm, martignlo
Move to/from Control Registers chapter of Intel SDM says. "Reserved bits
in CR0 remain clear after any load of those registers; attempts to set
them have no impact". Control Register chapter says "Bits 63:32 of CR0 are
reserved and must be written with zeros. Writing a nonzero value to any
of the upper 32 bits results in a general-protection exception, #GP(0)."
This patch tries to implement this twisted logic.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Reported-by: Lorenzo Martignoni <martignlo@gmail.com>
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 47c6e23..1df691d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -430,12 +430,16 @@ void kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
{
cr0 |= X86_CR0_ET;
- if (cr0 & CR0_RESERVED_BITS) {
+#ifdef CONFIG_X86_64
+ if (cr0 & 0xffffffff00000000lu) {
printk(KERN_DEBUG "set_cr0: 0x%lx #GP, reserved bits 0x%lx\n",
cr0, kvm_read_cr0(vcpu));
kvm_inject_gp(vcpu, 0);
return;
}
+#endif
+
+ cr0 &= ~CR0_RESERVED_BITS;
if ((cr0 & X86_CR0_NW) && !(cr0 & X86_CR0_CD)) {
printk(KERN_DEBUG "set_cr0: #GP, CD == 0 && NW == 1\n");
--
Gleb.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fix checking of cr0 validity
2010-01-21 13:28 [PATCH] fix checking of cr0 validity Gleb Natapov
@ 2010-01-23 18:47 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2010-01-23 18:47 UTC (permalink / raw)
To: Gleb Natapov; +Cc: avi, kvm, martignlo
On Thu, Jan 21, 2010 at 03:28:46PM +0200, Gleb Natapov wrote:
> Move to/from Control Registers chapter of Intel SDM says. "Reserved bits
> in CR0 remain clear after any load of those registers; attempts to set
> them have no impact". Control Register chapter says "Bits 63:32 of CR0 are
> reserved and must be written with zeros. Writing a nonzero value to any
> of the upper 32 bits results in a general-protection exception, #GP(0)."
>
> This patch tries to implement this twisted logic.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> Reported-by: Lorenzo Martignoni <martignlo@gmail.com>
Applied, thanks. Changed "lu" to "UL".
Please use standard "KVM: .." subject lines.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-23 19:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-21 13:28 [PATCH] fix checking of cr0 validity Gleb Natapov
2010-01-23 18:47 ` Marcelo Tosatti
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.