target/i386: fix error code for exceptions caused by IDT accesses
PATCH 1/1 target/i386: fix error code for exceptions caused by IDT accesses
Exceptions caused by IDT accesses have the interrupt number in bits 3:10 of the error code. When in long mode an IDT descriptor is 16 bytes in size, and due to a copy-and-paste mistake the multiplication by 8 (shift by 3) was changed to a multiplication by 16 even in the computation of the error code. Fix this.
Reported-by: Michael Petch <https://gitlab.com/mpetch>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1382#note_1220619456
Signed-off-by Paolo Bonzini <[email protected]>
--- target/i386/tcg/seg_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/i386/tcg/seg_helper.c +4 -4
@@ -882,7 +882,7 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int, dt = &env->idt;if (intno *16 +15 > dt->limit) { -raise_exception_err (env,EXCP0D_GPF , intno *16 +2 ); +raise_exception_err (env,EXCP0D_GPF , intno *8 +2 ); } ptr = dt->base + intno *16 ; e1 =cpu_ldl_kernel (env, ptr);
@@ -895,18 +895,18 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int,case 15 :/* 386 trap gate */ break ;default : -raise_exception_err (env,EXCP0D_GPF , intno *16 +2 ); +raise_exception_err (env,EXCP0D_GPF , intno *8 +2 );break ; } dpl = (e2 >>DESC_DPL_SHIFT ) &3 ; cpl = env->hflags &HF_CPL_MASK ;/* check privilege if software int */ if (is_int && dpl < cpl) { -raise_exception_err (env,EXCP0D_GPF , intno *16 +2 ); +raise_exception_err (env,EXCP0D_GPF , intno *8 +2 ); }/* check valid bit */ if (!(e2 &DESC_P_MASK )) { -raise_exception_err (env,EXCP0B_NOSEG , intno *16 +2 ); +raise_exception_err (env,EXCP0B_NOSEG , intno *8 +2 ); } selector = e1 >>16 ; offset = ((target_ulong )e3 <<32 ) | (e2 &0xffff0000 ) | (e1 &0x0000ffff );
Signature · 1 line
2.38.1