Re: [PATCH] KVM: nVMX: nested TPR shadow/threshold emulation

2014-08-01 Thread Paolo Bonzini
Il 01/08/2014 02:57, Zhang, Yang Z ha scritto: TPR_THRESHOLD will be likely written as zero, but the processor will never use it anyway. It's just a small optimization because nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW) will almost always be true. Theoretically, you are right. But we

RE: [PATCH] KVM: nVMX: nested TPR shadow/threshold emulation

2014-08-01 Thread Zhang, Yang Z
Paolo Bonzini wrote on 2014-08-01: Il 01/08/2014 02:57, Zhang, Yang Z ha scritto: TPR_THRESHOLD will be likely written as zero, but the processor will never use it anyway. It's just a small optimization because nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW) will almost always be true.

Re: Integrity in untrusted environments

2014-08-01 Thread Paolo Bonzini
Il 31/07/2014 23:25, Shiva V ha scritto: Hello, I am exploring ideas to implement a service inside a virtual machine on untrusted hypervisors under current cloud infrastructures. Particularly, I am interested how one can verify the integrity of the service in an environment where

[PATCH v2] KVM: nVMX: nested TPR shadow/threshold emulation

2014-08-01 Thread Wanpeng Li
This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=61411 TPR shadow/threshold feature is important to speed up the Windows guest. Besides, it is a must feature for certain VMM. We map virtual APIC page address and TPR threshold from L1 VMCS. If TPR_BELOW_THRESHOLD VM exit is

[PATCH 1/2] KVM: nVMX: Fix nested vmexit ack intr before load vmcs01

2014-08-01 Thread Wanpeng Li
External interrupt will cause L1 vmexit w/ reason external interrupt when L2 is running. Then L1 will pick up the interrupt through vmcs12 if L1 set the ack interrupt bit. Commit 77b0f5d (KVM: nVMX: Ack and write vector info to intr_info if L1 asks us to) get intr that belongs to L1 before load

[PATCH 2/2] KVM: nVMX: fix acknowledge interrupt on exit when APICv is in use

2014-08-01 Thread Wanpeng Li
After commit 77b0f5d (KVM: nVMX: Ack and write vector info to intr_info if L1 asks us to), Acknowledge interrupt on exit behavior can be emulated. To do so, KVM will ask the APIC for the interrupt vector if during a nested vmexit if VM_EXIT_ACK_INTR_ON_EXIT is set. With APICv,

[PATCH 2/2] KVM: nVMX: fix acknowledge interrupt on exit when APICv is in use

2014-08-01 Thread Wanpeng Li
After commit 77b0f5d (KVM: nVMX: Ack and write vector info to intr_info if L1 asks us to), Acknowledge interrupt on exit behavior can be emulated. To do so, KVM will ask the APIC for the interrupt vector if during a nested vmexit if VM_EXIT_ACK_INTR_ON_EXIT is set. With APICv,

Re: [PATCH 2/2] KVM: nVMX: fix acknowledge interrupt on exit when APICv is in use

2014-08-01 Thread Wanpeng Li
Please ignore this duplicate one. 于 14-8-1 下午4:13, Wanpeng Li 写道: After commit 77b0f5d (KVM: nVMX: Ack and write vector info to intr_info if L1 asks us to), Acknowledge interrupt on exit behavior can be emulated. To do so, KVM will ask the APIC for the interrupt vector if during a nested

Re: [PATCH 1/2] x86: AMD: mark TSC unstable on APU family 15h models 10h-1fh

2014-08-01 Thread Borislav Petkov
On Thu, Jul 31, 2014 at 09:47:12AM +, Igor Mammedov wrote: Due to erratum #778 from Revision Guide for AMD Family 15h Models 10h-1Fh Processors, Publication # 48931, Issue Date: May 2013, Revision: 3.10 TSC on affected processor, a core may drift under certain conditions, which makes

Re: [PATCH v2] KVM: nVMX: nested TPR shadow/threshold emulation

2014-08-01 Thread Paolo Bonzini
Il 01/08/2014 10:09, Wanpeng Li ha scritto: This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=61411 TPR shadow/threshold feature is important to speed up the Windows guest. Besides, it is a must feature for certain VMM. We map virtual APIC page address and TPR threshold from

Re: [PATCH] arm64: KVM: export current vcpu-pause state via pseudo regs

2014-08-01 Thread Alex Bennée
Christoffer Dall writes: On Thu, Jul 31, 2014 at 04:14:51PM +0100, Alex Bennée wrote: Christoffer Dall writes: On Wed, Jul 09, 2014 at 02:55:12PM +0100, Alex Bennée wrote: To cleanly restore an SMP VM we need to ensure that the current pause state of each vcpu is correctly recorded.

