[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 1/2] xen/arm: address violations of Rule 11.3
Hi Nicola, > On 24 Jun 2025, at 02:20, victorm.lira@xxxxxxx wrote: > > From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> > > Use {get,put}_unaligned_t to ensure that reads and writes are > safe to perform even on potentially misaligned pointers. > Make sense as we convert a void* to uint32_t * so might be misaligned. > Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> > Signed-off-by: Victor Lira <victorm.lira@xxxxxxx> Acked-by: Bertrand Marquis <bertrand.marquis@xxxxxxx> Cheers Bertrand > --- > Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> > Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx> > Cc: Michal Orzel <michal.orzel@xxxxxxx> > Cc: Jan Beulich <jbeulich@xxxxxxxx> > Cc: Julien Grall <julien@xxxxxxx> > Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx> > Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> > Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> > Cc: Federico Serafini <federico.serafini@xxxxxxxxxxx> > Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx> > --- > xen/arch/arm/efi/efi-boot.h | 9 +++++---- > xen/common/device-tree/bootfdt.c | 3 ++- > 2 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h > index ee80560e13..12dbb6961f 100644 > --- a/xen/arch/arm/efi/efi-boot.h > +++ b/xen/arch/arm/efi/efi-boot.h > @@ -9,6 +9,7 @@ > > #include <xen/device_tree.h> > #include <xen/libfdt/libfdt.h> > +#include <xen/unaligned.h> > #include <asm/setup.h> > #include <asm/smp.h> > > @@ -85,7 +86,7 @@ static int __init setup_chosen_node(void *fdt, int > *addr_cells, int *size_cells) > *addr_cells = 2; > } > else > - *addr_cells = fdt32_to_cpu(*((uint32_t *)prop->data)); > + *addr_cells = fdt32_to_cpu(get_unaligned_t(uint32_t, prop->data)); > > prop = fdt_get_property(fdt, node, "#size-cells", &len); > if ( !prop ) > @@ -96,7 +97,7 @@ static int __init setup_chosen_node(void *fdt, int > *addr_cells, int *size_cells) > *size_cells = 2; > } > else > - *size_cells = fdt32_to_cpu(*((uint32_t *)prop->data)); > + *size_cells = fdt32_to_cpu(get_unaligned_t(uint32_t, prop->data)); > > /* > * Make sure ranges is empty if it exists, otherwise create empty ranges > @@ -824,7 +825,7 @@ static int __init handle_dom0less_domain_node(const > EFI_LOADED_IMAGE *loaded_ima > return ERROR_MISSING_DT_PROPERTY; > } > > - addr_cells = fdt32_to_cpu(*((uint32_t *)prop->data)); > + addr_cells = fdt32_to_cpu(get_unaligned_t(uint32_t, prop->data)); > > prop = fdt_get_property(fdt_efi, domain_node, "#size-cells", &len); > if ( !prop ) > @@ -833,7 +834,7 @@ static int __init handle_dom0less_domain_node(const > EFI_LOADED_IMAGE *loaded_ima > return ERROR_MISSING_DT_PROPERTY; > } > > - size_cells = fdt32_to_cpu(*((uint32_t *)prop->data)); > + size_cells = fdt32_to_cpu(get_unaligned_t(uint32_t, prop->data)); > > /* Check for nodes compatible with multiboot,module inside this node */ > for ( module_node = fdt_first_subnode(fdt_efi, domain_node); > diff --git a/xen/common/device-tree/bootfdt.c > b/xen/common/device-tree/bootfdt.c > index 529c91e603..9f255027ea 100644 > --- a/xen/common/device-tree/bootfdt.c > +++ b/xen/common/device-tree/bootfdt.c > @@ -13,6 +13,7 @@ > #include <xen/lib.h> > #include <xen/libfdt/libfdt-xen.h> > #include <xen/sort.h> > +#include <xen/unaligned.h> > #include <xsm/xsm.h> > #include <asm/setup.h> > #ifdef CONFIG_STATIC_SHM > @@ -213,7 +214,7 @@ u32 __init device_tree_get_u32(const void *fdt, int node, > if ( !prop || prop->len < sizeof(u32) ) > return dflt; > > - return fdt32_to_cpu(*(uint32_t*)prop->data); > + return fdt32_to_cpu(get_unaligned_t(uint32_t, prop->data)); > } > > /** > -- > 2.25.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |