diff options
author | ru <ru@FreeBSD.org> | 2007-04-06 18:15:03 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2007-04-06 18:15:03 +0000 |
commit | 754d500925e9a87c3e7033cdc4c5bb351cc13fc2 (patch) | |
tree | 9e733007036c8815c464b9e9850e903fc3668831 /sys/i386/include | |
parent | d4909d3f260573c6d441042b491b81be22487231 (diff) | |
download | FreeBSD-src-754d500925e9a87c3e7033cdc4c5bb351cc13fc2.zip FreeBSD-src-754d500925e9a87c3e7033cdc4c5bb351cc13fc2.tar.gz |
Add the PG_NX support for i386/PAE.
Reviewed by: alc
Diffstat (limited to 'sys/i386/include')
-rw-r--r-- | sys/i386/include/pmap.h | 37 | ||||
-rw-r--r-- | sys/i386/include/specialreg.h | 8 | ||||
-rw-r--r-- | sys/i386/include/vmparam.h | 2 |
3 files changed, 45 insertions, 2 deletions
diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h index 95a0c42..775c29e 100644 --- a/sys/i386/include/pmap.h +++ b/sys/i386/include/pmap.h @@ -63,12 +63,21 @@ #define PG_AVAIL2 0x400 /* < programmers use */ #define PG_AVAIL3 0x800 /* \ */ #define PG_PDE_PAT 0x1000 /* PAT PAT index */ +#ifdef PAE +#define PG_NX (1ull<<63) /* No-execute */ +#endif /* Our various interpretations of the above */ #define PG_W PG_AVAIL1 /* "Wired" pseudoflag */ #define PG_MANAGED PG_AVAIL2 -#define PG_FRAME (~((vm_paddr_t)PAGE_MASK)) +#ifdef PAE +#define PG_FRAME (0x000ffffffffff000ull) +#define PG_PS_FRAME (0x000fffffffe00000ull) +#else +#define PG_FRAME (~PAGE_MASK) +#define PG_PS_FRAME (0xffc00000) +#endif #define PG_PROT (PG_RW|PG_U) /* all protection bits . */ #define PG_N (PG_NC_PWT|PG_NC_PCD) /* Non-cacheable */ @@ -79,6 +88,7 @@ #define PGEX_P 0x01 /* Protection violation vs. not present */ #define PGEX_W 0x02 /* during a Write cycle */ #define PGEX_U 0x04 /* access from User mode (UPL) */ +#define PGEX_I 0x10 /* during an instruction fetch */ /* * Size of Kernel address space. This is the number of page table pages @@ -201,7 +211,7 @@ pmap_kextract(vm_offset_t va) vm_paddr_t pa; if ((pa = PTD[va >> PDRSHIFT]) & PG_PS) { - pa = (pa & ~(NBPDR - 1)) | (va & (NBPDR - 1)); + pa = (pa & PG_PS_FRAME) | (va & PDRMASK); } else { pa = *vtopte(va); pa = (pa & PG_FRAME) | (va & PAGE_MASK); @@ -238,10 +248,33 @@ pte_load_store(pt_entry_t *ptep, pt_entry_t v) return (r); } +/* XXXRU move to atomic.h? */ +static __inline int +atomic_cmpset_64(volatile uint64_t *dst, uint64_t exp, uint64_t src) +{ + int64_t res = exp; + + __asm __volatile ( + " lock ; " + " cmpxchg8b %2 ; " + " setz %%al ; " + " movzbl %%al,%0 ; " + "# atomic_cmpset_64" + : "+A" (res), /* 0 (result) */ + "=m" (*dst) /* 1 */ + : "m" (*dst), /* 2 */ + "b" ((uint32_t)src), + "c" ((uint32_t)(src >> 32))); + + return (res); +} + #define pte_load_clear(ptep) pte_load_store((ptep), (pt_entry_t)0ULL) #define pte_store(ptep, pte) pte_load_store((ptep), (pt_entry_t)pte) +extern pt_entry_t pg_nx; + #else /* PAE */ static __inline pt_entry_t diff --git a/sys/i386/include/specialreg.h b/sys/i386/include/specialreg.h index f89760f..9fa01ee 100644 --- a/sys/i386/include/specialreg.h +++ b/sys/i386/include/specialreg.h @@ -68,6 +68,11 @@ #define CR4_XMM 0x00000400 /* enable SIMD/MMX2 to use except 16 */ /* + * Bits in AMD64 special registers. EFER is 64 bits wide. + */ +#define EFER_NXE 0x000000800 /* PTE No-Execute bit enable (R/W) */ + +/* * CPUID instruction features register */ #define CPUID_FPU 0x00000001 @@ -420,6 +425,9 @@ #define AMD_WT_ALLOC_PRE 0x20000 /* programmable range enable */ #define AMD_WT_ALLOC_FRE 0x10000 /* fixed (A0000-FFFFF) range enable */ +/* AMD64 MSR's */ +#define MSR_EFER 0xc0000080 /* extended features */ + /* VIA ACE crypto featureset: for via_feature_rng */ #define VIA_HAS_RNG 1 /* cpu has RNG */ diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h index a94408a..53c3f45 100644 --- a/sys/i386/include/vmparam.h +++ b/sys/i386/include/vmparam.h @@ -43,7 +43,9 @@ * Machine dependent constants for 386. */ +#ifndef PAE #define VM_PROT_READ_IS_EXEC /* if you can read -- then you can exec */ +#endif /* * Virtual memory related constants, all in bytes |