[PULL 19/63] KVM: PPC: Book3S HV: Access host lppaca and shadow slb in BE

2014-08-01 Thread Alexander Graf
Some data structures are always stored in big endian. Among those are the LPPACA fields as well as the shadow slb. These structures might be shared with a hypervisor. So whenever we access those fields, make sure we do so in big endian byte order. Signed-off-by: Alexander Graf ag...@suse.de ---

[PULL 29/63] kvm: ppc: bookehv: Added wrapper macros for shadow registers

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com There are shadow registers like, GSPRG[0-3], GSRR0, GSRR1 etc on BOOKE-HV and these shadow registers are guest accessible. So these shadow registers needs to be updated on BOOKE-HV. This patch adds new macro for get/set helper of shadow register .

[PULL 07/63] KVM: PPC: Book3S HV: Fix ABIv2 indirect branch issue

2014-08-01 Thread Alexander Graf
From: Anton Blanchard an...@samba.org To establish addressability quickly, ABIv2 requires the target address of the function being called to be in r12. Signed-off-by: Anton Blanchard an...@samba.org Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 4 ++--

[PULL 52/63] KVM: PPC: BOOK3S: HV: Update compute_tlbie_rb to handle 16MB base page

2014-08-01 Thread Alexander Graf
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com When calculating the lower bits of AVA field, use the shift count based on the base page size. Also add the missing segment size and remove stale comment. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Acked-by: Paul

[PULL 56/63] KVM: PPC: Use kvm_read_guest in kvmppc_ld

2014-08-01 Thread Alexander Graf
We have a nice and handy helper to read from guest physical address space, so we should make use of it in kvmppc_ld as we already do for its counterpart in kvmppc_st. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/powerpc.c | 27 ++- 1 file changed, 2

[PULL 12/63] KVM: PPC: Book3S: Controls for in-kernel sPAPR hypercall handling

2014-08-01 Thread Alexander Graf
From: Paul Mackerras pau...@samba.org This provides a way for userspace controls which sPAPR hcalls get handled in the kernel. Each hcall can be individually enabled or disabled for in-kernel handling, except for H_RTAS. The exception for H_RTAS is because userspace can already control whether

[PULL 24/63] KVM: PPC: Book3S: Move vcore definition to end of kvm_arch struct

2014-08-01 Thread Alexander Graf
When building KVM with a lot of vcores (NR_CPUS is big), we can potentially get out of the ld immediate range for dereferences inside that struct. Move the array to the end of our kvm_arch struct. This fixes compilation issues with NR_CPUS=2048 for me. Signed-off-by: Alexander Graf ag...@suse.de

[PULL 28/63] KVM: PPC: Book3S: Make magic page properly 4k mappable

2014-08-01 Thread Alexander Graf
The magic page is defined as a 4k page of per-vCPU data that is shared between the guest and the host to accelerate accesses to privileged registers. However, when the host is using 64k page size granularity we weren't quite as strict about that rule anymore. Instead, we partially treated all of

[PULL 53/63] KVM: PPC: Implement kvmppc_xlate for all targets

2014-08-01 Thread Alexander Graf
We have a nice API to find the translated GPAs of a GVA including protection flags. So far we only use it on Book3S, but there's no reason the same shouldn't be used on BookE as well. Implement a kvmppc_xlate() version for BookE and clean it up to make it more readable in general. Signed-off-by:

[PULL 03/63] KVM: PPC: BOOK3S: PR: Emulate instruction counter

2014-08-01 Thread Alexander Graf
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Writing to IC is not allowed in the privileged mode. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc/kvm/book3s.c

[PULL 04/63] KVM: PPC: Book3s PR: Disable AIL mode with OPAL

2014-08-01 Thread Alexander Graf
When we're using PR KVM we must not allow the CPU to take interrupts in virtual mode, as the SLB does not contain host kernel mappings when running inside the guest context. To make sure we get good performance for non-KVM tasks but still properly functioning PR KVM, let's just disable AIL

[PULL 55/63] KVM: PPC: Remove kvmppc_bad_hva()

2014-08-01 Thread Alexander Graf
We have a proper define for invalid HVA numbers. Use those instead of the ppc specific kvmppc_bad_hva(). Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/powerpc.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c

[PULL 45/63] KVM: PPC: Book3S PR: Take SRCU read lock around RTAS kvm_read_guest() call

