aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/pc98/i386/machdep.c18
-rw-r--r--sys/pc98/pc98/machdep.c18
2 files changed, 36 insertions, 0 deletions
diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c
index 5f2952aa20ac..f63a452ce7a6 100644
--- a/sys/pc98/i386/machdep.c
+++ b/sys/pc98/i386/machdep.c
@@ -2511,6 +2511,24 @@ set_dbregs(p, dbregs)
struct dbreg *dbregs;
{
struct pcb *pcb;
+ int i;
+ u_int32_t mask1, mask2;
+
+ /*
+ * Don't let an illegal value for dr7 get set. Specifically,
+ * check for undefined settings. Setting these bit patterns
+ * result in undefined behaviour and can lead to an unexpected
+ * TRCTRAP.
+ */
+ for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8;
+ i++, mask1 <<= 2, mask2 <<= 2)
+ if ((dbregs->dr7 & mask1) == mask2)
+ return (EINVAL);
+
+ if (dbregs->dr7 & 0x0000fc00)
+ return (EINVAL);
+
+
pcb = &p->p_addr->u_pcb;
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index 5f2952aa20ac..f63a452ce7a6 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -2511,6 +2511,24 @@ set_dbregs(p, dbregs)
struct dbreg *dbregs;
{
struct pcb *pcb;
+ int i;
+ u_int32_t mask1, mask2;
+
+ /*
+ * Don't let an illegal value for dr7 get set. Specifically,
+ * check for undefined settings. Setting these bit patterns
+ * result in undefined behaviour and can lead to an unexpected
+ * TRCTRAP.
+ */
+ for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8;
+ i++, mask1 <<= 2, mask2 <<= 2)
+ if ((dbregs->dr7 & mask1) == mask2)
+ return (EINVAL);
+
+ if (dbregs->dr7 & 0x0000fc00)
+ return (EINVAL);
+
+
pcb = &p->p_addr->u_pcb;