Skip to contentSkip to conversation

tools/libxl: Fix build following c/s 74fd984ae

PATCH In review Andrew Cooper 4 participants 9 messages Apr 5, 2018 – Apr 9, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/libxl: Fix build following c/s 74fd984ae

c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from libxl__domain_build_state" removed state->config completely, but the GIC version is available in info. Use the up-to-date version.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Juergen Gross <[email protected]>

Completely untested. I don't even have a compile environment to hand, which is how this got missed before. Sorry.

---
 tools/libxl/libxl_arm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/libxl/libxl_arm.c +2 -4
index fbe8786..177c6b7 100644
@@ -846,9 +846,6 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
     const libxl_version_info *vers;
     const struct arch_info *ainfo;
 
-    /* convenience aliases */
-    xc_domain_configuration_t *xc_config = &state->config;
-
     vers = libxl_get_version_info(CTX);
     if (vers == NULL) return ERROR_FAIL;
 
@@ -857,7 +854,8 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
 
     LOG(DEBUG, "constructing DTB for Xen version %d.%d guest",
         vers->xen_version_major, vers->xen_version_minor);
-    LOG(DEBUG, " - vGIC version: %s", gicv_to_string(xc_config->gic_version));
+    LOG(DEBUG, " - vGIC version: %s",
+        gicv_to_string(info->arch_arm.gic_version));
 
     if (info->device_tree) {
         LOG(DEBUG, " - Partial device tree provided: %s", info->device_tree);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Andrew Cooper

c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from libxl__domain_build_state" removed state->config completely, but the GIC version is available in info. Use the up-to-date version.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Juergen Gross <[email protected]>

Quoted 2 lines

Completely untested. I don't even have a compile environment to hand, which is how this got missed before. Sorry.

Looks correct to me:

Quoted 31 lines
---
 tools/libxl/libxl_arm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/libxl/libxl_arm.c +2 -4
index fbe8786..177c6b7 100644
@@ -846,9 +846,6 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
     const libxl_version_info *vers;
     const struct arch_info *ainfo;
 
-    /* convenience aliases */
-    xc_domain_configuration_t *xc_config = &state->config;
-
     vers = libxl_get_version_info(CTX);
     if (vers == NULL) return ERROR_FAIL;
 
@@ -857,7 +854,8 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
 
     LOG(DEBUG, "constructing DTB for Xen version %d.%d guest",
         vers->xen_version_major, vers->xen_version_minor);
-    LOG(DEBUG, " - vGIC version: %s", gicv_to_string(xc_config->gic_version));
+    LOG(DEBUG, " - vGIC version: %s",
+        gicv_to_string(info->arch_arm.gic_version));
 
     if (info->device_tree) {
         LOG(DEBUG, " - Partial device tree provided: %s", info->device_tree);
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 13 lines · Wei Liu
Quoted 12 lines · Andrew Cooper

c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from libxl__domain_build_state" removed state->config completely, but the GIC version is available in info. Use the up-to-date version.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Juergen Gross <[email protected]>

Quoted 6 lines
Quoted 2 lines

Completely untested. I don't even have a compile environment to hand, which is how this got missed before. Sorry.

Looks correct to me:

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Wei Liu

Hi,

Quoted 13 lines · Wei Liu
Quoted 12 lines · Andrew Cooper

c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from libxl__domain_build_state" removed state->config completely, but the GIC version is available in info. Use the up-to-date version.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Juergen Gross <[email protected]>

Quoted 6 lines
Quoted 2 lines

Completely untested. I don't even have a compile environment to hand, which is how this got missed before. Sorry.

Looks correct to me:

Sadly libxl still does not compile on ARM:

libxl_arm.c: In function 'libxl__prepare_dtb':
libxl_arm.c:923:17: error: 'xc_config' undeclared (first use in this function); did you mean 'yajl_config'?

         switch (xc_config->gic_version) {
                 ^~~~~~~~~
                 yajl_config

libxl_arm.c:923:17: note: each undeclared identifier is reported only once for each function it appears in

Quoted 19 lines
Quoted 19 lines
---
  tools/libxl/libxl_arm.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
tools/libxl/libxl_arm.c +0 -3
index fbe8786..177c6b7 100644
@@ -846,9 +846,6 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
      const libxl_version_info *vers;
      const struct arch_info *ainfo;
 
-    /* convenience aliases */
-    xc_domain_configuration_t *xc_config = &state->config;
-
      vers = libxl_get_version_info(CTX);
      if (vers == NULL) return ERROR_FAIL;
 
Quoted 7 lines

tools/libxl/libxl_arm.c static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info, · line 858

Quoted 7 lines
tools/libxl/libxl_arm.c +2 -1
@@ -857,7 +854,8 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
 
      LOG(DEBUG, "constructing DTB for Xen version %d.%d guest",
          vers->xen_version_major, vers->xen_version_minor);
-    LOG(DEBUG, " - vGIC version: %s", gicv_to_string(xc_config->gic_version));
+    LOG(DEBUG, " - vGIC version: %s",
+        gicv_to_string(info->arch_arm.gic_version));

This is wrong. gicv_to_string works on XEN_DOMCTL_* define and not the LIBXL_GIC_*. So this will not give the right output.

I would suggest to revert that patch and I will send one that actually fix the compilation. Not sure I would be able to do it today thought.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#4 lore raw
Quoted 62 lines · Julien Grall

Hi,

Quoted 13 lines · Wei Liu
Quoted 12 lines · Andrew Cooper

c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from libxl__domain_build_state" removed state->config completely, but the GIC version is available in info. Use the up-to-date version.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Juergen Gross <[email protected]>

Quoted 6 lines
Quoted 2 lines

Completely untested. I don't even have a compile environment to hand, which is how this got missed before. Sorry.

Looks correct to me:

Sadly libxl still does not compile on ARM:

libxl_arm.c: In function 'libxl__prepare_dtb':
libxl_arm.c:923:17: error: 'xc_config' undeclared (first use in this function); did you mean 'yajl_config'?

         switch (xc_config->gic_version) {
                 ^~~~~~~~~
                 yajl_config

libxl_arm.c:923:17: note: each undeclared identifier is reported only once for each function it appears in

Quoted 19 lines
Quoted 19 lines
---
  tools/libxl/libxl_arm.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
tools/libxl/libxl_arm.c +0 -3
index fbe8786..177c6b7 100644
@@ -846,9 +846,6 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
      const libxl_version_info *vers;
      const struct arch_info *ainfo;
 
-    /* convenience aliases */
-    xc_domain_configuration_t *xc_config = &state->config;
-
      vers = libxl_get_version_info(CTX);
      if (vers == NULL) return ERROR_FAIL;
 
Quoted 7 lines

tools/libxl/libxl_arm.c static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info, · line 858

Quoted 7 lines
tools/libxl/libxl_arm.c +2 -1
@@ -857,7 +854,8 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
 
      LOG(DEBUG, "constructing DTB for Xen version %d.%d guest",
          vers->xen_version_major, vers->xen_version_minor);
-    LOG(DEBUG, " - vGIC version: %s", gicv_to_string(xc_config->gic_version));
+    LOG(DEBUG, " - vGIC version: %s",
+        gicv_to_string(info->arch_arm.gic_version));

This is wrong. gicv_to_string works on XEN_DOMCTL_* define and not the LIBXL_GIC_*. So this will not give the right output.

Quoted 2 lines

I would suggest to revert that patch and I will send one that actually fix the compilation. Not sure I would be able to do it today thought.

Fine with me.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
In reply to Julien Grall
Quoted 6 lines · Julien Grall

This is wrong. gicv_to_string works on XEN_DOMCTL_* define and not the LIBXL_GIC_*. So this will not give the right output.

I would suggest to revert that patch and I will send one that actually fix the compilation. Not sure I would be able to do it today thought.

OK, I will revert this patch.

Quoted 4 lines

Cheers,

Signature · 1 line
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw

Hi,

Quoted 9 lines · Wei Liu
Quoted 6 lines · Julien Grall

This is wrong. gicv_to_string works on XEN_DOMCTL_* define and not the LIBXL_GIC_*. So this will not give the right output.

I would suggest to revert that patch and I will send one that actually fix the compilation. Not sure I would be able to do it today thought.

OK, I will revert this patch.

I have looked at a potential way to fix it. The original patch (74fd984ae6) assumption is incorrect. Some of information from xc_domain_configuration_t is not written back ton libxl__domain_build_state.

For instance, this is the case of the clock frequency. That field is used to workaround bootloader/firmware that didn't configure correct CNTFRQ. If we detect such platform, we will read the host clock frequency from the host Device-Tree and write it to the guest Device-Tree. This should never be exposed to the guest.

Arguably, this field should not belong to xc_domain_configuration_t. So I can see two solutions:
1) Store the frequency in libxl__domain_build_state
2) Introduce a different hypercall to get the system frequency. I guess
we could piggy-back on Andrew's idea to provide XEN_DOMCTL_{get,set}_arch_settings.

The latter will require some rework in the code and define a new API. Not sure if that would be acceptable for Xen 4.11.

Any opinions?

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#7 lore raw
Quoted 17 lines · Julien Grall

Hi,

Quoted 9 lines · Wei Liu
Quoted 6 lines · Julien Grall

This is wrong. gicv_to_string works on XEN_DOMCTL_* define and not the LIBXL_GIC_*. So this will not give the right output.

I would suggest to revert that patch and I will send one that actually fix the compilation. Not sure I would be able to do it today thought.

OK, I will revert this patch.

I have looked at a potential way to fix it. The original patch (74fd984ae6) assumption is incorrect. Some of information from xc_domain_configuration_t is not written back ton libxl__domain_build_state.

Quoted 5 lines

For instance, this is the case of the clock frequency. That field is used to workaround bootloader/firmware that didn't configure correct CNTFRQ. If we detect such platform, we will read the host clock frequency from the host Device-Tree and write it to the guest Device-Tree. This should never be exposed to the guest.

Not sure I follow. If you write that value to guest DT, guest should be able to see it?

Quoted 8 lines

Arguably, this field should not belong to xc_domain_configuration_t. So I can see two solutions:
1) Store the frequency in libxl__domain_build_state
2) Introduce a different hypercall to get the system frequency. I guess we
could piggy-back on Andrew's idea to provide XEN_DOMCTL_{get,set}_arch_settings.

