mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: kvm-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: [PATCH 33/38] KVM: Make is_long_mode() an arch operation
Date: Mon, 27 Nov 2006 12:43:38 -0000	[thread overview]
Message-ID: <20061127124338.D052925015E@cleopatra.q> (raw)
In-Reply-To: <456AD5C6.1090406@qumranet.com>

Signed-off-by: Avi Kivity <avi@qumranet.com>

Index: linux-2.6/drivers/kvm/kvm.h
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm.h
+++ linux-2.6/drivers/kvm/kvm.h
@@ -275,6 +275,7 @@ struct kvm_arch_ops {
 			    struct kvm_segment *var, int seg);
 	void (*set_segment)(struct kvm_vcpu *vcpu,
 			    struct kvm_segment *var, int seg);
+	int (*is_long_mode)(struct kvm_vcpu *vcpu);
 	void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l);
 	void (*set_cr0)(struct kvm_vcpu *vcpu, unsigned long cr0);
 	void (*set_cr0_no_modeswitch)(struct kvm_vcpu *vcpu,
@@ -411,11 +412,6 @@ static inline void vmcs_write32(unsigned
 	vmcs_writel(field, value);
 }
 
-static inline int is_long_mode(void)
-{
-	return vmcs_read32(VM_ENTRY_CONTROLS) & VM_ENTRY_CONTROLS_IA32E_MASK;
-}
-
 static inline int is_pae(struct kvm_vcpu *vcpu)
 {
 	return vcpu->cr4 & CR4_PAE_MASK;
Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm_main.c
+++ linux-2.6/drivers/kvm/kvm_main.c
@@ -441,7 +441,7 @@ void set_cr4(struct kvm_vcpu *vcpu, unsi
 		return;
 	}
 
-	if (is_long_mode()) {
+	if (kvm_arch_ops->is_long_mode(vcpu)) {
 		if (!(cr4 & CR4_PAE_MASK)) {
 			printk(KERN_DEBUG "set_cr4: #GP, clearing PAE while "
 			       "in long mode\n");
@@ -468,7 +468,7 @@ EXPORT_SYMBOL_GPL(set_cr4);
 
 void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
 {
-	if (is_long_mode()) {
+	if (kvm_arch_ops->is_long_mode(vcpu)) {
 		if ( cr3 & CR3_L_MODE_RESEVED_BITS) {
 			printk(KERN_DEBUG "set_cr3: #GP, reserved bits\n");
 			inject_gp(vcpu);
Index: linux-2.6/drivers/kvm/mmu.c
===================================================================
--- linux-2.6.orig/drivers/kvm/mmu.c
+++ linux-2.6/drivers/kvm/mmu.c
@@ -589,7 +589,7 @@ static int init_kvm_mmu(struct kvm_vcpu 
 
 	if (!is_paging(vcpu))
 		return nonpaging_init_context(vcpu);
-	else if (is_long_mode())
+	else if (kvm_arch_ops->is_long_mode(vcpu))
 		return paging64_init_context(vcpu);
 	else if (is_pae(vcpu))
 		return paging32E_init_context(vcpu);
Index: linux-2.6/drivers/kvm/paging_tmpl.h
===================================================================
--- linux-2.6.orig/drivers/kvm/paging_tmpl.h
+++ linux-2.6/drivers/kvm/paging_tmpl.h
@@ -70,7 +70,7 @@ static void FNAME(init_walker)(struct gu
 	hpa = safe_gpa_to_hpa(vcpu, vcpu->cr3 & PT64_BASE_ADDR_MASK);
 	walker->table = kmap_atomic(pfn_to_page(hpa >> PAGE_SHIFT), KM_USER0);
 
-	ASSERT((!is_long_mode() && is_pae(vcpu)) ||
+	ASSERT((!kvm_arch_ops->is_long_mode(vcpu) && is_pae(vcpu)) ||
 	       (vcpu->cr3 & ~(PAGE_MASK | CR3_FLAGS_MASK)) == 0);
 
 	walker->table = (pt_element_t *)( (unsigned long)walker->table |
@@ -135,7 +135,7 @@ static pt_element_t *FNAME(fetch_guest)(
 		     (walker->table[index] & PT_PAGE_SIZE_MASK) &&
 		     (PTTYPE == 64 || is_pse(vcpu))))
 			return &walker->table[index];
-		if (walker->level != 3 || is_long_mode())
+		if (walker->level != 3 || kvm_arch_ops->is_long_mode(vcpu))
 			walker->inherited_ar &= walker->table[index];
 		paddr = safe_gpa_to_hpa(vcpu, walker->table[index] & PT_BASE_ADDR_MASK);
 		kunmap_atomic(walker->table, KM_USER0);
@@ -204,7 +204,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu
 		shadow_addr = kvm_mmu_alloc_page(vcpu, shadow_ent);
 		if (!VALID_PAGE(shadow_addr))
 			return ERR_PTR(-ENOMEM);
-		if (!is_long_mode() && level == 3)
+		if (!kvm_arch_ops->is_long_mode(vcpu) && level == 3)
 			*shadow_ent = shadow_addr |
 				(*guest_ent & (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK));
 		else {
Index: linux-2.6/drivers/kvm/vmx.c
===================================================================
--- linux-2.6.orig/drivers/kvm/vmx.c
+++ linux-2.6/drivers/kvm/vmx.c
@@ -811,6 +811,11 @@ static void vmx_set_segment(struct kvm_v
 	vmcs_write32(sf->ar_bytes, ar);
 }
 
+static int vmx_is_long_mode(struct kvm_vcpu *vcpu)
+{
+	return vmcs_read32(VM_ENTRY_CONTROLS) & VM_ENTRY_CONTROLS_IA32E_MASK;
+}
+
 static void vmx_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l)
 {
 	u32 ar = vmcs_read32(GUEST_CS_AR_BYTES);
@@ -1884,6 +1889,7 @@ static struct kvm_arch_ops vmx_arch_ops 
 	.get_segment_base = vmx_get_segment_base,
 	.get_segment = vmx_get_segment,
 	.set_segment = vmx_set_segment,
+	.is_long_mode = vmx_is_long_mode,
 	.get_cs_db_l_bits = vmx_get_cs_db_l_bits,
 	.set_cr0 = vmx_set_cr0,
 	.set_cr0_no_modeswitch = vmx_set_cr0_no_modeswitch,

  parent reply	other threads:[~2006-11-27 12:43 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-27 12:10 [PATCH 0/38] KVM: Decouple Intel VT implementation from base kvm Avi Kivity
2006-11-27 12:11 ` [PATCH 1/38] KVM: Create kvm-intel.ko module Avi Kivity
2006-11-27 12:36   ` Ingo Molnar
2006-11-30 14:24     ` Christoph Hellwig
2006-11-30 15:44       ` Ingo Molnar
2006-11-30 19:59         ` Andrew Morton
2006-11-30 20:19           ` Ingo Molnar
2006-11-30 20:24             ` Christoph Hellwig
2006-11-30 20:31               ` Ingo Molnar
2006-11-27 12:12 ` [PATCH 2/38] KVM: Make /dev/registration happen when the arch specific module is loaded Avi Kivity
2006-11-27 12:13 ` [PATCH 0/38] KVM: Decouple Intel VT implementation from base kvm Avi Kivity
2006-11-27 12:13 ` [PATCH 3/38] KV: Make hardware detection an arch operation Avi Kivity
2006-11-27 12:14 ` [PATCH 4/38] KVM: Make the per-cpu enable/disable functions arch operations Avi Kivity
2006-11-27 12:15 ` [PATCH 5/38] KVM: Make the hardware setup operations (non-percpu) " Avi Kivity
2006-11-27 12:16 ` [PATCH 6/38] KVM: Make the guest debugger an arch operation Avi Kivity
2006-11-27 12:17 ` [PATCH 7/38] KVM: Make msr accessors arch operations Avi Kivity
2006-11-27 12:18 ` [PATCH 8/38] KVM: Make the segment " Avi Kivity
2006-11-27 12:19 ` [PATCH 9/38] KVM: Cache guest cr4 in vcpu structure Avi Kivity
2006-11-27 12:20 ` [PATCH 10/38] KVM: Cache guest cr0 " Avi Kivity
2006-11-27 12:21 ` [PATCH 11/38] KVM: Add get_segment_base() arch accessor Avi Kivity
2006-11-27 12:22 ` [PATCH 12/38] KVM: Add idt and gdt descriptor accessors Avi Kivity
2006-11-27 12:23 ` [PATCH 13/38] KVM: Make syncing the register file to the vcpu structure an arch operation Avi Kivity
2006-11-27 12:24 ` [PATCH 14/38] KVM: Make the vcpu execution loop " Avi Kivity
2006-11-27 12:25 ` [PATCH 15/38] KVM: Move the vmx exit handlers to vmx.c Avi Kivity
2006-11-27 12:26 ` [PATCH 16/38] KVM: Make vcpu_setup() an arch operation Avi Kivity
2006-11-27 12:27 ` [PATCH 17/38] KVM: Make __set_cr0() (and dependencies) arch operations Avi Kivity
2006-11-27 12:28 ` [PATCH 18/38] KVM: Make __set_cr4() an arch operation Avi Kivity
2006-11-27 12:29 ` [PATCH 19/38] KVM: Make __set_efer() " Avi Kivity
2006-11-27 13:39   ` Christoph Hellwig
2006-11-27 13:46     ` Avi Kivity
2006-11-27 12:30 ` [PATCH 20/38] KVM: Make set_cr3() and tlb flushing arch operations Avi Kivity
2006-11-27 12:31 ` [PATCH 21/38] KVM: Make inject_page_fault() an arch operation Avi Kivity
2006-11-27 12:32 ` [PATCH 22/38] KVM: Make inject_gp() " Avi Kivity
2006-11-27 12:33 ` [PATCH 23/38] KVM: Use the idt and gdt accessors in realmode emulation Avi Kivity
2006-11-27 12:34 ` [PATCH 24/38] KVM: Use the general purpose register accessors rather than direct access Avi Kivity
2006-11-27 12:35 ` [PATCH 25/38] KVM: Move the vmx tsc accessors to vmx.c Avi Kivity
2006-11-27 12:36 ` [PATCH 26/38] KVM: Access rflags through an arch operation Avi Kivity
2006-11-27 12:37 ` [PATCH 27/38] KVM: Move the vmx segment field definitions to vmx.c Avi Kivity
2006-11-27 12:38 ` [PATCH 28/38] KVM: Add an arch accessor for cs d/b and l bits Avi Kivity
2006-11-27 12:39 ` [PATCH 29/38] KVM: Add a set_cr0_no_modeswitch() arch accessor Avi Kivity
2006-11-27 12:40 ` [PATCH 30/38] KVM: Make vcpu_load() and vcpu_put() arch operations Avi Kivity
2006-11-27 12:41 ` [PATCH 31/38] KVM: Make vcpu creation and destruction " Avi Kivity
2006-11-27 12:42 ` [PATCH 32/38] KVM: Move vmcs static variables to vmx.c Avi Kivity
2006-11-27 12:43 ` Avi Kivity [this message]
2006-11-27 12:44 ` [PATCH 34/38] KVM: Use the tlb flush arch operation instead of an inline Avi Kivity
2006-11-27 12:45 ` [PATCH 35/38] KVM: Remove guest_cpl() Avi Kivity
2006-11-27 12:46 ` [PATCH 36/38] KVM: Move vmcs accessors to vmx.c Avi Kivity
2006-11-27 12:47 ` [PATCH 37/38] KVM: Move vmx helper inlines " Avi Kivity
2006-11-27 12:48 ` [PATCH 38/38] KVM: Remove vmx includes from arch independent 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=20061127124338.D052925015E@cleopatra.q \
    --to=avi@qumranet.com \
    --cc=akpm@osdl.org \
    --cc=kvm-devel@lists.sourceforge.net \
    --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

all inboxes | Powered by JetHome®