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 the following revisions, requested by ma...
details: https://anonhg.NetBSD.org/src/rev/329f6159a069
branches: netbsd-8
changeset: 434752:329f6159a069
user: martin <martin%NetBSD.org@localhost>
date: Sat Mar 17 11:23:18 2018 +0000
description:
Pull up the following revisions, requested by maxv in ticket #637:
sys/arch/amd64/amd64/process_machdep.c 1.33,1.34,1.35 (patch)
sys/arch/amd64/include/types.h 1.55 (patch)
sys/arch/x86/x86/vm_machdep.c 1.33 (patch)
- Reduce the number of places where segment register faults can
occur.
- Remove __HAVE_CPU_UAREA_ROUTINES.
diffstat:
sys/arch/amd64/amd64/process_machdep.c | 72 +++++++++++++++++++++++++++------
sys/arch/amd64/include/cpu.h | 5 +-
sys/arch/amd64/include/types.h | 3 +-
sys/arch/x86/x86/vm_machdep.c | 59 +--------------------------
4 files changed, 62 insertions(+), 77 deletions(-)
diffs (289 lines):
diff -r 1738ff6ad6f8 -r 329f6159a069 sys/arch/amd64/amd64/process_machdep.c
--- a/sys/arch/amd64/amd64/process_machdep.c Sat Mar 17 11:19:27 2018 +0000
+++ b/sys/arch/amd64/amd64/process_machdep.c Sat Mar 17 11:23:18 2018 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: process_machdep.c,v 1.32 2017/02/23 03:34:22 kamil Exp $ */
+/* $NetBSD: process_machdep.c,v 1.32.6.1 2018/03/17 11:23:18 martin Exp $ */
-/*-
+/*
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -71,13 +71,13 @@
*
* process_set_pc(proc)
* Set the process's program counter.
- *
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.32 2017/02/23 03:34:22 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.32.6.1 2018/03/17 11:23:18 martin Exp $");
+#include "opt_xen.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/time.h>
@@ -93,33 +93,39 @@
#include <x86/fpu.h>
static inline struct trapframe *process_frame(struct lwp *);
-#if 0
-static inline int verr_gdt(struct pmap *, int sel);
-static inline int verr_ldt(struct pmap *, int sel);
-#endif
static inline struct trapframe *
process_frame(struct lwp *l)
{
- return (l->l_md.md_regs);
+ return l->l_md.md_regs;
}
int
process_read_regs(struct lwp *l, struct reg *regs)
{
struct trapframe *tf = process_frame(l);
+ struct proc *p = l->l_proc;
+
+ if (p->p_flag & PK_32) {
+ return EINVAL;
+ }
#define copy_to_reg(reg, REG, idx) regs->regs[_REG_##REG] = tf->tf_##reg;
_FRAME_GREG(copy_to_reg)
#undef copy_to_reg
- return (0);
+ return 0;
}
int
process_read_fpregs(struct lwp *l, struct fpreg *regs, size_t *sz)
{
+ struct proc *p = l->l_proc;
+
+ if (p->p_flag & PK_32) {
+ return EINVAL;
+ }
process_read_fpregs_xmm(l, ®s->fxstate);
@@ -129,6 +135,11 @@
int
process_read_dbregs(struct lwp *l, struct dbreg *regs, size_t *sz)
{
+ struct proc *p = l->l_proc;
+
+ if (p->p_flag & PK_32) {
+ return EINVAL;
+ }
x86_dbregs_read(l, regs);
@@ -139,8 +150,14 @@
process_write_regs(struct lwp *l, const struct reg *regp)
{
struct trapframe *tf = process_frame(l);
+ struct proc *p = l->l_proc;
int error;
const long *regs = regp->regs;
+ int err, trapno;
+
+ if (p->p_flag & PK_32) {
+ return EINVAL;
+ }
/*
* Check for security violations.
@@ -151,16 +168,33 @@
if (error != 0)
return error;
+ err = tf->tf_err;
+ trapno = tf->tf_trapno;
+
#define copy_to_frame(reg, REG, idx) tf->tf_##reg = regs[_REG_##REG];
_FRAME_GREG(copy_to_frame)
#undef copy_to_frame
- return (0);
+ tf->tf_err = err;
+ tf->tf_trapno = trapno;
+
+#ifdef XEN
+ /* see comment in cpu_setmcontext */
+ tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
+ tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
+#endif
+
+ return 0;
}
int
process_write_fpregs(struct lwp *l, const struct fpreg *regs, size_t sz)
{
+ struct proc *p = l->l_proc;
+
+ if (p->p_flag & PK_32) {
+ return EINVAL;
+ }
process_write_fpregs_xmm(l, ®s->fxstate);
return 0;
@@ -169,8 +203,13 @@
int
process_write_dbregs(struct lwp *l, const struct dbreg *regs, size_t sz)
{
+ struct proc *p = l->l_proc;
int error;
+ if (p->p_flag & PK_32) {
+ return EINVAL;
+ }
+
/*
* Check for security violations.
*/
@@ -193,17 +232,22 @@
else
tf->tf_rflags &= ~PSL_T;
- return (0);
+ return 0;
}
int
process_set_pc(struct lwp *l, void *addr)
{
struct trapframe *tf = process_frame(l);
+ struct proc *p = l->l_proc;
- if ((uint64_t)addr > VM_MAXUSER_ADDRESS)
+ if (p->p_flag & PK_32) {
+ return EINVAL;
+ }
+
+ if ((uint64_t)addr >= VM_MAXUSER_ADDRESS)
return EINVAL;
tf->tf_rip = (uint64_t)addr;
- return (0);
+ return 0;
}
diff -r 1738ff6ad6f8 -r 329f6159a069 sys/arch/amd64/include/cpu.h
--- a/sys/arch/amd64/include/cpu.h Sat Mar 17 11:19:27 2018 +0000
+++ b/sys/arch/amd64/include/cpu.h Sat Mar 17 11:23:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.60 2012/01/21 16:48:56 chs Exp $ */
+/* $NetBSD: cpu.h,v 1.60.40.1 2018/03/17 11:23:18 martin Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -89,9 +89,6 @@
#define CLKF_INTR(frame) (curcpu()->ci_idepth > 0)
#define LWP_PC(l) ((l)->l_md.md_regs->tf_rip)
-void *cpu_uarea_alloc(bool);
-bool cpu_uarea_free(void *);
-
#endif /* _KERNEL */
#else /* __x86_64__ */
diff -r 1738ff6ad6f8 -r 329f6159a069 sys/arch/amd64/include/types.h
--- a/sys/arch/amd64/include/types.h Sat Mar 17 11:19:27 2018 +0000
+++ b/sys/arch/amd64/include/types.h Sat Mar 17 11:23:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.52.6.1 2018/03/16 13:17:56 martin Exp $ */
+/* $NetBSD: types.h,v 1.52.6.2 2018/03/17 11:23:18 martin Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -106,7 +106,6 @@
#define __HAVE_DIRECT_MAP 1
#define __HAVE_MM_MD_DIRECT_MAPPED_IO
#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS
-#define __HAVE_CPU_UAREA_ROUTINES
#if !defined(NO_PCI_MSI_MSIX)
#define __HAVE_PCI_MSI_MSIX
#endif
diff -r 1738ff6ad6f8 -r 329f6159a069 sys/arch/x86/x86/vm_machdep.c
--- a/sys/arch/x86/x86/vm_machdep.c Sat Mar 17 11:19:27 2018 +0000
+++ b/sys/arch/x86/x86/vm_machdep.c Sat Mar 17 11:23:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.28.6.1 2018/01/01 19:09:04 snj Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.28.6.2 2018/03/17 11:23:18 martin Exp $ */
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.28.6.1 2018/01/01 19:09:04 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.28.6.2 2018/03/17 11:23:18 martin Exp $");
#include "opt_mtrr.h"
@@ -360,58 +360,3 @@
bp->b_data = bp->b_saveaddr;
bp->b_saveaddr = 0;
}
-
-#ifdef __HAVE_CPU_UAREA_ROUTINES
-void *
-cpu_uarea_alloc(bool system)
-{
- struct pglist pglist;
- int error;
-
- /*
- * Allocate a new physically contiguous uarea which can be
- * direct-mapped.
- */
- error = uvm_pglistalloc(USPACE, 0, ptoa(physmem), 0, 0, &pglist, 1, 1);
- if (error) {
- return NULL;
- }
-
- /*
- * Get the physical address from the first page.
- */
- const struct vm_page * const pg = TAILQ_FIRST(&pglist);
- KASSERT(pg != NULL);
- const paddr_t pa = VM_PAGE_TO_PHYS(pg);
-
- /*
- * We need to return a direct-mapped VA for the pa.
- */
-
- return (void *)PMAP_MAP_POOLPAGE(pa);
-}
-
-/*
- * Return true if we freed it, false if we didn't.
- */
-bool
-cpu_uarea_free(void *vva)
-{
- vaddr_t va = (vaddr_t) vva;
-
- if (va >= VM_MIN_KERNEL_ADDRESS && va < VM_MAX_KERNEL_ADDRESS) {
- return false;
- }
-
- /*
- * Since the pages are physically contiguous, the vm_page structures
- * will be as well.
- */
- struct vm_page *pg = PHYS_TO_VM_PAGE(PMAP_UNMAP_POOLPAGE(va));
- KASSERT(pg != NULL);
- for (size_t i = 0; i < UPAGES; i++, pg++) {
- uvm_pagefree(pg);
- }
- return true;
-}
-#endif /* __HAVE_CPU_UAREA_ROUTINES */
Home |
Main Index |
Thread Index |
Old Index