From: "Dr. David Alan Gilbert" <dave@treblig.org>
handle_vm86_fault has been unused since:
1ade5b2fed ("linux-user/i386: Split out maybe_handle_vm86_trap")
Remove it, and it's local macros.
Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
linux-user/user-internals.h | 1 -
linux-user/vm86.c | 136 ------------------------------------
2 files changed, 137 deletions(-)
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
index 5c7f173ceb..46ffc093f4 100644
--- a/linux-user/user-internals.h
+++ b/linux-user/user-internals.h
@@ -102,7 +102,6 @@ int host_to_target_waitstatus(int status);
/* vm86.c */
void save_v86_state(CPUX86State *env);
void handle_vm86_trap(CPUX86State *env, int trapno);
-void handle_vm86_fault(CPUX86State *env);
int do_vm86(CPUX86State *env, long subfunction, abi_ulong v86_addr);
#elif defined(TARGET_SPARC64)
void sparc64_set_context(CPUSPARCState *env);
diff --git a/linux-user/vm86.c b/linux-user/vm86.c
index 9f512a2242..31a2d707cf 100644
--- a/linux-user/vm86.c
+++ b/linux-user/vm86.c
@@ -255,142 +255,6 @@ void handle_vm86_trap(CPUX86State *env, int trapno)
}
}
-#define CHECK_IF_IN_TRAP() \
- if ((ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_active) && \
- (ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_TFpendig)) \
- newflags |= TF_MASK
-
-#define VM86_FAULT_RETURN \
- if ((ts->vm86plus.vm86plus.flags & TARGET_force_return_for_pic) && \
- (ts->v86flags & (IF_MASK | VIF_MASK))) \
- return_to_32bit(env, TARGET_VM86_PICRETURN); \
- return
-
-void handle_vm86_fault(CPUX86State *env)
-{
- CPUState *cs = env_cpu(env);
- TaskState *ts = get_task_state(cs);
- uint32_t csp, ssp;
- unsigned int ip, sp, newflags, newip, newcs, opcode, intno;
- int data32, pref_done;
-
- csp = env->segs[R_CS].selector << 4;
- ip = env->eip & 0xffff;
-
- ssp = env->segs[R_SS].selector << 4;
- sp = env->regs[R_ESP] & 0xffff;
-
- LOG_VM86("VM86 exception %04x:%08x\n",
- env->segs[R_CS].selector, env->eip);
-
- data32 = 0;
- pref_done = 0;
- do {
- opcode = vm_getb(env, csp, ip);
- ADD16(ip, 1);
- switch (opcode) {
- case 0x66: /* 32-bit data */ data32=1; break;
- case 0x67: /* 32-bit address */ break;
- case 0x2e: /* CS */ break;
- case 0x3e: /* DS */ break;
- case 0x26: /* ES */ break;
- case 0x36: /* SS */ break;
- case 0x65: /* GS */ break;
- case 0x64: /* FS */ break;
- case 0xf2: /* repnz */ break;
- case 0xf3: /* rep */ break;
- default: pref_done = 1;
- }
- } while (!pref_done);
-
- /* VM86 mode */
- switch(opcode) {
- case 0x9c: /* pushf */
- if (data32) {
- vm_putl(env, ssp, sp - 4, get_vflags(env));
- ADD16(env->regs[R_ESP], -4);
- } else {
- vm_putw(env, ssp, sp - 2, get_vflags(env));
- ADD16(env->regs[R_ESP], -2);
- }
- env->eip = ip;
- VM86_FAULT_RETURN;
-
- case 0x9d: /* popf */
- if (data32) {
- newflags = vm_getl(env, ssp, sp);
- ADD16(env->regs[R_ESP], 4);
- } else {
- newflags = vm_getw(env, ssp, sp);
- ADD16(env->regs[R_ESP], 2);
- }
- env->eip = ip;
- CHECK_IF_IN_TRAP();
- if (data32) {
- if (set_vflags_long(newflags, env))
- return;
- } else {
- if (set_vflags_short(newflags, env))
- return;
- }
- VM86_FAULT_RETURN;
-
- case 0xcd: /* int */
- intno = vm_getb(env, csp, ip);
- ADD16(ip, 1);
- env->eip = ip;
- if (ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_active) {
- if ( (ts->vm86plus.vm86plus.vm86dbg_intxxtab[intno >> 3] >>
- (intno &7)) & 1) {
- return_to_32bit(env, TARGET_VM86_INTx + (intno << 8));
- return;
- }
- }
- do_int(env, intno);
- break;
-
- case 0xcf: /* iret */
- if (data32) {
- newip = vm_getl(env, ssp, sp) & 0xffff;
- newcs = vm_getl(env, ssp, sp + 4) & 0xffff;
- newflags = vm_getl(env, ssp, sp + 8);
- ADD16(env->regs[R_ESP], 12);
- } else {
- newip = vm_getw(env, ssp, sp);
- newcs = vm_getw(env, ssp, sp + 2);
- newflags = vm_getw(env, ssp, sp + 4);
- ADD16(env->regs[R_ESP], 6);
- }
- env->eip = newip;
- cpu_x86_load_seg(env, R_CS, newcs);
- CHECK_IF_IN_TRAP();
- if (data32) {
- if (set_vflags_long(newflags, env))
- return;
- } else {
- if (set_vflags_short(newflags, env))
- return;
- }
- VM86_FAULT_RETURN;
-
- case 0xfa: /* cli */
- env->eip = ip;
- clear_IF(env);
- VM86_FAULT_RETURN;
-
- case 0xfb: /* sti */
- env->eip = ip;
- if (set_IF(env))
- return;
- VM86_FAULT_RETURN;
-
- default:
- /* real VM86 GPF exception */
- return_to_32bit(env, TARGET_VM86_UNKNOWN);
- break;
- }
-}
-
int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr)
{
CPUState *cs = env_cpu(env);
--
2.39.5
On 04/10/2024 18.03, Michael Tokarev wrote: > From: "Dr. David Alan Gilbert" <dave@treblig.org> > > handle_vm86_fault has been unused since: > 1ade5b2fed ("linux-user/i386: Split out maybe_handle_vm86_trap") > > Remove it, and it's local macros. > > Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org> > Reviewed-by: Thomas Huth <thuth@redhat.com> > Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> > Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> > --- > linux-user/user-internals.h | 1 - > linux-user/vm86.c | 136 ------------------------------------ > 2 files changed, 137 deletions(-) > > diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h > index 5c7f173ceb..46ffc093f4 100644 > --- a/linux-user/user-internals.h > +++ b/linux-user/user-internals.h > @@ -102,7 +102,6 @@ int host_to_target_waitstatus(int status); > /* vm86.c */ > void save_v86_state(CPUX86State *env); > void handle_vm86_trap(CPUX86State *env, int trapno); > -void handle_vm86_fault(CPUX86State *env); > int do_vm86(CPUX86State *env, long subfunction, abi_ulong v86_addr); > #elif defined(TARGET_SPARC64) > void sparc64_set_context(CPUSPARCState *env); > diff --git a/linux-user/vm86.c b/linux-user/vm86.c > index 9f512a2242..31a2d707cf 100644 > --- a/linux-user/vm86.c > +++ b/linux-user/vm86.c > @@ -255,142 +255,6 @@ void handle_vm86_trap(CPUX86State *env, int trapno) > } > } > > -#define CHECK_IF_IN_TRAP() \ > - if ((ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_active) && \ > - (ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_TFpendig)) \ > - newflags |= TF_MASK > - > -#define VM86_FAULT_RETURN \ > - if ((ts->vm86plus.vm86plus.flags & TARGET_force_return_for_pic) && \ > - (ts->v86flags & (IF_MASK | VIF_MASK))) \ > - return_to_32bit(env, TARGET_VM86_PICRETURN); \ > - return > - > -void handle_vm86_fault(CPUX86State *env) > -{ > - CPUState *cs = env_cpu(env); > - TaskState *ts = get_task_state(cs); > - uint32_t csp, ssp; > - unsigned int ip, sp, newflags, newip, newcs, opcode, intno; > - int data32, pref_done; > - > - csp = env->segs[R_CS].selector << 4; > - ip = env->eip & 0xffff; > - > - ssp = env->segs[R_SS].selector << 4; > - sp = env->regs[R_ESP] & 0xffff; > - > - LOG_VM86("VM86 exception %04x:%08x\n", > - env->segs[R_CS].selector, env->eip); > - > - data32 = 0; > - pref_done = 0; > - do { > - opcode = vm_getb(env, csp, ip); > - ADD16(ip, 1); > - switch (opcode) { > - case 0x66: /* 32-bit data */ data32=1; break; > - case 0x67: /* 32-bit address */ break; > - case 0x2e: /* CS */ break; > - case 0x3e: /* DS */ break; > - case 0x26: /* ES */ break; > - case 0x36: /* SS */ break; > - case 0x65: /* GS */ break; > - case 0x64: /* FS */ break; > - case 0xf2: /* repnz */ break; > - case 0xf3: /* rep */ break; > - default: pref_done = 1; > - } > - } while (!pref_done); > - > - /* VM86 mode */ > - switch(opcode) { > - case 0x9c: /* pushf */ > - if (data32) { > - vm_putl(env, ssp, sp - 4, get_vflags(env)); > - ADD16(env->regs[R_ESP], -4); > - } else { > - vm_putw(env, ssp, sp - 2, get_vflags(env)); > - ADD16(env->regs[R_ESP], -2); > - } > - env->eip = ip; > - VM86_FAULT_RETURN; > - > - case 0x9d: /* popf */ > - if (data32) { > - newflags = vm_getl(env, ssp, sp); > - ADD16(env->regs[R_ESP], 4); > - } else { > - newflags = vm_getw(env, ssp, sp); > - ADD16(env->regs[R_ESP], 2); > - } > - env->eip = ip; > - CHECK_IF_IN_TRAP(); > - if (data32) { > - if (set_vflags_long(newflags, env)) > - return; > - } else { > - if (set_vflags_short(newflags, env)) > - return; > - } > - VM86_FAULT_RETURN; > - > - case 0xcd: /* int */ > - intno = vm_getb(env, csp, ip); > - ADD16(ip, 1); > - env->eip = ip; > - if (ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_active) { > - if ( (ts->vm86plus.vm86plus.vm86dbg_intxxtab[intno >> 3] >> > - (intno &7)) & 1) { > - return_to_32bit(env, TARGET_VM86_INTx + (intno << 8)); > - return; > - } > - } > - do_int(env, intno); > - break; > - > - case 0xcf: /* iret */ > - if (data32) { > - newip = vm_getl(env, ssp, sp) & 0xffff; > - newcs = vm_getl(env, ssp, sp + 4) & 0xffff; > - newflags = vm_getl(env, ssp, sp + 8); > - ADD16(env->regs[R_ESP], 12); > - } else { > - newip = vm_getw(env, ssp, sp); > - newcs = vm_getw(env, ssp, sp + 2); > - newflags = vm_getw(env, ssp, sp + 4); > - ADD16(env->regs[R_ESP], 6); > - } > - env->eip = newip; > - cpu_x86_load_seg(env, R_CS, newcs); > - CHECK_IF_IN_TRAP(); > - if (data32) { > - if (set_vflags_long(newflags, env)) > - return; > - } else { > - if (set_vflags_short(newflags, env)) > - return; > - } > - VM86_FAULT_RETURN; > - > - case 0xfa: /* cli */ > - env->eip = ip; > - clear_IF(env); > - VM86_FAULT_RETURN; > - > - case 0xfb: /* sti */ > - env->eip = ip; > - if (set_IF(env)) > - return; > - VM86_FAULT_RETURN; > - > - default: > - /* real VM86 GPF exception */ > - return_to_32bit(env, TARGET_VM86_UNKNOWN); > - break; > - } > -} FYI, looks like this broke compiling with Clang: ../../devel/qemu/linux-user/vm86.c:50:20: error: unused function 'vm_putl' [-Werror,-Wunused-function] 50 | static inline void vm_putl(CPUX86State *env, uint32_t segptr, | ^~~~~~~ ../../devel/qemu/linux-user/vm86.c:56:28: error: unused function 'vm_getb' [-Werror,-Wunused-function] 56 | static inline unsigned int vm_getb(CPUX86State *env, | ^~~~~~~ ../../devel/qemu/linux-user/vm86.c:62:28: error: unused function 'vm_getw' [-Werror,-Wunused-function] 62 | static inline unsigned int vm_getw(CPUX86State *env, | ^~~~~~~ ../../devel/qemu/linux-user/vm86.c:68:28: error: unused function 'vm_getl' [-Werror,-Wunused-function] 68 | static inline unsigned int vm_getl(CPUX86State *env, | ^~~~~~~ ../../devel/qemu/linux-user/vm86.c:165:19: error: unused function 'set_vflags_long' [-Werror,-Wunused-function] 165 | static inline int set_vflags_long(unsigned long eflags, CPUX86State *env) | ^~~~~~~~~~~~~~~ ../../devel/qemu/linux-user/vm86.c:179:19: error: unused function 'set_vflags_short' [-Werror,-Wunused-function] 179 | static inline int set_vflags_short(unsigned short flags, CPUX86State *env) | ^~~~~~~~~~~~~~~~ 6 errors generated. Should be easy to fix, I guess.. Thomas
On 11.10.2024 19:02, Thomas Huth wrote: > On 04/10/2024 18.03, Michael Tokarev wrote: >> From: "Dr. David Alan Gilbert" <dave@treblig.org> >> >> handle_vm86_fault has been unused since: >> 1ade5b2fed ("linux-user/i386: Split out maybe_handle_vm86_trap") >> >> Remove it, and it's local macros. > FYI, looks like this broke compiling with Clang: > > ../../devel/qemu/linux-user/vm86.c:50:20: error: unused function > 'vm_putl' [-Werror,-Wunused-function] > 50 | static inline void vm_putl(CPUX86State *env, uint32_t segptr, > | ^~~~~~~ > ../../devel/qemu/linux-user/vm86.c:56:28: error: unused function > 'vm_getb' [-Werror,-Wunused-function] ... Hm. I built it with clang before sending the MR. But it was clang16 - the most recent one on bookworm. It does not show this issue :) Apparently I should upgrade clang somehow. Thank you for the fix! /mjt
© 2016 - 2024 Red Hat, Inc.