diff mbox series

[RFC,v2,5/5] Enable the MTE support for KVM guest

Message ID 5ed81ba84e44100798009cee95c3dc2d993602f0.1615972140.git.haibo.xu@linaro.org
State New
Headers show
Series target/arm: Add MTE support to KVM guest | expand

Commit Message

Haibo Xu March 17, 2021, 9:28 a.m. UTC
Signed-off-by: Haibo Xu <haibo.xu@linaro.org>

---
 hw/arm/virt.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

-- 
2.17.1

Comments

Juan Quintela March 25, 2021, 12:40 p.m. UTC | #1
Haibo Xu <haibo.xu@linaro.org> wrote:
> Signed-off-by: Haibo Xu <haibo.xu@linaro.org>

> ---

>  hw/arm/virt.c | 22 +++++++++++++++++++---

>  1 file changed, 19 insertions(+), 3 deletions(-)

>

> diff --git a/hw/arm/virt.c b/hw/arm/virt.c

> index 76658b93a3..36cfdb29e9 100644

> --- a/hw/arm/virt.c

> +++ b/hw/arm/virt.c

> @@ -79,6 +79,7 @@

>  #include "hw/virtio/virtio-iommu.h"

>  #include "hw/char/pl011.h"

>  #include "qemu/guest-random.h"

> +#include "migration/misc.h"

>  

>  #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \

>      static void virt_##major##_##minor##_class_init(ObjectClass *oc, \

> @@ -828,6 +829,21 @@ static void virt_powerdown_req(Notifier *n, void *opaque)

>      }

>  }

>  

> +static int virt_precopy_notify(NotifierWithReturn *n, void *data)

> +{

> +    PrecopyNotifyData *pnd = data;

> +

> +    switch (pnd->reason) {

> +    case PRECOPY_NOTIFY_SETUP:

> +        precopy_enable_metadata_migration();

> +        break;

> +    default:

> +        break;

> +    }

> +

> +    return 0;

> +}

> +

>  static void create_gpio_keys(char *fdt, DeviceState *pl061_dev,

>                               uint32_t phandle)

>  {

> @@ -1912,9 +1928,9 @@ static void machvirt_init(MachineState *machine)

>      }

>  

>      if (vms->mte && kvm_enabled()) {

> -        error_report("mach-virt: KVM does not support providing "

> -                     "MTE to the guest CPU");

> -        exit(1);

> +        /* connect migration precopy request */

> +        vms->precopy_notifier.notify = virt_precopy_notify;

> +        precopy_add_notifier(&vms->precopy_notifier);

>      }

>  

>      create_fdt(vms);


Why are you using a notifier here?
It is not enough for you just esetup at this point a variable somewhere
   "foo->mte_enabled = true"

And create a function that just does:

bool is_mte_enabled(vode)
{
        return foo->mte_enabled;
}

And just check that everywhere?

Later, Juan.
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 76658b93a3..36cfdb29e9 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -79,6 +79,7 @@ 
 #include "hw/virtio/virtio-iommu.h"
 #include "hw/char/pl011.h"
 #include "qemu/guest-random.h"
+#include "migration/misc.h"
 
 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
     static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
@@ -828,6 +829,21 @@  static void virt_powerdown_req(Notifier *n, void *opaque)
     }
 }
 
+static int virt_precopy_notify(NotifierWithReturn *n, void *data)
+{
+    PrecopyNotifyData *pnd = data;
+
+    switch (pnd->reason) {
+    case PRECOPY_NOTIFY_SETUP:
+        precopy_enable_metadata_migration();
+        break;
+    default:
+        break;
+    }
+
+    return 0;
+}
+
 static void create_gpio_keys(char *fdt, DeviceState *pl061_dev,
                              uint32_t phandle)
 {
@@ -1912,9 +1928,9 @@  static void machvirt_init(MachineState *machine)
     }
 
     if (vms->mte && kvm_enabled()) {
-        error_report("mach-virt: KVM does not support providing "
-                     "MTE to the guest CPU");
-        exit(1);
+        /* connect migration precopy request */
+        vms->precopy_notifier.notify = virt_precopy_notify;
+        precopy_add_notifier(&vms->precopy_notifier);
     }
 
     create_fdt(vms);