summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-11-11 01:32:35 +0000
committerjhb <jhb@FreeBSD.org>2015-11-11 01:32:35 +0000
commit9c319c0ee46b77f68febe6ec66b2e787d91e1627 (patch)
treee3ff827d472df36acb14e1d6e06240194ee25406 /sys/i386
parent5033903e2b91c8722c776318d671e7bee03179ba (diff)
downloadFreeBSD-src-9c319c0ee46b77f68febe6ec66b2e787d91e1627.zip
FreeBSD-src-9c319c0ee46b77f68febe6ec66b2e787d91e1627.tar.gz
MFC 284324,290164:
Workaround debuggers that try to read the full 32-bit words holding selectors in trapframes. 284324: Ensure that the upper 16 bits of segment registers manually saved in trapframes are cleared by explicitly pushing a zero and then moving the segment register into the low 16 bits. Certain Intel processors treat a push of a segment register as a move of the segment register into the low 16 bits leaving the upper 16 bits of the word in the stack unchanged. 290164: Use movw instead of movl (or plain mov) when moving segment registers into memory. This is a nop on clang's assembler, but some assemblers complain if the size suffix is incorrect.
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/exception.s36
-rw-r--r--sys/i386/include/asmacros.h9
2 files changed, 30 insertions, 15 deletions
diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s
index 58cd3e8..9386ada 100644
--- a/sys/i386/i386/exception.s
+++ b/sys/i386/i386/exception.s
@@ -158,9 +158,12 @@ IDTVEC(xmm)
.type alltraps,@function
alltraps:
pushal
- pushl %ds
- pushl %es
- pushl %fs
+ pushl $0
+ movw %ds,(%esp)
+ pushl $0
+ movw %es,(%esp)
+ pushl $0
+ movw %fs,(%esp)
alltraps_with_regs_pushed:
SET_KERNEL_SREGS
cld
@@ -234,9 +237,12 @@ IDTVEC(lcall_syscall)
pushl $7 /* sizeof "lcall 7,0" */
subl $4,%esp /* skip over tf_trapno */
pushal
- pushl %ds
- pushl %es
- pushl %fs
+ pushl $0
+ movw %ds,(%esp)
+ pushl $0
+ movw %es,(%esp)
+ pushl $0
+ movw %fs,(%esp)
SET_KERNEL_SREGS
cld
FAKE_MCOUNT(TF_EIP(%esp))
@@ -260,9 +266,12 @@ IDTVEC(int0x80_syscall)
pushl $2 /* sizeof "int 0x80" */
subl $4,%esp /* skip over tf_trapno */
pushal
- pushl %ds
- pushl %es
- pushl %fs
+ pushl $0
+ movw %ds,(%esp)
+ pushl $0
+ movw %es,(%esp)
+ pushl $0
+ movw %fs,(%esp)
SET_KERNEL_SREGS
cld
FAKE_MCOUNT(TF_EIP(%esp))
@@ -417,13 +426,16 @@ doreti_iret:
doreti_iret_fault:
subl $8,%esp
pushal
- pushl %ds
+ pushl $0
+ movw %ds,(%esp)
.globl doreti_popl_ds_fault
doreti_popl_ds_fault:
- pushl %es
+ pushl $0
+ movw %es,(%esp)
.globl doreti_popl_es_fault
doreti_popl_es_fault:
- pushl %fs
+ pushl $0
+ movw %fs,(%esp)
.globl doreti_popl_fs_fault
doreti_popl_fs_fault:
sti
diff --git a/sys/i386/include/asmacros.h b/sys/i386/include/asmacros.h
index c1c3f64..ef08d03 100644
--- a/sys/i386/include/asmacros.h
+++ b/sys/i386/include/asmacros.h
@@ -146,9 +146,12 @@
pushl $0 ; /* dummy error code */ \
pushl $0 ; /* dummy trap type */ \
pushal ; /* 8 ints */ \
- pushl %ds ; /* save data and extra segments ... */ \
- pushl %es ; \
- pushl %fs
+ pushl $0 ; /* save data and extra segments ... */ \
+ movw %ds,(%esp) ; \
+ pushl $0 ; \
+ movw %es,(%esp) ; \
+ pushl $0 ; \
+ movw %fs,(%esp)
#define POP_FRAME \
popl %fs ; \
OpenPOWER on IntegriCloud