2014-08-01 Thread Alexander Graf
From: Paul Mackerras pau...@samba.org This does for PR KVM what c9438092cae4 (KVM: PPC: Book3S HV: Take SRCU read lock around kvm_read_guest() call) did for HV KVM, that is, eliminate a suspicious rcu_dereference_check() usage! warning by taking the SRCU lock around the call to

[PULL 59/63] KVM: PPC: Expose helper functions for data/inst faults

2014-08-01 Thread Alexander Graf
We're going to implement guest code interpretation in KVM for some rare corner cases. This code needs to be able to inject data and instruction faults into the guest when it encounters them. Expose generic APIs to do this in a reasonably subarch agnostic fashion. Signed-off-by: Alexander Graf

[PULL 60/63] KVM: PPC: Remove DCR handling

2014-08-01 Thread Alexander Graf
DCR handling was only needed for 440 KVM. Since we removed it, we can also remove handling of DCR accesses. Signed-off-by: Alexander Graf ag...@suse.de --- Documentation/virtual/kvm/api.txt | 6 +++--- arch/powerpc/include/asm/kvm_host.h | 4 arch/powerpc/include/asm/kvm_ppc.h | 1 -

[PULL 16/63] PPC: Add asm helpers for BE 32bit load/store

2014-08-01 Thread Alexander Graf
From assembly code we might not only have to explicitly BE access 64bit values, but sometimes also 32bit ones. Add helpers that allow for easy use of lwzx/stwx in their respective byte-reverse or native form. Signed-off-by: Alexander Graf ag...@suse.de CC: Benjamin Herrenschmidt

[PULL 50/63] KVM: Allow KVM_CHECK_EXTENSION on the vm fd

2014-08-01 Thread Alexander Graf
The KVM_CHECK_EXTENSION is only available on the kvm fd today. Unfortunately on PPC some of the capabilities change depending on the way a VM was created. So instead we need a way to expose capabilities as VM ioctl, so that we can see which VM type we're using (HV or PR). To enable this, add the

[PULL 47/63] Split out struct kvmppc_vcore creation to separate function

2014-08-01 Thread Alexander Graf
From: Stewart Smith stew...@linux.vnet.ibm.com No code changes, just split it out to a function so that with the addition of micro partition prefetch buffer allocation (in subsequent patch) looks neater and doesn't require excessive indentation. Signed-off-by: Stewart Smith

[PULL 54/63] KVM: PPC: Move kvmppc_ld/st to common code

2014-08-01 Thread Alexander Graf
We have enough common infrastructure now to resolve GVA-GPA mappings at runtime. With this we can move our book3s specific helpers to load / store in guest virtual address space to common code as well. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/include/asm/kvm_book3s.h | 2 +-

[PULL 58/63] KVM: PPC: Separate loadstore emulation from priv emulation

2014-08-01 Thread Alexander Graf
Today the instruction emulator can get called via 2 separate code paths. It can either be called by MMIO emulation detection code or by privileged instruction traps. This is bad, as both code paths prepare the environment differently. For MMIO emulation we already know the virtual address we

[PULL 37/63] KVM: PPC: Book3s: Remove kvmppc_read_inst() function

2014-08-01 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com In the context of replacing kvmppc_ld() function calls with a version of kvmppc_get_last_inst() which allow to fail, Alex Graf suggested this: If we get EMULATE_AGAIN, we just have to make sure we go back into the guest. No need to inject an ISI

[PULL 42/63] KVM: PPC: Remove comment saying SPRG1 is used for vcpu pointer

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com Scott Wood pointed out that We are no longer using SPRG1 for vcpu pointer, but using SPRN_SPRG_THREAD = SPRG3 (thread-vcpu). So this comment is not valid now. Note: SPRN_SPRG3R is not supported (do not see any need as of now), and if we want to

[PULL 43/63] KVM: PPC: Remove 440 support

2014-08-01 Thread Alexander Graf
The 440 target hasn't been properly functioning for a few releases and before I was the only one who fixes a very serious bug that indicates to me that nobody used it before either. Furthermore KVM on 440 is slow to the extent of unusable. We don't have to carry along completely unused code.

[PULL 46/63] KVM: PPC: Book3S: Make kvmppc_ld return a more accurate error indication

2014-08-01 Thread Alexander Graf
From: Paul Mackerras pau...@samba.org At present, kvmppc_ld calls kvmppc_xlate, and if kvmppc_xlate returns any error indication, it returns -ENOENT, which is taken to mean an HPTE not found error. However, the error could have been a segment found (no SLB entry) or a permission error.

