RE: [PATCH v5 3/4] KVM: PPC: epapr: install ev_idle hcall for e500 guest
-Original Message- From: tiejun.chen [mailto:tiejun.c...@windriver.com] Sent: Tuesday, February 21, 2012 6:54 PM To: Liu Yu-B13201 Cc: ag...@suse.de; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org; Wood Scott-B07421 Subject: Re: [PATCH v5 3/4] KVM: PPC: epapr: install ev_idle hcall for e500 guest Liu Yu wrote: If the guest hypervisor node contains has-idle property. Signed-off-by: Liu Yu yu@freescale.com --- v5: no change arch/powerpc/kernel/epapr_hcalls.S | 29 + arch/powerpc/kernel/epapr_paravirt.c | 11 ++- 2 files changed, 39 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S index 697b390..72fa234 100644 --- a/arch/powerpc/kernel/epapr_hcalls.S +++ b/arch/powerpc/kernel/epapr_hcalls.S @@ -15,6 +15,35 @@ #include asm/ppc_asm.h #include asm/asm-offsets.h +#define HC_VENDOR_EPAPR(1 16) +#define HC_EV_IDLE 16 Why not use 'EV_IDLE' directly? + +_GLOBAL(epapr_ev_idle) +epapr_ev_idle: + rlwinm r3,r1,0,0,31-THREAD_SHIFT /* current thread_info */ + lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */ + ori r4,r4,_TLF_NAPPING /* so when we take an exception */ + stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */ + + wrteei 1 + +idle_loop: + LOAD_REG_IMMEDIATE(r11, HC_VENDOR_EPAPR | HC_EV_IDLE) And could this line be simplified as something like this: LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE)) If so, even we can remove the previous HC_VENDOR_EPAPR definition as well. Because the epapr_hcalls.h contains C functions, so it cannot be included by assembly code. Thanks, Yu ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v5 1/4] KVM: PPC: epapr: Factor out the epapr init
-Original Message- From: Wood Scott-B07421 Sent: Wednesday, February 22, 2012 5:56 AM To: Liu Yu-B13201 Cc: ag...@suse.de; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org; Wood Scott-B07421 Subject: Re: [PATCH v5 1/4] KVM: PPC: epapr: Factor out the epapr init On 02/20/2012 10:46 PM, Liu Yu wrote: from the kvm guest paravirt init code. Signed-off-by: Liu Yu yu@freescale.com --- v5: 1. fix the if test 2. use patch_instruction() 3. code cleanup 4. rename the files 5. make epapr paravirt user-selectable arch/powerpc/include/asm/epapr_hcalls.h |2 + arch/powerpc/kernel/Makefile|1 + arch/powerpc/kernel/epapr_hcalls.S | 25 ++ arch/powerpc/kernel/epapr_paravirt.c| 54 +++ arch/powerpc/kernel/kvm.c | 28 ++-- arch/powerpc/kernel/kvm_emul.S | 10 -- arch/powerpc/platforms/Kconfig |7 7 files changed, 92 insertions(+), 35 deletions(-) create mode 100644 arch/powerpc/kernel/epapr_hcalls.S create mode 100644 arch/powerpc/kernel/epapr_paravirt.c diff --git a/arch/powerpc/include/asm/epapr_hcalls.h b/arch/powerpc/include/asm/epapr_hcalls.h index f3b0c2c..0ff3f24 100644 --- a/arch/powerpc/include/asm/epapr_hcalls.h +++ b/arch/powerpc/include/asm/epapr_hcalls.h @@ -148,6 +148,8 @@ #define EV_HCALL_CLOBBERS2 EV_HCALL_CLOBBERS3, r5 #define EV_HCALL_CLOBBERS1 EV_HCALL_CLOBBERS2, r4 +extern bool epapr_para_enabled; +extern u32 epapr_hypercall_start[]; I asked for s/epapr_para/epapr_paravirt/, at least in anything that is exposed beyond a single file. /* * We use uintptr_t to define a register because it's guaranteed to be a diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index ee728e4..ba8fa43 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -136,6 +136,7 @@ ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC),) obj-y += ppc_save_regs.o endif +obj-$(CONFIG_EPAPR_PARAVIRT) += epapr_paravirt.o epapr_hcalls.o obj-$(CONFIG_KVM_GUEST)+= kvm.o kvm_emul.o # Disable GCOV in odd or sensitive code diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S new file mode 100644 index 000..697b390 --- /dev/null +++ b/arch/powerpc/kernel/epapr_hcalls.S @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2012 Freescale Semiconductor, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include linux/threads.h +#include asm/reg.h +#include asm/page.h +#include asm/cputable.h +#include asm/thread_info.h +#include asm/ppc_asm.h +#include asm/asm-offsets.h + +/* Hypercall entry point. Will be patched with device tree +instructions. */ .global epapr_hypercall_start +epapr_hypercall_start: + li r3, -1 + nop + nop + nop + blr diff --git a/arch/powerpc/kernel/epapr_paravirt.c b/arch/powerpc/kernel/epapr_paravirt.c new file mode 100644 index 000..e601da7 --- /dev/null +++ b/arch/powerpc/kernel/epapr_paravirt.c @@ -0,0 +1,54 @@ +/* + * ePAPR para-virtualization support. + * + * This program is free software; you can redistribute it and/or +modify + * it under the terms of the GNU General Public License, version 2, +as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright (C) 2012 Freescale Semiconductor, Inc. + */ + +#include linux/of.h +#include asm/epapr_hcalls.h +#include asm/cacheflush.h +#include asm/code-patching.h + +bool epapr_para_enabled = false; No need to explicitly initialize to false. Why not make code more readable? +static int __init epapr_para_init(void) { + struct device_node *hyper_node; + const u32 *insts; + int len, i; + + hyper_node = of_find_node_by_path(/hypervisor); + if (!hyper_node) { + printk(KERN_WARNING + ePAPR paravirt disabled: No hypervisor node found\n); + return -ENODEV; + } + + insts = of_get_property(hyper_node, hcall-instructions, len); + if (insts !(len % 4) len = (4 * 4
RE: [PATCH v5 4/4] KVM: PPC: epapr: Update other hypercall invoking
-Original Message- From: Wood Scott-B07421 Sent: Wednesday, February 22, 2012 5:58 AM To: Liu Yu-B13201 Cc: ag...@suse.de; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org; Wood Scott-B07421 Subject: Re: [PATCH v5 4/4] KVM: PPC: epapr: Update other hypercall invoking On 02/20/2012 10:46 PM, Liu Yu wrote: Discard the old way that invoke hypercall, instead, use epapr paravirt. Signed-off-by: Liu Yu yu@freescale.com --- v5: new patch arch/powerpc/include/asm/epapr_hcalls.h | 22 +- arch/powerpc/include/asm/fsl_hcalls.h | 36 +++ --- 2 files changed, 29 insertions(+), 29 deletions(-) Make sure all the Topaz/ePAPR drivers that use this select EPAPR_PARAVIRT. Have you tested with Topaz? Not yet test. Thanks, Yu ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v5 3/4] KVM: PPC: epapr: install ev_idle hcall for e500 guest
-Original Message- From: tiejun.chen [mailto:tiejun.c...@windriver.com] Sent: Wednesday, February 22, 2012 10:52 AM To: Liu Yu-B13201 Cc: ag...@suse.de; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org; Wood Scott-B07421 Subject: Re: [PATCH v5 3/4] KVM: PPC: epapr: install ev_idle hcall for e500 guest Liu Yu-B13201 wrote: -Original Message- From: tiejun.chen [mailto:tiejun.c...@windriver.com] Sent: Tuesday, February 21, 2012 6:54 PM To: Liu Yu-B13201 Cc: ag...@suse.de; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org; Wood Scott-B07421 Subject: Re: [PATCH v5 3/4] KVM: PPC: epapr: install ev_idle hcall for e500 guest Liu Yu wrote: If the guest hypervisor node contains has-idle property. Signed-off-by: Liu Yu yu@freescale.com --- v5: no change arch/powerpc/kernel/epapr_hcalls.S | 29 + arch/powerpc/kernel/epapr_paravirt.c | 11 ++- 2 files changed, 39 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S index 697b390..72fa234 100644 --- a/arch/powerpc/kernel/epapr_hcalls.S +++ b/arch/powerpc/kernel/epapr_hcalls.S @@ -15,6 +15,35 @@ #include asm/ppc_asm.h #include asm/asm-offsets.h +#define HC_VENDOR_EPAPR (1 16) +#define HC_EV_IDLE 16 Why not use 'EV_IDLE' directly? + +_GLOBAL(epapr_ev_idle) +epapr_ev_idle: + rlwinm r3,r1,0,0,31-THREAD_SHIFT /* current thread_info */ + lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */ + ori r4,r4,_TLF_NAPPING /* so when we take an exception */ + stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */ + + wrteei 1 + +idle_loop: + LOAD_REG_IMMEDIATE(r11, HC_VENDOR_EPAPR | HC_EV_IDLE) And could this line be simplified as something like this: LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE)) If so, even we can remove the previous HC_VENDOR_EPAPR definition as well. Because the epapr_hcalls.h contains C functions, so it cannot be included by assembly code. These common definitions are already covered in epapr_hcalls.h, but looks you redefine the same items many times, in kvm_para.h/epapr_hcalls.S. And I think maybe we'll also reuse these generics elsewhere lately.\ The ones in kvm_para.h are alias, not redefine. Because kvm has its own name rule. So can we limit that with __ASSEMBLY__ in epapr_hcalls.h? Or other way. If so it makes our life easy in the future. Yes. This would be helpful. Thanks, Yu ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v4 1/3] KVM: PPC: epapr: Factor out the epapr init
-Original Message- From: Wood Scott-B07421 Sent: Friday, February 17, 2012 1:13 AM To: Liu Yu-B13201 Cc: ag...@suse.de; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org; Wood Scott-B07421 Subject: Re: [PATCH v4 1/3] KVM: PPC: epapr: Factor out the epapr init On 02/16/2012 03:26 AM, Liu Yu wrote: from the kvm guest paravirt init code. Signed-off-by: Liu Yu yu@freescale.com --- v4: 1. code cleanup 2. move kvm_hypercall_start() to epapr_hypercall_start() arch/powerpc/Kconfig|4 ++ arch/powerpc/include/asm/epapr_hcalls.h |2 + arch/powerpc/kernel/Makefile|1 + arch/powerpc/kernel/epapr.S | 25 arch/powerpc/kernel/epapr_para.c| 49 +++ arch/powerpc/kernel/kvm.c | 28 ++ arch/powerpc/kernel/kvm_emul.S | 10 -- arch/powerpc/kvm/Kconfig|1 + 8 files changed, 85 insertions(+), 35 deletions(-) create mode 100644 arch/powerpc/kernel/epapr.S create mode 100644 arch/powerpc/kernel/epapr_para.c The comment about spelling out paravirt wasnn't meant to be restricted to the kconfig symbol. There are lots of words that begin with para, and ePAPR isn't just about virtualization. What do you mean? Do you suggest that we should name it epapr_paravirt.c? Thanks, Yu ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v4 2/3] KVM: PPC: epapr: Add idle hcall support for host
-Original Message- From: Alexander Graf [mailto:ag...@suse.de] Sent: Thursday, February 16, 2012 6:20 PM To: Liu Yu-B13201 Cc: kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc- d...@ozlabs.org; Wood Scott-B07421; Liu Yu-B13201 Subject: Re: [PATCH v4 2/3] KVM: PPC: epapr: Add idle hcall support for host On 16.02.2012, at 10:26, Liu Yu yu@freescale.com wrote: And add a new flag definition in kvm_ppc_pvinfo to indicate whether host support EV_IDLE hcall. Signed-off-by: Liu Yu yu@freescale.com --- v4: no change arch/powerpc/include/asm/kvm_para.h | 14 -- arch/powerpc/kvm/powerpc.c |8 include/linux/kvm.h |2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h index 7b754e7..81a34c9 100644 --- a/arch/powerpc/include/asm/kvm_para.h +++ b/arch/powerpc/include/asm/kvm_para.h @@ -75,9 +75,19 @@ struct kvm_vcpu_arch_shared { }; #define KVM_SC_MAGIC_R00x4b564d21 /* KVM! */ -#define HC_VENDOR_KVM(42 16) + +#include asm/epapr_hcalls.h + +/* ePAPR Hypercall Vendor ID */ +#define HC_VENDOR_EPAPR(EV_EPAPR_VENDOR_ID 16) +#define HC_VENDOR_KVM(EV_KVM_VENDOR_ID 16) + +/* ePAPR Hypercall Token */ +#define HC_EV_IDLEEV_IDLE + +/* ePAPR Hypercall Return Codes */ #define HC_EV_SUCCESS0 -#define HC_EV_UNIMPLEMENTED12 +#define HC_EV_UNIMPLEMENTEDEV_UNIMPLEMENTED #define KVM_FEATURE_MAGIC_PAGE1 diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 0e21d15..03ebd5d 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) /* Second return value is in r4 */ break; +case HC_VENDOR_EPAPR | HC_EV_IDLE: +r = HC_EV_SUCCESS; +kvm_vcpu_block(vcpu); +break; default: r = HC_EV_UNIMPLEMENTED; break; @@ -746,6 +750,10 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo) pvinfo-hcall[2] = inst_sc; pvinfo-hcall[3] = inst_nop; +#ifdef CONFIG_BOOKE +pvinfo-flags |= KVM_PPC_PVINFO_FLAGS_EV_IDLE; #endif + return 0; } Why limit it to booke? The less ifdefs our code has, the better :) The code here tells userspace that kvm support ev_idle. But I'm not sure if the ev_idle code works for other platforms. So I think we should keep the ifdef until other platform test the code :) Thanks, Yu ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v3 1/3] KVM: PPC: epapr: Factor out the epapr init
-Original Message- From: Wood Scott-B07421 Sent: Saturday, February 11, 2012 2:40 AM To: Liu Yu-B13201 Cc: ag...@suse.de; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org; Wood Scott-B07421 Subject: Re: [PATCH v3 1/3] KVM: PPC: epapr: Factor out the epapr init On 02/10/2012 04:02 AM, Liu Yu wrote: from the kvm guest paravirt init code. Signed-off-by: Liu Yu yu@freescale.com --- v3: apply the epapr init for all ppc platform arch/powerpc/Kconfig|4 +++ arch/powerpc/include/asm/epapr_hcalls.h |8 + arch/powerpc/kernel/Makefile|1 + arch/powerpc/kernel/epapr_para.c| 46 +++ arch/powerpc/kernel/kvm.c | 13 +++-- arch/powerpc/kvm/Kconfig|1 + 6 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 arch/powerpc/kernel/epapr_para.c diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 47682b6..00bd508 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -196,6 +196,10 @@ config EPAPR_BOOT Used to allow a board to specify it wants an ePAPR compliant wrapper. default n +config EPAPR_PARA + bool + default n EPAPR_PARAVIRT config DEFAULT_UIMAGE bool help diff --git a/arch/powerpc/include/asm/epapr_hcalls.h b/arch/powerpc/include/asm/epapr_hcalls.h index f3b0c2c..c4b86e4 100644 --- a/arch/powerpc/include/asm/epapr_hcalls.h +++ b/arch/powerpc/include/asm/epapr_hcalls.h @@ -148,6 +148,14 @@ #define EV_HCALL_CLOBBERS2 EV_HCALL_CLOBBERS3, r5 #define EV_HCALL_CLOBBERS1 EV_HCALL_CLOBBERS2, r4 +extern u32 *epapr_hcall_insts; +extern int epapr_hcall_insts_len; + +static inline void epapr_get_hcall_insts(u32 **instp, int *lenp) { + *instp = epapr_hcall_insts; + *lenp = epapr_hcall_insts_len; +} Why do we need a function for this? Why is the public interface anything other than invoke a hypercall? +static int __init epapr_para_init(void) { + struct device_node *hyper_node; + u32 *insts; + int len; + + hyper_node = of_find_node_by_path(/hypervisor); + if (!hyper_node) + return -ENODEV; + + insts = (u32*)of_get_property(hyper_node, hcall-instructions, +len); Do not cast away that const. @@ -535,18 +536,12 @@ EXPORT_SYMBOL_GPL(kvm_hypercall); static int kvm_para_setup(void) { extern u32 kvm_hypercall_start; - struct device_node *hyper_node; u32 *insts; int len, i; - hyper_node = of_find_node_by_path(/hypervisor); - if (!hyper_node) - return -1; - - insts = (u32*)of_get_property(hyper_node, hcall-instructions, len); - if (len % 4) - return -1; - if (len (4 * 4)) + insts = epapr_hcall_insts; + len = epapr_hcall_insts_len; + if (insts == NULL) return -1; for (i = 0; i (len / 4); i++) Why are you still doing the patching inside kvm.c? Do you mean we should move kvm_hypercall_start() into epapr bit? Thanks, Yu ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH 2/4] KVM: PPC: booke: Wrap __kvmppc_vcpu_run()
-Original Message- From: linuxppc-dev-bounces+b13201=freescale@lists.ozlabs.org [mailto:linuxppc-dev-bounces+b13201=freescale.com@lists.ozlabs .org] On Behalf Of Alexander Graf Sent: Tuesday, March 29, 2011 5:32 PM To: Wood Scott-B07421 Cc: linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 2/4] KVM: PPC: booke: Wrap __kvmppc_vcpu_run() On 28.03.2011, at 21:25, Scott Wood wrote: From: yu liu yu@freescale.com We need to save/restore SPE environment on e500 core. Wrap __kvmppc_vcpu_run() so that we can put the SPE code in e500.c. Signed-off-by: Liu Yu yu@freescale.com Signed-off-by: Scott Wood scottw...@freescale.com --- arch/powerpc/include/asm/kvm_ppc.h |1 + arch/powerpc/kvm/44x.c |5 + arch/powerpc/kvm/book3s.c |1 - arch/powerpc/kvm/booke_interrupts.S |2 +- arch/powerpc/kvm/e500.c |5 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index ecb3bc7..4e7a1be 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -42,6 +42,7 @@ enum emulation_result { EMULATE_AGAIN,/* something went wrong. go again */ }; +extern int __kvmppc_vcpu_entry(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); extern char kvmppc_handlers_start[]; extern unsigned long kvmppc_handler_len; diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c index 74d0e74..3d2e7d2 100644 --- a/arch/powerpc/kvm/44x.c +++ b/arch/powerpc/kvm/44x.c @@ -147,6 +147,11 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) kmem_cache_free(kvm_vcpu_cache, vcpu_44x); } +int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) +{ + return __kvmppc_vcpu_entry(kvm_run, vcpu); 440 calls _entry on _run +} + static int __init kvmppc_44x_init(void) { int r; diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index c961de4..fb12853 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -1379,7 +1379,6 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) vfree(vcpu_book3s); } -extern int __kvmppc_vcpu_entry(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); BookS loses its _entry reference? int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) { int ret; diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S index 1cc471f..ab29f5f 100644 --- a/arch/powerpc/kvm/booke_interrupts.S +++ b/arch/powerpc/kvm/booke_interrupts.S @@ -293,7 +293,7 @@ heavyweight_exit: * r3: kvm_run pointer * r4: vcpu pointer */ -_GLOBAL(__kvmppc_vcpu_run) +_GLOBAL(__kvmppc_vcpu_entry) BookE calls _run _entry now stwur1, -HOST_STACK_SIZE(r1) stw r1, VCPU_HOST_STACK(r4) /* Save stack pointer to vcpu. */ diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c index e3768ee..e762634 100644 --- a/arch/powerpc/kvm/e500.c +++ b/arch/powerpc/kvm/e500.c @@ -70,6 +70,11 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu) return 0; } +int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) +{ + return __kvmppc_vcpu_entry(kvm_run, vcpu); +} e500 calls _entry on _run So you're basically adding a C wrapper around _entry. That's fine for me, but what is the BookS change about? Hi Alex, The declaration for Book3S is moved to global header. Thanks, Yu ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH] e500: Erratum cpu a005 workaround
-Original Message- From: Gala Kumar-B11780 Sent: Tuesday, January 25, 2011 3:01 PM To: Liu Yu-B13201 Cc: linuxppc-dev@lists.ozlabs.org; Gala Kumar-B11780 Subject: Re: [PATCH] e500: Erratum cpu a005 workaround On Jan 25, 2011, at 12:02 AM, Liu Yu wrote: This errata can occur if a single-precision floating-point, double-precision floating-point or vector floating-point instruction on a mispredicted branch path signals one of the floating-point data interrupts which are enabled by the SPEFSCR (FINVE, FDBZE, FUNFE or FOVFE bits). This interrupt must be recorded in a one-cycle window when the misprediction is resolved. If this extremely rare event should occur, the result could be: The SPE Data Exception from the mispredicted path may be reported erroneously if a single-precision floating-point, double-precision floating-point or vector floating-point instruction is the second instruction on the correct branch path. According to errata description, some efp instructions which are not supposed to trigger SPE exceptions can trigger the exceptions in this case. However, as we haven't emulated these instructions here, a signal will send to userspace, and userspace application would exit. This patch re-issue the efp instruction that we haven't emulated, so that hardware can properly execute it again if this case happen. Signed-off-by: Liu Yu yu@freescale.com --- This is an erratum workaround patch. It would be better if the patch can go into 2.6.38. arch/powerpc/include/asm/reg.h |2 + arch/powerpc/math-emu/math_efp.c | 53 +- 2 files changed, 54 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index 6315edc..0abfd91 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -833,6 +833,8 @@ #define PVR_74500x8000 #define PVR_85400x8020 #define PVR_85600x8020 +#define PVR_VER_E500V1 0x8020 +#define PVR_VER_E500V2 0x8021 /* * For the 8xx processors, all of them report the same PVR family for * the PowerPC core. The various versions of these processors must be diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/math_efp.c index 41f4ef3..634830b 100644 --- a/arch/powerpc/math-emu/math_efp.c +++ b/arch/powerpc/math-emu/math_efp.c @@ -1,7 +1,7 @@ /* * arch/powerpc/math-emu/math_efp.c * - * Copyright (C) 2006-2008 Freescale Semiconductor, Inc. All rights reserved. + * Copyright (C) 2006-2008, 2010 Freescale Semiconductor, Inc. * * Author: Ebony Zhu, ebony@freescale.com * Yu Liu, yu@freescale.com @@ -104,6 +104,8 @@ #define FP_EX_MASK (FP_EX_INEXACT | FP_EX_INVALID | FP_EX_DIVZERO | \ FP_EX_UNDERFLOW | FP_EX_OVERFLOW) +static int have_e500_cpu_a005_erratum; + union dw_union { u64 dp[1]; u32 wp[2]; @@ -652,6 +654,15 @@ update_regs: return 0; illegal: + if (have_e500_cpu_a005_erratum) { + /* according to e500 cpu a005 erratum, reissue efp inst */ + regs-nip -= 4; +#ifdef DEBUG + printk(KERN_DEBUG re-issue efp inst: %08lx\n, speinsn); +#endif + return 0; + } + printk(KERN_ERR \nOoops! IEEE-754 compliance handler encountered un-supported instruction.\ninst code: %08lx\n, speinsn); return -ENOSYS; } @@ -718,3 +729,43 @@ int speround_handler(struct pt_regs *regs) return 0; } + +int __init spe_mathemu_init(void) +{ + u32 pvr, maj, min; + + pvr = mfspr(SPRN_PVR); + + if ((PVR_VER(pvr) == PVR_VER_E500V1) || + (PVR_VER(pvr) == PVR_VER_E500V2)) { + maj = PVR_MAJ(pvr); + min = PVR_MIN(pvr); + + /* +* E500 revision below 1.1, 2.3, 3.1, 4.1, 5.1 +* need cpu a005 errata workaround +*/ This isn't the way to do this. We normally add entries in cputable.c an add a new cpu_feature_bit for the errata. Than above we'd do: if (cur_cpu_spec-cpu_features CPU_FTR_E500_A005_ERRATUM) IMHO, a cpu erratum is not a cpu feature. See there're only 32 bits can be used for all PowerPC platform to represent cpu feature, then is it worth consuming one of them to represent one e500 erratum? Thanks, Yu ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH 14/27] KVM: PPC: Magic Page BookE support
-Original Message- From: kvm-ow...@vger.kernel.org [mailto:kvm-ow...@vger.kernel.org] On Behalf Of Alexander Graf Sent: Thursday, July 01, 2010 6:43 PM To: kvm-...@vger.kernel.org Cc: KVM list; linuxppc-dev Subject: [PATCH 14/27] KVM: PPC: Magic Page BookE support As we now have Book3s support for the magic page, we also need BookE to join in on the party. This patch implements generic magic page logic for BookE and specific TLB logic for e500. I didn't have any 440 around, so I didn't dare to blindly try and write up broken code. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke.c| 29 + arch/powerpc/kvm/e500_tlb.c | 19 +-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 0f8ff9d..9609207 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -380,6 +406,9 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, gpa_t gpaddr; gfn_t gfn; + if (kvmppc_dtlb_magic_page(vcpu, eaddr)) + break; + /* Check the guest TLB. */ gtlb_index = kvmppc_mmu_dtlb_index(vcpu, eaddr); if (gtlb_index 0) { How about moving this part into tlb search fail path? ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH] kvm/powerpc: fix a build error in e500_tlb.c
-Original Message- From: kvm-ow...@vger.kernel.org [mailto:kvm-ow...@vger.kernel.org] On Behalf Of Alexander Graf Sent: Friday, June 04, 2010 10:08 PM To: Kevin Hao Cc: Marcelo Tosatti; Kumar Gala; Avi Kivity; k...@vger.kernel.org list; linuxppc-...@ozlabs.org; Liu Yu-B13201 Subject: Re: [PATCH] kvm/powerpc: fix a build error in e500_tlb.c On 03.06.2010, at 07:52, Kevin Hao wrote: We use the wrong number arguments when invoking trace_kvm_stlb_inval, and cause the following build error. arch/powerpc/kvm/e500_tlb.c: In function 'kvmppc_e500_stlbe_invalidate': arch/powerpc/kvm/e500_tlb.c:230: error: too many arguments to function 'trace_kvm_stlb_inval' Liu, I'd like to get an ack from you here. Seems commit e43f2f741a49483034bf968841275cfa553a4cb3 has solved this. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH 4/4] phy: add RTBI mode for m88e1111
-Original Message- From: Kumar Gala [mailto:ga...@kernel.crashing.org] Sent: Friday, January 15, 2010 12:20 AM To: Liu Yu-B13201 Cc: da...@davemloft.net; linuxppc-dev@lists.ozlabs.org; net...@vger.kernel.org Subject: Re: [PATCH 4/4] phy: add RTBI mode for m88e On Jan 14, 2010, at 2:13 AM, Liu Yu wrote: Signed-off-by: Liu Yu yu@freescale.com --- drivers/net/phy/marvell.c | 38 ++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 6f69b9b..65ed385 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -63,6 +63,7 @@ #define MII_M_HWCFG_MODE_COPPER_RGMII 0xb #define MII_M_HWCFG_MODE_FIBER_RGMII0x3 #define MII_M_HWCFG_MODE_SGMII_NO_CLK 0x4 +#define MII_M_HWCFG_MODE_COPPER_RTBI 0x9 #define MII_M_HWCFG_FIBER_COPPER_AUTO 0x8000 #define MII_M_HWCFG_FIBER_COPPER_RES0x2000 @@ -269,6 +270,43 @@ static int m88e_config_init(struct phy_device *phydev) return err; } + if (phydev-interface == PHY_INTERFACE_MODE_RTBI) { + temp = phy_read(phydev, MII_M_PHY_EXT_CR); + if (temp 0) + return temp; + temp |= (MII_M_RX_DELAY | MII_M_TX_DELAY); + err = phy_write(phydev, MII_M_PHY_EXT_CR, temp); + if (err 0) + return err; + + temp = phy_read(phydev, MII_M_PHY_EXT_SR); + if (temp 0) + return temp; + temp = ~(MII_M_HWCFG_MODE_MASK | MII_M_HWCFG_FIBER_COPPER_RES); + temp |= 0x7 | MII_M_HWCFG_FIBER_COPPER_AUTO; Does this magic 0x7 have some meaning? Hrr... it's GMII to fibre mode. Document 88E_erata_RevB2 chapter 4.35 describ the reason. Without this sometimes phys couldnot work. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH 1/2] KVM/PPC: Fix PPC KVM e500_tlb.c build error
-Original Message- From: Avi Kivity [mailto:a...@redhat.com] Sent: Thursday, July 02, 2009 7:20 PM To: Liu Yu-B13201 Cc: Yang Shi; holl...@us.ibm.com; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org Subject: Re: [PATCH 1/2] KVM/PPC: Fix PPC KVM e500_tlb.c build error On 07/02/2009 06:09 AM, Liu Yu-B13201 wrote: This fix is already accepted in kvm.git What about the other? Is it needed? No, it's already fixed by commit b57227e600f4ecc394d6ba3c2aaa558867b5addc. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH 1/2] KVM/PPC: Fix PPC KVM e500_tlb.c build error
This fix is already accepted in kvm.git -Original Message- From: Yang Shi [mailto:yang@windriver.com] Sent: Thursday, July 02, 2009 10:55 AM To: Liu Yu-B13201; holl...@us.ibm.com; a...@redhat.com Cc: kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@ozlabs.org Subject: [PATCH 1/2] KVM/PPC: Fix PPC KVM e500_tlb.c build error Since include/asm/mmu-fsl-booke.h was replaced by include/asm/mmu-book3e.h, fix e500_tlb.h to reflect the change and fix e500_tlb.c to align with the new page size macro definition in include/asm/mmu-book3e.h. Signed-off-by: Yang Shi yang@windriver.com --- arch/powerpc/kvm/e500_tlb.c |8 arch/powerpc/kvm/e500_tlb.h |2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index 0e773fc..616762b 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -309,7 +309,7 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, vcpu_e500-shadow_pages[tlbsel][esel] = new_page; /* Force TS=1 IPROT=0 TSIZE=4KB for all guest mappings. */ - stlbe-mas1 = MAS1_TSIZE(BOOKE_PAGESZ_4K) + stlbe-mas1 = MAS1_TSIZE(BOOK3E_PAGESZ_4K) | MAS1_TID(get_tlb_tid(gtlbe)) | MAS1_TS | MAS1_VALID; stlbe-mas2 = (gvaddr MAS2_EPN) | e500_shadow_mas2_attrib(gtlbe-mas2, @@ -545,7 +545,7 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) case 0: /* TLB0 */ gtlbe-mas1 = ~MAS1_TSIZE(~0); - gtlbe-mas1 |= MAS1_TSIZE(BOOKE_PAGESZ_4K); + gtlbe-mas1 |= MAS1_TSIZE(BOOK3E_PAGESZ_4K); stlbsel = 0; sesel = kvmppc_e500_stlbe_map(vcpu_e500, 0, esel); @@ -679,14 +679,14 @@ void kvmppc_e500_tlb_setup(struct kvmppc_vcpu_e500 *vcpu_e500) /* Insert large initial mapping for guest. */ tlbe = vcpu_e500-guest_tlb[1][0]; - tlbe-mas1 = MAS1_VALID | MAS1_TSIZE(BOOKE_PAGESZ_256M); + tlbe-mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_256M); tlbe-mas2 = 0; tlbe-mas3 = E500_TLB_SUPER_PERM_MASK; tlbe-mas7 = 0; /* 4K map for serial output. Used by kernel wrapper. */ tlbe = vcpu_e500-guest_tlb[1][1]; - tlbe-mas1 = MAS1_VALID | MAS1_TSIZE(BOOKE_PAGESZ_4K); + tlbe-mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_4K); tlbe-mas2 = (0xe0004500 0xF000) | MAS2_I | MAS2_G; tlbe-mas3 = (0xe0004500 0xF000) | E500_TLB_SUPER_PERM_MASK; tlbe-mas7 = 0; diff --git a/arch/powerpc/kvm/e500_tlb.h b/arch/powerpc/kvm/e500_tlb.h index 45b064b..abb1bf8 100644 --- a/arch/powerpc/kvm/e500_tlb.h +++ b/arch/powerpc/kvm/e500_tlb.h @@ -16,7 +16,7 @@ #define __KVM_E500_TLB_H__ #include linux/kvm_host.h -#include asm/mmu-fsl-booke.h +#include asm/mmu-book3e.h #include asm/tlb.h #include asm/kvm_e500.h -- 1.6.0.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: who know's what is TestFloat cases and how to test this feature onthe Freescale MPC8536DS board
-Original Message- From: linuxppc-dev-bounces+b13201=freescale@ozlabs.org [mailto:linuxppc-dev-bounces+b13201=freescale@ozlabs.org] On Behalf Of derekzheng Sent: Sunday, April 19, 2009 5:25 PM To: 'linuxppc-dev'; microblaze-ucli...@itee.uq.edu.au; linux-ker...@vger.kernel.org Subject: who know's what is TestFloat cases and how to test this feature onthe Freescale MPC8536DS board Hi all guys: The Freescale MPC8536DS board Integrated TestFloat cases, and I do not know how to test this feature on this board. Please tell me how to test it if you known You can find the user manual E500v2 SPE Floating Point in BSP iso. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
RE: [PATCH] powerpc/math-emu: Use kernel generic math-emu code
diff --git a/arch/powerpc/include/asm/sfp-machine.h b/arch/powerpc/include/asm/sfp-machine.h new file mode 100644 index 000..ced34f1 --- /dev/null +++ b/arch/powerpc/include/asm/sfp-machine.h @@ -0,0 +1,353 @@ +/* Machine-dependent software floating-point definitions. PPC version. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Actually, this is a PPC (32bit) version, written based on the + i386, sparc, and sparc64 versions, by me, + Peter Maydell ([EMAIL PROTECTED]). + Comments are by and large also mine, although they may be inaccurate. + + In picking out asm fragments I've gone with the lowest common + denominator, which also happens to be the hardware I have :- + That is, a SPARC without hardware multiply and divide. + */ + +/* basic word size definitions */ +#define _FP_W_TYPE_SIZE 32 +#define _FP_W_TYPE unsigned long +#define _FP_WS_TYPE signed long +#define _FP_I_TYPE long + +#define __ll_B ((UWtype) 1 (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((UWtype) (t) (__ll_B - 1)) +#define __ll_highpart(t) ((UWtype) (t) (W_TYPE_SIZE / 2)) + +/* You can optionally code some things like addition in asm. For + * example, i386 defines __FP_FRAC_ADD_2 as asm. If you don't + * then you get a fragment of C code [if you change an #ifdef 0 + * in op-2.h] or a call to add_ss (see below). + * Good places to look for asm fragments to use are gcc and glibc. + * gcc's longlong.h is useful. + */ + +/* We need to know how to multiply and divide. If the host word size + * is = 2*fracbits you can use FP_MUL_MEAT_n_imm(t,R,X,Y) which + * codes the multiply with whatever gcc does to 'a * b'. + * _FP_MUL_MEAT_n_wide(t,R,X,Y,f) is used when you have an asm + * function that can multiply two 1W values and get a 2W result. + * Otherwise you're stuck with _FP_MUL_MEAT_n_hard(t,R,X,Y) which + * does bitshifting to avoid overflow. + * For division there is FP_DIV_MEAT_n_imm(t,R,X,Y,f) for word size + * = 2*fracbits, where f is either _FP_DIV_HELP_imm or + * _FP_DIV_HELP_ldiv (see op-1.h). + * _FP_DIV_MEAT_udiv() is if you have asm to do 2W/1W = (1W, 1W). + * [GCC and glibc have longlong.h which has the asm macro udiv_qrnnd + * to do this.] + * In general, 'n' is the number of words required to hold the type, + * and 't' is either S, D or Q for single/double/quad. + * -- PMM + */ +/* Example: SPARC64: + * #define _FP_MUL_MEAT_S(R,X,Y) _FP_MUL_MEAT_1_imm(S,R,X,Y) + * #define _FP_MUL_MEAT_D(R,X,Y) _FP_MUL_MEAT_1_wide(D,R,X,Y,umul_ppmm) + * #define _FP_MUL_MEAT_Q(R,X,Y) _FP_MUL_MEAT_2_wide(Q,R,X,Y,umul_ppmm) + * + * #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm) + * #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv(D,R,X,Y) + * #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv_64(Q,R,X,Y) + * + * Example: i386: + * #define _FP_MUL_MEAT_S(R,X,Y) _FP_MUL_MEAT_1_wide(S,R,X,Y,_i386_mul_32_64) + * #define _FP_MUL_MEAT_D(R,X,Y) _FP_MUL_MEAT_2_wide(D,R,X,Y,_i386_mul_32_64) + * + * #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y,_i386_div_64_32) + * #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv_64(D,R,X,Y) + */ + +#define _FP_MUL_MEAT_S(R,X,Y) _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) +#define _FP_MUL_MEAT_D(R,X,Y) _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) + +#define _FP_DIV_MEAT_S(R,X,Y)_FP_DIV_MEAT_1_udiv(S,R,X,Y) It seems _FP_DIV_MEAT_S() should be defined to _FP_DIV_MEAT_1_udiv_norm(). I can't remember very clear, but it seems single point float need to be normalized before calling udiv_qrnnd. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev