[PATCH 07/14] KVM: PPC: Fix build failure with HV KVM and CBE

2011-10-31 Thread Alexander Graf
When running with HV KVM and CBE config options enabled, I get
build failures like the following:

  arch/powerpc/kernel/head_64.o: In function `cbe_system_error_hv':
  (.text+0x1228): undefined reference to `do_kvm_0x1202'
  arch/powerpc/kernel/head_64.o: In function `cbe_maintenance_hv':
  (.text+0x1628): undefined reference to `do_kvm_0x1602'
  arch/powerpc/kernel/head_64.o: In function `cbe_thermal_hv':
  (.text+0x1828): undefined reference to `do_kvm_0x1802'

This is because we jump to a KVM handler when HV is enabled, but we
only generate the handler with PR KVM mode.

Signed-off-by: Alexander Graf ag...@suse.de
---
 arch/powerpc/kernel/exceptions-64s.S |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 29ddd8b..396d080 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -267,7 +267,7 @@ vsx_unavailable_pSeries_1:
 
 #ifdef CONFIG_CBE_RAS
STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error)
-   KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1202)
+   KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1202)
 #endif /* CONFIG_CBE_RAS */
 
STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint)
@@ -275,7 +275,7 @@ vsx_unavailable_pSeries_1:
 
 #ifdef CONFIG_CBE_RAS
STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance)
-   KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1602)
+   KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602)
 #endif /* CONFIG_CBE_RAS */
 
STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist)
@@ -283,7 +283,7 @@ vsx_unavailable_pSeries_1:
 
 #ifdef CONFIG_CBE_RAS
STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
-   KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
+   KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
 #endif /* CONFIG_CBE_RAS */
 
. = 0x3000
-- 
1.6.0.2

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/14] PPC: Fix race in mtmsr paravirt implementation

2011-10-31 Thread Alexander Graf
From: Bharat Bhushan r65...@freescale.com

The current implementation of mtmsr and mtmsrd are racy in that it does:

  * check (int_pending == 0)
  --- host sets int_pending = 1 ---
  * write shared page
  * done

while instead we should check for int_pending after the shared page is written.

Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com
Signed-off-by: Alexander Graf ag...@suse.de
---
 arch/powerpc/kernel/kvm_emul.S |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
index f2b1b25..3d64c57 100644
--- a/arch/powerpc/kernel/kvm_emul.S
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -167,6 +167,9 @@ maybe_stay_in_guest:
 kvm_emulate_mtmsr_reg2:
ori r30, r0, 0
 
+   /* Put MSR into magic page because we don't call mtmsr */
+   STL64(r30, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
+
/* Check if we have to fetch an interrupt */
lwz r31, (KVM_MAGIC_PAGE + KVM_MAGIC_INT)(0)
cmpwi   r31, 0
@@ -174,15 +177,10 @@ kvm_emulate_mtmsr_reg2:
 
/* Check if we may trigger an interrupt */
andi.   r31, r30, MSR_EE
-   beq no_mtmsr
-
-   b   do_mtmsr
+   bne do_mtmsr
 
 no_mtmsr:
 
-   /* Put MSR into magic page because we don't call mtmsr */
-   STL64(r30, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
-
SCRATCH_RESTORE
 
/* Go back to caller */
-- 
1.6.0.2

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/14] KVM: Fix whitespace in kvm_para.h

2011-10-31 Thread Alexander Graf
When syncing KVM headers with QEMU I (or whoever applies the
diff) end up automatically fixing whitespaces. One of them
is in kvm_para.h.

It's a lot more consistent for people who don't do the whitespace
fixups automatically to already have fixed headers in Linux. So
remove the sparse empty line at the end of kvm_para.h and everyone's
happy.

Reported-by: Blue Swirl blauwir...@gmail.com
Signed-off-by: Alexander Graf ag...@suse.de
---
 include/linux/kvm_para.h |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h
index 47a070b..ff476dd 100644
--- a/include/linux/kvm_para.h
+++ b/include/linux/kvm_para.h
@@ -35,4 +35,3 @@ static inline int kvm_para_has_feature(unsigned int feature)
 }
 #endif /* __KERNEL__ */
 #endif /* __LINUX_KVM_PARA_H */
-
-- 
1.6.0.2

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PULL 00/14] ppc patch queue 2011-10-31

2011-10-31 Thread Alexander Graf
Hi Avi / Marcelo,

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

Alex


The following changes since commit b796a09c5d808f4013f27ad45953db604dac18fd:
  Marcelo Tosatti (1):
Merge remote-tracking branch 'upstream/master' into kvm-devel

are available in the git repository at:

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

Alexander Graf (7):
  KVM: PPC: Fix build failure with HV KVM and CBE
  Revert KVM: PPC: Add support for explicit HIOR setting
  KVM: PPC: Add generic single register ioctls
  KVM: PPC: Add support for explicit HIOR setting
  KVM: PPC: Whitespace fix for kvm.h
  KVM: Fix whitespace in kvm_para.h
  KVM: PPC: E500: Support hugetlbfs

Bharat Bhushan (1):
  PPC: Fix race in mtmsr paravirt implementation

Scott Wood (6):
  KVM: PPC: e500: don't translate gfn to pfn with preemption disabled
  KVM: PPC: e500: Eliminate preempt_disable in local_sid_destroy_all
  KVM: PPC: e500: clear up confusion between host and guest entries
  KVM: PPC: e500: MMU API
  KVM: PPC: e500: tlbsx: fix tlb0 esel
  KVM: PPC: e500: Don't hardcode PIR=0

 Documentation/virtual/kvm/api.txt |  122 ++
 arch/powerpc/include/asm/kvm.h|   49 ++-
 arch/powerpc/include/asm/kvm_book3s.h |2 +-
 arch/powerpc/include/asm/kvm_e500.h   |   46 ++-
 arch/powerpc/include/asm/kvm_ppc.h|5 +
 arch/powerpc/include/asm/mmu-book3e.h |1 +
 arch/powerpc/kernel/exceptions-64s.S  |6 +-
 arch/powerpc/kernel/kvm_emul.S|   10 +-
 arch/powerpc/kvm/book3s_pr.c  |   12 +-
 arch/powerpc/kvm/booke.c  |4 +-
 arch/powerpc/kvm/e500.c   |8 +-
 arch/powerpc/kvm/e500_emulate.c   |   12 +-
 arch/powerpc/kvm/e500_tlb.c   |  674 +++--
 arch/powerpc/kvm/e500_tlb.h   |   55 +--
 arch/powerpc/kvm/powerpc.c|   92 +
 include/linux/kvm.h   |   50 +++
 include/linux/kvm_para.h  |1 -
 17 files changed, 865 insertions(+), 284 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/14] KVM: PPC: e500: tlbsx: fix tlb0 esel

2011-10-31 Thread Alexander Graf
From: Scott Wood scottw...@freescale.com

It should contain the way, not the absolute TLB0 index.

Signed-off-by: Scott Wood scottw...@freescale.com
Signed-off-by: Alexander Graf ag...@suse.de
---
 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 f19ae2f..ec17148 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -853,6 +853,8 @@ int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb)
}
 
if (gtlbe) {
+   esel = vcpu_e500-gtlb_params[tlbsel].ways - 1;
+
vcpu_e500-mas0 = MAS0_TLBSEL(tlbsel) | MAS0_ESEL(esel)
| MAS0_NV(vcpu_e500-gtlb_nv[tlbsel]);
vcpu_e500-mas1 = gtlbe-mas1;
-- 
1.6.0.2

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/14] KVM: PPC: Whitespace fix for kvm.h

2011-10-31 Thread Alexander Graf
kvm.h had sparse whitespace at the end of the line. Clean it
up so syncing with QEMU gets easier.

Signed-off-by: Alexander Graf ag...@suse.de
---
 arch/powerpc/include/asm/kvm.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
