Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/arch Pull up following revision(s) (requested by maxv...
details: https://anonhg.NetBSD.org/src/rev/022617454f07
branches: netbsd-8
changeset: 434288:022617454f07
user: snj <snj%NetBSD.org@localhost>
date: Sat Sep 09 17:29:40 2017 +0000
description:
Pull up following revision(s) (requested by maxv in ticket #258):
sys/arch/amd64/conf/ALL: 1.68
sys/arch/i386/conf/ALL: 1.428
sys/arch/i386/i386/i386_trap.S: 1.12
sys/arch/i386/i386/locore.S: 1.149-1.150
sys/arch/x86/x86/sys_machdep.c: 1.38
Remove undocumented hack.
--
Switch to the temporary stack right away when booted via multiboot. GRUB
happens to give a correct stack, but it is not guaranteed by the spec. This
temporary stack will be reset later, which is fine.
Fixes PR/50245.
--
Pfff, use %ss and not %ds. The latter is controlled by userland, the former
contains the kernel value (flat); FreeBSD fixed this too a few weeks ago.
As I said earlier, this dtrace code is complete bullshit.
--
Don't allow userland to create 286/386 call gates anymore - they are not
used by Wine. While here, don't allow it to overwrite the static entries
either, don't allow unknown entry types, remove LDT_DEBUG, and style.
diffstat:
sys/arch/amd64/conf/ALL | 5 +-
sys/arch/i386/conf/ALL | 5 +-
sys/arch/i386/i386/i386_trap.S | 6 +-
sys/arch/i386/i386/locore.S | 32 +++---------
sys/arch/x86/x86/sys_machdep.c | 108 ++++++++++------------------------------
5 files changed, 43 insertions(+), 113 deletions(-)
diffs (truncated from 379 to 300 lines):
diff -r cc9996ef50df -r 022617454f07 sys/arch/amd64/conf/ALL
--- a/sys/arch/amd64/conf/ALL Sat Sep 09 17:01:23 2017 +0000
+++ b/sys/arch/amd64/conf/ALL Sat Sep 09 17:29:40 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.59 2017/05/27 22:53:29 bouyer Exp $
+# $NetBSD: ALL,v 1.59.2.1 2017/09/09 17:29:40 snj Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.59 $"
+#ident "ALL-$Revision: 1.59.2.1 $"
maxusers 64 # estimated number of users
@@ -2076,7 +2076,6 @@
options KUE_DEBUG
options LANA_DEBUG
options LCD_DEBUG
-options LDT_DEBUG
options LEDEBUG
options LE_DEBUG
options LIFDEBUG
diff -r cc9996ef50df -r 022617454f07 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL Sat Sep 09 17:01:23 2017 +0000
+++ b/sys/arch/i386/conf/ALL Sat Sep 09 17:29:40 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.419.2.1 2017/08/31 08:41:33 bouyer Exp $
+# $NetBSD: ALL,v 1.419.2.2 2017/09/09 17:29:40 snj Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.419.2.1 $"
+#ident "ALL-$Revision: 1.419.2.2 $"
maxusers 64 # estimated number of users
@@ -2230,7 +2230,6 @@
options KUE_DEBUG
options LANA_DEBUG
options LCD_DEBUG
-options LDT_DEBUG
options LEDEBUG
options LE_DEBUG
options LIFDEBUG
diff -r cc9996ef50df -r 022617454f07 sys/arch/i386/i386/i386_trap.S
--- a/sys/arch/i386/i386/i386_trap.S Sat Sep 09 17:01:23 2017 +0000
+++ b/sys/arch/i386/i386/i386_trap.S Sat Sep 09 17:29:40 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i386_trap.S,v 1.6.6.1 2017/08/01 23:18:30 snj Exp $ */
+/* $NetBSD: i386_trap.S,v 1.6.6.2 2017/09/09 17:29:40 snj Exp $ */
/*
* Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
#if 0
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.6.6.1 2017/08/01 23:18:30 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.6.6.2 2017/09/09 17:29:40 snj Exp $");
#endif
/*
@@ -139,7 +139,7 @@
SUPERALIGN_TEXT
IDTVEC(trap06)
/* Check if there is no DTrace hook registered. */
- cmpl $0,dtrace_invop_jump_addr
+ cmpl $0,%ss:dtrace_invop_jump_addr
je norm_ill
/* Check if this is a user fault. */
diff -r cc9996ef50df -r 022617454f07 sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S Sat Sep 09 17:01:23 2017 +0000
+++ b/sys/arch/i386/i386/locore.S Sat Sep 09 17:29:40 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.145.6.1 2017/07/05 19:59:29 snj Exp $ */
+/* $NetBSD: locore.S,v 1.145.6.2 2017/09/09 17:29:40 snj Exp $ */
/*
* Copyright-o-rama!
@@ -128,7 +128,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.145.6.1 2017/07/05 19:59:29 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.145.6.2 2017/09/09 17:29:40 snj Exp $");
#include "opt_compat_oldboot.h"
#include "opt_copy_symtab.h"
@@ -343,11 +343,13 @@
jne 1f
/*
- * Indeed, a multiboot-compliant boot loader executed us. We copy
- * the received Multiboot information structure into kernel's data
- * space to process it later -- after we are relocated. It will
- * be safer to run complex C code than doing it at this point.
+ * Indeed, a multiboot-compliant boot loader executed us. We switch
+ * to the temporary stack, and copy the received Multiboot information
+ * structure into kernel's data space to process it later -- after we
+ * are relocated. It will be safer to run complex C code than doing it
+ * at this point.
*/
+ movl $_RELOC(tmpstk),%esp
pushl %ebx /* Address of Multiboot information */
call _C_LABEL(multiboot_pre_reloc)
addl $4,%esp
@@ -842,24 +844,6 @@
addl $PDE_SIZE,%esp /* pop paddr_t */
addl $NGDT*8,%esp /* pop temporary gdt */
-#ifdef SAFARI_FIFO_HACK
- movb $5,%al
- movw $0x37b,%dx
- outb %al,%dx
- movw $0x37f,%dx
- inb %dx,%al
- movb %al,%cl
-
- orb $1,%cl
-
- movb $5,%al
- movw $0x37b,%dx
- outb %al,%dx
- movw $0x37f,%dx
- movb %cl,%al
- outb %al,%dx
-#endif /* SAFARI_FIFO_HACK */
-
call _C_LABEL(main)
#else /* XEN */
/* First, reset the PSL. */
diff -r cc9996ef50df -r 022617454f07 sys/arch/x86/x86/sys_machdep.c
--- a/sys/arch/x86/x86/sys_machdep.c Sat Sep 09 17:01:23 2017 +0000
+++ b/sys/arch/x86/x86/sys_machdep.c Sat Sep 09 17:29:40 2017 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: sys_machdep.c,v 1.35.6.1 2017/08/01 23:18:30 snj Exp $ */
+/* $NetBSD: sys_machdep.c,v 1.35.6.2 2017/09/09 17:29:41 snj Exp $ */
-/*-
- * Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
+/*
+ * Copyright (c) 1998, 2007, 2009, 2017 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum, and by Andrew Doran.
+ * by Charles M. Hannum, by Andrew Doran, and by Maxime Villard.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.35.6.1 2017/08/01 23:18:30 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.35.6.2 2017/09/09 17:29:41 snj Exp $");
#include "opt_mtrr.h"
#include "opt_pmc.h"
@@ -117,19 +117,6 @@
int x86_get_sdbase32(void *, char);
int x86_get_sdbase(void *, char);
-#if defined(USER_LDT) && defined(LDT_DEBUG)
-static void x86_print_ldt(int, const struct segment_descriptor *);
-
-static void
-x86_print_ldt(int i, const struct segment_descriptor *d)
-{
- printf("[%d] lolimit=0x%x, lobase=0x%x, type=%u, dpl=%u, p=%u, "
- "hilimit=0x%x, xx=%x, def32=%u, gran=%u, hibase=0x%x\n",
- i, d->sd_lolimit, d->sd_lobase, d->sd_type, d->sd_dpl, d->sd_p,
- d->sd_hilimit, d->sd_xx, d->sd_def32, d->sd_gran, d->sd_hibase);
-}
-#endif
-
int
x86_get_ldt(struct lwp *l, void *args, register_t *retval)
{
@@ -172,24 +159,23 @@
int nldt, num;
union descriptor *lp;
+#ifdef __x86_64__
+ const size_t min_ldt_size = LDT_SIZE;
+#else
+ const size_t min_ldt_size = NLDT * sizeof(union descriptor);
+#endif
+
error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_LDT_GET,
NULL, NULL, NULL, NULL);
if (error)
- return (error);
-
-#ifdef LDT_DEBUG
- printf("x86_get_ldt: start=%d num=%d descs=%p\n", ua->start,
- ua->num, ua->desc);
-#endif
+ return error;
if (ua->start < 0 || ua->num < 0 || ua->start > 8192 || ua->num > 8192 ||
ua->start + ua->num > 8192)
- return (EINVAL);
+ return EINVAL;
-#ifdef __x86_64__
- if (ua->start * sizeof(union descriptor) < LDT_SIZE)
+ if (ua->start * sizeof(union descriptor) < min_ldt_size)
return EINVAL;
-#endif
mutex_enter(&cpu_lock);
@@ -207,19 +193,12 @@
if (ua->start > nldt) {
mutex_exit(&cpu_lock);
- return (EINVAL);
+ return EINVAL;
}
lp += ua->start;
num = min(ua->num, nldt - ua->start);
ua->num = num;
-#ifdef LDT_DEBUG
- {
- int i;
- for (i = 0; i < num; i++)
- x86_print_ldt(i, &lp[i].sd);
- }
-#endif
memcpy(cp, lp, num * sizeof(union descriptor));
mutex_exit(&cpu_lock);
@@ -239,7 +218,7 @@
int error;
if ((error = copyin(args, &ua, sizeof(ua))) != 0)
- return (error);
+ return error;
if (ua.num < 0 || ua.num > 8192)
return EINVAL;
@@ -280,16 +259,14 @@
error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_LDT_SET,
NULL, NULL, NULL, NULL);
if (error)
- return (error);
+ return error;
if (ua->start < 0 || ua->num < 0 || ua->start > 8192 || ua->num > 8192 ||
ua->start + ua->num > 8192)
- return (EINVAL);
+ return EINVAL;
-#ifdef __x86_64__
- if (ua->start * sizeof(union descriptor) < LDT_SIZE)
+ if (ua->start * sizeof(union descriptor) < min_ldt_size)
return EINVAL;
-#endif
/* Check descriptors for access violations. */
for (i = 0; i < ua->num; i++) {
@@ -299,29 +276,6 @@
case SDT_SYSNULL:
desc->sd.sd_p = 0;
break;
-#ifdef __x86_64__
- case SDT_SYS286CGT:
- case SDT_SYS386CGT:
- /* We don't allow these on amd64. */
- return EACCES;
-#else
- case SDT_SYS286CGT:
- case SDT_SYS386CGT:
- /*
- * Only allow call gates targeting a segment
- * in the LDT or a user segment in the fixed
- * part of the gdt. Segments in the LDT are
- * constrained (below) to be user segments.
- */
- if (desc->gd.gd_p != 0 &&
- !ISLDT(desc->gd.gd_selector) &&
- ((IDXSEL(desc->gd.gd_selector) >= NGDT) ||
- (gdtstore[IDXSEL(desc->gd.gd_selector)].sd.sd_dpl !=
- SEL_UPL))) {
- return EACCES;
- }
- break;
-#endif
case SDT_MEMEC:
Home |
Main Index |
Thread Index |
Old Index