mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 07/40] KVM: VMX: Make guest cr4 mask more conservative
Date: Wed, 10 Feb 2010 19:22:36 +0200	[thread overview]
Message-ID: <1265822589-11155-8-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1265822589-11155-1-git-send-email-avi@redhat.com>

Instead of specifying the bits which we want to trap on, specify the bits
which we allow the guest to change transparently.  This is safer wrt future
changes to cr4.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/vmx.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 284e905..755811a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -69,8 +69,10 @@ module_param(emulate_invalid_guest_state, bool, S_IRUGO);
 	(X86_CR0_WP | X86_CR0_NE | X86_CR0_TS | X86_CR0_MP)
 #define KVM_VM_CR0_ALWAYS_ON						\
 	(KVM_VM_CR0_ALWAYS_ON_UNRESTRICTED_GUEST | X86_CR0_PG | X86_CR0_PE)
-#define KVM_GUEST_CR4_MASK						\
-	(X86_CR4_VME | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE | X86_CR4_VMXE)
+#define KVM_CR4_GUEST_OWNED_BITS				      \
+	(X86_CR4_PVI | X86_CR4_DE | X86_CR4_PCE | X86_CR4_OSFXSR      \
+	 | X86_CR4_OSXMMEXCPT)
+
 #define KVM_PMODE_VM_CR4_ALWAYS_ON (X86_CR4_PAE | X86_CR4_VMXE)
 #define KVM_RMODE_VM_CR4_ALWAYS_ON (X86_CR4_VME | X86_CR4_PAE | X86_CR4_VMXE)
 
@@ -2421,8 +2423,8 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
 	vmcs_write32(VM_ENTRY_CONTROLS, vmcs_config.vmentry_ctrl);
 
 	vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL);
-	vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK);
-	vmx->vcpu.arch.cr4_guest_owned_bits = ~KVM_GUEST_CR4_MASK;
+	vmx->vcpu.arch.cr4_guest_owned_bits = KVM_CR4_GUEST_OWNED_BITS;
+	vmcs_writel(CR4_GUEST_HOST_MASK, ~vmx->vcpu.arch.cr4_guest_owned_bits);
 
 	tsc_base = vmx->vcpu.kvm->arch.vm_init_tsc;
 	rdtscll(tsc_this);
-- 
1.6.5.3


  parent reply	other threads:[~2010-02-10 17:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-10 17:22 [PATCH 00/40] KVM updates for the 2.6.34 merge window (batch 1/4) Avi Kivity
2010-02-10 17:22 ` [PATCH 01/40] KVM: x86: make double/triple fault promotion generic to all exceptions Avi Kivity
2010-02-10 17:22 ` [PATCH 02/40] KVM: x86: raise TSS exception for NULL CS and SS segments Avi Kivity
2010-02-10 17:22 ` [PATCH 03/40] KVM: MMU: Report spte not found in rmap before BUG() Avi Kivity
2010-02-10 17:22 ` [PATCH 04/40] KVM: VMX: Trap and invalid MWAIT/MONITOR instruction Avi Kivity
2010-02-10 17:22 ` [PATCH 05/40] KVM: VMX: Move some cr[04] related constants to vmx.c Avi Kivity
2010-02-10 17:22 ` [PATCH 06/40] KVM: Add accessor for reading cr4 (or some bits of cr4) Avi Kivity
2010-02-10 17:22 ` Avi Kivity [this message]
2010-02-10 17:22 ` [PATCH 08/40] KVM: VMX: When using ept, allow the guest to own cr4.pge Avi Kivity
2010-02-10 17:22 ` [PATCH 09/40] KVM: VMX: Fold ept_update_paging_mode_cr4() into its caller Avi Kivity
2010-02-10 17:22 ` [PATCH 10/40] KVM: VMX: Remove redundant variable Avi Kivity
2010-02-10 17:22 ` [PATCH 11/40] KVM: Extended shared_msr_global to per CPU Avi Kivity
2010-02-10 17:22 ` [PATCH 12/40] x86: Raise vsyscall priority on hotplug notifier chain Avi Kivity
2010-02-10 17:22 ` [PATCH 13/40] KVM: Add cpuid_update() callback to kvm_x86_ops Avi Kivity
2010-02-10 17:22 ` [PATCH 14/40] KVM: VMX: Add instruction rdtscp support for guest Avi Kivity
2010-02-10 17:22 ` [PATCH 15/40] KVM: SVM: Adjust tsc_offset only if tsc_unstable Avi Kivity
2010-02-10 17:22 ` [PATCH 16/40] KVM: Disentangle mmu notifiers and coalesced_mmio registration Avi Kivity
2010-02-10 17:22 ` [PATCH 17/40] KVM: Add include guards for coalesced_mmio.h Avi Kivity
2010-02-10 17:22 ` [PATCH 18/40] KVM: Remove ifdefs from mmu notifier initialization Avi Kivity
2010-02-10 17:22 ` [PATCH 19/40] KVM: Add KVM_MMIO kconfig item Avi Kivity
2010-02-10 17:22 ` [PATCH 20/40] KVM: Simplify coalesced mmio initialization Avi Kivity
2010-02-10 17:22 ` [PATCH 21/40] KVM: powerpc: Move vector to irqprio resolving to separate function Avi Kivity
2010-02-10 17:22 ` [PATCH 22/40] KVM: powerpc: Improve DEC handling Avi Kivity
2010-02-10 17:22 ` [PATCH 23/40] KVM: powerpc: Remove AGGRESSIVE_DEC Avi Kivity
2010-02-10 17:22 ` [PATCH 24/40] KVM: powerpc: Change maintainer Avi Kivity
2010-02-10 17:22 ` [PATCH 25/40] KVM: trivial document fixes Avi Kivity
2010-02-10 17:22 ` [PATCH 26/40] KVM: modify memslots layout in struct kvm Avi Kivity
2010-02-10 17:22 ` [PATCH 27/40] KVM: modify alias layout in x86s struct kvm_arch Avi Kivity
2010-02-10 17:22 ` [PATCH 28/40] KVM: split kvm_arch_set_memory_region into prepare and commit Avi Kivity
2010-02-10 17:22 ` [PATCH 29/40] KVM: introduce gfn_to_pfn_memslot Avi Kivity
2010-02-10 17:22 ` [PATCH 30/40] KVM: use gfn_to_pfn_memslot in kvm_iommu_map_pages Avi Kivity
2010-02-10 17:23 ` [PATCH 31/40] KVM: introduce kvm->srcu and convert kvm_set_memory_region to SRCU update Avi Kivity
2010-02-10 17:23 ` [PATCH 32/40] KVM: use SRCU for dirty log Avi Kivity
2010-02-10 17:23 ` [PATCH 33/40] KVM: x86: switch kvm_set_memory_alias to SRCU update Avi Kivity
2010-02-10 17:23 ` [PATCH 34/40] KVM: convert io_bus to SRCU Avi Kivity
2010-02-10 17:23 ` [PATCH 35/40] KVM: switch vcpu context to use SRCU Avi Kivity
2010-02-10 17:23 ` [PATCH 36/40] KVM: convert slots_lock to a mutex Avi Kivity
2010-02-10 17:23 ` [PATCH 37/40] KVM: Bump maximum vcpu count to 64 Avi Kivity
2010-02-10 17:23 ` [PATCH 38/40] KVM: Fill out ftrace exit reason strings Avi Kivity
2010-02-10 17:23 ` [PATCH 39/40] KVM: avoid taking ioapic mutex for non-ioapic EOIs Avi Kivity
2010-02-10 17:23 ` [PATCH 40/40] KVM: PPC: Fix typo in rebolting code Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1265822589-11155-8-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome