diff options
author | Robert Mustacchi <rm@joyent.com> | 2011-07-27 17:49:21 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2011-07-27 17:49:21 +0000 |
commit | d83518e2263a7489388482ba5d9c011aba3f5b35 (patch) | |
tree | 9853e2accf428d43a97367a54278ad021c2c73af | |
parent | 002dd17038da793ca80490b77aac5c7a6c50f4ef (diff) | |
download | illumos-kvm-d83518e2263a7489388482ba5d9c011aba3f5b35.tar.gz |
HVM-530 Have kvm_tss.h match <sys/tss.h>
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | kvm_tss.h | 21 | ||||
-rw-r--r-- | kvm_x86.c | 44 |
4 files changed, 48 insertions, 28 deletions
@@ -12,6 +12,11 @@ CTFCONVERT=$(CTFBINDIR)/ctfconvert CTFMERGE=$(CTFBINDIR)/ctfmerge DESTDIR= CFLAGS += -D_KERNEL -D_MACHDEP -Dx86 -DDEBUG -c -g -DCONFIG_SOLARIS -O2 -fident -fno-inline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs -D__sun -O -D_ASM_INLINES -ffreestanding -Wall -Wno-unknown-pragmas -Wpointer-arith -Wno-unused -gdwarf-2 -std=gnu99 -fno-dwarf2-indirect-strings -Werror -DDIS_MEM -D_KERNEL -ffreestanding -D_SYSCALL32 -D_DDI_STRICT -Di86pc -D_MACHDEP -DOPTERON_ERRATUM_88 -DOPTERON_ERRATUM_91 -DOPTERON_ERRATUM_93 -DOPTERON_ERRATUM_95 -DOPTERON_ERRATUM_99 -DOPTERON_ERRATUM_100 -DOPTERON_ERRATUM_101 -DOPTERON_ERRATUM_108 -DOPTERON_ERRATUM_109 -DOPTERON_ERRATUM_121 -DOPTERON_ERRATUM_122 -DOPTERON_ERRATUM_123 -DOPTERON_ERRATUM_131 -DOPTERON_WORKAROUND_6336786 -DOPTERON_WORKAROUND_6323525 -DOPTERON_ERRATUM_172 -DOPTERON_ERRATUM_298 -I$(KERNEL_SOURCE)/usr/src/uts/common -nostdinc -c -DUTS_RELEASE="5.11" -DUTS_VERSION="joyent.147" -DUTS_PLATFORM="i86pc" -mno-red-zone +# +# Uncomment this line if you don't have an updated uts/intel/sys/tss.h that +# exposes the different tss definitions +# +#CFLAGS += -D_NEED_KVM_TSS INCLUDEDIR= -I $(KERNEL_SOURCE)/usr/src/uts/intel -I $(KERNEL_SOURCE)/usr/src/uts/i86pc -I $(KERNEL_SOURCE)/usr/src/uts/common CSTYLE=$(KERNEL_SOURCE)/usr/src/tools/scripts/cstyle @@ -12,8 +12,10 @@ finish in a snap. Preparation: -Edit the Makefile and appropriately set the path for the KERNEL_SOURCE -directory that points to the root of a checked out and built illumos directory. +Edit the Makefile and appropriately set the path for the KERNEL_SOURCE directory +that points to the root of a checked out and built illumos directory. As we +have not had the chance to upstream a change to uts/intel/sys/tss.h ensure that +line 19 of the Makfile, which adds the -D_NEED_KVM_TSS option, is uncommented. Verify that gcc is installed and the version you'd like to use is in your path. Note that this has only been tested against the SFW version of gcc -- version @@ -2,8 +2,19 @@ #define __TSS_SEGMENT_H #include <sys/stdint.h> +#include <sys/tss.h> -typedef struct tss_segment_32 { +/* + * uts/intel/sys/tss.h now exposes the following definitions. In the past, it + * only exposed the single architecture specific tss structure depending on what + * you were compiling for. When the tss.h changes finally gets upstreamed, this + * file can be deleted and the includes replaced with <sys/tss.h> instead of + * kvm_tss.h. + */ + +#ifdef _NEED_KVM_TSS + +struct tss32 { uint16_t tss_link; /* 16-bit prior TSS selector */ uint16_t tss_rsvd0; /* reserved, ignored */ uint32_t tss_esp0; @@ -42,13 +53,13 @@ typedef struct tss_segment_32 { uint16_t tss_rsvd10; /* reserved, ignored */ uint16_t tss_rsvd11; /* reserved, ignored */ uint16_t tss_bitmapbase; /* io permission bitmap base address */ -} tss_segment_32_t; +}; /* * Based on data from Intel Manual 3a, Intel 64 and IA-32 Architectures Software * Developer’s Manual Volume 3A: System Programming Guide, Part 1, Section 7.6 */ -typedef struct tss_segment_16 { +struct tss16 { uint16_t tss_link; uint16_t tss_sp0; uint16_t tss_ss0; @@ -71,6 +82,8 @@ typedef struct tss_segment_16 { uint16_t tss_ss; uint16_t tss_ds; uint16_t tss_ldt; -} tss_segment_16_t; +}; + +#endif /* _HAVE_KVM_TSS */ #endif @@ -4132,7 +4132,7 @@ exception: } static void -save_state_to_tss32(struct kvm_vcpu *vcpu, struct tss_segment_32 *tss) +save_state_to_tss32(struct kvm_vcpu *vcpu, struct tss32 *tss) { tss->tss_cr3 = vcpu->arch.cr3; tss->tss_eip = kvm_rip_read(vcpu); @@ -4164,7 +4164,7 @@ kvm_load_segment_selector(struct kvm_vcpu *vcpu, uint16_t sel, int seg) } static int -load_state_from_tss32(struct kvm_vcpu *vcpu, struct tss_segment_32 *tss) +load_state_from_tss32(struct kvm_vcpu *vcpu, struct tss32 *tss) { kvm_set_cr3(vcpu, tss->tss_cr3); @@ -4222,7 +4222,7 @@ load_state_from_tss32(struct kvm_vcpu *vcpu, struct tss_segment_32 *tss) } static void -save_state_to_tss16(struct kvm_vcpu *vcpu, struct tss_segment_16 *tss) +save_state_to_tss16(struct kvm_vcpu *vcpu, struct tss16 *tss) { tss->tss_ip = kvm_rip_read(vcpu); tss->tss_flag = kvm_get_rflags(vcpu); @@ -4243,7 +4243,7 @@ save_state_to_tss16(struct kvm_vcpu *vcpu, struct tss_segment_16 *tss) } static int -load_state_from_tss16(struct kvm_vcpu *vcpu, struct tss_segment_16 *tss) +load_state_from_tss16(struct kvm_vcpu *vcpu, struct tss16 *tss) { kvm_rip_write(vcpu, tss->tss_ip); kvm_set_rflags(vcpu, tss->tss_flag | 2); @@ -4292,33 +4292,33 @@ static int kvm_task_switch_16(struct kvm_vcpu *vcpu, uint16_t tss_selector, uint16_t old_tss_sel, uint32_t old_tss_base, struct desc_struct *nseg_desc) { - struct tss_segment_16 tss_segment_16; + struct tss16 tss16; int ret = 0; if (kvm_read_guest(vcpu->kvm, old_tss_base, - &tss_segment_16, sizeof (tss_segment_16))) + &tss16, sizeof (tss16))) goto out; - save_state_to_tss16(vcpu, &tss_segment_16); + save_state_to_tss16(vcpu, &tss16); if (kvm_write_guest(vcpu->kvm, old_tss_base, - &tss_segment_16, sizeof (tss_segment_16))) + &tss16, sizeof (tss16))) goto out; if (kvm_read_guest(vcpu->kvm, get_tss_base_addr_read(vcpu, nseg_desc), - &tss_segment_16, sizeof (tss_segment_16))) + &tss16, sizeof (tss16))) goto out; if (old_tss_sel != 0xffff) { - tss_segment_16.tss_link = old_tss_sel; + tss16.tss_link = old_tss_sel; if (kvm_write_guest(vcpu->kvm, get_tss_base_addr_write(vcpu, - nseg_desc), &tss_segment_16.tss_link, - sizeof (tss_segment_16.tss_link))) + nseg_desc), &tss16.tss_link, + sizeof (tss16.tss_link))) goto out; } - if (load_state_from_tss16(vcpu, &tss_segment_16)) + if (load_state_from_tss16(vcpu, &tss16)) goto out; ret = 1; @@ -4330,33 +4330,33 @@ static int kvm_task_switch_32(struct kvm_vcpu *vcpu, uint16_t tss_selector, uint16_t old_tss_sel, uint32_t old_tss_base, struct desc_struct *nseg_desc) { - struct tss_segment_32 tss_segment_32; + struct tss32 tss32; int ret = 0; if (kvm_read_guest(vcpu->kvm, old_tss_base, - &tss_segment_32, sizeof (tss_segment_32))) + &tss32, sizeof (tss32))) goto out; - save_state_to_tss32(vcpu, &tss_segment_32); + save_state_to_tss32(vcpu, &tss32); if (kvm_write_guest(vcpu->kvm, old_tss_base, - &tss_segment_32, sizeof (tss_segment_32))) + &tss32, sizeof (tss32))) goto out; if (kvm_read_guest(vcpu->kvm, get_tss_base_addr_read(vcpu, nseg_desc), - &tss_segment_32, sizeof (tss_segment_32))) + &tss32, sizeof (tss32))) goto out; if (old_tss_sel != 0xffff) { - tss_segment_32.tss_link = old_tss_sel; + tss32.tss_link = old_tss_sel; if (kvm_write_guest(vcpu->kvm, get_tss_base_addr_write(vcpu, - nseg_desc), &tss_segment_32.tss_link, - sizeof (tss_segment_32.tss_link))) + nseg_desc), &tss32.tss_link, + sizeof (tss32.tss_link))) goto out; } - if (load_state_from_tss32(vcpu, &tss_segment_32)) + if (load_state_from_tss32(vcpu, &tss32)) goto out; ret = 1; |