Skip to contentSkip to conversation

libxl__build_hvm type confusion

DISCUSSION Marek Marczykowski-Górecki 2 participants 3 messages Aug 4, 2018 – Aug 6, 2018

lore
Share & tools
lore
#0 lore raw

Hi,

libxl__domain_build calls libxl__build_hvm for both LIBXL_DOMAIN_TYPE_HVM and LIBXL_DOMAIN_TYPE_PVH, but libxl__build_hvm uses fields from b_info->u.hvm, which looks like invalid thing to do. Should those field be moved out of that union? Additionally I think some asserts in every function using b_info->u would be a good idea.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

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

#1 lore raw
Quoted 6 lines · Marek Marczykowski-Górecki

Hi,

libxl__domain_build calls libxl__build_hvm for both LIBXL_DOMAIN_TYPE_HVM and LIBXL_DOMAIN_TYPE_PVH, but libxl__build_hvm uses fields from b_info->u.hvm, which looks like invalid thing to do. Should those field be moved out of that union?

Depends on the fields and whether they are relevant for PVH or not. Either they are moved out of the HVM struct and shared between PVH and HVM if they are relevant, or it's usage it's fully limited to domain type HVM.

I guess this mostly works because those HVM fields are not aliased to any of the fields of the PVH struct and they are all 0 which happens to be the correct value for PVH.

Quoted 2 lines

Additionally I think some asserts in every function using b_info->u would be a good idea.

Sure, I'm all in for adding more checks!

Thanks, Roger.

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

#2 lore raw
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Marek Marczykowski-Górecki

Hi,

libxl__domain_build calls libxl__build_hvm for both LIBXL_DOMAIN_TYPE_HVM and LIBXL_DOMAIN_TYPE_PVH, but libxl__build_hvm uses fields from b_info->u.hvm, which looks like invalid thing to do. Should those field be moved out of that union?

Quoted 4 lines

Depends on the fields and whether they are relevant for PVH or not. Either they are moved out of the HVM struct and shared between PVH and HVM if they are relevant, or it's usage it's fully limited to domain type HVM.

In this particular case it is about:
- u.hvm.mmio_hole_memkb
- u.hvm.rdm_mem_boundary_memkb

Not sure if those are relevant for PVH

Quoted 3 lines

I guess this mostly works because those HVM fields are not aliased to any of the fields of the PVH struct and they are all 0 which happens to be the correct value for PVH.

Since u.pvh is very small, that's probably the case.

Quoted 6 lines
Quoted 2 lines

Additionally I think some asserts in every function using b_info->u would be a good idea.

Sure, I'm all in for adding more checks!

Thanks, Roger.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

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