Skip to content

Commit

Permalink
target/i386: tcg: fix segment register offsets for 16-bit TSS
Browse files Browse the repository at this point in the history
The TSS offsets in the manuals have only 2-byte slots for the
segment registers.  QEMU incorrectly uses 4-byte slots, so
that SS overlaps the LDT selector.

Resolves: #382
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Jun 4, 2021
1 parent 29c3d21 commit 28f6aa1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions target/i386/tcg/seg_helper.c
Expand Up @@ -281,7 +281,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_selector,
retaddr) | 0xffff0000;
}
for (i = 0; i < 4; i++) {
new_segs[i] = cpu_lduw_kernel_ra(env, tss_base + (0x22 + i * 4),
new_segs[i] = cpu_lduw_kernel_ra(env, tss_base + (0x22 + i * 2),
retaddr);
}
new_ldt = cpu_lduw_kernel_ra(env, tss_base + 0x2a, retaddr);
Expand Down Expand Up @@ -349,7 +349,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_selector,
cpu_stw_kernel_ra(env, env->tr.base + (0x12 + 6 * 2), env->regs[R_ESI], retaddr);
cpu_stw_kernel_ra(env, env->tr.base + (0x12 + 7 * 2), env->regs[R_EDI], retaddr);
for (i = 0; i < 4; i++) {
cpu_stw_kernel_ra(env, env->tr.base + (0x22 + i * 4),
cpu_stw_kernel_ra(env, env->tr.base + (0x22 + i * 2),
env->segs[i].selector, retaddr);
}
}
Expand Down

0 comments on commit 28f6aa1

Please sign in to comment.