KVM: PPC: Book3S PR: Exiting split hack mode needs to fixup both PC and LR

Message ID 201807311439.w6VEdLPU13304044@floodgap.com
State New
Headers show
Series
  • KVM: PPC: Book3S PR: Exiting split hack mode needs to fixup both PC and LR
Related show

Commit Message

Cameron Kaiser July 31, 2018, 2:39 p.m.
When an OS (currently only classic Mac OS) is running in KVM-PR and makes a
linked jump from code with split hack addressing enabled into code that does
not, LR is not correctly updated and reflects the previously munged PC. This
undoes the address munge when exiting split hack mode so that code relying
on LR being a proper address will now execute. This does not affect OS X
or other operating systems running on KVM-PR.

Signed-off-by: Cameron Kaiser <spectre@floodgap.com>

---
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index 97d4a112..2267e9b4 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -74,18 +74,21 @@  struct kvm_stats_debugfs_item debugfs_entries[] = {
        { "pthru_bad_aff",   VCPU_STAT(pthru_bad_aff) },
        { NULL }
 };
 
 void kvmppc_unfixup_split_real(struct kvm_vcpu *vcpu)
 {
        if (vcpu->arch.hflags & BOOK3S_HFLAG_SPLIT_HACK) {
                ulong pc = kvmppc_get_pc(vcpu);
+               ulong lr = kvmppc_get_lr(vcpu);
                if ((pc & SPLIT_HACK_MASK) == SPLIT_HACK_OFFS)
                        kvmppc_set_pc(vcpu, pc & ~SPLIT_HACK_MASK);
+               if ((lr & SPLIT_HACK_MASK) == SPLIT_HACK_OFFS)
+                       kvmppc_set_lr(vcpu, lr & ~SPLIT_HACK_MASK);
                vcpu->arch.hflags &= ~BOOK3S_HFLAG_SPLIT_HACK;
        }
 }
 EXPORT_SYMBOL_GPL(kvmppc_unfixup_split_real);
 
 static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu)
 {
        if (!is_kvmppc_hv_enabled(vcpu->kvm))