From: Ben Gras Date: Tue, 8 May 2007 15:43:00 +0000 (+0000) Subject: Restore user-owned bits from PSW after a signal handler, instead of X-Git-Tag: v3.1.4~381 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch11.html?a=commitdiff_plain;h=b00f2874490fcf135807c3510206697f8bb7aa6a;p=minix.git Restore user-owned bits from PSW after a signal handler, instead of copying complete PSW after signal handler. This fixes a psw corruption bug reported by Jens de Smit . --- diff --git a/include/ibm/cpu.h b/include/ibm/cpu.h index 691ca11db..ff885b32c 100755 --- a/include/ibm/cpu.h +++ b/include/ibm/cpu.h @@ -1,15 +1,19 @@ #ifndef _IBM_CPU_H #define _IBM_CPU_H 1 -#define X86_FLAG_C (1L << 0) /* Carry */ -#define X86_FLAG_P (1L << 2) /* Parity */ -#define X86_FLAG_A (1L << 4) /* Aux. carry */ -#define X86_FLAG_Z (1L << 6) /* Zero */ -#define X86_FLAG_S (1L << 7) /* Sign */ - -#define X86_FLAG_T (1L << 8) /* Trap */ -#define X86_FLAG_I (1L << 9) /* Interrupt */ -#define X86_FLAG_D (1L << 10) /* Direction */ -#define X86_FLAG_O (1L << 11) /* Overflow */ +#define X86_FLAG_C (1L << 0) /* S Carry */ +#define X86_FLAG_P (1L << 2) /* S Parity */ +#define X86_FLAG_A (1L << 4) /* S Aux. carry */ +#define X86_FLAG_Z (1L << 6) /* S Zero */ +#define X86_FLAG_S (1L << 7) /* S Sign */ + +#define X86_FLAG_T (1L << 8) /* X Trap */ +#define X86_FLAG_I (1L << 9) /* X Interrupt */ +#define X86_FLAG_D (1L << 10) /* C Direction */ +#define X86_FLAG_O (1L << 11) /* S Overflow */ + +/* User flags are S (Status) and C (Control) flags. */ +#define X86_FLAGS_USER (X86_FLAG_C | X86_FLAG_P | X86_FLAG_A | X86_FLAG_Z | \ + X86_FLAG_S | X86_FLAG_D | X86_FLAG_O) #endif diff --git a/kernel/system/do_sigreturn.c b/kernel/system/do_sigreturn.c index 97a99c34a..894260d44 100644 --- a/kernel/system/do_sigreturn.c +++ b/kernel/system/do_sigreturn.c @@ -10,6 +10,7 @@ #include "../system.h" #include #include +#include #include #if USE_SIGRETURN @@ -38,7 +39,9 @@ message *m_ptr; /* pointer to request message */ if (src_phys == 0) return(EFAULT); phys_copy(src_phys, vir2phys(&sc), (phys_bytes) sizeof(struct sigcontext)); - sc.sc_psw = rp->p_reg.psw; + /* Restore user bits of psw from sc, maintain system bits from proc. */ + sc.sc_psw = (sc.sc_psw & X86_FLAGS_USER) | + (rp->p_reg.psw & ~X86_FLAGS_USER); #if (_MINIX_CHIP == _CHIP_INTEL) /* Don't panic kernel if user gave bad selectors. */