Re: [PATCH v2 1/2] target/arm: kvm: Inject events at the last stage of sync

2020-02-06 Thread Andrew Jones
On Thu, Feb 06, 2020 at 09:41:10PM +, Beata Michalska wrote: > On Tue, 4 Feb 2020 at 10:34, Andrew Jones wrote: > > > > On Wed, Jan 29, 2020 at 08:24:40PM +, Beata Michalska wrote: > > > KVM_SET_VCPU_EVENTS might actually lead to vcpu registers being modified. > > > As such this should be

Re: [kvm-unit-tests PATCH v3 09/14] arm/arm64: ITS: Device and collection Initialization

2020-02-06 Thread Zenghui Yu
Hi Eric, On 2020/1/28 18:34, Eric Auger wrote: Introduce an helper functions to register - a new device, characterized by its device id and the max number of event IDs that dimension its ITT (Interrupt Translation Table). The function allocates the ITT. - a new collection, characterized

Re: [kvm-unit-tests PATCH v3 08/14] arm/arm64: ITS: its_enable_defaults

2020-02-06 Thread Zenghui Yu
Hi Eric, On 2020/1/28 18:34, Eric Auger wrote: its_enable_defaults() is the top init function that allocates the command queue and all the requested tables (device, collection, lpi config and pending tables), enable LPIs at distributor level and ITS level. gicv3_enable_defaults must be called b

Re: [kvm-unit-tests PATCH v3 06/14] arm/arm64: gicv3: Set the LPI config and pending tables

2020-02-06 Thread Zenghui Yu
Hi Eric, On 2020/1/28 18:34, Eric Auger wrote: Allocate the LPI configuration and per re-distributor pending table. Set redistributor's PROPBASER and PENDBASER. The LPIs are enabled by default in the config table. Also introduce a helper routine that allows to set the pending table bit for a gi

Re: [PATCH v5 19/19] KVM: selftests: Add test for KVM_SET_USER_MEMORY_REGION

2020-02-06 Thread Sean Christopherson
On Thu, Feb 06, 2020 at 05:30:01PM -0500, Peter Xu wrote: > On Tue, Jan 21, 2020 at 02:31:57PM -0800, Sean Christopherson wrote: > > Add a KVM selftest to test moving the base gfn of a userspace memory > > region. Although the basic concept of moving memory regions is not x86 > > specific, the ass

Re: [PATCH v5 19/19] KVM: selftests: Add test for KVM_SET_USER_MEMORY_REGION

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:57PM -0800, Sean Christopherson wrote: > Add a KVM selftest to test moving the base gfn of a userspace memory > region. Although the basic concept of moving memory regions is not x86 > specific, the assumptions regarding large pages and MMIO shenanigans > used to veri

Re: [PATCH v5 18/19] KVM: Dynamically size memslot array based on number of used slots

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:56PM -0800, Sean Christopherson wrote: > Now that the memslot logic doesn't assume memslots are always non-NULL, > dynamically size the array of memslots instead of unconditionally > allocating memory for the maximum number of memslots. > > Note, because a to-be-delet

Re: [PATCH v4 16/19] KVM: Ensure validity of memslot with respect to kvm_get_dirty_log()

2020-02-06 Thread Peter Xu
On Tue, Jan 14, 2020 at 10:25:07AM -0800, Sean Christopherson wrote: > On Tue, Dec 24, 2019 at 01:19:30PM -0500, Peter Xu wrote: > > On Tue, Dec 17, 2019 at 12:40:38PM -0800, Sean Christopherson wrote: > > > +int kvm_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log, > > > + in

Re: [PATCH v2 2/2] target/arm: kvm: Handle DABT with no valid ISS

2020-02-06 Thread Beata Michalska
On Wed, 5 Feb 2020 at 16:57, Andrew Jones wrote: > > On Wed, Jan 29, 2020 at 08:24:41PM +, Beata Michalska wrote: > > On ARMv7 & ARMv8 some load/store instructions might trigger a data abort > > exception with no valid ISS info to be decoded. The lack of decode info > > makes it at least trick

Re: [PATCH v2 1/2] target/arm: kvm: Inject events at the last stage of sync

