Skip to content

Commit a4a741a

Browse files
committed
Merge remote-tracking branch 'remotes/powerpc/topic/ppc-kvm' into kvm-ppc-next
This merges in a fix which touches both PPC and KVM code, which was therefore put into a topic branch in the powerpc tree. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2 parents 050f233 + ab9bad0 commit a4a741a

File tree

8 files changed

+55
-87
lines changed

8 files changed

+55
-87
lines changed

arch/powerpc/include/asm/exception-64s.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
236236
mtctr reg; \
237237
bctr
238238

239+
#define BRANCH_LINK_TO_FAR(reg, label) \
240+
__LOAD_FAR_HANDLER(reg, label); \
241+
mtctr reg; \
242+
bctrl
243+
239244
/*
240245
* KVM requires __LOAD_FAR_HANDLER.
241246
*
@@ -260,6 +265,9 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
260265
#define BRANCH_TO_COMMON(reg, label) \
261266
b label
262267

268+
#define BRANCH_LINK_TO_FAR(reg, label) \
269+
bl label
270+
263271
#define BRANCH_TO_KVM(reg, label) \
264272
b label
265273

arch/powerpc/include/asm/opal.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ int64_t opal_pci_config_write_half_word(uint64_t phb_id, uint64_t bus_dev_func,
6767
int64_t opal_pci_config_write_word(uint64_t phb_id, uint64_t bus_dev_func,
6868
uint64_t offset, uint32_t data);
6969
int64_t opal_set_xive(uint32_t isn, uint16_t server, uint8_t priority);
70-
int64_t opal_rm_set_xive(uint32_t isn, uint16_t server, uint8_t priority);
7170
int64_t opal_get_xive(uint32_t isn, __be16 *server, uint8_t *priority);
7271
int64_t opal_register_exception_handler(uint64_t opal_exception,
7372
uint64_t handler_address,
@@ -220,18 +219,12 @@ int64_t opal_pci_set_power_state(uint64_t async_token, uint64_t id,
220219
int64_t opal_pci_poll2(uint64_t id, uint64_t data);
221220

222221
int64_t opal_int_get_xirr(uint32_t *out_xirr, bool just_poll);
223-
int64_t opal_rm_int_get_xirr(__be32 *out_xirr, bool just_poll);
224222
int64_t opal_int_set_cppr(uint8_t cppr);
225223
int64_t opal_int_eoi(uint32_t xirr);
226-
int64_t opal_rm_int_eoi(uint32_t xirr);
227224
int64_t opal_int_set_mfrr(uint32_t cpu, uint8_t mfrr);
228-
int64_t opal_rm_int_set_mfrr(uint32_t cpu, uint8_t mfrr);
229225
int64_t opal_pci_tce_kill(uint64_t phb_id, uint32_t kill_type,
230226
uint32_t pe_num, uint32_t tce_size,
231227
uint64_t dma_addr, uint32_t npages);
232-
int64_t opal_rm_pci_tce_kill(uint64_t phb_id, uint32_t kill_type,
233-
uint32_t pe_num, uint32_t tce_size,
234-
uint64_t dma_addr, uint32_t npages);
235228

236229
/* Internal functions */
237230
extern int early_init_dt_scan_opal(unsigned long node, const char *uname,

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ TRAMP_REAL_BEGIN(hmi_exception_early)
982982
EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
983983
EXCEPTION_PROLOG_COMMON_3(0xe60)
984984
addi r3,r1,STACK_FRAME_OVERHEAD
985-
bl hmi_exception_realmode
985+
BRANCH_LINK_TO_FAR(r4, hmi_exception_realmode)
986986
/* Windup the stack. */
987987
/* Move original HSRR0 and HSRR1 into the respective regs */
988988
ld r9,_MSR(r1)

arch/powerpc/kernel/idle_book3s.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ fastsleep_workaround_at_entry:
250250
/* Fast sleep workaround */
251251
li r3,1
252252
li r4,1
253-
bl opal_rm_config_cpu_idle_state
253+
bl opal_config_cpu_idle_state
254254

255255
/* Clear Lock bit */
256256
li r0,0
@@ -544,7 +544,7 @@ timebase_resync:
544544
*/
545545
ble cr3,clear_lock
546546
/* Time base re-sync */
547-
bl opal_rm_resync_timebase;
547+
bl opal_resync_timebase;
548548
/*
549549
* If waking up from sleep, per core state is not lost, skip to
550550
* clear_lock.
@@ -633,7 +633,7 @@ hypervisor_state_restored:
633633
fastsleep_workaround_at_exit:
634634
li r3,1
635635
li r4,0
636-
bl opal_rm_config_cpu_idle_state
636+
bl opal_config_cpu_idle_state
637637
b timebase_resync
638638

639639
/*

arch/powerpc/kvm/book3s_hv_builtin.c

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@
2929
#include <asm/opal.h>
3030
#include <asm/smp.h>
3131

32-
static bool in_realmode(void)
33-
{
34-
return !(mfmsr() & MSR_IR);
35-
}
36-
3732
#define KVM_CMA_CHUNK_ORDER 18
3833

3934
/*
@@ -230,13 +225,10 @@ void kvmhv_rm_send_ipi(int cpu)
230225

231226
/* Else poke the target with an IPI */
232227
xics_phys = paca[cpu].kvm_hstate.xics_phys;
233-
if (!in_realmode())
234-
opal_int_set_mfrr(get_hard_smp_processor_id(cpu), IPI_PRIORITY);
235-
else if (xics_phys)
228+
if (xics_phys)
236229
rm_writeb(xics_phys + XICS_MFRR, IPI_PRIORITY);
237230
else
238-
opal_rm_int_set_mfrr(get_hard_smp_processor_id(cpu),
239-
IPI_PRIORITY);
231+
opal_int_set_mfrr(get_hard_smp_processor_id(cpu), IPI_PRIORITY);
240232
}
241233

