Skip to content

Commit 99212c8

Browse files
committed
Merge branch 'kvm-ppc-infrastructure' into kvm-ppc-next
This merges the topic branch 'kvm-ppc-infrastructure' into kvm-ppc-next so that I can then apply further patches that need the changes in the kvm-ppc-infrastructure branch. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2 parents 2a27f51 + 3f25777 commit 99212c8

File tree

13 files changed

+164
-131
lines changed

13 files changed

+164
-131
lines changed

arch/powerpc/include/asm/book3s/64/mmu-hash.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,43 @@ static inline int segment_shift(int ssize)
244244
return SID_SHIFT_1T;
245245
}
246246

247+
/*
248+
* This array is indexed by the LP field of the HPTE second dword.
249+
* Since this field may contain some RPN bits, some entries are
250+
* replicated so that we get the same value irrespective of RPN.
251+
* The top 4 bits are the page size index (MMU_PAGE_*) for the
252+
* actual page size, the bottom 4 bits are the base page size.
253+
*/
254+
extern u8 hpte_page_sizes[1 << LP_BITS];
255+
256+
static inline unsigned long __hpte_page_size(unsigned long h, unsigned long l,
257+
bool is_base_size)
258+
{
259+
unsigned int i, lp;
260+
261+
if (!(h & HPTE_V_LARGE))
262+
return 1ul << 12;
263+
264+
/* Look at the 8 bit LP value */
265+
lp = (l >> LP_SHIFT) & ((1 << LP_BITS) - 1);
266+
i = hpte_page_sizes[lp];
267+
if (!i)
268+
return 0;
269+
if (!is_base_size)
270+
i >>= 4;
271+
return 1ul << mmu_psize_defs[i & 0xf].shift;
272+
}
273+
274+
static inline unsigned long hpte_page_size(unsigned long h, unsigned long l)
275+
{
276+
return __hpte_page_size(h, l, 0);
277+
}
278+
279+
static inline unsigned long hpte_base_page_size(unsigned long h, unsigned long l)
280+
{
281+
return __hpte_page_size(h, l, 1);
282+
}
283+
247284
/*
248285
* The current system page and segment sizes
249286
*/

arch/powerpc/include/asm/hmi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef __ASM_PPC64_HMI_H__
2222
#define __ASM_PPC64_HMI_H__
2323

24-
#ifdef CONFIG_PPC_BOOK3S_64
24+
#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
2525

2626
#define CORE_TB_RESYNC_REQ_BIT 63
2727
#define MAX_SUBCORE_PER_CORE 4

arch/powerpc/include/asm/io.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,35 @@ static inline void out_be64(volatile u64 __iomem *addr, u64 val)
241241
#endif
242242
#endif /* __powerpc64__ */
243243

244+
245+
/*
246+
* Simple Cache inhibited accessors
247+
* Unlike the DEF_MMIO_* macros, these don't include any h/w memory
248+
* barriers, callers need to manage memory barriers on their own.
249+
* These can only be used in hypervisor real mode.
250+
*/
251+
252+
static inline u32 _lwzcix(unsigned long addr)
253+
{
254+
u32 ret;
255+
256+
__asm__ __volatile__("lwzcix %0,0, %1"
257+
: "=r" (ret) : "r" (addr) : "memory");
258+
return ret;
259+
}
260+
261+
static inline void _stbcix(u64 addr, u8 val)
262+
{
263+
__asm__ __volatile__("stbcix %0,0,%1"
264+
: : "r" (val), "r" (addr) : "memory");
265+
}
266+
267+
static inline void _stwcix(u64 addr, u32 val)
268+
{
269+
__asm__ __volatile__("stwcix %0,0,%1"
270+
: : "r" (val), "r" (addr) : "memory");
271+
}
272+
244273
/*
245274
* Low level IO stream instructions are defined out of line for now
246275
*/

arch/powerpc/include/asm/kvm_book3s_64.h