2020-02-06 Thread Beata Michalska
On Tue, 4 Feb 2020 at 10:34, Andrew Jones wrote: > > On Wed, Jan 29, 2020 at 08:24:40PM +, Beata Michalska wrote: > > KVM_SET_VCPU_EVENTS might actually lead to vcpu registers being modified. > > As such this should be the last step of sync to avoid potential overwriting > > of whatever change

Re: [PATCH v5 15/19] KVM: Provide common implementation for generic dirty log functions

2020-02-06 Thread Peter Xu
On Thu, Feb 06, 2020 at 01:21:20PM -0800, Sean Christopherson wrote: > On Thu, Feb 06, 2020 at 03:02:00PM -0500, Peter Xu wrote: > > On Tue, Jan 21, 2020 at 02:31:53PM -0800, Sean Christopherson wrote: > > > > [...] > > > > > -int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm, struct > > > kvm_cl

Re: [PATCH v5 15/19] KVM: Provide common implementation for generic dirty log functions

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:53PM -0800, Sean Christopherson wrote: [...] > @@ -1333,6 +1369,7 @@ int kvm_clear_dirty_log_protect(struct kvm *kvm, > unsigned long i, n; > unsigned long *dirty_bitmap; > unsigned long *dirty_bitmap_buffer; > + bool flush; > > as_id =

Re: [PATCH v5 15/19] KVM: Provide common implementation for generic dirty log functions

2020-02-06 Thread Sean Christopherson
On Thu, Feb 06, 2020 at 03:02:00PM -0500, Peter Xu wrote: > On Tue, Jan 21, 2020 at 02:31:53PM -0800, Sean Christopherson wrote: > > [...] > > > -int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm, struct > > kvm_clear_dirty_log *log) > > +void kvm_arch_dirty_log_tlb_flush(struct kvm *kvm, > > +

Re: [PATCH v5 17/19] KVM: Terminate memslot walks via used_slots

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:55PM -0800, Sean Christopherson wrote: > Refactor memslot handling to treat the number of used slots as the de > facto size of the memslot array, e.g. return NULL from id_to_memslot() > when an invalid index is provided instead of relying on npages==0 to > detect an in

Re: [PATCH v5 15/19] KVM: Provide common implementation for generic dirty log functions

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:53PM -0800, Sean Christopherson wrote: [...] > -int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm, struct kvm_clear_dirty_log > *log) > +void kvm_arch_dirty_log_tlb_flush(struct kvm *kvm, > + struct kvm_memory_slot *memslot) If it's to

Re: [PATCH v5 14/19] KVM: Clean up local variable usage in __kvm_set_memory_region()

