KVM: move segment_base() into vmx.c
segment_base() is used only by vmx so move it there. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
@@ -644,8 +644,6 @@ int emulator_write_emulated(unsigned long addr,
|
|||||||
unsigned int bytes,
|
unsigned int bytes,
|
||||||
struct kvm_vcpu *vcpu);
|
struct kvm_vcpu *vcpu);
|
||||||
|
|
||||||
unsigned long segment_base(u16 selector);
|
|
||||||
|
|
||||||
void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu);
|
void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu);
|
||||||
void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
|
void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
|
||||||
const u8 *new, int bytes,
|
const u8 *new, int bytes,
|
||||||
@@ -723,13 +721,6 @@ static inline void kvm_get_idt(struct desc_ptr *table)
|
|||||||
asm("sidt %0" : "=m"(*table));
|
asm("sidt %0" : "=m"(*table));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long kvm_read_tr_base(void)
|
|
||||||
{
|
|
||||||
u16 tr;
|
|
||||||
asm("str %0" : "=g"(tr));
|
|
||||||
return segment_base(tr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
#ifdef CONFIG_X86_64
|
||||||
static inline unsigned long read_msr(unsigned long msr)
|
static inline unsigned long read_msr(unsigned long msr)
|
||||||
{
|
{
|
||||||
|
@@ -634,6 +634,43 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned long segment_base(u16 selector)
|
||||||
|
{
|
||||||
|
struct desc_ptr gdt;
|
||||||
|
struct desc_struct *d;
|
||||||
|
unsigned long table_base;
|
||||||
|
unsigned long v;
|
||||||
|
|
||||||
|
if (!(selector & ~3))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
native_store_gdt(&gdt);
|
||||||
|
table_base = gdt.address;
|
||||||
|
|
||||||
|
if (selector & 4) { /* from ldt */
|
||||||
|
u16 ldt_selector = kvm_read_ldt();
|
||||||
|
|
||||||
|
if (!(ldt_selector & ~3))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
table_base = segment_base(ldt_selector);
|
||||||
|
}
|
||||||
|
d = (struct desc_struct *)(table_base + (selector & ~7));
|
||||||
|
v = get_desc_base(d);
|
||||||
|
#ifdef CONFIG_X86_64
|
||||||
|
if (d->s == 0 && (d->type == 2 || d->type == 9 || d->type == 11))
|
||||||
|
v |= ((unsigned long)((struct ldttss_desc64 *)d)->base3) << 32;
|
||||||
|
#endif
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long kvm_read_tr_base(void)
|
||||||
|
{
|
||||||
|
u16 tr;
|
||||||
|
asm("str %0" : "=g"(tr));
|
||||||
|
return segment_base(tr);
|
||||||
|
}
|
||||||
|
|
||||||
static void vmx_save_host_state(struct kvm_vcpu *vcpu)
|
static void vmx_save_host_state(struct kvm_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
||||||
|
@@ -223,36 +223,6 @@ static void drop_user_return_notifiers(void *ignore)
|
|||||||
kvm_on_user_return(&smsr->urn);
|
kvm_on_user_return(&smsr->urn);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long segment_base(u16 selector)
|
|
||||||
{
|
|
||||||
struct desc_ptr gdt;
|
|
||||||
struct desc_struct *d;
|
|
||||||
unsigned long table_base;
|
|
||||||
unsigned long v;
|
|
||||||
|
|
||||||
if (!(selector & ~3))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
native_store_gdt(&gdt);
|
|
||||||
table_base = gdt.address;
|
|
||||||
|
|
||||||
if (selector & 4) { /* from ldt */
|
|
||||||
u16 ldt_selector = kvm_read_ldt();
|
|
||||||
|
|
||||||
if (!(ldt_selector & ~3))
|
|
||||||
return 0;
|
|
||||||
table_base = segment_base(ldt_selector);
|
|
||||||
}
|
|
||||||
d = (struct desc_struct *)(table_base + (selector & ~7));
|
|
||||||
v = get_desc_base(d);
|
|
||||||
#ifdef CONFIG_X86_64
|
|
||||||
if (d->s == 0 && (d->type == 2 || d->type == 9 || d->type == 11))
|
|
||||||
v |= ((unsigned long)((struct ldttss_desc64 *)d)->base3) << 32;
|
|
||||||
#endif
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(segment_base);
|
|
||||||
|
|
||||||
u64 kvm_get_apic_base(struct kvm_vcpu *vcpu)
|
u64 kvm_get_apic_base(struct kvm_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
if (irqchip_in_kernel(vcpu->kvm))
|
if (irqchip_in_kernel(vcpu->kvm))
|
||||||
|
Reference in New Issue
Block a user