aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/include')
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_64.h26
-rw-r--r--arch/powerpc/include/asm/kvm_host.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h
index 10920f7a2b8d..18b590d261ff 100644
--- a/arch/powerpc/include/asm/kvm_book3s_64.h
+++ b/arch/powerpc/include/asm/kvm_book3s_64.h
@@ -113,6 +113,32 @@ static inline unsigned long hpte_page_size(unsigned long h, unsigned long l)
113 return 0; /* error */ 113 return 0; /* error */
114} 114}
115 115
116static inline int hpte_cache_flags_ok(unsigned long ptel, unsigned long io_type)
117{
118 unsigned int wimg = ptel & HPTE_R_WIMG;
119
120 /* Handle SAO */
121 if (wimg == (HPTE_R_W | HPTE_R_I | HPTE_R_M) &&
122 cpu_has_feature(CPU_FTR_ARCH_206))
123 wimg = HPTE_R_M;
124
125 if (!io_type)
126 return wimg == HPTE_R_M;
127
128 return (wimg & (HPTE_R_W | HPTE_R_I)) == io_type;
129}
130
131/* Return HPTE cache control bits corresponding to Linux pte bits */
132static inline unsigned long hpte_cache_bits(unsigned long pte_val)
133{
134#if _PAGE_NO_CACHE == HPTE_R_I && _PAGE_WRITETHRU == HPTE_R_W
135 return pte_val & (HPTE_R_W | HPTE_R_I);
136#else
137 return ((pte_val & _PAGE_NO_CACHE) ? HPTE_R_I : 0) +
138 ((pte_val & _PAGE_WRITETHRU) ? HPTE_R_W : 0);
139#endif
140}
141
116static inline bool slot_is_aligned(struct kvm_memory_slot *memslot, 142static inline bool slot_is_aligned(struct kvm_memory_slot *memslot,
117 unsigned long pagesize) 143 unsigned long pagesize)
118{ 144{
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 9252d5e3758d..243bc8038572 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -178,6 +178,8 @@ struct revmap_entry {
178 178
179/* Low-order bits in kvm->arch.slot_phys[][] */ 179/* Low-order bits in kvm->arch.slot_phys[][] */
180#define KVMPPC_PAGE_ORDER_MASK 0x1f 180#define KVMPPC_PAGE_ORDER_MASK 0x1f
181#define KVMPPC_PAGE_NO_CACHE HPTE_R_I /* 0x20 */
182#define KVMPPC_PAGE_WRITETHRU HPTE_R_W /* 0x40 */
181#define KVMPPC_GOT_PAGE 0x80 183#define KVMPPC_GOT_PAGE 0x80
182 184
183struct kvm_arch { 185struct kvm_arch {