[PULL 44/63] KVM: PPC: Book3S: Fix LPCR one_reg interface

2014-08-01 Thread Alexander Graf
From: Alexey Kardashevskiy a...@ozlabs.ru Unfortunately, the LPCR got defined as a 32-bit register in the one_reg interface. This is unfortunate because KVM allows userspace to control the DPFD (default prefetch depth) field, which is in the upper 32 bits. The result is that DPFD always get set

[PULL 62/63] KVM: PPC: HV: Remove generic instruction emulation

2014-08-01 Thread Alexander Graf
Now that we have properly split load/store instruction emulation and generic instruction emulation, we can move the generic one from kvm.ko to kvm-pr.ko on book3s_64. This reduces the attack surface and amount of code loaded on HV KVM kernels. Signed-off-by: Alexander Graf ag...@suse.de ---

[PULL 41/63] KVM: PPC: Booke-hv: Add one reg interface for SPRG9

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com We now support SPRG9 for guest, so also add a one reg interface for same Note: Changes are in bookehv code only as we do not have SPRG9 on booke-pr. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com Signed-off-by: Alexander Graf

[PULL 63/63] KVM: PPC: PR: Handle FSCR feature deselects

2014-08-01 Thread Alexander Graf
We handle FSCR feature bits (well, TAR only really today) lazily when the guest starts using them. So when a guest activates the bit and later uses that feature we enable it for real in hardware. However, when the guest stops using that bit we don't stop setting it in hardware. That means we can

[PULL 51/63] KVM: PPC: Book3S: Provide different CAPs based on HV or PR mode

2014-08-01 Thread Alexander Graf
With Book3S KVM we can create both PR and HV VMs in parallel on the same machine. That gives us new challenges on the CAPs we return - both have different capabilities. When we get asked about CAPs on the kvm fd, there's nothing we can do. We can try to be smart and assume we're running HV if HV

[PULL 61/63] KVM: PPC: BOOKEHV: rename e500hv_spr to bookehv_spr

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com This are not specific to e500hv but applicable for bookehv (As per comment from Scott Wood on my patch kvm: ppc: bookehv: Added wrapper macros for shadow registers) Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com Signed-off-by:

[PULL 49/63] KVM: Rename and add argument to check_extension

2014-08-01 Thread Alexander Graf
In preparation to make the check_extension function available to VM scope we add a struct kvm * argument to the function header and rename the function accordingly. It will still be called from the /dev/kvm fd, but with a NULL argument for struct kvm *. Signed-off-by: Alexander Graf ag...@suse.de

[PULL 27/63] KVM: PPC: Book3S: Add hack for split real mode

2014-08-01 Thread Alexander Graf
Today we handle split real mode by mapping both instruction and data faults into a special virtual address space that only exists during the split mode phase. This is good enough to catch 32bit Linux guests that use split real mode for copy_from/to_user. In this case we're always prefixed with

[PULL 40/63] kvm: ppc: bookehv: Save restore SPRN_SPRG9 on guest entry exit

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com SPRN_SPRG is used by debug interrupt handler, so this is required for debug support. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/include/asm/kvm_host.h | 1 +

[PULL 48/63] Use the POWER8 Micro Partition Prefetch Engine in KVM HV on POWER8

2014-08-01 Thread Alexander Graf
From: Stewart Smith stew...@linux.vnet.ibm.com The POWER8 processor has a Micro Partition Prefetch Engine, which is a fancy way of saying has way to store and load contents of L2 or L2+MRU way of L3 cache. We initiate the storing of the log (list of addresses) using the logmpp instruction and

[PULL 57/63] KVM: PPC: Handle magic page in kvmppc_ld/st

2014-08-01 Thread Alexander Graf
We use kvmppc_ld and kvmppc_st to emulate load/store instructions that may as well access the magic page. Special case it out so that we can properly access it. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/include/asm/kvm_book3s.h | 7 +++

[PULL 06/63] KVM: PPC: Book3S PR: Handle hyp doorbell exits

2014-08-01 Thread Alexander Graf
If we're running PR KVM in HV mode, we may get hypervisor doorbell interrupts. Handle those the same way we treat normal doorbells. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/book3s_pr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/kvm/book3s_pr.c

[PULL 39/63] KVM: PPC: Bookehv: Get vcpu's last instruction for emulation

2014-08-01 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com On book3e, KVM uses load external pid (lwepx) dedicated instruction to read guest last instruction on the exit path. lwepx exceptions (DTLB_MISS, DSI and LRAT), generated by loading a guest address, needs to be handled by KVM. These exceptions are