index 53b8759..fb3fddc 100644
--- a/arch/powerpc/include/asm/kvm.h
+++ b/arch/powerpc/include/asm/kvm.h
@@ -170,8 +170,8 @@ struct kvm_sregs {
} ppc64;
struct {
__u32 sr[16];
-   __u64 ibat[8]; 
-   __u64 dbat[8]; 
+   __u64 ibat[8];
+   __u64 dbat[8];
} ppc32;
} s;
struct {
-- 
1.6.0.2

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/14] KVM: PPC: e500: clear up confusion between host and guest entries

2011-10-31 Thread Alexander Graf
From: Scott Wood scottw...@freescale.com

Split out the portions of tlbe_priv that should be associated with host
entries into tlbe_ref.  Base victim selection on the number of hardware
entries, not guest entries.

For TLB1, where one guest entry can be mapped by multiple host entries,
we use the host tlbe_ref for tracking page references.  For the guest
TLB0 entries, we still track it with gtlb_priv, to avoid having to
retranslate if the entry is evicted from the host TLB but not the
guest TLB.

Signed-off-by: Scott Wood scottw...@freescale.com
Signed-off-by: Alexander Graf ag...@suse.de
---
 arch/powerpc/include/asm/kvm_e500.h   |   24 +++-
 arch/powerpc/include/asm/mmu-book3e.h |1 +
 arch/powerpc/kvm/e500_tlb.c   |  267 +++--
 arch/powerpc/kvm/e500_tlb.h   |   17 --
 4 files changed, 213 insertions(+), 96 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_e500.h 
b/arch/powerpc/include/asm/kvm_e500.h
index adbfca9..a5197d8 100644
--- a/arch/powerpc/include/asm/kvm_e500.h
+++ b/arch/powerpc/include/asm/kvm_e500.h
@@ -32,13 +32,21 @@ struct tlbe{
 #define E500_TLB_VALID 1
 #define E500_TLB_DIRTY 2
 
-struct tlbe_priv {
+struct tlbe_ref {
pfn_t pfn;
unsigned int flags; /* E500_TLB_* */
 };
 
+struct tlbe_priv {
+   struct tlbe_ref ref; /* TLB0 only -- TLB1 uses tlb_refs */
+};
+
 struct vcpu_id_table;
 
+struct kvmppc_e500_tlb_params {
+   int entries, ways, sets;
+};
+
 struct kvmppc_vcpu_e500 {
/* Unmodified copy of the guest's TLB. */
struct tlbe *gtlb_arch[E500_TLB_NUM];
@@ -49,6 +57,20 @@ struct kvmppc_vcpu_e500 {
unsigned int gtlb_size[E500_TLB_NUM];
unsigned int gtlb_nv[E500_TLB_NUM];
 
+   /*
+* information associated with each host TLB entry --
+* TLB1 only for now.  If/when guest TLB1 entries can be
+* mapped with host TLB0, this will be used for that too.
+*
+* We don't want to use this for guest TLB0 because then we'd
+* have the overhead of doing the translation again even if
+* the entry is still in the guest TLB (e.g. we swapped out
+* and back, and our host TLB entries got evicted).
+*/
+   struct tlbe_ref *tlb_refs[E500_TLB_NUM];
+
+   unsigned int host_tlb1_nv;
+
u32 host_pid[E500_PID_NUM];
u32 pid[E500_PID_NUM];
u32 svr;
diff --git a/arch/powerpc/include/asm/mmu-book3e.h 
b/arch/powerpc/include/asm/mmu-book3e.h
index 3ea0f9a..4c30de3 100644
--- a/arch/powerpc/include/asm/mmu-book3e.h
+++ b/arch/powerpc/include/asm/mmu-book3e.h
@@ -165,6 +165,7 @@
 #define TLBnCFG_MAXSIZE0x000f  /* Maximum Page Size 
(v1.0) */
 #define TLBnCFG_MAXSIZE_SHIFT  16
 #define TLBnCFG_ASSOC  0xff00  /* Associativity */
+#define TLBnCFG_ASSOC_SHIFT24
 
 /* TLBnPS encoding */
 #define TLBnPS_4K  0x0004
diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index b976d80..59221bb 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -12,6 +12,7 @@
  * published by the Free Software Foundation.
  */
 
+#include linux/kernel.h
 #include linux/types.h
 #include linux/slab.h
 #include linux/string.h
@@ -26,7 +27,7 @@
 #include trace.h
 #include timing.h
 
-#define to_htlb1_esel(esel) (tlb1_entry_num - (esel) - 1)
+#define to_htlb1_esel(esel) (host_tlb_params[1].entries - (esel) - 1)
 
 struct id {
unsigned long val;
@@ -63,7 +64,7 @@ static DEFINE_PER_CPU(struct pcpu_id_table, pcpu_sids);
  * The valid range of shadow ID is [1..255] */
 static DEFINE_PER_CPU(unsigned long, pcpu_last_used_sid);
 
-static unsigned int tlb1_entry_num;
+static struct kvmppc_e500_tlb_params host_tlb_params[E500_TLB_NUM];
 
 /*
  * Allocate a free shadow id and setup a valid sid mapping in given entry.
@@ -237,7 +238,7 @@ void kvmppc_dump_tlbs(struct kvm_vcpu *vcpu)
}
 }
 
-static inline unsigned int tlb0_get_next_victim(
+static inline unsigned int gtlb0_get_next_victim(
struct kvmppc_vcpu_e500 *vcpu_e500)
 {
unsigned int victim;
@@ -252,7 +253,7 @@ static inline unsigned int tlb0_get_next_victim(
 static inline unsigned int tlb1_max_shadow_size(void)
 {
/* reserve one entry for magic page */
-   return tlb1_entry_num - tlbcam_index - 1;
+   return host_tlb_params[1].entries - tlbcam_index - 1;
 }
 
 static inline int tlbe_is_writable(struct tlbe *tlbe)
@@ -302,13 +303,12 @@ static inline void __write_host_tlbe(struct tlbe *stlbe, 
uint32_t mas0)
local_irq_restore(flags);
 }
 
+/* esel is index into set, not whole array */
 static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500,
int tlbsel, int esel, struct tlbe *stlbe)
 {
if (tlbsel == 0) {
-   __write_host_tlbe(stlbe,
- MAS0_TLBSEL(0) |
- MAS0_ESEL(esel  (KVM_E500_TLB0_WAY_NUM - 
1)));
+   

[PATCH 08/14] Revert KVM: PPC: Add support for explicit HIOR setting

2011-10-31 Thread Alexander Graf
This reverts commit 11d7596e18a712dc3bc29d45662ec111fd65946b. It exceeded
the padding on the SREGS struct, rendering the ABI backwards-incompatible.

Signed-off-by: Alexander Graf ag...@suse.de
---
 arch/powerpc/include/asm/kvm.h|8 
 arch/powerpc/include/asm/kvm_book3s.h |2 --
 arch/powerpc/kvm/book3s_pr.c  |   14 ++
 arch/powerpc/kvm/powerpc.c|1 -
 include/linux/kvm.h   |1 -
 5 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
index 71684b9..a635e22 100644
--- a/arch/powerpc/include/asm/kvm.h
+++ b/arch/powerpc/include/asm/kvm.h
@@ -149,12 +149,6 @@ struct kvm_regs {
 #define KVM_SREGS_E_UPDATE_DBSR(1  3)
 
 /*
- * Book3S special bits to indicate contents in the struct by maintaining
- * backwards compatibility with older structs. If adding a new field,
- * please make sure to add a flag for that new field */
-#define KVM_SREGS_S_HIOR   (1  0)
-
-/*
  * In KVM_SET_SREGS, reserved/pad fields must be left untouched from a
  * previous KVM_GET_REGS.
  *
@@ -179,8 +173,6 @@ struct kvm_sregs {
__u64 ibat[8]; 
__u64 dbat[8]; 
} ppc32;
-   __u64 flags; /* KVM_SREGS_S_ */
-   __u64 hior;
} s;
struct {
union {
diff --git a/arch/powerpc/include/asm/kvm_book3s.h 
b/arch/powerpc/include/asm/kvm_book3s.h
index a384ffd..d4df013 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -90,8 +90,6 @@ struct kvmppc_vcpu_book3s {
 #endif
int context_id[SID_CONTEXTS];
 
-   bool hior_sregs;/* HIOR is set by SREGS, not PVR */
-
struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE];
struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG];
struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE];
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index d417511..84505a2 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -150,16 +150,14 @@ void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
 #ifdef CONFIG_PPC_BOOK3S_64
if ((pvr = 0x33)  (pvr  0x7033)) {
kvmppc_mmu_book3s_64_init(vcpu);
-   if (!to_book3s(vcpu)-hior_sregs)
-   to_book3s(vcpu)-hior = 0xfff0;
+   to_book3s(vcpu)-hior = 0xfff0;
to_book3s(vcpu)-msr_mask = 0xULL;
vcpu-arch.cpu_type = KVM_CPU_3S_64;
} else
 #endif
{
kvmppc_mmu_book3s_32_init(vcpu);
-   if (!to_book3s(vcpu)-hior_sregs)
-   to_book3s(vcpu)-hior = 0;
+   to_book3s(vcpu)-hior = 0;
to_book3s(vcpu)-msr_mask = 0xULL;
vcpu-arch.cpu_type = KVM_CPU_3S_32;
}
@@ -796,9 +794,6 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
}
}
 
-   if (sregs-u.s.flags  KVM_SREGS_S_HIOR)
-   sregs-u.s.hior = to_book3s(vcpu)-hior;
-
return 0;
 }
 
@@ -835,11 +830,6 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
/* Flush the MMU after messing with the segments */
kvmppc_mmu_pte_flush(vcpu, 0, 0);
 
-   if (sregs-u.s.flags  KVM_SREGS_S_HIOR) {
-   to_book3s(vcpu)-hior_sregs = true;
-   to_book3s(vcpu)-hior = sregs-u.s.hior;
-   }
-
return 0;
 }
 
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 55b4233..e75c5ac 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -209,7 +209,6 @@ int kvm_dev_ioctl_check_extension(long ext)
case KVM_CAP_PPC_BOOKE_SREGS:
 #else
