mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH V2] LoongArch: Align ACPI structures if ARCH_STRICT_ALIGN enabled
@ 2025-09-10  9:10 Huacai Chen
  2025-09-11  0:59 ` kernel test robot
  2025-09-20 23:48 ` Nathan Chancellor
  0 siblings, 2 replies; 10+ messages in thread
From: Huacai Chen @ 2025-09-10  9:10 UTC (permalink / raw)
  To: Huacai Chen
  Cc: loongarch, Xuefeng Li, Guo Ren, Xuerui Wang, Jiaxun Yang,
	linux-kernel, Huacai Chen, stable, Binbin Zhou, Xi Ruoyao

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 asm/acenv.h to
align ACPI structures if ARCH_STRICT_ALIGN enabled.

Cc: stable@vger.kernel.org
Reported-by: Binbin Zhou <zhoubinbin@loongson.cn>
Suggested-by: Xi Ruoyao <xry111@xry111.site>
Suggested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
V2: Modify asm/acenv.h instead of Makefile.

 arch/loongarch/include/asm/acenv.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/loongarch/include/asm/acenv.h b/arch/loongarch/include/asm/acenv.h
index 52f298f7293b..483c955f2ae5 100644
--- a/arch/loongarch/include/asm/acenv.h
+++ b/arch/loongarch/include/asm/acenv.h
@@ -10,9 +10,8 @@
 #ifndef _ASM_LOONGARCH_ACENV_H
 #define _ASM_LOONGARCH_ACENV_H
 
-/*
- * This header is required by ACPI core, but we have nothing to fill in
- * right now. Will be updated later when needed.
- */
+#ifdef CONFIG_ARCH_STRICT_ALIGN
+#define ACPI_MISALIGNMENT_NOT_SUPPORTED
+#endif /* CONFIG_ARCH_STRICT_ALIGN */
 
 #endif /* _ASM_LOONGARCH_ACENV_H */
-- 
2.47.3


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH V2] LoongArch: Align ACPI structures if ARCH_STRICT_ALIGN enabled
@ 2026-06-19 22:26 ANDREW
  0 siblings, 0 replies; 10+ messages in thread
From: ANDREW @ 2026-06-19 22:26 UTC (permalink / raw)
  To: 899f2dec-e8b9-44f4-ab8d-001e160a2aed
  Cc: Nathan Chancellor, Huacai Chen, loongarch, Xuefeng Li, Guo Ren,
	Xuerui Wang, Jiaxun Yang, linux-kernel, stable, Binbin Zhou,
	Xi Ruoyao


[-- Attachment #1.1.1: Type: text/plain, Size: 1811 bytes --]

voidacpi_tb_print_table_header(acpi_physical_address address,
  struct acpi_table_header *header)
{
struct acpi_table_header local_header;

ssize_t ssrc_len = sizeof(ACPI_CAST_PTR(struct acpi_table_rsdp, header)->signature);
size_t src_len = (ssrc_len < 0) ? 0 : (size_t)ssrc_len;
size_t src_length = (src_len < 8) ? src_len : 8;
char rsdp_sig[src_length + 1];
memcpy(rsdp_sig,
      ACPI_CAST_PTR(struct acpi_table_rsdp, header)->signature,
      src_length);
rsdp_sig[src_length] = '\0';

if (ACPI_COMPARE_NAMESEG(header->signature, ACPI_SIG_FACS)) {

/* FACS only has signature and length fields */

ACPI_INFO(("%-4.4s 0x%8.8X%8.8X %06X",
  header->signature, ACPI_FORMAT_UINT64(address),
  header->length));
} else if (ACPI_VALIDATE_RSDP_SIG(rsdp_sig)) {

/* RSDP has no common fields */

memcpy(local_header.oem_id,
      ACPI_CAST_PTR(struct acpi_table_rsdp, header)->oem_id,
      ACPI_OEM_ID_SIZE);
acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);

ACPI_INFO(("RSDP 0x%8.8X%8.8X %06X (v%.2d %-6.6s)",
  ACPI_FORMAT_UINT64(address),
  (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
   revision >
   0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
      header)->length : 20,
  ACPI_CAST_PTR(struct acpi_table_rsdp,
header)->revision,
  local_header.oem_id));
} else {
/* Standard ACPI table with full common header */

acpi_tb_cleanup_table_header(&local_header, header);

ACPI_INFO(("%-4.4s 0x%8.8X%8.8X"
  " %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)",
  local_header.signature, ACPI_FORMAT_UINT64(address),
  local_header.length, local_header.revision,
  local_header.oem_id, local_header.oem_table_id,
  local_header.oem_revision,
  local_header.asl_compiler_id,
  local_header.asl_compiler_revision));
}
}

[-- Attachment #1.1.2.1: Type: text/html, Size: 3250 bytes --]

[-- Attachment #1.2: publickey - andreasx0@protonmail.ch - 0xBB6B52B1.asc --]
[-- Type: application/pgp-keys, Size: 848 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 343 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-06-19 22:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-10  9:10 [PATCH V2] LoongArch: Align ACPI structures if ARCH_STRICT_ALIGN enabled Huacai Chen
2025-09-11  0:59 ` kernel test robot
2025-09-11  8:41   ` Huacai Chen
2025-09-20 23:48 ` Nathan Chancellor
2025-09-21  1:07   ` Huacai Chen
2025-09-26 14:31     ` Guenter Roeck
2025-09-26 17:15       ` Xi Ruoyao
2025-09-26 18:27         ` Guenter Roeck
2025-10-25 13:02           ` Xi Ruoyao
2026-06-19 22:26 ANDREW

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®