Skip to contentSkip to conversation

powerpc/kvm: support to handle sw breakpoint

PATCH Superseded Madhavan Srinivasan 2 participants 5 messages Jul 1, 2014 – Jul 4, 2014

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 powerpc/kvm: support to handle sw breakpoint

This patch adds kernel side support for software breakpoint. Design is that, by using an illegal instruction, we trap to hypervisor via Emulation Assistance interrupt, where we check for the illegal instruction and accordingly we return to Host or Guest. Patch also adds support for software breakpoint in PR KVM.

Patch mandates use of "abs" instruction as sw breakpoint instruction (primary opcode 31 and extended opcode 360). Based on PowerISA v2.01, ABS instruction has been dropped from the architecture and treated an illegal instruction.

Changes v1->v2:

Moved the debug instruction #def to kvm_book3s.h. This way PR_KVM can also share it. Added code to use KVM get one reg infrastructure to get debug opcode. Updated emulate.c to include emulation of debug instruction incase of PR_KVM. Made changes to commit message.

---
 arch/powerpc/include/asm/kvm_book3s.h |    8 ++++++++
 arch/powerpc/include/asm/ppc-opcode.h |    5 +++++
 arch/powerpc/kvm/book3s.c             |    3 ++-
 arch/powerpc/kvm/book3s_hv.c          |    9 +++++++++
 arch/powerpc/kvm/book3s_pr.c          |    3 +++
 arch/powerpc/kvm/emulate.c            |   10 ++++++++++
 6 files changed, 37 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/kvm_book3s.h +8 -0
index f52f656..180d549 100644
@@ -24,6 +24,14 @@
 #include <linux/kvm_host.h>
 #include <asm/kvm_book3s_asm.h>
 
+/*
+ * KVMPPC_INST_BOOK3S_DEBUG is debug Instruction for supporting Software Breakpoint.
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended opcode is 360.
+ * Based on PowerISA v2.01, ABS instruction has been dropped from the architecture
+ * and treated an illegal instruction.
+ */
+#define KVMPPC_INST_BOOK3S_DEBUG	0x7c0002d0
+
 struct kvmppc_bat {
 	u64 raw;
 	u32 bepi;
arch/powerpc/include/asm/ppc-opcode.h +5 -0
index 3132bb9..3fbb4c1 100644
@@ -111,6 +111,11 @@
 #define OP_31_XOP_LHBRX     790
 #define OP_31_XOP_STHBRX    918
 
+/* KVMPPC_INST_BOOK3S_DEBUG -- Software breakpoint Instruction
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended opcode is 360.
+ */
+#define OP_31_XOP_ABS	    360
+
 #define OP_LWZ  32
 #define OP_LD   58
 #define OP_LWZU 33
arch/powerpc/kvm/book3s.c +2 -1
index c254c27..b40fe5d 100644
@@ -789,7 +789,8 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
 int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
 					struct kvm_guest_debug *dbg)
 {
-	return -EINVAL;
+	vcpu->guest_debug = dbg->control;
+	return 0;
 }
 
 void kvmppc_decrementer_func(unsigned long data)
arch/powerpc/kvm/book3s_hv.c +9 -0
index 7a12edb..402c1ec 100644
@@ -725,8 +725,14 @@ static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu,
 	 * we don't emulate any guest instructions at this stage.
 	 */
 	case BOOK3S_INTERRUPT_H_EMUL_ASSIST:
+	if (kvmppc_get_last_inst(vcpu) == KVMPPC_INST_BOOK3S_DEBUG ) {
+		run->exit_reason = KVM_EXIT_DEBUG;
+		run->debug.arch.address = kvmppc_get_pc(vcpu);
+		r = RESUME_HOST;
+	} else {
 		kvmppc_core_queue_program(vcpu, SRR1_PROGILL);
 		r = RESUME_GUEST;
+	}
 		break;
 	/*
 	 * This occurs if the guest (kernel or userspace), does something that
@@ -831,6 +837,9 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
 	long int i;
 
 	switch (id) {
+	case KVM_REG_PPC_DEBUG_INST:
+		*val = get_reg_val(id, KVMPPC_INST_BOOK3S_DEBUG);
+		break;
 	case KVM_REG_PPC_HIOR:
 		*val = get_reg_val(id, 0);
 		break;
arch/powerpc/kvm/book3s_pr.c +3 -0
index 8eef1e5..27f5234 100644
@@ -1229,6 +1229,9 @@ static int kvmppc_get_one_reg_pr(struct kvm_vcpu *vcpu, u64 id,
 	int r = 0;
 
 	switch (id) {
+	case KVM_REG_PPC_DEBUG_INST:
+		*val = get_reg_val(id, KVMPPC_INST_BOOK3S_DEBUG);
+		break;
 	case KVM_REG_PPC_HIOR:
 		*val = get_reg_val(id, to_book3s(vcpu)->hior);
 		break;
arch/powerpc/kvm/emulate.c +10 -0
index da86d9b..13fba51 100644
@@ -363,6 +363,16 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
 			                               2, 0);
 			break;
 
+		case OP_31_XOP_ABS:
+			/*
+			 * This is debug instruction. So we dont emulate instead,
+			 * We fill the pc and exit code and direct the return to host.
+			 */
+			run->exit_reason = KVM_EXIT_DEBUG;
+			run->debug.arch.address = kvmppc_get_pc(vcpu);
+			emulated = EMULATE_EXIT_USER;
+			break;
+
 		default:
 			/* Attempt core-specific emulation below. */
 			emulated = EMULATE_FAIL;
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 33 lines · Madhavan Srinivasan

This patch adds kernel side support for software breakpoint. Design is that, by using an illegal instruction, we trap to hypervisor via Emulation Assistance interrupt, where we check for the illegal instruction and accordingly we return to Host or Guest. Patch also adds support for software breakpoint in PR KVM.

Patch mandates use of "abs" instruction as sw breakpoint instruction (primary opcode 31 and extended opcode 360). Based on PowerISA v2.01, ABS instruction has been dropped from the architecture and treated an illegal instruction.

Changes v1->v2:

Moved the debug instruction #def to kvm_book3s.h. This way PR_KVM can also share it. Added code to use KVM get one reg infrastructure to get debug opcode. Updated emulate.c to include emulation of debug instruction incase of PR_KVM. Made changes to commit message.

---
  arch/powerpc/include/asm/kvm_book3s.h |    8 ++++++++
  arch/powerpc/include/asm/ppc-opcode.h |    5 +++++
  arch/powerpc/kvm/book3s.c             |    3 ++-
  arch/powerpc/kvm/book3s_hv.c          |    9 +++++++++
  arch/powerpc/kvm/book3s_pr.c          |    3 +++
  arch/powerpc/kvm/emulate.c            |   10 ++++++++++
  6 files changed, 37 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/kvm_book3s.h +0 -0
index f52f656..180d549 100644

arch/powerpc/include/asm/kvm_book3s.h line 33

Quoted 10 lines
arch/powerpc/include/asm/kvm_book3s.h +7 -0
@@ -24,6 +24,14 @@
  #include <linux/kvm_host.h>
  #include <asm/kvm_book3s_asm.h>
 
+/*
+ * KVMPPC_INST_BOOK3S_DEBUG is debug Instruction for supporting Software Breakpoint.
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended opcode is 360.
+ * Based on PowerISA v2.01, ABS instruction has been dropped from the architecture
+ * and treated an illegal instruction.
+ */
+#define KVMPPC_INST_BOOK3S_DEBUG	0x7c0002d0

This will still break with LE guests.

