Skip to contentSkip to conversation

ppc patch queue 2012-12-18

GIT PULL In review Alexander Graf 3 participants 15 messages Dec 18, 2012 – Dec 19, 2012

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

Hi Marcelo / Gleb,

This is my current patch queue for ppc. Please pull.

Changes include:

- important header fix for UAPI
- Book3S: PR: Enable fake sc 1 instruction for KVM on top of pHyp

Alex

The following changes since commit e11ae1a102b46f76441e328a2743ae5d6e201423:
Gleb Natapov (1):
KVM: remove unused variable.

are available in the git repository at:

git://github.com/agraf/linux-2.6.git kvm-ppc-next

Alexander Graf (2):
KVM: PPC: Only WARN on invalid emulation
KVM: PPC: Book3S: PR: Enable alternative instruction for SC 1

Bharat Bhushan (1):
powerpc: Corrected include header path in kvm_para.h

Mihai Caraman (1):
KVM: PPC: Fix SREGS documentation reference

 Documentation/virtual/kvm/api.txt        |    2 +-
 arch/powerpc/include/asm/kvm_ppc.h       |    1 +
 arch/powerpc/include/uapi/asm/kvm_para.h |    2 +-
 arch/powerpc/kvm/book3s_emulate.c        |   28 ++++++++++++++++++++++++++++
 arch/powerpc/kvm/book3s_pr.c             |    5 +++++
 arch/powerpc/kvm/powerpc.c               |    3 ++-
 6 files changed, 38 insertions(+), 3 deletions(-)
#1 lore raw

PATCH 1/4 KVM: PPC: Fix SREGS documentation reference

From: Mihai Caraman <[email protected]>

Reflect the uapi folder change in SREGS API documentation.

---
 Documentation/virtual/kvm/api.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/virtual/kvm/api.txt +1 -1
index a4df553..9cf591d 100644
@@ -345,7 +345,7 @@ struct kvm_sregs {
 	__u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
 };
 
-/* ppc -- see arch/powerpc/include/asm/kvm.h */
+/* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */
 
 interrupt_bitmap is a bitmap of pending external interrupts.  At most
 one bit may be set.  This interrupt has been acknowledged by the APIC
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/4 KVM: PPC: Only WARN on invalid emulation

In reply to Alexander Graf

When we hit an emulation result that we didn't expect, that is an error, but it's nothing that warrants a BUG(), because it can be guest triggered.

So instead, let's only WARN() the user that this happened.

---
 arch/powerpc/kvm/powerpc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/powerpc/kvm/powerpc.c +2 -1
index be83fca..e2225e5 100644
@@ -237,7 +237,8 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
 		r = RESUME_HOST;
 		break;
 	default:
-		BUG();
+		WARN_ON(1);
+		r = RESUME_GUEST;
 	}
 
 	return r;
Signature · 1 line
1.6.0.2
#10 lore raw

PATCH 3/4 KVM: PPC: Book3S: PR: Enable alternative instruction for SC 1

In reply to Alexander Graf

When running on top of pHyp, the hypercall instruction "sc 1" goes straight into pHyp without trapping in supervisor mode.

So if we want to support PAPR guest in this configuration we need to add a second way of accessing PAPR hypercalls, preferably with the exact same semantics except for the instruction.

So let's overlay an officially reserved instruction and emulate PAPR hypercalls whenever we hit that one.

---
 arch/powerpc/include/asm/kvm_ppc.h |    1 +
 arch/powerpc/kvm/book3s_emulate.c  |   28 ++++++++++++++++++++++++++++
 arch/powerpc/kvm/book3s_pr.c       |    5 +++++
 3 files changed, 34 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/kvm_ppc.h +1 -0
index 572aa75..5f5f69a 100644
@@ -44,6 +44,7 @@ enum emulation_result {
 	EMULATE_DO_DCR,       /* kvm_run filled with DCR request */
 	EMULATE_FAIL,         /* can't emulate this instruction */
 	EMULATE_AGAIN,        /* something went wrong. go again */
+	EMULATE_DO_PAPR,      /* kvm_run filled with PAPR request */
 };
 
 extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
arch/powerpc/kvm/book3s_emulate.c +28 -0
index d31a716..c88161b 100644
@@ -34,6 +34,8 @@
 #define OP_31_XOP_MTSRIN	242
 #define OP_31_XOP_TLBIEL	274
 #define OP_31_XOP_TLBIE		306
+/* Opcode is officially reserved, reuse it as sc 1 when sc 1 doesn't trap */
+#define OP_31_XOP_FAKE_SC1	308
 #define OP_31_XOP_SLBMTE	402
 #define OP_31_XOP_SLBIE		434
 #define OP_31_XOP_SLBIA		498
@@ -170,6 +172,32 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
 			vcpu->arch.mmu.tlbie(vcpu, addr, large);
 			break;
 		}
+#ifdef CONFIG_KVM_BOOK3S_64_PR
+		case OP_31_XOP_FAKE_SC1:
+		{
+			/* SC 1 papr hypercalls */
+			ulong cmd = kvmppc_get_gpr(vcpu, 3);
+			int i;
+
+		        if ((vcpu->arch.shared->msr & MSR_PR) ||
+			    !vcpu->arch.papr_enabled) {
+				emulated = EMULATE_FAIL;
+				break;
+			}
+
+			if (kvmppc_h_pr(vcpu, cmd) == EMULATE_DONE)
+				break;
+
+			run->papr_hcall.nr = cmd;
+			for (i = 0; i < 9; ++i) {
+				ulong gpr = kvmppc_get_gpr(vcpu, 4 + i);
+				run->papr_hcall.args[i] = gpr;
+			}
+
+			emulated = EMULATE_DO_PAPR;
+			break;
+		}
+#endif
 		case OP_31_XOP_EIOIO:
 			break;
 		case OP_31_XOP_SLBMTE:
arch/powerpc/kvm/book3s_pr.c +5 -0
index 28d38ad..73ed11c 100644
@@ -760,6 +760,11 @@ program_interrupt:
 			run->exit_reason = KVM_EXIT_MMIO;
 			r = RESUME_HOST_NV;
 			break;
+		case EMULATE_DO_PAPR:
+			run->exit_reason = KVM_EXIT_PAPR_HCALL;
+			vcpu->arch.hcall_needed = 1;
+			r = RESUME_HOST_NV;
+			break;
 		default:
 			BUG();
 		}
Signature · 1 line
1.6.0.2
#11 lore raw

PATCH 4/4 powerpc: Corrected include header path in kvm_para.h

In reply to Alexander Graf

From: Bharat Bhushan <[email protected]>

The include/uapi/asm/kvm_para.h includes <include/uapi/asm/epapr_hcalls.h> but the correct reference should be <include/asm/epapr_hcalls.h> as this is the place where make install_header installs the header files for userspace.

---
 arch/powerpc/include/uapi/asm/kvm_para.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/include/uapi/asm/kvm_para.h +1 -1