case KVM_CAP_PPC_SEGSTATE:
-   case KVM_CAP_PPC_HIOR:
case KVM_CAP_PPC_PAPR:
 #endif
case KVM_CAP_PPC_UNSET_IRQ:
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 76ef719..a6b1295 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -555,7 +555,6 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_PPC_SMT 64
 #define KVM_CAP_PPC_RMA65
 #define KVM_CAP_MAX_VCPUS 66   /* returns max vcpus per vm */
-#define KVM_CAP_PPC_HIOR 67
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_SW_TLB 69
 #define KVM_CAP_S390_GMAP 71
-- 
1.6.0.2

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/14] KVM: PPC: e500: Don't hardcode PIR=0

2011-10-31 Thread Alexander Graf
From: Scott Wood scottw...@freescale.com

The hardcoded behavior prevents proper SMP support.

QEMU shall specify the vcpu's PIR as the vcpu id.

Signed-off-by: Scott Wood scottw...@freescale.com
Signed-off-by: Alexander Graf ag...@suse.de
---
 arch/powerpc/kvm/booke.c |4 ++--
 arch/powerpc/kvm/e500.c  |3 ---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index bb6c988..b642200 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -761,7 +761,7 @@ static void get_sregs_arch206(struct kvm_vcpu *vcpu,
 {
sregs-u.e.features |= KVM_SREGS_E_ARCH206;
 
-   sregs-u.e.pir = 0;
+   sregs-u.e.pir = vcpu-vcpu_id;
sregs-u.e.mcsrr0 = vcpu-arch.mcsrr0;
sregs-u.e.mcsrr1 = vcpu-arch.mcsrr1;
sregs-u.e.decar = vcpu-arch.decar;
@@ -774,7 +774,7 @@ static int set_sregs_arch206(struct kvm_vcpu *vcpu,
if (!(sregs-u.e.features  KVM_SREGS_E_ARCH206))
return 0;
 
-   if (sregs-u.e.pir != 0)
+   if (sregs-u.e.pir != vcpu-vcpu_id)
return -EINVAL;
 
vcpu-arch.mcsrr0 = sregs-u.e.mcsrr0;
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c
index 14d6e6e..cbbcc9e 100644
--- a/arch/powerpc/kvm/e500.c
+++ b/arch/powerpc/kvm/e500.c
@@ -70,9 +70,6 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
vcpu-arch.pvr = mfspr(SPRN_PVR);
vcpu_e500-svr = mfspr(SPRN_SVR);
 
-   /* Since booke kvm only support one core, update all vcpus' PIR to 0 */
-   vcpu-vcpu_id = 0;
-
vcpu-arch.cpu_type = KVM_CPU_E500V2;
 
return 0;
-- 
1.6.0.2

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/14] KVM: PPC: e500: don't translate gfn to pfn with preemption disabled

2011-10-31 Thread Alexander Graf
From: Scott Wood scottw...@freescale.com

Delay allocation of the shadow pid until we're ready to disable
preemption and write the entry.

Signed-off-by: Scott Wood scottw...@freescale.com
Signed-off-by: Alexander Graf ag...@suse.de
---
 arch/powerpc/kvm/e500_tlb.c |   36 +++-
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index 13c432e..22624a7 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -507,21 +507,16 @@ static inline void kvmppc_e500_deliver_tlb_miss(struct 
kvm_vcpu *vcpu,
vcpu_e500-mas7 = 0;
 }
 
+/* TID must be supplied by the caller */
 static inline void kvmppc_e500_setup_stlbe(struct kvmppc_vcpu_e500 *vcpu_e500,
   struct tlbe *gtlbe, int tsize,
   struct tlbe_priv *priv,
   u64 gvaddr, struct tlbe *stlbe)
 {
pfn_t pfn = priv-pfn;
-   unsigned int stid;
-
-   stid = kvmppc_e500_get_sid(vcpu_e500, get_tlb_ts(gtlbe),
-  get_tlb_tid(gtlbe),
-  get_cur_pr(vcpu_e500-vcpu), 0);
 
/* Force TS=1 IPROT=0 for all guest mappings. */
-   stlbe-mas1 = MAS1_TSIZE(tsize)
-   | MAS1_TID(stid) | MAS1_TS | MAS1_VALID;
+   stlbe-mas1 = MAS1_TSIZE(tsize) | MAS1_TS | MAS1_VALID;
stlbe-mas2 = (gvaddr  MAS2_EPN)
| e500_shadow_mas2_attrib(gtlbe-mas2,
vcpu_e500-vcpu.arch.shared-msr  MSR_PR);
@@ -816,6 +811,24 @@ int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb)
return EMULATE_DONE;
 }
 
+/* sesel is index into the set, not the whole array */
+static void write_stlbe(struct kvmppc_vcpu_e500 *vcpu_e500,
+   struct tlbe *gtlbe,
+   struct tlbe *stlbe,
+   int stlbsel, int sesel)
+{
+   int stid;
+
+   preempt_disable();
+   stid = kvmppc_e500_get_sid(vcpu_e500, get_tlb_ts(gtlbe),
+  get_tlb_tid(gtlbe),
+  get_cur_pr(vcpu_e500-vcpu), 0);
+
+   stlbe-mas1 |= MAS1_TID(stid);
+   write_host_tlbe(vcpu_e500, stlbsel, sesel, stlbe);
+   preempt_enable();
+}
+
 int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
 {
struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
@@ -845,7 +858,6 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
u64 eaddr;
u64 raddr;
 
-   preempt_disable();
switch (tlbsel) {
case 0:
/* TLB0 */
@@ -874,8 +886,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
default:
BUG();
}
-   write_host_tlbe(vcpu_e500, stlbsel, sesel, stlbe);
-   preempt_enable();
+
+   write_stlbe(vcpu_e500, gtlbe, stlbe, stlbsel, sesel);
}
 
kvmppc_set_exit_type(vcpu, EMULATED_TLBWE_EXITS);
@@ -937,7 +949,6 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 eaddr, gpa_t 
gpaddr,
 
gtlbe = vcpu_e500-gtlb_arch[tlbsel][esel];
 
-   preempt_disable();
switch (tlbsel) {
case 0:
stlbsel = 0;
@@ -962,8 +973,7 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 eaddr, gpa_t 
gpaddr,
break;
}
 
-   write_host_tlbe(vcpu_e500, stlbsel, sesel, stlbe);
-   preempt_enable();
+   write_stlbe(vcpu_e500, gtlbe, stlbe, stlbsel, sesel);
 }
 
 int kvmppc_e500_tlb_search(struct kvm_vcpu *vcpu,
-- 
1.6.0.2

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] KVM: booke: Do Not start decrementer when SPRN_DEC set 0

