mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: pwhMass <a203865235@gmail.com>
To: x86@kernel.org
Cc: pwhMass <a203865235@gmail.com>, Thomas Gleixner <tglx@kernel.org>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH] x86/apic: Use the physical address for the LAPIC resource
Date: Tue,  6 Oct 2026 19:25:25 +0800	[thread overview]
Message-ID: <20261006112527.26409-1-a203865235@gmail.com> (raw)

apic_mmio_base holds the fixmap virtual address used to access the local
APIC. Using it as lapic_resource.start passes a virtual address to the
physical iomem resource tree. On x86-64, the resulting range exceeds the
physical address limit of iomem_resource, so insert_resource() fails and
the Local APIC entry is missing from /proc/iomem.

Commit 81287ad65da5 ("x86/apic: Sanitize APIC address setup") replaced the
assignment of mp_lapic_addr to apic_phys with the fixmap virtual address.
The later removal of apic_phys retained that virtual address for the
resource.

Use mp_lapic_addr, which is the physical address passed to
set_fixmap_nocache(), as the resource start. Keep the apic_mmio_base guard
so that the resource is only registered when the MMIO mapping exists.

On an unmodified v7.3-rc2 x86-64 kernel under QEMU/KVM with nox2apic,
/proc/iomem has no Local APIC entry. With this change and the same kernel
configuration and VM parameters, it contains:

  fee00000-fee00fff : Local APIC

Fixes: 81287ad65da5 ("x86/apic: Sanitize APIC address setup")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: pwhMass <a203865235@gmail.com>
---
AI assistance was used to trace the missing /proc/iomem entry, prepare
this one-line fix and description, and execute the comparison tests.

Tested with clang/LLD 18.1.3, a virtme-ng generated configuration,
Q35/KVM, 1 GiB RAM, two vCPUs and nox2apic nokaslr. Both kernels built
and booted successfully. No HyperEnclave patches or modules were used
for this upstream reproduction.

Reproducer (run as root in the guest):
  grep -F 'Local APIC' /proc/iomem

Before: no match (exit 1).
After:  fee00000-fee00fff : Local APIC (exit 0).

 arch/x86/kernel/apic/apic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2667,7 +2667,7 @@
 		return -1;
 
 	/* Put local APIC into the resource map. */
-	lapic_resource.start = apic_mmio_base;
+	lapic_resource.start = mp_lapic_addr;
 	lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
 	insert_resource(&iomem_resource, &lapic_resource);
 

                 reply	other threads:[~2026-10-06 11:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261006112527.26409-1-a203865235@gmail.com \
    --to=a203865235@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@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

all inboxes | Powered by JetHome®