[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 73/73] ppc: allow certain HV interrupts to be delivered
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 73/73] ppc: allow certain HV interrupts to be delivered to guests |
Date: |
Fri, 28 Oct 2016 12:38:14 +1100 |
From: Nicholas Piggin <address@hidden>
ppc hypervisors have delivered system reset and machine check exception
interrupts to guests in some situations (e.g., see FWNMI feature of LoPAPR,
or NMI injection in QEMU).
These exceptions are architected to set the HV bit in hardware, however
when injected into a guest, the HV bit should be cleared. Current code
masks off the HV bit before setting the new MSR, however this happens after
the interrupt delivery model has calculated delivery mode for the exception.
This can result in the guest's MSR LE bit being lost.
Account for this in the exception handler and don't set HV bit for guest
delivery.
Also add another sanity check to ensure similar bugs get caught.
Signed-off-by: Nicholas Piggin <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
target-ppc/excp_helper.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c
index 53c4075..808760b 100644
--- a/target-ppc/excp_helper.c
+++ b/target-ppc/excp_helper.c
@@ -213,7 +213,12 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int
excp_model, int excp)
cs->halted = 1;
cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
- new_msr |= (target_ulong)MSR_HVB;
+ if (env->msr_mask & MSR_HVB) {
+ /* ISA specifies HV, but can be delivered to guest with HV clear
+ * (e.g., see FWNMI in PAPR).
+ */
+ new_msr |= (target_ulong)MSR_HVB;
+ }
ail = 0;
/* machine check exceptions don't have ME set */
@@ -391,8 +396,17 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int
excp_model, int excp)
msr |= 0x10000;
new_msr |= ((target_ulong)1 << MSR_ME);
}
-
- new_msr |= (target_ulong)MSR_HVB;
+ if (env->msr_mask & MSR_HVB) {
+ /* ISA specifies HV, but can be delivered to guest with HV clear
+ * (e.g., see FWNMI in PAPR, NMI injection in QEMU).
+ */
+ new_msr |= (target_ulong)MSR_HVB;
+ } else {
+ if (msr_pow) {
+ cpu_abort(cs, "Trying to deliver power-saving system reset "
+ "exception %d with no HV support\n", excp);
+ }
+ }
ail = 0;
break;
case POWERPC_EXCP_DSEG: /* Data segment exception */
@@ -609,9 +623,15 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int
excp_model, int excp)
env->spr[srr1] = msr;
/* Sanity check */
- if (!(env->msr_mask & MSR_HVB) && (srr0 == SPR_HSRR0)) {
- cpu_abort(cs, "Trying to deliver HV exception %d with "
- "no HV support\n", excp);
+ if (!(env->msr_mask & MSR_HVB)) {
+ if (new_msr & MSR_HVB) {
+ cpu_abort(cs, "Trying to deliver HV exception (MSR) %d with "
+ "no HV support\n", excp);
+ }
+ if (srr0 == SPR_HSRR0) {
+ cpu_abort(cs, "Trying to deliver HV exception (HSRR) %d with "
+ "no HV support\n", excp);
+ }
}
/* If any alternate SRR register are defined, duplicate saved values */
--
2.7.4
- [Qemu-ppc] [PULL 62/73] libqos: Change PCI accessors to take opaque BAR handle, (continued)
- [Qemu-ppc] [PULL 62/73] libqos: Change PCI accessors to take opaque BAR handle, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 59/73] libqos: Add 64-bit PCI IO accessors, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 61/73] tests: Don't assume structure of PCI IO base in ahci-test, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 67/73] spapr: update spapr hotplug documentation, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 60/73] tests: Use qpci_mem{read, write} in ivshmem-test, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 57/73] libqos: Implement mmio accessors in terms of mem{read, write}, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 63/73] spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 50/73] adb: change handler only when recognized, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 68/73] spapr_events: add support for dedicated hotplug event source, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 72/73] spapr: Memory hot-unplug support, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 73/73] ppc: allow certain HV interrupts to be delivered to guests,
David Gibson <=
- [Qemu-ppc] [PULL 22/73] ppc: add skiboot firmware for the pnv platform, David Gibson, 2016/10/28
- [Qemu-ppc] [PULL 01/73] pseries: Update SLOF firmware image to 20161019, David Gibson, 2016/10/28
- Re: [Qemu-ppc] [PULL 00/73] ppc-for-2.8 queue 20161028, Peter Maydell, 2016/10/28