Skip to contentSkip to conversation

KVM: PPC: BookE: Include trap in pt_regs

PATCH In review Alexander Graf 2 participants 6 messages May 16, 2012 – May 17, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: PPC: BookE: Include trap in pt_regs

When reinjecting host interrupt requests in the exit handler code, let's also tell the interrupt handler which interrupt number we're coming from.

---
 arch/powerpc/kvm/booke.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/kvm/booke.c +7 -5
index 72f13f4..0512bd7 100644
@@ -596,7 +596,8 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 	}
 }
 
-static void kvmppc_fill_pt_regs(struct pt_regs *regs)
+static void kvmppc_fill_pt_regs(struct pt_regs *regs,
+				int exit_nr)
 {
 	ulong r1, ip, msr, lr;
 
@@ -610,6 +611,7 @@ static void kvmppc_fill_pt_regs(struct pt_regs *regs)
 	regs->nip = ip;
 	regs->msr = msr;
 	regs->link = lr;
+	regs->trap = exit_nr;
 }
 
 static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
@@ -619,16 +621,16 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
 
 	switch (exit_nr) {
 	case BOOKE_INTERRUPT_EXTERNAL:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		do_IRQ(&regs);
 		break;
 	case BOOKE_INTERRUPT_DECREMENTER:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		timer_interrupt(&regs);
 		break;
 #if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3E_64)
 	case BOOKE_INTERRUPT_DOORBELL:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		doorbell_exception(&regs);
 		break;
 #endif
@@ -636,7 +638,7 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
 		/* FIXME */
 		break;
 	case BOOKE_INTERRUPT_PERFORMANCE_MONITOR:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		performance_monitor_exception(&regs);
 		break;
 	}
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 32 lines · Alexander Graf

When reinjecting host interrupt requests in the exit handler code, let's also tell the interrupt handler which interrupt number we're coming from.

---
 arch/powerpc/kvm/booke.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/kvm/booke.c +3 -1
index 72f13f4..0512bd7 100644
@@ -596,7 +596,8 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 	}
 }
 
-static void kvmppc_fill_pt_regs(struct pt_regs *regs)
+static void kvmppc_fill_pt_regs(struct pt_regs *regs,
+				int exit_nr)
 {
 	ulong r1, ip, msr, lr;
 
@@ -610,6 +611,7 @@ static void kvmppc_fill_pt_regs(struct pt_regs *regs)
 	regs->nip = ip;
 	regs->msr = msr;
 	regs->link = lr;
+	regs->trap = exit_nr;
 }
 
 static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,

arch/powerpc/kvm/booke.c static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu, · line 626

Quoted 7 lines
arch/powerpc/kvm/booke.c +1 -1
@@ -619,16 +621,16 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
 
 	switch (exit_nr) {
 	case BOOKE_INTERRUPT_EXTERNAL:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		do_IRQ(&regs);
 		break;

exit_nr is not the same as the trap number that the rest of the kernel wants to see.

-Scott

#2 lore raw
Quoted 34 lines · Scott Wood
Quoted 33 lines · Alexander Graf

When reinjecting host interrupt requests in the exit handler code, let's also tell the interrupt handler which interrupt number we're coming from.

---
arch/powerpc/kvm/booke.c | 12 +++++++-----

1 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/kvm/booke.c +3 -1
index 72f13f4..0512bd7 100644
@@ -596,7 +596,8 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 	}
 }
 
-static void kvmppc_fill_pt_regs(struct pt_regs *regs)
+static void kvmppc_fill_pt_regs(struct pt_regs *regs,
+				int exit_nr)
 {
 	ulong r1, ip, msr, lr;
 
@@ -610,6 +611,7 @@ static void kvmppc_fill_pt_regs(struct pt_regs *regs)
 	regs->nip = ip;
 	regs->msr = msr;
 	regs->link = lr;
+	regs->trap = exit_nr;
 }
 
 static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
@@ -619,16 +621,16 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
 
Quoted 9 lines

arch/powerpc/kvm/booke.c static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu, · line 626

Quoted 6 lines
arch/powerpc/kvm/booke.c +1 -1
 	switch (exit_nr) {
 	case BOOKE_INTERRUPT_EXTERNAL:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		do_IRQ(&regs);
 		break;

exit_nr is not the same as the trap number that the rest of the kernel wants to see.

It's not? What does the kernel want to see then?

Alex

#3 lore raw
Quoted 47 lines · Alexander Graf
Quoted 34 lines · Scott Wood
Quoted 33 lines · Alexander Graf

When reinjecting host interrupt requests in the exit handler code, let's also tell the interrupt handler which interrupt number we're coming from.

---
arch/powerpc/kvm/booke.c | 12 +++++++-----

1 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/kvm/booke.c +3 -1
index 72f13f4..0512bd7 100644
@@ -596,7 +596,8 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 	}
 }
 
-static void kvmppc_fill_pt_regs(struct pt_regs *regs)
+static void kvmppc_fill_pt_regs(struct pt_regs *regs,
+				int exit_nr)
 {
 	ulong r1, ip, msr, lr;
 
@@ -610,6 +611,7 @@ static void kvmppc_fill_pt_regs(struct pt_regs *regs)
 	regs->nip = ip;
 	regs->msr = msr;
 	regs->link = lr;
+	regs->trap = exit_nr;
 }
 
 static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
@@ -619,16 +621,16 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
 
Quoted 9 lines

arch/powerpc/kvm/booke.c static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu, · line 626

Quoted 6 lines
arch/powerpc/kvm/booke.c +1 -1
 	switch (exit_nr) {
 	case BOOKE_INTERRUPT_EXTERNAL:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		do_IRQ(&regs);
 		break;

exit_nr is not the same as the trap number that the rest of the kernel wants to see.

Quoted 1 line

It's not? What does the kernel want to see then?

Remember the commit message in the e500mc patchset about an undocumented, unnamed mess of magic numbers?

-Scott

#4 lore raw
Quoted 48 lines · Scott Wood
Quoted 47 lines · Alexander Graf
Quoted 43 lines · Scott Wood
Quoted 32 lines · Alexander Graf

When reinjecting host interrupt requests in the exit handler code, let's also tell the interrupt handler which interrupt number we're coming from.

---
arch/powerpc/kvm/booke.c | 12 +++++++-----

1 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/kvm/booke.c +3 -1
index 72f13f4..0512bd7 100644
@@ -596,7 +596,8 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 	}
 }
 
-static void kvmppc_fill_pt_regs(struct pt_regs *regs)
+static void kvmppc_fill_pt_regs(struct pt_regs *regs,
+				int exit_nr)
 {
 	ulong r1, ip, msr, lr;
 
@@ -610,6 +611,7 @@ static void kvmppc_fill_pt_regs(struct pt_regs *regs)
 	regs->nip = ip;
 	regs->msr = msr;
 	regs->link = lr;
+	regs->trap = exit_nr;
 }
 
 static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,

arch/powerpc/kvm/booke.c static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu, · line 626

Quoted 7 lines
arch/powerpc/kvm/booke.c +1 -1
@@ -619,16 +621,16 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
 
 	switch (exit_nr) {
 	case BOOKE_INTERRUPT_EXTERNAL:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		do_IRQ(&regs);
 		break;

exit_nr is not the same as the trap number that the rest of the kernel wants to see.

Quoted 4 lines
Quoted 1 line

It's not? What does the kernel want to see then?

Remember the commit message in the e500mc patchset about an undocumented, unnamed mess of magic numbers?

Yeah. So in KVM we're using the IVOR numbers, right? Any reason we can't do the same for the generic handler? That should simplify the code significantly, no?

I guess I should've checked on this a bit deeper - book3s does the above already :).

Alex

#5 lore raw
Quoted 51 lines · Alexander Graf
Quoted 48 lines · Scott Wood
Quoted 47 lines · Alexander Graf
Quoted 43 lines · Scott Wood
Quoted 32 lines · Alexander Graf

When reinjecting host interrupt requests in the exit handler code, let's also tell the interrupt handler which interrupt number we're coming from.

---
arch/powerpc/kvm/booke.c | 12 +++++++-----

1 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/kvm/booke.c +3 -1
index 72f13f4..0512bd7 100644
@@ -596,7 +596,8 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 	}
 }
 
-static void kvmppc_fill_pt_regs(struct pt_regs *regs)
+static void kvmppc_fill_pt_regs(struct pt_regs *regs,
+				int exit_nr)
 {
 	ulong r1, ip, msr, lr;
 
@@ -610,6 +611,7 @@ static void kvmppc_fill_pt_regs(struct pt_regs *regs)
 	regs->nip = ip;
 	regs->msr = msr;
 	regs->link = lr;
+	regs->trap = exit_nr;
 }
 
 static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,

arch/powerpc/kvm/booke.c static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu, · line 626

Quoted 7 lines
arch/powerpc/kvm/booke.c +1 -1
@@ -619,16 +621,16 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
 
 	switch (exit_nr) {
 	case BOOKE_INTERRUPT_EXTERNAL:
-		kvmppc_fill_pt_regs(&regs);
+		kvmppc_fill_pt_regs(&regs, exit_nr);
 		do_IRQ(&regs);
 		break;

exit_nr is not the same as the trap number that the rest of the kernel wants to see.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

It's not? What does the kernel want to see then?

Remember the commit message in the e500mc patchset about an undocumented, unnamed mess of magic numbers?

Yeah. So in KVM we're using the IVOR numbers, right? Any reason we can't do the same for the generic handler? That should simplify the code significantly, no?

Yeah, I had that as a FIXME on the original patch. You just need to make sure all users are updated, which is more difficult due to the fact that they're just numbers and not symbolic names.

-Scott