Skip to contentSkip to conversation

tools: Fix ifdef for aarch64 that should include also arm

PATCH In review Luca Fancellu 4 participants 11 messages Jun 8, 2023 – Jul 5, 2023 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tools: Fix ifdef for aarch64 that should include also arm

Commit 56a7aaa16bfe introduced some SVE related code that is protected by '#if defined(__aarch64__)', the issue is that this doesn't take into consideration when the toolstack is compiled for an arm32 Dom0 running on an arm64 platform, it should be able to create SVE enabled guests but with the current code it's not.

So fix the issue by compiling the code when the toolstack is compiled for both arm32 and arm64.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")
---
 tools/include/xen-tools/arm-arch-capabilities.h | 2 +-
 tools/python/xen/lowlevel/xc/xc.c               | 2 +-
 tools/xl/xl_info.c                              | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/include/xen-tools/arm-arch-capabilities.h +1 -1
index 3849e897925d..4aa4c6c34a99 100644
@@ -14,7 +14,7 @@
 static inline
 unsigned int arch_capabilities_arm_sve(unsigned int arch_capabilities)
 {
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
     unsigned int sve_vl = MASK_EXTR(arch_capabilities,
                                     XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK);
 
tools/python/xen/lowlevel/xc/xc.c +1 -1
index 491e88977fd3..e14e223ec903 100644
@@ -911,7 +911,7 @@ static PyObject *pyxc_physinfo(XcObject *self)
                            "hw_caps",          cpu_cap,
                            "virt_caps",        virt_caps);
 
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
     if ( objret ) {
         unsigned int sve_vl_bits;
         PyObject *py_arm_sve_vl;
tools/xl/xl_info.c +1 -1
index ddc42f96b979..72e87eac46d1 100644
@@ -226,7 +226,7 @@ static void output_physinfo(void)
         );
 
     /* Print arm SVE vector length only on ARM platforms */
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
     maybe_printf("arm_sve_vector_length  : %u\n",
          arch_capabilities_arm_sve(info.arch_capabilities)
         );
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 tools/python: Fix memory leak on error path

Commit 56a7aaa16bfe introduced a memory leak on the error path for a Py_BuildValue built object that on some newly introduced error path has not the correct reference count handling, fix that by decrementing the refcount in these path.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")
---
 tools/python/xen/lowlevel/xc/xc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/python/xen/lowlevel/xc/xc.c +7 -2
index e14e223ec903..d3ea350e07b9 100644
@@ -919,11 +919,16 @@ static PyObject *pyxc_physinfo(XcObject *self)
         sve_vl_bits = arch_capabilities_arm_sve(pinfo.arch_capabilities);
         py_arm_sve_vl = PyLong_FromUnsignedLong(sve_vl_bits);
 
-        if ( !py_arm_sve_vl )
+        if ( !py_arm_sve_vl ) {
+            Py_DECREF(objret);
             return NULL;
+        }
 
-        if( PyDict_SetItemString(objret, "arm_sve_vl", py_arm_sve_vl) )
+        if( PyDict_SetItemString(objret, "arm_sve_vl", py_arm_sve_vl) ) {
+            Py_DECREF(py_arm_sve_vl);
+            Py_DECREF(objret);
             return NULL;
+        }
     }
 #endif
 
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/2] tools/python: Fix memory leak on error path

Quoted 9 lines · Luca Fancellu

Commit 56a7aaa16bfe introduced a memory leak on the error path for a Py_BuildValue built object that on some newly introduced error path has not the correct reference count handling, fix that by decrementing the refcount in these path.

Quoted 4 lines
Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")

---

Hi all,

Is there any chance to have this one reviewed by the end of the month? I’m asking because I have a Jira task attached to this patch and my PM is chasing me :)

If it’s not possible it’s fine either and I’ll have just to report that.

Cheers,
Luca

Quoted 30 lines

tools/python/xen/lowlevel/xc/xc.c | 9 +++++++--

1 file changed, 7 insertions(+), 2 deletions(-)
tools/python/xen/lowlevel/xc/xc.c +7 -2
index e14e223ec903..d3ea350e07b9 100644
@@ -919,11 +919,16 @@ static PyObject *pyxc_physinfo(XcObject *self)
        sve_vl_bits = arch_capabilities_arm_sve(pinfo.arch_capabilities);
        py_arm_sve_vl = PyLong_FromUnsignedLong(sve_vl_bits);
 
-        if ( !py_arm_sve_vl )
+        if ( !py_arm_sve_vl ) {
+            Py_DECREF(objret);
            return NULL;
+        }
 
-        if( PyDict_SetItemString(objret, "arm_sve_vl", py_arm_sve_vl) )
+        if( PyDict_SetItemString(objret, "arm_sve_vl", py_arm_sve_vl) ) {
+            Py_DECREF(py_arm_sve_vl);
+            Py_DECREF(objret);
            return NULL;
+        }
    }
 #endif
 
