mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jiaxun Yang" <jiaxun.yang@flygoat.com>
To: "Huacai Chen" <chenhuacai@loongson.cn>,
	"Huacai Chen" <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev, "Xuefeng Li" <lixuefeng@loongson.cn>,
	"Guo Ren" <guoren@kernel.org>, "Xuerui Wang" <kernel@xen0n.name>,
	linux-kernel@vger.kernel.org,
	"Binbin Zhou" <zhoubinbin@loongson.cn>,
	"Xi Ruoyao" <xry111@xry111.site>
Subject: Re: [PATCH] LoongArch: Align ACPI structures if ARCH_STRICT_ALIGN enabled
Date: Tue, 09 Sep 2025 20:28:59 +0800	[thread overview]
Message-ID: <07042615-8fc9-476f-b614-46c8b9f148ab@app.fastmail.com> (raw)
In-Reply-To: <20250909095320.4083749-1-chenhuacai@loongson.cn>



在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

      reply	other threads:[~2025-09-09 12:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09  9:53 Huacai Chen
2025-09-09 12:28 ` Jiaxun Yang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=07042615-8fc9-476f-b614-46c8b9f148ab@app.fastmail.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=guoren@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=loongarch@lists.linux.dev \
    --cc=xry111@xry111.site \
    --cc=zhoubinbin@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®