aboutsummaryrefslogtreecommitdiff
path: root/target/ppc/kvm.c
diff options
context:
space:
mode:
authorGreg Kurz <groug@kaod.org>2017-09-25 13:00:02 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2017-09-27 13:05:41 +1000
commit1ec26c757d5996468afcc0dced4fad04139574b3 (patch)
tree2718d87821896125e083323d9cbc4019726b1c4e /target/ppc/kvm.c
parent15fcedb26fce9cde3f3a2cec533101b6fe43f6e5 (diff)
spapr: fix the value of SDR1 in kvmppc_put_books_sregs()
When running with KVM PR, if a new HPT is allocated we need to inform KVM about the HPT address and size. This is currently done by hacking the value of SDR1 and pushing it to KVM in several places. Also, migration breaks the guest since it is very unlikely the HPT has the same address in source and destination, but we push the incoming value of SDR1 to KVM anyway. This patch introduces a new virtual hypervisor hook so that the spapr code can provide the correct value of SDR1 to be pushed to KVM each time kvmppc_put_books_sregs() is called. It allows to get rid of all the hacking in the spapr/kvmppc code and it fixes migration of nested KVM PR. Suggested-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Greg Kurz <groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'target/ppc/kvm.c')
-rw-r--r--target/ppc/kvm.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 5b281b2f1b..171d3d8040 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -941,7 +941,13 @@ int kvmppc_put_books_sregs(PowerPCCPU *cpu)
sregs.pvr = env->spr[SPR_PVR];
- sregs.u.s.sdr1 = env->spr[SPR_SDR1];
+ if (cpu->vhyp) {
+ PPCVirtualHypervisorClass *vhc =
+ PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
+ sregs.u.s.sdr1 = vhc->encode_hpt_for_kvm_pr(cpu->vhyp);
+ } else {
+ sregs.u.s.sdr1 = env->spr[SPR_SDR1];
+ }
/* Sync SLB */
#ifdef TARGET_PPC64
@@ -2798,30 +2804,6 @@ int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift)
return kvm_vm_ioctl(cs->kvm_state, KVM_PPC_RESIZE_HPT_COMMIT, &rhpt);
}
-static void kvmppc_pivot_hpt_cpu(CPUState *cs, run_on_cpu_data arg)
-{
- target_ulong sdr1 = arg.target_ptr;
- PowerPCCPU *cpu = POWERPC_CPU(cs);
- CPUPPCState *env = &cpu->env;
-
- /* This is just for the benefit of PR KVM */
- cpu_synchronize_state(cs);
- env->spr[SPR_SDR1] = sdr1;
- if (kvmppc_put_books_sregs(cpu) < 0) {
- error_report("Unable to update SDR1 in KVM");
- exit(1);
- }
-}
-
-void kvmppc_update_sdr1(target_ulong sdr1)
-{
- CPUState *cs;
-
- CPU_FOREACH(cs) {
- run_on_cpu(cs, kvmppc_pivot_hpt_cpu, RUN_ON_CPU_TARGET_PTR(sdr1));
- }
-}
-
/*
* This is a helper function to detect a post migration scenario
* in which a guest, running as KVM-HV, freezes in cpu_post_load because