public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: George Guo <dongtai.guo@linux.dev>,
	chenhuacai@kernel.org, jiaxun.yang@flygoat.com
Cc: linux-kernel@vger.kernel.org, George Guo <guodongtai@kylinos.cn>,
	stable@vger.kernel.org, Kexin Liu <liukexin@kylinos.cn>
Subject: Re: [PATCH 1/1] irqchip/loongson-pch-pic: Fix vec_count reading for 32-bit and 64-bit
Date: Fri, 10 Apr 2026 17:02:39 +0200	[thread overview]
Message-ID: <871pgm2700.ffs@tglx> (raw)
In-Reply-To: <20260410013053.3877-1-dongtai.guo@linux.dev>

On Fri, Apr 10 2026 at 09:30, George Guo wrote:
> From: George Guo <guodongtai@kylinos.cn>
>
> Commit 0370a5e740f2 ("irqchip/loongson-pch-pic: Adjust irqchip driver for
> 32BIT/64BIT") changed vec_count reading from readq() to readl() to support
> both 32-bit and 64-bit platforms. However, on virtual 64-bit platforms
> (QEMU 8.2.0) this causes incorrect vec_count value, leading to panic:

Is this problem limited to qemu?

> WARNING: drivers/acpi/irq.c:63 at acpi_register_gsi+0xe8/0x108
> Call Trace:
> [<900000000024c634>] show_stack+0x64/0x188
> [<9000000000245154>] dump_stack_lvl+0x6c/0x9c

Please trim your backtrace as documented:

https://www.kernel.org/doc/html/latest/process/submitting-patches.html#backtraces

> @@ -343,7 +343,12 @@ static int pch_pic_init(phys_addr_t addr, unsigned long size, int vec_base,
>  		priv->table[i] = PIC_UNDEF_VECTOR;
>  
>  	priv->ht_vec_base = vec_base;
> -	priv->vec_count = ((readl(priv->base + 4) >> 16) & 0xff) + 1;
> +
> +	if (IS_ENABLED(CONFIG_64BIT))
> +		priv->vec_count = ((readq(priv->base) >> 48) & 0xff) + 1;
> +	else
> +		priv->vec_count = ((readl(priv->base + 4) >> 16) & 0xff) + 1;

This does not make sense at all.

     readl(base + 4) >> 16

is fully equivalent to

     readq(base) >> 48

on a little endian machine, no?

This needs a better explanation in the change log about the root cause
and why this is the correct solution to fix the problem.

If there is no other solution then this needs a big fat comment in the
code explaining the reason. Otherwise the next AI agent will notice the
equivalence and people will send cleanup patches....

Thanks,

        tglx

      reply	other threads:[~2026-04-10 15:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10  1:30 [PATCH 1/1] irqchip/loongson-pch-pic: Fix vec_count reading for 32-bit and 64-bit George Guo
2026-04-10 15:02 ` Thomas Gleixner [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=871pgm2700.ffs@tglx \
    --to=tglx@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=dongtai.guo@linux.dev \
    --cc=guodongtai@kylinos.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liukexin@kylinos.cn \
    --cc=stable@vger.kernel.org \
    /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