Quoted 39 lines
arch/powerpc/include/asm/kvm_book3s.h +1 -0
+
  struct kvmppc_bat {
  	u64 raw;
  	u32 bepi;
arch/powerpc/include/asm/ppc-opcode.h +5 -0
index 3132bb9..3fbb4c1 100644
@@ -111,6 +111,11 @@
  #define OP_31_XOP_LHBRX     790
  #define OP_31_XOP_STHBRX    918
 
+/* KVMPPC_INST_BOOK3S_DEBUG -- Software breakpoint Instruction
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended opcode is 360.
+ */
+#define OP_31_XOP_ABS	    360
+
  #define OP_LWZ  32
  #define OP_LD   58
  #define OP_LWZU 33
arch/powerpc/kvm/book3s.c +2 -1
index c254c27..b40fe5d 100644
@@ -789,7 +789,8 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
  int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
  					struct kvm_guest_debug *dbg)
  {
-	return -EINVAL;
+	vcpu->guest_debug = dbg->control;
+	return 0;
  }
 
  void kvmppc_decrementer_func(unsigned long data)
arch/powerpc/kvm/book3s_hv.c +0 -0
index 7a12edb..402c1ec 100644

arch/powerpc/kvm/book3s_hv.c static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu, · line 731

Quoted 7 lines
arch/powerpc/kvm/book3s_hv.c +4 -0
@@ -725,8 +725,14 @@ static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu,
  	 * we don't emulate any guest instructions at this stage.
  	 */
  	case BOOK3S_INTERRUPT_H_EMUL_ASSIST:
+	if (kvmppc_get_last_inst(vcpu) == KVMPPC_INST_BOOK3S_DEBUG ) {
+		run->exit_reason = KVM_EXIT_DEBUG;
+		run->debug.arch.address = kvmppc_get_pc(vcpu);
+		r = RESUME_HOST;

Phew - why can't we just go into the normal instruction emulator for EMUL_ASSIST?

Alex

#2 lore raw
Quoted 45 lines · Alexander Graf
Quoted 43 lines · Madhavan Srinivasan

This patch adds kernel side support for software breakpoint. Design is that, by using an illegal instruction, we trap to hypervisor via Emulation Assistance interrupt, where we check for the illegal instruction
and accordingly we return to Host or Guest. Patch also adds support for software breakpoint in PR KVM.

Patch mandates use of "abs" instruction as sw breakpoint instruction (primary opcode 31 and extended opcode 360). Based on PowerISA v2.01, ABS instruction has been dropped from the architecture and treated an illegal instruction.

Changes v1->v2:

Moved the debug instruction #def to kvm_book3s.h. This way PR_KVM
can also share it.
Added code to use KVM get one reg infrastructure to get debug opcode. Updated emulate.c to include emulation of debug instruction incase
of PR_KVM.
Made changes to commit message.

---
  arch/powerpc/include/asm/kvm_book3s.h |    8 ++++++++
  arch/powerpc/include/asm/ppc-opcode.h |    5 +++++
  arch/powerpc/kvm/book3s.c             |    3 ++-
  arch/powerpc/kvm/book3s_hv.c          |    9 +++++++++
  arch/powerpc/kvm/book3s_pr.c          |    3 +++
  arch/powerpc/kvm/emulate.c            |   10 ++++++++++
  6 files changed, 37 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/kvm_book3s.h +1 -0
index f52f656..180d549 100644
@@ -24,6 +24,14 @@
  #include <linux/kvm_host.h>
  #include <asm/kvm_book3s_asm.h>
  +/*
+ * KVMPPC_INST_BOOK3S_DEBUG is debug Instruction for supporting

Software Breakpoint.
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended

Quoted 9 lines
Quoted 6 lines

opcode is 360.
+ * Based on PowerISA v2.01, ABS instruction has been dropped from the architecture
+ * and treated an illegal instruction.
+ */
+#define KVMPPC_INST_BOOK3S_DEBUG 0x7c0002d0

This will still break with LE guests.

I am told to try with all 0s opcode. So rewriting the patch.

Quoted 43 lines
Quoted 43 lines
arch/powerpc/include/asm/kvm_book3s.h +1 -0
+
  struct kvmppc_bat {
      u64 raw;
      u32 bepi;
arch/powerpc/include/asm/ppc-opcode.h +1 -0
index 3132bb9..3fbb4c1 100644
@@ -111,6 +111,11 @@
  #define OP_31_XOP_LHBRX     790
  #define OP_31_XOP_STHBRX    918
  +/* KVMPPC_INST_BOOK3S_DEBUG -- Software breakpoint Instruction
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended

opcode is 360.
+ */

arch/powerpc/include/asm/ppc-opcode.h +2 -0
+#define OP_31_XOP_ABS        360
+
  #define OP_LWZ  32
  #define OP_LD   58
  #define OP_LWZU 33
arch/powerpc/kvm/book3s.c +2 -1
index c254c27..b40fe5d 100644
@@ -789,7 +789,8 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu
 *vcpu,
  int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
                      struct kvm_guest_debug *dbg)
  {
-    return -EINVAL;
+    vcpu->guest_debug = dbg->control;
+    return 0;
  }
    void kvmppc_decrementer_func(unsigned long data)
arch/powerpc/kvm/book3s_hv.c +0 -0
index 7a12edb..402c1ec 100644
@@ -725,8 +725,14 @@ static int kvmppc_handle_exit_hv(struct kvm_run
 *run, struct kvm_vcpu *vcpu,
       * we don't emulate any guest instructions at this stage.
       */
Quoted 9 lines

arch/powerpc/kvm/book3s_hv.c static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu, · line 731

Quoted 5 lines
arch/powerpc/kvm/book3s_hv.c +4 -0
      case BOOK3S_INTERRUPT_H_EMUL_ASSIST:
+    if (kvmppc_get_last_inst(vcpu) == KVMPPC_INST_BOOK3S_DEBUG ) {
+        run->exit_reason = KVM_EXIT_DEBUG;
+        run->debug.arch.address = kvmppc_get_pc(vcpu);
+        r = RESUME_HOST;

Phew - why can't we just go into the normal instruction emulator for EMUL_ASSIST?

IIUC, using the emulation_assist_interrupt function (kernel/trap.c) ?

Thanks for review
Regards
Maddy

Quoted 3 lines

Alex

#3 lore raw
Quoted 53 lines · Madhavan Srinivasan
Quoted 43 lines · Alexander Graf
Quoted 42 lines · Madhavan Srinivasan

This patch adds kernel side support for software breakpoint. Design is that, by using an illegal instruction, we trap to hypervisor via Emulation Assistance interrupt, where we check for the illegal instruction
and accordingly we return to Host or Guest. Patch also adds support for software breakpoint in PR KVM.

Patch mandates use of "abs" instruction as sw breakpoint instruction (primary opcode 31 and extended opcode 360). Based on PowerISA v2.01, ABS instruction has been dropped from the architecture and treated an illegal instruction.

Changes v1->v2:

Moved the debug instruction #def to kvm_book3s.h. This way PR_KVM
can also share it.
Added code to use KVM get one reg infrastructure to get debug opcode. Updated emulate.c to include emulation of debug instruction incase
of PR_KVM.
Made changes to commit message.

---
   arch/powerpc/include/asm/kvm_book3s.h |    8 ++++++++
   arch/powerpc/include/asm/ppc-opcode.h |    5 +++++
   arch/powerpc/kvm/book3s.c             |    3 ++-
   arch/powerpc/kvm/book3s_hv.c          |    9 +++++++++
   arch/powerpc/kvm/book3s_pr.c          |    3 +++
   arch/powerpc/kvm/emulate.c            |   10 ++++++++++
   6 files changed, 37 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/kvm_book3s.h +1 -0
index f52f656..180d549 100644
@@ -24,6 +24,14 @@
   #include <linux/kvm_host.h>
   #include <asm/kvm_book3s_asm.h>
   +/*
+ * KVMPPC_INST_BOOK3S_DEBUG is debug Instruction for supporting

Software Breakpoint.

Quoted 9 lines
Quoted 7 lines

+ * Instruction mnemonic is ABS, primary opcode is 31 and extended opcode is 360.
+ * Based on PowerISA v2.01, ABS instruction has been dropped from the architecture
+ * and treated an illegal instruction.
+ */
+#define KVMPPC_INST_BOOK3S_DEBUG 0x7c0002d0

This will still break with LE guests.

Quoted 1 line

I am told to try with all 0s opcode. So rewriting the patch.

The problem with "all 0s" is that it's reasonably likely to occur on real world code. Hence Segher was proposing something like 0x00dddd00 which should be the same regardless of endianness, but has a certain appeal of intentional placement ;).

Quoted 52 lines
Quoted 43 lines
Quoted 43 lines
arch/powerpc/include/asm/kvm_book3s.h +1 -0
+
   struct kvmppc_bat {
       u64 raw;
       u32 bepi;
arch/powerpc/include/asm/ppc-opcode.h +1 -0
index 3132bb9..3fbb4c1 100644
@@ -111,6 +111,11 @@
   #define OP_31_XOP_LHBRX     790
   #define OP_31_XOP_STHBRX    918
   +/* KVMPPC_INST_BOOK3S_DEBUG -- Software breakpoint Instruction
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended

opcode is 360.
+ */

arch/powerpc/include/asm/ppc-opcode.h +2 -0
+#define OP_31_XOP_ABS        360
+
   #define OP_LWZ  32
   #define OP_LD   58
   #define OP_LWZU 33
arch/powerpc/kvm/book3s.c +2 -1
index c254c27..b40fe5d 100644
@@ -789,7 +789,8 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu
 *vcpu,
   int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
                       struct kvm_guest_debug *dbg)
   {
-    return -EINVAL;
+    vcpu->guest_debug = dbg->control;
+    return 0;
   }
     void kvmppc_decrementer_func(unsigned long data)
arch/powerpc/kvm/book3s_hv.c +0 -0
index 7a12edb..402c1ec 100644
@@ -725,8 +725,14 @@ static int kvmppc_handle_exit_hv(struct kvm_run
 *run, struct kvm_vcpu *vcpu,
        * we don't emulate any guest instructions at this stage.
Quoted 9 lines

arch/powerpc/kvm/book3s_hv.c static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu, · line 731

Quoted 6 lines
arch/powerpc/kvm/book3s_hv.c +4 -0
        */
       case BOOK3S_INTERRUPT_H_EMUL_ASSIST:
+    if (kvmppc_get_last_inst(vcpu) = KVMPPC_INST_BOOK3S_DEBUG ) {
+        run->exit_reason = KVM_EXIT_DEBUG;
+        run->debug.arch.address = kvmppc_get_pc(vcpu);
+        r = RESUME_HOST;

Phew - why can't we just go into the normal instruction emulator for EMUL_ASSIST?

Quoted 1 line

IIUC, using the emulation_assist_interrupt function (kernel/trap.c) ?

I was more thinking of kvmppc_emulate_instruction() :).

Alex

#4 lore raw
Quoted 56 lines · Alexander Graf
Quoted 54 lines · Madhavan Srinivasan
Quoted 53 lines · Alexander Graf
Quoted 42 lines · Madhavan Srinivasan

This patch adds kernel side support for software breakpoint. Design is that, by using an illegal instruction, we trap to hypervisor via Emulation Assistance interrupt, where we check for the illegal instruction
and accordingly we return to Host or Guest. Patch also adds support for software breakpoint in PR KVM.

Patch mandates use of "abs" instruction as sw breakpoint instruction (primary opcode 31 and extended opcode 360). Based on PowerISA v2.01, ABS instruction has been dropped from the architecture and treated an illegal instruction.

Changes v1->v2:

Moved the debug instruction #def to kvm_book3s.h. This way PR_KVM
can also share it.
Added code to use KVM get one reg infrastructure to get debug
opcode.
Updated emulate.c to include emulation of debug instruction incase
of PR_KVM.
Made changes to commit message.

---
   arch/powerpc/include/asm/kvm_book3s.h |    8 ++++++++
   arch/powerpc/include/asm/ppc-opcode.h |    5 +++++
   arch/powerpc/kvm/book3s.c             |    3 ++-
   arch/powerpc/kvm/book3s_hv.c          |    9 +++++++++
   arch/powerpc/kvm/book3s_pr.c          |    3 +++
   arch/powerpc/kvm/emulate.c            |   10 ++++++++++
   6 files changed, 37 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/kvm_book3s.h +1 -0
index f52f656..180d549 100644
@@ -24,6 +24,14 @@
   #include <linux/kvm_host.h>
   #include <asm/kvm_book3s_asm.h>
   +/*
+ * KVMPPC_INST_BOOK3S_DEBUG is debug Instruction for supporting
Quoted 8 lines

Software Breakpoint.
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended opcode is 360.
+ * Based on PowerISA v2.01, ABS instruction has been dropped from the architecture
+ * and treated an illegal instruction.
+ */
+#define KVMPPC_INST_BOOK3S_DEBUG 0x7c0002d0

This will still break with LE guests.

Quoted 7 lines
Quoted 1 line

I am told to try with all 0s opcode. So rewriting the patch.

The problem with "all 0s" is that it's reasonably likely to occur on real world code. Hence Segher was proposing something like 0x00dddd00 which should be the same regardless of endianness, but has a certain appeal of intentional placement ;).

Ok Sure.

Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 42 lines
arch/powerpc/include/asm/kvm_book3s.h +1 -0
+
   struct kvmppc_bat {
       u64 raw;
       u32 bepi;
arch/powerpc/include/asm/ppc-opcode.h +1 -0
index 3132bb9..3fbb4c1 100644
@@ -111,6 +111,11 @@
   #define OP_31_XOP_LHBRX     790
   #define OP_31_XOP_STHBRX    918
   +/* KVMPPC_INST_BOOK3S_DEBUG -- Software breakpoint Instruction
+ * Instruction mnemonic is ABS, primary opcode is 31 and extended

opcode is 360.
+ */

arch/powerpc/include/asm/ppc-opcode.h +2 -0
+#define OP_31_XOP_ABS        360
+
   #define OP_LWZ  32
   #define OP_LD   58
   #define OP_LWZU 33
arch/powerpc/kvm/book3s.c +2 -1
index c254c27..b40fe5d 100644
@@ -789,7 +789,8 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu
 *vcpu,
   int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
                       struct kvm_guest_debug *dbg)
   {
-    return -EINVAL;
+    vcpu->guest_debug = dbg->control;
+    return 0;
   }
     void kvmppc_decrementer_func(unsigned long data)
arch/powerpc/kvm/book3s_hv.c +0 -0
index 7a12edb..402c1ec 100644

arch/powerpc/kvm/book3s_hv.c static int kvmppc_handle_exit_hv(struct kvm_run · line 732

Quoted 8 lines
arch/powerpc/kvm/book3s_hv.c +4 -0
@@ -725,8 +725,14 @@ static int kvmppc_handle_exit_hv(struct kvm_run
 *run, struct kvm_vcpu *vcpu,
        * we don't emulate any guest instructions at this stage.
        */
       case BOOK3S_INTERRUPT_H_EMUL_ASSIST:
+    if (kvmppc_get_last_inst(vcpu) == KVMPPC_INST_BOOK3S_DEBUG ) {
+        run->exit_reason = KVM_EXIT_DEBUG;
+        run->debug.arch.address = kvmppc_get_pc(vcpu);
+        r = RESUME_HOST;

Phew - why can't we just go into the normal instruction emulator for EMUL_ASSIST?

Quoted 4 lines
Quoted 1 line

IIUC, using the emulation_assist_interrupt function (kernel/trap.c) ?

I was more thinking of kvmppc_emulate_instruction() :).

This makes sense. Can use the same call for pr kvm also. awesome :)

Quoted 3 lines

Alex

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev