Re: [PATCH v5] KVM: nVMX: Fully support of nested VMX preemption timer
On 2013-09-26 22:44, Paolo Bonzini wrote: Il 26/09/2013 19:47, Paolo Bonzini ha scritto: If I only apply this hunk, which disables the preemption timer while in L1: @@ -8396,6 +8375,8 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu) load_vmcs12_host_state(vcpu, vmcs12); + vmcs_write32(PIN_BASED_VM_EXEC_CONTROL, vmx_pin_based_exec_ctrl(vmx)); + /* Update TSC_OFFSET if TSC was changed while L2 ran */ vmcs_write64(TSC_OFFSET, vmx-nested.vmcs01_tsc_offset); then the testcase works for somewhat larger values of the preemption timer (up to ~150 TSC cycles), but then fails. Err, does this mean we run L1 with PIN_BASED_VM_EXEC_CONTROL of L2? Ouch. Should be fixed independently. I mean if I apply it on top of current kvm/next, without Arthur's patch. If I apply the hunk on top of Arthur's patch nothing changes and the timer testcase starts breaking around ~65000 TSC cycles. So there are several overlapping issues. It is a bit problematic that adding printks changes something, so that the test starts passing. I haven't tried tracepoints yet. Yeah, just convert to trace_printk. Jan, which L1 is using the preemption timer? Any reason why you added it? The one I'm going to present in Edinburgh. Will publish code soon, but it's unspectacular regard preemption timer usage: I'm only using it to enforce immediate exits on next vmentry, i.e. set the timer value to 0. I wonder if it isn't better to revert it, since it is quite broken. It's in upstream since 3.10, so reverting doesn't buy us anything, we need to fix it anyway for long-term stable. Jan signature.asc Description: OpenPGP digital signature
Re: KVM call for agenda for 2013-10-01
On 24/09/2013 16:09, Juan Quintela wrote: Hi Please, send any topic that you are interested in covering. Last week I forgot to send the call for topics. We still have a topic there. Thanks, Juan. Agenda so far: - Talk about qemu reverse executing (1st description was done this week) How to handle IO when we want to do reverse execution. How this relate to Kemari needs? And to icount changes? Hi Juan, Just to confirm, both Mark and I will be present. Thanks, Fred Call details: 10:00 AM to 11:00 AM EDT Every two weeks If you need phone number details, contact me privately. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Guest memory access within hypervisor Inbox x
On Fri, Sep 27, 2013 at 03:19:28AM +0530, Piyus Kedia wrote: I am working on record replay in KVM. I just want to confirm that KVM doesn't access guest memory except for DMA. The functions kvm_read_guest_page() and kvm_write_guest_page() in kvm_main.c are only used for mmio emulation which access memory that is always emulated. It will be nice if somebody else also confirm this. kvmclock comes to mind, I think it has a shared page between the guest and the host kernel where clock updates are published from host - guest. I think kvmclock can be disabled by choosing another clocksource in the guest Linux kernel. There are other exceptions like the ivshmem device which is rarely used but can provide shared memory between guest - host or guest - guest. I think that memory is an MMIO PCI BAR in the guest just that neither kvm.ko nor QEMU may be catch the update if another process on the host is writing to it. Stefan -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Guest memory access within hypervisor Inbox x
Thanks. On Fri, Sep 27, 2013 at 3:40 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Fri, Sep 27, 2013 at 03:19:28AM +0530, Piyus Kedia wrote: I am working on record replay in KVM. I just want to confirm that KVM doesn't access guest memory except for DMA. The functions kvm_read_guest_page() and kvm_write_guest_page() in kvm_main.c are only used for mmio emulation which access memory that is always emulated. It will be nice if somebody else also confirm this. kvmclock comes to mind, I think it has a shared page between the guest and the host kernel where clock updates are published from host - guest. I think kvmclock can be disabled by choosing another clocksource in the guest Linux kernel. There are other exceptions like the ivshmem device which is rarely used but can provide shared memory between guest - host or guest - guest. I think that memory is an MMIO PCI BAR in the guest just that neither kvm.ko nor QEMU may be catch the update if another process on the host is writing to it. Stefan -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
答复: [Qemu-devel] Cross-Platform KVM
I'm sorry for replying this mail for so long. I named the 'Cross-Platform KVM' fvm ('f'is the beginning of my name :)). The kernel module is based on kvm-kmod 3.4, and the qemu (version 1.1~1.6) can be patched easily for fvm. I named the kernel module vmmr0 (VMM in Ring0). Not like the 'WinKVM' by Kazushi Takahashi, fvm is easy to compile and use. The build environment for windows is mingw-w64. I will sum up the internals of fvm, and release the docs and codes on github later. The code of vmmr0 is disordered, so I will reorganize it before releasing. Before this, I commited a binary package for windows on github: https://github.com/fanwenyi0529/fvm-release to use the fvm for windows, we should follow these steps: you should have a computer which installed 64-bit windows 7 or higher. 1. enable 'Lock pages in memory' of current user in gpedit.msc: http://msdn.microsoft.com/en-us/library/ms190730.aspx fvm use awe memory in order to lock guest 's page. Windows kernel do not have anything like mmu_notifier:( 2.windows x64 needs driver signing, so enable testmode. bcdedit -set testsigning on 3.reboot your computer. 4.install the vmmr0.sys kernel module as service named 'vmmr0' and start it. execute in cmd: sc create vmmr0 binpath=(path to vmmr0.sys) type=kernel start=demand net start vmmr0 5. all done! Let 's run kvm on windows. eg: create a bat file , and type this in the target blank: (path to fvm-x86_64w.exe) -drive file=D:\vm\linux-0.2.img,cache=writeback -machine accel=kvm,kernel_irqchip=off -cpu qemu64,-vmx -smp sockets=1,cores=1 -m 128 -soundhw hda -net nic,model=e1000 -net user -rtc base=localtime -vga vmware Save and run this bat as admin. Known problems: 1. I have not implement the kernel_irqchip, so please disable the kirqchip support in cmdline like this: -machine accel=kvm,kernel_irqchip=off 2. the performance of windows x64 guests is pr, I have not found the reason. 3. do not use vmware vga card if the guest is Ubuntu 12.04, or the qemu (version 1.3 )would core, qemu-1.6 is okay. 4. The mouse auto switching while running linux guests (Ubuntu, etc.) can not work. And the qemu will lost response. Please use vnc to run Ubuntu. 5. If your cpu do not support ept, please give the guest only 1vcpu if the guest is 64 bit. Or the guest will corrupt. Regards, Wincy -邮件原件- 发件人: kvm-ow...@vger.kernel.org [mailto:kvm-ow...@vger.kernel.org] 代表 Andreas F?rber 发送时间: 2013年8月22日 星期四 2:49 收件人: Wincy Van; Wincy Van 抄送: qemu-de...@nongnu.org; kvm; Stefan Weil; qemu-de...@nongnu.org; kvm; Stefan Weil 主题: Re: [Qemu-devel] Cross-Platform KVM Hi, Am 16.08.2013 09:41, schrieb Wincy Van: Hi,there: I have implemented a version of cross-platform KVM. Now, it can works on Linux and Windows(kernel version 7600-9200, amd64). Is it useful? If so, I want make it as a branch of current KVM. Here are some screenshots: Let's CC the KVM mailing list. More telling than screenshots would be some info about your code! Is there a public Git repository to look at? Is it based on a current kvm.git or some older Win32 KVM fork on SourceForge? If so, how invasive are your changes? Or is it a clean-room implementation of your own against the header/ioctl interface? How does it work technically? etc. Regards, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 09/11] kvm: simplify processor compat check
On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Missing patch description. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com I fail to see how this really simplifies things, but at the end of the day it's Gleb's and Paolo's call. Which brings me to the next issue: You forgot to CC kvm@vger on your patch set. Gleb and Paolo don't read kvm-ppc@vger. And they shouldn't have to. Every kvm patch that you want review on or that should get applied needs to be sent to kvm@vger. If you want to tag it as PPC specific patch, do so by CC'ing kvm-ppc@vger. Alex --- arch/arm/kvm/arm.c | 4 ++-- arch/ia64/kvm/kvm-ia64.c | 4 ++-- arch/mips/kvm/kvm_mips.c | 6 ++ arch/powerpc/include/asm/kvm_ppc.h | 2 +- arch/powerpc/kvm/44x.c | 2 +- arch/powerpc/kvm/book3s.c | 15 --- arch/powerpc/kvm/book3s_hv.c | 9 ++--- arch/powerpc/kvm/book3s_pr.c | 5 +++-- arch/powerpc/kvm/e500.c| 2 +- arch/powerpc/kvm/e500mc.c | 2 +- arch/powerpc/kvm/powerpc.c | 5 - arch/s390/kvm/kvm-s390.c | 3 ++- arch/x86/kvm/x86.c | 13 +++-- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c| 14 +- 15 files changed, 50 insertions(+), 38 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 9c697db..cccb121 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -109,9 +109,9 @@ void kvm_arch_hardware_unsetup(void) { } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - *(int *)rtn = 0; + return 0; } void kvm_arch_sync_events(struct kvm *kvm) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index bdfd878..065942c 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -185,9 +185,9 @@ void kvm_arch_hardware_disable(void *garbage) ia64_ptr_entry(0x3, slot); } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - *(int *)rtn = 0; + return 0; } int kvm_dev_ioctl_check_extension(long ext) diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c index a7b0445..4512739 100644 --- a/arch/mips/kvm/kvm_mips.c +++ b/arch/mips/kvm/kvm_mips.c @@ -97,11 +97,9 @@ void kvm_arch_hardware_unsetup(void) { } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - int *r = (int *)rtn; - *r = 0; - return; + return 0; } static void kvm_mips_init_tlbs(struct kvm *kvm) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 58e732f..592501b 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -204,7 +204,7 @@ struct kvmppc_ops { unsigned long npages); int (*init_vm)(struct kvm *kvm); void (*destroy_vm)(struct kvm *kvm); - int (*check_processor_compat)(void); + void (*check_processor_compat)(void *r); int (*get_smmu_info)(struct kvm *kvm, struct kvm_ppc_smmu_info *info); int (*emulate_op)(struct kvm_run *run, struct kvm_vcpu *vcpu, unsigned int inst, int *advance); diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c index 2f5c6b6..a1f4e60 100644 --- a/arch/powerpc/kvm/44x.c +++ b/arch/powerpc/kvm/44x.c @@ -43,7 +43,7 @@ void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu) kvmppc_booke_vcpu_put(vcpu); } -int kvmppc_core_check_processor_compat(void) +int kvm_arch_check_processor_compat(void *opaque) { int r; diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index ca617e1..485a6ff 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -827,9 +827,18 @@ void kvmppc_core_destroy_vm(struct kvm *kvm) #endif } -int kvmppc_core_check_processor_compat(void) -{ - return kvmppc_ops-check_processor_compat(); +int kvm_arch_check_processor_compat(void *opaque) +{ + int r,cpu; + struct kvmppc_ops *kvm_ops = (struct kvmppc_ops *)opaque; + for_each_online_cpu(cpu) { + smp_call_function_single(cpu, + kvm_ops-check_processor_compat, + r, 1); + if (r 0) + break; + } + return r; } EXPORT_SYMBOL_GPL(kvm_get_dirty_log); diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index ff57be8..4322db4 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1980,11 +1980,14 @@ static int kvmppc_core_emulate_mfspr_hv(struct kvm_vcpu *vcpu, int sprn, return EMULATE_FAIL; } -static int kvmppc_core_check_processor_compat_hv(void) + +static void
Re: [RFC PATCH 09/11] kvm: simplify processor compat check
Alexander Graf ag...@suse.de writes: On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Missing patch description. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com I fail to see how this really simplifies things, but at the end of the day it's Gleb's and Paolo's call. will do. It avoid calling for_each_online_cpu(cpu) { smp_call_function_single() on multiple architecture. We also want to make the smp call function a callback of opaque. Hence this should be made arch specific. int kvm_arch_check_processor_compat(void *opaque) { int r,cpu; struct kvmppc_ops *kvm_ops = (struct kvmppc_ops *)opaque; for_each_online_cpu(cpu) { smp_call_function_single(cpu, kvm_ops-check_processor_compat, r, 1); if (r 0) break; } return r; } against - for_each_online_cpu(cpu) { - smp_call_function_single(cpu, - kvm_arch_check_processor_compat, - r, 1); - if (r 0) - goto out_free_1; - } + + r = kvm_arch_check_processor_compat(opaque); + if (r 0) + goto out_free_1; Which brings me to the next issue: You forgot to CC kvm@vger on your patch set. Gleb and Paolo don't read kvm-ppc@vger. And they shouldn't have to. Every kvm patch that you want review on or that should get applied needs to be sent to kvm@vger. If you want to tag it as PPC specific patch, do so by CC'ing kvm-ppc@vger. Will do in the next update -aneesh -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems
On 09/26/2013 12:01 PM, Michael Ellerman wrote: +int powernv_hwrng_present(void) +{ + return __raw_get_cpu_var(powernv_rng) != NULL; +} + static unsigned long rng_whiten(struct powernv_rng *rng, unsigned long val) { unsigned long parity; @@ -42,6 +48,17 @@ static unsigned long rng_whiten(struct powernv_rng *rng, unsigned long val) return val; } +int powernv_get_random_real_mode(unsigned long *v) +{ + struct powernv_rng *rng; + + rng = __raw_get_cpu_var(powernv_rng); + + *v = rng_whiten(rng, in_rm64(rng-regs_real)); + Will it be in_be64() instead of in_rm64() ? Its failing the build here. Except this all individual patches build correctly. Regards Anshuman -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] kvm: Add KVM_GET_EMULATED_CPUID
On Thu, Sep 26, 2013 at 10:32:06PM +0200, Borislav Petkov wrote: On Thu, Sep 26, 2013 at 04:20:59PM -0300, Eduardo Habkost wrote: Please point me to the code that does this, because I don't see it on patch 6/6. @@ -1850,7 +1850,14 @@ static void filter_features_for_kvm(X86CPU *cpu) wi-cpuid_ecx, wi-cpuid_reg); uint32_t requested_features = env-features[w]; + +uint32_t emul_features = kvm_arch_get_emulated_cpuid(s, wi-cpuid_eax, + wi-cpuid_ecx, + wi-cpuid_reg); + env-features[w] = host_feat; +env-features[w] |= (requested_features emul_features); Basically we give the requested_features a second chance here. If we don't request an emulated feature, it won't get enabled. The problem here is that requested_features doesn't include just the explicit +flag flags, but any flag included in the CPU model definition. See the -cpu n270 example below. If you start with -cpu Haswell, MOVBE will be already set in the host CPUID. Or am I missing something? In the Haswell example, it is unlikely but possible in theory: you would need a CPU that supported all features from Haswell except movbe. But what will happen if you are using -cpu n270,enforce on a SandyBridge host? That's an interesting question: AFAICT, it will fail because MOVBE is not available on the host, right? It should, but your patch will make it stop failing because of MOVBE, as now it can be emulated[1]. And if so, then this is correct behavior IMHO, or how exactly is the enforce thing supposed to work? Enforce host CPUID? enforce makes sure all features are really being enabled. It makes QEMU abort if there's any feature that can't be enabled on that host. [1] Maybe one source of confusion is that the existing code have two feature-filtering functions doing basically the same thing: filter_features_for_kvm() and kvm_check_features_against_host(). That's something we must clean up, and they should be unified. enforce should become synonymous to make sure filtered_features is all zeroes. This way, libvirt can emulate what 'enforce does while being able to collect detailed error information (which is not easy to do if QEMU simply aborts). Also, we don't know anything about future CPUs or future features that will end up on EMULATED_CPUID. The current code doesn't have anything to differentiate features that were already included in the CPU definition and ones explicitly enabled in the command-line (and I would like to keep it that way). Ok. And just because a feature was explicitly enabled in the command-line, that doesn't mean the user believe it is acceptable to get it running in emulated mode. That's why I propose a new emulate flag, to allow features to be enabled in emulated mode. And I think, saying -cpu ...,+movbe is an explicit statement enough to say that yes, I am starting this guest and I want MOVBE emulation. Not necessarily. libvirt has some code that will translate its own CPU model definition to a -cpu Model,+flag,+flag,+flag,-flag command-line when necessary. It is by design that there is no difference between explicit +flag options and existing flags from the CPU model definition. Well, x2apic is emulated by KVM, and it is on SUPPORTED_CPUID. Ditto for tsc-deadline. Or are you talking specifically about instruction emulation? Basically, I'm viewing this from a very practical standpoint - if I build a kernel which requires MOVBE support but I cannot boot it in kvm because it doesn't emulate MOVBE (TCG does now but it didn't before) I'd like to be able to address that shortcoming by emulating that instruction, if possible. And the whole discussion grew out from the standpoint of being able to emulate stuff so that you can do quick and dirty booting of kernels but not show that emulation capability to the wide audience since it is slow and it shouldn't be used and then migration has issues, etc, etc. But hey, I don't really care all that much if I have to also say -emulate in order to get my functionality. OK, I undestand your use case, now. Thanks for your explanation. -- Eduardo -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 09/11] kvm: simplify processor compat check
Il 27/09/2013 15:13, Aneesh Kumar K.V ha scritto: Alexander Graf ag...@suse.de writes: On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Missing patch description. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com I fail to see how this really simplifies things, but at the end of the day it's Gleb's and Paolo's call. will do. It avoid calling for_each_online_cpu(cpu) { smp_call_function_single() on multiple architecture. I agree with Alex. The current code is not specially awesome; having kvm_arch_check_processor_compat take an int* disguised as a void* is a bit ugly indeed. However, the API makes sense and tells you that it is being passed as a callback (to smp_call_function_single in this case). You are making the API more complicated to use on the arch layer (because arch maintainers now have to think do I need to check this on all online CPUs?) and making the leaf POWER code less legible because it still has the weird void()(void *) calling convention. If anything, you could change kvm_arch_check_processor_compat to return an int and accept no argument, and introduce a wrapper that kvm_init passes to smp_call_function_single. Paolo We also want to make the smp call function a callback of opaque. Hence this should be made arch specific. int kvm_arch_check_processor_compat(void *opaque) { int r,cpu; struct kvmppc_ops *kvm_ops = (struct kvmppc_ops *)opaque; for_each_online_cpu(cpu) { smp_call_function_single(cpu, kvm_ops-check_processor_compat, r, 1); if (r 0) break; } return r; } against - for_each_online_cpu(cpu) { - smp_call_function_single(cpu, - kvm_arch_check_processor_compat, - r, 1); - if (r 0) - goto out_free_1; - } + + r = kvm_arch_check_processor_compat(opaque); + if (r 0) + goto out_free_1; Which brings me to the next issue: You forgot to CC kvm@vger on your patch set. Gleb and Paolo don't read kvm-ppc@vger. And they shouldn't have to. Every kvm patch that you want review on or that should get applied needs to be sent to kvm@vger. If you want to tag it as PPC specific patch, do so by CC'ing kvm-ppc@vger. Will do in the next update -aneesh -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] kvm tools: arm: extract common timer support code for ARM cpus
The ARM V7 and V8 CPUs use the nearly identical support code for generating timer DT nodes as they both use ARM's architected timers. This code is currently duplicated for AArch32 and AArch64. This cleanup patch generalises timer DT node generation to follow the same pattern as for the GIC. The ability of a DT node to contain multiple compatible strings is exploited to allow an identical DT node to be used on V7 and V8 platforms. Signed-off-by: Jonathan Austin jonathan.aus...@arm.com Acked-by: Will Deacon will.dea...@arm.com --- tools/kvm/Makefile |6 +-- tools/kvm/arm/aarch32/arm-cpu.c | 35 + tools/kvm/arm/aarch32/cortex-a15.c | 61 --- tools/kvm/arm/aarch64/arm-cpu.c | 50 +++ tools/kvm/arm/aarch64/cortex-a57.c | 80 -- tools/kvm/arm/include/arm-common/timer.h |6 +++ tools/kvm/arm/timer.c| 38 ++ 7 files changed, 132 insertions(+), 144 deletions(-) create mode 100644 tools/kvm/arm/aarch32/arm-cpu.c delete mode 100644 tools/kvm/arm/aarch32/cortex-a15.c create mode 100644 tools/kvm/arm/aarch64/arm-cpu.c delete mode 100644 tools/kvm/arm/aarch64/cortex-a57.c create mode 100644 tools/kvm/arm/include/arm-common/timer.h create mode 100644 tools/kvm/arm/timer.c diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index b614aab..27fb2fb 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -157,12 +157,12 @@ endif # ARM OBJS_ARM_COMMON:= arm/fdt.o arm/gic.o arm/ioport.o arm/irq.o \ - arm/kvm.o arm/kvm-cpu.o + arm/kvm.o arm/kvm-cpu.o arm/timer.o HDRS_ARM_COMMON:= arm/include ifeq ($(ARCH), arm) DEFINES += -DCONFIG_ARM OBJS+= $(OBJS_ARM_COMMON) - OBJS+= arm/aarch32/cortex-a15.o + OBJS+= arm/aarch32/arm-cpu.o OBJS+= arm/aarch32/kvm-cpu.o ARCH_INCLUDE:= $(HDRS_ARM_COMMON) ARCH_INCLUDE+= -Iarm/aarch32/include @@ -175,7 +175,7 @@ endif ifeq ($(ARCH), arm64) DEFINES += -DCONFIG_ARM64 OBJS+= $(OBJS_ARM_COMMON) - OBJS+= arm/aarch64/cortex-a57.o + OBJS+= arm/aarch64/arm-cpu.o OBJS+= arm/aarch64/kvm-cpu.o ARCH_INCLUDE:= $(HDRS_ARM_COMMON) ARCH_INCLUDE+= -Iarm/aarch64/include diff --git a/tools/kvm/arm/aarch32/arm-cpu.c b/tools/kvm/arm/aarch32/arm-cpu.c new file mode 100644 index 000..8817d2a --- /dev/null +++ b/tools/kvm/arm/aarch32/arm-cpu.c @@ -0,0 +1,35 @@ +#include kvm/kvm.h +#include kvm/kvm-cpu.h +#include kvm/util.h + +#include arm-common/gic.h +#include arm-common/timer.h + +#include linux/byteorder.h +#include linux/types.h + +static void generate_fdt_nodes(void *fdt, struct kvm *kvm, u32 gic_phandle) +{ + int timer_interrupts[4] = {13, 14, 11, 10}; + + gic__generate_fdt_nodes(fdt, gic_phandle); + timer__generate_fdt_nodes(fdt, kvm, timer_interrupts); +} + +static int arm_cpu__vcpu_init(struct kvm_cpu *vcpu) +{ + vcpu-generate_fdt_nodes = generate_fdt_nodes; + return 0; +} + +static struct kvm_arm_target target_cortex_a15 = { + .id = KVM_ARM_TARGET_CORTEX_A15, + .compatible = arm,cortex-a15, + .init = arm_cpu__vcpu_init, +}; + +static int arm_cpu__core_init(struct kvm *kvm) +{ + return kvm_cpu__register_kvm_arm_target(target_cortex_a15); +} +core_init(arm_cpu__core_init); diff --git a/tools/kvm/arm/aarch32/cortex-a15.c b/tools/kvm/arm/aarch32/cortex-a15.c deleted file mode 100644 index ca65af7..000 --- a/tools/kvm/arm/aarch32/cortex-a15.c +++ /dev/null @@ -1,61 +0,0 @@ -#include kvm/fdt.h -#include kvm/kvm.h -#include kvm/kvm-cpu.h -#include kvm/util.h - -#include arm-common/gic.h - -#include linux/byteorder.h -#include linux/types.h - -static void generate_timer_nodes(void *fdt, struct kvm *kvm) -{ - u32 cpu_mask = (((1 kvm-nrcpus) - 1) GIC_FDT_IRQ_PPI_CPU_SHIFT) \ - GIC_FDT_IRQ_PPI_CPU_MASK; - u32 irq_prop[] = { - cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), - cpu_to_fdt32(13), - cpu_to_fdt32(cpu_mask | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI), - - cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), - cpu_to_fdt32(14), - cpu_to_fdt32(cpu_mask | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI), - - cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), - cpu_to_fdt32(11), - cpu_to_fdt32(cpu_mask | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI), - - cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), - cpu_to_fdt32(10), - cpu_to_fdt32(cpu_mask | GIC_FDT_IRQ_FLAGS_EDGE_LO_HI), - }; - - _FDT(fdt_begin_node(fdt, timer)); - _FDT(fdt_property_string(fdt, compatible, arm,armv7-timer)); -
[PATCH 0/2] kvm tools: arm: support Cortex-A7 CPUs
These two patches allow KVM-tool to exploit the Cortex-A7 support for KVM recently posted to the kvmarm mailing list. The first patch is a standalone cleanup to extract previously duplicated timer setup code, and allows us to add A7 support in a small subsequent patch. Note: the removal of the timer code makes git refuse to see the following: tools/kvm/arm/aarch32/{cortex_a15.c -- arm-cpu.c} tools/kvm/arm/aarch64/{cortex_a57.c -- arm-cpu.c} (even when passed -M40 git's decisions about what's new/renamed are confusing) The second patch should not be merged before the Cortex-A7 support patches posted recently to the kvmarm list hit the kernel, as kvm-tool for ARM will not build if KVM_ARM_TARGET_CORTEX_A7 (added with that series) is not defined. Jonathan Austin (2): kvm tools: arm: extract common timer support code for ARM cpus kvm tools: arm: add support for ARM Cortex-A7 tools/kvm/Makefile |6 +-- tools/kvm/arm/aarch32/arm-cpu.c | 42 tools/kvm/arm/aarch32/cortex-a15.c | 61 --- tools/kvm/arm/aarch64/arm-cpu.c | 50 +++ tools/kvm/arm/aarch64/cortex-a57.c | 80 -- tools/kvm/arm/include/arm-common/timer.h |6 +++ tools/kvm/arm/timer.c| 38 ++ 7 files changed, 139 insertions(+), 144 deletions(-) create mode 100644 tools/kvm/arm/aarch32/arm-cpu.c delete mode 100644 tools/kvm/arm/aarch32/cortex-a15.c create mode 100644 tools/kvm/arm/aarch64/arm-cpu.c delete mode 100644 tools/kvm/arm/aarch64/cortex-a57.c create mode 100644 tools/kvm/arm/include/arm-common/timer.h create mode 100644 tools/kvm/arm/timer.c -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] kvm tools: arm: add support for ARM Cortex-A7
The Cortex-A7 is very similar to the Cortex-A15 and as such there is very little extra infrastructure required for KVM tool to be able to create A7-guests. This patch adds the basic support and allows booting of A7 guests on A7 hosts. It depends on Cortex-A7 support patches posted recently to the kvmarm list. Signed-off-by: Jonathan Austin jonathan.aus...@arm.com --- tools/kvm/arm/aarch32/arm-cpu.c |9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/kvm/arm/aarch32/arm-cpu.c b/tools/kvm/arm/aarch32/arm-cpu.c index 8817d2a..71b98fe 100644 --- a/tools/kvm/arm/aarch32/arm-cpu.c +++ b/tools/kvm/arm/aarch32/arm-cpu.c @@ -28,8 +28,15 @@ static struct kvm_arm_target target_cortex_a15 = { .init = arm_cpu__vcpu_init, }; +static struct kvm_arm_target target_cortex_a7 = { + .id = KVM_ARM_TARGET_CORTEX_A7, + .compatible = arm,cortex-a7, + .init = arm_cpu__vcpu_init, +}; + static int arm_cpu__core_init(struct kvm *kvm) { - return kvm_cpu__register_kvm_arm_target(target_cortex_a15); + return (kvm_cpu__register_kvm_arm_target(target_cortex_a15) || + kvm_cpu__register_kvm_arm_target(target_cortex_a7)); } core_init(arm_cpu__core_init); -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Donation
Dave And Nancy HoneyWell Donation Of £1,500,000.00GBP Contact us for your charity donation. Email: daveandhoneyw...@live.com -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 03/11] kvm: powerpc: book3s: move book3s_64_vio_hv.c into the main kernel binary
From: Paul Mackerras pau...@samba.org Since the code in book3s_64_vio_hv.c is called from real mode with HV KVM, and therefore has to be built into the main kernel binary, this makes it always built-in rather than part of the KVM module. It gets called from the KVM module by PR KVM, so this adds an EXPORT_SYMBOL_GPL(). Signed-off-by: Paul Mackerras pau...@samba.org Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/kvm/Makefile | 12 arch/powerpc/kvm/book3s_64_vio_hv.c | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile index 6646c95..104e8dc 100644 --- a/arch/powerpc/kvm/Makefile +++ b/arch/powerpc/kvm/Makefile @@ -53,32 +53,36 @@ kvm-e500mc-objs := \ e500_emulate.o kvm-objs-$(CONFIG_KVM_E500MC) := $(kvm-e500mc-objs) +kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) := \ + book3s_64_vio_hv.o + kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_PR) := \ $(KVM)/coalesced_mmio.o \ fpu.o \ book3s_paired_singles.o \ book3s_pr.o \ book3s_pr_papr.o \ - book3s_64_vio_hv.o \ book3s_emulate.o \ book3s_interrupts.o \ book3s_mmu_hpte.o \ book3s_64_mmu_host.o \ book3s_64_mmu.o \ book3s_32_mmu.o -kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_PR) := \ + +kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_PR) += \ book3s_rmhandlers.o kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) := \ book3s_hv.o \ book3s_hv_interrupts.o \ book3s_64_mmu_hv.o + kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \ book3s_hv_rm_xics.o -kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HV) := \ + +kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \ book3s_hv_rmhandlers.o \ book3s_hv_rm_mmu.o \ - book3s_64_vio_hv.o \ book3s_hv_ras.o \ book3s_hv_builtin.o \ book3s_hv_cma.o \ diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c index 30c2f3b..70d6594 100644 --- a/arch/powerpc/kvm/book3s_64_vio_hv.c +++ b/arch/powerpc/kvm/book3s_64_vio_hv.c @@ -74,3 +74,5 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn, /* Didn't find the liobn, punt it to userspace */ return H_TOO_HARD; } +EXPORT_SYMBOL_GPL(kvmppc_h_put_tce); + -- 1.8.1.2 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 01/11] kvm: powerpc: book3s hv: Fix vcore leak
From: Paul Mackerras pau...@samba.org add kvmppc_free_vcores() to free the kvmppc_vcore structures that we allocate for a guest, which are currently being leaked. Signed-off-by: Paul Mackerras pau...@samba.org Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/kvm/book3s_hv.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 62a2b5a..edc7f9f 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1931,10 +1931,20 @@ int kvmppc_core_init_vm(struct kvm *kvm) return 0; } +static void kvmppc_free_vcores(struct kvm *kvm) +{ + long int i; + + for (i = 0; i KVM_MAX_VCORES; ++i) + kfree(kvm-arch.vcores[i]); + kvm-arch.online_vcores = 0; +} + void kvmppc_core_destroy_vm(struct kvm *kvm) { uninhibit_secondary_onlining(); + kvmppc_free_vcores(kvm); if (kvm-arch.rma) { kvm_release_rma(kvm-arch.rma); kvm-arch.rma = NULL; -- 1.8.1.2 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 04/11] kvm: powerpc: book3s: Add a new config variable CONFIG_KVM_BOOK3S_HV
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This help ups to select the relevant code in the kernel code when we later move HV and PR bits as seperate modules. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_book3s_64.h | 6 +++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 +- arch/powerpc/include/asm/kvm_host.h | 10 +- arch/powerpc/include/asm/kvm_ppc.h| 2 +- arch/powerpc/kernel/asm-offsets.c | 8 arch/powerpc/kernel/exceptions-64s.S | 2 +- arch/powerpc/kernel/idle_power7.S | 2 +- arch/powerpc/kvm/Kconfig | 4 arch/powerpc/kvm/book3s_exports.c | 5 +++-- arch/powerpc/kvm/book3s_xics.c| 4 ++-- 10 files changed, 25 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h index 86d638a..37af4ae 100644 --- a/arch/powerpc/include/asm/kvm_book3s_64.h +++ b/arch/powerpc/include/asm/kvm_book3s_64.h @@ -35,7 +35,7 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu) #define SPAPR_TCE_SHIFT12 -#ifdef CONFIG_KVM_BOOK3S_64_HV +#ifdef CONFIG_KVM_BOOK3S_HV #define KVM_DEFAULT_HPT_ORDER 24 /* 16MB HPT by default */ extern unsigned long kvm_rma_pages; #endif @@ -278,7 +278,7 @@ static inline int is_vrma_hpte(unsigned long hpte_v) (HPTE_V_1TB_SEG | (VRMA_VSID (40 - 16))); } -#ifdef CONFIG_KVM_BOOK3S_64_HV +#ifdef CONFIG_KVM_BOOK3S_HV /* * Note modification of an HPTE; set the HPTE modified bit * if anyone is interested. @@ -289,6 +289,6 @@ static inline void note_hpte_modification(struct kvm *kvm, if (atomic_read(kvm-arch.hpte_mod_interest)) rev-guest_rpte |= HPTE_GR_MODIFIED; } -#endif /* CONFIG_KVM_BOOK3S_64_HV */ +#endif /* CONFIG_KVM_BOOK3S_HV */ #endif /* __ASM_KVM_BOOK3S_64_H__ */ diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h b/arch/powerpc/include/asm/kvm_book3s_asm.h index 360742a..1272178 100644 --- a/arch/powerpc/include/asm/kvm_book3s_asm.h +++ b/arch/powerpc/include/asm/kvm_book3s_asm.h @@ -84,7 +84,7 @@ struct kvmppc_host_state { u8 restore_hid5; u8 napping; -#ifdef CONFIG_KVM_BOOK3S_64_HV +#ifdef CONFIG_KVM_BOOK3S_HV u8 hwthread_req; u8 hwthread_state; u8 host_ipi; diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 78627c2..283e52e 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -229,15 +229,15 @@ struct revmap_entry { #define KVMPPC_GOT_PAGE0x80 struct kvm_arch_memory_slot { -#ifdef CONFIG_KVM_BOOK3S_64_HV +#ifdef CONFIG_KVM_BOOK3S_HV unsigned long *rmap; unsigned long *slot_phys; -#endif /* CONFIG_KVM_BOOK3S_64_HV */ +#endif /* CONFIG_KVM_BOOK3S_HV */ }; struct kvm_arch { unsigned int lpid; -#ifdef CONFIG_KVM_BOOK3S_64_HV +#ifdef CONFIG_KVM_BOOK3S_HV unsigned long hpt_virt; struct revmap_entry *revmap; unsigned int host_lpid; @@ -261,7 +261,7 @@ struct kvm_arch { cpumask_t need_tlb_flush; struct kvmppc_vcore *vcores[KVM_MAX_VCORES]; int hpt_cma_alloc; -#endif /* CONFIG_KVM_BOOK3S_64_HV */ +#endif /* CONFIG_KVM_BOOK3S_HV */ #ifdef CONFIG_KVM_BOOK3S_PR struct mutex hpt_mutex; bool relon_disabled; @@ -598,7 +598,7 @@ struct kvm_vcpu_arch { struct kvmppc_icp *icp; /* XICS presentation controller */ #endif -#ifdef CONFIG_KVM_BOOK3S_64_HV +#ifdef CONFIG_KVM_BOOK3S_HV struct kvm_vcpu_arch_shared shregs; unsigned long pgfault_addr; diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index b15554a..9161bd1 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -260,7 +260,7 @@ void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid); struct openpic; -#ifdef CONFIG_KVM_BOOK3S_64_HV +#ifdef CONFIG_KVM_BOOK3S_HV extern void kvm_cma_reserve(void) __init; static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) { diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 67b5d56..dd7ad4a 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -445,7 +445,7 @@ int main(void) DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr)); DEFINE(VCPU_PC, offsetof(struct kvm_vcpu, arch.pc)); -#ifdef CONFIG_KVM_BOOK3S_64_HV +#ifdef CONFIG_KVM_BOOK3S_HV DEFINE(VCPU_MSR, offsetof(struct kvm_vcpu, arch.shregs.msr)); DEFINE(VCPU_SRR0, offsetof(struct kvm_vcpu, arch.shregs.srr0)); DEFINE(VCPU_SRR1, offsetof(struct kvm_vcpu, arch.shregs.srr1)); @@ -476,7 +476,7 @@ int main(void) DEFINE(KVM_LPID, offsetof(struct kvm, arch.lpid)); /* book3s */ -#ifdef
[RFC PATCH 06/11] kvm: powerpc: book3s: Add is_hv_enabled to kvmppc_ops
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This help us to identify whether we are running with hypervisor mode KVM enabled. The change is needed so that we can have both HV and PR kvm enabled in the same kernel. If both HV and PR KVM are included, interrupts come in to the HV version of the kvmppc_interrupt code, which then jumps to the PR handler, renamed to kvmppc_interrupt_pr, if the guest is a PR guest. Allowing both PR and HV in the same kernel required some changes to kvm_dev_ioctl_check_extension(), since the values returned now can't be selected with #ifdefs as much as previously. We look at is_hv_enabled to return the right value when checking for capabilities.For capabilities that are only provided by HV KVM, we return the HV value only if is_hv_enabled is true. For capabilities provided by PR KVM but not HV, we return the PR value only if is_hv_enabled is false. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_book3s.h | 53 arch/powerpc/include/asm/kvm_ppc.h | 5 +-- arch/powerpc/kvm/Makefile | 2 +- arch/powerpc/kvm/book3s.c | 44 +++ arch/powerpc/kvm/book3s_hv.c| 1 + arch/powerpc/kvm/book3s_hv_rmhandlers.S | 4 +++ arch/powerpc/kvm/book3s_pr.c| 1 + arch/powerpc/kvm/book3s_segment.S | 7 - arch/powerpc/kvm/book3s_xics.c | 2 +- arch/powerpc/kvm/powerpc.c | 54 ++--- 10 files changed, 90 insertions(+), 83 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 3efba3c..ba33c49 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h @@ -297,59 +297,6 @@ static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) return vcpu-arch.fault_dar; } -#ifdef CONFIG_KVM_BOOK3S_PR - -static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) -{ - return to_book3s(vcpu)-hior; -} - -static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, - unsigned long pending_now, unsigned long old_pending) -{ - if (pending_now) - vcpu-arch.shared-int_pending = 1; - else if (old_pending) - vcpu-arch.shared-int_pending = 0; -} - -static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) -{ - ulong crit_raw = vcpu-arch.shared-critical; - ulong crit_r1 = kvmppc_get_gpr(vcpu, 1); - bool crit; - - /* Truncate crit indicators in 32 bit mode */ - if (!(vcpu-arch.shared-msr MSR_SF)) { - crit_raw = 0x; - crit_r1 = 0x; - } - - /* Critical section when crit == r1 */ - crit = (crit_raw == crit_r1); - /* ... and we're in supervisor mode */ - crit = crit !(vcpu-arch.shared-msr MSR_PR); - - return crit; -} -#else /* CONFIG_KVM_BOOK3S_PR */ - -static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) -{ - return 0; -} - -static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, - unsigned long pending_now, unsigned long old_pending) -{ -} - -static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) -{ - return false; -} -#endif - /* Magic register values loaded into r3 and r4 before the 'sc' assembly * instruction for the OSI hypercalls */ #define OSI_SC_MAGIC_R30x113724FA diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 4d9641c..58e732f 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -169,6 +169,7 @@ extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq); extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq); struct kvmppc_ops { + bool is_hv_enabled; int (*get_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int (*set_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int (*get_one_reg)(struct kvm_vcpu *vcpu, u64 id, @@ -309,10 +310,10 @@ static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) static inline u32 kvmppc_get_xics_latch(void) { - u32 xirr = get_paca()-kvm_hstate.saved_xirr; + u32 xirr; + xirr = get_paca()-kvm_hstate.saved_xirr; get_paca()-kvm_hstate.saved_xirr = 0; - return xirr; } diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile index c343793..a514ecd 100644 --- a/arch/powerpc/kvm/Makefile +++ b/arch/powerpc/kvm/Makefile @@ -77,7 +77,7 @@ kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \ book3s_rmhandlers.o endif -kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) := \ +kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \ book3s_hv.o \ book3s_hv_interrupts.o \ book3s_64_mmu_hv.o diff --git
[RFC PATCH 09/11] kvm: simplify processor compat check
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/arm/kvm/arm.c | 4 ++-- arch/ia64/kvm/kvm-ia64.c | 4 ++-- arch/mips/kvm/kvm_mips.c | 6 ++ arch/powerpc/include/asm/kvm_ppc.h | 2 +- arch/powerpc/kvm/44x.c | 2 +- arch/powerpc/kvm/book3s.c | 15 --- arch/powerpc/kvm/book3s_hv.c | 9 ++--- arch/powerpc/kvm/book3s_pr.c | 5 +++-- arch/powerpc/kvm/e500.c| 2 +- arch/powerpc/kvm/e500mc.c | 2 +- arch/powerpc/kvm/powerpc.c | 5 - arch/s390/kvm/kvm-s390.c | 3 ++- arch/x86/kvm/x86.c | 13 +++-- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c| 14 +- 15 files changed, 50 insertions(+), 38 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 9c697db..cccb121 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -109,9 +109,9 @@ void kvm_arch_hardware_unsetup(void) { } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - *(int *)rtn = 0; + return 0; } void kvm_arch_sync_events(struct kvm *kvm) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index bdfd878..065942c 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -185,9 +185,9 @@ void kvm_arch_hardware_disable(void *garbage) ia64_ptr_entry(0x3, slot); } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - *(int *)rtn = 0; + return 0; } int kvm_dev_ioctl_check_extension(long ext) diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c index a7b0445..4512739 100644 --- a/arch/mips/kvm/kvm_mips.c +++ b/arch/mips/kvm/kvm_mips.c @@ -97,11 +97,9 @@ void kvm_arch_hardware_unsetup(void) { } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - int *r = (int *)rtn; - *r = 0; - return; + return 0; } static void kvm_mips_init_tlbs(struct kvm *kvm) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 58e732f..592501b 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -204,7 +204,7 @@ struct kvmppc_ops { unsigned long npages); int (*init_vm)(struct kvm *kvm); void (*destroy_vm)(struct kvm *kvm); - int (*check_processor_compat)(void); + void (*check_processor_compat)(void *r); int (*get_smmu_info)(struct kvm *kvm, struct kvm_ppc_smmu_info *info); int (*emulate_op)(struct kvm_run *run, struct kvm_vcpu *vcpu, unsigned int inst, int *advance); diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c index 2f5c6b6..a1f4e60 100644 --- a/arch/powerpc/kvm/44x.c +++ b/arch/powerpc/kvm/44x.c @@ -43,7 +43,7 @@ void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu) kvmppc_booke_vcpu_put(vcpu); } -int kvmppc_core_check_processor_compat(void) +int kvm_arch_check_processor_compat(void *opaque) { int r; diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index ca617e1..485a6ff 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -827,9 +827,18 @@ void kvmppc_core_destroy_vm(struct kvm *kvm) #endif } -int kvmppc_core_check_processor_compat(void) -{ - return kvmppc_ops-check_processor_compat(); +int kvm_arch_check_processor_compat(void *opaque) +{ + int r,cpu; + struct kvmppc_ops *kvm_ops = (struct kvmppc_ops *)opaque; + for_each_online_cpu(cpu) { + smp_call_function_single(cpu, +kvm_ops-check_processor_compat, +r, 1); + if (r 0) + break; + } + return r; } EXPORT_SYMBOL_GPL(kvm_get_dirty_log); diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index ff57be8..4322db4 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1980,11 +1980,14 @@ static int kvmppc_core_emulate_mfspr_hv(struct kvm_vcpu *vcpu, int sprn, return EMULATE_FAIL; } -static int kvmppc_core_check_processor_compat_hv(void) + +static void kvmppc_core_check_processor_compat_hv(void *r) { if (!cpu_has_feature(CPU_FTR_HVMODE)) - return -EIO; - return 0; + *(int *)r = -EIO; + else + *(int *)r = 0; + return; } static long kvm_arch_vm_ioctl_hv(struct file *filp, diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index df48d89..127b961 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -1490,10 +1490,11 @@ static void kvmppc_core_destroy_vm_pr(struct kvm *kvm)
[RFC PATCH 05/11] kvm: powerpc: book3s: Add kvmppc_ops callback for HV and PR specific operations
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This moves HV and PR specific functions to kvmppc_ops callback. This is needed so that we can enable HV and PR together in the same kernel. Actual changes to enable both come in the later patch.This also renames almost all of the symbols that exist in both PR and HV KVM for clarity. Symbols in the PR KVM implementation get _pr appended, and those in the HV KVM implementation get _hv. Then, in book3s.c, we add a function with the name without the suffix and arrange for it to call the appropriate kvmppc_ops callback depending on which kvm type we selected during VM creation. NOTE: we still don't enable selecting both the HV and PR together in this commit that will be done by a later commit. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_book3s.h | 5 +- arch/powerpc/include/asm/kvm_ppc.h| 63 -- arch/powerpc/kvm/Kconfig | 15 ++- arch/powerpc/kvm/Makefile | 9 +- arch/powerpc/kvm/book3s.c | 145 +- arch/powerpc/kvm/book3s_32_mmu_host.c | 2 +- arch/powerpc/kvm/book3s_64_mmu_host.c | 2 +- arch/powerpc/kvm/book3s_64_mmu_hv.c | 17 ++- arch/powerpc/kvm/book3s_emulate.c | 8 +- arch/powerpc/kvm/book3s_hv.c | 226 +- arch/powerpc/kvm/book3s_interrupts.S | 2 +- arch/powerpc/kvm/book3s_pr.c | 196 ++--- arch/powerpc/kvm/emulate.c| 6 +- arch/powerpc/kvm/powerpc.c| 58 +++-- 14 files changed, 539 insertions(+), 215 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 1b32f6c..3efba3c 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h @@ -24,6 +24,8 @@ #include linux/kvm_host.h #include asm/kvm_book3s_asm.h +union kvmppc_one_reg; + struct kvmppc_bat { u64 raw; u32 bepi; @@ -124,7 +126,6 @@ extern void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, ulong ea, ulong ea_mask) extern void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 vp, u64 vp_mask); extern void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end); extern void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 new_msr); -extern void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr); extern void kvmppc_mmu_book3s_64_init(struct kvm_vcpu *vcpu); extern void kvmppc_mmu_book3s_32_init(struct kvm_vcpu *vcpu); extern void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu); @@ -193,8 +194,6 @@ static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu) return vcpu-arch.book3s; } -extern void kvm_return_point(void); - /* Also add subarch specific defines */ #ifdef CONFIG_KVM_BOOK3S_32_HANDLER diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 9161bd1..4d9641c 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -106,13 +106,6 @@ extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq); extern void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu); extern void kvmppc_core_flush_tlb(struct kvm_vcpu *vcpu); - -extern int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, - unsigned int op, int *advance); -extern int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, -ulong val); -extern int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, -ulong *val); extern int kvmppc_core_check_requests(struct kvm_vcpu *vcpu); extern int kvmppc_booke_init(void); @@ -135,8 +128,6 @@ extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, struct kvm_create_spapr_tce *args); extern long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn, unsigned long ioba, unsigned long tce); -extern long kvm_vm_ioctl_allocate_rma(struct kvm *kvm, - struct kvm_allocate_rma *rma); extern struct kvm_rma_info *kvm_alloc_rma(void); extern void kvm_release_rma(struct kvm_rma_info *ri); extern struct page *kvm_alloc_hpt(unsigned long nr_pages); @@ -177,6 +168,55 @@ extern int kvmppc_xics_get_xive(struct kvm *kvm, u32 irq, u32 *server, extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq); extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq); +struct kvmppc_ops { + int (*get_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); + int (*set_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); + int (*get_one_reg)(struct kvm_vcpu *vcpu, u64 id, + union kvmppc_one_reg *val); + int (*set_one_reg)(struct kvm_vcpu *vcpu, u64 id, + union kvmppc_one_reg
[RFC PATCH 11/11] kvm: powerpc: book3s: Fix module ownership
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This moves /dev/kvm ownership to kvm.ko module. Depending on which KVM mode we select during VM creation we take a reference count on respective module Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/book3s.c | 21 + arch/powerpc/kvm/book3s_hv.c | 15 ++- arch/powerpc/kvm/book3s_pr.c | 15 +-- arch/powerpc/kvm/powerpc.c | 19 +++ 5 files changed, 48 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index a4a5893..2022720 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -171,6 +171,7 @@ extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq); extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq); struct kvmppc_ops { + struct module *owner; bool is_hv_enabled; int (*get_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int (*set_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 34e189c..363df6a 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -831,6 +831,10 @@ int kvm_arch_check_processor_compat(void *opaque) { int r,cpu; struct kvmppc_ops *kvm_ops = (struct kvmppc_ops *)opaque; + + if (!kvm_ops) + return 0; + for_each_online_cpu(cpu) { smp_call_function_single(cpu, kvm_ops-check_processor_compat, @@ -840,6 +844,7 @@ int kvm_arch_check_processor_compat(void *opaque) } return r; } +EXPORT_SYMBOL_GPL(kvm_arch_check_processor_compat); EXPORT_SYMBOL_GPL(kvm_get_dirty_log); EXPORT_SYMBOL_GPL(kvmppc_core_pending_dec); @@ -851,3 +856,19 @@ EXPORT_SYMBOL_GPL(kvmppc_core_prepare_to_enter); EXPORT_SYMBOL_GPL(kvmppc_core_queue_dec); EXPORT_SYMBOL_GPL(kvmppc_free_lpid); +static int kvmppc_book3s_init(void) +{ + int r; + + r = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); + return r; +} + +static void kvmppc_book3s_exit(void) +{ + kvm_exit(); +} + +module_init(kvmppc_book3s_init); +module_exit(kvmppc_book3s_exit); + diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 0a684a7..7bdc780 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -2092,23 +2092,20 @@ static int kvmppc_book3s_init_hv(void) { int r; - if (!kvmppc_pr_ops) { - r = kvm_init(kvm_ops_hv, sizeof(struct kvm_vcpu), -0, THIS_MODULE); - if (r) - return r; - } + r = kvm_arch_check_processor_compat(kvm_ops_hv); + if (r 0) + return r; + + kvm_ops_hv.owner = THIS_MODULE; kvmppc_hv_ops = kvm_ops_hv; - r = kvmppc_mmu_hv_init(); + r = kvmppc_mmu_hv_init(); return r; } static void kvmppc_book3s_exit_hv(void) { kvmppc_hv_ops = NULL; - if (!kvmppc_pr_ops) - kvm_exit(); } module_init(kvmppc_book3s_init_hv); diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index e49e4b0..c79fada 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -1551,17 +1551,14 @@ static int kvmppc_book3s_init_pr(void) { int r; - if (!kvmppc_hv_ops) { - r = kvm_init(kvm_ops_pr, sizeof(struct kvm_vcpu), -0, THIS_MODULE); - if (r) - return r; - } - /* Assign the global value */ + r = kvm_arch_check_processor_compat(kvm_ops_pr); + if (r 0) + return r; + + kvm_ops_pr.owner = THIS_MODULE; kvmppc_pr_ops = kvm_ops_pr; r = kvmppc_mmu_hpte_sysinit(); - return r; } @@ -1569,8 +1566,6 @@ static void kvmppc_book3s_exit_pr(void) { kvmppc_pr_ops = NULL; kvmppc_mmu_hpte_sysexit(); - if (!kvmppc_hv_ops) - kvm_exit(); } module_init(kvmppc_book3s_init_pr); diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 1209229..677fa7e 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -26,6 +26,7 @@ #include linux/fs.h #include linux/slab.h #include linux/file.h +#include linux/module.h #include asm/cputable.h #include asm/uaccess.h #include asm/kvm_ppc.h @@ -270,25 +271,32 @@ void kvm_arch_hardware_unsetup(void) int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) { + struct kvmppc_ops *kvm_ops = NULL; /* * if we have both HV and PR enabled, default is HV */ if (type == 0) { if (kvmppc_hv_ops) - kvm-arch.kvm_ops = kvmppc_hv_ops; +
[RFC PATCH 00/11 Allow PR and HV KVM to coexist in one kernel
Hi All, This patch series support enabling HV and PR KVM together in the same kernel. We extend machine property with new property kvm_type. A value of 1 will force HV KVM and 2 PR KVM. The default value is 0 which will select the fastest KVM mode. ie, HV if that is supported otherwise PR. With Qemu command line having -machine pseries,accel=kvm,kvm_type=1 [root@llmp24l02 qemu]# bash ../qemu failed to initialize KVM: Invalid argument [root@llmp24l02 qemu]# modprobe kvm-pr [root@llmp24l02 qemu]# bash ../qemu failed to initialize KVM: Invalid argument [root@llmp24l02 qemu]# modprobe kvm-hv [root@llmp24l02 qemu]# bash ../qemu now with -machine pseries,accel=kvm,kvm_type=2 [root@llmp24l02 qemu]# rmmod kvm-pr [root@llmp24l02 qemu]# bash ../qemu failed to initialize KVM: Invalid argument [root@llmp24l02 qemu]# [root@llmp24l02 qemu]# modprobe kvm-pr [root@llmp24l02 qemu]# bash ../qemu if don't specify kvm_type machine property, it will take a default value 0, which means fastest supported. -aneesh -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 07/11] kvm: powerpc: book3s: pr: move PR related tracepoints to a separate header
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This patch moves PR related tracepoints to a separate header. This enables in converting PR to a kernel module which will be done in later patches Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/kvm/book3s_64_mmu_host.c | 2 +- arch/powerpc/kvm/book3s_mmu_hpte.c| 2 +- arch/powerpc/kvm/book3s_pr.c | 3 +- arch/powerpc/kvm/trace.h | 234 +-- arch/powerpc/kvm/trace_pr.h | 297 ++ 5 files changed, 308 insertions(+), 230 deletions(-) create mode 100644 arch/powerpc/kvm/trace_pr.h diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c index 329a978..fd5b393 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_host.c +++ b/arch/powerpc/kvm/book3s_64_mmu_host.c @@ -27,7 +27,7 @@ #include asm/machdep.h #include asm/mmu_context.h #include asm/hw_irq.h -#include trace.h +#include trace_pr.h #define PTE_SIZE 12 diff --git a/arch/powerpc/kvm/book3s_mmu_hpte.c b/arch/powerpc/kvm/book3s_mmu_hpte.c index d2d280b..4556168 100644 --- a/arch/powerpc/kvm/book3s_mmu_hpte.c +++ b/arch/powerpc/kvm/book3s_mmu_hpte.c @@ -28,7 +28,7 @@ #include asm/mmu_context.h #include asm/hw_irq.h -#include trace.h +#include trace_pr.h #define PTE_SIZE 12 diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 2a97279..99d0839 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -41,7 +41,8 @@ #include linux/vmalloc.h #include linux/highmem.h -#include trace.h +#define CREATE_TRACE_POINTS +#include trace_pr.h /* #define EXIT_DEBUG */ /* #define DEBUG_EXT */ diff --git a/arch/powerpc/kvm/trace.h b/arch/powerpc/kvm/trace.h index a088e9a..7d5a136 100644 --- a/arch/powerpc/kvm/trace.h +++ b/arch/powerpc/kvm/trace.h @@ -85,6 +85,12 @@ TRACE_EVENT(kvm_ppc_instr, {41, HV_PRIV} #endif +#ifndef CONFIG_KVM_BOOK3S_PR +/* + * For pr we define this in trace_pr.h since it pr can be built as + * a module + */ + TRACE_EVENT(kvm_exit, TP_PROTO(unsigned int exit_nr, struct kvm_vcpu *vcpu), TP_ARGS(exit_nr, vcpu), @@ -94,9 +100,6 @@ TRACE_EVENT(kvm_exit, __field(unsigned long, pc ) __field(unsigned long, msr ) __field(unsigned long, dar ) -#ifdef CONFIG_KVM_BOOK3S_PR - __field(unsigned long, srr1) -#endif __field(unsigned long, last_inst ) ), @@ -105,9 +108,6 @@ TRACE_EVENT(kvm_exit, __entry-pc = kvmppc_get_pc(vcpu); __entry-dar= kvmppc_get_fault_dar(vcpu); __entry-msr= vcpu-arch.shared-msr; -#ifdef CONFIG_KVM_BOOK3S_PR - __entry-srr1 = vcpu-arch.shadow_srr1; -#endif __entry-last_inst = vcpu-arch.last_inst; ), @@ -115,18 +115,12 @@ TRACE_EVENT(kvm_exit, | pc=0x%lx | msr=0x%lx | dar=0x%lx -#ifdef CONFIG_KVM_BOOK3S_PR -| srr1=0x%lx -#endif | last_inst=0x%lx , __print_symbolic(__entry-exit_nr, kvm_trace_symbol_exit), __entry-pc, __entry-msr, __entry-dar, -#ifdef CONFIG_KVM_BOOK3S_PR - __entry-srr1, -#endif __entry-last_inst ) ); @@ -145,6 +139,7 @@ TRACE_EVENT(kvm_unmap_hva, TP_printk(unmap hva 0x%lx\n, __entry-hva) ); +#endif TRACE_EVENT(kvm_stlb_inval, TP_PROTO(unsigned int stlb_index), @@ -231,221 +226,6 @@ TRACE_EVENT(kvm_check_requests, __entry-cpu_nr, __entry-requests) ); - -/* - * Book3S trace points * - */ - -#ifdef CONFIG_KVM_BOOK3S_PR - -TRACE_EVENT(kvm_book3s_reenter, - TP_PROTO(int r, struct kvm_vcpu *vcpu), - TP_ARGS(r, vcpu), - - TP_STRUCT__entry( - __field(unsigned int, r ) - __field(unsigned long, pc ) - ), - - TP_fast_assign( - __entry-r = r; - __entry-pc = kvmppc_get_pc(vcpu); - ), - - TP_printk(reentry r=%d | pc=0x%lx, __entry-r, __entry-pc) -); - -#ifdef CONFIG_PPC_BOOK3S_64 - -TRACE_EVENT(kvm_book3s_64_mmu_map, - TP_PROTO(int rflags, ulong hpteg, ulong va, pfn_t hpaddr, -struct kvmppc_pte *orig_pte), - TP_ARGS(rflags, hpteg, va, hpaddr, orig_pte), - - TP_STRUCT__entry( - __field(unsigned char, flag_w ) -
[RFC PATCH 08/11] kvm: powerpc: book3s: Support building HV and PR KVM as module
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/kvm/Kconfig | 6 +++--- arch/powerpc/kvm/Makefile | 12 arch/powerpc/kvm/book3s.c | 19 ++- arch/powerpc/kvm/book3s_64_mmu_host.c | 1 + arch/powerpc/kvm/book3s_emulate.c | 2 +- arch/powerpc/kvm/book3s_hv.c | 4 arch/powerpc/kvm/book3s_pr.c | 5 - arch/powerpc/kvm/book3s_rtas.c| 1 + arch/powerpc/kvm/emulate.c| 1 + arch/powerpc/kvm/powerpc.c| 6 ++ virt/kvm/kvm_main.c | 3 +++ 11 files changed, 50 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig index 5c62459..f63fd8f 100644 --- a/arch/powerpc/kvm/Kconfig +++ b/arch/powerpc/kvm/Kconfig @@ -73,7 +73,7 @@ config KVM_BOOK3S_64 If unsure, say N. config KVM_BOOK3S_64_HV - bool KVM support for POWER7 and PPC970 using hypervisor mode in host + tristate KVM support for POWER7 and PPC970 using hypervisor mode in host depends on KVM_BOOK3S_64 select KVM_BOOK3S_HV select MMU_NOTIFIER @@ -94,8 +94,8 @@ config KVM_BOOK3S_64_HV If unsure, say N. config KVM_BOOK3S_64_PR - bool KVM support without using hypervisor mode in host - depends on KVM_BOOK3S_64 !KVM_BOOK3S_64_HV + tristate KVM support without using hypervisor mode in host + depends on KVM_BOOK3S_64 select KVM_BOOK3S_PR ---help--- Support running guest kernels in virtual machines on processors diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile index a514ecd..861b8da 100644 --- a/arch/powerpc/kvm/Makefile +++ b/arch/powerpc/kvm/Makefile @@ -56,8 +56,7 @@ kvm-objs-$(CONFIG_KVM_E500MC) := $(kvm-e500mc-objs) kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) := \ book3s_64_vio_hv.o -kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_PR) := \ - $(KVM)/coalesced_mmio.o \ +kvm-pr-y := \ fpu.o \ book3s_paired_singles.o \ book3s_pr.o \ @@ -77,7 +76,7 @@ kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \ book3s_rmhandlers.o endif -kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \ +kvm-hv-y += \ book3s_hv.o \ book3s_hv_interrupts.o \ book3s_64_mmu_hv.o @@ -85,13 +84,15 @@ kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \ kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \ book3s_hv_rm_xics.o -kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \ +ifdef CONFIG_KVM_BOOK3S_HV +kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \ book3s_hv_rmhandlers.o \ book3s_hv_rm_mmu.o \ book3s_hv_ras.o \ book3s_hv_builtin.o \ book3s_hv_cma.o \ $(kvm-book3s_64-builtin-xics-objs-y) +endif kvm-book3s_64-objs-$(CONFIG_KVM_XICS) += \ book3s_xics.o @@ -132,4 +133,7 @@ obj-$(CONFIG_KVM_E500MC) += kvm.o obj-$(CONFIG_KVM_BOOK3S_64) += kvm.o obj-$(CONFIG_KVM_BOOK3S_32) += kvm.o +obj-$(CONFIG_KVM_BOOK3S_64_PR) += kvm-pr.o +obj-$(CONFIG_KVM_BOOK3S_64_HV) += kvm-hv.o + obj-y += $(kvm-book3s_64-builtin-objs-y) diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 12f94bf..ca617e1 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -170,13 +170,14 @@ void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec) printk(KERN_INFO Queueing interrupt %x\n, vec); #endif } - +EXPORT_SYMBOL_GPL(kvmppc_book3s_queue_irqprio); void kvmppc_core_queue_program(struct kvm_vcpu *vcpu, ulong flags) { /* might as well deliver this straight away */ kvmppc_inject_interrupt(vcpu, BOOK3S_INTERRUPT_PROGRAM, flags); } +EXPORT_SYMBOL_GPL(kvmppc_core_queue_program); void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu) { @@ -351,6 +352,7 @@ pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn) return gfn_to_pfn(vcpu-kvm, gfn); } +EXPORT_SYMBOL_GPL(kvmppc_gfn_to_pfn); static int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr, bool data, struct kvmppc_pte *pte) @@ -418,6 +420,7 @@ int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, return EMULATE_DONE; } +EXPORT_SYMBOL_GPL(kvmppc_st); int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data) @@ -448,6 +451,7 @@ nopte: mmio: return EMULATE_DO_MMIO; } +EXPORT_SYMBOL_GPL(kvmppc_ld); int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) { @@ -693,6 +697,7 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 msr) { kvmppc_ops-set_msr(vcpu, msr); } +EXPORT_SYMBOL_GPL(kvmppc_set_msr); int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) { @@ -774,6 +779,7 @@ int kvm_unmap_hva(struct kvm *kvm, unsigned long hva) { return
[RFC PATCH 10/11] kvm: powerpc: book3s: Allow the HV and PR selection per virtual machine
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This moves the kvmppc_ops callbacks to be a per VM entity. This enables us to select HV and PR mode when creating a VM Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_host.h | 3 ++ arch/powerpc/include/asm/kvm_ppc.h | 11 -- arch/powerpc/kvm/book3s.c | 60 +++--- arch/powerpc/kvm/book3s_hv.c| 18 + arch/powerpc/kvm/book3s_pr.c| 18 ++--- arch/powerpc/kvm/emulate.c | 11 +++--- arch/powerpc/kvm/powerpc.c | 74 - include/linux/kvm_host.h| 7 ++-- include/uapi/linux/kvm.h| 4 ++ virt/kvm/kvm_main.c | 18 - 10 files changed, 135 insertions(+), 89 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 283e52e..61a297fc 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -276,6 +276,9 @@ struct kvm_arch { #ifdef CONFIG_KVM_XICS struct kvmppc_xics *xics; #endif +#ifdef CONFIG_PPC_BOOK3S_64 + struct kvmppc_ops *kvm_ops; +#endif }; /* diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 592501b..a4a5893 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -134,9 +134,11 @@ extern struct page *kvm_alloc_hpt(unsigned long nr_pages); extern void kvm_release_hpt(struct page *page, unsigned long nr_pages); extern int kvmppc_core_init_vm(struct kvm *kvm); extern void kvmppc_core_destroy_vm(struct kvm *kvm); -extern void kvmppc_core_free_memslot(struct kvm_memory_slot *free, +extern void kvmppc_core_free_memslot(struct kvm *kvm, +struct kvm_memory_slot *free, struct kvm_memory_slot *dont); -extern int kvmppc_core_create_memslot(struct kvm_memory_slot *slot, +extern int kvmppc_core_create_memslot(struct kvm *kvm, + struct kvm_memory_slot *slot, unsigned long npages); extern int kvmppc_core_prepare_memory_region(struct kvm *kvm, struct kvm_memory_slot *memslot, @@ -216,7 +218,8 @@ struct kvmppc_ops { }; -extern struct kvmppc_ops *kvmppc_ops; +extern struct kvmppc_ops *kvmppc_hv_ops; +extern struct kvmppc_ops *kvmppc_pr_ops; /* * Cuts out inst bits with ordering according to spec. @@ -324,7 +327,7 @@ static inline void kvmppc_set_host_ipi(int cpu, u8 host_ipi) static inline void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu) { - kvmppc_ops-fast_vcpu_kick(vcpu); + vcpu-kvm-arch.kvm_ops-fast_vcpu_kick(vcpu); } #else diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 485a6ff..34e189c 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -71,7 +71,7 @@ void kvmppc_core_load_guest_debugstate(struct kvm_vcpu *vcpu) static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) { - if (!kvmppc_ops-is_hv_enabled) + if (!vcpu-kvm-arch.kvm_ops-is_hv_enabled) return to_book3s(vcpu)-hior; return 0; } @@ -79,7 +79,7 @@ static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, unsigned long pending_now, unsigned long old_pending) { - if (kvmppc_ops-is_hv_enabled) + if (vcpu-kvm-arch.kvm_ops-is_hv_enabled) return; if (pending_now) vcpu-arch.shared-int_pending = 1; @@ -93,7 +93,7 @@ static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) ulong crit_r1; bool crit; - if (kvmppc_ops-is_hv_enabled) + if (vcpu-kvm-arch.kvm_ops-is_hv_enabled) return false; crit_raw = vcpu-arch.shared-critical; @@ -470,13 +470,13 @@ void kvmppc_subarch_vcpu_uninit(struct kvm_vcpu *vcpu) int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { - return kvmppc_ops-get_sregs(vcpu, sregs); + return vcpu-kvm-arch.kvm_ops-get_sregs(vcpu, sregs); } int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { - return kvmppc_ops-set_sregs(vcpu, sregs); + return vcpu-kvm-arch.kvm_ops-set_sregs(vcpu, sregs); } int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) @@ -555,7 +555,7 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) if (size sizeof(val)) return -EINVAL; - r = kvmppc_ops-get_one_reg(vcpu, reg-id, val); + r = vcpu-kvm-arch.kvm_ops-get_one_reg(vcpu, reg-id, val); if (r == -EINVAL) { r = 0;
[RFC PATCH 02/11] kvm: powerpc: book3s: remove kvmppc_handler_highmem label
From: Paul Mackerras pau...@samba.org This label is not used now. Signed-off-by: Paul Mackerras pau...@samba.org Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/kvm/book3s_hv_interrupts.S | 3 --- arch/powerpc/kvm/book3s_interrupts.S| 3 --- 2 files changed, 6 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S index 37f1cc4..928142c 100644 --- a/arch/powerpc/kvm/book3s_hv_interrupts.S +++ b/arch/powerpc/kvm/book3s_hv_interrupts.S @@ -158,9 +158,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) * Interrupts are enabled again at this point. */ -.global kvmppc_handler_highmem -kvmppc_handler_highmem: - /* * Register usage at this point: * diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S index bf8f1ab..279ee3f 100644 --- a/arch/powerpc/kvm/book3s_interrupts.S +++ b/arch/powerpc/kvm/book3s_interrupts.S @@ -121,9 +121,6 @@ kvm_start_lightweight: * */ -.global kvmppc_handler_highmem -kvmppc_handler_highmem: - /* * Register usage at this point: * -- 1.8.1.2 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/11 Allow PR and HV KVM to coexist in one kernel
Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com writes: Hi All, This patch series support enabling HV and PR KVM together in the same kernel. We extend machine property with new property kvm_type. A value of 1 will force HV KVM and 2 PR KVM. The default value is 0 which will select the fastest KVM mode. ie, HV if that is supported otherwise PR. With Qemu command line having -machine pseries,accel=kvm,kvm_type=1 [root@llmp24l02 qemu]# bash ../qemu failed to initialize KVM: Invalid argument [root@llmp24l02 qemu]# modprobe kvm-pr [root@llmp24l02 qemu]# bash ../qemu failed to initialize KVM: Invalid argument [root@llmp24l02 qemu]# modprobe kvm-hv [root@llmp24l02 qemu]# bash ../qemu now with -machine pseries,accel=kvm,kvm_type=2 [root@llmp24l02 qemu]# rmmod kvm-pr [root@llmp24l02 qemu]# bash ../qemu failed to initialize KVM: Invalid argument [root@llmp24l02 qemu]# [root@llmp24l02 qemu]# modprobe kvm-pr [root@llmp24l02 qemu]# bash ../qemu if don't specify kvm_type machine property, it will take a default value 0, which means fastest supported. Related qemu patch commit 8d139053177d48a70cb710b211ea4c2843eccdfb Author: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Date: Mon Sep 23 12:28:37 2013 +0530 kvm: Add a new machine property kvm_type Targets like ppc64 support different type of KVM, one which use hypervisor mode and the other which doesn't. Add a new machine property kvm_type that helps in selecting the respective ones Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com diff --git a/kvm-all.c b/kvm-all.c index b87215c..a061eda 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1350,7 +1350,7 @@ int kvm_init(void) KVMState *s; const KVMCapabilityInfo *missing_cap; int ret; -int i; +int i, kvm_type; int max_vcpus; s = g_malloc0(sizeof(KVMState)); @@ -1407,7 +1407,8 @@ int kvm_init(void) goto err; } -s-vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0); +kvm_type = qemu_opt_get_number(qemu_get_machine_opts(), kvm_type, 0); +s-vmfd = kvm_ioctl(s, KVM_CREATE_VM, kvm_type); if (s-vmfd 0) { #ifdef TARGET_S390X fprintf(stderr, Please add the 'switch_amode' kernel parameter to diff --git a/vl.c b/vl.c index 4e709d5..4374b17 100644 --- a/vl.c +++ b/vl.c @@ -427,7 +427,12 @@ static QemuOptsList qemu_machine_opts = { .name = usb, .type = QEMU_OPT_BOOL, .help = Set on/off to enable/disable usb, +},{ +.name = kvm_type, +.type = QEMU_OPT_NUMBER, +.help = Set to kvm type to be used in create vm ioctl, }, + { /* End of list */ } }, }; -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 01/11] kvm: powerpc: book3s hv: Fix vcore leak
On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Paul Mackerras pau...@samba.org add kvmppc_free_vcores() to free the kvmppc_vcore structures that we allocate for a guest, which are currently being leaked. Signed-off-by: Paul Mackerras pau...@samba.org Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This one doesn't look like an RFC to me. Applied to kvm-ppc-queue :). Alex --- arch/powerpc/kvm/book3s_hv.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 62a2b5a..edc7f9f 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1931,10 +1931,20 @@ int kvmppc_core_init_vm(struct kvm *kvm) return 0; } +static void kvmppc_free_vcores(struct kvm *kvm) +{ + long int i; + + for (i = 0; i KVM_MAX_VCORES; ++i) + kfree(kvm-arch.vcores[i]); + kvm-arch.online_vcores = 0; +} + void kvmppc_core_destroy_vm(struct kvm *kvm) { uninhibit_secondary_onlining(); + kvmppc_free_vcores(kvm); if (kvm-arch.rma) { kvm_release_rma(kvm-arch.rma); kvm-arch.rma = NULL; -- 1.8.1.2 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 04/11] kvm: powerpc: book3s: Add a new config variable CONFIG_KVM_BOOK3S_HV
On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This help ups to select the relevant code in the kernel code when we later move HV and PR bits as seperate modules. I don't think I grasp what semantically the difference between CONFIG_KVM_BOOK3S_HV and CONFIG_KVM_BOOK3S_64_HV is :). Alex -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 05/11] kvm: powerpc: book3s: Add kvmppc_ops callback for HV and PR specific operations
On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This moves HV and PR specific functions to kvmppc_ops callback. This is needed so that we can enable HV and PR together in the same kernel. Actual changes to enable both come in the later patch.This also renames almost all of the symbols that exist in both PR and HV KVM for clarity. Symbols in the PR KVM implementation get _pr appended, and those in the HV KVM implementation get _hv. Then, in book3s.c, we add a function with the name without the suffix and arrange for it to call the appropriate kvmppc_ops callback depending on which kvm type we selected during VM creation. NOTE: we still don't enable selecting both the HV and PR together in this commit that will be done by a later commit. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_book3s.h | 5 +- arch/powerpc/include/asm/kvm_ppc.h| 63 -- arch/powerpc/kvm/Kconfig | 15 ++- arch/powerpc/kvm/Makefile | 9 +- arch/powerpc/kvm/book3s.c | 145 +- arch/powerpc/kvm/book3s_32_mmu_host.c | 2 +- arch/powerpc/kvm/book3s_64_mmu_host.c | 2 +- arch/powerpc/kvm/book3s_64_mmu_hv.c | 17 ++- arch/powerpc/kvm/book3s_emulate.c | 8 +- arch/powerpc/kvm/book3s_hv.c | 226 +- arch/powerpc/kvm/book3s_interrupts.S | 2 +- arch/powerpc/kvm/book3s_pr.c | 196 ++--- arch/powerpc/kvm/emulate.c| 6 +- arch/powerpc/kvm/powerpc.c| 58 +++-- 14 files changed, 539 insertions(+), 215 deletions(-) [...] @@ -888,14 +890,8 @@ int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *val) return r; } -int kvmppc_core_check_processor_compat(void) -{ - if (cpu_has_feature(CPU_FTR_HVMODE)) - return 0; - return -EIO; -} - -struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id) +static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm, +unsigned int id) { struct kvm_vcpu *vcpu; int err = -EINVAL; @@ -920,7 +916,6 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id) vcpu-arch.ctrl = CTRL_RUNLATCH; /* default to host PVR, since we can't spoof it */ vcpu-arch.pvr = mfspr(SPRN_PVR); - kvmppc_set_pvr(vcpu, vcpu-arch.pvr); Where is this one going? spin_lock_init(vcpu-arch.vpa_update_lock); spin_lock_init(vcpu-arch.tbacct_lock); vcpu-arch.busy_preempt = TB_NIL; @@ -972,7 +967,7 @@ static void unpin_vpa(struct kvm *kvm, struct kvmppc_vpa *vpa) vpa-dirty); } -void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) +static void kvmppc_core_vcpu_free_hv(struct kvm_vcpu *vcpu) { spin_lock(vcpu-arch.vpa_update_lock); unpin_vpa(vcpu-kvm, vcpu-arch.dtl); @@ -983,6 +978,12 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) kmem_cache_free(kvm_vcpu_cache, vcpu); } +static int kvmppc_core_check_requests_hv(struct kvm_vcpu *vcpu) +{ + /* Indicate we want to get back into the guest */ + return 1; +} + [...] + case KVM_PPC_GET_HTAB_FD: { + struct kvm_get_htab_fd ghf; + + r = -EFAULT; + if (copy_from_user(ghf, argp, sizeof(ghf))) + break; + r = kvm_vm_ioctl_get_htab_fd(kvm, ghf); + break; + } + + default: + r = -ENOTTY; + } + + return r; } -static int kvmppc_book3s_hv_init(void) +/* FIXME!! move to header */ Hrm :) +extern void kvmppc_core_flush_memslot_hv(struct kvm *kvm, + struct kvm_memory_slot *memslot); +extern int kvm_unmap_hva_hv(struct kvm *kvm, unsigned long hva); +extern int kvm_unmap_hva_range_hv(struct kvm *kvm, unsigned long start, + unsigned long end); +extern int kvm_age_hva_hv(struct kvm *kvm, unsigned long hva); +extern int kvm_test_age_hva_hv(struct kvm *kvm, unsigned long hva); +extern void kvm_set_spte_hva_hv(struct kvm *kvm, unsigned long hva, pte_t pte); + +static struct kvmppc_ops kvmppc_hv_ops = { + .get_sregs = kvm_arch_vcpu_ioctl_get_sregs_hv, + .set_sregs = kvm_arch_vcpu_ioctl_set_sregs_hv, + .get_one_reg = kvmppc_get_one_reg_hv, + .set_one_reg = kvmppc_set_one_reg_hv, + .vcpu_load = kvmppc_core_vcpu_load_hv, + .vcpu_put= kvmppc_core_vcpu_put_hv, + .set_msr = kvmppc_set_msr_hv, + .vcpu_run= kvmppc_vcpu_run_hv, + .vcpu_create = kvmppc_core_vcpu_create_hv, + .vcpu_free = kvmppc_core_vcpu_free_hv, + .check_requests = kvmppc_core_check_requests_hv, + .get_dirty_log = kvm_vm_ioctl_get_dirty_log_hv, + .flush_memslot
Re: [RFC PATCH 06/11] kvm: powerpc: book3s: Add is_hv_enabled to kvmppc_ops
On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This help us to identify whether we are running with hypervisor mode KVM enabled. The change is needed so that we can have both HV and PR kvm enabled in the same kernel. If both HV and PR KVM are included, interrupts come in to the HV version of the kvmppc_interrupt code, which then jumps to the PR handler, renamed to kvmppc_interrupt_pr, if the guest is a PR guest. Allowing both PR and HV in the same kernel required some changes to kvm_dev_ioctl_check_extension(), since the values returned now can't be selected with #ifdefs as much as previously. We look at is_hv_enabled to return the right value when checking for capabilities.For capabilities that are only provided by HV KVM, we return the HV value only if is_hv_enabled is true. For capabilities provided by PR KVM but not HV, we return the PR value only if is_hv_enabled is false. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_book3s.h | 53 arch/powerpc/include/asm/kvm_ppc.h | 5 +-- arch/powerpc/kvm/Makefile | 2 +- arch/powerpc/kvm/book3s.c | 44 +++ arch/powerpc/kvm/book3s_hv.c| 1 + arch/powerpc/kvm/book3s_hv_rmhandlers.S | 4 +++ arch/powerpc/kvm/book3s_pr.c| 1 + arch/powerpc/kvm/book3s_segment.S | 7 - arch/powerpc/kvm/book3s_xics.c | 2 +- arch/powerpc/kvm/powerpc.c | 54 ++--- 10 files changed, 90 insertions(+), 83 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 3efba3c..ba33c49 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h @@ -297,59 +297,6 @@ static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) return vcpu-arch.fault_dar; } -#ifdef CONFIG_KVM_BOOK3S_PR - -static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) -{ - return to_book3s(vcpu)-hior; -} - -static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, - unsigned long pending_now, unsigned long old_pending) -{ - if (pending_now) - vcpu-arch.shared-int_pending = 1; - else if (old_pending) - vcpu-arch.shared-int_pending = 0; -} - -static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) -{ - ulong crit_raw = vcpu-arch.shared-critical; - ulong crit_r1 = kvmppc_get_gpr(vcpu, 1); - bool crit; - - /* Truncate crit indicators in 32 bit mode */ - if (!(vcpu-arch.shared-msr MSR_SF)) { - crit_raw = 0x; - crit_r1 = 0x; - } - - /* Critical section when crit == r1 */ - crit = (crit_raw == crit_r1); - /* ... and we're in supervisor mode */ - crit = crit !(vcpu-arch.shared-msr MSR_PR); - - return crit; -} -#else /* CONFIG_KVM_BOOK3S_PR */ - -static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) -{ - return 0; -} - -static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, - unsigned long pending_now, unsigned long old_pending) -{ -} - -static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) -{ - return false; -} -#endif - /* Magic register values loaded into r3 and r4 before the 'sc' assembly * instruction for the OSI hypercalls */ #define OSI_SC_MAGIC_R3 0x113724FA diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 4d9641c..58e732f 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -169,6 +169,7 @@ extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq); extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq); struct kvmppc_ops { + bool is_hv_enabled; This doesn't really belong into an ops struct. Either you compare if (kvmppc_ops == kvmppc_ops_pr) against a global known good ops struct or you put the hint somewhere into the kvm struct. int (*get_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int (*set_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int (*get_one_reg)(struct kvm_vcpu *vcpu, u64 id, @@ -309,10 +310,10 @@ static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) static inline u32 kvmppc_get_xics_latch(void) { - u32 xirr = get_paca()-kvm_hstate.saved_xirr; + u32 xirr; + xirr = get_paca()-kvm_hstate.saved_xirr; get_paca()-kvm_hstate.saved_xirr = 0; - I don't see any functionality change here? return xirr; } diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile index c343793..a514ecd 100644 --- a/arch/powerpc/kvm/Makefile +++ b/arch/powerpc/kvm/Makefile @@
Re: [RFC PATCH 07/11] kvm: powerpc: book3s: pr: move PR related tracepoints to a separate header
On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This patch moves PR related tracepoints to a separate header. This enables in converting PR to a kernel module which will be done in later patches Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/kvm/book3s_64_mmu_host.c | 2 +- arch/powerpc/kvm/book3s_mmu_hpte.c| 2 +- arch/powerpc/kvm/book3s_pr.c | 3 +- arch/powerpc/kvm/trace.h | 234 +-- arch/powerpc/kvm/trace_pr.h | 297 ++ 5 files changed, 308 insertions(+), 230 deletions(-) create mode 100644 arch/powerpc/kvm/trace_pr.h diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c index 329a978..fd5b393 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_host.c +++ b/arch/powerpc/kvm/book3s_64_mmu_host.c @@ -27,7 +27,7 @@ #include asm/machdep.h #include asm/mmu_context.h #include asm/hw_irq.h -#include trace.h +#include trace_pr.h #define PTE_SIZE 12 diff --git a/arch/powerpc/kvm/book3s_mmu_hpte.c b/arch/powerpc/kvm/book3s_mmu_hpte.c index d2d280b..4556168 100644 --- a/arch/powerpc/kvm/book3s_mmu_hpte.c +++ b/arch/powerpc/kvm/book3s_mmu_hpte.c @@ -28,7 +28,7 @@ #include asm/mmu_context.h #include asm/hw_irq.h -#include trace.h +#include trace_pr.h #define PTE_SIZE 12 diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 2a97279..99d0839 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -41,7 +41,8 @@ #include linux/vmalloc.h #include linux/highmem.h -#include trace.h +#define CREATE_TRACE_POINTS +#include trace_pr.h /* #define EXIT_DEBUG */ /* #define DEBUG_EXT */ diff --git a/arch/powerpc/kvm/trace.h b/arch/powerpc/kvm/trace.h index a088e9a..7d5a136 100644 --- a/arch/powerpc/kvm/trace.h +++ b/arch/powerpc/kvm/trace.h @@ -85,6 +85,12 @@ TRACE_EVENT(kvm_ppc_instr, {41, HV_PRIV} #endif +#ifndef CONFIG_KVM_BOOK3S_PR +/* + * For pr we define this in trace_pr.h since it pr can be built as + * a module Not sure I understand the need. If the config option is available, so should the struct field. Worst case that happens with HV is that we get empty shadow_srr1 values in our trace, no? If your goal is to make it more obvious whether we are tracing in PR or HV land (which is a reasonable goal), then you should also split off all non-common trace points into a special hv trace header so that it's obvious whether we are looking at HV or PR. Alex -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 08/11] kvm: powerpc: book3s: Support building HV and PR KVM as module
On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/kvm/Kconfig | 6 +++--- arch/powerpc/kvm/Makefile | 12 arch/powerpc/kvm/book3s.c | 19 ++- arch/powerpc/kvm/book3s_64_mmu_host.c | 1 + arch/powerpc/kvm/book3s_emulate.c | 2 +- arch/powerpc/kvm/book3s_hv.c | 4 arch/powerpc/kvm/book3s_pr.c | 5 - arch/powerpc/kvm/book3s_rtas.c| 1 + arch/powerpc/kvm/emulate.c| 1 + arch/powerpc/kvm/powerpc.c| 6 ++ virt/kvm/kvm_main.c | 3 +++ 11 files changed, 50 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig index 5c62459..f63fd8f 100644 --- a/arch/powerpc/kvm/Kconfig +++ b/arch/powerpc/kvm/Kconfig @@ -73,7 +73,7 @@ config KVM_BOOK3S_64 If unsure, say N. config KVM_BOOK3S_64_HV - bool KVM support for POWER7 and PPC970 using hypervisor mode in host + tristate KVM support for POWER7 and PPC970 using hypervisor mode in host depends on KVM_BOOK3S_64 select KVM_BOOK3S_HV select MMU_NOTIFIER @@ -94,8 +94,8 @@ config KVM_BOOK3S_64_HV If unsure, say N. config KVM_BOOK3S_64_PR - bool KVM support without using hypervisor mode in host - depends on KVM_BOOK3S_64 !KVM_BOOK3S_64_HV + tristate KVM support without using hypervisor mode in host + depends on KVM_BOOK3S_64 select KVM_BOOK3S_PR ---help--- Support running guest kernels in virtual machines on processors diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile index a514ecd..861b8da 100644 --- a/arch/powerpc/kvm/Makefile +++ b/arch/powerpc/kvm/Makefile @@ -56,8 +56,7 @@ kvm-objs-$(CONFIG_KVM_E500MC) := $(kvm-e500mc-objs) kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) := \ book3s_64_vio_hv.o -kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_PR) := \ - $(KVM)/coalesced_mmio.o \ +kvm-pr-y := \ fpu.o \ book3s_paired_singles.o \ book3s_pr.o \ @@ -77,7 +76,7 @@ kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \ book3s_rmhandlers.o endif -kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \ +kvm-hv-y += \ book3s_hv.o \ book3s_hv_interrupts.o \ book3s_64_mmu_hv.o @@ -85,13 +84,15 @@ kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \ kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \ book3s_hv_rm_xics.o -kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HV) += \ +ifdef CONFIG_KVM_BOOK3S_HV +kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \ book3s_hv_rmhandlers.o \ book3s_hv_rm_mmu.o \ book3s_hv_ras.o \ book3s_hv_builtin.o \ book3s_hv_cma.o \ $(kvm-book3s_64-builtin-xics-objs-y) +endif kvm-book3s_64-objs-$(CONFIG_KVM_XICS) += \ book3s_xics.o @@ -132,4 +133,7 @@ obj-$(CONFIG_KVM_E500MC) += kvm.o obj-$(CONFIG_KVM_BOOK3S_64) += kvm.o obj-$(CONFIG_KVM_BOOK3S_32) += kvm.o +obj-$(CONFIG_KVM_BOOK3S_64_PR) += kvm-pr.o +obj-$(CONFIG_KVM_BOOK3S_64_HV) += kvm-hv.o + obj-y += $(kvm-book3s_64-builtin-objs-y) diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 12f94bf..ca617e1 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -170,13 +170,14 @@ void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec) printk(KERN_INFO Queueing interrupt %x\n, vec); #endif } - +EXPORT_SYMBOL_GPL(kvmppc_book3s_queue_irqprio); void kvmppc_core_queue_program(struct kvm_vcpu *vcpu, ulong flags) { /* might as well deliver this straight away */ kvmppc_inject_interrupt(vcpu, BOOK3S_INTERRUPT_PROGRAM, flags); } +EXPORT_SYMBOL_GPL(kvmppc_core_queue_program); void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu) { @@ -351,6 +352,7 @@ pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn) return gfn_to_pfn(vcpu-kvm, gfn); } +EXPORT_SYMBOL_GPL(kvmppc_gfn_to_pfn); static int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr, bool data, struct kvmppc_pte *pte) @@ -418,6 +420,7 @@ int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, return EMULATE_DONE; } +EXPORT_SYMBOL_GPL(kvmppc_st); int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data) @@ -448,6 +451,7 @@ nopte: mmio: return EMULATE_DO_MMIO; } +EXPORT_SYMBOL_GPL(kvmppc_ld); int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) { @@ -693,6 +697,7 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 msr) { kvmppc_ops-set_msr(vcpu, msr); } +EXPORT_SYMBOL_GPL(kvmppc_set_msr); int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) { @@ -774,6 +779,7 @@ int kvm_unmap_hva(struct
Re: [RFC PATCH 09/11] kvm: simplify processor compat check
On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Missing patch description. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com I fail to see how this really simplifies things, but at the end of the day it's Gleb's and Paolo's call. Which brings me to the next issue: You forgot to CC kvm@vger on your patch set. Gleb and Paolo don't read kvm-ppc@vger. And they shouldn't have to. Every kvm patch that you want review on or that should get applied needs to be sent to kvm@vger. If you want to tag it as PPC specific patch, do so by CC'ing kvm-ppc@vger. Alex --- arch/arm/kvm/arm.c | 4 ++-- arch/ia64/kvm/kvm-ia64.c | 4 ++-- arch/mips/kvm/kvm_mips.c | 6 ++ arch/powerpc/include/asm/kvm_ppc.h | 2 +- arch/powerpc/kvm/44x.c | 2 +- arch/powerpc/kvm/book3s.c | 15 --- arch/powerpc/kvm/book3s_hv.c | 9 ++--- arch/powerpc/kvm/book3s_pr.c | 5 +++-- arch/powerpc/kvm/e500.c| 2 +- arch/powerpc/kvm/e500mc.c | 2 +- arch/powerpc/kvm/powerpc.c | 5 - arch/s390/kvm/kvm-s390.c | 3 ++- arch/x86/kvm/x86.c | 13 +++-- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c| 14 +- 15 files changed, 50 insertions(+), 38 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 9c697db..cccb121 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -109,9 +109,9 @@ void kvm_arch_hardware_unsetup(void) { } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - *(int *)rtn = 0; + return 0; } void kvm_arch_sync_events(struct kvm *kvm) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index bdfd878..065942c 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -185,9 +185,9 @@ void kvm_arch_hardware_disable(void *garbage) ia64_ptr_entry(0x3, slot); } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - *(int *)rtn = 0; + return 0; } int kvm_dev_ioctl_check_extension(long ext) diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c index a7b0445..4512739 100644 --- a/arch/mips/kvm/kvm_mips.c +++ b/arch/mips/kvm/kvm_mips.c @@ -97,11 +97,9 @@ void kvm_arch_hardware_unsetup(void) { } -void kvm_arch_check_processor_compat(void *rtn) +int kvm_arch_check_processor_compat(void *opaque) { - int *r = (int *)rtn; - *r = 0; - return; + return 0; } static void kvm_mips_init_tlbs(struct kvm *kvm) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 58e732f..592501b 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -204,7 +204,7 @@ struct kvmppc_ops { unsigned long npages); int (*init_vm)(struct kvm *kvm); void (*destroy_vm)(struct kvm *kvm); - int (*check_processor_compat)(void); + void (*check_processor_compat)(void *r); int (*get_smmu_info)(struct kvm *kvm, struct kvm_ppc_smmu_info *info); int (*emulate_op)(struct kvm_run *run, struct kvm_vcpu *vcpu, unsigned int inst, int *advance); diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c index 2f5c6b6..a1f4e60 100644 --- a/arch/powerpc/kvm/44x.c +++ b/arch/powerpc/kvm/44x.c @@ -43,7 +43,7 @@ void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu) kvmppc_booke_vcpu_put(vcpu); } -int kvmppc_core_check_processor_compat(void) +int kvm_arch_check_processor_compat(void *opaque) { int r; diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index ca617e1..485a6ff 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -827,9 +827,18 @@ void kvmppc_core_destroy_vm(struct kvm *kvm) #endif } -int kvmppc_core_check_processor_compat(void) -{ - return kvmppc_ops-check_processor_compat(); +int kvm_arch_check_processor_compat(void *opaque) +{ + int r,cpu; + struct kvmppc_ops *kvm_ops = (struct kvmppc_ops *)opaque; + for_each_online_cpu(cpu) { + smp_call_function_single(cpu, + kvm_ops-check_processor_compat, + r, 1); + if (r 0) + break; + } + return r; } EXPORT_SYMBOL_GPL(kvm_get_dirty_log); diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index ff57be8..4322db4 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1980,11 +1980,14 @@ static int kvmppc_core_emulate_mfspr_hv(struct kvm_vcpu *vcpu, int sprn, return EMULATE_FAIL; } -static int kvmppc_core_check_processor_compat_hv(void) + +static void
Re: [RFC PATCH 05/11] kvm: powerpc: book3s: Add kvmppc_ops callback for HV and PR specific operations
Alexander Graf ag...@suse.de writes: On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This moves HV and PR specific functions to kvmppc_ops callback. This is needed so that we can enable HV and PR together in the same kernel. Actual changes to enable both come in the later patch.This also renames almost all of the symbols that exist in both PR and HV KVM for clarity. Symbols in the PR KVM implementation get _pr appended, and those in the HV KVM implementation get _hv. Then, in book3s.c, we add a function with the name without the suffix and arrange for it to call the appropriate kvmppc_ops callback depending on which kvm type we selected during VM creation. NOTE: we still don't enable selecting both the HV and PR together in this commit that will be done by a later commit. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_book3s.h | 5 +- arch/powerpc/include/asm/kvm_ppc.h| 63 -- arch/powerpc/kvm/Kconfig | 15 ++- arch/powerpc/kvm/Makefile | 9 +- arch/powerpc/kvm/book3s.c | 145 +- arch/powerpc/kvm/book3s_32_mmu_host.c | 2 +- arch/powerpc/kvm/book3s_64_mmu_host.c | 2 +- arch/powerpc/kvm/book3s_64_mmu_hv.c | 17 ++- arch/powerpc/kvm/book3s_emulate.c | 8 +- arch/powerpc/kvm/book3s_hv.c | 226 +- arch/powerpc/kvm/book3s_interrupts.S | 2 +- arch/powerpc/kvm/book3s_pr.c | 196 ++--- arch/powerpc/kvm/emulate.c| 6 +- arch/powerpc/kvm/powerpc.c| 58 +++-- 14 files changed, 539 insertions(+), 215 deletions(-) [...] @@ -888,14 +890,8 @@ int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *val) return r; } -int kvmppc_core_check_processor_compat(void) -{ -if (cpu_has_feature(CPU_FTR_HVMODE)) -return 0; -return -EIO; -} - -struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id) +static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm, + unsigned int id) { struct kvm_vcpu *vcpu; int err = -EINVAL; @@ -920,7 +916,6 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id) vcpu-arch.ctrl = CTRL_RUNLATCH; /* default to host PVR, since we can't spoof it */ vcpu-arch.pvr = mfspr(SPRN_PVR); -kvmppc_set_pvr(vcpu, vcpu-arch.pvr); Where is this one going? That is same as the line above. void kvmppc_set_pvr_hv(struct kvm_vcpu *vcpu, u32 pvr) { vcpu-arch.pvr = pvr; } spin_lock_init(vcpu-arch.vpa_update_lock); spin_lock_init(vcpu-arch.tbacct_lock); vcpu-arch.busy_preempt = TB_NIL; @@ -972,7 +967,7 @@ static void unpin_vpa(struct kvm *kvm, struct kvmppc_vpa *vpa) vpa-dirty); } -void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) +static void kvmppc_core_vcpu_free_hv(struct kvm_vcpu *vcpu) { spin_lock(vcpu-arch.vpa_update_lock); unpin_vpa(vcpu-kvm, vcpu-arch.dtl); @@ -983,6 +978,12 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) kmem_cache_free(kvm_vcpu_cache, vcpu); } +static int kvmppc_core_check_requests_hv(struct kvm_vcpu *vcpu) +{ +/* Indicate we want to get back into the guest */ +return 1; +} + [...] +case KVM_PPC_GET_HTAB_FD: { +struct kvm_get_htab_fd ghf; + +r = -EFAULT; +if (copy_from_user(ghf, argp, sizeof(ghf))) +break; +r = kvm_vm_ioctl_get_htab_fd(kvm, ghf); +break; +} + +default: +r = -ENOTTY; +} + +return r; } -static int kvmppc_book3s_hv_init(void) +/* FIXME!! move to header */ Hrm :) yes, want to get something out for review. Will fix if we agree on the approach. +extern void kvmppc_core_flush_memslot_hv(struct kvm *kvm, + struct kvm_memory_slot *memslot); +extern int kvm_unmap_hva_hv(struct kvm *kvm, unsigned long hva); +extern int kvm_unmap_hva_range_hv(struct kvm *kvm, unsigned long start, + unsigned long end); +extern int kvm_age_hva_hv(struct kvm *kvm, unsigned long hva); +extern int kvm_test_age_hva_hv(struct kvm *kvm, unsigned long hva); +extern void kvm_set_spte_hva_hv(struct kvm *kvm, unsigned long hva, pte_t pte); + +static struct kvmppc_ops kvmppc_hv_ops = { +.get_sregs = kvm_arch_vcpu_ioctl_get_sregs_hv, +.set_sregs = kvm_arch_vcpu_ioctl_set_sregs_hv, +.get_one_reg = kvmppc_get_one_reg_hv, +.set_one_reg = kvmppc_set_one_reg_hv, +.vcpu_load = kvmppc_core_vcpu_load_hv, +.vcpu_put= kvmppc_core_vcpu_put_hv, +.set_msr = kvmppc_set_msr_hv, +.vcpu_run= kvmppc_vcpu_run_hv, +.vcpu_create =
Re: [RFC PATCH 06/11] kvm: powerpc: book3s: Add is_hv_enabled to kvmppc_ops
Alexander Graf ag...@suse.de writes: On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com This help us to identify whether we are running with hypervisor mode KVM enabled. The change is needed so that we can have both HV and PR kvm enabled in the same kernel. If both HV and PR KVM are included, interrupts come in to the HV version of the kvmppc_interrupt code, which then jumps to the PR handler, renamed to kvmppc_interrupt_pr, if the guest is a PR guest. Allowing both PR and HV in the same kernel required some changes to kvm_dev_ioctl_check_extension(), since the values returned now can't be selected with #ifdefs as much as previously. We look at is_hv_enabled to return the right value when checking for capabilities.For capabilities that are only provided by HV KVM, we return the HV value only if is_hv_enabled is true. For capabilities provided by PR KVM but not HV, we return the PR value only if is_hv_enabled is false. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com --- arch/powerpc/include/asm/kvm_book3s.h | 53 arch/powerpc/include/asm/kvm_ppc.h | 5 +-- arch/powerpc/kvm/Makefile | 2 +- arch/powerpc/kvm/book3s.c | 44 +++ arch/powerpc/kvm/book3s_hv.c| 1 + arch/powerpc/kvm/book3s_hv_rmhandlers.S | 4 +++ arch/powerpc/kvm/book3s_pr.c| 1 + arch/powerpc/kvm/book3s_segment.S | 7 - arch/powerpc/kvm/book3s_xics.c | 2 +- arch/powerpc/kvm/powerpc.c | 54 ++--- 10 files changed, 90 insertions(+), 83 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 3efba3c..ba33c49 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h @@ -297,59 +297,6 @@ static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) return vcpu-arch.fault_dar; } -#ifdef CONFIG_KVM_BOOK3S_PR - -static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) -{ -return to_book3s(vcpu)-hior; -} - -static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, -unsigned long pending_now, unsigned long old_pending) -{ -if (pending_now) -vcpu-arch.shared-int_pending = 1; -else if (old_pending) -vcpu-arch.shared-int_pending = 0; -} - -static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) -{ -ulong crit_raw = vcpu-arch.shared-critical; -ulong crit_r1 = kvmppc_get_gpr(vcpu, 1); -bool crit; - -/* Truncate crit indicators in 32 bit mode */ -if (!(vcpu-arch.shared-msr MSR_SF)) { -crit_raw = 0x; -crit_r1 = 0x; -} - -/* Critical section when crit == r1 */ -crit = (crit_raw == crit_r1); -/* ... and we're in supervisor mode */ -crit = crit !(vcpu-arch.shared-msr MSR_PR); - -return crit; -} -#else /* CONFIG_KVM_BOOK3S_PR */ - -static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) -{ -return 0; -} - -static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, -unsigned long pending_now, unsigned long old_pending) -{ -} - -static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) -{ -return false; -} -#endif - /* Magic register values loaded into r3 and r4 before the 'sc' assembly * instruction for the OSI hypercalls */ #define OSI_SC_MAGIC_R3 0x113724FA diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 4d9641c..58e732f 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -169,6 +169,7 @@ extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq); extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq); struct kvmppc_ops { +bool is_hv_enabled; This doesn't really belong into an ops struct. Either you compare if (kvmppc_ops == kvmppc_ops_pr) will do that in the next update. against a global known good ops struct or you put the hint somewhere into the kvm struct. int (*get_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int (*set_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int (*get_one_reg)(struct kvm_vcpu *vcpu, u64 id, @@ -309,10 +310,10 @@ static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) static inline u32 kvmppc_get_xics_latch(void) { -u32 xirr = get_paca()-kvm_hstate.saved_xirr; +u32 xirr; +xirr = get_paca()-kvm_hstate.saved_xirr; get_paca()-kvm_hstate.saved_xirr = 0; - I don't see any functionality change here? return xirr; Mistake on my side, I had a if condition in there before, which i later removed. But forgot to move the assignment back. Will
Re: [RFC PATCH 08/11] kvm: powerpc: book3s: Support building HV and PR KVM as module
Alexander Graf ag...@suse.de writes: On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c index fd5b393..775d368 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_host.c +++ b/arch/powerpc/kvm/book3s_64_mmu_host.c @@ -27,6 +27,7 @@ #include asm/machdep.h #include asm/mmu_context.h #include asm/hw_irq.h + Stray whitespace change will fix #include trace_pr.h #define PTE_SIZE 12 diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index b9841ad..20d03c2 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c @@ -172,7 +172,7 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu, vcpu-arch.mmu.tlbie(vcpu, addr, large); break; } -#ifdef CONFIG_KVM_BOOK3S_64_PR +#ifdef CONFIG_KVM_BOOK3S_PR Why? If i have CONFIG_KVM_BOOK3S_64_PR=m #ifdef CONFIG_KVM_BOOK3S_64_PR will not work. There is a runtime check I can use IS_ENABLED(). But didn't want to do those. Hence moved to the symbol which will be set as CONFIG_KVM_BOOK3S_PR = y -aneesh -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 09/11] kvm: simplify processor compat check
Alexander Graf ag...@suse.de writes: On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Missing patch description. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com I fail to see how this really simplifies things, but at the end of the day it's Gleb's and Paolo's call. will do. It avoid calling for_each_online_cpu(cpu) { smp_call_function_single() on multiple architecture. We also want to make the smp call function a callback of opaque. Hence this should be made arch specific. int kvm_arch_check_processor_compat(void *opaque) { int r,cpu; struct kvmppc_ops *kvm_ops = (struct kvmppc_ops *)opaque; for_each_online_cpu(cpu) { smp_call_function_single(cpu, kvm_ops-check_processor_compat, r, 1); if (r 0) break; } return r; } against - for_each_online_cpu(cpu) { - smp_call_function_single(cpu, - kvm_arch_check_processor_compat, - r, 1); - if (r 0) - goto out_free_1; - } + + r = kvm_arch_check_processor_compat(opaque); + if (r 0) + goto out_free_1; Which brings me to the next issue: You forgot to CC kvm@vger on your patch set. Gleb and Paolo don't read kvm-ppc@vger. And they shouldn't have to. Every kvm patch that you want review on or that should get applied needs to be sent to kvm@vger. If you want to tag it as PPC specific patch, do so by CC'ing kvm-ppc@vger. Will do in the next update -aneesh -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] KVM: PPC: Book3S: Add support for hwrng found on some powernv systems
On 09/26/2013 12:01 PM, Michael Ellerman wrote: +int powernv_hwrng_present(void) +{ + return __raw_get_cpu_var(powernv_rng) != NULL; +} + static unsigned long rng_whiten(struct powernv_rng *rng, unsigned long val) { unsigned long parity; @@ -42,6 +48,17 @@ static unsigned long rng_whiten(struct powernv_rng *rng, unsigned long val) return val; } +int powernv_get_random_real_mode(unsigned long *v) +{ + struct powernv_rng *rng; + + rng = __raw_get_cpu_var(powernv_rng); + + *v = rng_whiten(rng, in_rm64(rng-regs_real)); + Will it be in_be64() instead of in_rm64() ? Its failing the build here. Except this all individual patches build correctly. Regards Anshuman -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 09/11] kvm: simplify processor compat check
Il 27/09/2013 15:13, Aneesh Kumar K.V ha scritto: Alexander Graf ag...@suse.de writes: On 27.09.2013, at 12:03, Aneesh Kumar K.V wrote: From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Missing patch description. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com I fail to see how this really simplifies things, but at the end of the day it's Gleb's and Paolo's call. will do. It avoid calling for_each_online_cpu(cpu) { smp_call_function_single() on multiple architecture. I agree with Alex. The current code is not specially awesome; having kvm_arch_check_processor_compat take an int* disguised as a void* is a bit ugly indeed. However, the API makes sense and tells you that it is being passed as a callback (to smp_call_function_single in this case). You are making the API more complicated to use on the arch layer (because arch maintainers now have to think do I need to check this on all online CPUs?) and making the leaf POWER code less legible because it still has the weird void()(void *) calling convention. If anything, you could change kvm_arch_check_processor_compat to return an int and accept no argument, and introduce a wrapper that kvm_init passes to smp_call_function_single. Paolo We also want to make the smp call function a callback of opaque. Hence this should be made arch specific. int kvm_arch_check_processor_compat(void *opaque) { int r,cpu; struct kvmppc_ops *kvm_ops = (struct kvmppc_ops *)opaque; for_each_online_cpu(cpu) { smp_call_function_single(cpu, kvm_ops-check_processor_compat, r, 1); if (r 0) break; } return r; } against - for_each_online_cpu(cpu) { - smp_call_function_single(cpu, - kvm_arch_check_processor_compat, - r, 1); - if (r 0) - goto out_free_1; - } + + r = kvm_arch_check_processor_compat(opaque); + if (r 0) + goto out_free_1; Which brings me to the next issue: You forgot to CC kvm@vger on your patch set. Gleb and Paolo don't read kvm-ppc@vger. And they shouldn't have to. Every kvm patch that you want review on or that should get applied needs to be sent to kvm@vger. If you want to tag it as PPC specific patch, do so by CC'ing kvm-ppc@vger. Will do in the next update -aneesh -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html