[PULL 31/63] kvm: ppc: booke: Use the shared struct helpers of SPRN_DEAR

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com Uses kvmppc_set_dar() and kvmppc_get_dar() helper functions Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke.c | 24 +++- 1 file changed, 3

[PULL 30/63] kvm: ppc: booke: Use the shared struct helpers of SRR0 and SRR1

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com Use kvmppc_set_srr0/srr1() and kvmppc_get_srr0/srr1() helper functions Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke.c | 17 ++--- 1 file changed, 6

[PULL 14/63] KVM: PPC: Book3S HV: Add H_SET_MODE hcall handling

2014-08-01 Thread Alexander Graf
From: Michael Neuling mi...@neuling.org This adds support for the H_SET_MODE hcall. This hcall is a multiplexer that has several functions, some of which are called rarely, and some which are potentially called very frequently. Here we add support for the functions that set the debug registers

[PULL 09/63] KVM: PPC: Book3S PR: Fix ABIv2 on LE

2014-08-01 Thread Alexander Graf
We switched to ABIv2 on Little Endian systems now which gets rid of the dotted function names. Branch to the actual functions when we see such a system. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/book3s_interrupts.S | 4 arch/powerpc/kvm/book3s_rmhandlers.S | 4 2

[PULL 21/63] KVM: PPC: Book3S HV: Fix ABIv2 on LE

2014-08-01 Thread Alexander Graf
For code that doesn't live in modules we can just branch to the real function names, giving us compatibility with ABIv1 and ABIv2. Do this for the compiled-in code of HV KVM. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 16 1 file

[PULL 33/63] kvm: ppc: booke: Use the shared struct helpers for SPRN_SPRG0-7

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com Use kvmppc_set_sprg[0-7]() and kvmppc_get_sprg[0-7]() helper functions Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke.c | 32

[PULL 36/63] KVM: PPC: Book3e: Add TLBSEL/TSIZE defines for MAS0/1

2014-08-01 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com Add mising defines MAS0_GET_TLBSEL() and MAS1_GET_TSIZE() for Book3E. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/include/asm/mmu-book3e.h | 9 ++--- 1 file changed, 6

[PULL 15/63] KVM: PPC: e500: Fix default tlb for victim hint

2014-08-01 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com Tlb search operation used for victim hint relies on the default tlb set by the host. When hardware tablewalk support is enabled in the host, the default tlb is TLB1 which leads KVM to evict the bolted entry. Set and restore the default tlb when

[PULL 23/63] KVM: PPC: e500: Emulate power management control SPR

2014-08-01 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com For FSL e6500 core the kernel uses power management SPR register (PWRMGTCR0) to enable idle power down for cores and devices by setting up the idle count period at boot time. With the host already controlling the power management configuration the

[PULL 22/63] KVM: PPC: Book3S HV: Enable for little endian hosts

2014-08-01 Thread Alexander Graf
Now that we've fixed all the issues that HV KVM code had on little endian hosts, we can enable it in the kernel configuration for users to play with. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git

[PULL 17/63] KVM: PPC: Book3S HV: Make HTAB code LE host aware

2014-08-01 Thread Alexander Graf
When running on an LE host all data structures are kept in little endian byte order. However, the HTAB still needs to be maintained in big endian. So every time we access any HTAB we need to make sure we do so in the right byte order. Fix up all accesses to manually byte swap. Signed-off-by:

[PULL 25/63] KVM: PPC: Deflect page write faults properly in kvmppc_st

2014-08-01 Thread Alexander Graf
When we have a page that we're not allowed to write to, xlate() will already tell us -EPERM on lookup of that page. With the code as is we change it into a page missing error which a guest may get confused about. Instead, just tell the caller about the -EPERM directly. This fixes Mac OS X guests

[PULL 05/63] KVM: PPC: Book3s HV: Fix tlbie compile error

2014-08-01 Thread Alexander Graf
Some compilers complain about uninitialized variables in the compute_tlbie_rb function. When you follow the code path you'll realize that we'll never get to that point, but the compiler isn't all that smart. So just default to 4k page sizes for everything, making the compiler happy and the code

[PULL 08/63] KVM: PPC: Assembly functions exported to modules need _GLOBAL_TOC()

2014-08-01 Thread Alexander Graf
From: Anton Blanchard an...@samba.org Both kvmppc_hv_entry_trampoline and kvmppc_entry_trampoline are assembly functions that are exported to modules and also require a valid r2. As such we need to use _GLOBAL_TOC so we provide a global entry point that establishes the TOC (r2). Signed-off-by:

[PULL 02/63] KVM: PPC: BOOK3S: PR: Emulate virtual timebase register

2014-08-01 Thread Alexander Graf
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com virtual time base register is a per VM, per cpu register that needs to be saved and restored on vm exit and entry. Writing to VTB is not allowed in the privileged mode. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com [agraf:

[PULL 13/63] KVM: PPC: Book3S: Allow only implemented hcalls to be enabled or disabled

2014-08-01 Thread Alexander Graf
From: Paul Mackerras pau...@samba.org This adds code to check that when the KVM_CAP_PPC_ENABLE_HCALL capability is used to enable or disable in-kernel handling of an hcall, that the hcall is actually implemented by the kernel. If not an EINVAL error is returned. This also checks the

[PULL 34/63] kvm: ppc: Add SPRN_EPR get helper function

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com kvmppc_set_epr() is already defined in asm/kvm_ppc.h, So rename and move get_epr helper function to same file. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com [agraf: remove duplicate return] Signed-off-by: Alexander Graf ag...@suse.de

[PULL 35/63] KVM: PPC: e500mc: Revert add load inst fixup

2014-08-01 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com The commit 1d628af7 add load inst fixup made an attempt to handle failures generated by reading the guest current instruction. The fixup code that was added works by chance hiding the real issue. Load external pid (lwepx) instruction, used by KVM

[PULL 11/63] KVM: PPC: e500mc: Enhance tlb invalidation condition on vcpu schedule

2014-08-01 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com On vcpu schedule, the condition checked for tlb pollution is too loose. The tlb entries of a vcpu become polluted (vs stale) only when a different vcpu within the same logical partition runs in-between. Optimize the tlb invalidation condition

[PULL 20/63] KVM: PPC: Book3S HV: Access XICS in BE

2014-08-01 Thread Alexander Graf
On the exit path from the guest we check what type of interrupt we received if we received one. This means we're doing hardware access to the XICS interrupt controller. However, when running on a little endian system, this access is byte reversed. So let's make sure to swizzle the bytes back

[PULL 10/63] KVM: PPC: Book3S PR: Fix sparse endian checks

2014-08-01 Thread Alexander Graf
While sending sparse with endian checks over the code base, it triggered at some places that were missing casts or had wrong types. Fix them up. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/book3s_pr_papr.c | 21 +++-- 1 file changed, 11 insertions(+), 10

[PULL 38/63] KVM: PPC: Allow kvmppc_get_last_inst() to fail

2014-08-01 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com On book3e, guest last instruction is read on the exit path using load external pid (lwepx) dedicated instruction. This load operation may fail due to TLB eviction and execute-but-not-read entries. This patch lay down the path for an alternative

[PULL 32/63] kvm: ppc: booke: Add shared struct helpers of SPRN_ESR

2014-08-01 Thread Alexander Graf
From: Bharat Bhushan bharat.bhus...@freescale.com Add and use kvmppc_set_esr() and kvmppc_get_esr() helper functions Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/booke.c

[PULL 01/63] KVM: PPC: BOOK3S: PR: Fix PURR and SPURR emulation

2014-08-01 Thread Alexander Graf
From: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com We use time base for PURR and SPURR emulation with PR KVM since we are emulating a single threaded core. When using time base we need to make sure that we don't accumulate time spent in the host in PURR and SPURR value. Also we don't need to

[PULL 00/63] ppc patch queue 2014-08-01

2014-08-01 Thread Alexander Graf
Hi Paolo / Marcelo, This is my current patch queue for ppc. Please pull. Alex The following changes since commit 9f6226a762c7ae02f6a23a3d4fc552dafa57ea23: arch: x86: kvm: x86.c: Cleaning up variable is set more than once (2014-06-30 16:52:04 +0200) are available in the git repository at:

[PULL 26/63] KVM: PPC: Book3S: Stop PTE lookup on write errors

2014-08-01 Thread Alexander Graf
When a page lookup failed because we're not allowed to write to the page, we should not overwrite that value with another lookup on the second PTEG which will return page not found. Instead, we should just tell the caller that we had a permission problem. This fixes Mac OS X guests looping

[PULL 18/63] KVM: PPC: Book3S HV: Access guest VPA in BE

2014-08-01 Thread Alexander Graf
There are a few shared data structures between the host and the guest. Most of them get registered through the VPA interface. These data structures are defined to always be in big endian byte order, so let's make sure we always access them in big endian. Signed-off-by: Alexander Graf

RE: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception

2014-08-01 Thread bharat.bhus...@freescale.com
-Original Message- From: Wood Scott-B07421 Sent: Friday, August 01, 2014 2:16 AM To: Bhushan Bharat-R65777 Cc: ag...@suse.de; kvm-...@vger.kernel.org; kvm@vger.kernel.org; Yoder Stuart- B08248 Subject: Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception On

Re: [PATCH] arm64: KVM: export current vcpu-pause state via pseudo regs

2014-08-01 Thread Alex Bennée
Christoffer Dall writes: On Thu, Jul 31, 2014 at 05:45:28PM +0100, Peter Maydell wrote: On 31 July 2014 17:38, Christoffer Dall christoffer.d...@linaro.org wrote: If we are not complaining when setting the pause value to false if it was true before, then we probably also need to wake up

Re: [PULL 16/63] PPC: Add asm helpers for BE 32bit load/store

2014-08-01 Thread Benjamin Herrenschmidt
On Fri, 2014-08-01 at 11:17 +0200, Alexander Graf wrote: From assembly code we might not only have to explicitly BE access 64bit values, but sometimes also 32bit ones. Add helpers that allow for easy use of lwzx/stwx in their respective byte-reverse or native form. Signed-off-by:

[PATCH] arm64: KVM: fix 64bit CP15 VM access for 32bit guests

2014-08-01 Thread Marc Zyngier
Commit f0a3eaff71b8 (ARM64: KVM: fix big endian issue in access_vm_reg for 32bit guest) changed the way we handle CP15 VM accesses, so that all 64bit accesses are done via vcpu_sys_reg. This looks like a good idea as it solves indianness issues in an elegant way, except for one small detail: the

Re: [PATCH] arm64: KVM: fix 64bit CP15 VM access for 32bit guests

2014-08-01 Thread Christoffer Dall
On Fri, Aug 01, 2014 at 12:00:36PM +0100, Marc Zyngier wrote: Commit f0a3eaff71b8 (ARM64: KVM: fix big endian issue in access_vm_reg for 32bit guest) changed the way we handle CP15 VM accesses, so that all 64bit accesses are done via vcpu_sys_reg. This looks like a good idea as it solves

Re: [RFC PATCH 04/17] COLO info: use colo info to tell migration target colo is enabled

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: migrate colo info to migration target to tell the target colo is enabled. If I understand this correctly this means that you send a 'colo info' device information for migrations that don't have COLO enabled; that's bad because it breaks migration

Re: [RFC PATCH 05/17] COLO save: integrate COLO checkpointed save into qemu migration

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: Integrate COLO checkpointed save flow into qemu migration. Add a migrate state: MIG_STATE_COLO, enter this migrate state after the first live migration successfully finished. Create a colo thread to do the checkpointed save. In postcopy I

Re: [RFC PATCH 07/17] COLO buffer: implement colo buffer as well as QEMUFileOps based on it

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: We need a buffer to store migration data. On save side: all saved data was write into colo buffer first, so that we can know the total size of the migration data. this can also separate the data transmission from colo control data, we use

Re: [RFC PATCH 10/17] COLO ctl: introduce is_slave() and is_master()

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: is_slaver is to determine whether the QEMU instance is a slaver(migration target) at runtime. is_master is to determine whether the QEMU instance is a master(migration starter) at runtime. This 2 APIs will be used later. Since the names are made

Re: [RFC PATCH 11/17] COLO ctl: implement colo checkpoint protocol

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: implement colo checkpoint protocol. Checkpoint synchronzing points. Primary Secondary NEW @ Suspend SUSPENDED @

Re: [RFC PATCH 13/17] COLO ctl: implement colo save

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: implement colo save My postcopy 'QEMU_VM_CMD_PACKAGED' does something similar to parts of this with the QEMUSizedBuffer, we might be able to share some more: https://lists.nongnu.org/archive/html/qemu-devel/2014-07/msg00886.html +/* we send

Re: [RFC PATCH 16/17] COLO ram cache: implement colo ram cache on slaver

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: The ram cache was initially the same as PVM's memory. At checkpoint, we cache the dirty memory of PVM into ram cache (so that ram cache always the same as PVM's memory at every checkpoint), flush cached memory to SVM after we received all PVM

Re: [RFC PATCH 15/17] COLO save: reuse migration bitmap under colo checkpoint

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: reuse migration bitmap under colo checkpoint, only send dirty pages per-checkpoint. Signed-off-by: Yang Hongyang yan...@cn.fujitsu.com --- arch_init.c| 20 +++- include/migration/migration-colo.h | 2

Re: Integrity in untrusted environments

2014-08-01 Thread Shiva V
Paolo Bonzini pbonzini at redhat.com writes Hello, I am exploring ideas to implement a service inside a virtual machine on untrusted hypervisors under current cloud infrastructures. Particularly, I am interested how one can verify the integrity of the service in an environment where

Re: [RFC PATCH 00/17] COarse-grain LOck-stepping(COLO) Virtual Machines for Non-stop Service

2014-08-01 Thread Dr. David Alan Gilbert
* Yang Hongyang (yan...@cn.fujitsu.com) wrote: Virtual machine (VM) replication is a well known technique for providing application-agnostic software-implemented hardware fault tolerance non-stop service. COLO is a high availability solution. Both primary VM (PVM) and secondary VM (SVM) run in

George Traykov Donation

2014-08-01 Thread George Traykov
Dear Sir / Ma'am, This is a personal email directed to you. My name is George Traykov and I have decided to write you to share my fortune to two (2) lucky winner.I won the lottery twice but I'm still not happy being labelled the world's most ungrateful winner hence I have voluntarily decided

