[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 15/45] xen: arm64: address translation
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- I'm torn between unsigned long and vaddr_t... --- xen/include/asm-arm/arm32/page.h | 34 ++++++++++++++++++++++++++++++++++ xen/include/asm-arm/arm64/page.h | 35 +++++++++++++++++++++++++++++++++++ xen/include/asm-arm/page.h | 38 ++------------------------------------ xen/include/asm-arm/types.h | 4 ++++ 4 files changed, 75 insertions(+), 36 deletions(-) diff --git a/xen/include/asm-arm/arm32/page.h b/xen/include/asm-arm/arm32/page.h index d4852f9..ef29429 100644 --- a/xen/include/asm-arm/arm32/page.h +++ b/xen/include/asm-arm/arm32/page.h @@ -79,6 +79,40 @@ static inline void flush_guest_tlb(void) WRITE_CP32(r0 /* dummy */, TLBIALLNSNH); } +/* Ask the MMU to translate a VA for us */ +static inline uint64_t __va_to_par(vaddr_t va) +{ + uint64_t par, tmp; + tmp = READ_CP64(PAR); + WRITE_CP32(va, ATS1HR); + isb(); /* Ensure result is available. */ + par = READ_CP64(PAR); + WRITE_CP64(tmp, PAR); + return par; +} + +/* Ask the MMU to translate a Guest VA for us */ +static inline uint64_t gva_to_ma_par(vaddr_t va) +{ + uint64_t par, tmp; + tmp = READ_CP64(PAR); + WRITE_CP32(va, ATS12NSOPR); + isb(); /* Ensure result is available. */ + par = READ_CP64(PAR); + WRITE_CP64(tmp, PAR); + return par; +} +static inline uint64_t gva_to_ipa_par(vaddr_t va) +{ + uint64_t par, tmp; + tmp = READ_CP64(PAR); + WRITE_CP32(va, ATS1CPR); + isb(); /* Ensure result is available. */ + par = READ_CP64(PAR); + WRITE_CP64(tmp, PAR); + return par; +} + #endif /* __ASSEMBLY__ */ #endif /* __ARM_ARM32_PAGE_H__ */ diff --git a/xen/include/asm-arm/arm64/page.h b/xen/include/asm-arm/arm64/page.h index e69b4a4..c4bb10a 100644 --- a/xen/include/asm-arm/arm64/page.h +++ b/xen/include/asm-arm/arm64/page.h @@ -72,6 +72,41 @@ static inline void flush_guest_tlb(void) asm volatile("tlbi alle1,ns" : : : "memory"); } +/* Ask the MMU to translate a VA for us */ +static inline uint64_t __va_to_par(vaddr_t va) +{ + uint64_t par, tmp = READ_SYSREG64(PAR_EL1); + + asm volatile ("at s1e2r, %0;" : : "r" (va)); + isb(); + par = READ_SYSREG64(PAR_EL1); + WRITE_SYSREG64(tmp, PAR_EL1); + return par; +} + +/* Ask the MMU to translate a Guest VA for us */ +static inline uint64_t gva_to_ma_par(vaddr_t va) +{ + uint64_t par, tmp = READ_SYSREG64(PAR_EL1); + + asm volatile ("at s12e1r, %0;" : : "r" (va)); + isb(); + par = READ_SYSREG64(PAR_EL1); + WRITE_SYSREG64(tmp, PAR_EL1); + return par; +} + +static inline uint64_t gva_to_ipa_par(vaddr_t va) +{ + uint64_t par, tmp = READ_SYSREG64(PAR_EL1); + + asm volatile ("at s1e1r, %0;" : : "r" (va)); + isb(); + par = READ_SYSREG64(PAR_EL1); + WRITE_SYSREG64(tmp, PAR_EL1); + return par; +} + #endif /* __ASSEMBLY__ */ #endif /* __ARM_ARM64_PAGE_H__ */ diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 05b7caa..d4a18da 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -277,19 +277,7 @@ extern void dump_hyp_walk(uint32_t addr); /* Print a walk of the p2m for a domain for a physical address. */ extern void dump_p2m_lookup(struct domain *d, paddr_t addr); -/* Ask the MMU to translate a VA for us */ -static inline uint64_t __va_to_par(uint32_t va) -{ - uint64_t par, tmp; - tmp = READ_CP64(PAR); - WRITE_CP32(va, ATS1HR); - isb(); /* Ensure result is available. */ - par = READ_CP64(PAR); - WRITE_CP64(tmp, PAR); - return par; -} - -static inline uint64_t va_to_par(uint32_t va) +static inline uint64_t va_to_par(vaddr_t va) { uint64_t par = __va_to_par(va); /* It is not OK to call this with an invalid VA */ @@ -301,29 +289,7 @@ static inline uint64_t va_to_par(uint32_t va) return par; } -/* Ask the MMU to translate a Guest VA for us */ -static inline uint64_t gva_to_ma_par(uint32_t va) -{ - uint64_t par, tmp; - tmp = READ_CP64(PAR); - WRITE_CP32(va, ATS12NSOPR); - isb(); /* Ensure result is available. */ - par = READ_CP64(PAR); - WRITE_CP64(tmp, PAR); - return par; -} -static inline uint64_t gva_to_ipa_par(uint32_t va) -{ - uint64_t par, tmp; - tmp = READ_CP64(PAR); - WRITE_CP32(va, ATS1CPR); - isb(); /* Ensure result is available. */ - par = READ_CP64(PAR); - WRITE_CP64(tmp, PAR); - return par; -} - -static inline int gva_to_ipa(uint32_t va, paddr_t *paddr) +static inline int gva_to_ipa(vaddr_t va, paddr_t *paddr) { uint64_t par = gva_to_ipa_par(va); if ( par & PAR_F ) diff --git a/xen/include/asm-arm/types.h b/xen/include/asm-arm/types.h index 07f7898..d3e16d8 100644 --- a/xen/include/asm-arm/types.h +++ b/xen/include/asm-arm/types.h @@ -36,12 +36,16 @@ typedef unsigned int u32; #if defined(CONFIG_ARM_32) typedef signed long long s64; typedef unsigned long long u64; +typedef u32 vaddr_t; +#define PRIvaddr PRIx32 typedef u64 paddr_t; #define INVALID_PADDR (~0ULL) #define PRIpaddr "016llx" #elif defined (CONFIG_ARM_64) typedef signed long s64; typedef unsigned long u64; +typedef u64 vaddr_t; +#define PRIvaddr PRIx64 typedef u64 paddr_t; #define INVALID_PADDR (~0UL) #define PRIpaddr "016lx" -- 1.7.2.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |