From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4EB93D891B; Fri, 10 Apr 2026 15:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775833362; cv=none; b=gGtpuQvZDAgNLdDJ6evKnBRvlGQG5XXpR04ujVX0+36gu2wWrFuVGinnFUfZ9OzBYC5fV9ANfkvKdqnVXnoAqenrYcAehUrXukTkBzQfoxExQh+YbFGp2azxn6AixMAKhHqNs2Zph2IH5YdMw3bgIZu6ax6c/DOnAa1NofME0WA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775833362; c=relaxed/simple; bh=atcdLfEzGCk7sNy6PlWGj//0B89T1lqmjP4hSanhbAo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=gpjaG1Fvg2hZvTCBjWTMghN8W1vgp3Di6dOFfkSpcPY1ipCksZdnk/W6zS0fmJX9lFP20hS/nJ3GwLZ0nmbPzuAm7mfl7NIKfu/LMNWnWvCIi42IYLYjtwDnT7/vpq92C/vnxbovYLny3t29wTAZlYryAoFZ+89rFZEQA30oWms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gkKMSHsa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gkKMSHsa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFF82C2BC87; Fri, 10 Apr 2026 15:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775833362; bh=atcdLfEzGCk7sNy6PlWGj//0B89T1lqmjP4hSanhbAo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=gkKMSHsaFUxtGTMBpEQovhvqntBsuEEVDg+N/o0y3EUyJR+fX8ZDmXFW1vQHheZR/ gDAceUB3mJ5Dn8UTmLlwZnnnfHu9Xgmt6Mzfc5yM+KuEvi9xCxAh2Sdvk52ThR4Klz M7ozUcNZiXQBdrZiGUNevzXwUqb5b0Nl4AZnQn5RxYY336ADdWT5pq5ElFitFedjj/ gsa7OYH1OoMjA3pJzsZmN2ZaqWHaZddMLqiL5tcDaXPiZ5ZKp+hpBLTAiZxryTY3zy YS/lO/DgPOU6Y+N5hHhRT2lJFf1IPeFHK3Qt4HljQ5H/byl8s3qOQ0L3a07ct6vZGj BUhnQn5LkNleA== From: Thomas Gleixner To: George Guo , chenhuacai@kernel.org, jiaxun.yang@flygoat.com Cc: linux-kernel@vger.kernel.org, George Guo , stable@vger.kernel.org, Kexin Liu Subject: Re: [PATCH 1/1] irqchip/loongson-pch-pic: Fix vec_count reading for 32-bit and 64-bit In-Reply-To: <20260410013053.3877-1-dongtai.guo@linux.dev> References: <20260410013053.3877-1-dongtai.guo@linux.dev> Date: Fri, 10 Apr 2026 17:02:39 +0200 Message-ID: <871pgm2700.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, Apr 10 2026 at 09:30, George Guo wrote: > From: George Guo > > 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