* [PATCH 01/12] KVM: PPC: e500: Silence bogus GCC warning in tlb code
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-10-11 16:13 ` [PATCH 02/12] KVM: PPC: booke: Fix get_tb() compile error on 64-bit Mihai Caraman
` (11 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
64-bit GCC 4.5.1 warns about an uninitialized variable which was guarded
by a flag. Initialize the variable to make it happy.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
arch/powerpc/kvm/e500_tlb.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index c733894..23b3de6 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -415,7 +415,8 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
struct tlbe_ref *ref)
{
struct kvm_memory_slot *slot;
- unsigned long pfn, hva;
+ unsigned long pfn = 0; /* shut up 64-bit GCC */
+ unsigned long hva;
int pfnmap = 0;
int tsize = BOOK3E_PAGESZ_4K;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 02/12] KVM: PPC: booke: Fix get_tb() compile error on 64-bit
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
2012-10-11 16:13 ` [PATCH 01/12] KVM: PPC: e500: Silence bogus GCC warning in tlb code Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-10-11 16:13 ` [PATCH 03/12] KVM: PPC: bookehv: Remove GET_VCPU macro from exception handler Mihai Caraman
` (10 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Include header file for get_tb() declaration.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
arch/powerpc/kvm/booke.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 3d1f35d..7c9c389 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -36,6 +36,7 @@
#include <asm/dbell.h>
#include <asm/hw_irq.h>
#include <asm/irq.h>
+#include <asm/time.h>
#include "timing.h"
#include "booke.h"
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 03/12] KVM: PPC: bookehv: Remove GET_VCPU macro from exception handler
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
2012-10-11 16:13 ` [PATCH 01/12] KVM: PPC: e500: Silence bogus GCC warning in tlb code Mihai Caraman
2012-10-11 16:13 ` [PATCH 02/12] KVM: PPC: booke: Fix get_tb() compile error on 64-bit Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-10-11 16:13 ` [PATCH 04/12] KVM: PPC64: bookehv: Add support for interrupt handling Mihai Caraman
` (9 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
GET_VCPU define will not be implemented for 64-bit for performance reasons
so get rid of it also on 32-bit.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
arch/powerpc/kvm/bookehv_interrupts.S | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S
index 099fe82..fa6d552 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -32,9 +32,6 @@
#include "../kernel/head_booke.h" /* for THREAD_NORMSAVE() */
-#define GET_VCPU(vcpu, thread) \
- PPC_LL vcpu, THREAD_KVM_VCPU(thread)
-
#define LONGBYTES (BITS_PER_LONG / 8)
#define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES))
@@ -206,7 +203,7 @@
*/
.macro kvm_handler intno srr0, srr1, flags
_GLOBAL(kvmppc_handler_\intno\()_\srr1)
- GET_VCPU(r11, r10)
+ PPC_LL r11, THREAD_KVM_VCPU(r10)
PPC_STL r3, VCPU_GPR(R3)(r11)
mfspr r3, SPRN_SPRG_RSCRATCH0
PPC_STL r4, VCPU_GPR(R4)(r11)
@@ -233,7 +230,7 @@ _GLOBAL(kvmppc_handler_\intno\()_\srr1)
.macro kvm_lvl_handler intno scratch srr0, srr1, flags
_GLOBAL(kvmppc_handler_\intno\()_\srr1)
mfspr r10, SPRN_SPRG_THREAD
- GET_VCPU(r11, r10)
+ PPC_LL r11, THREAD_KVM_VCPU(r10)
PPC_STL r3, VCPU_GPR(R3)(r11)
mfspr r3, \scratch
PPC_STL r4, VCPU_GPR(R4)(r11)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 04/12] KVM: PPC64: bookehv: Add support for interrupt handling
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (2 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 03/12] KVM: PPC: bookehv: Remove GET_VCPU macro from exception handler Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-10-11 16:13 ` [PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea Mihai Caraman
` (8 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Add interrupt handling support for 64-bit bookehv hosts. Unify 32 and 64 bit
implementations using a common stack layout and a common execution flow starting
from kvm_handler_common macro. Update documentation for 64-bit input register
values. This patch only address the bolted TLB miss exception handlers version.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
v1: updated CRIT and TLB exception handling following core side changes.
arch/powerpc/include/asm/kvm_booke_hv_asm.h | 25 +++++
arch/powerpc/kvm/bookehv_interrupts.S | 138 +++++++++++++++++++++++++--
2 files changed, 155 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/include/asm/kvm_booke_hv_asm.h b/arch/powerpc/include/asm/kvm_booke_hv_asm.h
index a37a12a..7ad5af7 100644
--- a/arch/powerpc/include/asm/kvm_booke_hv_asm.h
+++ b/arch/powerpc/include/asm/kvm_booke_hv_asm.h
@@ -17,6 +17,7 @@
* there are no exceptions for which we fall through directly to
* the normal host handler.
*
+ * 32-bit host
* Expected inputs (normal exceptions):
* SCRATCH0 = saved r10
* r10 = thread struct
@@ -33,6 +34,30 @@
* *(r8 + GPR9) = saved r9
* *(r8 + GPR10) = saved r10 (r10 not yet clobbered)
* *(r8 + GPR11) = saved r11
+ *
+ * 64-bit host
+ * Expected inputs (GEN/GDBELL/DBG/MC exception types):
+ * r10 = saved CR
+ * r13 = PACA_POINTER
+ * *(r13 + PACA_EX##type + EX_R10) = saved r10
+ * *(r13 + PACA_EX##type + EX_R11) = saved r11
+ * SPRN_SPRG_##type##_SCRATCH = saved r13
+ *
+ * Expected inputs (CRIT exception type):
+ * r10 = saved CR
+ * r13 = PACA_POINTER
+ * *(r13 + PACA_EX##type + EX_R10) = saved r10
+ * *(r13 + PACA_EX##type + EX_R11) = saved r11
+ * *(r13 + PACA_EX##type + EX_R13) = saved r13
+ *
+ * Expected inputs (TLB exception type):
+ * r10 = saved CR
+ * r13 = PACA_POINTER
+ * *(r13 + PACA_EX##type + EX_TLB_R10) = saved r10
+ * *(r13 + PACA_EX##type + EX_TLB_R11) = saved r11
+ * SPRN_SPRG_GEN_SCRATCH = saved r13
+ *
+ * Only the bolted version of TLB miss exception handlers is supported now.
*/
.macro DO_KVM intno srr1
#ifdef CONFIG_KVM_BOOKE_HV
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S
index fa6d552..e8ed7d6 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -16,6 +16,7 @@
*
* Author: Varun Sethi <varun.sethi@freescale.com>
* Author: Scott Wood <scotwood@freescale.com>
+ * Author: Mihai Caraman <mihai.caraman@freescale.com>
*
* This file is derived from arch/powerpc/kvm/booke_interrupts.S
*/
@@ -30,28 +31,33 @@
#include <asm/bitsperlong.h>
#include <asm/thread_info.h>
+#ifdef CONFIG_64BIT
+#include <asm/exception-64e.h>
+#else
#include "../kernel/head_booke.h" /* for THREAD_NORMSAVE() */
+#endif
#define LONGBYTES (BITS_PER_LONG / 8)
#define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES))
/* The host stack layout: */
-#define HOST_R1 (0 * LONGBYTES) /* Implied by stwu. */
-#define HOST_CALLEE_LR (1 * LONGBYTES)
-#define HOST_RUN (2 * LONGBYTES) /* struct kvm_run */
+#define HOST_R1 0 /* Implied by stwu. */
+#define HOST_CALLEE_LR PPC_LR_STKOFF
+#define HOST_RUN (HOST_CALLEE_LR + LONGBYTES)
/*
* r2 is special: it holds 'current', and it made nonvolatile in the
* kernel with the -ffixed-r2 gcc option.
*/
-#define HOST_R2 (3 * LONGBYTES)
-#define HOST_CR (4 * LONGBYTES)
-#define HOST_NV_GPRS (5 * LONGBYTES)
+#define HOST_R2 (HOST_RUN + LONGBYTES)
+#define HOST_CR (HOST_R2 + LONGBYTES)
+#define HOST_NV_GPRS (HOST_CR + LONGBYTES)
#define __HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES))
#define HOST_NV_GPR(n) __HOST_NV_GPR(__REG_##n)
#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(R31) + LONGBYTES)
#define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) & ~15) /* Align. */
-#define HOST_STACK_LR (HOST_STACK_SIZE + LONGBYTES) /* In caller stack frame. */
+/* LR in caller stack frame. */
+#define HOST_STACK_LR (HOST_STACK_SIZE + PPC_LR_STKOFF)
#define NEED_EMU 0x00000001 /* emulation -- save nv regs */
#define NEED_DEAR 0x00000002 /* save faulting DEAR */
@@ -198,6 +204,122 @@
b kvmppc_resume_host
.endm
+#ifdef CONFIG_64BIT
+/* Exception types */
+#define EX_GEN 1
+#define EX_GDBELL 2
+#define EX_DBG 3
+#define EX_MC 4
+#define EX_CRIT 5
+#define EX_TLB 6
+
+/*
+ * For input register values, see arch/powerpc/include/asm/kvm_booke_hv_asm.h
+ */
+.macro kvm_handler intno type scratch, paca_ex, ex_r10, ex_r11, srr0, srr1, flags
+ _GLOBAL(kvmppc_handler_\intno\()_\srr1)
+ mr r11, r4
+ /*
+ * Get vcpu from Paca: paca->__current.thread->kvm_vcpu
+ */
+ PPC_LL r4, PACACURRENT(r13)
+ PPC_LL r4, (THREAD + THREAD_KVM_VCPU)(r4)
+ stw r10, VCPU_CR(r4)
+ PPC_STL r11, VCPU_GPR(R4)(r4)
+ PPC_STL r5, VCPU_GPR(R5)(r4)
+ .if \type == EX_CRIT
+ PPC_LL r5, (\paca_ex + EX_R13)(r13)
+ .else
+ mfspr r5, \scratch
+ .endif
+ PPC_STL r6, VCPU_GPR(R6)(r4)
+ PPC_STL r8, VCPU_GPR(R8)(r4)
+ PPC_STL r9, VCPU_GPR(R9)(r4)
+ PPC_STL r5, VCPU_GPR(R13)(r4)
+ PPC_LL r6, (\paca_ex + \ex_r10)(r13)
+ PPC_LL r8, (\paca_ex + \ex_r11)(r13)
+ PPC_STL r3, VCPU_GPR(R3)(r4)
+ PPC_STL r7, VCPU_GPR(R7)(r4)
+ PPC_STL r12, VCPU_GPR(R12)(r4)
+ PPC_STL r6, VCPU_GPR(R10)(r4)
+ PPC_STL r8, VCPU_GPR(R11)(r4)
+ mfctr r5
+ PPC_STL r5, VCPU_CTR(r4)
+ mfspr r5, \srr0
+ mfspr r6, \srr1
+ kvm_handler_common \intno, \srr0, \flags
+.endm
+
+#define EX_PARAMS(type) \
+ EX_##type, \
+ SPRN_SPRG_##type##_SCRATCH, \
+ PACA_EX##type, \
+ EX_R10, \
+ EX_R11
+
+#define EX_PARAMS_TLB \
+ EX_TLB, \
+ SPRN_SPRG_GEN_SCRATCH, \
+ PACA_EXTLB, \
+ EX_TLB_R10, \
+ EX_TLB_R11
+
+kvm_handler BOOKE_INTERRUPT_CRITICAL, EX_PARAMS(CRIT), \
+ SPRN_CSRR0, SPRN_CSRR1, 0
+kvm_handler BOOKE_INTERRUPT_MACHINE_CHECK, EX_PARAMS(MC), \
+ SPRN_MCSRR0, SPRN_MCSRR1, 0
+kvm_handler BOOKE_INTERRUPT_DATA_STORAGE, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1,(NEED_EMU | NEED_DEAR | NEED_ESR)
+kvm_handler BOOKE_INTERRUPT_INST_STORAGE, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, NEED_ESR
+kvm_handler BOOKE_INTERRUPT_EXTERNAL, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_ALIGNMENT, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1,(NEED_DEAR | NEED_ESR)
+kvm_handler BOOKE_INTERRUPT_PROGRAM, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1,NEED_ESR
+kvm_handler BOOKE_INTERRUPT_FP_UNAVAIL, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_AP_UNAVAIL, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_DECREMENTER, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_FIT, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_WATCHDOG, EX_PARAMS(CRIT),\
+ SPRN_CSRR0, SPRN_CSRR1, 0
+/*
+ * Only bolted TLB miss exception handlers are supported for now
+ */
+kvm_handler BOOKE_INTERRUPT_DTLB_MISS, EX_PARAMS_TLB, \
+ SPRN_SRR0, SPRN_SRR1, (NEED_EMU | NEED_DEAR | NEED_ESR)
+kvm_handler BOOKE_INTERRUPT_ITLB_MISS, EX_PARAMS_TLB, \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_SPE_UNAVAIL, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_SPE_FP_DATA, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_SPE_FP_ROUND, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_PERFORMANCE_MONITOR, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_DOORBELL, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_DOORBELL_CRITICAL, EX_PARAMS(CRIT), \
+ SPRN_CSRR0, SPRN_CSRR1, 0
+kvm_handler BOOKE_INTERRUPT_HV_PRIV, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, NEED_EMU
+kvm_handler BOOKE_INTERRUPT_HV_SYSCALL, EX_PARAMS(GEN), \
+ SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_GUEST_DBELL, EX_PARAMS(GDBELL), \
+ SPRN_GSRR0, SPRN_GSRR1, 0
+kvm_handler BOOKE_INTERRUPT_GUEST_DBELL_CRIT, EX_PARAMS(CRIT), \
+ SPRN_CSRR0, SPRN_CSRR1, 0
+kvm_handler BOOKE_INTERRUPT_DEBUG, EX_PARAMS(DBG), \
+ SPRN_DSRR0, SPRN_DSRR1, 0
+kvm_handler BOOKE_INTERRUPT_DEBUG, EX_PARAMS(CRIT), \
+ SPRN_CSRR0, SPRN_CSRR1, 0
+#else
/*
* For input register values, see arch/powerpc/include/asm/kvm_booke_hv_asm.h
*/
@@ -292,7 +414,7 @@ kvm_lvl_handler BOOKE_INTERRUPT_DEBUG, \
SPRN_SPRG_RSCRATCH_CRIT, SPRN_CSRR0, SPRN_CSRR1, 0
kvm_lvl_handler BOOKE_INTERRUPT_DEBUG, \
SPRN_SPRG_RSCRATCH_DBG, SPRN_DSRR0, SPRN_DSRR1, 0
-
+#endif
/* Registers:
* SPRG_SCRATCH0: guest r10
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (3 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 04/12] KVM: PPC64: bookehv: Add support for interrupt handling Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-12-01 13:28 ` Alexander Graf
2012-10-11 16:13 ` [PATCH 06/12] KVM: PPC: Mask ea's high 32-bits in 32/64 instr emulation Mihai Caraman
` (7 subsequent siblings)
12 siblings, 1 reply; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Add emulation helper for getting instruction ea and refactor tlb instruction
emulation to use it.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
v1: use _t_ype instead of _t_arget _r_egister in tlbilx emulation.
arch/powerpc/include/asm/kvm_ppc.h | 11 +++++++++++
arch/powerpc/kvm/e500.h | 6 +++---
arch/powerpc/kvm/e500_emulate.c | 15 ++++++++++-----
arch/powerpc/kvm/e500_tlb.c | 33 +++++++++++----------------------
4 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index 609cca3..a08e756 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -293,4 +293,15 @@ static inline void kvmppc_lazy_ee_enable(void)
#endif
}
+static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb)
+{
+ ulong ea;
+
+ ea = kvmppc_get_gpr(vcpu, rb);
+ if (ra)
+ ea += kvmppc_get_gpr(vcpu, ra);
+
+ return ea;
+}
+
#endif /* __POWERPC_KVM_PPC_H__ */
diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h
index d162286..32e98a7 100644
--- a/arch/powerpc/kvm/e500.h
+++ b/arch/powerpc/kvm/e500.h
@@ -129,9 +129,9 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500,
ulong value);
int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu);
int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu);
-int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb);
-int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, int rb);
-int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb);
+int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea);
+int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int type, gva_t ea);
+int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, gva_t ea);
int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500);
void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500);
diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c
index e04b0ef..3bf2486 100644
--- a/arch/powerpc/kvm/e500_emulate.c
+++ b/arch/powerpc/kvm/e500_emulate.c
@@ -88,7 +88,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
int emulated = EMULATE_DONE;
int ra = get_ra(inst);
int rb = get_rb(inst);
- int rt = get_rt(inst);
+ gva_t ea;
switch (get_op(inst)) {
case 31:
@@ -113,15 +113,20 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
break;
case XOP_TLBSX:
- emulated = kvmppc_e500_emul_tlbsx(vcpu,rb);
+ ea = kvmppc_get_ea_indexed(vcpu, ra, rb);
+ emulated = kvmppc_e500_emul_tlbsx(vcpu, ea);
break;
- case XOP_TLBILX:
- emulated = kvmppc_e500_emul_tlbilx(vcpu, rt, ra, rb);
+ case XOP_TLBILX: {
+ int t = (inst >> 21) & 0x3;
+ ea = kvmppc_get_ea_indexed(vcpu, ra, rb);
+ emulated = kvmppc_e500_emul_tlbilx(vcpu, t, ea);
break;
+ }
case XOP_TLBIVAX:
- emulated = kvmppc_e500_emul_tlbivax(vcpu, ra, rb);
+ ea = kvmppc_get_ea_indexed(vcpu, ra, rb);
+ emulated = kvmppc_e500_emul_tlbivax(vcpu, ea);
break;
default:
diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index 23b3de6..b5a188a 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -689,14 +689,11 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500, ulong value)
return EMULATE_DONE;
}
-int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb)
+int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea)
{
struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
unsigned int ia;
int esel, tlbsel;
- gva_t ea;
-
- ea = ((ra) ? kvmppc_get_gpr(vcpu, ra) : 0) + kvmppc_get_gpr(vcpu, rb);
ia = (ea >> 2) & 0x1;
@@ -723,7 +720,7 @@ int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb)
}
static void tlbilx_all(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
- int pid, int rt)
+ int pid, int type)
{
struct kvm_book3e_206_tlb_entry *tlbe;
int tid, esel;
@@ -732,7 +729,7 @@ static void tlbilx_all(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
for (esel = 0; esel < vcpu_e500->gtlb_params[tlbsel].entries; esel++) {
tlbe = get_entry(vcpu_e500, tlbsel, esel);
tid = get_tlb_tid(tlbe);
- if (rt == 0 || tid == pid) {
+ if (type == 0 || tid == pid) {
inval_gtlbe_on_host(vcpu_e500, tlbsel, esel);
kvmppc_e500_gtlbe_invalidate(vcpu_e500, tlbsel, esel);
}
@@ -740,14 +737,9 @@ static void tlbilx_all(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
}
static void tlbilx_one(struct kvmppc_vcpu_e500 *vcpu_e500, int pid,
- int ra, int rb)
+ gva_t ea)
{
int tlbsel, esel;
- gva_t ea;
-
- ea = kvmppc_get_gpr(&vcpu_e500->vcpu, rb);
- if (ra)
- ea += kvmppc_get_gpr(&vcpu_e500->vcpu, ra);
for (tlbsel = 0; tlbsel < 2; tlbsel++) {
esel = kvmppc_e500_tlb_index(vcpu_e500, ea, tlbsel, pid, -1);
@@ -759,16 +751,16 @@ static void tlbilx_one(struct kvmppc_vcpu_e500 *vcpu_e500, int pid,
}
}
-int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, int rb)
+int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int type, gva_t ea)
{
struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
int pid = get_cur_spid(vcpu);
- if (rt == 0 || rt == 1) {
- tlbilx_all(vcpu_e500, 0, pid, rt);
- tlbilx_all(vcpu_e500, 1, pid, rt);
- } else if (rt == 3) {
- tlbilx_one(vcpu_e500, pid, ra, rb);
+ if (type == 0 || type == 1) {
+ tlbilx_all(vcpu_e500, 0, pid, type);
+ tlbilx_all(vcpu_e500, 1, pid, type);
+ } else if (type == 3) {
+ tlbilx_one(vcpu_e500, pid, ea);
}
return EMULATE_DONE;
@@ -793,16 +785,13 @@ int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu)
return EMULATE_DONE;
}
-int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb)
+int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, gva_t ea)
{
struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
int as = !!get_cur_sas(vcpu);
unsigned int pid = get_cur_spid(vcpu);
int esel, tlbsel;
struct kvm_book3e_206_tlb_entry *gtlbe = NULL;
- gva_t ea;
-
- ea = kvmppc_get_gpr(vcpu, rb);
for (tlbsel = 0; tlbsel < 2; tlbsel++) {
esel = kvmppc_e500_tlb_index(vcpu_e500, ea, tlbsel, pid, as);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea
2012-10-11 16:13 ` [PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea Mihai Caraman
@ 2012-12-01 13:28 ` Alexander Graf
2012-12-01 13:32 ` Alexander Graf
0 siblings, 1 reply; 20+ messages in thread
From: Alexander Graf @ 2012-12-01 13:28 UTC (permalink / raw)
To: Mihai Caraman; +Cc: linuxppc-dev, kvm, kvm-ppc
On 11.10.2012, at 18:13, Mihai Caraman wrote:
> Add emulation helper for getting instruction ea and refactor tlb =
instruction
> emulation to use it.
>=20
> Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
> ---
> v1: use _t_ype instead of _t_arget _r_egister in tlbilx emulation.
>=20
> arch/powerpc/include/asm/kvm_ppc.h | 11 +++++++++++
> arch/powerpc/kvm/e500.h | 6 +++---
> arch/powerpc/kvm/e500_emulate.c | 15 ++++++++++-----
> arch/powerpc/kvm/e500_tlb.c | 33 =
+++++++++++----------------------
> 4 files changed, 35 insertions(+), 30 deletions(-)
>=20
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h =
b/arch/powerpc/include/asm/kvm_ppc.h
> index 609cca3..a08e756 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -293,4 +293,15 @@ static inline void kvmppc_lazy_ee_enable(void)
> #endif
> }
>=20
> +static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int =
ra, int rb)
> +{
> + ulong ea;
> +
> + ea =3D kvmppc_get_gpr(vcpu, rb);
> + if (ra)
> + ea +=3D kvmppc_get_gpr(vcpu, ra);
> +
> + return ea;
> +}
> +
> #endif /* __POWERPC_KVM_PPC_H__ */
> diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h
> index d162286..32e98a7 100644
> --- a/arch/powerpc/kvm/e500.h
> +++ b/arch/powerpc/kvm/e500.h
> @@ -129,9 +129,9 @@ int kvmppc_e500_emul_mt_mmucsr0(struct =
kvmppc_vcpu_e500 *vcpu_e500,
> ulong value);
> int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu);
> int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu);
> -int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb);
> -int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, =
int rb);
> -int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb);
> +int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea);
> +int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int type, gva_t =
ea);
> +int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, gva_t ea);
> int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500);
> void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500);
>=20
> diff --git a/arch/powerpc/kvm/e500_emulate.c =
b/arch/powerpc/kvm/e500_emulate.c
> index e04b0ef..3bf2486 100644
> --- a/arch/powerpc/kvm/e500_emulate.c
> +++ b/arch/powerpc/kvm/e500_emulate.c
> @@ -88,7 +88,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, =
struct kvm_vcpu *vcpu,
> int emulated =3D EMULATE_DONE;
> int ra =3D get_ra(inst);
> int rb =3D get_rb(inst);
> - int rt =3D get_rt(inst);
The function scope rt variable shouldn't hurt, as the compiler will be =
smart enough to only calculate it when it's actually used.
> + gva_t ea;
>=20
> switch (get_op(inst)) {
> case 31:
> @@ -113,15 +113,20 @@ int kvmppc_core_emulate_op(struct kvm_run *run, =
struct kvm_vcpu *vcpu,
> break;
>=20
> case XOP_TLBSX:
> - emulated =3D kvmppc_e500_emul_tlbsx(vcpu,rb);
> + ea =3D kvmppc_get_ea_indexed(vcpu, ra, rb);
> + emulated =3D kvmppc_e500_emul_tlbsx(vcpu, ea);
> break;
>=20
> - case XOP_TLBILX:
> - emulated =3D kvmppc_e500_emul_tlbilx(vcpu, rt, =
ra, rb);
> + case XOP_TLBILX: {
> + int t =3D (inst >> 21) & 0x3;
so we can remove this
> + ea =3D kvmppc_get_ea_indexed(vcpu, ra, rb);
> + emulated =3D kvmppc_e500_emul_tlbilx(vcpu, t, =
ea);
and instead here pass rt & 3.
The rest of the patch looks fine, so I'll do the change while applying =
it.
Alex
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea
2012-12-01 13:28 ` Alexander Graf
@ 2012-12-01 13:32 ` Alexander Graf
0 siblings, 0 replies; 20+ messages in thread
From: Alexander Graf @ 2012-12-01 13:32 UTC (permalink / raw)
To: Mihai Caraman; +Cc: linuxppc-dev, kvm, kvm-ppc
On 01.12.2012, at 14:28, Alexander Graf wrote:
>=20
> On 11.10.2012, at 18:13, Mihai Caraman wrote:
>=20
>> Add emulation helper for getting instruction ea and refactor tlb =
instruction
>> emulation to use it.
>>=20
>> Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
>> ---
>> v1: use _t_ype instead of _t_arget _r_egister in tlbilx emulation.
>>=20
>> arch/powerpc/include/asm/kvm_ppc.h | 11 +++++++++++
>> arch/powerpc/kvm/e500.h | 6 +++---
>> arch/powerpc/kvm/e500_emulate.c | 15 ++++++++++-----
>> arch/powerpc/kvm/e500_tlb.c | 33 =
+++++++++++----------------------
>> 4 files changed, 35 insertions(+), 30 deletions(-)
>>=20
>> diff --git a/arch/powerpc/include/asm/kvm_ppc.h =
b/arch/powerpc/include/asm/kvm_ppc.h
>> index 609cca3..a08e756 100644
>> --- a/arch/powerpc/include/asm/kvm_ppc.h
>> +++ b/arch/powerpc/include/asm/kvm_ppc.h
>> @@ -293,4 +293,15 @@ static inline void kvmppc_lazy_ee_enable(void)
>> #endif
>> }
>>=20
>> +static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int =
ra, int rb)
>> +{
>> + ulong ea;
>> +
>> + ea =3D kvmppc_get_gpr(vcpu, rb);
>> + if (ra)
>> + ea +=3D kvmppc_get_gpr(vcpu, ra);
>> +
>> + return ea;
>> +}
>> +
>> #endif /* __POWERPC_KVM_PPC_H__ */
>> diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h
>> index d162286..32e98a7 100644
>> --- a/arch/powerpc/kvm/e500.h
>> +++ b/arch/powerpc/kvm/e500.h
>> @@ -129,9 +129,9 @@ int kvmppc_e500_emul_mt_mmucsr0(struct =
kvmppc_vcpu_e500 *vcpu_e500,
>> ulong value);
>> int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu);
>> int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu);
>> -int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb);
>> -int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, =
int rb);
>> -int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb);
>> +int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea);
>> +int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int type, gva_t =
ea);
>> +int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, gva_t ea);
>> int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500);
>> void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500);
>>=20
>> diff --git a/arch/powerpc/kvm/e500_emulate.c =
b/arch/powerpc/kvm/e500_emulate.c
>> index e04b0ef..3bf2486 100644
>> --- a/arch/powerpc/kvm/e500_emulate.c
>> +++ b/arch/powerpc/kvm/e500_emulate.c
>> @@ -88,7 +88,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, =
struct kvm_vcpu *vcpu,
>> int emulated =3D EMULATE_DONE;
>> int ra =3D get_ra(inst);
>> int rb =3D get_rb(inst);
>> - int rt =3D get_rt(inst);
>=20
> The function scope rt variable shouldn't hurt, as the compiler will be =
smart enough to only calculate it when it's actually used.
>=20
>> + gva_t ea;
>>=20
>> switch (get_op(inst)) {
>> case 31:
>> @@ -113,15 +113,20 @@ int kvmppc_core_emulate_op(struct kvm_run *run, =
struct kvm_vcpu *vcpu,
>> break;
>>=20
>> case XOP_TLBSX:
>> - emulated =3D kvmppc_e500_emul_tlbsx(vcpu,rb);
>> + ea =3D kvmppc_get_ea_indexed(vcpu, ra, rb);
>> + emulated =3D kvmppc_e500_emul_tlbsx(vcpu, ea);
>> break;
>>=20
>> - case XOP_TLBILX:
>> - emulated =3D kvmppc_e500_emul_tlbilx(vcpu, rt, =
ra, rb);
>> + case XOP_TLBILX: {
>> + int t =3D (inst >> 21) & 0x3;
>=20
> so we can remove this
>=20
>> + ea =3D kvmppc_get_ea_indexed(vcpu, ra, rb);
>> + emulated =3D kvmppc_e500_emul_tlbilx(vcpu, t, =
ea);
>=20
> and instead here pass rt & 3.
>=20
> The rest of the patch looks fine, so I'll do the change while applying =
it.
Reading my old comment on the previous version, I realized that I was =
slightly too fuzzy in my wording. I meant to make the parameter that =
gets passed into the functions a variable of a different type (like you =
did). Calculating that one from rt is fine.
Alex
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 06/12] KVM: PPC: Mask ea's high 32-bits in 32/64 instr emulation
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (4 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-10-11 16:13 ` [PATCH 07/12] KVM: PPC: e500: Mask MAS2 EPN high 32-bits in 32/64 tlbwe emulation Mihai Caraman
` (6 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Mask high 32 bits of effective address in emulation layer for guests running
in 32-bit mode.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
v1: added BOOK3S implementation.
arch/powerpc/include/asm/kvm_ppc.h | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index a08e756..4a3fdbd 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -296,11 +296,21 @@ static inline void kvmppc_lazy_ee_enable(void)
static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb)
{
ulong ea;
+ ulong msr_64bit = 0;
ea = kvmppc_get_gpr(vcpu, rb);
if (ra)
ea += kvmppc_get_gpr(vcpu, ra);
+#if defined(CONFIG_PPC_BOOK3E_64)
+ msr_64bit = MSR_CM;
+#elif defined(CONFIG_PPC_BOOK3S_64)
+ msr_64bit = MSR_SF;
+#endif
+
+ if (!(vcpu->arch.shared->msr & msr_64bit))
+ ea = (uint32_t)ea;
+
return ea;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 07/12] KVM: PPC: e500: Mask MAS2 EPN high 32-bits in 32/64 tlbwe emulation
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (5 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 06/12] KVM: PPC: Mask ea's high 32-bits in 32/64 instr emulation Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-10-11 16:13 ` [PATCH 08/12] KVM: PPC: booke: Extend MAS2 EPN mask for 64-bit Mihai Caraman
` (5 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Mask high 32 bits of MAS2's effective page number in tlbwe emulation for guests
running in 32-bit mode.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
v1: patch splited.
arch/powerpc/kvm/e500_tlb.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index b5a188a..6c0997e 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -871,6 +871,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
gtlbe->mas1 = vcpu->arch.shared->mas1;
gtlbe->mas2 = vcpu->arch.shared->mas2;
+ if (!(vcpu->arch.shared->msr & MSR_CM))
+ gtlbe->mas2 &= 0xffffffffUL;
gtlbe->mas7_3 = vcpu->arch.shared->mas7_3;
trace_kvm_booke206_gtlb_write(vcpu->arch.shared->mas0, gtlbe->mas1,
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 08/12] KVM: PPC: booke: Extend MAS2 EPN mask for 64-bit
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (6 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 07/12] KVM: PPC: e500: Mask MAS2 EPN high 32-bits in 32/64 tlbwe emulation Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-10-11 16:13 ` [PATCH 09/12] KVM: PPC: bookehv: Add guest computation mode for irq delivery Mihai Caraman
` (4 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Extend MAS2 EPN mask to retain most significant bits on 64-bit hosts.
Use this mask in tlb effective address accessor.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
arch/powerpc/include/asm/mmu-book3e.h | 2 +-
arch/powerpc/kvm/e500.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h
index eeabcdb..99d43e0 100644
--- a/arch/powerpc/include/asm/mmu-book3e.h
+++ b/arch/powerpc/include/asm/mmu-book3e.h
@@ -59,7 +59,7 @@
#define MAS1_TSIZE_SHIFT 7
#define MAS1_TSIZE(x) (((x) << MAS1_TSIZE_SHIFT) & MAS1_TSIZE_MASK)
-#define MAS2_EPN 0xFFFFF000
+#define MAS2_EPN (~0xFFFUL)
#define MAS2_X0 0x00000040
#define MAS2_X1 0x00000020
#define MAS2_W 0x00000010
diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h
index 32e98a7..c70d37e 100644
--- a/arch/powerpc/kvm/e500.h
+++ b/arch/powerpc/kvm/e500.h
@@ -154,7 +154,7 @@ get_tlb_size(const struct kvm_book3e_206_tlb_entry *tlbe)
static inline gva_t get_tlb_eaddr(const struct kvm_book3e_206_tlb_entry *tlbe)
{
- return tlbe->mas2 & 0xfffff000;
+ return tlbe->mas2 & MAS2_EPN;
}
static inline u64 get_tlb_bytes(const struct kvm_book3e_206_tlb_entry *tlbe)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 09/12] KVM: PPC: bookehv: Add guest computation mode for irq delivery
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (7 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 08/12] KVM: PPC: booke: Extend MAS2 EPN mask for 64-bit Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-12-01 13:42 ` Alexander Graf
2012-10-11 16:13 ` [PATCH 10/12] KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation Mihai Caraman
` (3 subsequent siblings)
12 siblings, 1 reply; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
When delivering guest IRQs, update MSR computation mode according to guest
interrupt computation mode found in EPCR.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
v1: added intermediate msr variable.
arch/powerpc/kvm/booke.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 7c9c389..86f0d0d 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -312,6 +312,7 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
bool crit;
bool keep_irq = false;
enum int_class int_class;
+ ulong new_msr = vcpu->arch.shared->msr;
/* Truncate crit indicators in 32 bit mode */
if (!(vcpu->arch.shared->msr & MSR_SF)) {
@@ -407,7 +408,13 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
set_guest_esr(vcpu, vcpu->arch.queued_esr);
if (update_dear == true)
set_guest_dear(vcpu, vcpu->arch.queued_dear);
- kvmppc_set_msr(vcpu, vcpu->arch.shared->msr & msr_mask);
+
+ new_msr &= msr_mask;
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+ if (vcpu->arch.epcr & SPRN_EPCR_ICM)
+ new_msr |= MSR_CM;
+#endif
+ kvmppc_set_msr(vcpu, new_msr);
if (!keep_irq)
clear_bit(priority, &vcpu->arch.pending_exceptions);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 09/12] KVM: PPC: bookehv: Add guest computation mode for irq delivery
2012-10-11 16:13 ` [PATCH 09/12] KVM: PPC: bookehv: Add guest computation mode for irq delivery Mihai Caraman
@ 2012-12-01 13:42 ` Alexander Graf
0 siblings, 0 replies; 20+ messages in thread
From: Alexander Graf @ 2012-12-01 13:42 UTC (permalink / raw)
To: Mihai Caraman; +Cc: linuxppc-dev, kvm, kvm-ppc
On 11.10.2012, at 18:13, Mihai Caraman wrote:
> When delivering guest IRQs, update MSR computation mode according to =
guest
> interrupt computation mode found in EPCR.
>=20
> Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
> ---
> v1: added intermediate msr variable.
>=20
> arch/powerpc/kvm/booke.c | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>=20
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index 7c9c389..86f0d0d 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -312,6 +312,7 @@ static int kvmppc_booke_irqprio_deliver(struct =
kvm_vcpu *vcpu,
> bool crit;
> bool keep_irq =3D false;
> enum int_class int_class;
> + ulong new_msr =3D vcpu->arch.shared->msr;
>=20
> /* Truncate crit indicators in 32 bit mode */
> if (!(vcpu->arch.shared->msr & MSR_SF)) {
> @@ -407,7 +408,13 @@ static int kvmppc_booke_irqprio_deliver(struct =
kvm_vcpu *vcpu,
> set_guest_esr(vcpu, vcpu->arch.queued_esr);
> if (update_dear =3D=3D true)
> set_guest_dear(vcpu, vcpu->arch.queued_dear);
> - kvmppc_set_msr(vcpu, vcpu->arch.shared->msr & msr_mask);
> +
> + new_msr &=3D msr_mask;
> +#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
Why the dependency on booke_hv? This is booke code and according to =
booke, ICM declares the interrupt mode a guest will be in, right?
I'll just remove the BOOKE_HV ifdef bit.
Alex
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 10/12] KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (8 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 09/12] KVM: PPC: bookehv: Add guest computation mode for irq delivery Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-12-01 13:59 ` Alexander Graf
2012-10-11 16:13 ` [PATCH 11/12] KVM: PPC: booke: Add EPCR support in sregs Mihai Caraman
` (2 subsequent siblings)
12 siblings, 1 reply; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Add EPCR support in booke mtspr/mfspr emulation. EPCR register is defined only
for 64-bit and HV categories, we will expose it at this point only to 64-bit
virtual processors running on 64-bit HV hosts.
Define a reusable setter function for vcpu's EPCR.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
v1: extended guard defines with CONFIG_KVM_BOOKE_HV required by arch's epcr and
shadow_epcr fields.
arch/powerpc/kvm/booke.c | 10 ++++++++++
arch/powerpc/kvm/booke.h | 1 +
arch/powerpc/kvm/booke_emulate.c | 12 +++++++++++-
3 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 86f0d0d..e6159f5 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -1473,6 +1473,16 @@ void kvmppc_core_flush_memslot(struct kvm *kvm, struct kvm_memory_slot *memslot)
{
}
+void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr)
+{
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+ vcpu->arch.epcr = new_epcr;
+ vcpu->arch.shadow_epcr &= ~SPRN_EPCR_GICM;
+ if (vcpu->arch.epcr & SPRN_EPCR_ICM)
+ vcpu->arch.shadow_epcr |= SPRN_EPCR_GICM;
+#endif
+}
+
void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr)
{
vcpu->arch.tcr = new_tcr;
diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
index ba61974..e9b88e4 100644
--- a/arch/powerpc/kvm/booke.h
+++ b/arch/powerpc/kvm/booke.h
@@ -69,6 +69,7 @@ extern unsigned long kvmppc_booke_handlers;
void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
+void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index 514790f..8d9d8f9 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -240,7 +240,12 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
case SPRN_MCSR:
vcpu->arch.mcsr &= ~spr_val;
break;
-
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+ case SPRN_EPCR:
+ kvmppc_set_epcr(vcpu, spr_val);
+ mtspr(SPRN_EPCR, vcpu->arch.shadow_epcr);
+ break;
+#endif
default:
emulated = EMULATE_FAIL;
}
@@ -335,6 +340,11 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
case SPRN_MCSR:
*spr_val = vcpu->arch.mcsr;
break;
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+ case SPRN_EPCR:
+ *spr_val = vcpu->arch.epcr;
+ break;
+#endif
default:
emulated = EMULATE_FAIL;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 10/12] KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation
2012-10-11 16:13 ` [PATCH 10/12] KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation Mihai Caraman
@ 2012-12-01 13:59 ` Alexander Graf
0 siblings, 0 replies; 20+ messages in thread
From: Alexander Graf @ 2012-12-01 13:59 UTC (permalink / raw)
To: Mihai Caraman; +Cc: linuxppc-dev, kvm, kvm-ppc
On 11.10.2012, at 18:13, Mihai Caraman wrote:
> Add EPCR support in booke mtspr/mfspr emulation. EPCR register is =
defined only
> for 64-bit and HV categories, we will expose it at this point only to =
64-bit
> virtual processors running on 64-bit HV hosts.
> Define a reusable setter function for vcpu's EPCR.
>=20
> Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
> ---
> v1: extended guard defines with CONFIG_KVM_BOOKE_HV required by arch's =
epcr and
> shadow_epcr fields.
I removed that constraint in another patch I just sent out and will =
remove the guards on HV while applying the patch.
Alex
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 11/12] KVM: PPC: booke: Add EPCR support in sregs
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (9 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 10/12] KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-12-01 14:02 ` Alexander Graf
2012-10-11 16:13 ` [PATCH 12/12] KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface Mihai Caraman
2012-12-01 15:06 ` [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Alexander Graf
12 siblings, 1 reply; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Add KVM_SREGS_E_64 feature and EPCR spr support in get/set sregs for 64-bit
hosts.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
arch/powerpc/kvm/booke.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index e6159f5..d396374 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -1215,6 +1215,9 @@ static void get_sregs_base(struct kvm_vcpu *vcpu,
u64 tb = get_tb();
sregs->u.e.features |= KVM_SREGS_E_BASE;
+#ifdef CONFIG_64BIT
+ sregs->u.e.features |= KVM_SREGS_E_64;
+#endif
sregs->u.e.csrr0 = vcpu->arch.csrr0;
sregs->u.e.csrr1 = vcpu->arch.csrr1;
@@ -1226,6 +1229,9 @@ static void get_sregs_base(struct kvm_vcpu *vcpu,
sregs->u.e.dec = kvmppc_get_dec(vcpu, tb);
sregs->u.e.tb = tb;
sregs->u.e.vrsave = vcpu->arch.vrsave;
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+ sregs->u.e.epcr = vcpu->arch.epcr;
+#endif
}
static int set_sregs_base(struct kvm_vcpu *vcpu,
@@ -1241,6 +1247,7 @@ static int set_sregs_base(struct kvm_vcpu *vcpu,
set_guest_dear(vcpu, sregs->u.e.dear);
vcpu->arch.vrsave = sregs->u.e.vrsave;
kvmppc_set_tcr(vcpu, sregs->u.e.tcr);
+ kvmppc_set_epcr(vcpu, sregs->u.e.epcr);
if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_DEC) {
vcpu->arch.dec = sregs->u.e.dec;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 11/12] KVM: PPC: booke: Add EPCR support in sregs
2012-10-11 16:13 ` [PATCH 11/12] KVM: PPC: booke: Add EPCR support in sregs Mihai Caraman
@ 2012-12-01 14:02 ` Alexander Graf
0 siblings, 0 replies; 20+ messages in thread
From: Alexander Graf @ 2012-12-01 14:02 UTC (permalink / raw)
To: Mihai Caraman; +Cc: linuxppc-dev, kvm, kvm-ppc
On 11.10.2012, at 18:13, Mihai Caraman wrote:
> Add KVM_SREGS_E_64 feature and EPCR spr support in get/set sregs for 64-bit
> hosts.
Why would we need this if we have a proper ONE_REG interface for EPCR?
Alex
>
> Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
> ---
> arch/powerpc/kvm/booke.c | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index e6159f5..d396374 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -1215,6 +1215,9 @@ static void get_sregs_base(struct kvm_vcpu *vcpu,
> u64 tb = get_tb();
>
> sregs->u.e.features |= KVM_SREGS_E_BASE;
> +#ifdef CONFIG_64BIT
> + sregs->u.e.features |= KVM_SREGS_E_64;
> +#endif
>
> sregs->u.e.csrr0 = vcpu->arch.csrr0;
> sregs->u.e.csrr1 = vcpu->arch.csrr1;
> @@ -1226,6 +1229,9 @@ static void get_sregs_base(struct kvm_vcpu *vcpu,
> sregs->u.e.dec = kvmppc_get_dec(vcpu, tb);
> sregs->u.e.tb = tb;
> sregs->u.e.vrsave = vcpu->arch.vrsave;
> +#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
> + sregs->u.e.epcr = vcpu->arch.epcr;
> +#endif
> }
>
> static int set_sregs_base(struct kvm_vcpu *vcpu,
> @@ -1241,6 +1247,7 @@ static int set_sregs_base(struct kvm_vcpu *vcpu,
> set_guest_dear(vcpu, sregs->u.e.dear);
> vcpu->arch.vrsave = sregs->u.e.vrsave;
> kvmppc_set_tcr(vcpu, sregs->u.e.tcr);
> + kvmppc_set_epcr(vcpu, sregs->u.e.epcr);
>
> if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_DEC) {
> vcpu->arch.dec = sregs->u.e.dec;
> --
> 1.7.4.1
>
>
> --
> 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 12/12] KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (10 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 11/12] KVM: PPC: booke: Add EPCR support in sregs Mihai Caraman
@ 2012-10-11 16:13 ` Mihai Caraman
2012-12-01 14:15 ` Alexander Graf
2012-12-01 15:06 ` [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Alexander Graf
12 siblings, 1 reply; 20+ messages in thread
From: Mihai Caraman @ 2012-10-11 16:13 UTC (permalink / raw)
To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
Implement ONE_REG interface for EPCR register adding KVM_REG_PPC_EPCR to
the list of ONE_REG PPC supported registers.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
Documentation/virtual/kvm/api.txt | 1 +
arch/powerpc/include/asm/kvm.h | 2 ++
arch/powerpc/kvm/booke.c | 16 ++++++++++++++++
3 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index e726d76..c78dff4 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1773,6 +1773,7 @@ registers, find a list below:
PPC | KVM_REG_PPC_VPA_ADDR | 64
PPC | KVM_REG_PPC_VPA_SLB | 128
PPC | KVM_REG_PPC_VPA_DTL | 128
+ PPC | KVM_REG_PPC_EPCR | 32
4.69 KVM_GET_ONE_REG
diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
index b89ae4d..beb6b20 100644
--- a/arch/powerpc/include/asm/kvm.h
+++ b/arch/powerpc/include/asm/kvm.h
@@ -386,4 +386,6 @@ struct kvm_book3e_206_tlb_params {
#define KVM_REG_PPC_VPA_SLB (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x83)
#define KVM_REG_PPC_VPA_DTL (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84)
+#define KVM_REG_PPC_EPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85)
+
#endif /* __LINUX_KVM_POWERPC_H */
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index d396374..60b8237 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -1395,6 +1395,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
&vcpu->arch.dbg_reg.dac[dac], sizeof(u64));
break;
}
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+ case KVM_REG_PPC_EPCR:
+ r = copy_to_user((u32 __user *)(long)reg->addr,
+ &vcpu->arch.epcr, sizeof(u32));
+ break;
+#endif
default:
break;
}
@@ -1422,6 +1428,16 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
(u64 __user *)(long)reg->addr, sizeof(u64));
break;
}
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+ case KVM_REG_PPC_EPCR: {
+ u32 new_epcr;
+ r = copy_from_user(&new_epcr,
+ (u32 __user *)(long)reg->addr, sizeof(u32));
+ if (r == 0)
+ kvmppc_set_epcr(vcpu, new_epcr);
+ break;
+ }
+#endif
default:
break;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 12/12] KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface
2012-10-11 16:13 ` [PATCH 12/12] KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface Mihai Caraman
@ 2012-12-01 14:15 ` Alexander Graf
0 siblings, 0 replies; 20+ messages in thread
From: Alexander Graf @ 2012-12-01 14:15 UTC (permalink / raw)
To: Mihai Caraman; +Cc: linuxppc-dev, kvm, kvm-ppc
On 11.10.2012, at 18:13, Mihai Caraman wrote:
> Implement ONE_REG interface for EPCR register adding KVM_REG_PPC_EPCR =
to
> the list of ONE_REG PPC supported registers.
>=20
> Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
> ---
> Documentation/virtual/kvm/api.txt | 1 +
> arch/powerpc/include/asm/kvm.h | 2 ++
> arch/powerpc/kvm/booke.c | 16 ++++++++++++++++
> 3 files changed, 19 insertions(+), 0 deletions(-)
>=20
> diff --git a/Documentation/virtual/kvm/api.txt =
b/Documentation/virtual/kvm/api.txt
> index e726d76..c78dff4 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -1773,6 +1773,7 @@ registers, find a list below:
> PPC | KVM_REG_PPC_VPA_ADDR | 64
> PPC | KVM_REG_PPC_VPA_SLB | 128
> PPC | KVM_REG_PPC_VPA_DTL | 128
> + PPC | KVM_REG_PPC_EPCR | 32
>=20
> 4.69 KVM_GET_ONE_REG
>=20
> diff --git a/arch/powerpc/include/asm/kvm.h =
b/arch/powerpc/include/asm/kvm.h
> index b89ae4d..beb6b20 100644
> --- a/arch/powerpc/include/asm/kvm.h
> +++ b/arch/powerpc/include/asm/kvm.h
> @@ -386,4 +386,6 @@ struct kvm_book3e_206_tlb_params {
> #define KVM_REG_PPC_VPA_SLB (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x83)
> #define KVM_REG_PPC_VPA_DTL (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84)
>=20
> +#define KVM_REG_PPC_EPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85)
> +
> #endif /* __LINUX_KVM_POWERPC_H */
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index d396374..60b8237 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -1395,6 +1395,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu =
*vcpu, struct kvm_one_reg *reg)
> &vcpu->arch.dbg_reg.dac[dac], =
sizeof(u64));
> break;
> }
> +#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
No need for the HV dependency here.
> + case KVM_REG_PPC_EPCR:
> + r =3D copy_to_user((u32 __user *)(long)reg->addr,
> + &vcpu->arch.epcr, sizeof(u32));
This can be put_user. The reason we don't do it for the other ONE_REG =
variables is that they are u64s which can't be put_user'd on 32bit =
systems.
> + break;
> +#endif
> default:
> break;
> }
> @@ -1422,6 +1428,16 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu =
*vcpu, struct kvm_one_reg *reg)
> (u64 __user *)(long)reg->addr, =
sizeof(u64));
> break;
> }
> +#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
Same as above
> + case KVM_REG_PPC_EPCR: {
> + u32 new_epcr;
> + r =3D copy_from_user(&new_epcr,
> + (u32 __user *)(long)reg->addr, =
sizeof(u32));
Same as above.
I'll fix those up for you when applying the patch.
Alex
> + if (r =3D=3D 0)
> + kvmppc_set_epcr(vcpu, new_epcr);
> + break;
> + }
> +#endif
> default:
> break;
> }
> --=20
> 1.7.4.1
>=20
>=20
> --
> 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
` (11 preceding siblings ...)
2012-10-11 16:13 ` [PATCH 12/12] KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface Mihai Caraman
@ 2012-12-01 15:06 ` Alexander Graf
12 siblings, 0 replies; 20+ messages in thread
From: Alexander Graf @ 2012-12-01 15:06 UTC (permalink / raw)
To: Mihai Caraman; +Cc: linuxppc-dev, kvm, kvm-ppc
On 11.10.2012, at 18:13, Mihai Caraman wrote:
> This patchset adds arch support to KVM for 64-bit Book3E PowerPC =
procesosrs
> with Embedded.Hypervisor category. The support is limited to the =
bolted TLB miss
> exception handlers version and was validated on Freescale's e5500 =
cores
> using P5020DS boards.
Thanks, applied all except for 11/12 with their respective small =
fine-tunings to kvm-ppc-next :).
Alex
^ permalink raw reply [flat|nested] 20+ messages in thread