aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorCarsten Otte <cotte@de.ibm.com>2007-10-29 11:08:51 -0400
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:52:57 -0500
commit5fb76f9be1a050a25e21a44ab2003c9d36a72a77 (patch)
treefa5a184ade52e55746efb1bab59fa283ee3535ed /drivers/kvm/kvm_main.c
parent1fe779f8eccd16e527315e1bafd2b3a876ff2489 (diff)
KVM: Portability: Move memory segmentation to x86.c
This patch moves the definition of segment_descriptor_64 for AMD64 and EM64T from kvm_main.c to segment_descriptor.h. It also adds a proper #ifndef...#define...#endif around that header file. The implementation of segment_base is moved from kvm_main.c to x86.c. Signed-off-by: Carsten Otte <cotte@de.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c42
1 files changed, 0 insertions, 42 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index c632e3a3b514..cf163bddfbd3 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -18,7 +18,6 @@
18#include "kvm.h" 18#include "kvm.h"
19#include "x86.h" 19#include "x86.h"
20#include "x86_emulate.h" 20#include "x86_emulate.h"
21#include "segment_descriptor.h"
22#include "irq.h" 21#include "irq.h"
23 22
24#include <linux/kvm.h> 23#include <linux/kvm.h>
@@ -104,50 +103,9 @@ static struct dentry *debugfs_dir;
104#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR) 103#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
105#define EFER_RESERVED_BITS 0xfffffffffffff2fe 104#define EFER_RESERVED_BITS 0xfffffffffffff2fe
106 105
107#ifdef CONFIG_X86_64
108/* LDT or TSS descriptor in the GDT. 16 bytes. */
109struct segment_descriptor_64 {
110 struct segment_descriptor s;
111 u32 base_higher;
112 u32 pad_zero;
113};
114
115#endif
116
117static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl, 106static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
118 unsigned long arg); 107 unsigned long arg);
119 108
120unsigned long segment_base(u16 selector)
121{
122 struct descriptor_table gdt;
123 struct segment_descriptor *d;
124 unsigned long table_base;
125 unsigned long v;
126
127 if (selector == 0)
128 return 0;
129
130 asm("sgdt %0" : "=m"(gdt));
131 table_base = gdt.base;
132
133 if (selector & 4) { /* from ldt */
134 u16 ldt_selector;
135
136 asm("sldt %0" : "=g"(ldt_selector));
137 table_base = segment_base(ldt_selector);
138 }
139 d = (struct segment_descriptor *)(table_base + (selector & ~7));
140 v = d->base_low | ((unsigned long)d->base_mid << 16) |
141 ((unsigned long)d->base_high << 24);
142#ifdef CONFIG_X86_64
143 if (d->system == 0 && (d->type == 2 || d->type == 9 || d->type == 11))
144 v |= ((unsigned long) \
145 ((struct segment_descriptor_64 *)d)->base_higher) << 32;
146#endif
147 return v;
148}
149EXPORT_SYMBOL_GPL(segment_base);
150
151static inline int valid_vcpu(int n) 109static inline int valid_vcpu(int n)
152{ 110{
153 return likely(n >= 0 && n < KVM_MAX_VCPUS); 111 return likely(n >= 0 && n < KVM_MAX_VCPUS);