ppc patch queue 2014-05-30
Subsystems (4)
Hi Paolo / Marcelo,
This is my current patch queue for ppc. Please pull.
Alex
The following changes since commit 1f854112553a1d65363ab27d4ee3dfb4b27075fb:
KVM: vmx: DR7 masking on task switch emulation is wrong (2014-05-22 17:47:18 +0200)
are available in the git repository at:
git://github.com/agraf/linux-2.6.git tags/signed-kvm-ppc-next
for you to fetch changes up to d8d164a9850d486cc48081c18831680254688d0f:
KVM: PPC: Book3S PR: Rework SLB switching code (2014-05-30 14:26:30 +0200)
----------------------------------------------------------------
Patch queue for ppc - 2014-05-30
In this round we have a few nice gems. PR KVM gains initial POWER8 support as well as LE host awareness, ihe e500 targets can now properly run u-boot, LE guests now work with PR KVM including KVM hypercalls and HV KVM guests can now use huge pages.
On top of this there are some bug fixes.
----------------------------------------------------------------
Alexander Graf (27):
KVM: PPC: E500: Ignore L1CSR1_ICFI,ICLFR
KVM: PPC: E500: Add dcbtls emulation
KVM: PPC: Book3S: PR: Fix C/R bit setting
KVM: PPC: Book3S_32: PR: Access HTAB in big endian
KVM: PPC: Book3S_64 PR: Access HTAB in big endian
KVM: PPC: Book3S_64 PR: Access shadow slb in big endian
KVM: PPC: Book3S PR: Default to big endian guest
KVM: PPC: Book3S PR: PAPR: Access HTAB in big endian
KVM: PPC: Book3S PR: PAPR: Access RTAS in big endian
KVM: PPC: PR: Fill pvinfo hcall instructions in big endian
KVM: PPC: Make shared struct aka magic page guest endian
KVM: PPC: Book3S PR: Do dcbz32 patching with big endian instructions
KVM: PPC: Book3S: Move little endian conflict to HV KVM
KVM: PPC: Book3S PR: Ignore PMU SPRs
KVM: PPC: Book3S PR: Emulate TIR register
KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
KVM: PPC: Book3S PR: Expose TAR facility to guest
KVM: PPC: Book3S PR: Expose EBB registers
KVM: PPC: Book3S PR: Expose TM registers
KVM: PPC: Disable NX for old magic page using guests
PPC: KVM: Make NX bit available with magic page
PPC: ePAPR: Fix hypercall on LE guest
KVM: PPC: Graciously fail broken LE hypercalls
KVM: PPC: MPIC: Reset IRQ source private members
KVM: PPC: Add CAP to indicate hcall fixes
KVM: PPC: Book3S PR: Use SLB entry 0
KVM: PPC: Book3S PR: Rework SLB switching code
Alexey Kardashevskiy (1):
KVM: PPC: Book3S HV: Fix dirty map for hugepages
Aneesh Kumar K.V (6):
KVM: PPC: BOOK3S: PR: Enable Little Endian PR guest
KVM: PPC: BOOK3S: PR: Fix WARN_ON with debug options on
KVM: PPC: BOOK3S: HV: Prefer CMA region for hash page table allocation
KVM: PPC: BOOK3S: HV: Add mixed page-size support for guest
KVM: PPC: BOOK3S: Always use the saved DAR value
KVM: PPC: BOOK3S: Remove open coded make_dsisr in alignment handler
Paul Mackerras (7):
KVM: PPC: Book3S: Add ONE_REG register names that were missed
KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
KVM: PPC: Book3S HV: Fix check for running inside guest in global_invalidates()
KVM: PPC: Book3S HV: Put huge-page HPTEs in rmap chain for base address
KVM: PPC: Book3S HV: Make sure we don't miss dirty pages
KVM: PPC: Book3S HV: Work around POWER8 performance monitor bugs
KVM: PPC: Book3S HV: Fix machine check delivery to guest
Documentation/virtual/kvm/api.txt | 6 + Documentation/virtual/kvm/ppc-pv.txt | 14 ++ arch/powerpc/include/asm/disassemble.h | 34 +++++ arch/powerpc/include/asm/kvm_asm.h | 18 ++- arch/powerpc/include/asm/kvm_book3s.h | 3 +- arch/powerpc/include/asm/kvm_book3s_64.h | 146 +++++++++++++++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_booke.h | 5 - arch/powerpc/include/asm/kvm_host.h | 9 +- arch/powerpc/include/asm/kvm_ppc.h | 80 +++++++++- arch/powerpc/include/asm/reg.h | 12 +- arch/powerpc/include/asm/reg_booke.h | 1 + arch/powerpc/include/uapi/asm/kvm.h | 2 +- arch/powerpc/include/uapi/asm/kvm_para.h | 6 + arch/powerpc/kernel/align.c | 34 +---- arch/powerpc/kernel/asm-offsets.c | 11 +- arch/powerpc/kernel/epapr_paravirt.c | 5 +- arch/powerpc/kernel/kvm.c | 2 +- arch/powerpc/kernel/paca.c | 3 + arch/powerpc/kvm/Kconfig | 2 +- arch/powerpc/kvm/book3s.c | 106 ++++++++----- arch/powerpc/kvm/book3s_32_mmu.c | 41 ++--- arch/powerpc/kvm/book3s_32_mmu_host.c | 4 +- arch/powerpc/kvm/book3s_64_mmu.c | 39 +++-- arch/powerpc/kvm/book3s_64_mmu_host.c | 15 +- arch/powerpc/kvm/book3s_64_mmu_hv.c | 116 ++++++++++----- arch/powerpc/kvm/book3s_64_slb.S | 87 +++++------ arch/powerpc/kvm/book3s_emulate.c | 156 +++++++++++++------- arch/powerpc/kvm/book3s_exports.c | 1 + arch/powerpc/kvm/book3s_hv.c | 48 +++--- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 3 +- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 60 +++++++- arch/powerpc/kvm/book3s_interrupts.S | 23 ++- arch/powerpc/kvm/book3s_paired_singles.c | 16 +- arch/powerpc/kvm/book3s_pr.c | 238 ++++++++++++++++++++++++------ arch/powerpc/kvm/book3s_pr_papr.c | 16 +- arch/powerpc/kvm/book3s_rtas.c | 29 ++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++ arch/powerpc/kvm/e500_emulate.c | 15 ++ arch/powerpc/kvm/emulate.c | 24 +-- arch/powerpc/kvm/mpic.c | 5 +- arch/powerpc/kvm/powerpc.c | 64 ++++++-- arch/powerpc/kvm/trace_pr.h | 2 +- arch/powerpc/mm/slb.c | 2 +- include/uapi/linux/kvm.h | 1 + 45 files changed, 1116 insertions(+), 415 deletions(-)
[PULL 01/41] KVM: PPC: E500: Ignore L1CSR1_ICFI,ICLFR
The L1 instruction cache control register contains bits that indicate that we're still handling a request. Mask those out when we set the SPR so that a read doesn't assume we're still doing something.
--- arch/powerpc/kvm/e500_emulate.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kvm/e500_emulate.c +1 -0
@@ -222,6 +222,7 @@ int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn, ulong spr_vabreak ;case SPRN_L1CSR1 : vcpu_e500->l1csr1 = spr_val; + vcpu_e500->l1csr1 &= ~(L1CSR1_ICFI |L1CSR1_ICLFR );break ;case SPRN_HID0 : vcpu_e500->hid0 = spr_val;
Signature · 1 line
1.8.1.4
[PULL 02/41] KVM: PPC: E500: Add dcbtls emulation
In reply to Alexander GrafThe dcbtls instruction is able to lock data inside the L1 cache.
We don't want to give the guest actual access to hardware cache locks, as that could influence other VMs on the same system. But we can tell the guest that its locking attempt failed.
By implementing the instruction we at least don't give the guest a program exception which it definitely does not expect.
--- arch/powerpc/include/asm/reg_booke.h | 1 + arch/powerpc/kvm/e500_emulate.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+)
arch/powerpc/include/asm/reg_booke.h +1 -0
@@ -583,6 +583,7 @@/* Bit definitions for L1CSR0. */ #define L1CSR0_CPE 0x00010000/* Data Cache Parity Enable */ +#define L1CSR0_CUL 0x00000400/* Data Cache Unable to Lock */ #define L1CSR0_CLFC 0x00000100/* Cache Lock Bits Flash Clear */ #define L1CSR0_DCFI 0x00000002/* Data Cache Flash Invalidate */ #define L1CSR0_CFI 0x00000002/* Cache Flash Invalidate */
arch/powerpc/kvm/e500_emulate.c +14 -0
@@ -19,6 +19,7 @@#include "booke.h" #include "e500.h" +#define XOP_DCBTLS 166#define XOP_MSGSND 206#define XOP_MSGCLR 238#define XOP_TLBIVAX 786
@@ -103,6 +104,15 @@ static int kvmppc_e500_emul_ehpriv(struct kvm_run *run, struct kvm_vcpu *vcpu,return emulated; } +static int kvmppc_e500_emul_dcbtls (struct kvm_vcpu *vcpu) +{ +struct kvmppc_vcpu_e500 *vcpu_e500 =to_e500 (vcpu); + +/* Always fail to lock the cache */ + vcpu_e500->l1csr0 |=L1CSR0_CUL ; +return EMULATE_DONE ; +} +int kvmppc_core_emulate_op_e500 (struct kvm_run *run,struct kvm_vcpu *vcpu,unsigned int inst,int *advance) {
@@ -116,6 +126,10 @@ int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,case 31 :switch (get_xop (inst)) { +case XOP_DCBTLS : + emulated =kvmppc_e500_emul_dcbtls (vcpu); +break ; +#ifdef CONFIG_KVM_E500MC case XOP_MSGSND : emulated =kvmppc_e500_emul_msgsnd (vcpu, rb);
Signature · 1 line
1.8.1.4
[PULL 03/41] KVM: PPC: BOOK3S: PR: Enable Little Endian PR guest
In reply to Alexander GrafFrom: "Aneesh Kumar K.V" <[email protected]>
This patch make sure we inherit the LE bit correctly in different case so that we can run Little Endian distro in PR mode
--- arch/powerpc/include/asm/kvm_host.h | 2 +- arch/powerpc/kernel/asm-offsets.c | 2 +- arch/powerpc/kvm/book3s_64_mmu.c | 2 +- arch/powerpc/kvm/book3s_pr.c | 23 ++++++++++++++++++++++- 4 files changed, 25 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/kvm_host.h +1 -1
@@ -562,6 +562,7 @@ struct kvm_vcpu_arch {#ifdef CONFIG_PPC_BOOK3S ulong fault_dar;u32 fault_dsisr; +unsigned long intr_msr;#endif #ifdef CONFIG_BOOKE
@@ -654,7 +655,6 @@ struct kvm_vcpu_arch {spinlock_t tbacct_lock;u64 busy_stolen;u64 busy_preempt; -unsigned long intr_msr;#endif };
arch/powerpc/kernel/asm-offsets.c +1 -1
@@ -493,7 +493,6 @@ int main(void) DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); DEFINE(VCPU_VPA, offsetof(struct kvm_vcpu, arch.vpa.pinned_addr)); DEFINE(VCPU_VPA_DIRTY, offsetof(struct kvm_vcpu, arch.vpa.dirty)); - DEFINE(VCPU_INTR_MSR, offsetof(struct kvm_vcpu, arch.intr_msr));#endif #ifdef CONFIG_PPC_BOOK3S DEFINE (VCPU_VCPUID , offsetof(struct kvm_vcpu , vcpu_id));
@@ -528,6 +527,7 @@ int main(void) DEFINE(VCPU_SLB_NR, offsetof(struct kvm_vcpu, arch.slb_nr)); DEFINE(VCPU_FAULT_DSISR, offsetof(struct kvm_vcpu, arch.fault_dsisr)); DEFINE(VCPU_FAULT_DAR, offsetof(struct kvm_vcpu, arch.fault_dar)); + DEFINE(VCPU_INTR_MSR, offsetof(struct kvm_vcpu, arch.intr_msr)); DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst)); DEFINE(VCPU_TRAP, offsetof(struct kvm_vcpu, arch.trap)); DEFINE(VCPU_CFAR, offsetof(struct kvm_vcpu, arch.cfar));
arch/powerpc/kvm/book3s_64_mmu.c +1 -1
@@ -38,7 +38,7 @@static void kvmppc_mmu_book3s_64_reset_msr (struct kvm_vcpu *vcpu) { -kvmppc_set_msr (vcpu,MSR_SF ); +kvmppc_set_msr (vcpu, vcpu->arch.intr_msr); } static struct kvmppc_slb *kvmppc_mmu_book3s_64_find_slbe(
arch/powerpc/kvm/book3s_pr.c +22 -1
@@ -249,7 +249,7 @@ static void kvmppc_recalc_shadow_msr(struct kvm_vcpu *vcpu)ulong smsr = vcpu->arch.shared->msr;/* Guest MSR values */ - smsr &=MSR_FE0 |MSR_FE1 |MSR_SF |MSR_SE |MSR_BE ; + smsr &=MSR_FE0 |MSR_FE1 |MSR_SF |MSR_SE |MSR_BE |MSR_LE ;/* Process MSR values */ smsr |=MSR_ME |MSR_RI |MSR_IR |MSR_DR |MSR_PR |MSR_EE ;/* External providers the guest reserved */
@@ -1110,6 +1110,15 @@ static int kvmppc_get_one_reg_pr(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_HIOR : *val =get_reg_val (id,to_book3s (vcpu)->hior);break ; +case KVM_REG_PPC_LPCR : +/* +* We are only interested in the LPCR_ILE bit +*/ +if (vcpu->arch.intr_msr &MSR_LE ) + *val =get_reg_val (id,LPCR_ILE ); +else + *val =get_reg_val (id,0 ); +break ;default : r = -EINVAL ;break ;
@@ -1118,6 +1127,14 @@ static int kvmppc_get_one_reg_pr(struct kvm_vcpu *vcpu, u64 id,return r; } +static void kvmppc_set_lpcr_pr (struct kvm_vcpu *vcpu,u64 new_lpcr) +{ +if (new_lpcr &LPCR_ILE ) + vcpu->arch.intr_msr |=MSR_LE ; +else + vcpu->arch.intr_msr &= ~MSR_LE ; +} +static int kvmppc_set_one_reg_pr (struct kvm_vcpu *vcpu,u64 id,union kvmppc_one_reg *val) {
@@ -1128,6 +1145,9 @@ static int kvmppc_set_one_reg_pr(struct kvm_vcpu *vcpu, u64 id,to_book3s (vcpu)->hior =set_reg_val (id, *val);to_book3s (vcpu)->hior_explicit = true;break ; +case KVM_REG_PPC_LPCR : +kvmppc_set_lpcr_pr (vcpu,set_reg_val (id, *val)); +break ;default : r = -EINVAL ;break ;
@@ -1180,6 +1200,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_pr(struct kvm *kvm, vcpu->arch.pvr =0x3C0301 ;if (mmu_has_feature (MMU_FTR_1T_SEGMENT )) vcpu->arch.pvr =mfspr (SPRN_PVR ); + vcpu->arch.intr_msr =MSR_SF ;#else /* default to book3s_32 (750) */ vcpu->arch.pvr =0x84202 ;
Signature · 1 line
1.8.1.4
[PULL 04/41] KVM: PPC: BOOK3S: PR: Fix WARN_ON with debug options on
In reply to Alexander GrafFrom: "Aneesh Kumar K.V" <[email protected]>
With debug option "sleep inside atomic section checking" enabled we get the below WARN_ON during a PR KVM boot. This is because upstream now have PREEMPT_COUNT enabled even if we have preempt disabled. Fix the warning by adding preempt_disable/enable around floating point and altivec enable.
WARNING: at arch/powerpc/kernel/process.c:156 Modules linked in: kvm_pr kvm CPU: 1 PID: 3990 Comm: qemu-system-ppc Tainted: G W 3.15.0-rc1+ #4 task: c0000000eb85b3a0 ti: c0000000ec59c000 task.ti: c0000000ec59c000 NIP: c000000000015c84 LR: d000000003334644 CTR: c000000000015c00 REGS: c0000000ec59f140 TRAP: 0700 Tainted: G W (3.15.0-rc1+) MSR: 8000000000029032 <SF,EE,ME,IR,DR,RI> CR: 42000024 XER: 20000000
CFAR: c000000000015c24 SOFTE: 1
GPR00: d000000003334644 c0000000ec59f3c0 c000000000e2fa40 c0000000e2f80000
GPR04: 0000000000000800 0000000000002000 0000000000000001 8000000000000000
GPR08: 0000000000000001 0000000000000001 0000000000002000 c000000000015c00
GPR12: d00000000333da18 c00000000fb80900 0000000000000000 0000000000000000
GPR16: 0000000000000000 0000000000000000 0000000000000000 00003fffce4e0fa1
GPR20: 0000000000000010 0000000000000001 0000000000000002 00000000100b9a38
GPR24: 0000000000000002 0000000000000000 0000000000000000 0000000000000013
GPR28: 0000000000000000 c0000000eb85b3a0 0000000000002000 c0000000e2f80000 NIP [c000000000015c84] .enable_kernel_fp+0x84/0x90
LR [d000000003334644] .kvmppc_handle_ext+0x134/0x190 [kvm_pr]
Call Trace:
[c0000000ec59f3c0] [0000000000000010] 0x10 (unreliable) [c0000000ec59f430] [d000000003334644] .kvmppc_handle_ext+0x134/0x190 [kvm_pr] [c0000000ec59f4c0] [d00000000324b380] .kvmppc_set_msr+0x30/0x50 [kvm] [c0000000ec59f530] [d000000003337cac] .kvmppc_core_emulate_op_pr+0x16c/0x5e0 [kvm_pr] [c0000000ec59f5f0] [d00000000324a944] .kvmppc_emulate_instruction+0x284/0xa80 [kvm] [c0000000ec59f6c0] [d000000003336888] .kvmppc_handle_exit_pr+0x488/0xb70 [kvm_pr] [c0000000ec59f790] [d000000003338d34] kvm_start_lightweight+0xcc/0xdc [kvm_pr] [c0000000ec59f960] [d000000003336288] .kvmppc_vcpu_run_pr+0xc8/0x190 [kvm_pr] [c0000000ec59f9f0] [d00000000324c880] .kvmppc_vcpu_run+0x30/0x50 [kvm] [c0000000ec59fa60] [d000000003249e74] .kvm_arch_vcpu_ioctl_run+0x54/0x1b0 [kvm] [c0000000ec59faf0] [d000000003244948] .kvm_vcpu_ioctl+0x478/0x760 [kvm] [c0000000ec59fcb0] [c000000000224e34] .do_vfs_ioctl+0x4d4/0x790 [c0000000ec59fd90] [c000000000225148] .SyS_ioctl+0x58/0xb0 [c0000000ec59fe30] [c00000000000a1e4] syscall_exit+0x0/0x98
--- arch/powerpc/kvm/book3s_pr.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/powerpc/kvm/book3s_pr.c +8 -0
@@ -683,16 +683,20 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,#endif if (msr &MSR_FP ) { +preempt_disable ();enable_kernel_fp ();load_fp_state (&vcpu->arch.fp); t->fp_save_area = &vcpu->arch.fp; +preempt_enable (); }if (msr &MSR_VEC ) {#ifdef CONFIG_ALTIVEC +preempt_disable ();enable_kernel_altivec ();load_vr_state (&vcpu->arch.vr); t->vr_save_area = &vcpu->arch.vr; +preempt_enable ();#endif }
@@ -716,13 +720,17 @@ static void kvmppc_handle_lost_ext(struct kvm_vcpu *vcpu)return ;if (lost_ext &MSR_FP ) { +preempt_disable ();enable_kernel_fp ();load_fp_state (&vcpu->arch.fp); +preempt_enable (); }#ifdef CONFIG_ALTIVEC if (lost_ext &MSR_VEC ) { +preempt_disable ();enable_kernel_altivec ();load_vr_state (&vcpu->arch.vr); +preempt_enable (); }#endif current->thread.regs->msr |= lost_ext;
Signature · 1 line
1.8.1.4
[PULL 05/41] KVM: PPC: Book3S: PR: Fix C/R bit setting
In reply to Alexander GrafCommit 9308ab8e2d made C/R HTAB updates go byte-wise into the target HTAB. However, it didn't update the guest's copy of the HTAB, but instead the host local copy of it.
Write to the guest's HTAB instead.
--- arch/powerpc/kvm/book3s_32_mmu.c | 2 +- arch/powerpc/kvm/book3s_64_mmu.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/kvm/book3s_32_mmu.c +1 -1
@@ -270,7 +270,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,page */ if (found) {u32 pte_r = pteg[i+1 ]; -char __user *addr = (char __user *) &pteg[i+1 ]; +char __user *addr = (char __user *) (ptegp + (i+1 ) *sizeof (u32));/* * Use single-byte writes to update the HPTE, to
arch/powerpc/kvm/book3s_64_mmu.c +2 -2
@@ -342,14 +342,14 @@ do_second:* non-PAPR platforms such as mac99, and this is * what real hardware does. */ -char __user *addr = (char __user *) &pteg[i+1 ]; +char __user *addr = (char __user *) (ptegp + (i +1 ) *sizeof (u64)); r |=HPTE_R_R ;put_user (r >>8 , addr +6 ); }if (iswrite && gpte->may_write && !(r &HPTE_R_C )) {/* Set the dirty flag */ /* Use a single byte write */ -char __user *addr = (char __user *) &pteg[i+1 ]; +char __user *addr = (char __user *) (ptegp + (i +1 ) *sizeof (u64)); r |=HPTE_R_C ;put_user (r, addr +7 ); }
Signature · 1 line
1.8.1.4
[PULL 06/41] KVM: PPC: Book3S_32: PR: Access HTAB in big endian
In reply to Alexander GrafThe HTAB is always big endian. We access the guest's HTAB using copy_from/to_user, but don't yet take care of the fact that we might be running on an LE host.
Wrap all accesses to the guest HTAB with big endian accessors.
--- arch/powerpc/kvm/book3s_32_mmu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
arch/powerpc/kvm/book3s_32_mmu.c +10 -6
@@ -208,6 +208,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,u32 sre;hva_t ptegp;u32 pteg[16 ]; +u32 pte0, pte1;u32 ptem =0 ;int i;int found =0 ;
@@ -233,11 +234,13 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, }for (i=0 ; i<16 ; i+=2 ) { -if (ptem == pteg[i]) { + pte0 =be32_to_cpu (pteg[i]); + pte1 =be32_to_cpu (pteg[i +1 ]); +if (ptem == pte0) {u8 pp; - pte->raddr = (pteg[i+1 ] & ~(0xFFFULL )) | (eaddr &0xFFF ); - pp = pteg[i+1 ] &3 ; + pte->raddr = (pte1 & ~(0xFFFULL )) | (eaddr &0xFFF ); + pp = pte1 &3 ;if ((sr_kp (sre) && (vcpu->arch.shared->msr &MSR_PR )) || (sr_ks (sre) && !(vcpu->arch.shared->msr &MSR_PR )))
@@ -260,7 +263,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, }dprintk_pte ("MMU: Found PTE -> %x %x - %x\n" , - pteg[i], pteg[i+1 ], pp); + pte0, pte1, pp); found =1 ;break ; }
@@ -269,7 +272,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,/* Update PTE C and A bits, so the guest's swapper knows we used the page */ if (found) { -u32 pte_r = pteg[i+1 ]; +u32 pte_r = pte1;char __user *addr = (char __user *) (ptegp + (i+1 ) *sizeof (u32));/*
@@ -296,7 +299,8 @@ no_page_found: to_book3s(vcpu)->sdr1, ptegp);for (i=0 ; i<16 ; i+=2 ) {dprintk_pte (" %02d: 0x%x - 0x%x (0x%x)\n" , - i, pteg[i], pteg[i+1 ], ptem); + i,be32_to_cpu (pteg[i]), +be32_to_cpu (pteg[i+1 ]), ptem); } }
Signature · 1 line
1.8.1.4
[PULL 07/41] KVM: PPC: Book3S_64 PR: Access HTAB in big endian
In reply to Alexander GrafThe HTAB is always big endian. We access the guest's HTAB using copy_from/to_user, but don't yet take care of the fact that we might be running on an LE host.
Wrap all accesses to the guest HTAB with big endian accessors.
--- arch/powerpc/kvm/book3s_64_mmu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
arch/powerpc/kvm/book3s_64_mmu.c +7 -4
@@ -275,12 +275,15 @@ do_second: key =4 ;for (i=0 ; i<16 ; i+=2 ) { +u64 pte0 =be64_to_cpu (pteg[i]); +u64 pte1 =be64_to_cpu (pteg[i +1 ]); +/* Check all relevant fields of 1st dword */ -if ((pteg[i] & v_mask) = v_val) { +if ((pte0 & v_mask) = v_val) {/* If large page bit is set, check pgsize encoding */ if (slbe->large && (vcpu->arch.hflags &BOOK3S_HFLAG_MULTI_PGSIZE )) { - pgsize =decode_pagesize (slbe, pteg[i+1 ]); + pgsize =decode_pagesize (slbe, pte1);if (pgsize <0 )continue ; }
@@ -297,8 +300,8 @@ do_second: goto do_second; } - v = pteg[i]; - r = pteg[i+1 ]; + v =be64_to_cpu (pteg[i]); + r =be64_to_cpu (pteg[i+1 ]); pp = (r &HPTE_R_PP ) | key;if (r &HPTE_R_PP0 ) pp |=8 ;
Signature · 1 line
1.8.1.4
[PULL 08/41] KVM: PPC: Book3S_64 PR: Access shadow slb in big endian
In reply to Alexander GrafThe "shadow SLB" in the PACA is shared with the hypervisor, so it has to be big endian. We access the shadow SLB during world switch, so let's make sure we access it in big endian even when we're on a little endian host.
--- arch/powerpc/kvm/book3s_64_slb.S | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
arch/powerpc/kvm/book3s_64_slb.S +16 -17
@@ -17,29 +17,28 @@ * Authors: Alexander Graf <[email protected]> */ -#ifdef __LITTLE_ENDIAN__ -#error Need to fix SLB shadow accesses in little endian mode -#endif - #define SHADOW_SLB_ESID(num) (SLBSHADOW_SAVEAREA + (num * 0x10)) #define SHADOW_SLB_VSID(num) (SLBSHADOW_SAVEAREA + (num * 0x10) + 0x8) #define UNBOLT_SLB_ENTRY(num) \ - ld r9, SHADOW_SLB_ESID(num)(r12); \ - /* Invalid? Skip. */; \ - rldicl. r0, r9, 37, 63; \ - beq slb_entry_skip_ ## num; \ - xoris r9, r9, SLB_ESID_V@h; \ - std r9, SHADOW_SLB_ESID(num)(r12); \ + li r11, SHADOW_SLB_ESID(num); \ + LDX_BE r9, r12, r11; \ + /* Invalid? Skip. */; \ + rldicl. r0, r9, 37, 63; \ + beq slb_entry_skip_ ## num; \ + xoris r9, r9, SLB_ESID_V@h; \ + STDX_BE r9, r12, r11; \ slb_entry_skip_ ## num: #define REBOLT_SLB_ENTRY(num) \ - ld r10, SHADOW_SLB_ESID(num)(r11); \ - cmpdi r10, 0; \ - beq slb_exit_skip_ ## num; \ - oris r10, r10, SLB_ESID_V@h; \ - ld r9, SHADOW_SLB_VSID(num)(r11); \ - slbmte r9, r10; \ - std r10, SHADOW_SLB_ESID(num)(r11); \ + li r8, SHADOW_SLB_ESID(num); \ + li r7, SHADOW_SLB_VSID(num); \ + LDX_BE r10, r11, r8; \ + cmpdi r10, 0; \ + beq slb_exit_skip_ ## num; \ + oris r10, r10, SLB_ESID_V@h; \ + LDX_BE r9, r11, r7; \ + slbmte r9, r10; \ + STDX_BE r10, r11, r8; \ slb_exit_skip_ ## num: /******************************************************************************
Signature · 1 line
1.8.1.4
[PULL 09/41] KVM: PPC: Book3S PR: Default to big endian guest
In reply to Alexander GrafThe default MSR when user space does not define anything should be identical on little and big endian hosts, so remove MSR_LE from it.
--- arch/powerpc/kvm/book3s_pr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s_pr.c +1 -1
@@ -1216,7 +1216,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_pr(struct kvm *kvm,kvmppc_set_pvr_pr (vcpu, vcpu->arch.pvr); vcpu->arch.slb_nr =64 ; - vcpu->arch.shadow_msr =MSR_USER64 ; + vcpu->arch.shadow_msr =MSR_USER64 & ~MSR_LE ; err =kvmppc_mmu_init (vcpu);if (err <0 )
Signature · 1 line
1.8.1.4
[PULL 10/41] KVM: PPC: Book3S PR: PAPR: Access HTAB in big endian
In reply to Alexander GrafThe HTAB on PPC is always in big endian. When we access it via hypercalls on behalf of the guest and we're running on a little endian host, we need to make sure we swap the bits accordingly.
--- arch/powerpc/kvm/book3s_pr_papr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
arch/powerpc/kvm/book3s_pr_papr.c +11 -3
@@ -57,7 +57,7 @@ static int kvmppc_h_pr_enter(struct kvm_vcpu *vcpu)for (i =0 ; ; ++i) {if (i =8 ) goto done; -if ((*hpte &HPTE_V_VALID ) =0 ) +if ((be64_to_cpu (*hpte) &HPTE_V_VALID ) =0 )break ; hpte +=2 ; }
@@ -67,8 +67,8 @@ static int kvmppc_h_pr_enter(struct kvm_vcpu *vcpu) goto done; } - hpte[0 ] =kvmppc_get_gpr (vcpu,6 ); - hpte[1 ] =kvmppc_get_gpr (vcpu,7 ); + hpte[0 ] =cpu_to_be64 (kvmppc_get_gpr (vcpu,6 )); + hpte[1 ] =cpu_to_be64 (kvmppc_get_gpr (vcpu,7 )); pteg_addr += i *HPTE_SIZE ;copy_to_user ((void __user *)pteg_addr, hpte,HPTE_SIZE );kvmppc_set_gpr (vcpu,4 , pte_index | i);
@@ -93,6 +93,8 @@ static int kvmppc_h_pr_remove(struct kvm_vcpu *vcpu) pteg =get_pteg_addr (vcpu, pte_index);mutex_lock (&vcpu->kvm->arch.hpt_mutex);copy_from_user (pte, (void __user *)pteg,sizeof (pte)); + pte[0 ] =be64_to_cpu (pte[0 ]); + pte[1 ] =be64_to_cpu (pte[1 ]); ret =H_NOT_FOUND ; if ((pte[0] & HPTE_V_VALID) = 0 ||
@@ -169,6 +171,8 @@ static int kvmppc_h_pr_bulk_remove(struct kvm_vcpu *vcpu) pteg =get_pteg_addr (vcpu, tsh &H_BULK_REMOVE_PTEX );copy_from_user (pte, (void __user *)pteg,sizeof (pte)); + pte[0 ] =be64_to_cpu (pte[0 ]); + pte[1 ] =be64_to_cpu (pte[1 ]);/* tsl = AVPN */ flags = (tsh &H_BULK_REMOVE_FLAGS ) >>26 ;
@@ -207,6 +211,8 @@ static int kvmppc_h_pr_protect(struct kvm_vcpu *vcpu) pteg =get_pteg_addr (vcpu, pte_index);mutex_lock (&vcpu->kvm->arch.hpt_mutex);copy_from_user (pte, (void __user *)pteg,sizeof (pte)); + pte[0 ] =be64_to_cpu (pte[0 ]); + pte[1 ] =be64_to_cpu (pte[1 ]); ret =H_NOT_FOUND ; if ((pte[0] & HPTE_V_VALID) = 0 ||
@@ -225,6 +231,8 @@ static int kvmppc_h_pr_protect(struct kvm_vcpu *vcpu) rb =compute_tlbie_rb (v, r, pte_index); vcpu->arch.mmu.tlbie (vcpu, rb, rb &1 ? true : false); + pte[0 ] =cpu_to_be64 (pte[0 ]); + pte[1 ] =cpu_to_be64 (pte[1 ]);copy_to_user ((void __user *)pteg, pte,sizeof (pte)); ret =H_SUCCESS ;
Signature · 1 line
1.8.1.4
[PULL 11/41] KVM: PPC: Book3S PR: PAPR: Access RTAS in big endian
In reply to Alexander GrafWhen the guest does an RTAS hypercall it keeps all RTAS variables inside a big endian data structure.
To make sure we don't have to bother about endianness inside the actual RTAS handlers, let's just convert the whole structure to host endian before we call our RTAS handlers and back to big endian when we return to the guest.
--- arch/powerpc/kvm/book3s_rtas.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
arch/powerpc/kvm/book3s_rtas.c +29 -0
@@ -205,6 +205,32 @@ int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp)return rc; } +static void kvmppc_rtas_swap_endian_in (struct rtas_args *args) +{ +#ifdef __LITTLE_ENDIAN__ +int i; + + args->token =be32_to_cpu (args->token); + args->nargs =be32_to_cpu (args->nargs); + args->nret =be32_to_cpu (args->nret); +for (i =0 ; i < args->nargs; i++) + args->args[i] =be32_to_cpu (args->args[i]); +#endif +} + +static void kvmppc_rtas_swap_endian_out (struct rtas_args *args) +{ +#ifdef __LITTLE_ENDIAN__ +int i; + +for (i =0 ; i < args->nret; i++) + args->args[i] =cpu_to_be32 (args->args[i]); + args->token =cpu_to_be32 (args->token); + args->nargs =cpu_to_be32 (args->nargs); + args->nret =cpu_to_be32 (args->nret); +#endif +} +int kvmppc_rtas_hcall (struct kvm_vcpu *vcpu) {struct rtas_token_definition *d;
@@ -223,6 +249,8 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)if (rc) goto fail; +kvmppc_rtas_swap_endian_in (&args); +/* * args->rets is a pointer into args->args. Now that we've * copied args we need to fix it up to point into our copy,
@@ -247,6 +275,7 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)if (rc =0 ) { args.rets = orig_rets; +kvmppc_rtas_swap_endian_out (&args); rc =kvm_write_guest (vcpu->kvm, args_phys, &args,sizeof (args));if (rc) goto fail;
Signature · 1 line
1.8.1.4
[PULL 12/41] KVM: PPC: PR: Fill pvinfo hcall instructions in big endian
In reply to Alexander GrafWe expose a blob of hypercall instructions to user space that it gives to the guest via device tree again. That blob should contain a stream of instructions necessary to do a hypercall in big endian, as it just gets passed into the guest and old guests use them straight away.
--- arch/powerpc/kvm/powerpc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/powerpc/kvm/powerpc.c +8 -8
@@ -1015,10 +1015,10 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)u32 inst_nop =0x60000000 ;#ifdef CONFIG_KVM_BOOKE_HV u32 inst_sc1 =0x44000022 ; - pvinfo->hcall[0 ] = inst_sc1; - pvinfo->hcall[1 ] = inst_nop; - pvinfo->hcall[2 ] = inst_nop; - pvinfo->hcall[3 ] = inst_nop; + pvinfo->hcall[0 ] =cpu_to_be32 (inst_sc1); + pvinfo->hcall[1 ] =cpu_to_be32 (inst_nop); + pvinfo->hcall[2 ] =cpu_to_be32 (inst_nop); + pvinfo->hcall[3 ] =cpu_to_be32 (inst_nop);#else u32 inst_lis =0x3c000000 ;u32 inst_ori =0x60000000 ;
@@ -1034,10 +1034,10 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)* sc * nop */ - pvinfo->hcall[0 ] = inst_lis | ((KVM_SC_MAGIC_R0 >>16 ) & inst_imm_mask); - pvinfo->hcall[1 ] = inst_ori | (KVM_SC_MAGIC_R0 & inst_imm_mask); - pvinfo->hcall[2 ] = inst_sc; - pvinfo->hcall[3 ] = inst_nop; + pvinfo->hcall[0 ] =cpu_to_be32 (inst_lis | ((KVM_SC_MAGIC_R0 >>16 ) & inst_imm_mask)); + pvinfo->hcall[1 ] =cpu_to_be32 (inst_ori | (KVM_SC_MAGIC_R0 & inst_imm_mask)); + pvinfo->hcall[2 ] =cpu_to_be32 (inst_sc); + pvinfo->hcall[3 ] =cpu_to_be32 (inst_nop);#endif pvinfo->flags =KVM_PPC_PVINFO_FLAGS_EV_IDLE ;
Signature · 1 line
1.8.1.4
[PULL 13/41] KVM: PPC: Make shared struct aka magic page guest endian
In reply to Alexander GrafThe shared (magic) page is a data structure that contains often used supervisor privileged SPRs accessible via memory to the user to reduce the number of exits we have to take to read/write them.
When we actually share this structure with the guest we have to maintain it in guest endianness, because some of the patch tricks only work with native endian load/store operations.
Since we only share the structure with either host or guest in little endian on book3s_64 pr mode, we don't have to worry about booke or book3s hv.
For booke, the shared struct stays big endian. For book3s_64 hv we maintain the struct in host native endian, since it never gets shared with the guest.
For book3s_64 pr we introduce a variable that tells us which endianness the shared struct is in and route every access to it through helper inline functions that evaluate this variable.
--- arch/powerpc/include/asm/kvm_book3s.h | 3 +- arch/powerpc/include/asm/kvm_booke.h | 5 -- arch/powerpc/include/asm/kvm_host.h | 3 + arch/powerpc/include/asm/kvm_ppc.h | 80 +++++++++++++++++++++++++- arch/powerpc/kernel/asm-offsets.c | 4 ++ arch/powerpc/kvm/book3s.c | 72 ++++++++++++------------ arch/powerpc/kvm/book3s_32_mmu.c | 21 +++---- arch/powerpc/kvm/book3s_32_mmu_host.c | 4 +- arch/powerpc/kvm/book3s_64_mmu.c | 19 ++++--- arch/powerpc/kvm/book3s_64_mmu_host.c | 4 +- arch/powerpc/kvm/book3s_emulate.c | 28 ++++----- arch/powerpc/kvm/book3s_exports.c | 1 + arch/powerpc/kvm/book3s_hv.c | 11 ++++ arch/powerpc/kvm/book3s_interrupts.S | 23 +++++++- arch/powerpc/kvm/book3s_paired_singles.c | 16 +++--- arch/powerpc/kvm/book3s_pr.c | 97 +++++++++++++++++++------------- arch/powerpc/kvm/book3s_pr_papr.c | 2 +- arch/powerpc/kvm/emulate.c | 24 ++++---- arch/powerpc/kvm/powerpc.c | 33 ++++++++++- arch/powerpc/kvm/trace_pr.h | 2 +- 20 files changed, 309 insertions(+), 143 deletions(-)
arch/powerpc/include/asm/kvm_book3s.h +2 -1
@@ -268,9 +268,10 @@ static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)return vcpu->arch.pc; } +static inline u64 kvmppc_get_msr (struct kvm_vcpu *vcpu);static inline bool kvmppc_need_byteswap (struct kvm_vcpu *vcpu) { -return (vcpu->arch.shared->msr &MSR_LE ) != (MSR_KERNEL &MSR_LE ); +return (kvmppc_get_msr (vcpu) &MSR_LE ) != (MSR_KERNEL &MSR_LE ); }static inline u32 kvmppc_get_last_inst_internal (struct kvm_vcpu *vcpu,ulong pc)
arch/powerpc/include/asm/kvm_booke.h +0 -5
@@ -108,9 +108,4 @@ static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) {return vcpu->arch.fault_dear; } - -static inline ulong kvmppc_get_msr (struct kvm_vcpu *vcpu) -{ -return vcpu->arch.shared->msr; -}#endif /* __ASM_KVM_BOOKE_H__ */
arch/powerpc/include/asm/kvm_host.h +3 -0
@@ -623,6 +623,9 @@ struct kvm_vcpu_arch {wait_queue_head_t cpu_run;struct kvm_vcpu_arch_shared *shared; +#if defined(CONFIG_PPC_BOOK3S_64 ) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE ) +bool shared_big_endian; +#endif unsigned long magic_page_pa;/* phys addr to map the magic page to */ unsigned long magic_page_ea;/* effect. addr to map the magic page to */
arch/powerpc/include/asm/kvm_ppc.h +79 -1
92 lines not on this page · raw message
arch/powerpc/kernel/asm-offsets.c +4 -0
@@ -54,6 +54,7 @@#endif #if defined(CONFIG_KVM ) && defined(CONFIG_PPC_BOOK3S )#include <asm/kvm_book3s.h> +#include <asm/kvm_ppc.h> #endif #ifdef CONFIG_PPC32
@@ -467,6 +468,9 @@ int main(void) DEFINE(VCPU_SHARED, offsetof(struct kvm_vcpu, arch.shared));DEFINE (VCPU_SHARED_MSR , offsetof(struct kvm_vcpu_arch_shared , msr)); DEFINE(VCPU_SHADOW_MSR, offsetof(struct kvm_vcpu, arch.shadow_msr)); +#if defined(CONFIG_PPC_BOOK3S_64 ) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE ) + DEFINE(VCPU_SHAREDBE, offsetof(struct kvm_vcpu, arch.shared_big_endian)); +#endif DEFINE (VCPU_SHARED_MAS0 , offsetof(struct kvm_vcpu_arch_shared , mas0));DEFINE (VCPU_SHARED_MAS1 , offsetof(struct kvm_vcpu_arch_shared , mas1));
arch/powerpc/kvm/book3s.c +36 -36
151 lines not on this page · raw message
arch/powerpc/kvm/book3s_32_mmu.c +11 -10
@@ -91,7 +91,7 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,static u32 find_sr (struct kvm_vcpu *vcpu,gva_t eaddr) { -return vcpu->arch.shared->sr[(eaddr >>28 ) &0xf ]; +return kvmppc_get_sr (vcpu, (eaddr >>28 ) &0xf ); } static u64 kvmppc_mmu_book3s_32_ea_to_vp(struct kvm_vcpu *vcpu, gva_t eaddr,
@@ -160,7 +160,7 @@ static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr,else bat = &vcpu_book3s->ibat[i]; -if (vcpu->arch.shared->msr &MSR_PR ) { +if (kvmppc_get_msr (vcpu) &MSR_PR ) {if (!bat->vp)continue ; }else {
@@ -242,8 +242,8 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, pte->raddr = (pte1 & ~(0xFFFULL )) | (eaddr &0xFFF ); pp = pte1 &3 ; -if ((sr_kp (sre) && (vcpu->arch.shared->msr &MSR_PR )) || - (sr_ks (sre) && !(vcpu->arch.shared->msr &MSR_PR ))) +if ((sr_kp (sre) && (kvmppc_get_msr (vcpu) &MSR_PR )) || + (sr_ks (sre) && !(kvmppc_get_msr (vcpu) &MSR_PR ))) pp |=4 ; pte->may_write = false;
@@ -320,7 +320,7 @@ static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,/* Magic page override */ if (unlikely (mp_ea) &&unlikely ((eaddr & ~0xfffULL ) = (mp_ea & ~0xfffULL )) && - !(vcpu->arch.shared->msr &MSR_PR )) { + !(kvmppc_get_msr (vcpu) &MSR_PR )) { pte->vpage =kvmppc_mmu_book3s_32_ea_to_vp (vcpu, eaddr, data); pte->raddr = vcpu->arch.magic_page_pa | (pte->raddr &0xfff ); pte->raddr &=KVM_PAM ;
@@ -345,13 +345,13 @@ static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,static u32 kvmppc_mmu_book3s_32_mfsrin (struct kvm_vcpu *vcpu,u32 srnum) { -return vcpu->arch.shared->sr[srnum]; +return kvmppc_get_sr (vcpu, srnum); }static void kvmppc_mmu_book3s_32_mtsrin (struct kvm_vcpu *vcpu,u32 srnum,ulong value) { - vcpu->arch.shared->sr[srnum] = value; +kvmppc_set_sr (vcpu, srnum, value);kvmppc_mmu_map_segment (vcpu, srnum <<SID_SHIFT ); }
@@ -371,8 +371,9 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,ulong ea = esid <<SID_SHIFT ;u32 sr;u64 gvsid = esid; +u64 msr =kvmppc_get_msr (vcpu); -if (vcpu->arch.shared->msr & (MSR_DR |MSR_IR )) { +if (msr & (MSR_DR |MSR_IR )) { sr =find_sr (vcpu, ea);if (sr_valid (sr)) gvsid =sr_vsid (sr);
@@ -381,7 +382,7 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,/* In case we only have one of MSR_IR or MSR_DR set, let's put that in the real-mode context (and hope RM doesn't access high memory) */ -switch (vcpu->arch.shared->msr & (MSR_DR |MSR_IR )) { +switch (msr & (MSR_DR |MSR_IR )) {case 0 : *vsid =VSID_REAL | esid;break ;
@@ -401,7 +402,7 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,BUG (); } -if (vcpu->arch.shared->msr &MSR_PR ) +if (msr &MSR_PR ) *vsid |=VSID_PR ;return 0 ;
arch/powerpc/kvm/book3s_32_mmu_host.c +2 -2
@@ -92,7 +92,7 @@ static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid)struct kvmppc_sid_map *map;u16 sid_map_mask; -if (vcpu->arch.shared->msr &MSR_PR ) +if (kvmppc_get_msr (vcpu) &MSR_PR ) gvsid |=VSID_PR ; sid_map_mask =kvmppc_sid_hash (vcpu, gvsid);
@@ -279,7 +279,7 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)u16 sid_map_mask;static int backwards_map =0 ; -if (vcpu->arch.shared->msr &MSR_PR ) +if (kvmppc_get_msr (vcpu) &MSR_PR ) gvsid |=VSID_PR ;/* We might get collisions that trap in preceding order, so let's
arch/powerpc/kvm/book3s_64_mmu.c +10 -9
@@ -226,7 +226,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,/* Magic page override */ if (unlikely (mp_ea) &&unlikely ((eaddr & ~0xfffULL ) = (mp_ea & ~0xfffULL )) && - !(vcpu->arch.shared->msr &MSR_PR )) { + !(kvmppc_get_msr (vcpu) &MSR_PR )) { gpte->eaddr = eaddr; gpte->vpage =kvmppc_mmu_book3s_64_ea_to_vp (vcpu, eaddr, data); gpte->raddr = vcpu->arch.magic_page_pa | (gpte->raddr &0xfff );
@@ -269,9 +269,9 @@ do_second: goto no_page_found; } -if ((vcpu->arch.shared->msr &MSR_PR ) && slbe->Kp) +if ((kvmppc_get_msr (vcpu) &MSR_PR ) && slbe->Kp) key =4 ; -else if (!(vcpu->arch.shared->msr &MSR_PR ) && slbe->Ks) +else if (!(kvmppc_get_msr (vcpu) &MSR_PR ) && slbe->Ks) key =4 ;for (i=0 ; i<16 ; i+=2 ) {
@@ -482,7 +482,7 @@ static void kvmppc_mmu_book3s_64_slbia(struct kvm_vcpu *vcpu) vcpu->arch.slb[i].origv =0 ; } -if (vcpu->arch.shared->msr &MSR_IR ) { +if (kvmppc_get_msr (vcpu) &MSR_IR ) {kvmppc_mmu_flush_segments (vcpu);kvmppc_mmu_map_segment (vcpu,kvmppc_get_pc (vcpu)); }
@@ -566,7 +566,7 @@ static int segment_contains_magic_page(struct kvm_vcpu *vcpu, ulong esid) {ulong mp_ea = vcpu->arch.magic_page_ea; -return mp_ea && !(vcpu->arch.shared->msr &MSR_PR ) && +return mp_ea && !(kvmppc_get_msr (vcpu) &MSR_PR ) && (mp_ea >>SID_SHIFT ) = esid; }#endif
@@ -579,8 +579,9 @@ static int kvmppc_mmu_book3s_64_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,u64 gvsid = esid;ulong mp_ea = vcpu->arch.magic_page_ea;int pagesize =MMU_PAGE_64K ; +u64 msr =kvmppc_get_msr (vcpu); -if (vcpu->arch.shared->msr & (MSR_DR |MSR_IR )) { +if (msr & (MSR_DR |MSR_IR )) { slb =kvmppc_mmu_book3s_64_find_slbe (vcpu, ea);if (slb) { gvsid = slb->vsid;
@@ -593,7 +594,7 @@ static int kvmppc_mmu_book3s_64_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid, } } -switch (vcpu->arch.shared->msr & (MSR_DR |MSR_IR )) { +switch (msr & (MSR_DR |MSR_IR )) {case 0 : gvsid =VSID_REAL | esid;break ;
@@ -626,7 +627,7 @@ static int kvmppc_mmu_book3s_64_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid, gvsid |=VSID_64K ;#endif -if (vcpu->arch.shared->msr &MSR_PR ) +if (kvmppc_get_msr (vcpu) &MSR_PR ) gvsid |=VSID_PR ; *vsid = gvsid;
@@ -636,7 +637,7 @@ no_slb:/* Catch magic page case */ if (unlikely (mp_ea) &&unlikely (esid = (mp_ea >>SID_SHIFT )) && - !(vcpu->arch.shared->msr &MSR_PR )) { + !(kvmppc_get_msr (vcpu) &MSR_PR )) { *vsid =VSID_REAL | esid;return 0 ; }
arch/powerpc/kvm/book3s_64_mmu_host.c +2 -2
@@ -58,7 +58,7 @@ static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid)struct kvmppc_sid_map *map;u16 sid_map_mask; -if (vcpu->arch.shared->msr &MSR_PR ) +if (kvmppc_get_msr (vcpu) &MSR_PR ) gvsid |=VSID_PR ; sid_map_mask =kvmppc_sid_hash (vcpu, gvsid);
@@ -230,7 +230,7 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)u16 sid_map_mask;static int backwards_map =0 ; -if (vcpu->arch.shared->msr &MSR_PR ) +if (kvmppc_get_msr (vcpu) &MSR_PR ) gvsid |=VSID_PR ;/* We might get collisions that trap in preceding order, so let's
arch/powerpc/kvm/book3s_emulate.c +14 -14
@@ -80,7 +80,7 @@ static bool spr_allowed(struct kvm_vcpu *vcpu, enum priv_level level)return false;/* Limit user space to its own small SPR set */ -if ((vcpu->arch.shared->msr &MSR_PR ) && level >PRIV_PROBLEM ) +if ((kvmppc_get_msr (vcpu) &MSR_PR ) && level >PRIV_PROBLEM )return false;return true;
@@ -100,8 +100,8 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,switch (get_xop (inst)) {case OP_19_XOP_RFID :case OP_19_XOP_RFI : -kvmppc_set_pc (vcpu, vcpu->arch.shared->srr0); -kvmppc_set_msr (vcpu, vcpu->arch.shared->srr1); +kvmppc_set_pc (vcpu,kvmppc_get_srr0 (vcpu)); +kvmppc_set_msr (vcpu,kvmppc_get_srr1 (vcpu)); *advance =0 ;break ;
@@ -113,16 +113,16 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,case 31 :switch (get_xop (inst)) {case OP_31_XOP_MFMSR : -kvmppc_set_gpr (vcpu, rt, vcpu->arch.shared->msr); +kvmppc_set_gpr (vcpu, rt,kvmppc_get_msr (vcpu));break ;case OP_31_XOP_MTMSRD : {ulong rs_val =kvmppc_get_gpr (vcpu, rs);if (inst &0x10000 ) { -ulong new_msr = vcpu->arch.shared->msr; +ulong new_msr =kvmppc_get_msr (vcpu); new_msr &= ~(MSR_RI |MSR_EE ); new_msr |= rs_val & (MSR_RI |MSR_EE ); - vcpu->arch.shared->msr = new_msr; +kvmppc_set_msr_fast (vcpu, new_msr); }else kvmppc_set_msr (vcpu, rs_val);break ;
@@ -179,7 +179,7 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,ulong cmd =kvmppc_get_gpr (vcpu,3 );int i; -if ((vcpu->arch.shared->msr &MSR_PR ) || +if ((kvmppc_get_msr (vcpu) &MSR_PR ) || !vcpu->arch.papr_enabled) { emulated =EMULATE_FAIL ;break ;
@@ -261,14 +261,14 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu, ra_val =kvmppc_get_gpr (vcpu, ra); addr = (ra_val + rb_val) & ~31ULL ; -if (!(vcpu->arch.shared->msr &MSR_SF )) +if (!(kvmppc_get_msr (vcpu) &MSR_SF )) addr &=0xffffffff ; vaddr = addr; r =kvmppc_st (vcpu, &addr,32 , zeros, true);if ((r = -ENOENT ) || (r = -EPERM )) { *advance =0 ; - vcpu->arch.shared->dar = vaddr; +kvmppc_set_dar (vcpu, vaddr); vcpu->arch.fault_dar = vaddr; dsisr =DSISR_ISSTORE ;
@@ -277,7 +277,7 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,else if (r = -EPERM ) dsisr |=DSISR_PROTFAULT ; - vcpu->arch.shared->dsisr = dsisr; +kvmppc_set_dsisr (vcpu, dsisr); vcpu->arch.fault_dsisr = dsisr; kvmppc_book3s_queue_irqprio(vcpu,
@@ -356,10 +356,10 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)to_book3s (vcpu)->sdr1 = spr_val;break ;case SPRN_DSISR : - vcpu->arch.shared->dsisr = spr_val; +kvmppc_set_dsisr (vcpu, spr_val);break ;case SPRN_DAR : - vcpu->arch.shared->dar = spr_val; +kvmppc_set_dar (vcpu, spr_val);break ;case SPRN_HIOR :to_book3s (vcpu)->hior = spr_val;
@@ -493,10 +493,10 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val *spr_val =to_book3s (vcpu)->sdr1;break ;case SPRN_DSISR : - *spr_val = vcpu->arch.shared->dsisr; + *spr_val =kvmppc_get_dsisr (vcpu);break ;case SPRN_DAR : - *spr_val = vcpu->arch.shared->dar; + *spr_val =kvmppc_get_dar (vcpu);break ;case SPRN_HIOR : *spr_val =to_book3s (vcpu)->hior;
arch/powerpc/kvm/book3s_exports.c +1 -0
@@ -18,6 +18,7 @@*/ #include <linux/export.h> +#include <asm/kvm_ppc.h> #include <asm/kvm_book3s.h> #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
arch/powerpc/kvm/book3s_hv.c +11 -0
@@ -1280,6 +1280,17 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm, goto free_vcpu; vcpu->arch.shared = &vcpu->arch.shregs; +#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE +/* +* The shared struct is never shared on HV, +* so we can always use host endianness +*/ +#ifdef __BIG_ENDIAN__ + vcpu->arch.shared_big_endian = true; +#else + vcpu->arch.shared_big_endian = false; +#endif +#endif vcpu->arch.mmcr[0 ] =MMCR0_FC ; vcpu->arch.ctrl =CTRL_RUNLATCH ;/* default to host PVR, since we can't spoof it */
arch/powerpc/kvm/book3s_interrupts.S +21 -2
@@ -104,8 +104,27 @@ kvm_start_lightweight: stb r3, HSTATE_RESTORE_HID5(r13) /* Load up guest SPRG3 value, since it's user readable */ - ld r3, VCPU_SHARED(r4) - ld r3, VCPU_SHARED_SPRG3(r3) + lwz r3, VCPU_SHAREDBE(r4) + cmpwi r3, 0 + ld r5, VCPU_SHARED(r4) + beq sprg3_little_endian +sprg3_big_endian: +#ifdef __BIG_ENDIAN__ + ld r3, VCPU_SHARED_SPRG3(r5) +#else + addi r5, r5, VCPU_SHARED_SPRG3 + ldbrx r3, 0, r5 +#endif + b after_sprg3_load +sprg3_little_endian: +#ifdef __LITTLE_ENDIAN__ + ld r3, VCPU_SHARED_SPRG3(r5) +#else + addi r5, r5, VCPU_SHARED_SPRG3 + ldbrx r3, 0, r5 +#endif + +after_sprg3_load: mtspr SPRN_SPRG3, r3 #endif /* CONFIG_PPC_BOOK3S_64 */
arch/powerpc/kvm/book3s_paired_singles.c +9 -7
@@ -165,16 +165,18 @@ static inline void kvmppc_sync_qpr(struct kvm_vcpu *vcpu, int rt)static void kvmppc_inject_pf (struct kvm_vcpu *vcpu,ulong eaddr,bool is_store) { -u64 dsisr; -struct kvm_vcpu_arch_shared *shared = vcpu->arch.shared; +u32 dsisr; +u64 msr =kvmppc_get_msr (vcpu); - shared->msr =kvmppc_set_field (shared->msr,33 ,36 ,0 ); - shared->msr =kvmppc_set_field (shared->msr,42 ,47 ,0 ); - shared->dar = eaddr; + msr =kvmppc_set_field (msr,33 ,36 ,0 ); + msr =kvmppc_set_field (msr,42 ,47 ,0 ); +kvmppc_set_msr (vcpu, msr); +kvmppc_set_dar (vcpu, eaddr);/* Page Fault */ dsisr =kvmppc_set_field (0 ,33 ,33 ,1 );if (is_store) - shared->dsisr =kvmppc_set_field (dsisr,38 ,38 ,1 ); + dsisr =kvmppc_set_field (dsisr,38 ,38 ,1 ); +kvmppc_set_dsisr (vcpu, dsisr);kvmppc_book3s_queue_irqprio (vcpu,BOOK3S_INTERRUPT_DATA_STORAGE ); }
@@ -660,7 +662,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)if (!kvmppc_inst_is_paired_single (vcpu, inst))return EMULATE_FAIL ; -if (!(vcpu->arch.shared->msr &MSR_FP )) { +if (!(kvmppc_get_msr (vcpu) &MSR_FP )) {kvmppc_book3s_queue_irqprio (vcpu,BOOK3S_INTERRUPT_FP_UNAVAIL );return EMULATE_AGAIN ; }
arch/powerpc/kvm/book3s_pr.c +57 -37
244 lines not on this page · raw message
arch/powerpc/kvm/book3s_pr_papr.c +1 -1
@@ -278,7 +278,7 @@ int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd)case H_PUT_TCE :return kvmppc_h_pr_put_tce (vcpu);case H_CEDE : - vcpu->arch.shared->msr |=MSR_EE ; +kvmppc_set_msr_fast (vcpu,kvmppc_get_msr (vcpu) |MSR_EE );kvm_vcpu_block (vcpu);clear_bit (KVM_REQ_UNHALT , &vcpu->requests); vcpu->stat.halt_wakeup++;
arch/powerpc/kvm/emulate.c +12 -12
@@ -97,10 +97,10 @@ static int kvmppc_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)switch (sprn) {case SPRN_SRR0 : - vcpu->arch.shared->srr0 = spr_val; +kvmppc_set_srr0 (vcpu, spr_val);break ;case SPRN_SRR1 : - vcpu->arch.shared->srr1 = spr_val; +kvmppc_set_srr1 (vcpu, spr_val);break ;/* XXX We need to context-switch the timebase for
@@ -114,16 +114,16 @@ static int kvmppc_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)break ;case SPRN_SPRG0 : - vcpu->arch.shared->sprg0 = spr_val; +kvmppc_set_sprg0 (vcpu, spr_val);break ;case SPRN_SPRG1 : - vcpu->arch.shared->sprg1 = spr_val; +kvmppc_set_sprg1 (vcpu, spr_val);break ;case SPRN_SPRG2 : - vcpu->arch.shared->sprg2 = spr_val; +kvmppc_set_sprg2 (vcpu, spr_val);break ;case SPRN_SPRG3 : - vcpu->arch.shared->sprg3 = spr_val; +kvmppc_set_sprg3 (vcpu, spr_val);break ;/* PIR can legally be written, but we ignore it */
@@ -150,10 +150,10 @@ static int kvmppc_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)switch (sprn) {case SPRN_SRR0 : - spr_val = vcpu->arch.shared->srr0; + spr_val =kvmppc_get_srr0 (vcpu);break ;case SPRN_SRR1 : - spr_val = vcpu->arch.shared->srr1; + spr_val =kvmppc_get_srr1 (vcpu);break ;case SPRN_PVR : spr_val = vcpu->arch.pvr;
@@ -173,16 +173,16 @@ static int kvmppc_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)break ;case SPRN_SPRG0 : - spr_val = vcpu->arch.shared->sprg0; + spr_val =kvmppc_get_sprg0 (vcpu);break ;case SPRN_SPRG1 : - spr_val = vcpu->arch.shared->sprg1; + spr_val =kvmppc_get_sprg1 (vcpu);break ;case SPRN_SPRG2 : - spr_val = vcpu->arch.shared->sprg2; + spr_val =kvmppc_get_sprg2 (vcpu);break ;case SPRN_SPRG3 : - spr_val = vcpu->arch.shared->sprg3; + spr_val =kvmppc_get_sprg3 (vcpu);break ;/* Note: SPRG4-7 are user-readable, so we don't get * a trap. */
arch/powerpc/kvm/powerpc.c +32 -1
@@ -125,6 +125,27 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) }EXPORT_SYMBOL_GPL (kvmppc_prepare_to_enter); +#if defined(CONFIG_PPC_BOOK3S_64 ) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE ) +static void kvmppc_swab_shared (struct kvm_vcpu *vcpu) +{ +struct kvm_vcpu_arch_shared *shared = vcpu->arch.shared; +int i; + + shared->sprg0 =swab64 (shared->sprg0); + shared->sprg1 =swab64 (shared->sprg1); + shared->sprg2 =swab64 (shared->sprg2); + shared->sprg3 =swab64 (shared->sprg3); + shared->srr0 =swab64 (shared->srr0); + shared->srr1 =swab64 (shared->srr1); + shared->dar =swab64 (shared->dar); + shared->msr =swab64 (shared->msr); + shared->dsisr =swab32 (shared->dsisr); + shared->int_pending =swab32 (shared->int_pending); +for (i =0 ; i <ARRAY_SIZE (shared->sr); i++) + shared->sr[i] =swab32 (shared->sr[i]); +} +#endif +int kvmppc_kvm_pv (struct kvm_vcpu *vcpu) {int nr =kvmppc_get_gpr (vcpu,11 );
@@ -135,7 +156,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)unsigned long __maybe_unused param4 =kvmppc_get_gpr (vcpu,6 );unsigned long r2 =0 ; -if (!(vcpu->arch.shared->msr &MSR_SF )) { +if (!(kvmppc_get_msr (vcpu) &MSR_SF )) {/* 32 bit mode */ param1 &=0xffffffff ; param2 &=0xffffffff ;
@@ -146,6 +167,16 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)switch (nr) {case KVM_HCALL_TOKEN (KVM_HC_PPC_MAP_MAGIC_PAGE ): { +#if defined(CONFIG_PPC_BOOK3S_64 ) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE ) +/* Book3S can be little endian, find it out here */ +int shared_big_endian = true; +if (vcpu->arch.intr_msr &MSR_LE ) + shared_big_endian = false; +if (shared_big_endian != vcpu->arch.shared_big_endian) +kvmppc_swab_shared (vcpu); + vcpu->arch.shared_big_endian = shared_big_endian; +#endif + vcpu->arch.magic_page_pa = param1; vcpu->arch.magic_page_ea = param2;
arch/powerpc/kvm/trace_pr.h +1 -1
@@ -255,7 +255,7 @@ TRACE_EVENT(kvm_exit, __entry->exit_nr = exit_nr; __entry->pc =kvmppc_get_pc (vcpu); __entry->dar =kvmppc_get_fault_dar (vcpu); - __entry->msr = vcpu->arch.shared->msr; + __entry->msr =kvmppc_get_msr (vcpu); __entry->srr1 = vcpu->arch.shadow_srr1; __entry->last_inst = vcpu->arch.last_inst; ),
Signature · 1 line
1.8.1.4
[PULL 14/41] KVM: PPC: Book3S PR: Do dcbz32 patching with big endian instructions
In reply to Alexander GrafWhen the host CPU we're running on doesn't support dcbz32 itself, but the guest wants to have dcbz only clear 32 bytes of data, we loop through every executable mapped page to search for dcbz instructions and patch them with a special privileged instruction that we emulate as dcbz32.
The only guests that want to see dcbz act as 32byte are book3s_32 guests, so we don't have to worry about little endian instruction ordering. So let's just always search for big endian dcbz instructions, also when we're on a little endian host.
--- arch/powerpc/kvm/book3s_32_mmu.c | 2 +- arch/powerpc/kvm/book3s_pr.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/kvm/book3s_32_mmu.c +1 -1
@@ -131,7 +131,7 @@ static hva_t kvmppc_mmu_book3s_32_get_pteg(struct kvm_vcpu *vcpu, pteg = (vcpu_book3s->sdr1 &0xffff0000 ) | hash;dprintk ("MMU: pc=0x%lx eaddr=0x%lx sdr1=0x%llx pteg=0x%x vsid=0x%x\n" , -kvmppc_get_pc (&vcpu_book3s->vcpu), eaddr, vcpu_book3s->sdr1, pteg, +kvmppc_get_pc (vcpu), eaddr, vcpu_book3s->sdr1, pteg,sr_vsid (sre)); r =gfn_to_hva (vcpu->kvm, pteg >>PAGE_SHIFT );
arch/powerpc/kvm/book3s_pr.c +2 -2
@@ -428,8 +428,8 @@ static void kvmppc_patch_dcbz(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte)/* patch dcbz into reserved instruction, so we trap */ for (i=hpage_offset; i < hpage_offset + (HW_PAGE_SIZE /4 ); i++) -if ((page[i] &0xff0007ff ) =INS_DCBZ ) - page[i] &=0xfffffff7 ; +if ((be32_to_cpu (page[i]) &0xff0007ff ) =INS_DCBZ ) + page[i] &=cpu_to_be32 (0xfffffff7 );kunmap_atomic (page);put_page (hpage);
Signature · 1 line
1.8.1.4
[PULL 15/41] KVM: PPC: Book3S: Move little endian conflict to HV KVM
In reply to Alexander GrafWith the previous patches applied, we can now successfully use PR KVM on little endian hosts which means we can now allow users to select it.
However, HV KVM still needs some work, so let's keep the kconfig conflict on that one.
--- arch/powerpc/kvm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/Kconfig +1 -1
@@ -6,7 +6,6 @@ source "virt/kvm/Kconfig" menuconfig VIRTUALIZATION bool "Virtualization" - depends on !CPU_LITTLE_ENDIAN ---help--- Say Y here to get to see options for using your Linux host to run other operating systems inside virtual machines (guests).
@@ -76,6 +75,7 @@ config KVM_BOOK3S_64 config KVM_BOOK3S_64_HV tristate "KVM support for POWER7 and PPC970 using hypervisor mode in host" depends on KVM_BOOK3S_64 + depends on !CPU_LITTLE_ENDIAN select KVM_BOOK3S_HV_POSSIBLE select MMU_NOTIFIER select CMA
Signature · 1 line
1.8.1.4
[PULL 16/41] KVM: PPC: Book3S PR: Ignore PMU SPRs
In reply to Alexander GrafWhen we expose a POWER8 CPU into the guest, it will start accessing PMU SPRs that we don't emulate. Just ignore accesses to them.
--- arch/powerpc/kvm/book3s_emulate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/powerpc/kvm/book3s_emulate.c +14 -0
@@ -455,6 +455,13 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_WPAR_GEKKO :case SPRN_MSSSR0 :case SPRN_DABR : +#ifdef CONFIG_PPC_BOOK3S_64 +case SPRN_MMCRS : +case SPRN_MMCRA : +case SPRN_MMCR0 : +case SPRN_MMCR1 : +case SPRN_MMCR2 : +#endif break ; unprivileged:default :
@@ -553,6 +560,13 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_WPAR_GEKKO :case SPRN_MSSSR0 :case SPRN_DABR : +#ifdef CONFIG_PPC_BOOK3S_64 +case SPRN_MMCRS : +case SPRN_MMCRA : +case SPRN_MMCR0 : +case SPRN_MMCR1 : +case SPRN_MMCR2 : +#endif *spr_val =0 ;break ;default :
Signature · 1 line
1.8.1.4
[PULL 17/41] KVM: PPC: Book3S PR: Emulate TIR register
In reply to Alexander GrafIn parallel to the Processor ID Register (PIR) threaded POWER8 also adds a Thread ID Register (TIR). Since PR KVM doesn't emulate more than one thread per core, we can just always expose 0 here.
--- arch/powerpc/kvm/book3s_emulate.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kvm/book3s_emulate.c +1 -0
@@ -566,6 +566,7 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_MMCR0 :case SPRN_MMCR1 :case SPRN_MMCR2 : +case SPRN_TIR :#endif *spr_val =0 ;break ;
Signature · 1 line
1.8.1.4
[PULL 18/41] KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
In reply to Alexander GrafPOWER8 introduced a new interrupt type called "Facility unavailable interrupt" which contains its status message in a new register called FSCR.
Handle these exits and try to emulate instructions for unhandled facilities. Follow-on patches enable KVM to expose specific facilities into the guest.
--- arch/powerpc/include/asm/kvm_asm.h | 18 ++++---- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc/kernel/asm-offsets.c | 3 ++ arch/powerpc/kvm/book3s.c | 10 +++++ arch/powerpc/kvm/book3s_emulate.c | 6 +++ arch/powerpc/kvm/book3s_hv.c | 6 --- arch/powerpc/kvm/book3s_pr.c | 68 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++++++++++ 9 files changed, 125 insertions(+), 14 deletions(-)
arch/powerpc/include/asm/kvm_asm.h +10 -8
@@ -102,6 +102,7 @@#define BOOK3S_INTERRUPT_PERFMON 0xf00#define BOOK3S_INTERRUPT_ALTIVEC 0xf20#define BOOK3S_INTERRUPT_VSX 0xf40 +#define BOOK3S_INTERRUPT_FAC_UNAVAIL 0xf60#define BOOK3S_INTERRUPT_H_FAC_UNAVAIL 0xf80#define BOOK3S_IRQPRIO_SYSTEM_RESET 0
@@ -114,14 +115,15 @@#define BOOK3S_IRQPRIO_FP_UNAVAIL 7#define BOOK3S_IRQPRIO_ALTIVEC 8#define BOOK3S_IRQPRIO_VSX 9 -#define BOOK3S_IRQPRIO_SYSCALL 10 -#define BOOK3S_IRQPRIO_MACHINE_CHECK 11 -#define BOOK3S_IRQPRIO_DEBUG 12 -#define BOOK3S_IRQPRIO_EXTERNAL 13 -#define BOOK3S_IRQPRIO_DECREMENTER 14 -#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 15 -#define BOOK3S_IRQPRIO_EXTERNAL_LEVEL 16 -#define BOOK3S_IRQPRIO_MAX 17 +#define BOOK3S_IRQPRIO_FAC_UNAVAIL 10 +#define BOOK3S_IRQPRIO_SYSCALL 11 +#define BOOK3S_IRQPRIO_MACHINE_CHECK 12 +#define BOOK3S_IRQPRIO_DEBUG 13 +#define BOOK3S_IRQPRIO_EXTERNAL 14 +#define BOOK3S_IRQPRIO_DECREMENTER 15 +#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 16 +#define BOOK3S_IRQPRIO_EXTERNAL_LEVEL 17 +#define BOOK3S_IRQPRIO_MAX 18#define BOOK3S_HFLAG_DCBZ32 0x1#define BOOK3S_HFLAG_SLB 0x2
arch/powerpc/include/asm/kvm_book3s_asm.h +2 -0
@@ -104,6 +104,7 @@ struct kvmppc_host_state {#ifdef CONFIG_PPC_BOOK3S_64 u64 cfar;u64 ppr; +u64 host_fscr;#endif };
@@ -133,6 +134,7 @@ struct kvmppc_book3s_shadow_vcpu {u64 esid; u64 vsid; } slb[64 ];/* guest SLB */ +u64 shadow_fscr;#endif };
arch/powerpc/include/asm/kvm_host.h +1 -0
@@ -475,6 +475,7 @@ struct kvm_vcpu_arch {ulong ppr;ulong pspb;ulong fscr; +ulong shadow_fscr;ulong ebbhr;ulong ebbrr;ulong bescr;
arch/powerpc/kernel/asm-offsets.c +3 -0
@@ -537,6 +537,7 @@ int main(void) DEFINE(VCPU_CFAR, offsetof(struct kvm_vcpu, arch.cfar)); DEFINE(VCPU_PPR, offsetof(struct kvm_vcpu, arch.ppr)); DEFINE(VCPU_FSCR, offsetof(struct kvm_vcpu, arch.fscr)); + DEFINE(VCPU_SHADOW_FSCR, offsetof(struct kvm_vcpu, arch.shadow_fscr)); DEFINE(VCPU_PSPB, offsetof(struct kvm_vcpu, arch.pspb)); DEFINE(VCPU_EBBHR, offsetof(struct kvm_vcpu, arch.ebbhr)); DEFINE(VCPU_EBBRR, offsetof(struct kvm_vcpu, arch.ebbrr));
@@ -618,6 +619,7 @@ int main(void)#ifdef CONFIG_PPC64 SVCPU_FIELD (SVCPU_SLB , slb);SVCPU_FIELD (SVCPU_SLB_MAX , slb_max); +SVCPU_FIELD (SVCPU_SHADOW_FSCR , shadow_fscr);#endif HSTATE_FIELD (HSTATE_HOST_R1 , host_r1);
@@ -653,6 +655,7 @@ int main(void)#ifdef CONFIG_PPC_BOOK3S_64 HSTATE_FIELD (HSTATE_CFAR , cfar);HSTATE_FIELD (HSTATE_PPR , ppr); +HSTATE_FIELD (HSTATE_HOST_FSCR , host_fscr);#endif /* CONFIG_PPC_BOOK3S_64 */ #else /* CONFIG_PPC_BOOK3S */
arch/powerpc/kvm/book3s.c +10 -0
@@ -145,6 +145,7 @@ static int kvmppc_book3s_vec2irqprio(unsigned int vec)case 0xd00 : prio =BOOK3S_IRQPRIO_DEBUG ;break ;case 0xf20 : prio =BOOK3S_IRQPRIO_ALTIVEC ;break ;case 0xf40 : prio =BOOK3S_IRQPRIO_VSX ;break ; +case 0xf60 : prio =BOOK3S_IRQPRIO_FAC_UNAVAIL ;break ;default : prio =BOOK3S_IRQPRIO_MAX ;break ; }
@@ -275,6 +276,9 @@ int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu, unsigned int priority)case BOOK3S_IRQPRIO_PERFORMANCE_MONITOR : vec =BOOK3S_INTERRUPT_PERFMON ;break ; +case BOOK3S_IRQPRIO_FAC_UNAVAIL : + vec =BOOK3S_INTERRUPT_FAC_UNAVAIL ; +break ;default : deliver =0 ;printk (KERN_ERR "KVM: Unknown interrupt: 0x%x\n" , priority);
@@ -627,6 +631,9 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) val =get_reg_val (reg->id,kvmppc_xics_get_icp (vcpu));break ;#endif /* CONFIG_KVM_XICS */ +case KVM_REG_PPC_FSCR : + val =get_reg_val (reg->id, vcpu->arch.fscr); +break ;default : r = -EINVAL ;break ;
@@ -716,6 +723,9 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) set_reg_val(reg->id, val));break ;#endif /* CONFIG_KVM_XICS */ +case KVM_REG_PPC_FSCR : + vcpu->arch.fscr =set_reg_val (reg->id, val); +break ;default : r = -EINVAL ;break ;
arch/powerpc/kvm/book3s_emulate.c +6 -0
@@ -438,6 +438,9 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_GQR7 :to_book3s (vcpu)->gqr[sprn -SPRN_GQR0 ] = spr_val;break ; +case SPRN_FSCR : + vcpu->arch.fscr = spr_val; +break ;case SPRN_ICTC :case SPRN_THRM1 :case SPRN_THRM2 :
@@ -545,6 +548,9 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_GQR7 : *spr_val =to_book3s (vcpu)->gqr[sprn -SPRN_GQR0 ];break ; +case SPRN_FSCR : + *spr_val = vcpu->arch.fscr; +break ;case SPRN_THRM1 :case SPRN_THRM2 :case SPRN_THRM3 :
arch/powerpc/kvm/book3s_hv.c +0 -6
@@ -879,9 +879,6 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_IAMR : *val =get_reg_val (id, vcpu->arch.iamr);break ; -case KVM_REG_PPC_FSCR : - *val =get_reg_val (id, vcpu->arch.fscr); -break ;case KVM_REG_PPC_PSPB : *val =get_reg_val (id, vcpu->arch.pspb);break ;
@@ -1091,9 +1088,6 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_IAMR : vcpu->arch.iamr =set_reg_val (id, *val);break ; -case KVM_REG_PPC_FSCR : - vcpu->arch.fscr =set_reg_val (id, *val); -break ;case KVM_REG_PPC_PSPB : vcpu->arch.pspb =set_reg_val (id, *val);break ;
arch/powerpc/kvm/book3s_pr.c +68 -0
104 lines not on this page · raw message
arch/powerpc/kvm/book3s_segment.S +25 -0
@@ -90,6 +90,15 @@ kvmppc_handler_trampoline_enter: LOAD_GUEST_SEGMENTS #ifdef CONFIG_PPC_BOOK3S_64 +BEGIN_FTR_SECTION + /* Save host FSCR */ + mfspr r8, SPRN_FSCR + std r8, HSTATE_HOST_FSCR(r13) + /* Set FSCR during guest execution */ + ld r9, SVCPU_SHADOW_FSCR(r13) + mtspr SPRN_FSCR, r9 +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) + /* Some guests may need to have dcbz set to 32 byte length. * * Usually we ensure that by patching the guest's instructions
@@ -255,6 +264,10 @@ BEGIN_FTR_SECTION cmpwi r12, BOOK3S_INTERRUPT_H_EMUL_ASSIST beq- ld_last_inst END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) +BEGIN_FTR_SECTION + cmpwi r12, BOOK3S_INTERRUPT_FAC_UNAVAIL + beq- ld_last_inst +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) #endif b no_ld_last_inst
@@ -311,6 +324,18 @@ no_ld_last_inst: no_dcbz32_off: +BEGIN_FTR_SECTION + /* Save guest FSCR on a FAC_UNAVAIL interrupt */ + cmpwi r12, BOOK3S_INTERRUPT_FAC_UNAVAIL + bne+ no_fscr_save + mfspr r7, SPRN_FSCR + std r7, SVCPU_SHADOW_FSCR(r13) +no_fscr_save: + /* Restore host FSCR */ + ld r8, HSTATE_HOST_FSCR(r13) + mtspr SPRN_FSCR, r8 +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) + #endif /* CONFIG_PPC_BOOK3S_64 */ /*
Signature · 1 line
1.8.1.4
[PULL 19/41] KVM: PPC: Book3S PR: Expose TAR facility to guest
In reply to Alexander GrafPOWER8 implements a new register called TAR. This register has to be enabled in FSCR and then from KVM's point of view is mere storage.
This patch enables the guest to use TAR.
--- arch/powerpc/include/asm/kvm_host.h | 2 ++ arch/powerpc/kernel/asm-offsets.c | 2 ++ arch/powerpc/kvm/book3s.c | 6 ++++++ arch/powerpc/kvm/book3s_hv.c | 6 ------ arch/powerpc/kvm/book3s_pr.c | 18 ++++++++++++++++++ 5 files changed, 28 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/kvm_host.h +2 -0
@@ -449,7 +449,9 @@ struct kvm_vcpu_arch {ulong pc;ulong ctr;ulong lr; +#ifdef CONFIG_PPC_BOOK3S ulong tar; +#endif ulong xer;u32 cr;
arch/powerpc/kernel/asm-offsets.c +2 -0
@@ -446,7 +446,9 @@ int main(void) DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, arch.xer)); DEFINE(VCPU_CTR, offsetof(struct kvm_vcpu, arch.ctr)); DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); +#ifdef CONFIG_PPC_BOOK3S DEFINE(VCPU_TAR, offsetof(struct kvm_vcpu, arch.tar)); +#endif DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr)); DEFINE(VCPU_PC, offsetof(struct kvm_vcpu, arch.pc));#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
arch/powerpc/kvm/book3s.c +6 -0
@@ -634,6 +634,9 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)case KVM_REG_PPC_FSCR : val =get_reg_val (reg->id, vcpu->arch.fscr);break ; +case KVM_REG_PPC_TAR : + val =get_reg_val (reg->id, vcpu->arch.tar); +break ;default : r = -EINVAL ;break ;
@@ -726,6 +729,9 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)case KVM_REG_PPC_FSCR : vcpu->arch.fscr =set_reg_val (reg->id, val);break ; +case KVM_REG_PPC_TAR : + vcpu->arch.tar =set_reg_val (reg->id, val); +break ;default : r = -EINVAL ;break ;
arch/powerpc/kvm/book3s_hv.c +0 -6
@@ -891,9 +891,6 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_BESCR : *val =get_reg_val (id, vcpu->arch.bescr);break ; -case KVM_REG_PPC_TAR : - *val =get_reg_val (id, vcpu->arch.tar); -break ;case KVM_REG_PPC_DPDES : *val =get_reg_val (id, vcpu->arch.vcore->dpdes);break ;
@@ -1100,9 +1097,6 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_BESCR : vcpu->arch.bescr =set_reg_val (id, *val);break ; -case KVM_REG_PPC_TAR : - vcpu->arch.tar =set_reg_val (id, *val); -break ;case KVM_REG_PPC_DPDES : vcpu->arch.vcore->dpdes =set_reg_val (id, *val);break ;
arch/powerpc/kvm/book3s_pr.c +18 -0
@@ -90,6 +90,7 @@ static void kvmppc_core_vcpu_put_pr(struct kvm_vcpu *vcpu)#endif kvmppc_giveup_ext (vcpu,MSR_FP |MSR_VEC |MSR_VSX ); +kvmppc_giveup_fac (vcpu,FSCR_TAR_LG ); vcpu->cpu =-1 ; }
@@ -625,6 +626,14 @@ static void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac)/* Facility not available to the guest, ignore giveup request*/ return; } + +switch (fac) { +case FSCR_TAR_LG : + vcpu->arch.tar =mfspr (SPRN_TAR ); +mtspr (SPRN_TAR , current->thread.tar); + vcpu->arch.shadow_fscr &= ~FSCR_TAR ; +break ; + }#endif }
@@ -794,6 +803,12 @@ static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac) }switch (fac) { +case FSCR_TAR_LG : +/* TAR switching isn't lazy in Linux yet */ + current->thread.tar =mfspr (SPRN_TAR ); +mtspr (SPRN_TAR , vcpu->arch.tar); + vcpu->arch.shadow_fscr |=FSCR_TAR ; +break ;default :kvmppc_emulate_fac (vcpu, fac);break ;
@@ -1393,6 +1408,9 @@ static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)/* Make sure we save the guest FPU/Altivec/VSX state */ kvmppc_giveup_ext (vcpu,MSR_FP |MSR_VEC |MSR_VSX ); +/* Make sure we save the guest TAR/EBB/DSCR state */ +kvmppc_giveup_fac (vcpu,FSCR_TAR_LG ); + out: vcpu->mode =OUTSIDE_GUEST_MODE ;return ret;
Signature · 1 line
1.8.1.4
[PULL 20/41] KVM: PPC: Book3S PR: Expose EBB registers
In reply to Alexander GrafPOWER8 introduces a new facility called the "Event Based Branch" facility. It contains of a few registers that indicate where a guest should branch to when a defined event occurs and it's in PR mode.
We don't want to really enable EBB as it will create a big mess with !PR guest mode while hardware is in PR and we don't really emulate the PMU anyway.
So instead, let's just leave it at emulation of all its registers.
--- arch/powerpc/kvm/book3s.c | 18 ++++++++++++++++++ arch/powerpc/kvm/book3s_emulate.c | 22 ++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 18 ------------------ 3 files changed, 40 insertions(+), 18 deletions(-)
arch/powerpc/kvm/book3s.c +18 -0
@@ -637,6 +637,15 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)case KVM_REG_PPC_TAR : val =get_reg_val (reg->id, vcpu->arch.tar);break ; +case KVM_REG_PPC_EBBHR : + val =get_reg_val (reg->id, vcpu->arch.ebbhr); +break ; +case KVM_REG_PPC_EBBRR : + val =get_reg_val (reg->id, vcpu->arch.ebbrr); +break ; +case KVM_REG_PPC_BESCR : + val =get_reg_val (reg->id, vcpu->arch.bescr); +break ;default : r = -EINVAL ;break ;
@@ -732,6 +741,15 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)case KVM_REG_PPC_TAR : vcpu->arch.tar =set_reg_val (reg->id, val);break ; +case KVM_REG_PPC_EBBHR : + vcpu->arch.ebbhr =set_reg_val (reg->id, val); +break ; +case KVM_REG_PPC_EBBRR : + vcpu->arch.ebbrr =set_reg_val (reg->id, val); +break ; +case KVM_REG_PPC_BESCR : + vcpu->arch.bescr =set_reg_val (reg->id, val); +break ;default : r = -EINVAL ;break ;
arch/powerpc/kvm/book3s_emulate.c +22 -0
@@ -441,6 +441,17 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_FSCR : vcpu->arch.fscr = spr_val;break ; +#ifdef CONFIG_PPC_BOOK3S_64 +case SPRN_BESCR : + vcpu->arch.bescr = spr_val; +break ; +case SPRN_EBBHR : + vcpu->arch.ebbhr = spr_val; +break ; +case SPRN_EBBRR : + vcpu->arch.ebbrr = spr_val; +break ; +#endif case SPRN_ICTC :case SPRN_THRM1 :case SPRN_THRM2 :
@@ -551,6 +562,17 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_FSCR : *spr_val = vcpu->arch.fscr;break ; +#ifdef CONFIG_PPC_BOOK3S_64 +case SPRN_BESCR : + *spr_val = vcpu->arch.bescr; +break ; +case SPRN_EBBHR : + *spr_val = vcpu->arch.ebbhr; +break ; +case SPRN_EBBRR : + *spr_val = vcpu->arch.ebbrr; +break ; +#endif case SPRN_THRM1 :case SPRN_THRM2 :case SPRN_THRM3 :
arch/powerpc/kvm/book3s_hv.c +0 -18
@@ -882,15 +882,6 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_PSPB : *val =get_reg_val (id, vcpu->arch.pspb);break ; -case KVM_REG_PPC_EBBHR : - *val =get_reg_val (id, vcpu->arch.ebbhr); -break ; -case KVM_REG_PPC_EBBRR : - *val =get_reg_val (id, vcpu->arch.ebbrr); -break ; -case KVM_REG_PPC_BESCR : - *val =get_reg_val (id, vcpu->arch.bescr); -break ;case KVM_REG_PPC_DPDES : *val =get_reg_val (id, vcpu->arch.vcore->dpdes);break ;
@@ -1088,15 +1079,6 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_PSPB : vcpu->arch.pspb =set_reg_val (id, *val);break ; -case KVM_REG_PPC_EBBHR : - vcpu->arch.ebbhr =set_reg_val (id, *val); -break ; -case KVM_REG_PPC_EBBRR : - vcpu->arch.ebbrr =set_reg_val (id, *val); -break ; -case KVM_REG_PPC_BESCR : - vcpu->arch.bescr =set_reg_val (id, *val); -break ;case KVM_REG_PPC_DPDES : vcpu->arch.vcore->dpdes =set_reg_val (id, *val);break ;
Signature · 1 line
1.8.1.4
[PULL 21/41] KVM: PPC: Book3S PR: Expose TM registers
In reply to Alexander GrafPOWER8 introduces transactional memory which brings along a number of new registers and MSR bits.
Implementing all of those is a pretty big headache, so for now let's at least emulate enough to make Linux's context switching code happy.
--- arch/powerpc/kvm/book3s_emulate.c | 22 ++++++++++++++++++++++ arch/powerpc/kvm/book3s_pr.c | 20 +++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_emulate.c +22 -0
@@ -451,6 +451,17 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_EBBRR : vcpu->arch.ebbrr = spr_val;break ; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +case SPRN_TFHAR : + vcpu->arch.tfhar = spr_val; +break ; +case SPRN_TEXASR : + vcpu->arch.texasr = spr_val; +break ; +case SPRN_TFIAR : + vcpu->arch.tfiar = spr_val; +break ; +#endif #endif case SPRN_ICTC :case SPRN_THRM1 :
@@ -572,6 +583,17 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_EBBRR : *spr_val = vcpu->arch.ebbrr;break ; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +case SPRN_TFHAR : + *spr_val = vcpu->arch.tfhar; +break ; +case SPRN_TEXASR : + *spr_val = vcpu->arch.texasr; +break ; +case SPRN_TFIAR : + *spr_val = vcpu->arch.tfiar; +break ; +#endif #endif case SPRN_THRM1 :case SPRN_THRM2 :
arch/powerpc/kvm/book3s_pr.c +19 -1
@@ -794,9 +794,27 @@ static void kvmppc_emulate_fac(struct kvm_vcpu *vcpu, ulong fac)/* Enable facilities (TAR, EBB, DSCR) for the guest */ static int kvmppc_handle_fac (struct kvm_vcpu *vcpu,ulong fac) { +bool guest_fac_enabled;BUG_ON (!cpu_has_feature (CPU_FTR_ARCH_207S )); -if (!(vcpu->arch.fscr & (1ULL << fac))) { +/* +* Not every facility is enabled by FSCR bits, check whether the +* guest has this facility enabled at all. +*/ +switch (fac) { +case FSCR_TAR_LG : +case FSCR_EBB_LG : + guest_fac_enabled = (vcpu->arch.fscr & (1ULL << fac)); +break ; +case FSCR_TM_LG : + guest_fac_enabled =kvmppc_get_msr (vcpu) &MSR_TM ; +break ; +default : + guest_fac_enabled = false; +break ; + } + +if (!guest_fac_enabled) {/* Facility not enabled by the guest */ kvmppc_trigger_fac_interrupt (vcpu, fac);return RESUME_GUEST ;
Signature · 1 line
1.8.1.4
[PULL 22/41] KVM: PPC: BOOK3S: HV: Prefer CMA region for hash page table allocation
In reply to Alexander GrafFrom: "Aneesh Kumar K.V" <[email protected]>
Today when KVM tries to reserve memory for the hash page table it allocates from the normal page allocator first. If that fails it falls back to CMA's reserved region. One of the side effects of this is that we could end up exhausting the page allocator and get linux into OOM conditions while we still have plenty of space available in CMA.
This patch addresses this issue by first trying hash page table allocation from CMA's reserved region before falling back to the normal page allocator. So if we run out of memory, we really are out of memory.
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +6 -17
@@ -52,7 +52,7 @@ static void kvmppc_rmap_reset(struct kvm *kvm);long kvmppc_alloc_hpt (struct kvm *kvm,u32 *htab_orderp) { -unsigned long hpt; +unsigned long hpt =0 ;struct revmap_entry *rev;struct page *page =NULL ;long order =KVM_DEFAULT_HPT_ORDER ;
@@ -64,22 +64,11 @@ long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp) } kvm->arch.hpt_cma_alloc =0 ; -/* -* try first to allocate it from the kernel page allocator. -* We keep the CMA reserved for failed allocation. -*/ - hpt =__get_free_pages (GFP_KERNEL | __GFP_ZERO | __GFP_REPEAT | - __GFP_NOWARN, order -PAGE_SHIFT ); - -/* Next try to allocate from the preallocated pool */ -if (!hpt) { -VM_BUG_ON (order <KVM_CMA_CHUNK_ORDER ); - page =kvm_alloc_hpt (1 << (order -PAGE_SHIFT )); -if (page) { - hpt = (unsigned long )pfn_to_kaddr (page_to_pfn (page)); - kvm->arch.hpt_cma_alloc =1 ; - }else - --order; +VM_BUG_ON (order <KVM_CMA_CHUNK_ORDER ); + page =kvm_alloc_hpt (1 << (order -PAGE_SHIFT )); +if (page) { + hpt = (unsigned long )pfn_to_kaddr (page_to_pfn (page)); + kvm->arch.hpt_cma_alloc =1 ; }/* Lastly try successively smaller sizes from the page allocator */
Signature · 1 line
1.8.1.4
[PULL 23/41] KVM: PPC: BOOK3S: HV: Add mixed page-size support for guest
In reply to Alexander GrafFrom: "Aneesh Kumar K.V" <[email protected]>
On recent IBM Power CPUs, while the hashed page table is looked up using the page size from the segmentation hardware (i.e. the SLB), it is possible to have the HPT entry indicate a larger page size. Thus for example it is possible to put a 16MB page in a 64kB segment, but since the hash lookup is done using a 64kB page size, it may be necessary to put multiple entries in the HPT for a single 16MB page. This capability is called mixed page-size segment (MPSS). With MPSS, there are two relevant page sizes: the base page size, which is the size used in searching the HPT, and the actual page size, which is the size indicated in the HPT entry. [ Note that the actual page size is always >= base page size ].
We use "ibm,segment-page-sizes" device tree node to advertise the MPSS support to PAPR guest. The penc encoding indicates whether we support a specific combination of base page size and actual page size in the same segment. We also use the penc value in the LP encoding of HPTE entry.
This patch exposes MPSS support to KVM guest by advertising the feature via "ibm,segment-page-sizes". It also adds the necessary changes to decode the base page size and the actual page size correctly from the HPTE entry.
--- arch/powerpc/include/asm/kvm_book3s_64.h | 146 ++++++++++++++++++++++++++----- arch/powerpc/kvm/book3s_hv.c | 7 ++ 2 files changed, 130 insertions(+), 23 deletions(-)
arch/powerpc/include/asm/kvm_book3s_64.h +123 -23
@@ -77,34 +77,122 @@ static inline long try_lock_hpte(unsigned long *hpte, unsigned long bits)return old ==0 ; } +static inline int __hpte_actual_psize (unsigned int lp,int psize) +{ +int i, shift; +unsigned int mask; + +/* start from 1 ignoring MMU_PAGE_4K */ +for (i =1 ; i <MMU_PAGE_COUNT ; i++) { + +/* invalid penc */ +if (mmu_psize_defs[psize].penc[i] ==-1 ) +continue ; +/* +* encoding bits per actual page size +* PTE LP actual page size +* rrrr rrrz >=8KB +* rrrr rrzz >=16KB +* rrrr rzzz >=32KB +* rrrr zzzz >=64KB +* ....... +*/ + shift = mmu_psize_defs[i].shift -LP_SHIFT ; +if (shift >LP_BITS ) + shift =LP_BITS ; + mask = (1 << shift) -1 ; +if ((lp & mask) == mmu_psize_defs[psize].penc[i]) +return i; + } +return -1 ; +} +static inline unsigned long compute_tlbie_rb (unsigned long v,unsigned long r,unsigned long pte_index) { -unsigned long rb, va_low; +int b_psize, a_psize; +unsigned int penc; +unsigned long rb =0 , va_low, sllp; +unsigned int lp = (r >>LP_SHIFT ) & ((1 <<LP_BITS ) -1 ); + +if (!(v &HPTE_V_LARGE )) { +/* both base and actual psize is 4k */ + b_psize =MMU_PAGE_4K ; + a_psize =MMU_PAGE_4K ; + }else { +for (b_psize =0 ; b_psize <MMU_PAGE_COUNT ; b_psize++) { + +/* valid entries have a shift value */ +if (!mmu_psize_defs[b_psize].shift) +continue ; + a_psize =__hpte_actual_psize (lp, b_psize); +if (a_psize !=-1 ) +break ; + } + } +/* +* Ignore the top 14 bits of va +* v have top two bits covering segment size, hence move +* by 16 bits, Also clear the lower HPTE_V_AVPN_SHIFT (7) bits. +* AVA field in v also have the lower 23 bits ignored. +* For base page size 4K we need 14 .. 65 bits (so need to +* collect extra 11 bits) +* For others we need 14..14+i +*/ +/* This covers 14..54 bits of va*/ rb = (v & ~0x7fUL ) <<16 ;/* AVA field */ +/* +* AVA in v had cleared lower 23 bits. We need to derive +* that from pteg index +*/ va_low = pte_index >>3 ;if (v &HPTE_V_SECONDARY ) va_low = ~va_low; -/* xor vsid from AVA */ +/* +* get the vpn bits from va_low using reverse of hashing. +* In v we have va with 23 bits dropped and then left shifted +* HPTE_V_AVPN_SHIFT (7) bits. Now to find vsid we need +* right shift it with (SID_SHIFT - (23 - 7)) +*/ if (!(v &HPTE_V_1TB_SEG )) - va_low ^= v >>12 ; + va_low ^= v >> (SID_SHIFT -16 );else - va_low ^= v >>24 ; + va_low ^= v >> (SID_SHIFT_1T -16 ); va_low &=0x7ff ; -if (v &HPTE_V_LARGE ) { - rb |=1 ;/* L field */ -if (cpu_has_feature (CPU_FTR_ARCH_206 ) && - (r &0xff000 )) { -/* non-16MB large page, must be 64k */ -/* (masks depend on page size) */ - rb |=0x1000 ;/* page encoding in LP field */ - rb |= (va_low &0x7f ) <<16 ;/* 7b of VA in AVA/LP field */ - rb |= ((va_low <<4 ) &0xf0 );/* AVAL field (P7 doesn't seem to care) */ - } - }else { -/* 4kB page */ - rb |= (va_low &0x7ff ) <<12 ;/* remaining 11b of VA */ + +switch (b_psize) { +case MMU_PAGE_4K : + sllp = ((mmu_psize_defs[a_psize].sllp &SLB_VSID_L ) >>6 ) | + ((mmu_psize_defs[a_psize].sllp &SLB_VSID_LP ) >>4 ); + rb |= sllp <<5 ;/* AP field */ + rb |= (va_low &0x7ff ) <<12 ;/* remaining 11 bits of AVA */ +break ; +default : + { +int aval_shift; +/* +* remaining 7bits of AVA/LP fields +* Also contain the rr bits of LP +*/ + rb |= (va_low &0x7f ) <<16 ; +/* +* Now clear not needed LP bits based on actual psize +*/ + rb &= ~((1ul << mmu_psize_defs[a_psize].shift) -1 ); +/* +* AVAL field 58..77 - base_page_shift bits of va +* we have space for 58..64 bits, Missing bits should +* be zero filled. +1 is to take care of L bit shift +*/ + aval_shift =64 - (77 - mmu_psize_defs[b_psize].shift) +1 ; + rb |= ((va_low << aval_shift) &0xfe ); + + rb |=1 ;/* L field */ + penc = mmu_psize_defs[b_psize].penc[a_psize]; + rb |= penc <<12 ;/* LP field */ +break ; + } } rb |= (v >>54 ) &0x300 ;/* B field */ return rb;
@@ -112,14 +200,26 @@ static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,static inline unsigned long hpte_page_size (unsigned long h,unsigned long l) { +int size, a_psize; +/* Look at the 8 bit LP value */ +unsigned int lp = (l >>LP_SHIFT ) & ((1 <<LP_BITS ) -1 ); +/* only handle 4k, 64k and 16M pages for now */ if (!(h &HPTE_V_LARGE )) -return 1ul <<12 ;/* 4k page */ -if ((l &0xf000 ) ==0x1000 &&cpu_has_feature (CPU_FTR_ARCH_206 )) -return 1ul <<16 ;/* 64k page */ -if ((l &0xff000 ) ==0 ) -return 1ul <<24 ;/* 16M page */ -return 0 ;/* error */ +return 1ul <<12 ; +else { +for (size =0 ; size <MMU_PAGE_COUNT ; size++) { +/* valid entries have a shift value */ +if (!mmu_psize_defs[size].shift) +continue ; + + a_psize =__hpte_actual_psize (lp, size); +if (a_psize !=-1 ) +return 1ul << mmu_psize_defs[a_psize].shift; + } + + } +return 0 ; }static inline unsigned long hpte_rpn (unsigned long ptel,unsigned long psize)
arch/powerpc/kvm/book3s_hv.c +7 -0
@@ -1930,6 +1930,13 @@ static void kvmppc_add_seg_page_size(struct kvm_ppc_one_seg_page_size **sps,* support pte_enc here */ (*sps)->enc[0 ].pte_enc = def->penc[linux_psize]; +/* +* Add 16MB MPSS support if host supports it +*/ +if (linux_psize !=MMU_PAGE_16M && def->penc[MMU_PAGE_16M ] !=-1 ) { + (*sps)->enc[1 ].page_shift =24 ; + (*sps)->enc[1 ].pte_enc = def->penc[MMU_PAGE_16M ]; + } (*sps)++; }
Signature · 1 line
1.8.1.4
[PULL 24/41] KVM: PPC: Disable NX for old magic page using guests
In reply to Alexander GrafOld guests try to use the magic page, but map their trampoline code inside of an NX region.
Since we can't fix those old kernels, try to detect whether the guest is sane or not. If not, just disable NX functionality in KVM so that old guests at least work at all. For newer guests, add a bit that we can set to keep NX functionality available.
--- Documentation/virtual/kvm/ppc-pv.txt | 14 ++++++++++++++ arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc/include/uapi/asm/kvm_para.h | 6 ++++++ arch/powerpc/kvm/book3s_64_mmu.c | 3 +++ arch/powerpc/kvm/powerpc.c | 14 ++++++++++++-- 5 files changed, 36 insertions(+), 2 deletions(-)
Documentation/virtual/kvm/ppc-pv.txt +14 -0
@@ -94,10 +94,24 @@ a bitmap of available features inside the magic page. The following enhancements to the magic page are currently available: KVM_MAGIC_FEAT_SR Maps SR registers r/w in the magic page + KVM_MAGIC_FEAT_MAS0_TO_SPRG7 Maps MASn, ESR, PIR and high SPRGs For enhanced features in the magic page, please check for the existence of the feature before using them! +Magic page flags +======== + +In addition to features that indicate whether a host is capable of a particular +feature we also have a channel for a guest to tell the guest whether it's capable +of something. This is what we call "flags". + +Flags are passed to the host in the low 12 bits of the Effective Address. + +The following flags are currently available for a guest to expose: + + MAGIC_PAGE_FLAG_NOT_MAPPED_NX Guest handles NX bits correclty wrt magic page + MSR bits ====
arch/powerpc/include/asm/kvm_host.h +1 -0
@@ -631,6 +631,7 @@ struct kvm_vcpu_arch {#endif unsigned long magic_page_pa;/* phys addr to map the magic page to */ unsigned long magic_page_ea;/* effect. addr to map the magic page to */ +bool disable_kernel_nx;int irq_type;/* one of KVM_IRQ_* */ int irq_cpu_id;
arch/powerpc/include/uapi/asm/kvm_para.h +6 -0
@@ -82,10 +82,16 @@ struct kvm_vcpu_arch_shared {#define KVM_FEATURE_MAGIC_PAGE 1 +/* Magic page flags from host to guest */ +#define KVM_MAGIC_FEAT_SR (1 << 0)/* MASn, ESR, PIR, and high SPRGs */ #define KVM_MAGIC_FEAT_MAS0_TO_SPRG7 (1 << 1) +/* Magic page flags from guest to host */ + +#define MAGIC_PAGE_FLAG_NOT_MAPPED_NX (1 << 0) +#endif /* _UAPI__POWERPC_KVM_PARA_H__ */
arch/powerpc/kvm/book3s_64_mmu.c +3 -0
@@ -313,6 +313,9 @@ do_second: gpte->raddr = (r &HPTE_R_RPN & ~eaddr_mask) | (eaddr & eaddr_mask); gpte->page_size = pgsize; gpte->may_execute = ((r &HPTE_R_N ) ? false : true); +if (unlikely (vcpu->arch.disable_kernel_nx) && + !(kvmppc_get_msr (vcpu) &MSR_PR )) + gpte->may_execute = true; gpte->may_read = false; gpte->may_write = false;
arch/powerpc/kvm/powerpc.c +12 -2
@@ -177,8 +177,18 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) vcpu->arch.shared_big_endian = shared_big_endian;#endif - vcpu->arch.magic_page_pa = param1; - vcpu->arch.magic_page_ea = param2; +if (!(param2 &MAGIC_PAGE_FLAG_NOT_MAPPED_NX )) { +/* +* Older versions of the Linux magic page code had +* a bug where they would map their trampoline code +* NX. If that's the case, remove !PR NX capability. +*/ + vcpu->arch.disable_kernel_nx = true; +kvm_make_request (KVM_REQ_TLB_FLUSH , vcpu); + } + + vcpu->arch.magic_page_pa = param1 & ~0xfffULL ; + vcpu->arch.magic_page_ea = param2 & ~0xfffULL ; r2 =KVM_MAGIC_FEAT_SR |KVM_MAGIC_FEAT_MAS0_TO_SPRG7 ;
Signature · 1 line
1.8.1.4
[PULL 25/41] PPC: KVM: Make NX bit available with magic page
In reply to Alexander GrafBecause old kernels enable the magic page and then choke on NXed trampoline code we have to disable NX by default in KVM when we use the magic page.
However, since commit b18db0b8 we have successfully fixed that and can now leave NX enabled, so tell the hypervisor about this.
--- arch/powerpc/kernel/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/kvm.c +1 -1
@@ -417,7 +417,7 @@ static void kvm_map_magic_page(void *data)ulong out[8 ]; in[0 ] =KVM_MAGIC_PAGE ; - in[1 ] =KVM_MAGIC_PAGE ; + in[1 ] =KVM_MAGIC_PAGE |MAGIC_PAGE_FLAG_NOT_MAPPED_NX ;epapr_hypercall (in, out,KVM_HCALL_TOKEN (KVM_HC_PPC_MAP_MAGIC_PAGE ));
Signature · 1 line
1.8.1.4
[PULL 26/41] KVM: PPC: BOOK3S: Always use the saved DAR value
In reply to Alexander GrafFrom: "Aneesh Kumar K.V" <[email protected]>
Although it's optional, IBM POWER cpus always had DAR value set on alignment interrupt. So don't try to compute these values.
--- arch/powerpc/kvm/book3s_emulate.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/powerpc/kvm/book3s_emulate.c +7 -0
@@ -676,6 +676,12 @@ u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)ulong kvmppc_alignment_dar (struct kvm_vcpu *vcpu,unsigned int inst) { +#ifdef CONFIG_PPC_BOOK3S_64 +/* +* Linux's fix_alignment() assumes that DAR is valid, so can we +*/ +return vcpu->arch.fault_dar; +#else ulong dar =0 ;ulong ra =get_ra (inst);ulong rb =get_rb (inst);
@@ -700,4 +706,5 @@ ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst) }return dar; +#endif }
Signature · 1 line
1.8.1.4
[PULL 27/41] KVM: PPC: BOOK3S: Remove open coded make_dsisr in alignment handler
In reply to Alexander GrafFrom: "Aneesh Kumar K.V" <[email protected]>
Use make_dsisr instead of open coding it. This also have the added benefit of handling alignment interrupt on additional instructions.
--- arch/powerpc/include/asm/disassemble.h | 34 +++++++++++++++++++++++++++++ arch/powerpc/kernel/align.c | 34 +---------------------------- arch/powerpc/kvm/book3s_emulate.c | 39 +--------------------------------- 3 files changed, 36 insertions(+), 71 deletions(-)
arch/powerpc/include/asm/disassemble.h +34 -0
@@ -81,4 +81,38 @@ static inline unsigned int get_oc(u32 inst) {return (inst >>11 ) &0x7fff ; } + +#define IS_XFORM (inst) (get_op(inst) = 31) +#define IS_DSFORM (inst) (get_op(inst) >= 56) + +/* +* Create a DSISR value from the instruction +*/ +static inline unsigned make_dsisr (unsigned instr) +{ +unsigned dsisr; + + +/* bits 6:15 --> 22:31 */ + dsisr = (instr &0x03ff0000 ) >>16 ; + +if (IS_XFORM (instr)) { +/* bits 29:30 --> 15:16 */ + dsisr |= (instr &0x00000006 ) <<14 ; +/* bit 25 --> 17 */ + dsisr |= (instr &0x00000040 ) <<8 ; +/* bits 21:24 --> 18:21 */ + dsisr |= (instr &0x00000780 ) <<3 ; + }else { +/* bit 5 --> 17 */ + dsisr |= (instr &0x04000000 ) >>12 ; +/* bits 1: 4 --> 18:21 */ + dsisr |= (instr &0x78000000 ) >>17 ; +/* bits 30:31 --> 12:13 */ +if (IS_DSFORM (instr)) + dsisr |= (instr &0x00000003 ) <<18 ; + } + +return dsisr; +}#endif /* __ASM_PPC_DISASSEMBLE_H__ */
arch/powerpc/kernel/align.c +1 -33
@@ -25,14 +25,13 @@#include <asm/cputable.h> #include <asm/emulated_ops.h> #include <asm/switch_to.h> +#include <asm/disassemble.h> struct aligninfo {unsigned char len;unsigned char flags; }; -#define IS_XFORM (inst) (((inst) >> 26) = 31) -#define IS_DSFORM (inst) (((inst) >> 26) >= 56)#define INVALID { 0, 0 }
@@ -192,37 +191,6 @@ static struct aligninfo aligninfo[128] = { };/* -* Create a DSISR value from the instruction -*/ -static inline unsigned make_dsisr (unsigned instr) -{ -unsigned dsisr; - - -/* bits 6:15 --> 22:31 */ - dsisr = (instr &0x03ff0000 ) >>16 ; - -if (IS_XFORM (instr)) { -/* bits 29:30 --> 15:16 */ - dsisr |= (instr &0x00000006 ) <<14 ; -/* bit 25 --> 17 */ - dsisr |= (instr &0x00000040 ) <<8 ; -/* bits 21:24 --> 18:21 */ - dsisr |= (instr &0x00000780 ) <<3 ; - }else { -/* bit 5 --> 17 */ - dsisr |= (instr &0x04000000 ) >>12 ; -/* bits 1: 4 --> 18:21 */ - dsisr |= (instr &0x78000000 ) >>17 ; -/* bits 30:31 --> 12:13 */ -if (IS_DSFORM (instr)) - dsisr |= (instr &0x00000003 ) <<18 ; - } - -return dsisr; -} - -/* * The dcbz (data cache block zero) instruction * gives an alignment fault if used on non-cacheable * memory. We handle the fault mainly for the
arch/powerpc/kvm/book3s_emulate.c +1 -38
@@ -634,44 +634,7 @@ unprivileged:u32 kvmppc_alignment_dsisr (struct kvm_vcpu *vcpu,unsigned int inst) { -u32 dsisr =0 ; - -/* -* This is what the spec says about DSISR bits (not mentioned = 0): -* -* 12:13 [DS] Set to bits 30:31 -* 15:16 [X] Set to bits 29:30 -* 17 [X] Set to bit 25 -* [D/DS] Set to bit 5 -* 18:21 [X] Set to bits 21:24 -* [D/DS] Set to bits 1:4 -* 22:26 Set to bits 6:10 (RT/RS/FRT/FRS) -* 27:31 Set to bits 11:15 (RA) -*/ - -switch (get_op (inst)) { -/* D-form */ -case OP_LFS : -case OP_LFD : -case OP_STFD : -case OP_STFS : - dsisr |= (inst >>12 ) &0x4000 ;/* bit 17 */ - dsisr |= (inst >>17 ) &0x3c00 ;/* bits 18:21 */ -break ; -/* X-form */ -case 31 : - dsisr |= (inst <<14 ) &0x18000 ;/* bits 15:16 */ - dsisr |= (inst <<8 ) &0x04000 ;/* bit 17 */ - dsisr |= (inst <<3 ) &0x03c00 ;/* bits 18:21 */ -break ; -default : -printk (KERN_INFO "KVM: Unaligned instruction 0x%x\n" , inst); -break ; - } - - dsisr |= (inst >>16 ) &0x03ff ;/* bits 22:31 */ - -return dsisr; +return make_dsisr (inst); }ulong kvmppc_alignment_dar (struct kvm_vcpu *vcpu,unsigned int inst)
Signature · 1 line
1.8.1.4
[PULL 28/41] PPC: ePAPR: Fix hypercall on LE guest
In reply to Alexander GrafWe get an array of instructions from the hypervisor via device tree that we write into a buffer that gets executed whenever we want to make an ePAPR compliant hypercall.
However, the hypervisor passes us these instructions in BE order which we have to manually convert to LE when we want to run them in LE mode.
With this fixup in place, I can successfully run LE kernels with KVM PV enabled on PR KVM.
--- arch/powerpc/kernel/epapr_paravirt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/kernel/epapr_paravirt.c +3 -2
@@ -47,9 +47,10 @@ static int __init early_init_dt_scan_epapr(unsigned long node,return -1 ;for (i =0 ; i < (len /4 ); i++) { -patch_instruction (epapr_hypercall_start + i, insts[i]); +u32 inst =be32_to_cpu (insts[i]); +patch_instruction (epapr_hypercall_start + i, inst);#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -patch_instruction (epapr_ev_idle_start + i, insts[i]); +patch_instruction (epapr_ev_idle_start + i, inst);#endif }
Signature · 1 line
1.8.1.4
[PULL 29/41] KVM: PPC: Graciously fail broken LE hypercalls
In reply to Alexander GrafThere are LE Linux guests out there that don't handle hypercalls correctly. Instead of interpreting the instruction stream from device tree as big endian they assume it's a little endian instruction stream and fail.
When we see an illegal instruction from such a byte reversed instruction stream, bail out graciously and just declare every hcall as error.
--- arch/powerpc/kvm/book3s_emulate.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
arch/powerpc/kvm/book3s_emulate.c +17 -0
@@ -94,8 +94,25 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,int rs =get_rs (inst);int ra =get_ra (inst);int rb =get_rb (inst); +u32 inst_sc =0x44000002 ;switch (get_op (inst)) { +case 0 : + emulated =EMULATE_FAIL ; +if ((kvmppc_get_msr (vcpu) &MSR_LE ) && + (inst ==swab32 (inst_sc))) { +/* +* This is the byte reversed syscall instruction of our +* hypercall handler. Early versions of LE Linux didn't +* swap the instructions correctly and ended up in +* illegal instructions. +* Just always fail hypercalls on these broken systems. +*/ +kvmppc_set_gpr (vcpu,3 ,EV_UNIMPLEMENTED ); +kvmppc_set_pc (vcpu,kvmppc_get_pc (vcpu) +4 ); + emulated =EMULATE_DONE ; + } +break ;case 19 :switch (get_xop (inst)) {case OP_19_XOP_RFID :
Signature · 1 line
1.8.1.4
[PULL 30/41] KVM: PPC: MPIC: Reset IRQ source private members
In reply to Alexander GrafWhen we reset the in-kernel MPIC controller, we forget to reset some hidden state such as destmask and output. This state is usually set when the guest writes to the IDR register for a specific IRQ line.
To make sure we stay in sync and don't forget hidden state, treat reset of the IDR register as a simple write of the IDR register. That automatically updates all the hidden state as well.
--- arch/powerpc/kvm/mpic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/kvm/mpic.c +4 -1
@@ -126,6 +126,8 @@ static int openpic_cpu_write_internal(void *opaque, gpa_t addr, u32 val, int idx);static int openpic_cpu_read_internal (void *opaque,gpa_t addr,u32 *ptr,int idx); +static inline void write_IRQreg_idr (struct openpic *opp,int n_IRQ, +uint32_t val);enum irq_type {IRQ_TYPE_NORMAL =0 ,
@@ -528,7 +530,6 @@ static void openpic_reset(struct openpic *opp)/* Initialise IRQ sources */ for (i =0 ; i < opp->max_irq; i++) { opp->src[i].ivpr = opp->ivpr_reset; - opp->src[i].idr = opp->idr_reset;switch (opp->src[i].type) {case IRQ_TYPE_NORMAL :
@@ -543,6 +544,8 @@ static void openpic_reset(struct openpic *opp)case IRQ_TYPE_FSLSPECIAL :break ; } + +write_IRQreg_idr (opp, i, opp->idr_reset); }/* Initialise IRQ destinations */ for (i =0 ; i <MAX_CPU ; i++) {
Signature · 1 line
1.8.1.4
[PULL 31/41] KVM: PPC: Add CAP to indicate hcall fixes
In reply to Alexander GrafWe worked around some nasty KVM magic page hcall breakages:
1) NX bit not honored, so ignore NX when we detect it
2) LE guests swizzle hypercall instruction
Without these fixes in place, there's no way it would make sense to expose kvm hypercalls to a guest. Chances are immensely high it would trip over and break.
So add a new CAP that gives user space a hint that we have workarounds for the bugs above in place. It can use those as hint to disable PV hypercalls when the guest CPU is anything POWER7 or higher and the host does not have fixes in place.
--- arch/powerpc/kvm/powerpc.c | 1 + include/uapi/linux/kvm.h | 1 + 2 files changed, 2 insertions(+)
arch/powerpc/kvm/powerpc.c +1 -0
@@ -416,6 +416,7 @@ int kvm_dev_ioctl_check_extension(long ext)case KVM_CAP_SPAPR_TCE :case KVM_CAP_PPC_ALLOC_HTAB :case KVM_CAP_PPC_RTAS : +case KVM_CAP_PPC_FIXUP_HCALL :#ifdef CONFIG_KVM_XICS case KVM_CAP_IRQ_XICS :#endif
include/uapi/linux/kvm.h +1 -0
@@ -748,6 +748,7 @@ struct kvm_ppc_smmu_info {#define KVM_CAP_S390_IRQCHIP 99#define KVM_CAP_IOEVENTFD_NO_LENGTH 100#define KVM_CAP_VM_ATTRIBUTES 101 +#define KVM_CAP_PPC_FIXUP_HCALL 102#ifdef KVM_CAP_IRQ_ROUTING
Signature · 1 line
1.8.1.4
[PULL 32/41] KVM: PPC: Book3S: Add ONE_REG register names that were missed
In reply to Alexander GrafFrom: Paul Mackerras <[email protected]>
Commit 3b7834743f9 ("KVM: PPC: Book3S HV: Reserve POWER8 space in get/set_one_reg") added definitions for several KVM_REG_PPC_* symbols but missed adding some to api.txt. This adds them.
--- Documentation/virtual/kvm/api.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/virtual/kvm/api.txt +5 -0
@@ -1794,6 +1794,11 @@ registers, find a list below: PPC | KVM_REG_PPC_MMCR0 | 64 PPC | KVM_REG_PPC_MMCR1 | 64 PPC | KVM_REG_PPC_MMCRA | 64 + PPC | KVM_REG_PPC_MMCR2 | 64 + PPC | KVM_REG_PPC_MMCRS | 64 + PPC | KVM_REG_PPC_SIAR | 64 + PPC | KVM_REG_PPC_SDAR | 64 + PPC | KVM_REG_PPC_SIER | 64 PPC | KVM_REG_PPC_PMC1 | 32 PPC | KVM_REG_PPC_PMC2 | 32 PPC | KVM_REG_PPC_PMC3 | 32
Signature · 1 line
1.8.1.4
[PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
In reply to Alexander GrafFrom: Paul Mackerras <[email protected]>
Commit b005255e12a3 ("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs") added a definition of KVM_REG_PPC_WORT with the same register number as the existing KVM_REG_PPC_VRSAVE (though in fact the definitions are not identical because of the different register sizes.)
For clarity, this moves KVM_REG_PPC_WORT to the next unused number, and also adds it to api.txt.
--- Documentation/virtual/kvm/api.txt | 1 + arch/powerpc/include/uapi/asm/kvm.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
Documentation/virtual/kvm/api.txt +1 -0
@@ -1873,6 +1873,7 @@ registers, find a list below: PPC | KVM_REG_PPC_PPR | 64 PPC | KVM_REG_PPC_ARCH_COMPAT 32 PPC | KVM_REG_PPC_DABRX | 32 + PPC | KVM_REG_PPC_WORT | 64 PPC | KVM_REG_PPC_TM_GPR0 | 64 ... PPC | KVM_REG_PPC_TM_GPR31 | 64
arch/powerpc/include/uapi/asm/kvm.h +1 -1
@@ -545,7 +545,6 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_TCSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb1)#define KVM_REG_PPC_PID (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb2)#define KVM_REG_PPC_ACOP (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb3) -#define KVM_REG_PPC_WORT (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb4)#define KVM_REG_PPC_VRSAVE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb4)#define KVM_REG_PPC_LPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5)
@@ -555,6 +554,7 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_ARCH_COMPAT (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb7)#define KVM_REG_PPC_DABRX (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb8) +#define KVM_REG_PPC_WORT (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb9)/* Transactional Memory checkpointed state: * This is all GPRs, all VSX regs and a subset of SPRs
Signature · 1 line
1.8.1.4
Paolo Bonzini
maintainerRe: [PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
Il 30/05/2014 14:42, Alexander Graf ha scritto:
Quoted 42 lines
From: Paul Mackerras <[email protected]>
Commit
b005255e12a3("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs") added a definition ofKVM_REG_PPC_WORTwith the same register number as the existingKVM_REG_PPC_VRSAVE(though in fact the definitions are not identical because of the different register sizes.)For clarity, this moves
KVM_REG_PPC_WORTto the next unused number, and also adds it to api.txt.Signed-off-by Paul Mackerras <[email protected]>Signed-off-by Alexander Graf <[email protected]>--- Documentation/virtual/kvm/api.txt | 1 + arch/powerpc/include/uapi/asm/kvm.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)Documentation/virtual/kvm/api.txt +1
-0@@ -1873,6 +1873,7 @@ registers, find a list below: PPC | KVM_REG_PPC_PPR | 64 PPC | KVM_REG_PPC_ARCH_COMPAT 32 PPC | KVM_REG_PPC_DABRX | 32 + PPC | KVM_REG_PPC_WORT | 64 PPC | KVM_REG_PPC_TM_GPR0 | 64 PPC | KVM_REG_PPC_TM_GPR31 | 64arch/powerpc/include/uapi/asm/kvm.h +0
-1@@ -545,7 +545,6 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_TCSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb1)#define KVM_REG_PPC_PID (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb2)#define KVM_REG_PPC_ACOP (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb3) -#define KVM_REG_PPC_WORT (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb4)#define KVM_REG_PPC_VRSAVE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb4)#define KVM_REG_PPC_LPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5)
arch/powerpc/include/uapi/asm/kvm.h struct kvm_get_htab_header { · line 557
Quoted 4 lines
arch/powerpc/include/uapi/asm/kvm.h +1
-0@@ -555,6 +554,7 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_ARCH_COMPAT (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb7)#define KVM_REG_PPC_DABRX (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb8) +#define KVM_REG_PPC_WORT (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb9)
This is an ABI break, this symbol was added in 3.14. I think I should revert this. Can you convince me otherwise?
Paolo
Re: [PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
Quoted 46 lines · Paolo Bonzini
Il 30/05/2014 14:42, Alexander Graf ha scritto:
Quoted 45 lines
From: Paul Mackerras <[email protected]>
Commit
b005255e12a3("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs") added a definition ofKVM_REG_PPC_WORTwith the same register number as the existingKVM_REG_PPC_VRSAVE(though in fact the definitions are not identical because of the different register sizes.)For clarity, this moves
KVM_REG_PPC_WORTto the next unused number, and also adds it to api.txt.Signed-off-by Paul Mackerras <[email protected]>Signed-off-by Alexander Graf <[email protected]>--- Documentation/virtual/kvm/api.txt | 1 + arch/powerpc/include/uapi/asm/kvm.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)Documentation/virtual/kvm/api.txt +1
-0@@ -1873,6 +1873,7 @@ registers, find a list below: PPC | KVM_REG_PPC_PPR | 64 PPC | KVM_REG_PPC_ARCH_COMPAT 32 PPC | KVM_REG_PPC_DABRX | 32 + PPC | KVM_REG_PPC_WORT | 64 PPC | KVM_REG_PPC_TM_GPR0 | 64 PPC | KVM_REG_PPC_TM_GPR31 | 64arch/powerpc/include/uapi/asm/kvm.h +0
-1@@ -545,7 +545,6 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_TCSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb1)#define KVM_REG_PPC_PID (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb2)#define KVM_REG_PPC_ACOP (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb3) -#define KVM_REG_PPC_WORT (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb4)#define KVM_REG_PPC_VRSAVE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb4)#define KVM_REG_PPC_LPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5)@@ -555,6 +554,7 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_ARCH_COMPAT (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb7)
Quoted 4 lines
arch/powerpc/include/uapi/asm/kvm.h struct kvm_get_htab_header { · line 557
Quoted 2 lines
arch/powerpc/include/uapi/asm/kvm.h +1
-0#define KVM_REG_PPC_DABRX (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb8) +#define KVM_REG_PPC_WORT (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb9)This is an ABI break, this symbol was added in 3.14. I think I should revert this. Can you convince me otherwise?
There's nothing bad happening with the change. Newer user space won't be able to read WORT on older kernels, but there were more things broken that just WORT for POWER8 support there ;).
And user space build with new headers running on an old kernel won't find the register, which is OK.
I couldn't find any combination where it's really a problem.
Alex
Paolo Bonzini
maintainerRe: [PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
Il 30/05/2014 17:53, Alexander Graf ha scritto:
Quoted 9 lines
Quoted 2 lines
This is an ABI break, this symbol was added in 3.14. I think I should revert this. Can you convince me otherwise?
There's nothing bad happening with the change. Newer user space won't be able to read WORT on older kernels, but there were more things broken that just WORT for POWER8 support there ;).
And user space build with new headers running on an old kernel won't find the register, which is OK.
Would new userspace with old kernel be able to detect that POWER8 support isn't quite complete?
Paolo
Re: [PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
Quoted 8 lines · Paolo Bonzini
Il 30/05/2014 17:53, Alexander Graf ha scritto:
Quoted 7 lines
Quoted 2 lines
This is an ABI break, this symbol was added in 3.14. I think I should revert this. Can you convince me otherwise?
There's nothing bad happening with the change. Newer user space won't be able to read WORT on older kernels, but there were more things broken that just WORT for POWER8 support there ;).
Quoted 5 lines
Quoted 2 lines
And user space build with new headers running on an old kernel won't find the register, which is OK.
Would new userspace with old kernel be able to detect that POWER8 support isn't quite complete?
It couldn't, no. It would try to run a guest - if it happens to work we're lucky ;). Even then the only thing that would remotely be affected by that one_reg rename is live migration (which just got a few more fixes in this pull request).
Alex
Paolo Bonzini
maintainerRe: [PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
Il 30/05/2014 17:58, Alexander Graf ha scritto:
Quoted 6 lines
Quoted 3 lines
Would new userspace with old kernel be able to detect that POWER8 support isn't quite complete?
It couldn't, no. It would try to run a guest - if it happens to work we're lucky ;).
That's why I'm considering a revert.
Quoted 3 lines
Even then the only thing that would remotely be affected by that
one_regrename is live migration (which just got a few more fixes in this pull request).
Doesn't "info cpus" also do get/set one_reg? What happens if it returns EINVAL? Also, reset should certainly try to write all registers, what happens if one is missed.
Beyond the particular case of WORT, I'd just like to point out that uapi/ changes need even more scrutiny from maintainers than usual. I don't know exactly what checks Linus makes in my pull requests, but uapi/ is at the top of the list of things he might look at, right after the diffstat. :)
Paolo
Re: [PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
Quoted 8 lines · Paolo Bonzini
Il 30/05/2014 17:58, Alexander Graf ha scritto:
Quoted 6 lines
Quoted 3 lines
Would new userspace with old kernel be able to detect that POWER8 support isn't quite complete?
It couldn't, no. It would try to run a guest - if it happens to work we're lucky ;).
Quoted 7 lines
That's why I'm considering a revert.
Quoted 3 lines
Even then the only thing that would remotely be affected by that
one_regrename is live migration (which just got a few more fixes in this pull request).Doesn't "info cpus" also do get/set
one_reg?
Yeah, but WORT is not important enough to get listed.
Quoted 1 line
What happens if it returns EINVAL? Also, reset should certainly try to write all registers, what happens if one is missed.
If it returns EINVAL we just ignore the register.
Quoted 2 lines
Beyond the particular case of WORT, I'd just like to point out that uapi/ changes need even more scrutiny from maintainers than usual. I don't know exactly what checks Linus makes in my pull requests, but uapi/ is at the top of the list of things he might look at, right after the diffstat. :)
Consider that ONE_REG as experimental flagged :). Really, I am as concerned as you are on ABI breakages, but in this case it's not worth it. I'm not even sure any guest uses WORT at all. Linux doesn't seem to.
Alex
Paolo Bonzini
maintainerRe: [PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
Il 30/05/2014 18:08, Alexander Graf ha scritto:
Quoted 4 lines
Quoted 2 lines
What happens if it returns EINVAL? Also, reset should certainly try to write all registers, what happens if one is missed.
If it returns EINVAL we just ignore the register.
I wonder if it's the right thing to do. You remember how you were bitten by less-than-sensible error handling in the x86 kvm_arch_put_registers.
Quoted 9 lines
Quoted 5 lines
Beyond the particular case of WORT, I'd just like to point out that uapi/ changes need even more scrutiny from maintainers than usual. I don't know exactly what checks Linus makes in my pull requests, but uapi/ is at the top of the list of things he might look at, right after the diffstat. :)
Consider that
ONE_REGas experimental flagged :). Really, I am as concerned as you are on ABI breakages, but in this case it's not worth it. I'm not even sure any guest uses WORT at all. Linux doesn't seem to.
Fair enough... for this time only!...
Paolo
Re: [PULL 33/41] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number
Quoted 7 lines · Paolo Bonzini
Il 30/05/2014 18:08, Alexander Graf ha scritto:
Quoted 4 lines
Quoted 2 lines
What happens if it returns EINVAL? Also, reset should certainly try to write all registers, what happens if one is missed.
If it returns EINVAL we just ignore the register.
I wonder if it's the right thing to do. You remember how you were bitten by less-than-sensible error handling in the x86
kvm_arch_put_registers.
Yeah, I think we'll have to do a flag day as of which we declare PPC as a first class supported citizen. At that point we'll have compat machine types and start to do more intense error checking.
Alex
[PULL 34/41] KVM: PPC: Book3S HV: Fix check for running inside guest in global_invalidates()
In reply to Alexander GrafFrom: Paul Mackerras <[email protected]>
The global_invalidates() function contains a check that is intended to tell whether we are currently executing in the context of a hypercall issued by the guest. The reason is that the optimization of using a local TLB invalidate instruction is only valid in that context. The check was testing local_paca->kvm_hstate.kvm_vcore, which gets set when entering the guest but no longer gets cleared when exiting the guest. To fix this, we use the kvm_vcpu field instead, which does get cleared when exiting the guest, by the kvmppc_release_hwthread() calls inside kvmppc_run_core().
The effect of having the check wrong was that when kvmppc_do_h_remove() got called from htab_write() on the destination machine during a migration, it cleared the current cpu's bit in kvm->arch.need_tlb_flush. This meant that when the guest started running in the destination VM, it may miss out on doing a complete TLB flush, and therefore may end up using stale TLB entries from a previous guest that used the same LPID value.
This should make migration more reliable.
--- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_hv_rm_mmu.c +2 -1
@@ -42,13 +42,14 @@ static int global_invalidates(struct kvm *kvm, unsigned long flags)/* * If there is only one vcore, and it's currently running, +* as indicated by local_paca->kvm_hstate.kvm_vcpu being set, * we can use tlbiel as long as we mark all other physical * cores as potentially having stale TLB entries for this lpid. * If we're not using MMU notifiers, we never take pages away * from the guest, so we can use tlbiel if requested. * Otherwise, don't use tlbiel. */ -if (kvm->arch.online_vcores =1 && local_paca->kvm_hstate.kvm_vcore) +if (kvm->arch.online_vcores =1 && local_paca->kvm_hstate.kvm_vcpu) global =0 ;else if (kvm->arch.using_mmu_notifiers) global =1 ;
Signature · 1 line
1.8.1.4
[PULL 35/41] KVM: PPC: Book3S HV: Put huge-page HPTEs in rmap chain for base address
In reply to Alexander GrafFrom: Paul Mackerras <[email protected]>
Currently, when a huge page is faulted in for a guest, we select the rmap chain to insert the HPTE into based on the guest physical address that the guest tried to access. Since there is an rmap chain for each system page, there are many rmap chains for the area covered by a huge page (e.g. 256 for 16MB pages when PAGE_SIZE = 64kB), and the huge-page HPTE could end up in any one of them.
For consistency, and to make the huge-page HPTEs easier to find, we now put huge-page HPTEs in the rmap chain corresponding to the base address of the huge page.
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +13 -2
@@ -585,6 +585,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,struct kvm *kvm = vcpu->kvm;unsigned long *hptep, hpte[3 ], r;unsigned long mmu_seq, psize, pte_size; +unsigned long gpa_base, gfn_base;unsigned long gpa, gfn, hva, pfn;struct kvm_memory_slot *memslot;unsigned long *rmap;
@@ -623,7 +624,9 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,/* Translate the logical address and get the page */ psize =hpte_page_size (hpte[0 ], r); - gpa = (r &HPTE_R_RPN & ~(psize -1 )) | (ea & (psize -1 )); + gpa_base = r &HPTE_R_RPN & ~(psize -1 ); + gfn_base = gpa_base >>PAGE_SHIFT ; + gpa = gpa_base | (ea & (psize -1 )); gfn = gpa >>PAGE_SHIFT ; memslot =gfn_to_memslot (kvm, gfn);
@@ -635,6 +638,13 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,if (!kvm->arch.using_mmu_notifiers)return -EFAULT ;/* should never get here */ +/* +* This should never happen, because of the slot_is_aligned() +* check in kvmppc_do_h_enter(). +*/ +if (gfn_base < memslot->base_gfn) +return -EFAULT ; +/* used to check for invalidations in progress */ mmu_seq = kvm->mmu_notifier_seq;smp_rmb ();
@@ -727,7 +737,8 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, goto out_unlock; hpte[0 ] = (hpte[0 ] & ~HPTE_V_ABSENT ) |HPTE_V_VALID ; - rmap = &memslot->arch.rmap[gfn - memslot->base_gfn]; +/* Always put the HPTE in the rmap chain for the page base address */ + rmap = &memslot->arch.rmap[gfn_base - memslot->base_gfn];lock_rmap (rmap);/* Check if we might have been invalidated; let the guest retry if so */
Signature · 1 line
1.8.1.4
[PULL 36/41] KVM: PPC: Book3S HV: Fix dirty map for hugepages
In reply to Alexander GrafFrom: Alexey Kardashevskiy <[email protected]>
The dirty map that we construct for the KVM_GET_DIRTY_LOG ioctl has one bit per system page (4K/64K). Currently, we only set one bit in the map for each HPT entry with the Change bit set, even if the HPT is for a large page (e.g., 16MB). Userspace then considers only the first system page dirty, though in fact the guest may have modified anywhere in the large page.
To fix this, we make kvm_test_clear_dirty() return the actual number of pages that are dirty (and rename it to kvm_test_clear_dirty_npages() to emphasize that that's what it returns). In kvmppc_hv_get_dirty_log() we then set that many bits in the dirty map.
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +24 -9
@@ -1060,22 +1060,27 @@ void kvm_set_spte_hva_hv(struct kvm *kvm, unsigned long hva, pte_t pte)kvm_handle_hva (kvm, hva, kvm_unmap_rmapp); } -static int kvm_test_clear_dirty (struct kvm *kvm,unsigned long *rmapp) +/* +* Returns the number of system pages that are dirty. +* This can be more than 1 if we find a huge-page HPTE. +*/ +static int kvm_test_clear_dirty_npages (struct kvm *kvm,unsigned long *rmapp) {struct revmap_entry *rev = kvm->arch.revmap;unsigned long head, i, j; +unsigned long n;unsigned long *hptep; -int ret =0 ; +int npages_dirty =0 ; retry:lock_rmap (rmapp);if (*rmapp &KVMPPC_RMAP_CHANGED ) { *rmapp &= ~KVMPPC_RMAP_CHANGED ; - ret =1 ; + npages_dirty =1 ; }if (!(*rmapp &KVMPPC_RMAP_PRESENT )) {unlock_rmap (rmapp); -return ret; +return npages_dirty; } i = head = *rmapp &KVMPPC_RMAP_INDEX ;
@@ -1106,13 +1111,16 @@ static int kvm_test_clear_dirty(struct kvm *kvm, unsigned long *rmapp) rev[i].guest_rpte |=HPTE_R_C ;note_hpte_modification (kvm, &rev[i]); } - ret =1 ; + n =hpte_page_size (hptep[0 ], hptep[1 ]); + n = (n +PAGE_SIZE -1 ) >>PAGE_SHIFT ; +if (n > npages_dirty) + npages_dirty = n; } hptep[0 ] &= ~HPTE_V_HVLOCK ; }while ((i = j) != head);unlock_rmap (rmapp); -return ret; +return npages_dirty; } static void harvest_vpa_dirty(struct kvmppc_vpa *vpa,
@@ -1136,15 +1144,22 @@ static void harvest_vpa_dirty(struct kvmppc_vpa *vpa,long kvmppc_hv_get_dirty_log (struct kvm *kvm,struct kvm_memory_slot *memslot,unsigned long *map) { -unsigned long i; +unsigned long i, j;unsigned long *rmapp;struct kvm_vcpu *vcpu;preempt_disable (); rmapp = memslot->arch.rmap;for (i =0 ; i < memslot->npages; ++i) { -if (kvm_test_clear_dirty (kvm, rmapp) && map) -__set_bit_le (i, map); +int npages =kvm_test_clear_dirty_npages (kvm, rmapp); +/* +* Note that if npages > 0 then i must be a multiple of npages, +* since we always put huge-page HPTEs in the rmap chain +* corresponding to their page base address. +*/ +if (npages && map) +for (j = i; npages; ++j, --npages) +__set_bit_le (j, map); ++rmapp; }
Signature · 1 line
1.8.1.4
[PULL 37/41] KVM: PPC: Book3S HV: Make sure we don't miss dirty pages
In reply to Alexander GrafFrom: Paul Mackerras <[email protected]>
Current, when testing whether a page is dirty (when constructing the bitmap for the KVM_GET_DIRTY_LOG ioctl), we test the C (changed) bit in the HPT entries mapping the page, and if it is 0, we consider the page to be clean. However, the Power ISA doesn't require processors to set the C bit to 1 immediately when writing to a page, and in fact allows them to delay the writeback of the C bit until they receive a TLB invalidation for the page. Thus it is possible that the page could be dirty and we miss it.
Now, if there are vcpus running, this is not serious since the collection of the dirty log is racy already - some vcpu could dirty the page just after we check it. But if there are no vcpus running we should return definitive results, in case we are in the final phase of migrating the guest.
Also, if the permission bits in the HPTE don't allow writing, then we know that no CPU can set C. If the HPTE was previously writable and the page was modified, any C bit writeback would have been flushed out by the tlbie that we did when changing the HPTE to read-only.
Otherwise we need to do a TLB invalidation even if the C bit is 0, and then check the C bit.
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 47 +++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +37 -10
@@ -1060,6 +1060,11 @@ void kvm_set_spte_hva_hv(struct kvm *kvm, unsigned long hva, pte_t pte)kvm_handle_hva (kvm, hva, kvm_unmap_rmapp); } +static int vcpus_running (struct kvm *kvm) +{ +return atomic_read (&kvm->arch.vcpus_running) !=0 ; +} +/* * Returns the number of system pages that are dirty. * This can be more than 1 if we find a huge-page HPTE.
@@ -1069,6 +1074,7 @@ static int kvm_test_clear_dirty_npages(struct kvm *kvm, unsigned long *rmapp)struct revmap_entry *rev = kvm->arch.revmap;unsigned long head, i, j;unsigned long n; +unsigned long v, r;unsigned long *hptep;int npages_dirty =0 ;
@@ -1088,7 +1094,22 @@ static int kvm_test_clear_dirty_npages(struct kvm *kvm, unsigned long *rmapp) hptep = (unsigned long *) (kvm->arch.hpt_virt + (i <<4 )); j = rev[i].forw; -if (!(hptep[1 ] &HPTE_R_C )) +/* +* Checking the C (changed) bit here is racy since there +* is no guarantee about when the hardware writes it back. +* If the HPTE is not writable then it is stable since the +* page can't be written to, and we would have done a tlbie +* (which forces the hardware to complete any writeback) +* when making the HPTE read-only. +* If vcpus are running then this call is racy anyway +* since the page could get dirtied subsequently, so we +* expect there to be a further call which would pick up +* any delayed C bit writeback. +* Otherwise we need to do the tlbie even if C=0 in +* order to pick up any delayed writeback of C. +*/ +if (!(hptep[1 ] &HPTE_R_C ) && + (!hpte_is_writable (hptep[1 ]) ||vcpus_running (kvm)))continue ;if (!try_lock_hpte (hptep,HPTE_V_HVLOCK )) {
@@ -1100,23 +1121,29 @@ static int kvm_test_clear_dirty_npages(struct kvm *kvm, unsigned long *rmapp) }/* Now check and modify the HPTE */ -if ((hptep[0 ] &HPTE_V_VALID ) && (hptep[1 ] &HPTE_R_C )) { -/* need to make it temporarily absent to clear C */ - hptep[0 ] |=HPTE_V_ABSENT ; -kvmppc_invalidate_hpte (kvm, hptep, i); - hptep[1 ] &= ~HPTE_R_C ; -eieio (); - hptep[0 ] = (hptep[0 ] & ~HPTE_V_ABSENT ) |HPTE_V_VALID ; +if (!(hptep[0 ] &HPTE_V_VALID )) +continue ; + +/* need to make it temporarily absent so C is stable */ + hptep[0 ] |=HPTE_V_ABSENT ; +kvmppc_invalidate_hpte (kvm, hptep, i); + v = hptep[0 ]; + r = hptep[1 ]; +if (r &HPTE_R_C ) { + hptep[1 ] = r & ~HPTE_R_C ;if (!(rev[i].guest_rpte &HPTE_R_C )) { rev[i].guest_rpte |=HPTE_R_C ;note_hpte_modification (kvm, &rev[i]); } - n =hpte_page_size (hptep[0 ], hptep[1 ]); + n =hpte_page_size (v, r); n = (n +PAGE_SIZE -1 ) >>PAGE_SHIFT ;if (n > npages_dirty) npages_dirty = n; +eieio (); } - hptep[0 ] &= ~HPTE_V_HVLOCK ; + v &= ~(HPTE_V_ABSENT |HPTE_V_HVLOCK ); + v |=HPTE_V_VALID ; + hptep[0 ] = v; }while ((i = j) != head);unlock_rmap (rmapp);
Signature · 1 line
1.8.1.4
[PULL 38/41] KVM: PPC: Book3S HV: Work around POWER8 performance monitor bugs
In reply to Alexander GrafFrom: Paul Mackerras <[email protected]>
This adds workarounds for two hardware bugs in the POWER8 performance monitor unit (PMU), both related to interrupt generation. The effect of these bugs is that PMU interrupts can get lost, leading to tools such as perf reporting fewer counts and samples than they should.
The first bug relates to the PMAO (perf. mon. alert occurred) bit in MMCR0; setting it should cause an interrupt, but doesn't. The other bug relates to the PMAE (perf. mon. alert enable) bit in MMCR0. Setting PMAE when a counter is negative and counter negative conditions are enabled to cause alerts should cause an alert, but doesn't.
The workaround for the first bug is to create conditions where a counter will overflow, whenever we are about to restore a MMCR0 value that has PMAO set (and PMAO_SYNC clear). The workaround for the second bug is to freeze all counters using MMCR2 before reading MMCR0.
--- arch/powerpc/include/asm/reg.h | 12 ++++--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 59 +++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/reg.h +7 -5
@@ -670,18 +670,20 @@#define MMCR0_PROBLEM_DISABLE MMCR0_FCP#define MMCR0_FCM1 0x10000000UL/* freeze counters while MSR mark = 1 */ #define MMCR0_FCM0 0x08000000UL/* freeze counters while MSR mark = 0 */ -#define MMCR0_PMXE 0x04000000UL/* performance monitor exception enable */ -#define MMCR0_FCECE 0x02000000UL/* freeze ctrs on enabled cond or event */ +#define MMCR0_PMXE ASM_CONST(0x04000000)/* perf mon exception enable */ +#define MMCR0_FCECE ASM_CONST(0x02000000)/* freeze ctrs on enabled cond or event */ #define MMCR0_TBEE 0x00400000UL/* time base exception enable */ #define MMCR0_BHRBA 0x00200000UL/* BHRB Access allowed in userspace */ #define MMCR0_EBE 0x00100000UL/* Event based branch enable */ #define MMCR0_PMCC 0x000c0000UL/* PMC control */ #define MMCR0_PMCC_U6 0x00080000UL/* PMC1-6 are R/W by user (PR) */ #define MMCR0_PMC1CE 0x00008000UL/* PMC1 count enable*/ -#define MMCR0_PMCjCE 0x00004000UL/* PMCj count enable*/ +#define MMCR0_PMCjCE ASM_CONST(0x00004000)/* PMCj count enable*/ #define MMCR0_TRIGGER 0x00002000UL/* TRIGGER enable */ -#define MMCR0_PMAO_SYNC 0x00000800UL/* PMU interrupt is synchronous */ -#define MMCR0_PMAO 0x00000080UL/* performance monitor alert has occurred, set to 0 after handling exception */ +#define MMCR0_PMAO_SYNC ASM_CONST(0x00000800)/* PMU intr is synchronous */ +#define MMCR0_C56RUN ASM_CONST(0x00000100)/* PMC5/6 count when RUN=0 */ +/* performance monitor alert has occurred, set to 0 after handling exception */ +#define MMCR0_PMAO ASM_CONST(0x00000080)#define MMCR0_SHRFC 0x00000040UL/* SHRre freeze conditions between threads */ #define MMCR0_FC56 0x00000010UL/* freeze counters 5 and 6 */ #define MMCR0_FCTI 0x00000008UL/* freeze counters in tags inactive mode */
arch/powerpc/kvm/book3s_hv_rmhandlers.S +57 -2
96 lines not on this page · raw message
Signature · 1 line
1.8.1.4
[PULL 39/41] KVM: PPC: Book3S HV: Fix machine check delivery to guest
In reply to Alexander GrafFrom: Paul Mackerras <[email protected]>
The code that delivered a machine check to the guest after handling it in real mode failed to load up r11 before calling kvmppc_msr_interrupt, which needs the old MSR value in r11 so it can see the transactional state there. This adds the missing load.
--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kvm/book3s_hv_rmhandlers.S +1 -0
@@ -2144,6 +2144,7 @@ machine_check_realmode: beq mc_cont /* If not, deliver a machine check. SRR0/1 are already set */ li r10, BOOK3S_INTERRUPT_MACHINE_CHECK + ld r11, VCPU_MSR(r9) bl kvmppc_msr_interrupt b fast_interrupt_c_return
Signature · 1 line
1.8.1.4
[PULL 40/41] KVM: PPC: Book3S PR: Use SLB entry 0
In reply to Alexander GrafWe didn't make use of SLB entry 0 because ... of no good reason. SLB entry 0 will always be used by the Linux linear SLB entry, so the fact that slbia does not invalidate it doesn't matter as we overwrite SLB 0 on exit anyway.
Just enable use of SLB entry 0 for our shadow SLB code.
--- arch/powerpc/kvm/book3s_64_mmu_host.c | 11 ++++------- arch/powerpc/kvm/book3s_64_slb.S | 3 ++- 2 files changed, 6 insertions(+), 8 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_host.c +4 -7
@@ -271,11 +271,8 @@ static int kvmppc_mmu_next_segment(struct kvm_vcpu *vcpu, ulong esid)int found_inval =-1 ;int r; -if (!svcpu->slb_max) - svcpu->slb_max =1 ; -/* Are we overwriting? */ -for (i =1 ; i < svcpu->slb_max; i++) { +for (i =0 ; i < svcpu->slb_max; i++) {if (!(svcpu->slb[i].esid &SLB_ESID_V )) found_inval = i;else if ((svcpu->slb[i].esid &ESID_MASK ) = esid) {
@@ -285,7 +282,7 @@ static int kvmppc_mmu_next_segment(struct kvm_vcpu *vcpu, ulong esid) }/* Found a spare entry that was invalidated before */ -if (found_inval >0 ) { +if (found_inval >=0 ) { r = found_inval; goto out; }
@@ -359,7 +356,7 @@ void kvmppc_mmu_flush_segment(struct kvm_vcpu *vcpu, ulong ea, ulong seg_size)ulong seg_mask = -seg_size;int i; -for (i =1 ; i < svcpu->slb_max; i++) { +for (i =0 ; i < svcpu->slb_max; i++) {if ((svcpu->slb[i].esid &SLB_ESID_V ) && (svcpu->slb[i].esid & seg_mask) = ea) {/* Invalidate this entry */
@@ -373,7 +370,7 @@ void kvmppc_mmu_flush_segment(struct kvm_vcpu *vcpu, ulong ea, ulong seg_size)void kvmppc_mmu_flush_segments (struct kvm_vcpu *vcpu) {struct kvmppc_book3s_shadow_vcpu *svcpu =svcpu_get (vcpu); - svcpu->slb_max =1 ; + svcpu->slb_max =0 ; svcpu->slb[0 ].esid =0 ;svcpu_put (svcpu); }
arch/powerpc/kvm/book3s_64_slb.S +2 -1
@@ -138,7 +138,8 @@ slb_do_enter: /* Restore bolted entries from the shadow and fix it along the way */ - /* We don't store anything in entry 0, so we don't need to take care of it */ + li r0, r0 + slbmte r0, r0 slbia isync
Signature · 1 line
1.8.1.4
[PULL 41/41] KVM: PPC: Book3S PR: Rework SLB switching code
In reply to Alexander GrafOn LPAR guest systems Linux enables the shadow SLB to indicate to the hypervisor a number of SLB entries that always have to be available.
Today we go through this shadow SLB and disable all ESID's valid bits. However, pHyp doesn't like this approach very much and honors us with fancy machine checks.
Fortunately the shadow SLB descriptor also has an entry that indicates the number of valid entries following. During the lifetime of a guest we can just swap that value to 0 and don't have to worry about the SLB restoration magic.
While we're touching the code, let's also make it more readable (get rid of rldicl), allow it to deal with a dynamic number of bolted SLB entries and only do shadow SLB swizzling on LPAR systems.
--- arch/powerpc/kernel/paca.c | 3 ++ arch/powerpc/kvm/book3s_64_slb.S | 83 ++++++++++++++++++---------------------- arch/powerpc/mm/slb.c | 2 +- 3 files changed, 42 insertions(+), 46 deletions(-)
arch/powerpc/kernel/paca.c +3 -0
@@ -98,6 +98,9 @@ static inline void free_lppacas(void) { }/* * 3 persistent SLBs are registered here. The buffer will be zero * initially, hence will all be invaild until we actually write them. +* +* If you make the number of persistent SLB entries dynamic, please also +* update PR KVM to flush and restore them accordingly. */ static struct slb_shadow *slb_shadow;
arch/powerpc/kvm/book3s_64_slb.S +38 -45
118 lines not on this page · raw message
arch/powerpc/mm/slb.c +1 -1
@@ -97,7 +97,7 @@ static inline void create_shadowed_slbe(unsigned long ea, int ssize,static void __slb_flush_and_rebolt (void ) {/* If you change this make sure you change SLB_NUM_BOLTED -* appropriately too. */ +* and PR KVM appropriately too. */ unsigned long linear_llp, vmalloc_llp, lflags, vflags;unsigned long ksp_esid_data, ksp_vsid_data;
Signature · 1 line
1.8.1.4
Paolo Bonzini
maintainerIl 30/05/2014 14:42, Alexander Graf ha scritto:
Quoted 22 lines
Hi Paolo / Marcelo,
This is my current patch queue for ppc. Please pull.
Alex
The following changes since commit
1f854112553a1d65363ab27d4ee3dfb4b27075fb:KVM: vmx: DR7 masking on task switch emulation is wrong (2014-05-22 17:47:18 +0200)
are available in the git repository at:
git://github.com/agraf/linux-2.6.gittags/signed-kvm-ppc-nextfor you to fetch changes up to
d8d164a9850d486cc48081c18831680254688d0f:KVM: PPC: Book3S PR: Rework SLB switching code (2014-05-30 14:26:30 +0200)
----------------------------------------------------------------
Patch queue for ppc - 2014-05-30
Quoted 6 lines
In this round we have a few nice gems. PR KVM gains initial POWER8 support as well as LE host awareness, ihe e500 targets can now properly run u-boot, LE guests now work with PR KVM including KVM hypercalls and HV KVM guests can now use huge pages.
On top of this there are some bug fixes.
Thanks for sending the patches well before the merge window!
There is a conflict in capability numbers. KVM_CAP_PPC_FIXUP_HCALL is 102 on the branch, but will be 103 when I merge.
This will be a very large release for KVM, with over 200 patches scattered over all architectures except ia64 (~25 MIPS, ~20 ARM, ~40 PPC, ~35 x86, ~80 s390).
Paolo
Quoted 97 lines
----------------------------------------------------------------
Alexander Graf (27):
KVM: PPC: E500: Ignore L1CSR1_ICFI,ICLFR
KVM: PPC: E500: Add dcbtls emulation
KVM: PPC: Book3S: PR: Fix C/R bit setting
KVM: PPC:Book3S_32: PR: Access HTAB in big endian
KVM: PPC:Book3S_64PR: Access HTAB in big endian
KVM: PPC:Book3S_64PR: Access shadow slb in big endian
KVM: PPC: Book3S PR: Default to big endian guest
KVM: PPC: Book3S PR: PAPR: Access HTAB in big endian
KVM: PPC: Book3S PR: PAPR: Access RTAS in big endian
KVM: PPC: PR: Fill pvinfo hcall instructions in big endian
KVM: PPC: Make shared struct aka magic page guest endian
KVM: PPC: Book3S PR: Do dcbz32 patching with big endian instructions
KVM: PPC: Book3S: Move little endian conflict to HV KVM
KVM: PPC: Book3S PR: Ignore PMU SPRs
KVM: PPC: Book3S PR: Emulate TIR register
KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
KVM: PPC: Book3S PR: Expose TAR facility to guest
KVM: PPC: Book3S PR: Expose EBB registers
KVM: PPC: Book3S PR: Expose TM registers
KVM: PPC: Disable NX for old magic page using guests
PPC: KVM: Make NX bit available with magic page
PPC: ePAPR: Fix hypercall on LE guest
KVM: PPC: Graciously fail broken LE hypercalls
KVM: PPC: MPIC: Reset IRQ source private members
KVM: PPC: Add CAP to indicate hcall fixes
KVM: PPC: Book3S PR: Use SLB entry 0
KVM: PPC: Book3S PR: Rework SLB switching codeAlexey Kardashevskiy (1):
KVM: PPC: Book3S HV: Fix dirty map for hugepagesAneesh Kumar K.V (6):
KVM: PPC: BOOK3S: PR: Enable Little Endian PR guest
KVM: PPC: BOOK3S: PR: FixWARN_ONwith debug options on
KVM: PPC: BOOK3S: HV: Prefer CMA region for hash page table allocation
KVM: PPC: BOOK3S: HV: Add mixed page-size support for guest
KVM: PPC: BOOK3S: Always use the saved DAR value
KVM: PPC: BOOK3S: Remove open codedmake_dsisrin alignment handlerPaul Mackerras (7):
KVM: PPC: Book3S: AddONE_REGregister names that were missed
KVM: PPC: Book3S: MoveKVM_REG_PPC_WORTto an unused register number
KVM: PPC: Book3S HV: Fix check for running inside guest inglobal_invalidates()
KVM: PPC: Book3S HV: Put huge-page HPTEs in rmap chain for base address
KVM: PPC: Book3S HV: Make sure we don't miss dirty pages
KVM: PPC: Book3S HV: Work around POWER8 performance monitor bugs
KVM: PPC: Book3S HV: Fix machine check delivery to guestDocumentation/virtual/kvm/api.txt | 6 + Documentation/virtual/kvm/ppc-pv.txt | 14 ++ arch/powerpc/include/asm/disassemble.h | 34 +++++ arch/powerpc/include/asm/kvm_asm.h | 18 ++- arch/powerpc/include/asm/kvm_book3s.h | 3 +- arch/powerpc/include/asm/kvm_book3s_64.h | 146 +++++++++++++++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_booke.h | 5 - arch/powerpc/include/asm/kvm_host.h | 9 +- arch/powerpc/include/asm/kvm_ppc.h | 80 +++++++++- arch/powerpc/include/asm/reg.h | 12 +- arch/powerpc/include/asm/reg_booke.h | 1 + arch/powerpc/include/uapi/asm/kvm.h | 2 +- arch/powerpc/include/uapi/asm/kvm_para.h | 6 + arch/powerpc/kernel/align.c | 34 +---- arch/powerpc/kernel/asm-offsets.c | 11 +- arch/powerpc/kernel/epapr_paravirt.c | 5 +- arch/powerpc/kernel/kvm.c | 2 +- arch/powerpc/kernel/paca.c | 3 + arch/powerpc/kvm/Kconfig | 2 +- arch/powerpc/kvm/book3s.c | 106 ++++++++----- arch/powerpc/kvm/book3s_32_mmu.c | 41 ++--- arch/powerpc/kvm/book3s_32_mmu_host.c | 4 +- arch/powerpc/kvm/book3s_64_mmu.c | 39 +++-- arch/powerpc/kvm/book3s_64_mmu_host.c | 15 +- arch/powerpc/kvm/book3s_64_mmu_hv.c | 116 ++++++++++----- arch/powerpc/kvm/book3s_64_slb.S | 87 +++++------ arch/powerpc/kvm/book3s_emulate.c | 156 +++++++++++++------- arch/powerpc/kvm/book3s_exports.c | 1 + arch/powerpc/kvm/book3s_hv.c | 48 +++--- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 3 +- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 60 +++++++- arch/powerpc/kvm/book3s_interrupts.S | 23 ++- arch/powerpc/kvm/book3s_paired_singles.c | 16 +- arch/powerpc/kvm/book3s_pr.c | 238 ++++++++++++++++++++++++------ arch/powerpc/kvm/book3s_pr_papr.c | 16 +- arch/powerpc/kvm/book3s_rtas.c | 29 ++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++ arch/powerpc/kvm/e500_emulate.c | 15 ++ arch/powerpc/kvm/emulate.c | 24 +-- arch/powerpc/kvm/mpic.c | 5 +- arch/powerpc/kvm/powerpc.c | 64 ++++++-- arch/powerpc/kvm/trace_pr.h | 2 +- arch/powerpc/mm/slb.c | 2 +- include/uapi/linux/kvm.h | 1 + 45 files changed, 1116 insertions(+), 415 deletions(-)
Quoted 27 lines
Am 30.05.2014 um 14:58 schrieb Paolo Bonzini <[email protected]>:
Il 30/05/2014 14:42, Alexander Graf ha scritto:
Quoted 22 lines
Hi Paolo / Marcelo,
This is my current patch queue for ppc. Please pull.
Alex
The following changes since commit
1f854112553a1d65363ab27d4ee3dfb4b27075fb:KVM: vmx: DR7 masking on task switch emulation is wrong (2014-05-22 17:47:18 +0200)
are available in the git repository at:
git://github.com/agraf/linux-2.6.gittags/signed-kvm-ppc-nextfor you to fetch changes up to
d8d164a9850d486cc48081c18831680254688d0f:KVM: PPC: Book3S PR: Rework SLB switching code (2014-05-30 14:26:30 +0200)
----------------------------------------------------------------
Patch queue for ppc - 2014-05-30
Quoted 8 lines
Quoted 6 lines
In this round we have a few nice gems. PR KVM gains initial POWER8 support as well as LE host awareness, ihe e500 targets can now properly run u-boot, LE guests now work with PR KVM including KVM hypercalls and HV KVM guests can now use huge pages.
On top of this there are some bug fixes.
Thanks for sending the patches well before the merge window!
Heh, I figured I'd be nice for a change. And my qemu queue is beyond 100 patches already and waiting on this one ;).
Quoted 2 lines
There is a conflict in capability numbers.
KVM_CAP_PPC_FIXUP_HCALLis 102 on the branch, but will be 103 when I merge.
That's ok, I've waited for the consumer of this cap until now, so the wrong number will be unused. Thanks a lot for the heads-up though :). And thanks for merging!
Quoted 2 lines
This will be a very large release for KVM, with over 200 patches scattered over all architectures except ia64 (~25 MIPS, ~20 ARM, ~40 PPC, ~35 x86, ~80 s390).
Woot, nice!
Alex