index ed0e025..e3af328 100644
@@ -78,7 +78,7 @@ struct kvm_vcpu_arch_shared {
 
 #define KVM_HCALL_TOKEN(num)     _EV_HCALL_TOKEN(EV_KVM_VENDOR_ID, num)
 
-#include <uapi/asm/epapr_hcalls.h>
+#include <asm/epapr_hcalls.h>
 
 #define KVM_FEATURE_MAGIC_PAGE	1
 
Signature · 1 line
1.6.0.2
#12 lore raw
In reply to Alexander Graf
Quoted 4 lines · Alexander Graf

Hi Marcelo / Gleb,

This is my current patch queue for ppc. Please pull.

Is this for 3.8 or 3.9?

Quoted 26 lines

Changes include:

- important header fix for UAPI
- Book3S: PR: Enable fake sc 1 instruction for KVM on top of pHyp

Alex

The following changes since commit e11ae1a102b46f76441e328a2743ae5d6e201423:
Gleb Natapov (1):
KVM: remove unused variable.

are available in the git repository at:

git://github.com/agraf/linux-2.6.git kvm-ppc-next

Alexander Graf (2):
KVM: PPC: Only WARN on invalid emulation
KVM: PPC: Book3S: PR: Enable alternative instruction for SC 1

Bharat Bhushan (1):
powerpc: Corrected include header path in kvm_para.h

Mihai Caraman (1):
KVM: PPC: Fix SREGS documentation reference

Quoted 7 lines
 Documentation/virtual/kvm/api.txt        |    2 +-
 arch/powerpc/include/asm/kvm_ppc.h       |    1 +
 arch/powerpc/include/uapi/asm/kvm_para.h |    2 +-
 arch/powerpc/kvm/book3s_emulate.c        |   28 ++++++++++++++++++++++++++++
 arch/powerpc/kvm/book3s_pr.c             |    5 +++++
 arch/powerpc/kvm/powerpc.c               |    3 ++-
 6 files changed, 38 insertions(+), 3 deletions(-)

--
Gleb.

#13 lore raw
Quoted 6 lines · Gleb Natapov
Quoted 4 lines · Alexander Graf

Hi Marcelo / Gleb,

This is my current patch queue for ppc. Please pull.

Is this for 3.8 or 3.9?

This is for 3.9, except for the UAPI one. That one should go into 3.8 and stable.

Alex

Quoted 36 lines
Quoted 27 lines

Changes include:

- important header fix for UAPI
- Book3S: PR: Enable fake sc 1 instruction for KVM on top of pHyp

Alex

The following changes since commit e11ae1a102b46f76441e328a2743ae5d6e201423:
Gleb Natapov (1):
KVM: remove unused variable.

are available in the git repository at:

   git://github.com/agraf/linux-2.6.git kvm-ppc-next

Alexander Graf (2):
KVM: PPC: Only WARN on invalid emulation
KVM: PPC: Book3S: PR: Enable alternative instruction for SC 1

Bharat Bhushan (1):
powerpc: Corrected include header path in kvm_para.h

Mihai Caraman (1):
KVM: PPC: Fix SREGS documentation reference

Quoted 7 lines
  Documentation/virtual/kvm/api.txt        |    2 +-
  arch/powerpc/include/asm/kvm_ppc.h       |    1 +
  arch/powerpc/include/uapi/asm/kvm_para.h |    2 +-
  arch/powerpc/kvm/book3s_emulate.c        |   28 ++++++++++++++++++++++++++++
  arch/powerpc/kvm/book3s_pr.c             |    5 +++++
  arch/powerpc/kvm/powerpc.c               |    3 ++-
  6 files changed, 38 insertions(+), 3 deletions(-)

--
Gleb.

#3 lore raw

Re: [PATCH 2/4] KVM: PPC: Only WARN on invalid emulation

In reply to Alexander Graf
Quoted 17 lines · Alexander Graf

When we hit an emulation result that we didn't expect, that is an error,
but it's nothing that warrants a BUG(), because it can be guest triggered.

So instead, let's only WARN() the user that this happened.

---
 arch/powerpc/kvm/powerpc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/powerpc/kvm/powerpc.c +0 -0
index be83fca..e2225e5 100644

arch/powerpc/kvm/powerpc.c int kvmppc_emulate_mmio(struct kvm_run *run, · line 242

Quoted 7 lines
arch/powerpc/kvm/powerpc.c +2 -1
@@ -237,7 +237,8 @@ int kvmppc_emulate_mmio(struct kvm_run *run,  
 struct kvm_vcpu *vcpu)
 		r = RESUME_HOST;
 		break;
 	default:
-		BUG();
+		WARN_ON(1);
+		r = RESUME_GUEST;

Do you have a specific way of a guest triggering this in mind, or is it just being cautious? The guest probably shouldn't be allowed to spam the kernel log with WARNs either. Is a traceback even useful here?

-Scott

#4 lore raw

Re: [PATCH 2/4] KVM: PPC: Only WARN on invalid emulation

Quoted 13 lines · Scott Wood
Quoted 12 lines · Alexander Graf

When we hit an emulation result that we didn't expect, that is an error, but it's nothing that warrants a BUG(), because it can be guest triggered. So instead, let's only WARN() the user that this happened.

---
arch/powerpc/kvm/powerpc.c | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
arch/powerpc/kvm/powerpc.c +0 -0
index be83fca..e2225e5 100644
@@ -237,7 +237,8 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
Quoted 8 lines

arch/powerpc/kvm/powerpc.c int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) · line 241

Quoted 6 lines
arch/powerpc/kvm/powerpc.c +2 -1
 		r = RESUME_HOST;
 		break;
 	default:
-		BUG();
+		WARN_ON(1);
+		r = RESUME_GUEST;

Do you have a specific way of a guest triggering this in mind, or is it just being cautious? The guest probably shouldn't be allowed to spam the kernel log with WARNs either. Is a traceback even useful here?

For debugging, yes. But maybe we would be better off with a trace point. Anyway, a WARN is better than a BUG either way for now.

I was able to provoke this by live patching an instruction without flushing the icache, so that the last_inst instruction fetch gets a different instruction from the instruction that resulted in the trap we're currently in.

Alex

#5 lore raw

Re: [PATCH 2/4] KVM: PPC: Only WARN on invalid emulation

Quoted 28 lines · Alexander Graf
Quoted 2 lines · Scott Wood
Quoted 1 line · Alexander Graf

When we hit an emulation result that we didn't expect, that is an

error,

Quoted 1 line
Quoted 1 line

but it's nothing that warrants a BUG(), because it can be guest

triggered.

Quoted 6 lines

Review

Quoted 6 lines

So instead, let's only WARN() the user that this happened.

---
arch/powerpc/kvm/powerpc.c | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/arch/powerpc/kvm/powerpc.c

Quoted 4 lines

arch/powerpc/kvm/powerpc.c int kvmppc_emulate_mmio(struct kvm_run *run,

Quoted 4 lines

index be83fca..e2225e5 100644

arch/powerpc/kvm/powerpc.c +0 -0
@@ -237,7 +237,8 @@ int kvmppc_emulate_mmio(struct kvm_run *run,  

struct kvm_vcpu *vcpu)

Quoted 8 lines

arch/powerpc/kvm/powerpc.c int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) · line 241

Quoted 6 lines
arch/powerpc/kvm/powerpc.c +2 -1
 		r = RESUME_HOST;
 		break;
 	default:
-		BUG();
+		WARN_ON(1);
+		r = RESUME_GUEST;

Do you have a specific way of a guest triggering this in mind, or

Quoted 3 lines

is it just being cautious? The guest probably shouldn't be allowed to spam the kernel log with WARNs either. Is a traceback even useful here?

For debugging, yes.

I figured the interesting bits would be in the stack frames you've just returned from.

Quoted 1 line

But maybe we would be better off with a trace point.

Or a ratelimited error message, and maybe we should return to host instead of guest?

Quoted 1 line

Anyway, a WARN is better than a BUG either way for now.

Yes...

Quoted 1 line

I was able to provoke this by live patching an instruction without flushing the icache, so that the last_inst instruction fetch gets a different instruction from the instruction that resulted in the trap we're currently in.

Which EMULATE code did you get in that case?

-Scott

#6 lore raw

Re: [PATCH 2/4] KVM: PPC: Only WARN on invalid emulation

Quoted 31 lines · Scott Wood
Quoted 22 lines · Alexander Graf
Quoted 13 lines · Scott Wood
Quoted 12 lines · Alexander Graf

When we hit an emulation result that we didn't expect, that is an error, but it's nothing that warrants a BUG(), because it can be guest triggered. So instead, let's only WARN() the user that this happened.

---
arch/powerpc/kvm/powerpc.c | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
arch/powerpc/kvm/powerpc.c +0 -0
index be83fca..e2225e5 100644
@@ -237,7 +237,8 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
Quoted 8 lines

arch/powerpc/kvm/powerpc.c int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) · line 241

