Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 295765 Details for
Bug 311431
kernel BUG at mm/rmap.c:479 during suspend/resume testing
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Another version of the PROT_NONE patch that actually compiles on x86_64
linux-2.6.9-xen-prot_none3.patch (text/plain), 20.50 KB, created by
Chris Lalancette
on 2008-02-25 05:12:54 UTC
(
hide
)
Description:
Another version of the PROT_NONE patch that actually compiles on x86_64
Filename:
MIME Type:
Creator:
Chris Lalancette
Created:
2008-02-25 05:12:54 UTC
Size:
20.50 KB
patch
obsolete
>diff -urp linux-2.6.9.orig/include/asm-i386/mach-xen/asm/maddr.h linux-2.6.9/include/asm-i386/mach-xen/asm/maddr.h >--- linux-2.6.9.orig/include/asm-i386/mach-xen/asm/maddr.h 2008-02-24 23:45:37.000000000 -0500 >+++ linux-2.6.9/include/asm-i386/mach-xen/asm/maddr.h 2008-02-24 23:48:28.000000000 -0500 >@@ -9,9 +9,19 @@ > #define FOREIGN_FRAME_BIT (1UL<<31) > #define FOREIGN_FRAME(m) ((m) | FOREIGN_FRAME_BIT) > >+/* Definitions for machine and pseudophysical addresses. */ >+#ifdef CONFIG_X86_PAE >+typedef unsigned long long paddr_t; >+typedef unsigned long long maddr_t; >+#else >+typedef unsigned long paddr_t; >+typedef unsigned long maddr_t; >+#endif >+ > #ifdef CONFIG_XEN > > extern unsigned long *phys_to_machine_mapping; >+extern unsigned long max_mapnr; > > #undef machine_to_phys_mapping > extern unsigned long *machine_to_phys_mapping; >@@ -21,20 +31,20 @@ static inline unsigned long pfn_to_mfn(u > { > if (xen_feature(XENFEAT_auto_translated_physmap)) > return pfn; >- return phys_to_machine_mapping[(unsigned int)(pfn)] & >- ~FOREIGN_FRAME_BIT; >+ BUG_ON(max_mapnr && pfn >= max_mapnr); >+ return phys_to_machine_mapping[pfn] & ~FOREIGN_FRAME_BIT; > } > > static inline int phys_to_machine_mapping_valid(unsigned long pfn) > { > if (xen_feature(XENFEAT_auto_translated_physmap)) > return 1; >+ BUG_ON(max_mapnr && pfn >= max_mapnr); > return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY); > } > > static inline unsigned long mfn_to_pfn(unsigned long mfn) > { >- extern unsigned long max_mapnr; > unsigned long pfn; > > if (xen_feature(XENFEAT_auto_translated_physmap)) >@@ -83,7 +93,6 @@ static inline unsigned long mfn_to_pfn(u > */ > static inline unsigned long mfn_to_local_pfn(unsigned long mfn) > { >- extern unsigned long max_mapnr; > unsigned long pfn = mfn_to_pfn(mfn); > if ((pfn < max_mapnr) > && !xen_feature(XENFEAT_auto_translated_physmap) >@@ -94,6 +103,7 @@ static inline unsigned long mfn_to_local > > static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn) > { >+ BUG_ON(max_mapnr && pfn >= max_mapnr); > if (xen_feature(XENFEAT_auto_translated_physmap)) { > BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); > return; >@@ -101,6 +111,20 @@ static inline void set_phys_to_machine(u > phys_to_machine_mapping[pfn] = mfn; > } > >+#ifdef CONFIG_X86_PAE >+static inline paddr_t pte_phys_to_machine(paddr_t phys) >+{ >+ /* >+ * In PAE mode, the NX bit needs to be dealt with in the value >+ * passed to pfn_to_mfn(). On x86_64, we need to mask it off, >+ * but for i386 the conversion to ulong for the argument will >+ * clip it off. >+ */ >+ maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT); >+ machine = (machine << PAGE_SHIFT) | (phys & ~PHYSICAL_PAGE_MASK); >+ return machine; >+} >+#endif > > #else /* !CONFIG_XEN */ > >@@ -112,21 +136,13 @@ static inline void set_phys_to_machine(u > > #endif /* !CONFIG_XEN */ > >-/* Definitions for machine and pseudophysical addresses. */ >-#ifdef CONFIG_X86_PAE >-typedef unsigned long long paddr_t; >-typedef unsigned long long maddr_t; >-#else >-typedef unsigned long paddr_t; >-typedef unsigned long maddr_t; >-#endif >- > static inline maddr_t phys_to_machine(paddr_t phys) > { > maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT); > machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK); > return machine; > } >+ > static inline paddr_t machine_to_phys(maddr_t machine) > { > paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT); >@@ -134,6 +150,47 @@ static inline paddr_t machine_to_phys(ma > return phys; > } > >+static inline paddr_t pte_machine_to_phys(maddr_t machine) >+{ >+ /* >+ * In PAE mode, the NX bit needs to be dealt with in the value >+ * passed to mfn_to_pfn(). On x86_64, we need to mask it off, >+ * but for i386 the conversion to ulong for the argument will >+ * clip it off. >+ */ >+ paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT); >+ phys = (phys << PAGE_SHIFT) | (machine & ~PHYSICAL_PAGE_MASK); >+ return phys; >+} >+ >+#ifdef CONFIG_X86_PAE >+static inline paddr_t pte_phys_to_machine(paddr_t phys) >+{ >+ /* >+ * In PAE mode, the NX bit needs to be dealt with in the value >+ * passed to pfn_to_mfn(). On x86_64, we need to mask it off, >+ * but for i386 the conversion to ulong for the argument will >+ * clip it off. >+ */ >+ maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT); >+ machine = (machine << PAGE_SHIFT) | (phys & ~PHYSICAL_PAGE_MASK); >+ return machine; >+} >+ >+static inline paddr_t pte_machine_to_phys(maddr_t machine) >+{ >+ /* >+ * In PAE mode, the NX bit needs to be dealt with in the value >+ * passed to mfn_to_pfn(). On x86_64, we need to mask it off, >+ * but for i386 the conversion to ulong for the argument will >+ * clip it off. >+ */ >+ paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT); >+ phys = (phys << PAGE_SHIFT) | (machine & ~PHYSICAL_PAGE_MASK); >+ return phys; >+} >+#endif >+ > /* VIRT <-> MACHINE conversion */ > #define virt_to_machine(v) (phys_to_machine(__pa(v))) > #define virt_to_mfn(v) (pfn_to_mfn(__pa(v) >> PAGE_SHIFT)) >diff -urp linux-2.6.9.orig/include/asm-i386/mach-xen/asm/page.h linux-2.6.9/include/asm-i386/mach-xen/asm/page.h >--- linux-2.6.9.orig/include/asm-i386/mach-xen/asm/page.h 2008-02-24 23:45:37.000000000 -0500 >+++ linux-2.6.9/include/asm-i386/mach-xen/asm/page.h 2008-02-24 23:48:28.000000000 -0500 >@@ -8,6 +8,16 @@ > #define PAGE_SIZE (1UL << PAGE_SHIFT) > #define PAGE_MASK (~(PAGE_SIZE-1)) > >+#ifdef CONFIG_X86_PAE >+#define __PHYSICAL_MASK_SHIFT 36 >+#define __PHYSICAL_MASK ((1ULL << __PHYSICAL_MASK_SHIFT) - 1) >+#define PHYSICAL_PAGE_MASK (~((1ULL << PAGE_SHIFT) - 1) & __PHYSICAL_MASK) >+#else >+#define __PHYSICAL_MASK_SHIFT 32 >+#define __PHYSICAL_MASK (~0UL) >+#define PHYSICAL_PAGE_MASK (PAGE_MASK & __PHYSICAL_MASK) >+#endif >+ > #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) > #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT) > >@@ -22,6 +32,13 @@ > #include <xen/features.h> > #include <xen/foreign_page.h> > >+/* >+ * Need to repeat this here in order to not include pgtable.h (which in turn >+ * depends on definitions made here), but to be able to use the symbolic >+ * below. The preprocessor will warn if the two definitions aren't identical. >+ */ >+#define _PAGE_PRESENT 0x001 >+ > #define arch_free_page(_page,_order) \ > ({ int foreign = PageForeign(_page); \ > if (foreign) \ >@@ -70,40 +87,38 @@ typedef struct { unsigned long long pgpr > #define pgprot_val(x) ((x).pgprot) > #include <asm/maddr.h> > #define __pte(x) ({ unsigned long long _x = (x); \ >- if (_x & 1) _x = phys_to_machine(_x); \ >+ if (_x & _PAGE_PRESENT) _x = pte_phys_to_machine(_x); \ > ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); }) > #define __pgd(x) ({ unsigned long long _x = (x); \ >- (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); }) >+ (pgd_t) {((_x) & _PAGE_PRESENT) ? pte_phys_to_machine(_x) : (_x)}; }) > #define __pmd(x) ({ unsigned long long _x = (x); \ >- (((_x)&1) ? ((pmd_t) {phys_to_machine(_x)}) : ((pmd_t) {(_x)})); }) >+ (pmd_t) {((_x) & _PAGE_PRESENT) ? pte_phys_to_machine(_x) : (_x)}; }) >+static inline unsigned long long pte_val_ma(pte_t x) >+{ >+ return ((unsigned long long)x.pte_high << 32) | x.pte_low; >+} > static inline unsigned long long pte_val(pte_t x) > { >- unsigned long long ret; >- >- if (x.pte_low) { >- ret = x.pte_low | (unsigned long long)x.pte_high << 32; >- ret = machine_to_phys(ret) | 1; >- } else { >- ret = 0; >- } >+ unsigned long long ret = pte_val_ma(x); >+ if (x.pte_low & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); > return ret; > } > static inline unsigned long long pmd_val(pmd_t x) > { > unsigned long long ret = x.pmd; >- if (ret) ret = machine_to_phys(ret) | 1; >+#ifdef CONFIG_XEN_COMPAT_030002 >+ if (ret) ret = pte_machine_to_phys(ret) | _PAGE_PRESENT; >+#else >+ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); >+#endif > return ret; > } > static inline unsigned long long pgd_val(pgd_t x) > { > unsigned long long ret = x.pgd; >- if (ret) ret = machine_to_phys(ret) | 1; >+ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); > return ret; > } >-static inline unsigned long long pte_val_ma(pte_t x) >-{ >- return (unsigned long long)x.pte_high << 32 | x.pte_low; >-} > #define HPAGE_SHIFT 21 > #else > #define nx_enabled 0 >@@ -114,17 +129,22 @@ typedef struct { unsigned long pgprot; } > #define pgprot_val(x) ((x).pgprot) > #include <asm/maddr.h> > #define boot_pte_t pte_t /* or would you rather have a typedef */ >-#define pte_val(x) (((x).pte_low & 1) ? machine_to_phys((x).pte_low) : \ >+#define pte_val(x) (((x).pte_low & _PAGE_PRESENT) ? \ >+ machine_to_phys((x).pte_low) : \ > (x).pte_low) > #define pte_val_ma(x) ((x).pte_low) > #define __pte(x) ({ unsigned long _x = (x); \ >- (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); }) >+ (pte_t) {((_x) & _PAGE_PRESENT) ? phys_to_machine(_x) : (_x)}; }) > #define __pgd(x) ({ unsigned long _x = (x); \ >- (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); }) >+ (pgd_t) {((_x) & _PAGE_PRESENT) ? phys_to_machine(_x) : (_x)}; }) > static inline unsigned long pgd_val(pgd_t x) > { > unsigned long ret = x.pgd; >- if (ret) ret = machine_to_phys(ret) | 1; >+#if CONFIG_XEN_COMPAT <= 0x030002 >+ if (ret) ret = machine_to_phys(ret) | _PAGE_PRESENT; >+#else >+ if (ret & _PAGE_PRESENT) ret = machine_to_phys(ret); >+#endif > return ret; > } > #define HPAGE_SHIFT 22 >@@ -144,7 +164,7 @@ static inline unsigned long long pmd_val > #define __pmd(x) ({ unsigned long _x = (x); \ > (((_x)&1) ? ((pmd_t) {phys_to_machine(_x)}) : ((pmd_t) {(_x)})); }) > #endif >-#define PTE_MASK PAGE_MASK >+#define PTE_MASK PHYSICAL_PAGE_MASK > > #ifdef CONFIG_HUGETLB_PAGE > #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) >diff -urp linux-2.6.9.orig/include/asm-i386/mach-xen/asm/pgtable-2level.h linux-2.6.9/include/asm-i386/mach-xen/asm/pgtable-2level.h >--- linux-2.6.9.orig/include/asm-i386/mach-xen/asm/pgtable-2level.h 2008-02-24 23:45:37.000000000 -0500 >+++ linux-2.6.9/include/asm-i386/mach-xen/asm/pgtable-2level.h 2008-02-24 23:48:28.000000000 -0500 >@@ -72,9 +72,12 @@ static inline pte_t ptep_get_and_clear(p > mm_track(ptep); > return __pte_ma(xchg(&(ptep)->pte_low, 0)); > } >-#define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT) >-#define pte_pfn(_pte) mfn_to_local_pfn(pte_mfn(_pte)) >-#define pte_same(a, b) ((a).pte_low == (b).pte_low) >+#define __pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT) >+#define pte_mfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \ >+ __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte))) >+#define pte_pfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \ >+ mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte)) >+ > #define pte_page(x) pfn_to_page(pte_pfn(x)) > #define pte_none(x) (!(x).pte_low) > #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) >diff -urp linux-2.6.9.orig/include/asm-i386/mach-xen/asm/pgtable-3level.h linux-2.6.9/include/asm-i386/mach-xen/asm/pgtable-3level.h >--- linux-2.6.9.orig/include/asm-i386/mach-xen/asm/pgtable-3level.h 2008-02-24 23:45:37.000000000 -0500 >+++ linux-2.6.9/include/asm-i386/mach-xen/asm/pgtable-3level.h 2008-02-24 23:48:28.000000000 -0500 >@@ -146,20 +146,24 @@ static inline int pte_none(pte_t pte) > return !pte.pte_low && !pte.pte_high; > } > >-#define pte_mfn(_pte) (((_pte).pte_low >> PAGE_SHIFT) |\ >- (((_pte).pte_high & 0xfff) << (32-PAGE_SHIFT))) >-#define pte_pfn(_pte) mfn_to_local_pfn(pte_mfn(_pte)) >+#define __pte_mfn(_pte) (((_pte).pte_low >> PAGE_SHIFT) | \ >+ ((_pte).pte_high << (32-PAGE_SHIFT))) >+#define pte_mfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \ >+ __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte))) >+#define pte_pfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \ >+ mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte)) > > extern unsigned long long __supported_pte_mask; > > static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) > { >- return pfn_pte_ma(pfn_to_mfn(page_nr), pgprot); >+ return __pte((((unsigned long long)page_nr << PAGE_SHIFT) | >+ pgprot_val(pgprot)) & __supported_pte_mask); > } > > static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) > { >- return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) | \ >+ return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) | > pgprot_val(pgprot)) & __supported_pte_mask); > } > >diff -urp linux-2.6.9.orig/include/asm-i386/mach-xen/asm/pgtable.h linux-2.6.9/include/asm-i386/mach-xen/asm/pgtable.h >--- linux-2.6.9.orig/include/asm-i386/mach-xen/asm/pgtable.h 2008-02-24 23:45:37.000000000 -0500 >+++ linux-2.6.9/include/asm-i386/mach-xen/asm/pgtable.h 2008-02-24 23:48:28.000000000 -0500 >@@ -294,18 +294,19 @@ static inline void ptep_mkdirty(pte_t *p > > static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) > { >- pte.pte_low &= _PAGE_CHG_MASK; >- pte.pte_low |= pgprot_val(newprot); >-#ifdef CONFIG_X86_PAE > /* >- * Chop off the NX bit (if present), and add the NX portion of >- * the newprot (if present): >+ * Since this might change the present bit (which controls whether >+ * a pte_t object has undergone p2m translation), we must use >+ * pte_val() on the input pte and __pte() for the return value. > */ >- pte.pte_high &= ~(1 << (_PAGE_BIT_NX - 32)); >- pte.pte_high |= (pgprot_val(newprot) >> 32) & \ >- (__supported_pte_mask >> 32); >+ paddr_t pteval = pte_val(pte); >+ >+ pteval &= _PAGE_CHG_MASK; >+ pteval |= pgprot_val(newprot); >+#ifdef CONFIG_X86_PAE >+ pteval &= __supported_pte_mask; > #endif >- return pte; >+ return __pte(pteval); > } > > #define page_pte(page) page_pte_prot(page, __pgprot(0)) >diff -urp linux-2.6.9.orig/include/asm-x86_64/mach-xen/asm/maddr.h linux-2.6.9/include/asm-x86_64/mach-xen/asm/maddr.h >--- linux-2.6.9.orig/include/asm-x86_64/mach-xen/asm/maddr.h 2008-02-24 23:45:37.000000000 -0500 >+++ linux-2.6.9/include/asm-x86_64/mach-xen/asm/maddr.h 2008-02-24 23:48:28.000000000 -0500 >@@ -21,14 +21,15 @@ static inline unsigned long pfn_to_mfn(u > { > if (xen_feature(XENFEAT_auto_translated_physmap)) > return pfn; >- return phys_to_machine_mapping[(unsigned int)(pfn)] & >- ~FOREIGN_FRAME_BIT; >+ BUG_ON(end_pfn && pfn >= end_pfn); >+ return phys_to_machine_mapping[pfn] & ~FOREIGN_FRAME_BIT; > } > > static inline int phys_to_machine_mapping_valid(unsigned long pfn) > { > if (xen_feature(XENFEAT_auto_translated_physmap)) > return 1; >+ BUG_ON(end_pfn && pfn >= end_pfn); > return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY); > } > >@@ -92,6 +93,7 @@ static inline unsigned long mfn_to_local > > static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn) > { >+ BUG_ON(end_pfn && pfn >= end_pfn); > if (xen_feature(XENFEAT_auto_translated_physmap)) { > BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); > return; >@@ -127,6 +129,22 @@ static inline paddr_t machine_to_phys(ma > return phys; > } > >+static inline paddr_t pte_phys_to_machine(paddr_t phys) >+{ >+ maddr_t machine; >+ machine = pfn_to_mfn((phys & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT); >+ machine = (machine << PAGE_SHIFT) | (phys & ~PHYSICAL_PAGE_MASK); >+ return machine; >+} >+ >+static inline paddr_t pte_machine_to_phys(maddr_t machine) >+{ >+ paddr_t phys; >+ phys = mfn_to_pfn((machine & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT); >+ phys = (phys << PAGE_SHIFT) | (machine & ~PHYSICAL_PAGE_MASK); >+ return phys; >+} >+ > /* VIRT <-> MACHINE conversion */ > #define virt_to_machine(v) (phys_to_machine(__pa(v))) > #define virt_to_mfn(v) (pfn_to_mfn(__pa(v) >> PAGE_SHIFT)) >diff -urp linux-2.6.9.orig/include/asm-x86_64/mach-xen/asm/page.h linux-2.6.9/include/asm-x86_64/mach-xen/asm/page.h >--- linux-2.6.9.orig/include/asm-x86_64/mach-xen/asm/page.h 2008-02-24 23:45:37.000000000 -0500 >+++ linux-2.6.9/include/asm-x86_64/mach-xen/asm/page.h 2008-02-24 23:51:39.000000000 -0500 >@@ -12,6 +12,13 @@ > #include <xen/interface/xen.h> > #include <xen/foreign_page.h> > >+/* >+ * Need to repeat this here in order to not include pgtable.h (which in turn >+ * depends on definitions made here), but to be able to use the symbolic >+ * below. The preprocessor will warn if the two definitions aren't identical. >+ */ >+#define _PAGE_PRESENT 0x001 >+ > #define arch_free_page(_page,_order) \ > ({ int foreign = PageForeign(_page); \ > if (foreign) \ >@@ -34,12 +41,14 @@ > #define PAGE_SIZE (1UL << PAGE_SHIFT) > #endif > #define PAGE_MASK (~(PAGE_SIZE-1)) >+ > /* See Documentation/x86_64/mm.txt for a description of the memory map. */ >-#define __PHYSICAL_MASK_SHIFT 40 >+#define __PHYSICAL_MASK_SHIFT 46 > #define __PHYSICAL_MASK ((1UL << __PHYSICAL_MASK_SHIFT) - 1) >-#define __VIRTUAL_MASK_SHIFT 48 /* P3: Incorrect, we use 39 in RHEL 4 */ >+#define __VIRTUAL_MASK_SHIFT 48 > #define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1) >-#define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & (__PHYSICAL_MASK << PAGE_SHIFT)) >+ >+#define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK) > #define PTE_MASK PHYSICAL_PAGE_MASK > > #define THREAD_ORDER 1 >@@ -101,35 +110,33 @@ typedef struct { unsigned long pml4; } p > > typedef struct { unsigned long pgprot; } pgprot_t; > >-static inline paddr_t pte_machine_to_phys(maddr_t machine) >-{ >- paddr_t phys = mfn_to_pfn((machine & PTE_MASK) >> PAGE_SHIFT); >- phys = (phys << PAGE_SHIFT) | (machine & ~PTE_MASK); >- return phys; >-} >- >-#define pte_val(x) (((x).pte & 1) ? pte_machine_to_phys((x).pte) : \ >+#define pte_val(x) (((x).pte & _PAGE_PRESENT) ? \ >+ pte_machine_to_phys((x).pte) : \ > (x).pte) > #define pte_val_ma(x) ((x).pte) > > static inline unsigned long pmd_val(pmd_t x) > { > unsigned long ret = x.pmd; >- if (ret) ret = pte_machine_to_phys(ret); >+#ifdef CONFIG_XEN_COMPAT_030002 >+ if (ret) ret = pte_machine_to_phys(ret) | _PAGE_PRESENT; >+#else >+ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); >+#endif > return ret; > } > > static inline unsigned long pgd_val(pgd_t x) > { > unsigned long ret = x.pgd; >- if (ret) ret = pte_machine_to_phys(ret); >+ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); > return ret; > } > > static inline unsigned long pml4_val(pml4_t x) > { > unsigned long ret = x.pml4; >- if (ret) ret = pte_machine_to_phys(ret); >+ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); > return ret; > } > >@@ -139,25 +146,25 @@ static inline unsigned long pml4_val(pml > > static inline pte_t __pte(unsigned long x) > { >- if (x & 1) x = phys_to_machine(x); >+ if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x); > return ((pte_t) { (x) }); > } > > static inline pmd_t __pmd(unsigned long x) > { >- if ((x & 1)) x = phys_to_machine(x); >+ if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x); > return ((pmd_t) { (x) }); > } > > static inline pgd_t __pgd(unsigned long x) > { >- if ((x & 1)) x = phys_to_machine(x); >+ if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x); > return ((pgd_t) { (x) }); > } > > static inline pml4_t __pml4(unsigned long x) > { >- if ((x & 1)) x = phys_to_machine(x); >+ if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x); > return ((pml4_t) { (x) }); > } > >diff -urp linux-2.6.9.orig/include/asm-x86_64/mach-xen/asm/pgtable.h linux-2.6.9/include/asm-x86_64/mach-xen/asm/pgtable.h >--- linux-2.6.9.orig/include/asm-x86_64/mach-xen/asm/pgtable.h 2008-02-24 23:45:37.000000000 -0500 >+++ linux-2.6.9/include/asm-x86_64/mach-xen/asm/pgtable.h 2008-02-24 23:48:28.000000000 -0500 >@@ -285,17 +285,20 @@ static inline unsigned long pml4_bad(pml > > #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) /* FIXME: is this > right? */ >-#define pte_mfn(_pte) (((_pte).pte & PTE_MASK) >> PAGE_SHIFT) >-#define pte_pfn(_pte) mfn_to_local_pfn(pte_mfn(_pte)) >+#define __pte_mfn(_pte) (((_pte).pte & PTE_MASK) >> PAGE_SHIFT) >+#define pte_mfn(_pte) ((_pte).pte & _PAGE_PRESENT ? \ >+ __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte))) >+#define pte_pfn(_pte) ((_pte).pte & _PAGE_PRESENT ? \ >+ mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte)) >+ > #define pte_page(x) pfn_to_page(pte_pfn(x)) > > static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) > { >- pte_t pte; >- (pte).pte = (pfn_to_mfn(page_nr) << PAGE_SHIFT); >- (pte).pte |= pgprot_val(pgprot); >- (pte).pte &= __supported_pte_mask; >- return pte; >+ unsigned long pte = page_nr << PAGE_SHIFT; >+ pte |= pgprot_val(pgprot); >+ pte &= __supported_pte_mask; >+ return __pte(pte); > } > > #define pfn_pte_ma(pfn, prot) __pte_ma((((pfn) << PAGE_SHIFT) | pgprot_val(prot)) & __supported_pte_mask) >@@ -464,18 +467,25 @@ static inline pgd_t *current_pgd_offset_ > /* physical address -> PTE */ > static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot) > { >- pte_t pte; >- (pte).pte = physpage | pgprot_val(pgprot); >- return pte; >+ unsigned long pteval; >+ pteval = physpage | pgprot_val(pgprot); >+ return __pte(pteval); > } > > /* Change flags of a PTE */ > extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot) > { >- (pte).pte &= _PAGE_CHG_MASK; >- (pte).pte |= pgprot_val(newprot); >- (pte).pte &= __supported_pte_mask; >- return pte; >+ /* >+ * Since this might change the present bit (which controls whether >+ * a pte_t object has undergone p2m translation), we must use >+ * pte_val() on the input pte and __pte() for the return value. >+ */ >+ unsigned long pteval = pte_val(pte); >+ >+ pteval &= _PAGE_CHG_MASK; >+ pteval |= pgprot_val(newprot); >+ pteval &= __supported_pte_mask; >+ return __pte(pteval); > } > > #define pte_index(address) \
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 311431
:
210741
|
210751
|
295746
| 295765