2011-10-31 Thread Bharat Bhushan
As per specification the decrementer interrupt not happen when DEC is written 
with 0. Also when DEC is zero, no decrementer running. So we should not start 
hrtimer for decrementer when DEC = 0.

Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com
---
 arch/powerpc/kvm/emulate.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 141dce3..0452357 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -77,7 +77,8 @@ static int kvmppc_dec_enabled(struct kvm_vcpu *vcpu)
 #else
 static int kvmppc_dec_enabled(struct kvm_vcpu *vcpu)
 {
-   return vcpu-arch.tcr  TCR_DIE;
+   /* On BOOKE, DEC = 0 is as good as decrementer not enabled */
+   return (vcpu-arch.tcr  TCR_DIE)  vcpu-arch.dec;
 }
 #endif
 
-- 
1.7.0.4


--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: kernel BUG at include/linux/kvm_host.h:603!

2011-10-31 Thread Jörg Sommer
Hi Alexander,

Alexander Graf hat am Mon 10. Oct, 10:09 (+0200) geschrieben:
 On 07.10.2011, at 23:10, Jörg Sommer wrote:
 
  Hi,
  
  I've got this backtrace:
  
  [130902.709711] [ cut here ]
  [130902.709747] kernel BUG at include/linux/kvm_host.h:603!
 
 Ouch. This means that preemption is broken in KVM for PPC. To quickly
 get things working on your side, please recompile your kernel with
 CONFIG_PREEMPT_NONE. I'll take a look at fixing it for real ASAP.