Quoted 6 lines
arch/powerpc/kvm/powerpc.c +2 -1
 		r = RESUME_HOST;
 		break;
 	default:
-		BUG();
+		WARN_ON(1);
+		r = RESUME_GUEST;

Do you have a specific way of a guest triggering this in mind, or is it just being cautious? The guest probably shouldn't be allowed to spam the kernel log with WARNs either. Is a traceback even useful here?

Quoted 1 line

For debugging, yes.

I figured the interesting bits would be in the stack frames you've just returned from.

Quoted 1 line

But maybe we would be better off with a trace point.

Or a ratelimited error message, and maybe we should return to host instead of guest?

Quoted 7 lines
Quoted 1 line

Anyway, a WARN is better than a BUG either way for now.

Yes...

Quoted 1 line

I was able to provoke this by live patching an instruction without flushing the icache, so that the last_inst instruction fetch gets a different instruction from the instruction that resulted in the trap we're currently in.

Which EMULATE code did you get in that case?

I was patching SC into the PAPR_SC illegal instruction. So I got the EMULATE_PAPR code.

Maybe we should simply always handle all EMULATE codes everywhere. Then the whole problem goes away automatically :).

Alex

#7 lore raw

Re: [PATCH 2/4] KVM: PPC: Only WARN on invalid emulation

