|
|
59eb7a |
From: Greg Kurz <groug@kaod.org>
|
|
|
59eb7a |
Date: Thu, 17 Aug 2017 13:23:50 +0200
|
|
|
59eb7a |
Subject: [PATCH] spapr: fallback to raw mode if best compat mode cannot be set
|
|
|
59eb7a |
during CAS
|
|
|
59eb7a |
|
|
|
59eb7a |
KVM PR doesn't allow to set a compat mode. This causes ppc_set_compat_all()
|
|
|
59eb7a |
to fail and we return H_HARDWARE to the guest right away.
|
|
|
59eb7a |
|
|
|
59eb7a |
This is excessive: even if we favor compat mode since commit 152ef803ceb19,
|
|
|
59eb7a |
we should at least fallback to raw mode if the guest supports it.
|
|
|
59eb7a |
|
|
|
59eb7a |
This patch modifies cas_check_pvr() so that it also reports that the real
|
|
|
59eb7a |
PVR was found in the table supplied by the guest. Note that this is only
|
|
|
59eb7a |
makes sense if raw mode isn't explicitely disabled (ie, the user didn't
|
|
|
59eb7a |
set the machine "max-cpu-compat" property). If this is the case, we can
|
|
|
59eb7a |
simply ignore ppc_set_compat_all() failures, and let the guest run in raw
|
|
|
59eb7a |
mode.
|
|
|
59eb7a |
|
|
|
59eb7a |
Signed-off-by: Greg Kurz <groug@kaod.org>
|
|
|
59eb7a |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
59eb7a |
(cherry picked from commit cc7b35b169e96600c09947a31c610c84a3eda3ff)
|
|
|
59eb7a |
---
|
|
|
59eb7a |
hw/ppc/spapr_hcall.c | 18 ++++++++++++++----
|
|
|
59eb7a |
1 file changed, 14 insertions(+), 4 deletions(-)
|
|
|
59eb7a |
|
|
|
59eb7a |
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
|
|
|
59eb7a |
index 07b3da8dc4..2f4c4f59e1 100644
|
|
|
59eb7a |
--- a/hw/ppc/spapr_hcall.c
|
|
|
59eb7a |
+++ b/hw/ppc/spapr_hcall.c
|
|
|
59eb7a |
@@ -1441,7 +1441,8 @@ static target_ulong h_signal_sys_reset(PowerPCCPU *cpu,
|
|
|
59eb7a |
}
|
|
|
59eb7a |
|
|
|
59eb7a |
static uint32_t cas_check_pvr(sPAPRMachineState *spapr, PowerPCCPU *cpu,
|
|
|
59eb7a |
- target_ulong *addr, Error **errp)
|
|
|
59eb7a |
+ target_ulong *addr, bool *raw_mode_supported,
|
|
|
59eb7a |
+ Error **errp)
|
|
|
59eb7a |
{
|
|
|
59eb7a |
bool explicit_match = false; /* Matched the CPU's real PVR */
|
|
|
59eb7a |
uint32_t max_compat = spapr->max_compat_pvr;
|
|
|
59eb7a |
@@ -1481,6 +1482,8 @@ static uint32_t cas_check_pvr(sPAPRMachineState *spapr, PowerPCCPU *cpu,
|
|
|
59eb7a |
return 0;
|
|
|
59eb7a |
}
|
|
|
59eb7a |
|
|
|
59eb7a |
+ *raw_mode_supported = explicit_match;
|
|
|
59eb7a |
+
|
|
|
59eb7a |
/* Parsing finished */
|
|
|
59eb7a |
trace_spapr_cas_pvr(cpu->compat_pvr, explicit_match, best_compat);
|
|
|
59eb7a |
|
|
|
59eb7a |
@@ -1499,8 +1502,9 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
|
|
|
59eb7a |
sPAPROptionVector *ov1_guest, *ov5_guest, *ov5_cas_old, *ov5_updates;
|
|
|
59eb7a |
bool guest_radix;
|
|
|
59eb7a |
Error *local_err = NULL;
|
|
|
59eb7a |
+ bool raw_mode_supported = false;
|
|
|
59eb7a |
|
|
|
59eb7a |
- cas_pvr = cas_check_pvr(spapr, cpu, &addr, &local_err);
|
|
|
59eb7a |
+ cas_pvr = cas_check_pvr(spapr, cpu, &addr, &raw_mode_supported, &local_err);
|
|
|
59eb7a |
if (local_err) {
|
|
|
59eb7a |
error_report_err(local_err);
|
|
|
59eb7a |
return H_HARDWARE;
|
|
|
59eb7a |
@@ -1510,8 +1514,14 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
|
|
|
59eb7a |
if (cpu->compat_pvr != cas_pvr) {
|
|
|
59eb7a |
ppc_set_compat_all(cas_pvr, &local_err);
|
|
|
59eb7a |
if (local_err) {
|
|
|
59eb7a |
- error_report_err(local_err);
|
|
|
59eb7a |
- return H_HARDWARE;
|
|
|
59eb7a |
+ /* We fail to set compat mode (likely because running with KVM PR),
|
|
|
59eb7a |
+ * but maybe we can fallback to raw mode if the guest supports it.
|
|
|
59eb7a |
+ */
|
|
|
59eb7a |
+ if (!raw_mode_supported) {
|
|
|
59eb7a |
+ error_report_err(local_err);
|
|
|
59eb7a |
+ return H_HARDWARE;
|
|
|
59eb7a |
+ }
|
|
|
59eb7a |
+ local_err = NULL;
|
|
|
59eb7a |
}
|
|
|
59eb7a |
}
|
|
|
59eb7a |
|