2020-02-06 Thread Peter Xu
On Thu, Feb 06, 2020 at 11:22:30AM -0800, Sean Christopherson wrote: > On Thu, Feb 06, 2020 at 02:06:41PM -0500, Peter Xu wrote: > > On Tue, Jan 21, 2020 at 02:31:52PM -0800, Sean Christopherson wrote: > > > > [...] > > > > > @@ -1101,52 +1099,55 @@ int __kvm_set_memory_region(struct kvm *kvm, >

Re: [PATCH v5 14/19] KVM: Clean up local variable usage in __kvm_set_memory_region()

2020-02-06 Thread Sean Christopherson
On Thu, Feb 06, 2020 at 02:06:41PM -0500, Peter Xu wrote: > On Tue, Jan 21, 2020 at 02:31:52PM -0800, Sean Christopherson wrote: > > [...] > > > @@ -1101,52 +1099,55 @@ int __kvm_set_memory_region(struct kvm *kvm, > > if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr) > >

Re: [PATCH v5 14/19] KVM: Clean up local variable usage in __kvm_set_memory_region()

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:52PM -0800, Sean Christopherson wrote: [...] > @@ -1101,52 +1099,55 @@ int __kvm_set_memory_region(struct kvm *kvm, > if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr) > return -EINVAL; > > - slot = id_to_memslot(__kvm_mems

Re: [PATCH kvmtool] Add emulation for CFI compatible flash memory

2020-02-06 Thread Andre Przywara
On Thu, 6 Feb 2020 14:42:11 + Andre Przywara wrote: Hi, > On Wed, 5 Feb 2020 17:11:57 + > Will Deacon wrote: > > Hi Will, > > many thanks for having a look! > > > On Wed, Jan 08, 2020 at 06:32:12PM +, Andre Przywara wrote: > > > From: Raphael Gault [ ... ] > > > +/* We only

Re: [PATCH v5 12/19] KVM: Move memslot deletion to helper function

2020-02-06 Thread Peter Xu
On Thu, Feb 06, 2020 at 08:28:18AM -0800, Sean Christopherson wrote: > On Thu, Feb 06, 2020 at 11:14:15AM -0500, Peter Xu wrote: > > On Tue, Jan 21, 2020 at 02:31:50PM -0800, Sean Christopherson wrote: > > > Move memslot deletion into its own routine so that the success path for > > > other memslot

Re: [PATCH v5 13/19] KVM: Simplify kvm_free_memslot() and all its descendents

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:51PM -0800, Sean Christopherson wrote: > Now that all callers of kvm_free_memslot() pass NULL for @dont, remove > the param from the top-level routine and all arch's implementations. > > No functional change intended. > > Tested-by: Christoffer Dall > Signed-off-by:

Re: [PATCH v5 12/19] KVM: Move memslot deletion to helper function

2020-02-06 Thread Sean Christopherson
On Thu, Feb 06, 2020 at 11:14:15AM -0500, Peter Xu wrote: > On Tue, Jan 21, 2020 at 02:31:50PM -0800, Sean Christopherson wrote: > > Move memslot deletion into its own routine so that the success path for > > other memslot updates does not need to use kvm_free_memslot(), i.e. can > > explicitly des

Re: [PATCH v5 10/19] KVM: Drop "const" attribute from old memslot in commit_memory_region()

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:48PM -0800, Sean Christopherson wrote: > Drop the "const" attribute from @old in kvm_arch_commit_memory_region() > to allow arch specific code to free arch specific resources in the old > memslot without having to cast away the attribute. Freeing resources in > kvm_ar

Re: [PATCH v5 09/19] KVM: Move setting of memslot into helper routine

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:47PM -0800, Sean Christopherson wrote: > Split out the core functionality of setting a memslot into a separate > helper in preparation for moving memslot deletion into its own routine. > > Tested-by: Christoffer Dall > Reviewed-by: Philippe Mathieu-Daudé > Signed-of

Re: [PATCH v5 12/19] KVM: Move memslot deletion to helper function

2020-02-06 Thread Peter Xu
On Tue, Jan 21, 2020 at 02:31:50PM -0800, Sean Christopherson wrote: > Move memslot deletion into its own routine so that the success path for > other memslot updates does not need to use kvm_free_memslot(), i.e. can > explicitly destroy the dirty bitmap when necessary. This paves the way > for dr

Re: [kvm-unit-tests PATCH v3 05/14] arm/arm64: ITS: Introspection tests

2020-02-06 Thread Zenghui Yu
Hi Eric, On 2020/1/28 18:34, Eric Auger wrote: Detect the presence of an ITS as part of the GICv3 init routine, initialize its base address and read few registers the IIDR, the TYPER to store its dimensioning parameters. Also parse the BASER registers. This is our first ITS test, belonging to a

Re: [PATCH kvmtool] Add emulation for CFI compatible flash memory

2020-02-06 Thread Andre Przywara
On Wed, 5 Feb 2020 17:11:57 + Will Deacon wrote: Hi Will, many thanks for having a look! > On Wed, Jan 08, 2020 at 06:32:12PM +, Andre Przywara wrote: > > From: Raphael Gault > > > > The EDK II UEFI firmware implementation requires some storage for the EFI > > variables, which is typi

Re: [kvm-unit-tests PATCH v3 04/14] arm/arm64: gicv3: Add some re-distributor defines

2020-02-06 Thread Zenghui Yu
Hi Eric, On 2020/1/28 18:34, Eric Auger wrote: PROPBASER, PENDBASE and GICR_CTRL will be used for LPI management. Signed-off-by: Eric Auger --- lib/arm/asm/gic-v3.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/lib/arm/asm/gic-v3.h b/lib/arm/asm/gic-v3.h index 6beeab6..ffb2e26 1