Lines changed: 7 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#ifndef __ASM_KVM_BOOK3S_64_H__
2121
#define __ASM_KVM_BOOK3S_64_H__
2222

23+
#include <asm/book3s/64/mmu-hash.h>
24+
2325
#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
2426
static inline struct kvmppc_book3s_shadow_vcpu *svcpu_get(struct kvm_vcpu *vcpu)
2527
{
@@ -97,56 +99,20 @@ static inline void __unlock_hpte(__be64 *hpte, unsigned long hpte_v)
9799
hpte[0] = cpu_to_be64(hpte_v);
98100
}
99101

100-
static inline int __hpte_actual_psize(unsigned int lp, int psize)
101-
{
102-
int i, shift;
103-
unsigned int mask;
104-
105-
/* start from 1 ignoring MMU_PAGE_4K */
106-
for (i = 1; i < MMU_PAGE_COUNT; i++) {
107-
108-
/* invalid penc */
109-
if (mmu_psize_defs[psize].penc[i] == -1)
110-
continue;
111-
/*
112-
* encoding bits per actual page size
113-
* PTE LP actual page size
114-
* rrrr rrrz >=8KB
115-
* rrrr rrzz >=16KB
116-
* rrrr rzzz >=32KB
117-
* rrrr zzzz >=64KB
118-
* .......
119-
*/
120-
shift = mmu_psize_defs[i].shift - LP_SHIFT;
121-
if (shift > LP_BITS)
122-
shift = LP_BITS;
123-
mask = (1 << shift) - 1;
124-
if ((lp & mask) == mmu_psize_defs[psize].penc[i])
125-
return i;
126-
}
127-
return -1;
128-
}
129-
130102
static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,
131103
unsigned long pte_index)
132104
{
133-
int b_psize = MMU_PAGE_4K, a_psize = MMU_PAGE_4K;
105+
int i, b_psize = MMU_PAGE_4K, a_psize = MMU_PAGE_4K;
134106
unsigned int penc;
135107
unsigned long rb = 0, va_low, sllp;
136108
unsigned int lp = (r >> LP_SHIFT) & ((1 << LP_BITS) - 1);
137109

138110
if (v & HPTE_V_LARGE) {
139-
for (b_psize = 0; b_psize < MMU_PAGE_COUNT; b_psize++) {
140-
141-
/* valid entries have a shift value */
142-
if (!mmu_psize_defs[b_psize].shift)
143-
continue;
144-
145-
a_psize = __hpte_actual_psize(lp, b_psize);
146-
if (a_psize != -1)
147-
break;
148-
}
111+
i = hpte_page_sizes[lp];
112+
b_psize = i & 0xf;
113+
a_psize = i >> 4;
149114
}
115+
150116
/*
151117
* Ignore the top 14 bits of va
152118
* v have top two bits covering segment size, hence move
@@ -215,45 +181,6 @@ static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,
215181
return rb;
216182
}
217183

218-
static inline unsigned long __hpte_page_size(unsigned long h, unsigned long l,
219-
bool is_base_size)
220-
{
221-
222-
int size, a_psize;
223-
/* Look at the 8 bit LP value */
224-
unsigned int lp = (l >> LP_SHIFT) & ((1 << LP_BITS) - 1);
225-
226-
/* only handle 4k, 64k and 16M pages for now */
227-
if (!(h & HPTE_V_LARGE))
228-
return 1ul << 12;
229-
else {
230-
for (size = 0; size < MMU_PAGE_COUNT; size++) {
231-
/* valid entries have a shift value */
232-
if (!mmu_psize_defs[size].shift)
233-
continue;
234-
235-
a_psize = __hpte_actual_psize(lp, size);
236-
if (a_psize != -1) {
237-
if (is_base_size)
238-
return 1ul << mmu_psize_defs[size].shift;
239-
return 1ul << mmu_psize_defs[a_psize].shift;
240-
}
241-
}
242-
243-
}
244-
return 0;
245-
}
246-
247-
static inline unsigned long hpte_page_size(unsigned long h, unsigned long l)
248-
{
249-
return __hpte_page_size(h, l, 0);
250-
}
251-
252-
static inline unsigned long hpte_base_page_size(unsigned long h, unsigned long l)
253-
{
254-
return __hpte_page_size(h, l, 1);
255-
}
256-
257184
static inline unsigned long hpte_rpn(unsigned long ptel, unsigned long psize)
258185
{
259186
return ((ptel & HPTE_R_RPN) & ~(psize - 1)) >> PAGE_SHIFT;

arch/powerpc/include/asm/mmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ static inline bool early_radix_enabled(void)
271271
#define MMU_PAGE_16G 13
272272
#define MMU_PAGE_64G 14
273273

274+
/* N.B. we need to change the type of hpte_page_sizes if this gets to be > 16 */
274275
#define MMU_PAGE_COUNT 15
275276

276277
#ifdef CONFIG_PPC_BOOK3S_64

arch/powerpc/include/asm/paca.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,6 @@ struct paca_struct {
183183
*/
184184
u16 in_mce;
185185
u8 hmi_event_available; /* HMI event is available */
186-
/*
187-
* Bitmap for sibling subcore status. See kvm/book3s_hv_ras.c for
188-
* more details
189-
*/
190-
struct sibling_subcore_state *sibling_subcore_state;
191186
#endif
192187

193188
/* Stuff for accurate time accounting */
@@ -202,6 +197,13 @@ struct paca_struct {
202197
struct kvmppc_book3s_shadow_vcpu shadow_vcpu;
203198
#endif
204199
struct kvmppc_host_state kvm_hstate;
200+
#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
201+
/*
202+
* Bitmap for sibling subcore status. See kvm/book3s_hv_ras.c for
203+
* more details
204+
*/
205+
struct sibling_subcore_state *sibling_subcore_state;
206+
#endif
205207
#endif
206208
};
207209

arch/powerpc/include/asm/pnv-pci.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <linux/pci.h>
1414
#include <linux/pci_hotplug.h>
15+
#include <linux/irq.h>
1516
#include <misc/cxl-base.h>
1617
#include <asm/opal-api.h>
1718

@@ -33,6 +34,8 @@ int pnv_cxl_alloc_hwirqs(struct pci_dev *dev, int num);
3334
void pnv_cxl_release_hwirqs(struct pci_dev *dev, int hwirq, int num);
3435
int pnv_cxl_get_irq_count(struct pci_dev *dev);
3536
struct device_node *pnv_pci_get_phb_node(struct pci_dev *dev);
37+
int64_t pnv_opal_pci_msi_eoi(struct irq_chip *chip, unsigned int hw_irq);
38+
bool is_pnv_opal_msi(struct irq_chip *chip);
3639

3740
#ifdef CONFIG_CXL_BASE
3841
int pnv_cxl_alloc_hwirq_ranges(struct cxl_irq_ranges *irqs,

arch/powerpc/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ obj-$(CONFIG_VDSO32) += vdso32/
4141
obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
4242
obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o
4343
obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o
44-
obj-$(CONFIG_PPC_BOOK3S_64) += mce.o mce_power.o hmi.o
44+
obj-$(CONFIG_PPC_BOOK3S_64) += mce.o mce_power.o
4545
obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o
4646
obj-$(CONFIG_PPC64) += vdso64/
4747
obj-$(CONFIG_ALTIVEC) += vecemu.o

arch/powerpc/kvm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \
7777

7878
ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
7979
kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
80+
book3s_hv_hmi.o \
8081
book3s_hv_rmhandlers.o \
8182
book3s_hv_rm_mmu.o \
8283
book3s_hv_ras.o \
File renamed without changes.

0 commit comments

Comments
 (0)