arch/loongarch/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ARCH_STRICT_ALIGN is used for hardware without UAL, now it only control
the -mstrict-align flag. However, ACPI structures are packed by default
so will cause unaligned accesses.
To avoid this, define ACPI_MISALIGNMENT_NOT_SUPPORTED in Makefile to
align ACPI structures if ARCH_STRICT_ALIGN enabled.
Reported-by: Binbin Zhou <zhoubinbin@loongson.cn>
Suggested-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
arch/loongarch/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index a3a9759414f4..a86de4f26264 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -147,10 +147,10 @@ ifdef CONFIG_ARCH_STRICT_ALIGN
# Don't emit unaligned accesses.
# Not all LoongArch cores support unaligned access, and as kernel we can't
# rely on others to provide emulation for these accesses.
-KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
+KBUILD_CFLAGS += $(call cc-option,-mstrict-align) -DACPI_MISALIGNMENT_NOT_SUPPORTED
else
# Optimise for performance on hardware supports unaligned access.
-KBUILD_CFLAGS += $(call cc-option,-mno-strict-align)
+KBUILD_CFLAGS += $(call cc-option,-mno-strict-align) -UACPI_MISALIGNMENT_NOT_SUPPORTED
endif
KBUILD_CFLAGS += -isystem $(shell $(CC) -print-file-name=include)
--
2.47.3
在2025年9月9日周二 下午5:53,Huacai Chen写道: > ARCH_STRICT_ALIGN is used for hardware without UAL, now it only control > the -mstrict-align flag. However, ACPI structures are packed by default > so will cause unaligned accesses. > > To avoid this, define ACPI_MISALIGNMENT_NOT_SUPPORTED in Makefile to > align ACPI structures if ARCH_STRICT_ALIGN enabled. > > Reported-by: Binbin Zhou <zhoubinbin@loongson.cn> > Suggested-by: Xi Ruoyao <xry111@xry111.site> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > --- > arch/loongarch/Makefile | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > index a3a9759414f4..a86de4f26264 100644 > --- a/arch/loongarch/Makefile > +++ b/arch/loongarch/Makefile > @@ -147,10 +147,10 @@ ifdef CONFIG_ARCH_STRICT_ALIGN > # Don't emit unaligned accesses. > # Not all LoongArch cores support unaligned access, and as kernel we > can't > # rely on others to provide emulation for these accesses. > -KBUILD_CFLAGS += $(call cc-option,-mstrict-align) > +KBUILD_CFLAGS += $(call cc-option,-mstrict-align) > -DACPI_MISALIGNMENT_NOT_SUPPORTED This is a little bit hacky. Maybe a better place for `ACPI_MISALIGNMENT_NOT_SUPPORTED would be `arch/loongarch/include/asm/acenv.h`, or `include/acpi/platform/aclinux.h` > else > # Optimise for performance on hardware supports unaligned access. > -KBUILD_CFLAGS += $(call cc-option,-mno-strict-align) > +KBUILD_CFLAGS += $(call cc-option,-mno-strict-align) > -UACPI_MISALIGNMENT_NOT_SUPPORTED > endif > > KBUILD_CFLAGS += -isystem $(shell $(CC) -print-file-name=include) > -- > 2.47.3 Thanks -- - Jiaxun
© 2016 - 2025 Red Hat, Inc.