Re: [PATCH v2] arm/arm64: KVM: Properly account for guest CPU time

2015-06-08 Thread Marc Zyngier
Hi Christoffer, On 28/05/15 19:49, Christoffer Dall wrote: Until now we have been calling kvm_guest_exit after re-enabling interrupts when we come back from the guest, but this has the unfortunate effect that CPU time accounting done in the context of timer interrupts occurring while the

[PATCH 08/10] KVM: arm/arm64: vgic: Add vgic_{get,set}_phys_irq_active

2015-06-08 Thread Marc Zyngier
In order to control the active state of an interrupt, introduce a pair of accessors allowing the state to be set/queried. This only affects the logical state, and the HW state will only be applied at world-switch time. Signed-off-by: Marc Zyngier marc.zyng...@arm.com --- include/kvm/arm_vgic.h

[PATCH 03/10] KVM: arm/arm64: vgic: Convert struct vgic_lr to use bitfields

2015-06-08 Thread Marc Zyngier
As we're about to cram more information in the vgic_lr structure (HW interrupt number and additional state information), we switch to a layout similar to the HW's: - use bitfields to save space (we don't need more than 10 bits to represent the irq numbers) - source CPU and HW interrupt can

[PATCH 09/10] KVM: arm/arm64: timer: Allow the timer to control the active state

2015-06-08 Thread Marc Zyngier
In order to remove the crude hack where we sneak the masked bit into the timer's control register, make use of the phys_irq_map API control the active state of the interrupt. Signed-off-by: Marc Zyngier marc.zyng...@arm.com --- include/kvm/arm_arch_timer.h | 3 +++ virt/kvm/arm/arch_timer.c

[PATCH 04/10] KVM: arm/arm64: vgic: Allow HW irq to be encoded in LR

2015-06-08 Thread Marc Zyngier
Now that struct vgic_lr supports the LR_HW bit and carries a hwirq field, we can encode that information into the list registers. This patch provides implementations for both GICv2 and GICv3. Signed-off-by: Marc Zyngier marc.zyng...@arm.com --- include/linux/irqchip/arm-gic-v3.h | 3 +++

[PATCH 10/10] KVM: arm/arm64: vgic: Allow non-shared device HW interrupts

2015-06-08 Thread Marc Zyngier
So far, the only use of the HW interrupt facility is the timer, implying that the active state is context-switched for each vcpu, as the device is is shared across all vcpus. This does not work for a device that has been assigned to a VM, as the guest is entierely in control of that device (the

[PATCH 07/10] KVM: arm/arm64: vgic: Allow HW interrupts to be queued to a guest

2015-06-08 Thread Marc Zyngier
To allow a HW interrupt to be injected into a guest, we lookup the guest virtual interrupt in the irq_phys_map rbtree, and if we have a match, encode both interrupts in the LR. We also mark the interrupt as active at the host distributor level. On guest EOI on the virtual interrupt, the host

[PATCH 00/10] arm/arm64: KVM: Active interrupt state switching for shared devices

2015-06-08 Thread Marc Zyngier
From day 1, our timer code has been using a terrible hack: whenever the guest is scheduled with a timer interrupt pending (i.e. the HW timer has expired), we restore the timer state with the MASK bit set, in order to avoid the physical interrupt to fire again. And again. And again... This is

[PATCH 01/10] arm/arm64: KVM: Fix ordering of timer/GIC on guest entry

2015-06-08 Thread Marc Zyngier
As we now inject the timer interrupt when we're about to enter the guest, it makes a lot more sense to make sure this happens before the vgic code queues the pending interrupts. Otherwise, we get the interrupt on the following exit, which is not great for latency (and leads to all kind of bizarre

[PATCH 02/10] arm/arm64: KVM: Move vgic handling to a non-preemptible section

2015-06-08 Thread Marc Zyngier
As we're about to introduce some serious GIC-poking to the vgic code, it is important to make sure that we're going to poke the part of the GIC that belongs to the CPU we're about to run on (otherwise, we'd end up with some unexpected interrupts firing)... Introducing a non-preemptible section in

[PATCH 05/10] KVM: arm/arm64: vgic: Relax vgic_can_sample_irq for edge IRQs

2015-06-08 Thread Marc Zyngier
We only set the irq_queued flag for level interrupts, meaning that !vgic_irq_is_queued(vcpu, irq) is a good enough predicate for all interrupts. This will allow us to inject edge HW interrupts, for which the state ACTIVE+PENDING is not allowed. Signed-off-by: Marc Zyngier marc.zyng...@arm.com

[PATCH 06/10] KVM: arm/arm64: vgic: Allow dynamic mapping of physical/virtual interrupts

2015-06-08 Thread Marc Zyngier
In order to be able to feed physical interrupts to a guest, we need to be able to establish the virtual-physical mapping between the two worlds. The mapping is kept in a rbtree, indexed by virtual interrupts. Signed-off-by: Marc Zyngier marc.zyng...@arm.com --- include/kvm/arm_vgic.h | 18

Re: [PATCH 00/13] arm64: KVM: GICv3 ITS emulation

2015-06-08 Thread Marc Zyngier
On 08/06/15 11:54, Pavel Fedin wrote: Hi! I'm afraid this is not enough. A write to GICR_TRANSLATER (DID+EID) results in a (LPI,CPU) pair. Can you easily express the CPU part in irqfd (this is a genuine question, I'm not familiar enough with that part of the core)? But... As far as i