In reply to Alexander Graf
Quoted 25 lines · Alexander Graf
Quoted 13 lines · Scott Wood
Quoted 12 lines · Alexander Graf

When we hit an emulation result that we didn't expect, that is an error, but it's nothing that warrants a BUG(), because it can be guest triggered. So instead, let's only WARN() the user that this happened.

---
arch/powerpc/kvm/powerpc.c | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
arch/powerpc/kvm/powerpc.c +0 -0
index be83fca..e2225e5 100644
@@ -237,7 +237,8 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
Quoted 8 lines

arch/powerpc/kvm/powerpc.c int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) · line 241

Quoted 6 lines
arch/powerpc/kvm/powerpc.c +2 -1
 		r = RESUME_HOST;
 		break;
 	default:
-		BUG();
+		WARN_ON(1);
+		r = RESUME_GUEST;

Do you have a specific way of a guest triggering this in mind, or is it just being cautious? The guest probably shouldn't be allowed to spam the kernel log with WARNs either. Is a traceback even useful here?

Quoted 4 lines

For debugging, yes. But maybe we would be better off with a trace point. Anyway, a WARN is better than a BUG either way for now.

I was able to provoke this by live patching an instruction without flushing the icache, so that the last_inst instruction fetch gets a different instruction from the instruction that resulted in the trap we're currently in.

If guest can trigger this it better be WARN_ON_ONCE(). Otherwise, as Scott said, guest will be able to spam host kernel log.

--
Gleb.

#14 lore raw
In reply to Alexander Graf
Quoted 11 lines · Alexander Graf
Quoted 6 lines · Gleb Natapov
Quoted 4 lines · Alexander Graf

Hi Marcelo / Gleb,

This is my current patch queue for ppc. Please pull.

Is this for 3.8 or 3.9?

This is for 3.9, except for the UAPI one. That one should go into 3.8 and stable.

It is good to have this information with pull request. Also patches for 3.8 go to master branch while patches for 3.9 go to next branch, so you need to prepare separate pull requests for two of those.

Quoted 39 lines

Alex

Quoted 36 lines
Quoted 27 lines

Changes include:

- important header fix for UAPI
- Book3S: PR: Enable fake sc 1 instruction for KVM on top of pHyp

Alex

The following changes since commit e11ae1a102b46f76441e328a2743ae5d6e201423:
Gleb Natapov (1):
KVM: remove unused variable.

are available in the git repository at:

git://github.com/agraf/linux-2.6.git kvm-ppc-next

Alexander Graf (2):
KVM: PPC: Only WARN on invalid emulation
KVM: PPC: Book3S: PR: Enable alternative instruction for SC 1

Bharat Bhushan (1):
powerpc: Corrected include header path in kvm_para.h

Mihai Caraman (1):
KVM: PPC: Fix SREGS documentation reference

Quoted 7 lines
 Documentation/virtual/kvm/api.txt        |    2 +-
 arch/powerpc/include/asm/kvm_ppc.h       |    1 +
 arch/powerpc/include/uapi/asm/kvm_para.h |    2 +-
 arch/powerpc/kvm/book3s_emulate.c        |   28 ++++++++++++++++++++++++++++
 arch/powerpc/kvm/book3s_pr.c             |    5 +++++
 arch/powerpc/kvm/powerpc.c               |    3 ++-
 6 files changed, 38 insertions(+), 3 deletions(-)

