On Thu, 25 Mar 2021 at 20:18, Juan Quintela <quint...@redhat.com> wrote: > > Haibo Xu <haibo...@linaro.org> wrote: > > MTE spec provide instructions to retrieve the memory tags: > > (1) LDG, at 16 bytes granularity, and available in both user > > and kernel space; > > (2) LDGM, at 256 bytes granularity in maximum, and only > > available in kernel space > > > > To improve the performance, KVM has exposed the LDGM capability > > to user space by providing a new APIs. This patch is just a > > wrapper for the KVM APIs. > > > > Signed-off-by: Haibo Xu <haibo...@linaro.org> > > --- > > target/arm/kvm64.c | 24 ++++++++++++++++++++++++ > > target/arm/kvm_arm.h | 2 ++ > > 2 files changed, 26 insertions(+) > > > > diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c > > index 73a191f8e1..3157025316 100644 > > --- a/target/arm/kvm64.c > > +++ b/target/arm/kvm64.c > > @@ -1606,3 +1606,27 @@ bool kvm_arm_verify_ext_dabt_pending(CPUState *cs) > > } > > return false; > > } > > + > > +int kvm_arm_mte_get_tags(uint64_t ipa, uint64_t len, uint8_t *buf) > > +{ > > + struct kvm_arm_copy_mte_tags args = { > > + .guest_ipa = ipa, > > + .length = len, > > + .addr = buf, > > + .flags = KVM_ARM_TAGS_FROM_GUEST, > > + }; > > + > > + return kvm_vm_ioctl(kvm_state, KVM_ARM_MTE_COPY_TAGS, &args); > > Just a question, how fast/slow are this calls? >
There is no performance data for this API yet, but at least it's more efficient than that to only be able to access a single tag by the EL0 "LDG" instruction. We will try to collect some performance data for this KVM API later. > My understanding is that we are making a kvm call for each page that we > want to migrate, right? > Yes, currently I chose to append the tag values to the page data during the migration. > Each time that we want to send it. > > Later, Juan. > > > > +} > > + > > +int kvm_arm_mte_set_tags(uint64_t ipa, uint64_t len, uint8_t *buf) > > +{ > > + struct kvm_arm_copy_mte_tags args = { > > + .guest_ipa = ipa, > > + .length = len, > > + .addr = buf, > > + .flags = KVM_ARM_TAGS_TO_GUEST, > > + }; > > + > > + return kvm_vm_ioctl(kvm_state, KVM_ARM_MTE_COPY_TAGS, &args); > > +} > > diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h > > index 34f8daa377..bbb833d6c6 100644 > > --- a/target/arm/kvm_arm.h > > +++ b/target/arm/kvm_arm.h > > @@ -360,6 +360,8 @@ int kvm_arm_vgic_probe(void); > > > > void kvm_arm_pmu_set_irq(CPUState *cs, int irq); > > void kvm_arm_pmu_init(CPUState *cs); > > +int kvm_arm_mte_get_tags(uint64_t ipa, uint64_t len, uint8_t *buf); > > +int kvm_arm_mte_set_tags(uint64_t ipa, uint64_t len, uint8_t *buf); > > > > /** > > * kvm_arm_pvtime_init: >