Quoted 4 lines

The latter will require some rework in the code and define a new API. Not sure if that would be acceptable for Xen 4.11.

Any opinions?

#1 seems simpler to me, especially since we already have vuart (ARM only) information in libxl__domain_build_state.

Wei.

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw

Hi,

Quoted 18 lines · Wei Liu
Quoted 17 lines · Julien Grall

Hi,

Quoted 9 lines · Wei Liu
Quoted 6 lines · Julien Grall

This is wrong. gicv_to_string works on XEN_DOMCTL_* define and not the LIBXL_GIC_*. So this will not give the right output.

I would suggest to revert that patch and I will send one that actually fix the compilation. Not sure I would be able to do it today thought.

OK, I will revert this patch.

I have looked at a potential way to fix it. The original patch (74fd984ae6) assumption is incorrect. Some of information from xc_domain_configuration_t is not written back ton libxl__domain_build_state.

Quoted 8 lines
Quoted 5 lines

For instance, this is the case of the clock frequency. That field is used to workaround bootloader/firmware that didn't configure correct CNTFRQ. If we detect such platform, we will read the host clock frequency from the host Device-Tree and write it to the guest Device-Tree. This should never be exposed to the guest.

Not sure I follow. If you write that value to guest DT, guest should be able to see it?

On normal system the clock frequency can be read by using the system register CNTFRQ. This register is usually initialized by the firmware/bootloader. However, on some platforms the firmware does not do its job and therefore CNTFRQ is configured incorrectly. To workaround the problem, a property exists in the host DT with the correct frequency.

On the broken platform, the field clock_frequency in xc_domain_configuration_t will be written by the hypervisor with the correct frequency.

Quoted 9 lines
Quoted 9 lines

Arguably, this field should not belong to xc_domain_configuration_t. So I can see two solutions:
1) Store the frequency in libxl__domain_build_state
2) Introduce a different hypercall to get the system frequency. I guess we
could piggy-back on Andrew's idea to provide XEN_DOMCTL_{get,set}_arch_settings.

Quoted 7 lines
Quoted 4 lines

The latter will require some rework in the code and define a new API. Not sure if that would be acceptable for Xen 4.11.

Any opinions?

#1 seems simpler to me, especially since we already have vuart (ARM only) information in libxl__domain_build_state.

I will have a look at that.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel