@@ -744,13 +744,9 @@ static void init_host_state(void)
744
744
uint16_t value16 ;
745
745
uint64_t value64 ;
746
746
uint64_t value ;
747
- uint64_t trbase ;
748
- uint64_t trbase_lo ;
749
- uint64_t trbase_hi ;
750
- uint64_t realtrbase ;
747
+ uint64_t tss_addr ;
751
748
descriptor_table gdtb = {0U , 0UL };
752
749
descriptor_table idtb = {0U , 0UL };
753
- uint16_t tr_sel ;
754
750
755
751
pr_dbg ("*********************" );
756
752
pr_dbg ("Initialize host state" );
@@ -787,9 +783,8 @@ static void init_host_state(void)
787
783
exec_vmwrite16 (VMX_HOST_GS_SEL , value16 );
788
784
pr_dbg ("VMX_HOST_GS_SEL: 0x%hu " , value16 );
789
785
790
- asm volatile ("str %%ax" :"=a" (tr_sel ));
791
- exec_vmwrite16 (VMX_HOST_TR_SEL , tr_sel );
792
- pr_dbg ("VMX_HOST_TR_SEL: 0x%hx " , tr_sel );
786
+ exec_vmwrite16 (VMX_HOST_TR_SEL , HOST_GDT_RING0_CPU_TSS_SEL );
787
+ pr_dbg ("VMX_HOST_TR_SEL: 0x%hx " , HOST_GDT_RING0_CPU_TSS_SEL );
793
788
794
789
/******************************************************
795
790
* 32-bit fields
@@ -809,30 +804,10 @@ static void init_host_state(void)
809
804
exec_vmwrite (VMX_HOST_GDTR_BASE , gdtb .base );
810
805
pr_dbg ("VMX_HOST_GDTR_BASE: 0x%x " , gdtb .base );
811
806
812
- /* TODO: Should guest TR point to host TR ? */
813
- trbase = gdtb .base + tr_sel ;
814
- if (((trbase >> 47U ) & 0x1UL ) != 0UL ) {
815
- trbase |= 0xffff000000000000UL ;
816
- }
817
-
818
- /* SS segment override */
819
- asm volatile ("mov %0,%%rax\n"
820
- ".byte 0x36\n"
821
- "movq (%%rax),%%rax\n" :"=a" (trbase_lo ):"0" (trbase )
822
- );
823
- realtrbase = ((trbase_lo >> 16U ) & (0x0ffffUL )) |
824
- (((trbase_lo >> 32U ) & 0x000000ffUL ) << 16U ) |
825
- (((trbase_lo >> 56U ) & 0xffUL ) << 24U );
826
-
827
- /* SS segment override for upper32 bits of base in ia32e mode */
828
- asm volatile (
829
- ".byte 0x36\n"
830
- "movq 8(%%rax),%%rax\n" :"=a" (trbase_hi ):"0" (trbase ));
831
- realtrbase = realtrbase | (trbase_hi << 32U );
832
-
833
- /* Set up host and guest TR base fields */
834
- exec_vmwrite (VMX_HOST_TR_BASE , realtrbase );
835
- pr_dbg ("VMX_HOST_TR_BASE: 0x%016llx " , realtrbase );
807
+ tss_addr = hva2hpa ((void * )& get_cpu_var (tss ));
808
+ /* Set up host TR base fields */
809
+ exec_vmwrite (VMX_HOST_TR_BASE , tss_addr );
810
+ pr_dbg ("VMX_HOST_TR_BASE: 0x%016llx " , tss_addr );
836
811
837
812
/* Obtain the current interrupt descriptor table base */
838
813
asm volatile ("sidt %0" :"=m" (idtb )::"memory" );
0 commit comments