@@ -3633,17 +3633,27 @@ static int em_rdmsr(struct x86_emulate_ctxt *ctxt)
3633
3633
return X86EMUL_CONTINUE ;
3634
3634
}
3635
3635
3636
- static int em_mov_rm_sreg (struct x86_emulate_ctxt * ctxt )
3636
+ static int em_store_sreg (struct x86_emulate_ctxt * ctxt , int segment )
3637
3637
{
3638
- if (ctxt -> modrm_reg > VCPU_SREG_GS )
3639
- return emulate_ud (ctxt );
3638
+ if (segment > VCPU_SREG_GS &&
3639
+ (ctxt -> ops -> get_cr (ctxt , 4 ) & X86_CR4_UMIP ) &&
3640
+ ctxt -> ops -> cpl (ctxt ) > 0 )
3641
+ return emulate_gp (ctxt , 0 );
3640
3642
3641
- ctxt -> dst .val = get_segment_selector (ctxt , ctxt -> modrm_reg );
3643
+ ctxt -> dst .val = get_segment_selector (ctxt , segment );
3642
3644
if (ctxt -> dst .bytes == 4 && ctxt -> dst .type == OP_MEM )
3643
3645
ctxt -> dst .bytes = 2 ;
3644
3646
return X86EMUL_CONTINUE ;
3645
3647
}
3646
3648
3649
+ static int em_mov_rm_sreg (struct x86_emulate_ctxt * ctxt )
3650
+ {
3651
+ if (ctxt -> modrm_reg > VCPU_SREG_GS )
3652
+ return emulate_ud (ctxt );
3653
+
3654
+ return em_store_sreg (ctxt , ctxt -> modrm_reg );
3655
+ }
3656
+
3647
3657
static int em_mov_sreg_rm (struct x86_emulate_ctxt * ctxt )
3648
3658
{
3649
3659
u16 sel = ctxt -> src .val ;
@@ -3659,6 +3669,11 @@ static int em_mov_sreg_rm(struct x86_emulate_ctxt *ctxt)
3659
3669
return load_segment_descriptor (ctxt , sel , ctxt -> modrm_reg );
3660
3670
}
3661
3671
3672
+ static int em_sldt (struct x86_emulate_ctxt * ctxt )
3673
+ {
3674
+ return em_store_sreg (ctxt , VCPU_SREG_LDTR );
3675
+ }
3676
+
3662
3677
static int em_lldt (struct x86_emulate_ctxt * ctxt )
3663
3678
{
3664
3679
u16 sel = ctxt -> src .val ;
@@ -3668,6 +3683,11 @@ static int em_lldt(struct x86_emulate_ctxt *ctxt)
3668
3683
return load_segment_descriptor (ctxt , sel , VCPU_SREG_LDTR );
3669
3684
}
3670
3685
3686
+ static int em_str (struct x86_emulate_ctxt * ctxt )
3687
+ {
3688
+ return em_store_sreg (ctxt , VCPU_SREG_TR );
3689
+ }
3690
+
3671
3691
static int em_ltr (struct x86_emulate_ctxt * ctxt )
3672
3692
{
3673
3693
u16 sel = ctxt -> src .val ;
@@ -4372,8 +4392,8 @@ static const struct opcode group5[] = {
4372
4392
};
4373
4393
4374
4394
static const struct opcode group6 [] = {
4375
- DI (Prot | DstMem , sldt ),
4376
- DI (Prot | DstMem , str ),
4395
+ II (Prot | DstMem , em_sldt , sldt ),
4396
+ II (Prot | DstMem , em_str , str ),
4377
4397
II (Prot | Priv | SrcMem16 , em_lldt , lldt ),
4378
4398
II (Prot | Priv | SrcMem16 , em_ltr , ltr ),
4379
4399
N , N , N , N ,
0 commit comments