Re: [PATCH v3 3/4] KVM: x86: Add EOI exit bitmap inference

2015-06-08 Thread Wanpeng Li
On 6/8/15 10:15 PM, Paolo Bonzini wrote: On 08/06/2015 12:33, Wanpeng Li wrote: +if (kvm_check_request(KVM_REQ_SCAN_IOAPIC, vcpu)) { +if (irqchip_split(vcpu-kvm)) { +memset(vcpu-arch.eoi_exit_bitmaps, 0, 32); +kvm_scan_ioapic_routes( +

Re: [PATCH 09/15] KVM: MTRR: introduce var_mtrr_range

2015-06-08 Thread Xiao Guangrong
Thanks for your review, David! On 06/09/2015 08:36 AM, David Matlack wrote: static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) { struct kvm_mtrr *mtrr_state = vcpu-arch.mtrr_state; - gfn_t start, end, mask; + gfn_t start, end; int index; if

Re: [PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-08 Thread David Matlack
On Sat, May 30, 2015 at 3:59 AM, Xiao Guangrong guangrong.x...@linux.intel.com wrote: It walks all MTRRs and gets all the memory cache type setting for the specified range also it checks if the range is fully covered by MTRRs Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com ---

Re: [PATCH 05/15] KVM: MTRR: clean up mtrr default type

2015-06-08 Thread David Matlack
On Sat, May 30, 2015 at 3:59 AM, Xiao Guangrong guangrong.x...@linux.intel.com wrote: Use union definition to avoid the decode/code workload and drop all the hard code Thank you for doing this cleanup. The new code is much clearer! Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com

Re: [PATCH 09/15] KVM: MTRR: introduce var_mtrr_range

2015-06-08 Thread David Matlack
On Sat, May 30, 2015 at 3:59 AM, Xiao Guangrong guangrong.x...@linux.intel.com wrote: It gets the range for the specified variable MTRR Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/kvm/mtrr.c | 19 +-- 1 file changed, 13 insertions(+), 6

Re: [PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-08 Thread Xiao Guangrong
On 06/09/2015 08:36 AM, David Matlack wrote: On Sat, May 30, 2015 at 3:59 AM, Xiao Guangrong guangrong.x...@linux.intel.com wrote: It walks all MTRRs and gets all the memory cache type setting for the specified range also it checks if the range is fully covered by MTRRs Signed-off-by: Xiao

Re: [PATCH v2 09/13] KVM: x86: pass kvm_mmu_page to gfn_to_rmap

2015-06-08 Thread Xiao Guangrong
On 05/28/2015 01:05 AM, Paolo Bonzini wrote: This is always available (with one exception in the auditing code). Later we will also use the role to look up the right memslots array. return; @@ -191,11 +191,15 @@ static void audit_write_protection(struct kvm *kvm,

Re: [PATCH v2 10/13] KVM: x86: use vcpu-specific functions to read/write/translate GFNs

2015-06-08 Thread Xiao Guangrong
On 05/28/2015 01:05 AM, Paolo Bonzini wrote: We need to hide SMRAM from guests not running in SMM. Therefore, all uses of kvm_read_guest* and kvm_write_guest* must be changed to check whether the VCPU is in system management mode and use a different set of memslots. Switch from kvm_* to the

Re: [PATCH 1/2] KVM: MMU: fix SMAP virtualization

2015-06-08 Thread Vinson Lee
On Tue, May 26, 2015 at 7:53 PM, Xiao Guangrong guangrong.x...@linux.intel.com wrote: On 05/26/2015 10:48 PM, Paolo Bonzini wrote: On 26/05/2015 16:45, Edward Cree wrote: This breaks older compilers that can't initialize anon structures. How old ? Even gcc 3.1 says you can use unnamed

Re: [PATCH v2 08/13] KVM: implement multiple address spaces

2015-06-08 Thread Xiao Guangrong
On 05/28/2015 01:05 AM, Paolo Bonzini wrote: /* @@ -772,6 +776,7 @@ int __kvm_set_memory_region(struct kvm *kvm, struct kvm_memory_slot *slot; struct kvm_memory_slot old, new; struct kvm_memslots *slots = NULL, *old_memslots; + int as_id, id; enum

Re: [PATCH v2 11/13] KVM: x86: work on all available address spaces

2015-06-08 Thread Xiao Guangrong
On 05/28/2015 01:05 AM, Paolo Bonzini wrote: This patch has no semantic change, but it prepares for the introduction of a second address space for system management mode. A new function x86_set_memory_region (and the slots_lock taken counterpart __x86_set_memory_region) is introduced in order

Re: [PATCH v2 12/13] KVM: x86: add SMM to the MMU role, support SMRAM address space

2015-06-08 Thread Xiao Guangrong
On 05/28/2015 01:05 AM, Paolo Bonzini wrote: This is now very simple to do. The only interesting part is a simple trick to find the right memslot in gfn_to_rmap, retrieving the address space from the spte role word. The same trick is used in the auditing code. The comment on top of union

Re: [PATCH 00/13] arm64: KVM: GICv3 ITS emulation

2015-06-08 Thread Marc Zyngier
Hi Pavel, On 08/06/15 07:53, Pavel Fedin wrote: Hello everybody! The GICv3 ITS (Interrupt Translation Service) is a part of the ARM GICv3 interrupt controller used for implementing MSIs. It specifies a new kind of interrupts (LPIs), which are mapped to establish a connection between a

Steroid Products--Numberone Biotech Inc.

2015-06-08 Thread Numberone Biotech Inc.
Dear, Our company manufactures a range of injectable and oral steroids products that are used successfully in over 10 countries. We are considering expanding our products to new markets and we would appreciate you assistance. In particular, we would like to look for product agents. We will quote

RE: [PATCH 00/13] arm64: KVM: GICv3 ITS emulation

2015-06-08 Thread Pavel Fedin
Hello everybody! The GICv3 ITS (Interrupt Translation Service) is a part of the ARM GICv3 interrupt controller used for implementing MSIs. It specifies a new kind of interrupts (LPIs), which are mapped to establish a connection between a device, its MSI payload value and the target

Re: [PATCH v3 3/4] KVM: x86: Add EOI exit bitmap inference

2015-06-08 Thread Wanpeng Li
On 6/3/15 7:51 AM, Steve Rutherford wrote: In order to support a userspace IOAPIC interacting with an in kernel APIC, the EOI exit bitmaps need to be configurable. If the IOAPIC is in userspace (i.e. the irqchip has been split), the EOI exit bitmaps will be set whenever the GSI Routes are

Re: [PATCH] MIPS: KVM: do not sign extend on unsigned MMIO load

2015-06-08 Thread James Hogan
Hi stable folk, On 08/05/15 15:16, James Hogan wrote: On 07/05/15 13:47, Nicholas Mc Guire wrote: Fix possible unintended sign extension in unsigned MMIO loads by casting to uint16_t in the case of mmio_needed != 2. Signed-off-by: Nicholas Mc Guire hof...@osadl.org Looks good to me. I

RE: [PATCH 00/13] arm64: KVM: GICv3 ITS emulation

2015-06-08 Thread Pavel Fedin
Hi! I'm afraid this is not enough. A write to GICR_TRANSLATER (DID+EID) results in a (LPI,CPU) pair. Can you easily express the CPU part in irqfd (this is a genuine question, I'm not familiar enough with that part of the core)? But... As far as i could understand, LPI is added to a

Re: [kvm:queue 76/76] arch/x86/kvm/../../../virt/kvm/irqchip.c:144:35: sparse: incorrect type in argument 1 (different address spaces)

2015-06-08 Thread Paolo Bonzini
On 06/06/2015 01:50, kbuild test robot wrote: tree: git://git.kernel.org/pub/scm/virt/kvm/kvm.git queue head: 6aa5e7eb06cff8d317328a0c4696b5f635ba6be3 commit: 6aa5e7eb06cff8d317328a0c4696b5f635ba6be3 [76/76] kvm: irqchip: Break up high order allocations of kvm_irq_routing_table

Re: [PATCH v3 3/4] KVM: x86: Add EOI exit bitmap inference

2015-06-08 Thread Paolo Bonzini
On 08/06/2015 12:33, Wanpeng Li wrote: +if (kvm_check_request(KVM_REQ_SCAN_IOAPIC, vcpu)) { +if (irqchip_split(vcpu-kvm)) { +memset(vcpu-arch.eoi_exit_bitmaps, 0, 32); +kvm_scan_ioapic_routes( +vcpu,

Re: [PATCH v2] arm/arm64: KVM: Properly account for guest CPU time

2015-06-08 Thread Christoffer Dall
On Fri, Jun 05, 2015 at 05:24:07AM -0700, Mario Smarduch wrote: On 06/02/2015 02:27 AM, Christoffer Dall wrote: On Mon, Jun 01, 2015 at 08:48:22AM -0700, Mario Smarduch wrote: On 05/30/2015 11:59 PM, Christoffer Dall wrote: Hi Mario, On Fri, May 29, 2015 at 03:34:47PM -0700, Mario

Re: [PATCH v5] i386: Introduce ARAT CPU feature

2015-06-08 Thread Paolo Bonzini
On 07/06/2015 11:15, Jan Kiszka wrote: From: Jan Kiszka jan.kis...@siemens.com ARAT signals that the APIC timer does not stop in power saving states. As our APICs are emulated, it's fine to expose this feature to guests, at least when asking for KVM host features or with CPU types that

Re: [PATCH v5] i386: Introduce ARAT CPU feature

2015-06-08 Thread Michael S. Tsirkin
On Sun, Jun 07, 2015 at 11:15:08AM +0200, Jan Kiszka wrote: From: Jan Kiszka jan.kis...@siemens.com ARAT signals that the APIC timer does not stop in power saving states. As our APICs are emulated, it's fine to expose this feature to guests, at least when asking for KVM host features or with