--
Gleb.

--
Gleb.

#8 lore raw

Re: [PATCH 2/4] KVM: PPC: Only WARN on invalid emulation

In reply to Gleb Natapov
Quoted 26 lines · Gleb Natapov
Quoted 25 lines · Alexander Graf
Quoted 21 lines · Scott Wood
Quoted 12 lines · Alexander Graf

When we hit an emulation result that we didn't expect, that is an error, but it's nothing that warrants a BUG(), because it can be guest triggered. So instead, let's only WARN() the user that this happened.

---
arch/powerpc/kvm/powerpc.c | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
arch/powerpc/kvm/powerpc.c +0 -0
index be83fca..e2225e5 100644

arch/powerpc/kvm/powerpc.c int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) · line 241

Quoted 6 lines
arch/powerpc/kvm/powerpc.c +2 -1
@@ -237,7 +237,8 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
 		r = RESUME_HOST;
 		break;
 	default:
-		BUG();
+		WARN_ON(1);
+		r = RESUME_GUEST;

Do you have a specific way of a guest triggering this in mind, or is it just being cautious? The guest probably shouldn't be allowed to spam the kernel log with WARNs either. Is a traceback even useful here?

Quoted 6 lines
Quoted 4 lines

For debugging, yes. But maybe we would be better off with a trace point. Anyway, a WARN is better than a BUG either way for now.

I was able to provoke this by live patching an instruction without flushing the icache, so that the last_inst instruction fetch gets a different instruction from the instruction that resulted in the trap we're currently in.

If guest can trigger this it better be WARN_ON_ONCE(). Otherwise, as Scott said, guest will be able to spam host kernel log.

I really think eventually we want a trace point and no WARN at all or all possible EMULATE targets handled, because a guest can legitimately not flush its icache and thus confuse our logic.

Just consider this patch as a quick fix to make sure we enable people (me) to unload the module still after they hit this case ;). Real fix coming soon.

Alex

#9 lore raw

Re: [PATCH 2/4] KVM: PPC: Only WARN on invalid emulation

Quoted 31 lines · Alexander Graf
Quoted 28 lines · Gleb Natapov
Quoted 27 lines · Alexander Graf
Quoted 13 lines · Scott Wood
Quoted 12 lines · Alexander Graf

When we hit an emulation result that we didn't expect, that is an error, but it's nothing that warrants a BUG(), because it can be guest triggered. So instead, let's only WARN() the user that this happened.

---
arch/powerpc/kvm/powerpc.c | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
arch/powerpc/kvm/powerpc.c +0 -0
index be83fca..e2225e5 100644
@@ -237,7 +237,8 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
Quoted 8 lines

arch/powerpc/kvm/powerpc.c int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) · line 241

Quoted 6 lines
arch/powerpc/kvm/powerpc.c +2 -1
 		r = RESUME_HOST;
 		break;
 	default:
-		BUG();
+		WARN_ON(1);
+		r = RESUME_GUEST;

Do you have a specific way of a guest triggering this in mind, or is it just being cautious? The guest probably shouldn't be allowed to spam the kernel log with WARNs either. Is a traceback even useful here?

For debugging, yes. But maybe we would be better off with a trace point. Anyway, a WARN is better than a BUG either way for now.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

I was able to provoke this by live patching an instruction without flushing the icache, so that the last_inst instruction fetch gets a different instruction from the instruction that resulted in the trap we're currently in.

If guest can trigger this it better be WARN_ON_ONCE(). Otherwise, as Scott said, guest will be able to spam host kernel log.

I really think eventually we want a trace point and no WARN at all or all possible EMULATE targets handled, because a guest can legitimately not flush its icache and thus confuse our logic.

Just consider this patch as a quick fix to make sure we enable people (me) to unload the module still after they hit this case ;). Real fix coming soon.

OK.

--
Gleb.