Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/amd64 Fix netbsd32_process_write_dbregs() for...



details:   https://anonhg.NetBSD.org/src/rev/b0c39a6d0f9a
branches:  trunk
changeset: 465384:b0c39a6d0f9a
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Nov 20 10:57:08 2019 +0000

description:
Fix netbsd32_process_write_dbregs() for amd64:

- Zero-clear regs64 so that random values are not written into the
  preserved registers.
- Cast 32-bit registers (int) to u_int, in order to avoid undesired
  sign extension when filled into 64-bit registers (long).

XXX
pullup to netbsd-9

diffstat:

 sys/arch/amd64/amd64/netbsd32_machdep.c |  18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diffs (40 lines):

diff -r fa7138eaf611 -r b0c39a6d0f9a sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c   Wed Nov 20 10:26:56 2019 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c   Wed Nov 20 10:57:08 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.129 2019/11/10 21:16:22 chs Exp $       */
+/*     $NetBSD: netbsd32_machdep.c,v 1.130 2019/11/20 10:57:08 rin Exp $       */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.129 2019/11/10 21:16:22 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.130 2019/11/20 10:57:08 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -487,13 +487,15 @@
                return EINVAL;
        }
 
-       regs64.dr[0] = regs->dr[0];
-       regs64.dr[1] = regs->dr[1];
-       regs64.dr[2] = regs->dr[2];
-       regs64.dr[3] = regs->dr[3];
+       memset(&regs64, 0, sizeof(regs64));
 
-       regs64.dr[6] = regs->dr[6];
-       regs64.dr[7] = regs->dr[7];
+       regs64.dr[0] = (u_int)regs->dr[0];
+       regs64.dr[1] = (u_int)regs->dr[1];
+       regs64.dr[2] = (u_int)regs->dr[2];
+       regs64.dr[3] = (u_int)regs->dr[3];
+
+       regs64.dr[6] = (u_int)regs->dr[6];
+       regs64.dr[7] = (u_int)regs->dr[7];
 
        x86_dbregs_write(l, &regs64);
        return 0;



Home | Main Index | Thread Index | Old Index