Enable the NX bit feature for Xen i386pae and amd64 kernels.

Tested with Xen 3.1 and Xen 3.3, dom0 and domU, by bouyer@ and jym@.

Ok bouyer@.
This commit is contained in:
jym 2010-05-04 23:27:13 +00:00
parent d3a30408f7
commit d66ce3b289
7 changed files with 22 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.144 2010/04/18 23:47:50 jym Exp $ */
/* $NetBSD: machdep.c,v 1.145 2010/05/04 23:27:13 jym Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@ -107,7 +107,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.144 2010/04/18 23:47:50 jym Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.145 2010/05/04 23:27:13 jym Exp $");
/* #define XENDEBUG_LOW */
@ -1253,7 +1253,6 @@ init_x86_64(paddr_t first_avail)
#endif /* XEN */
cpu_feature[0] &= ~CPUID_FEAT_BLACKLIST;
cpu_feature[2] &= ~CPUID_EXT_FEAT_BLACKLIST;
cpu_init_msrs(&cpu_info_primary, true);

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.686 2010/04/23 16:07:33 joerg Exp $ */
/* $NetBSD: machdep.c,v 1.687 2010/05/04 23:27:13 jym Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.686 2010/04/23 16:07:33 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.687 2010/05/04 23:27:13 jym Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@ -1299,7 +1299,6 @@ init386(paddr_t first_avail)
pcb = lwp_getpcb(&lwp0);
cpu_feature[0] &= ~CPUID_FEAT_BLACKLIST;
cpu_feature[2] &= ~CPUID_EXT_FEAT_BLACKLIST;
cpu_init_msrs(&cpu_info_primary, true);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.256 2010/04/23 19:18:09 rmind Exp $ */
/* $NetBSD: trap.c,v 1.257 2010/05/04 23:27:13 jym Exp $ */
/*-
* Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.256 2010/04/23 19:18:09 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.257 2010/05/04 23:27:13 jym Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -671,6 +671,8 @@ faultcommon:
map = &vm->vm_map;
if (frame->tf_err & PGEX_W)
ftype = VM_PROT_WRITE;
else if (frame->tf_err & PGEX_X)
ftype = VM_PROT_EXECUTE;
else
ftype = VM_PROT_READ;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pte.h,v 1.22 2010/04/06 20:43:57 jld Exp $ */
/* $NetBSD: pte.h,v 1.23 2010/05/04 23:27:14 jym Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@ -274,5 +274,6 @@ typedef uint32_t pt_entry_t; /* PTE */
#define PGEX_P 0x01 /* protection violation (vs. no mapping) */
#define PGEX_W 0x02 /* exception during a write cycle */
#define PGEX_U 0x04 /* exception while in user mode (upl) */
#define PGEX_X 0x10 /* exception during instruction fetch */
#endif /* _I386_PTE_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: specialreg.h,v 1.40 2010/04/18 23:47:51 jym Exp $ */
/* $NetBSD: specialreg.h,v 1.41 2010/05/04 23:27:14 jym Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@ -262,10 +262,8 @@
#ifdef XEN
/* Not on Xen */
#define CPUID_FEAT_BLACKLIST (CPUID_PGE|CPUID_PSE|CPUID_MTRR|CPUID_FXSR)
#define CPUID_EXT_FEAT_BLACKLIST (CPUID_NOX)
#else
#define CPUID_FEAT_BLACKLIST 0
#define CPUID_EXT_FEAT_BLACKLIST 0
#endif /* XEN */
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.107 2010/04/18 23:47:51 jym Exp $ */
/* $NetBSD: pmap.c,v 1.108 2010/05/04 23:27:14 jym Exp $ */
/*
* Copyright (c) 2007 Manuel Bouyer.
@ -149,7 +149,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2010/04/18 23:47:51 jym Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.108 2010/05/04 23:27:14 jym Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@ -1146,10 +1146,9 @@ pmap_kenter_ma(vaddr_t va, paddr_t ma, vm_prot_t prot, u_int flags)
if (flags & PMAP_NOCACHE)
npte |= PG_N;
#ifndef XEN
if ((cpu_feature[2] & CPUID_NOX) && !(prot & VM_PROT_EXECUTE))
npte |= PG_NX;
#endif
opte = pmap_pte_testset (pte, npte); /* zap! */
if (pmap_valid_entry(opte)) {
@ -1268,14 +1267,13 @@ pmap_bootstrap(vaddr_t kva_start)
struct pcb *pcb;
int i;
vaddr_t kva;
#ifdef XEN
pt_entry_t pg_nx = 0;
#else
#ifndef XEN
unsigned long p1i;
vaddr_t kva_end;
pt_entry_t pg_nx = (cpu_feature[2] & CPUID_NOX ? PG_NX : 0);
#endif
pt_entry_t pg_nx = (cpu_feature[2] & CPUID_NOX ? PG_NX : 0);
/*
* set up our local static global vars that keep track of the
* usage of KVM before kernel_map is set up

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.43 2010/04/18 23:47:52 jym Exp $ */
/* $NetBSD: cpu.c,v 1.44 2010/05/04 23:27:14 jym Exp $ */
/* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp */
/*-
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.43 2010/04/18 23:47:52 jym Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.44 2010/05/04 23:27:14 jym Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -1005,6 +1005,9 @@ cpu_init_msrs(struct cpu_info *ci, bool full)
HYPERVISOR_set_segment_base (SEGBASE_GS_USER, 0);
}
#endif /* __x86_64__ */
if (cpu_feature[2] & CPUID_NOX)
wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NXE);
}
void