mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
Fix many uses of machine addresses in XenLinux. Primarily
this fixes users of virt_to_machine/machine_to_virt to use virt_to_mfn/mfn_to_virt where that is more appropriate. This should be a big step to improved PAE stability. Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
1 parent
df3303d149
commit
4e4ffc8edf
27 files changed
+127
-109
No files matched your search
@@ -93,7 +93,7 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size)
|
||||
|
||||
static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
|
||||
{
|
||||
#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), ((u32 *)&t->tls_array[i])[0], ((u32 *)&t->tls_array[i])[1])
|
||||
#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), *(u64 *)&t->tls_array[i])
|
||||
C(0); C(1); C(2);
|
||||
#undef C
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ enum fixed_addresses {
|
||||
__end_of_fixed_addresses
|
||||
};
|
||||
|
||||
extern void __set_fixmap (enum fixed_addresses idx,
|
||||
unsigned long phys, pgprot_t flags);
|
||||
extern void __set_fixmap(
|
||||
enum fixed_addresses idx, maddr_t phys, pgprot_t flags);
|
||||
|
||||
#define set_fixmap(idx, phys) \
|
||||
__set_fixmap(idx, phys, PAGE_KERNEL)
|
||||
|
||||
@@ -316,16 +316,17 @@ HYPERVISOR_get_debugreg(
|
||||
|
||||
static inline int
|
||||
HYPERVISOR_update_descriptor(
|
||||
unsigned long ma, unsigned long word1, unsigned long word2)
|
||||
u64 ma, u64 desc)
|
||||
{
|
||||
int ret;
|
||||
unsigned long ign1, ign2, ign3;
|
||||
unsigned long ign1, ign2, ign3, ign4;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
TRAP_INSTR
|
||||
: "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
|
||||
: "0" (__HYPERVISOR_update_descriptor), "1" (ma), "2" (word1),
|
||||
"3" (word2)
|
||||
: "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
|
||||
: "0" (__HYPERVISOR_update_descriptor),
|
||||
"1" ((unsigned long)ma), "2" ((unsigned long)(ma>>32)),
|
||||
"3" ((unsigned long)desc), "4" ((unsigned long)(desc>>32))
|
||||
: "memory" );
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -63,20 +63,25 @@
|
||||
extern unsigned int *phys_to_machine_mapping;
|
||||
#define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
|
||||
#define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
|
||||
|
||||
/* Definitions for machine and pseudophysical addresses. */
|
||||
#ifdef CONFIG_X86_PAE
|
||||
typedef unsigned long long physaddr_t;
|
||||
typedef unsigned long long paddr_t;
|
||||
typedef unsigned long long maddr_t;
|
||||
#else
|
||||
typedef unsigned long physaddr_t;
|
||||
typedef unsigned long paddr_t;
|
||||
typedef unsigned long maddr_t;
|
||||
#endif
|
||||
static inline physaddr_t phys_to_machine(physaddr_t phys)
|
||||
|
||||
static inline maddr_t phys_to_machine(paddr_t phys)
|
||||
{
|
||||
physaddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
|
||||
maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
|
||||
machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
|
||||
return machine;
|
||||
}
|
||||
static inline physaddr_t machine_to_phys(physaddr_t machine)
|
||||
static inline paddr_t machine_to_phys(maddr_t machine)
|
||||
{
|
||||
physaddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
|
||||
paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
|
||||
phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
|
||||
return phys;
|
||||
}
|
||||
@@ -233,8 +238,10 @@ extern int sysctl_legacy_va_layout;
|
||||
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
|
||||
|
||||
/* VIRT <-> MACHINE conversion */
|
||||
#define virt_to_machine(_a) (phys_to_machine(__pa(_a)))
|
||||
#define machine_to_virt(_m) (__va(machine_to_phys(_m)))
|
||||
#define virt_to_machine(v) (phys_to_machine(__pa(v)))
|
||||
#define machine_to_virt(m) (__va(machine_to_phys(m)))
|
||||
#define virt_to_mfn(v) (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
|
||||
#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
|
||||
@@ -450,7 +450,7 @@ void make_pages_writable(void *va, unsigned int nr);
|
||||
#define arbitrary_virt_to_machine(__va) \
|
||||
({ \
|
||||
pte_t *__pte = virt_to_ptep(__va); \
|
||||
unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK; \
|
||||
maddr_t __pa = (maddr_t)pte_mfn(*__pte) << PAGE_SHIFT; \
|
||||
__pa | ((unsigned long)(__va) & (PAGE_SIZE-1)); \
|
||||
})
|
||||
|
||||
|
||||
@@ -65,16 +65,21 @@ void copy_page(void *, void *);
|
||||
extern u32 *phys_to_machine_mapping;
|
||||
#define pfn_to_mfn(_pfn) ((unsigned long) phys_to_machine_mapping[(unsigned int)(_pfn)])
|
||||
#define mfn_to_pfn(_mfn) ((unsigned long) machine_to_phys_mapping[(unsigned int)(_mfn)])
|
||||
static inline unsigned long phys_to_machine(unsigned long phys)
|
||||
|
||||
/* Definitions for machine and pseudophysical addresses. */
|
||||
typedef unsigned long paddr_t;
|
||||
typedef unsigned long maddr_t;
|
||||
|
||||
static inline maddr_t phys_to_machine(paddr_t phys)
|
||||
{
|
||||
unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
|
||||
maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
|
||||
machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
|
||||
return machine;
|
||||
}
|
||||
|
||||
static inline unsigned long machine_to_phys(unsigned long machine)
|
||||
static inline paddr_t machine_to_phys(maddr_t machine)
|
||||
{
|
||||
unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
|
||||
paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
|
||||
phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
|
||||
return phys;
|
||||
}
|
||||
@@ -211,8 +216,10 @@ extern __inline__ int get_order(unsigned long size)
|
||||
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
|
||||
|
||||
/* VIRT <-> MACHINE conversion */
|
||||
#define virt_to_machine(_a) (phys_to_machine(__pa(_a)))
|
||||
#define machine_to_virt(_m) (__va(machine_to_phys(_m)))
|
||||
#define virt_to_machine(v) (phys_to_machine(__pa(v)))
|
||||
#define machine_to_virt(m) (__va(machine_to_phys(m)))
|
||||
#define virt_to_mfn(v) (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
|
||||
#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
|
||||
|
||||
#define VM_DATA_DEFAULT_FLAGS \
|
||||
(((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
|
||||
|
||||