Did you look for it? I still get this message for 3.1.0-02829.

Bye, Jörg.
-- 
Es gibt nichts schöneres als dem Schweigen eines Dummkopfes zuzuhören.
(Helmut Quatlinger)


signature.asc
Description: Digital signature http://en.wikipedia.org/wiki/OpenPGP


Re: [PATCH 06/14] KVM: PPC: e500: Don't hardcode PIR=0

2011-10-31 Thread Avi Kivity
On 10/31/2011 09:53 AM, Alexander Graf wrote:
 From: Scott Wood scottw...@freescale.com

 The hardcoded behavior prevents proper SMP support.

 QEMU shall specify the vcpu's PIR as the vcpu id.



Could also be kvm tool - we generally use the code name 'userspace' to
refer to qemu (but don't rewrite the patch on this account).

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 08/14] Revert KVM: PPC: Add support for explicit HIOR setting

2011-10-31 Thread Avi Kivity
On 10/31/2011 09:53 AM, Alexander Graf wrote:
 This reverts commit 11d7596e18a712dc3bc29d45662ec111fd65946b. It exceeded
 the padding on the SREGS struct, rendering the ABI backwards-incompatible.

Can't find the commit hash.  Please use hashes from the Linus tree when
possible.

This needs to be backported?  To which trees?

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/14] KVM: PPC: Add generic single register ioctls

2011-10-31 Thread Avi Kivity
On 10/31/2011 09:53 AM, Alexander Graf wrote:
 Right now we transfer a static struct every time we want to get or set
 registers. Unfortunately, over time we realize that there are more of
 these than we thought of before and the extensibility and flexibility of
 transferring a full struct every time is limited.

 So this is a new approach to the problem. With these new ioctls, we can
 get and set a single register that is identified by an ID. This allows for
 very precise and limited transmittal of data. When we later realize that
 it's a better idea to shove over multiple registers at once, we can reuse
 most of the infrastructure and simply implement a GET_MANY_REGS / 
 SET_MANY_REGS
 interface.

 The only downpoint I see to this one is that it needs to pad to 1024 bits
 (hardware is already on 512 bit registers, so I wanted to leave some room)
 which is slightly too much for transmitting only 64 bits. But if that's all
 the tradeoff we have to do for getting an extensible interface, I'd say go
 for it nevertheless.

Do we want this for x86 too?  How often do we want just one register?

  
 +4.64 KVM_SET_ONE_REG
 +
 +Capability: KVM_CAP_ONE_REG
 +Architectures: all
 +Type: vcpu ioctl
 +Parameters: struct kvm_one_reg (in)
 +Returns: 0 on success, negative value on failure
 +
 +struct kvm_one_reg {
 +   __u64 id;

would be better to have a register set (in x86 terms,
gpr/x86/sse/cr/xcr/msr/special) and an ID within the set.  __u64 is
excessive, I hope.

 +   union {
 +   __u8 reg8;
 +   __u16 reg16;
 +   __u32 reg32;
 +   __u64 reg64;
 +   __u8 reg128[16];
 +   __u8 reg256[32];
 +   __u8 reg512[64];
 +   __u8 reg1024[128];
 +   } u;
 +};
 +
 +Using this ioctl, a single vcpu register can be set to a specific value
 +defined by user space with the passed in struct kvm_one_reg. There can
 +be architecture agnostic and architecture specific registers. Each have
 +their own range of operation and their own constants and width. To keep
 +track of the implemented registers, find a list below:
 +
 +  Arch  |   Register| Width (bits)
 +|   |
 +


One possible issue is that certain register have mutually exclusive
values, so you may need to issue multiple calls to get the right
sequence.  You probably don't have that on ppc.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/14] KVM: PPC: E500: Support hugetlbfs

2011-10-31 Thread Avi Kivity
On 10/31/2011 09:53 AM, Alexander Graf wrote:
 With hugetlbfs support emerging on e500, we should also support KVM
 backing its guest memory by it.

 This patch adds support for hugetlbfs into the e500 shadow mmu code.


 @@ -673,12 +674,31 @@ static inline void kvmppc_e500_shadow_map(struct 
 kvmppc_vcpu_e500 *vcpu_e500,
   pfn = ~(tsize_pages - 1);
   break;
   }
 + } else if (vma  hva = vma-vm_start 
 +   (vma-vm_flags  VM_HUGETLB)) {
 + unsigned long psize = vma_kernel_pagesize(vma);


Leading spaces spotted.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/14] KVM: PPC: Add generic single register ioctls

2011-10-31 Thread Jan Kiszka
On 2011-10-31 14:36, Avi Kivity wrote:
 On 10/31/2011 09:53 AM, Alexander Graf wrote:
 Right now we transfer a static struct every time we want to get or set
 registers. Unfortunately, over time we realize that there are more of
 these than we thought of before and the extensibility and flexibility of
 transferring a full struct every time is limited.

 So this is a new approach to the problem. With these new ioctls, we can
 get and set a single register that is identified by an ID. This allows for
 very precise and limited transmittal of data. When we later realize that
 it's a better idea to shove over multiple registers at once, we can reuse
 most of the infrastructure and simply implement a GET_MANY_REGS / 
 SET_MANY_REGS
 interface.

 The only downpoint I see to this one is that it needs to pad to 1024 bits
 (hardware is already on 512 bit registers, so I wanted to leave some room)
 which is slightly too much for transmitting only 64 bits. But if that's all
 the tradeoff we have to do for getting an extensible interface, I'd say go
 for it nevertheless.
 
 Do we want this for x86 too?  How often do we want just one register?

On x86, a single register is probably only interesting for debugging
purposes. Things that matter (performance wise) are in kvm.run, anything
else does not worry that much about speed. At least for now. I'm still
waiting for Kemari to propose some get/set optimizations, but there is
obviously not that much to gain or still bigger fish to fry.

Also, x86 is less regular than PPC. And where it is fairly regular, we
already have a GET/SET_MANY interface: MSRs.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html