mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/apic: Use the physical address for the local APIC resource
@ 2026-11-06 22:08 Ahmed Abdelfattah via B4 Relay
  2026-11-20  8:37 ` Chao Gao
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmed Abdelfattah via B4 Relay @ 2026-11-06 22:08 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Peter Zijlstra (Intel)
  Cc: linux-kernel, Ahmed Abdelfattah

From: Ahmed Abdelfattah <me@ahmedabdelfattah.dev>

Since v6.6 the "Local APIC" entry is missing from /proc/iomem whenever
the kernel maps the xAPIC itself.

lapic_insert_resource() used to take the address from apic_phys. When
apic_phys went away it was switched to apic_mmio_base, but that holds
the fixmap virtual address, not the physical one:

  APIC: Mapped APIC to ffffffffff5fc000 (        fee00000)

insert_resource() rejects that range because it lies outside
iomem_resource, and as the return value is not checked, the failure
goes unnoticed.

Use mp_lapic_addr, which is the address apic_set_fixmap() maps. Keep
the apic_mmio_base check, so the resource is still only added when the
APIC was actually mapped.

Fixes: 78c32000848c ("x86/apic: Get rid of apic_phys")
Signed-off-by: Ahmed Abdelfattah <me@ahmedabdelfattah.dev>
---
This showed up while comparing /proc/iomem with the memory map of a
QEMU guest.

Tested on QEMU q35 with KVM (x86_64_defconfig + kvm_guest.config),
booting with and without nox2apic. Without the patch there is no
"Local APIC" entry in either case; with it both show

  fee00000-fee00fff : Local APIC

as before 78c32000848c.
---
 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
index 90025451ace2..17525b5daa0d 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2667,7 +2667,7 @@ static int __init lapic_insert_resource(void)
 		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);
 

---
base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee
change-id: 20261107-x86-apic-lapic-resource-e2f88ada8677

Best regards,
--  
Ahmed Abdelfattah <me@ahmedabdelfattah.dev>



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

* Re: [PATCH] x86/apic: Use the physical address for the local APIC resource
  2026-11-06 22:08 [PATCH] x86/apic: Use the physical address for the local APIC resource Ahmed Abdelfattah via B4 Relay
@ 2026-11-20  8:37 ` Chao Gao
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Gao @ 2026-11-20  8:37 UTC (permalink / raw)
  To: Ahmed Abdelfattah
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Peter Zijlstra (Intel),
	linux-kernel

On Sat, Nov 07, 2026 at 12:08:07AM +0200, Ahmed Abdelfattah wrote:
>Since v6.6 the "Local APIC" entry is missing from /proc/iomem whenever
>the kernel maps the xAPIC itself.

What is the impact on end users if this isn't fixed? Please make it clear
in the changelog, even if it is minor.

No one else has noticed this since v6.6, so it looks to me that nothing
depends on this "Local APIC" entry.

>
>lapic_insert_resource() used to take the address from apic_phys. When
>apic_phys went away it was switched to apic_mmio_base, but that holds
>the fixmap virtual address, not the physical one:
>
>  APIC: Mapped APIC to ffffffffff5fc000 (        fee00000)
>
>insert_resource() rejects that range because it lies outside
>iomem_resource, and as the return value is not checked, the failure
>goes unnoticed.
>
>Use mp_lapic_addr, which is the address apic_set_fixmap() maps. Keep
>the apic_mmio_base check, so the resource is still only added when the
>APIC was actually mapped.
>
>Fixes: 78c32000848c ("x86/apic: Get rid of apic_phys")
>Signed-off-by: Ahmed Abdelfattah <me@ahmedabdelfattah.dev>

Using the virtual address is clearly a mistake, so this fix looks good to
me. But the Fixes tag is wrong, as "apic_phys" already held the same
virtual address before that commit.

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

end of thread, other threads:[~2026-11-20  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 22:08 [PATCH] x86/apic: Use the physical address for the local APIC resource Ahmed Abdelfattah via B4 Relay
2026-11-20  8:37 ` Chao Gao

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®