Skip to contentSkip to conversation

KVM: PPC: Book3S HV: Reuse kvmppc_inject_interrupt for async guest delivery

PATCH In review Nicholas Piggin 2 participants 4 messages May 20, 2019 – Jun 19, 2019

Subsystems (2)
lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 3/5 KVM: PPC: Book3S HV: Reuse kvmppc_inject_interrupt for async guest delivery

---
 arch/powerpc/kvm/book3s.h            |  3 ++
 arch/powerpc/kvm/book3s_hv.c         | 45 -------------------
 arch/powerpc/kvm/book3s_hv_builtin.c | 65 ++++++++++++++++++++++------
 3 files changed, 54 insertions(+), 59 deletions(-)
arch/powerpc/kvm/book3s.h +3 -0
index 14ef03501d21..ce7360f4e784 100644
@@ -37,4 +37,7 @@ extern void kvmppc_emulate_tabort(struct kvm_vcpu *vcpu, int ra_val);
 static inline void kvmppc_emulate_tabort(struct kvm_vcpu *vcpu, int ra_val) {}
 #endif
 
+extern void kvmppc_set_msr_hv(struct kvm_vcpu *vcpu, u64 msr);
+extern void kvmppc_inject_interrupt_hv(struct kvm_vcpu *vcpu, int vec, u64 srr1_flags);
+
 #endif
arch/powerpc/kvm/book3s_hv.c +0 -45

63 lines not on this page · raw message

arch/powerpc/kvm/book3s_hv_builtin.c +51 -14

90 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw
In reply to Nicholas Piggin
Quoted 1 line · Nicholas Piggin

Comment below...

arch/powerpc/kvm/book3s_hv_builtin.c void kvmhv_p9_restore_lpcr(struct kvm_split_mode *sip) · line 765

Quoted 13 lines
arch/powerpc/kvm/book3s_hv_builtin.c +5 -0
index 6035d24f1d1d..5ae7f8359368 100644
@@ -758,6 +758,53 @@ void kvmhv_p9_restore_lpcr(struct kvm_split_mode *sip)
 	local_paca->kvm_hstate.kvm_split_mode = NULL;
 }
 
+static void kvmppc_end_cede(struct kvm_vcpu *vcpu)
+{
+	vcpu->arch.ceded = 0;
+	if (vcpu->arch.timer_running) {
+		hrtimer_try_to_cancel(&vcpu->arch.dec_timer);

So now we're potentially calling hrtimer_try_to_cancel in real mode. Are you absolutely sure that nothing in the hrtimer code accesses anything that is vmalloc'd? I'm not. Maybe you can prove that when called in real mode, vcpu->arch.timer_running will always be false, but it seems fragile to me.

Paul.

author reviewer
#3 lore raw
In reply to Nicholas Piggin

Paul Mackerras's on June 17, 2019 11:45 am:

Quoted 13 lines · Nicholas Piggin
Quoted 1 line

Comment below...

Quoted 8 lines
arch/powerpc/kvm/book3s_hv_builtin.c +0 -0
index 6035d24f1d1d..5ae7f8359368 100644
@@ -758,6 +758,53 @@ void kvmhv_p9_restore_lpcr(struct kvm_split_mode *sip)
 	local_paca->kvm_hstate.kvm_split_mode = NULL;
 }
 
Quoted 11 lines

arch/powerpc/kvm/book3s_hv_builtin.c void kvmhv_p9_restore_lpcr(struct kvm_split_mode *sip) · line 765

Quoted 5 lines
arch/powerpc/kvm/book3s_hv_builtin.c +5 -0
+static void kvmppc_end_cede(struct kvm_vcpu *vcpu)
+{
+	vcpu->arch.ceded = 0;
+	if (vcpu->arch.timer_running) {
+		hrtimer_try_to_cancel(&vcpu->arch.dec_timer);

So now we're potentially calling hrtimer_try_to_cancel in real mode. Are you absolutely sure that nothing in the hrtimer code accesses anything that is vmalloc'd? I'm not. Maybe you can prove that when called in real mode, vcpu->arch.timer_running will always be false, but it seems fragile to me.

Good point, no we shouldn't do this.

Is the guest always going to be out of cede at this point? Possibly just a variant of the function that doesn't end cede would be the go.

Thanks,
Nick