[PATCH] KVM: arm/arm64: avoid using kvm_run for in-kernel emulation

2015-03-27 Thread Andre Przywara
Our in-kernel VGIC emulation still uses struct kvm_run briefly before writing back the emulation result into the guest register. Using a userspace mapped data structure within the kernel sounds dodgy, also we do some extra copying at the moment at the end of the VGIC emulation code. Replace the usa

[PATCH v3a 11/11] KVM: arm/arm64: rework MMIO abort handling to use KVM MMIO bus

2015-03-27 Thread Andre Przywara
Currently we have struct kvm_exit_mmio for encapsulating MMIO abort data to be passed on from syndrome decoding all the way down to the VGIC register handlers. Now as we switch the MMIO handling to be routed through the KVM MMIO bus, it does not make sense anymore to use that structure already from

Re: [PATCH v3 09/11] KVM: arm/arm64: merge GICv3 RD_base and SGI_base register frames

2015-03-27 Thread Christoffer Dall
On Thu, Mar 26, 2015 at 02:39:36PM +, Andre Przywara wrote: > Currently we handle the redistributor registers in two separate MMIO > regions, one for the overall behaviour and SPIs and one for the > SGIs/PPIs. That latter forces the creation of _two_ KVM I/O bus > devices for each redistributor

Re: [PATCH v3 10/11] KVM: arm/arm64: prepare GICv3 emulation to use kvm_io_bus MMIO handling

2015-03-27 Thread Christoffer Dall
On Thu, Mar 26, 2015 at 02:39:37PM +, Andre Przywara wrote: > Using the framework provided by the recent vgic.c changes, we > register a kvm_io_bus device on mapping the virtual GICv3 resources. > The distributor mapping is pretty straight forward, but the > redistributors need some more love,

Re: [PATCH v3 08/11] KVM: arm/arm64: prepare GICv2 emulation to be handled by kvm_io_bus

2015-03-27 Thread Christoffer Dall
On Thu, Mar 26, 2015 at 02:39:35PM +, Andre Przywara wrote: > Using the framework provided by the recent vgic.c changes we register > a kvm_io_bus device when initializing the virtual GICv2. > > Signed-off-by: Andre Przywara Reviewed-by: Christoffer Dall

Re: [PATCH v3 11/11] KVM: arm/arm64: rework MMIO abort handling to use KVM MMIO bus

2015-03-27 Thread Christoffer Dall
On Thu, Mar 26, 2015 at 02:39:38PM +, Andre Przywara wrote: > Currently we have struct kvm_exit_mmio for encapsulating MMIO abort > data to be passed on from syndrome decoding all the way down to the > VGIC register handlers. Now as we switch the MMIO handling to be > routed through the KVM MMI

Re: [PATCH v3 07/11] KVM: arm/arm64: implement kvm_io_bus MMIO handling for the VGIC

2015-03-27 Thread Christoffer Dall
On Thu, Mar 26, 2015 at 02:39:34PM +, Andre Przywara wrote: > Currently we use a lot of VGIC specific code to do the MMIO > dispatching. > Use the previous reworks to add kvm_io_bus style MMIO handlers. > > Those are not yet called by the MMIO abort handler, also the actual > VGIC emulator fun

[PATCH] kvmtool: Add minimal support for macvtap

2015-03-27 Thread Marc Zyngier
In order to be useable by kvmtool, a macvtap interface requires some minimal configuration (basically setting up the offload bits). This requires skipping some of the low level TUN/TAP setup. To avoid adding yet another option, we extend the 'tapif' option to detect the use of a file (such as /dev

[PATCH v3 0/5] arm64: Patching branches for fun and profit

2015-03-27 Thread Marc Zyngier
The current alternative instruction framework is not kind to branches, potentially leading to all kind of hacks in the code that uses alternatives. This series expands it to deal with immediate branches (for a start), and applies it to the VGIC world switch. Patch #1 adds the required infrastructu

[PATCH v3 4/5] arm64: alternative: Introduce feature for GICv3 CPU interface

2015-03-27 Thread Marc Zyngier
Add a new item to the feature set (ARM64_HAS_SYSREG_GIC_CPUIF) to indicate that we have a system register GIC CPU interface This will help KVM switching to alternative instruction patching. Reviewed-by: Andre Przywara Acked-by: Will Deacon Signed-off-by: Marc Zyngier --- arch/arm64/include/as

[PATCH v3 2/5] arm64: alternative: Allow immediate branch as alternative instruction

2015-03-27 Thread Marc Zyngier
Since all immediate branches are PC-relative on Aarch64, these instructions cannot be used as an alternative with the simplistic approach we currently have (the immediate has been computed from the .altinstr_replacement section, and end-up being completely off if we insert it directly). This patch

[PATCH v3 5/5] arm64: KVM: Switch vgic save/restore to alternative_insn

2015-03-27 Thread Marc Zyngier
So far, we configured the world-switch by having a small array of pointers to the save and restore functions, depending on the GIC used on the platform. Loading these values each time is a bit silly (they never change), and it makes sense to rely on the instruction patching instead. This leads to

[PATCH v3 3/5] arm64: Extract feature parsing code from cpu_errata.c

2015-03-27 Thread Marc Zyngier
As we detect more architectural features at runtime, it makes sense to reuse the existing framework whilst avoiding to call a feature an erratum... This patch extract the core capability parsing, moves it into a new file (cpufeature.c), and let the CPU errata detection code use it. Reviewed-by: A

[PATCH v3 1/5] arm64: insn: Add aarch64_insn_decode_immediate

2015-03-27 Thread Marc Zyngier
Patching an instruction sometimes requires extracting the immediate field from this instruction. To facilitate this, and avoid potential duplication of code, add aarch64_insn_decode_immediate as the reciprocal to aarch64_insn_encode_immediate. Acked-by: Will Deacon Signed-off-by: Marc Zyngier --

Re: [PATCH 2/5] arm64: alternative: Allow immediate branch as alternative instruction

2015-03-27 Thread Marc Zyngier
Hi Tixy, On 27/03/15 10:42, Jon Medhurst (Tixy) wrote: > On Thu, 2015-03-26 at 22:19 +, Marc Zyngier wrote: >> On Thu, 26 Mar 2015 22:03:23 + >> Will Deacon wrote: >> >>> On Thu, Mar 19, 2015 at 01:59:33PM +, Marc Zyngier wrote: Since all immediate branches are PC-relative on Aar

Re: [PATCH v2 06/12] KVM: mark kvm->buses as empty once they were destroyed

2015-03-27 Thread Chen, Tiejun
On 2015/3/27 9:31, Marcelo Tosatti wrote: On Wed, Mar 25, 2015 at 05:09:13PM +, Marc Zyngier wrote: On 23/03/15 15:58, Andre Przywara wrote: In kvm_destroy_vm() we call kvm_io_bus_destroy() pretty early, especially before calling kvm_arch_destroy_vm(). To avoid unregistering devices from th

Re: [PATCH 2/5] arm64: alternative: Allow immediate branch as alternative instruction

2015-03-27 Thread Jon Medhurst (Tixy)
On Thu, 2015-03-26 at 22:19 +, Marc Zyngier wrote: > On Thu, 26 Mar 2015 22:03:23 + > Will Deacon wrote: > > > On Thu, Mar 19, 2015 at 01:59:33PM +, Marc Zyngier wrote: > > > Since all immediate branches are PC-relative on Aarch64, these > > > instructions cannot be used as an alterna

Re: ARM: KVM/XEN: how should we support virt-what?

2015-03-27 Thread Andrew Jones
On Thu, Mar 26, 2015 at 07:50:06PM +0100, Ard Biesheuvel wrote: > On 26 March 2015 at 19:49, Ard Biesheuvel wrote: > > On 26 March 2015 at 19:45, Stefano Stabellini > > wrote: > >> On Thu, 26 Mar 2015, Andrew Jones wrote: > >>> On Wed, Mar 25, 2015 at 10:44:42AM +0100, Andrew Jones wrote: > >>> >

Re: [PATCH v2 12/12] KVM: arm/arm64: remove now obsolete VGIC specific MMIO handling code

2015-03-27 Thread Marc Zyngier
On 23/03/15 15:58, Andre Przywara wrote: > With all of the virtual GIC emulation code now being registered with > the kvm_io_bus, we can remove all of the old MMIO handling code and > its dispatching functionality. > > Signed-off-by: Andre Przywara > --- > include/kvm/arm_vgic.h |2 -- >

Re: [PATCH v3 10/11] KVM: arm/arm64: prepare GICv3 emulation to use kvm_io_bus MMIO handling

2015-03-27 Thread Marc Zyngier
On Fri, 27 Mar 2015 00:14:12 + Andre Przywara wrote: > On 03/26/2015 10:06 PM, Marc Zyngier wrote: > > On Thu, 26 Mar 2015 14:39:37 + > > Andre Przywara wrote: > > > >> Using the framework provided by the recent vgic.c changes, we > >> register a kvm_io_bus device on mapping the virtual