ia64/xen-unstable

changeset 12438:ade94aa072c5

[LINUX] Preserve flags when converting PTEs from machine to phys.
Signed-off-by: John Byrne <john.l.byrne@hp.com>
author kfraser@localhost.localdomain
date Tue Nov 14 11:57:53 2006 +0000 (2006-11-14)
parents 9d88f224b7f1
children 680b37789200
files linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h	Tue Nov 14 11:55:58 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h	Tue Nov 14 11:57:53 2006 +0000
     1.3 @@ -127,6 +127,7 @@ static inline maddr_t phys_to_machine(pa
     1.4  	machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
     1.5  	return machine;
     1.6  }
     1.7 +
     1.8  static inline paddr_t machine_to_phys(maddr_t machine)
     1.9  {
    1.10  	paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
    1.11 @@ -134,6 +135,19 @@ static inline paddr_t machine_to_phys(ma
    1.12  	return phys;
    1.13  }
    1.14  
    1.15 +static inline paddr_t pte_machine_to_phys(maddr_t machine)
    1.16 +{
    1.17 +	/*
    1.18 +	 * In PAE mode, the NX bit needs to be dealt with in the value
    1.19 +	 * passed to mfn_to_pfn(). On x86_64, we need to mask it off,
    1.20 +	 * but for i386 the conversion to ulong for the argument will
    1.21 +	 * clip it off.
    1.22 +	 */
    1.23 +	paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
    1.24 +	phys = (phys << PAGE_SHIFT) | (machine & ~PHYSICAL_PAGE_MASK);
    1.25 +	return phys;
    1.26 +}
    1.27 +
    1.28  /* VIRT <-> MACHINE conversion */
    1.29  #define virt_to_machine(v)	(phys_to_machine(__pa(v)))
    1.30  #define virt_to_mfn(v)		(pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
     2.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h	Tue Nov 14 11:55:58 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h	Tue Nov 14 11:57:53 2006 +0000
     2.3 @@ -6,6 +6,16 @@
     2.4  #define PAGE_SIZE	(1UL << PAGE_SHIFT)
     2.5  #define PAGE_MASK	(~(PAGE_SIZE-1))
     2.6  
     2.7 +#ifdef CONFIG_X86_PAE
     2.8 +#define __PHYSICAL_MASK_SHIFT	36
     2.9 +#define __PHYSICAL_MASK		((1ULL << __PHYSICAL_MASK_SHIFT) - 1)
    2.10 +#define PHYSICAL_PAGE_MASK	(~((1ULL << PAGE_SHIFT) - 1) & __PHYSICAL_MASK)
    2.11 +#else
    2.12 +#define __PHYSICAL_MASK_SHIFT	32
    2.13 +#define __PHYSICAL_MASK		(~0UL)
    2.14 +#define PHYSICAL_PAGE_MASK	(PAGE_MASK & __PHYSICAL_MASK)
    2.15 +#endif
    2.16 +
    2.17  #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
    2.18  #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
    2.19  
    2.20 @@ -85,7 +95,7 @@ static inline unsigned long long pte_val
    2.21  
    2.22  	if (x.pte_low) {
    2.23  		ret = x.pte_low | (unsigned long long)x.pte_high << 32;
    2.24 -		ret = machine_to_phys(ret) | 1;
    2.25 +		ret = pte_machine_to_phys(ret) | 1;
    2.26  	} else {
    2.27  		ret = 0;
    2.28  	}
    2.29 @@ -94,13 +104,13 @@ static inline unsigned long long pte_val
    2.30  static inline unsigned long long pmd_val(pmd_t x)
    2.31  {
    2.32  	unsigned long long ret = x.pmd;
    2.33 -	if (ret) ret = machine_to_phys(ret) | 1;
    2.34 +	if (ret) ret = pte_machine_to_phys(ret) | 1;
    2.35  	return ret;
    2.36  }
    2.37  static inline unsigned long long pgd_val(pgd_t x)
    2.38  {
    2.39  	unsigned long long ret = x.pgd;
    2.40 -	if (ret) ret = machine_to_phys(ret) | 1;
    2.41 +	if (ret) ret = pte_machine_to_phys(ret) | 1;
    2.42  	return ret;
    2.43  }
    2.44  static inline unsigned long long pte_val_ma(pte_t x)
    2.45 @@ -115,7 +125,8 @@ typedef struct { unsigned long pgprot; }
    2.46  #define pgprot_val(x)	((x).pgprot)
    2.47  #include <asm/maddr.h>
    2.48  #define boot_pte_t pte_t /* or would you rather have a typedef */
    2.49 -#define pte_val(x)	(((x).pte_low & 1) ? machine_to_phys((x).pte_low) : \
    2.50 +#define pte_val(x)	(((x).pte_low & 1) ? \
    2.51 +			 pte_machine_to_phys((x).pte_low) : \
    2.52  			 (x).pte_low)
    2.53  #define pte_val_ma(x)	((x).pte_low)
    2.54  #define __pte(x) ({ unsigned long _x = (x); \
    2.55 @@ -125,7 +136,7 @@ typedef struct { unsigned long pgprot; }
    2.56  static inline unsigned long pgd_val(pgd_t x)
    2.57  {
    2.58  	unsigned long ret = x.pgd;
    2.59 -	if (ret) ret = machine_to_phys(ret) | 1;
    2.60 +	if (ret) ret = pte_machine_to_phys(ret) | 1;
    2.61  	return ret;
    2.62  }
    2.63  #define HPAGE_SHIFT	22
     3.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h	Tue Nov 14 11:55:58 2006 +0000
     3.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h	Tue Nov 14 11:57:53 2006 +0000
     3.3 @@ -127,6 +127,14 @@ static inline paddr_t machine_to_phys(ma
     3.4  	return phys;
     3.5  }
     3.6  
     3.7 +static inline paddr_t pte_machine_to_phys(maddr_t machine)
     3.8 +{
     3.9 +	paddr_t phys;
    3.10 +	phys = mfn_to_pfn((machine & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT);
    3.11 +	phys = (phys << PAGE_SHIFT) | (machine & ~PHYSICAL_PAGE_MASK);
    3.12 +	return phys;
    3.13 +}
    3.14 +
    3.15  /* VIRT <-> MACHINE conversion */
    3.16  #define virt_to_machine(v)	(phys_to_machine(__pa(v)))
    3.17  #define virt_to_mfn(v)		(pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
     4.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h	Tue Nov 14 11:55:58 2006 +0000
     4.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h	Tue Nov 14 11:57:53 2006 +0000
     4.3 @@ -33,6 +33,13 @@
     4.4  #define PAGE_SIZE	(1UL << PAGE_SHIFT)
     4.5  #endif
     4.6  #define PAGE_MASK	(~(PAGE_SIZE-1))
     4.7 +
     4.8 +/* See Documentation/x86_64/mm.txt for a description of the memory map. */
     4.9 +#define __PHYSICAL_MASK_SHIFT	46
    4.10 +#define __PHYSICAL_MASK		((1UL << __PHYSICAL_MASK_SHIFT) - 1)
    4.11 +#define __VIRTUAL_MASK_SHIFT	48
    4.12 +#define __VIRTUAL_MASK		((1UL << __VIRTUAL_MASK_SHIFT) - 1)
    4.13 +
    4.14  #define PHYSICAL_PAGE_MASK	(~(PAGE_SIZE-1) & __PHYSICAL_MASK)
    4.15  
    4.16  #define THREAD_ORDER 1 
    4.17 @@ -90,28 +97,28 @@ typedef struct { unsigned long pgd; } pg
    4.18  
    4.19  typedef struct { unsigned long pgprot; } pgprot_t;
    4.20  
    4.21 -#define pte_val(x)	(((x).pte & 1) ? machine_to_phys((x).pte) : \
    4.22 +#define pte_val(x)	(((x).pte & 1) ? pte_machine_to_phys((x).pte) : \
    4.23  			 (x).pte)
    4.24  #define pte_val_ma(x)	((x).pte)
    4.25  
    4.26  static inline unsigned long pmd_val(pmd_t x)
    4.27  {
    4.28  	unsigned long ret = x.pmd;
    4.29 -	if (ret) ret = machine_to_phys(ret);
    4.30 +	if (ret) ret = pte_machine_to_phys(ret);
    4.31  	return ret;
    4.32  }
    4.33  
    4.34  static inline unsigned long pud_val(pud_t x)
    4.35  {
    4.36  	unsigned long ret = x.pud;
    4.37 -	if (ret) ret = machine_to_phys(ret);
    4.38 +	if (ret) ret = pte_machine_to_phys(ret);
    4.39  	return ret;
    4.40  }
    4.41  
    4.42  static inline unsigned long pgd_val(pgd_t x)
    4.43  {
    4.44  	unsigned long ret = x.pgd;
    4.45 -	if (ret) ret = machine_to_phys(ret);
    4.46 +	if (ret) ret = pte_machine_to_phys(ret);
    4.47  	return ret;
    4.48  }
    4.49  
    4.50 @@ -163,12 +170,6 @@ static inline pgd_t __pgd(unsigned long 
    4.51  /* to align the pointer to the (next) page boundary */
    4.52  #define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
    4.53  
    4.54 -/* See Documentation/x86_64/mm.txt for a description of the memory map. */
    4.55 -#define __PHYSICAL_MASK_SHIFT	46
    4.56 -#define __PHYSICAL_MASK		((1UL << __PHYSICAL_MASK_SHIFT) - 1)
    4.57 -#define __VIRTUAL_MASK_SHIFT	48
    4.58 -#define __VIRTUAL_MASK		((1UL << __VIRTUAL_MASK_SHIFT) - 1)
    4.59 -
    4.60  #define KERNEL_TEXT_SIZE  (40UL*1024*1024)
    4.61  #define KERNEL_TEXT_START 0xffffffff80000000UL 
    4.62