Module Name: src
Committed By: maxv
Date: Sun Jan 13 10:01:07 UTC 2019
Modified Files:
src/sys/arch/x86/include: dbregs.h
src/sys/arch/x86/x86: dbregs.c
Log Message:
Error out if the higher 32 bits of DR6 and DR7 are set. MOV DR would
fault otherwise.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/include/dbregs.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/x86/dbregs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/include/dbregs.h
diff -u src/sys/arch/x86/include/dbregs.h:1.7 src/sys/arch/x86/include/dbregs.h:1.8
--- src/sys/arch/x86/include/dbregs.h:1.7 Thu Sep 27 13:04:22 2018
+++ src/sys/arch/x86/include/dbregs.h Sun Jan 13 10:01:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dbregs.h,v 1.7 2018/09/27 13:04:22 maxv Exp $ */
+/* $NetBSD: dbregs.h,v 1.8 2019/01/13 10:01:07 maxv Exp $ */
/*
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@
#define X86_DR6_DEBUG_REGISTER_ACCESS_DETECTED __BIT(13)
#define X86_DR6_SINGLE_STEP __BIT(14)
#define X86_DR6_TASK_SWITCH __BIT(15)
+#define X86_DR6_MBZ __BITS(32, 63)
/*
* CPU Debug Control Register (DR7)
@@ -67,7 +68,6 @@
#define X86_DR7_GLOBAL_EXACT_BREAKPOINT __BIT(9)
#define X86_DR7_RESTRICTED_TRANSACTIONAL_MEMORY __BIT(11)
#define X86_DR7_GENERAL_DETECT_ENABLE __BIT(13)
-
#define X86_DR7_DR0_CONDITION_MASK __BITS(16, 17)
#define X86_DR7_DR0_LENGTH_MASK __BITS(18, 19)
#define X86_DR7_DR1_CONDITION_MASK __BITS(20, 21)
@@ -76,6 +76,7 @@
#define X86_DR7_DR2_LENGTH_MASK __BITS(26, 27)
#define X86_DR7_DR3_CONDITION_MASK __BITS(28, 29)
#define X86_DR7_DR3_LENGTH_MASK __BITS(30, 31)
+#define X86_DR7_MBZ __BITS(32, 63)
/*
* X86_DR7_CONDITION_IO_READWRITE is currently unused. It requires DE
Index: src/sys/arch/x86/x86/dbregs.c
diff -u src/sys/arch/x86/x86/dbregs.c:1.12 src/sys/arch/x86/x86/dbregs.c:1.13
--- src/sys/arch/x86/x86/dbregs.c:1.12 Thu Sep 27 13:04:21 2018
+++ src/sys/arch/x86/x86/dbregs.c Sun Jan 13 10:01:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dbregs.c,v 1.12 2018/09/27 13:04:21 maxv Exp $ */
+/* $NetBSD: dbregs.c,v 1.13 2019/01/13 10:01:07 maxv Exp $ */
/*
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -256,6 +256,12 @@ x86_dbregs_validate(const struct dbreg *
return EINVAL;
}
+ if (regs->dr[6] & X86_DR6_MBZ) {
+ return EINVAL;
+ }
+ if (regs->dr[7] & X86_DR7_MBZ) {
+ return EINVAL;
+ }
if (regs->dr[7] & X86_DR7_GENERAL_DETECT_ENABLE) {
return EINVAL;
}