Signature · 1 line
2.34.1
Acked-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] tools/python: Fix memory leak on error path

In reply to Luca Fancellu
Quoted 8 lines · Luca Fancellu

Commit 56a7aaa16bfe introduced a memory leak on the error path for a Py_BuildValue built object that on some newly introduced error path has not the correct reference count handling, fix that by decrementing the refcount in these path.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")
Quoted 30 lines
---
 tools/python/xen/lowlevel/xc/xc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/python/xen/lowlevel/xc/xc.c +7 -2
index e14e223ec903..d3ea350e07b9 100644
@@ -919,11 +919,16 @@ static PyObject *pyxc_physinfo(XcObject *self)
         sve_vl_bits = arch_capabilities_arm_sve(pinfo.arch_capabilities);
         py_arm_sve_vl = PyLong_FromUnsignedLong(sve_vl_bits);
 
-        if ( !py_arm_sve_vl )
+        if ( !py_arm_sve_vl ) {
+            Py_DECREF(objret);
             return NULL;
+        }
 
-        if( PyDict_SetItemString(objret, "arm_sve_vl", py_arm_sve_vl) )
+        if( PyDict_SetItemString(objret, "arm_sve_vl", py_arm_sve_vl) ) {
+            Py_DECREF(py_arm_sve_vl);
+            Py_DECREF(objret);
             return NULL;
+        }
     }
 #endif
 
Signature · 1 line
2.34.1
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#4 lore raw

Re: [PATCH 2/2] tools/python: Fix memory leak on error path

Quoted 11 lines · Marek Marczykowski-Górecki
Quoted 8 lines · Luca Fancellu

Commit 56a7aaa16bfe introduced a memory leak on the error path for a Py_BuildValue built object that on some newly introduced error path has not the correct reference count handling, fix that by decrementing the refcount in these path.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")

Oh, and BTW, in relation to the discussion on the summit about committing process, the buggy version was committed without my ack, after waiting for my review for about two weeks.

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#5 lore raw

Re: [PATCH 2/2] tools/python: Fix memory leak on error path

Hi Marek,

Quoted 11 lines · Marek Marczykowski-Górecki
Quoted 10 lines · Marek Marczykowski-Górecki
Quoted 8 lines · Luca Fancellu

Commit 56a7aaa16bfe introduced a memory leak on the error path for a Py_BuildValue built object that on some newly introduced error path has not the correct reference count handling, fix that by decrementing the refcount in these path.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")
Quoted 5 lines
Quoted 1 line

Oh, and BTW, in relation to the discussion on the summit about committing process, the buggy version was committed without my ack, after waiting for my review for about two weeks.

I was the committer for the series. In this case, this was not a case of committing because I thought the patch was uncontroversial. Instead, this was a lack of my side to properly check the acks on the patch. Sorry for that.

In general, as I mentioned during the design session, I don't commit with missing acks without explicitly saying so on the mailing list and this is often after consulting with others on IRC.

On a similar topic. So far, checking the ack is a manual process for me. So this is not entirely an error-free process (in particular for patch requiring multiple maintainers acks). I would love to have a script that could tell me if a patch is fully approved and/or what acks are missing.

Cheers,

Signature · 1 line
Julien Grall
#6 lore raw
In reply to Luca Fancellu
Quoted 10 lines · Luca Fancellu

Commit 56a7aaa16bfe introduced some SVE related code that is protected by '#if defined(__aarch64__)', the issue is that this doesn't take into consideration when the toolstack is compiled for an arm32 Dom0 running on an arm64 platform, it should be able to create SVE enabled guests but with the current code it's not.

Quoted 7 lines

So fix the issue by compiling the code when the toolstack is compiled for both arm32 and arm64.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")

---

Hi all,

Is there any chance to have this one reviewed by the end of the month? I’m asking because I have a Jira task attached to this patch and my PM is chasing me :)

If it’s not possible it’s fine either and I’ll have just to report that.

Cheers,
Luca

Quoted 48 lines
tools/include/xen-tools/arm-arch-capabilities.h | 2 +-
tools/python/xen/lowlevel/xc/xc.c               | 2 +-
tools/xl/xl_info.c                              | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
tools/include/xen-tools/arm-arch-capabilities.h +0 -0
index 3849e897925d..4aa4c6c34a99 100644
@@ -14,7 +14,7 @@

static inline
unsigned int arch_capabilities_arm_sve(unsigned int arch_capabilities) {

tools/include/xen-tools/arm-arch-capabilities.h +1 -1
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
    unsigned int sve_vl = MASK_EXTR(arch_capabilities,
                                    XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK);
tools/python/xen/lowlevel/xc/xc.c +1 -1
index 491e88977fd3..e14e223ec903 100644
@@ -911,7 +911,7 @@ static PyObject *pyxc_physinfo(XcObject *self)
                           "hw_caps",          cpu_cap,
                           "virt_caps",        virt_caps);
 
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
    if ( objret ) {
        unsigned int sve_vl_bits;
        PyObject *py_arm_sve_vl;
tools/xl/xl_info.c +1 -1
index ddc42f96b979..72e87eac46d1 100644
@@ -226,7 +226,7 @@ static void output_physinfo(void)
        );
 
    /* Print arm SVE vector length only on ARM platforms */
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
    maybe_printf("arm_sve_vector_length  : %u\n",
         arch_capabilities_arm_sve(info.arch_capabilities)
        );
Signature · 1 line
2.34.1
Acked-by on v1 1/2
#7 lore raw
In reply to Luca Fancellu
Quoted 6 lines · Luca Fancellu

Commit 56a7aaa16bfe introduced some SVE related code that is protected by '#if defined(__aarch64__)', the issue is that this doesn't take into consideration when the toolstack is compiled for an arm32 Dom0 running on an arm64 platform, it should be able to create SVE enabled guests but with the current code it's not.

Quoted 6 lines

So fix the issue by compiling the code when the toolstack is compiled for both arm32 and arm64.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")
Quoted 48 lines
---
 tools/include/xen-tools/arm-arch-capabilities.h | 2 +-
 tools/python/xen/lowlevel/xc/xc.c               | 2 +-
 tools/xl/xl_info.c                              | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/include/xen-tools/arm-arch-capabilities.h +1 -1
index 3849e897925d..4aa4c6c34a99 100644
@@ -14,7 +14,7 @@
 static inline
 unsigned int arch_capabilities_arm_sve(unsigned int arch_capabilities)
 {
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
     unsigned int sve_vl = MASK_EXTR(arch_capabilities,
                                     XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK);
 
tools/python/xen/lowlevel/xc/xc.c +1 -1
index 491e88977fd3..e14e223ec903 100644
@@ -911,7 +911,7 @@ static PyObject *pyxc_physinfo(XcObject *self)
                            "hw_caps",          cpu_cap,
                            "virt_caps",        virt_caps);
 
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
     if ( objret ) {
         unsigned int sve_vl_bits;
         PyObject *py_arm_sve_vl;
tools/xl/xl_info.c +1 -1
index ddc42f96b979..72e87eac46d1 100644
@@ -226,7 +226,7 @@ static void output_physinfo(void)
         );
 
     /* Print arm SVE vector length only on ARM platforms */
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
     maybe_printf("arm_sve_vector_length  : %u\n",
          arch_capabilities_arm_sve(info.arch_capabilities)
         );
Signature · 1 line
2.34.1
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
Acked-by on v1 1/2
#8 lore raw
In reply to Luca Fancellu
Quoted 6 lines · Luca Fancellu

Commit 56a7aaa16bfe introduced some SVE related code that is protected by '#if defined(__aarch64__)', the issue is that this doesn't take into consideration when the toolstack is compiled for an arm32 Dom0 running on an arm64 platform, it should be able to create SVE enabled guests but with the current code it's not.

Quoted 6 lines

So fix the issue by compiling the code when the toolstack is compiled for both arm32 and arm64.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")

Thanks,

Signature · 1 line
Anthony PERARD
#9 lore raw

Hi,

Replying here because there is no cover letter (in the future please add one if you have more than two patches bundled together).

Quoted 7 lines · Anthony PERARD
Quoted 6 lines · Luca Fancellu

Commit 56a7aaa16bfe introduced some SVE related code that is protected by '#if defined(__aarch64__)', the issue is that this doesn't take into consideration when the toolstack is compiled for an arm32 Dom0 running on an arm64 platform, it should be able to create SVE enabled guests but with the current code it's not.

Quoted 8 lines
Quoted 6 lines

So fix the issue by compiling the code when the toolstack is compiled for both arm32 and arm64.

Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")

I have now committed the series.

Cheers,

Signature · 1 line
Julien Grall
#10 lore raw
Quoted 7 lines · Julien Grall

Hi,

Replying here because there is no cover letter (in the future please add one if you have more than two patches bundled together).

Sure I will

Quoted 12 lines · Anthony PERARD
Quoted 10 lines · Luca Fancellu
Quoted 9 lines

Commit 56a7aaa16bfe introduced some SVE related code that is protected by '#if defined(__aarch64__)', the issue is that this doesn't take into consideration when the toolstack is compiled for an arm32 Dom0 running on an arm64 platform, it should be able to create SVE enabled guests but with the current code it's not.

So fix the issue by compiling the code when the toolstack is compiled for both arm32 and arm64.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Fixes 56a7aaa16bfe ("tools: add physinfo arch_capabilities handling for Arm")

I have now committed the series.

Thank you

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall