From 0b718e0b7056adf63847d40134097c469a16984e Mon Sep 17 00:00:00 2001 From: pumnflqv2 Date: Tue, 5 Jul 2022 05:15:51 +0800 Subject: [PATCH] ADD file via upload --- cur/linux/kernel/math/math_emulate.c | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cur/linux/kernel/math/math_emulate.c diff --git a/cur/linux/kernel/math/math_emulate.c b/cur/linux/kernel/math/math_emulate.c new file mode 100644 index 0000000..825e528 --- /dev/null +++ b/cur/linux/kernel/math/math_emulate.c @@ -0,0 +1,42 @@ +/* + * linux/kernel/math/math_emulate.c + * + * (C) 1991 Linus Torvalds + */ + +/* + * This directory should contain the math-emulation code. + * Currently only results in a signal. + */ + +#include + +#include +#include +#include + +void math_emulate(long edi, long esi, long ebp, long sys_call_ret, + long eax,long ebx,long ecx,long edx, + unsigned short fs,unsigned short es,unsigned short ds, + unsigned long eip,unsigned short cs,unsigned long eflags, + unsigned short ss, unsigned long esp) +{ + unsigned char first, second; + +/* 0x0007 means user code space */ + if (cs != 0x000F) { + printk("math_emulate: %04x:%08x\n\r",cs,eip); + panic("Math emulation needed in kernel"); + } + first = get_fs_byte((char *)((*&eip)++)); + second = get_fs_byte((char *)((*&eip)++)); + printk("%04x:%08x %02x %02x\n\r",cs,eip-2,first,second); + current->signal |= 1<<(SIGFPE-1); +} + +void math_error(void) +{ + __asm__("fnclex"); + if (last_task_used_math) + last_task_used_math->signal |= 1<<(SIGFPE-1); +}