242234
/*
@@ -419,10 +411,8 @@ static long kvmppc_read_one_intr(bool *again)
419411
/* Now read the interrupt from the ICP */
420412
xics_phys = local_paca->kvm_hstate.xics_phys;
421413
rc = 0;
422-
if (!in_realmode())
414+
if (!xics_phys)
423415
rc = opal_int_get_xirr(&xirr, false);
424-
else if (!xics_phys)
425-
rc = opal_rm_int_get_xirr(&xirr, false);
426416
else
427417
xirr = _lwzcix(xics_phys + XICS_XIRR);
428418
if (rc < 0)
@@ -453,15 +443,12 @@ static long kvmppc_read_one_intr(bool *again)
453443
*/
454444
if (xisr == XICS_IPI) {
455445
rc = 0;
456-
if (!in_realmode()) {
457-
opal_int_set_mfrr(hard_smp_processor_id(), 0xff);
458-
rc = opal_int_eoi(h_xirr);
459-
} else if (xics_phys) {
446+
if (xics_phys) {
460447
_stbcix(xics_phys + XICS_MFRR, 0xff);
461448
_stwcix(xics_phys + XICS_XIRR, xirr);
462449
} else {
463-
opal_rm_int_set_mfrr(hard_smp_processor_id(), 0xff);
464-
rc = opal_rm_int_eoi(h_xirr);
450+
opal_int_set_mfrr(hard_smp_processor_id(), 0xff);
451+
rc = opal_int_eoi(h_xirr);
465452
}
466453
/* If rc > 0, there is another interrupt pending */
467454
*again = rc > 0;
@@ -482,14 +469,11 @@ static long kvmppc_read_one_intr(bool *again)
482469
/* We raced with the host,
483470
* we need to resend that IPI, bummer
484471
*/
485-
if (!in_realmode())
486-
opal_int_set_mfrr(hard_smp_processor_id(),
487-
IPI_PRIORITY);
488-
else if (xics_phys)
472+
if (xics_phys)
489473
_stbcix(xics_phys + XICS_MFRR, IPI_PRIORITY);
490474
else
491-
opal_rm_int_set_mfrr(hard_smp_processor_id(),
492-
IPI_PRIORITY);
475+
opal_int_set_mfrr(hard_smp_processor_id(),
476+
IPI_PRIORITY);
493477
/* Let side effects complete */
494478
smp_mb();
495479
return 1;

arch/powerpc/kvm/book3s_hv_rm_xics.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ EXPORT_SYMBOL(kvm_irq_bypass);
3636

3737
static void icp_rm_deliver_irq(struct kvmppc_xics *xics, struct kvmppc_icp *icp,
3838
u32 new_irq, bool check_resend);
39-
static int xics_opal_rm_set_server(unsigned int hw_irq, int server_cpu);
39+
static int xics_opal_set_server(unsigned int hw_irq, int server_cpu);
4040

4141
/* -- ICS routines -- */
4242
static void ics_rm_check_resend(struct kvmppc_xics *xics,
@@ -720,7 +720,7 @@ static int ics_rm_eoi(struct kvm_vcpu *vcpu, u32 irq)
720720
++vcpu->stat.pthru_host;
721721
if (state->intr_cpu != pcpu) {
722722
++vcpu->stat.pthru_bad_aff;
723-
xics_opal_rm_set_server(state->host_irq, pcpu);
723+
xics_opal_set_server(state->host_irq, pcpu);
724724
}
725725
state->intr_cpu = -1;
726726
}
@@ -781,16 +781,16 @@ static void icp_eoi(struct irq_chip *c, u32 hwirq, __be32 xirr, bool *again)
781781
if (xics_phys) {
782782
_stwcix(xics_phys + XICS_XIRR, xirr);
783783
} else {
784-
rc = opal_rm_int_eoi(be32_to_cpu(xirr));
784+
rc = opal_int_eoi(be32_to_cpu(xirr));
785785
*again = rc > 0;
786786
}
787787
}
788788

789-
static int xics_opal_rm_set_server(unsigned int hw_irq, int server_cpu)
789+
static int xics_opal_set_server(unsigned int hw_irq, int server_cpu)
790790
{
791791
unsigned int mangle_cpu = get_hard_smp_processor_id(server_cpu) << 2;
792792

793-
return opal_rm_set_xive(hw_irq, mangle_cpu, DEFAULT_PRIORITY);
793+
return opal_set_xive(hw_irq, mangle_cpu, DEFAULT_PRIORITY);
794794
}
795795

796796
/*

arch/powerpc/platforms/powernv/opal-wrappers.S

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ END_FTR_SECTION(0, 1); \
5858

5959
#define OPAL_CALL(name, token) \
6060
_GLOBAL_TOC(name); \
61+
mfmsr r12; \
6162
mflr r0; \
63+
andi. r11,r12,MSR_IR|MSR_DR; \
6264
std r0,PPC_LR_STKOFF(r1); \
6365
li r0,token; \
66+
beq opal_real_call; \
6467
OPAL_BRANCH(opal_tracepoint_entry) \
65-
mfcr r12; \
66-
stw r12,8(r1); \
68+
mfcr r11; \
69+
stw r11,8(r1); \
6770
li r11,0; \
68-
mfmsr r12; \
6971
ori r11,r11,MSR_EE; \
7072
std r12,PACASAVEDMSR(r13); \
7173
andc r12,r12,r11; \
@@ -98,6 +100,30 @@ opal_return:
98100
mtcr r4;
99101
rfid
100102

103+
opal_real_call:
104+
mfcr r11
105+
stw r11,8(r1)
106+
/* Set opal return address */
107+
LOAD_REG_ADDR(r11, opal_return_realmode)
108+
mtlr r11
109+
li r11,MSR_LE
110+
andc r12,r12,r11
111+
mtspr SPRN_HSRR1,r12
112+
LOAD_REG_ADDR(r11,opal)
113+
ld r12,8(r11)
114+
ld r2,0(r11)
115+
mtspr SPRN_HSRR0,r12
116+
hrfid
117+
118+
opal_return_realmode:
119+
FIXUP_ENDIAN
120+
ld r2,PACATOC(r13);
121+
lwz r11,8(r1);
122+
ld r12,PPC_LR_STKOFF(r1)
123+
mtcr r11;
124+
mtlr r12
125+
blr
126+
101127
#ifdef CONFIG_TRACEPOINTS
102128
opal_tracepoint_entry:
103129
stdu r1,-STACKFRAMESIZE(r1)
@@ -155,36 +181,6 @@ opal_tracepoint_return:
155181
blr
156182
#endif
157183

158-
#define OPAL_CALL_REAL(name, token) \
159-
_GLOBAL_TOC(name); \
160-
mflr r0; \
161-
std r0,PPC_LR_STKOFF(r1); \
162-
li r0,token; \
163-
mfcr r12; \
164-
stw r12,8(r1); \
165-
\
166-
/* Set opal return address */ \
167-
LOAD_REG_ADDR(r11, opal_return_realmode); \
168-
mtlr r11; \
169-
mfmsr r12; \
170-
li r11,MSR_LE; \
171-
andc r12,r12,r11; \
172-
mtspr SPRN_HSRR1,r12; \
173-
LOAD_REG_ADDR(r11,opal); \
174-
ld r12,8(r11); \
175-
ld r2,0(r11); \
176-
mtspr SPRN_HSRR0,r12; \
177-
hrfid
178-
179-
opal_return_realmode:
180-
FIXUP_ENDIAN
181-
ld r2,PACATOC(r13);
182-
lwz r11,8(r1);
183-
ld r12,PPC_LR_STKOFF(r1)
184-
mtcr r11;
185-
mtlr r12
186-
blr
187-
188184

189185
OPAL_CALL(opal_invalid_call, OPAL_INVALID_CALL);
190186
OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE);
@@ -208,7 +204,6 @@ OPAL_CALL(opal_pci_config_write_byte, OPAL_PCI_CONFIG_WRITE_BYTE);
208204
OPAL_CALL(opal_pci_config_write_half_word, OPAL_PCI_CONFIG_WRITE_HALF_WORD);
209205
OPAL_CALL(opal_pci_config_write_word, OPAL_PCI_CONFIG_WRITE_WORD);
210206
OPAL_CALL(opal_set_xive, OPAL_SET_XIVE);
211-
OPAL_CALL_REAL(opal_rm_set_xive, OPAL_SET_XIVE);
212207
OPAL_CALL(opal_get_xive, OPAL_GET_XIVE);
213208
OPAL_CALL(opal_register_exception_handler, OPAL_REGISTER_OPAL_EXCEPTION_HANDLER);
214209
OPAL_CALL(opal_pci_eeh_freeze_status, OPAL_PCI_EEH_FREEZE_STATUS);
@@ -264,7 +259,6 @@ OPAL_CALL(opal_validate_flash, OPAL_FLASH_VALIDATE);
264259
OPAL_CALL(opal_manage_flash, OPAL_FLASH_MANAGE);
265260
OPAL_CALL(opal_update_flash, OPAL_FLASH_UPDATE);
266261
OPAL_CALL(opal_resync_timebase, OPAL_RESYNC_TIMEBASE);
267-
OPAL_CALL_REAL(opal_rm_resync_timebase, OPAL_RESYNC_TIMEBASE);
268262
OPAL_CALL(opal_check_token, OPAL_CHECK_TOKEN);
269263
OPAL_CALL(opal_dump_init, OPAL_DUMP_INIT);
270264
OPAL_CALL(opal_dump_info, OPAL_DUMP_INFO);
@@ -280,9 +274,7 @@ OPAL_CALL(opal_sensor_read, OPAL_SENSOR_READ);
280274
OPAL_CALL(opal_get_param, OPAL_GET_PARAM);
281275
OPAL_CALL(opal_set_param, OPAL_SET_PARAM);
282276
OPAL_CALL(opal_handle_hmi, OPAL_HANDLE_HMI);
283-
OPAL_CALL_REAL(opal_rm_handle_hmi, OPAL_HANDLE_HMI);
284277
OPAL_CALL(opal_config_cpu_idle_state, OPAL_CONFIG_CPU_IDLE_STATE);
285-
OPAL_CALL_REAL(opal_rm_config_cpu_idle_state, OPAL_CONFIG_CPU_IDLE_STATE);
286278
OPAL_CALL(opal_slw_set_reg, OPAL_SLW_SET_REG);
287279
OPAL_CALL(opal_register_dump_region, OPAL_REGISTER_DUMP_REGION);
288280
OPAL_CALL(opal_unregister_dump_region, OPAL_UNREGISTER_DUMP_REGION);
@@ -304,11 +296,7 @@ OPAL_CALL(opal_pci_get_presence_state, OPAL_PCI_GET_PRESENCE_STATE);
304296
OPAL_CALL(opal_pci_get_power_state, OPAL_PCI_GET_POWER_STATE);
305297
OPAL_CALL(opal_pci_set_power_state, OPAL_PCI_SET_POWER_STATE);
306298
OPAL_CALL(opal_int_get_xirr, OPAL_INT_GET_XIRR);
307-
OPAL_CALL_REAL(opal_rm_int_get_xirr, OPAL_INT_GET_XIRR);
308299
OPAL_CALL(opal_int_set_cppr, OPAL_INT_SET_CPPR);
309300
OPAL_CALL(opal_int_eoi, OPAL_INT_EOI);
310-
OPAL_CALL_REAL(opal_rm_int_eoi, OPAL_INT_EOI);
311301
OPAL_CALL(opal_int_set_mfrr, OPAL_INT_SET_MFRR);
312-
OPAL_CALL_REAL(opal_rm_int_set_mfrr, OPAL_INT_SET_MFRR);
313302
OPAL_CALL(opal_pci_tce_kill, OPAL_PCI_TCE_KILL);
314-
OPAL_CALL_REAL(opal_rm_pci_tce_kill, OPAL_PCI_TCE_KILL);

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,11 +1962,6 @@ static void pnv_pci_ioda2_tce_invalidate(struct iommu_table *tbl,
19621962
if (phb->model == PNV_PHB_MODEL_PHB3 && phb->regs)
19631963
pnv_pci_phb3_tce_invalidate(pe, rm, shift,
19641964
index, npages);
1965-
else if (rm)
1966-
opal_rm_pci_tce_kill(phb->opal_id,
1967-
OPAL_PCI_TCE_KILL_PAGES,
1968-
pe->pe_number, 1u << shift,
1969-
index << shift, npages);
19701965
else
19711966
opal_pci_tce_kill(phb->opal_id,
19721967
OPAL_PCI_TCE_KILL_PAGES,

0 commit comments

Comments
 (0)