Fwd: Question and Performance of Intel's APIC-v on Xeon E5 v2

2014-08-01 Thread William Tu
Hi folks, I recently got a Intel Xeon E5-2609 v2 machine with APIC-v support. I did some performance tests under Linux kernel 3.11 and have some doubts about the new APICv feature. I'm appreciated for any comments and please correct me if I'm wrong. My understanding of APIC-v is that it mainly

kvm-unit-tests failures

2014-08-01 Thread Chris J Arges
Hi, We are planning on running kvm-unit-tests as part of our test suite; but I've noticed that many tests fail (even running the latest kvm tip). After searching I found many BZ entires that seem to point at this master bug for tracking these issues:

[RFC][PATCH] kvm: x86: fix stale mmio cache bug

2014-08-01 Thread David Matlack
The following events can lead to an incorrect KVM_EXIT_MMIO bubbling up to userspace: (1) Guest accesses gpa X without a memory slot. The gfn is cached in struct kvm_vcpu_arch (mmio_gfn). On Intel EPT-enabled hosts, KVM sets the SPTE write-execute-noread so that future accesses cause

Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception

2014-08-01 Thread Scott Wood
On Fri, 2014-08-01 at 04:34 -0500, Bhushan Bharat-R65777 wrote: on dbsr write emulation, deque the debug interrupt even if DBSR_IDE is set. case SPRN_DBSR: vcpu-arch.dbsr = ~spr_val; if (!(vcpu-arch.dbsr ~DBSR_IDE))

Re: [RFC][PATCH] kvm: x86: fix stale mmio cache bug

2014-08-01 Thread Xiao Guangrong
On Aug 2, 2014, at 7:54 AM, David Matlack dmatl...@google.com wrote: The following events can lead to an incorrect KVM_EXIT_MMIO bubbling up to userspace: (1) Guest accesses gpa X without a memory slot. The gfn is cached in struct kvm_vcpu_arch (mmio_gfn). On Intel EPT-enabled hosts, KVM

[PULL 04/63] KVM: PPC: Book3s PR: Disable AIL mode with OPAL

2014-08-01 Thread Alexander Graf
When we're using PR KVM we must not allow the CPU to take interrupts in virtual mode, as the SLB does not contain host kernel mappings when running inside the guest context. To make sure we get good performance for non-KVM tasks but still properly functioning PR KVM, let's just disable AIL

[PULL 19/63] KVM: PPC: Book3S HV: Access host lppaca and shadow slb in BE

2014-08-01 Thread Alexander Graf
Some data structures are always stored in big endian. Among those are the LPPACA fields as well as the shadow slb. These structures might be shared with a hypervisor. So whenever we access those fields, make sure we do so in big endian byte order. Signed-off-by: Alexander Graf ag...@suse.de ---

[PULL 28/63] KVM: PPC: Book3S: Make magic page properly 4k mappable

2014-08-01 Thread Alexander Graf
The magic page is defined as a 4k page of per-vCPU data that is shared between the guest and the host to accelerate accesses to privileged registers. However, when the host is using 64k page size granularity we weren't quite as strict about that rule anymore. Instead, we partially treated all of

[PULL 07/63] KVM: PPC: Book3S HV: Fix ABIv2 indirect branch issue

2014-08-01 Thread Alexander Graf
From: Anton Blanchard an...@samba.org To establish addressability quickly, ABIv2 requires the target address of the function being called to be in r12. Signed-off-by: Anton Blanchard an...@samba.org Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 4 ++--

  1   2   >