* Re: [PATCH v2 2/3] x86/apic: Introduce a variable to track the number of EILVT registers
@ 2026-05-15 11:48 Christian Ludloff
2026-05-15 13:30 ` Christian Ludloff
0 siblings, 1 reply; 4+ messages in thread
From: Christian Ludloff @ 2026-05-15 11:48 UTC (permalink / raw)
To: Naveen N Rao (AMD)
Cc: x86, Thomas Gleixner, Borislav Petkov, Dave Hansen,
H. Peter Anvin, Nikunj A Dadhania, Manali Shukla, Bharata B Rao,
linux-kernel
> + if (cpu_feature_enabled(X86_FEATURE_EXTAPIC))
> + apic_eilvt_count = APIC_EFEAT_XLC(apic_read(APIC_EFEAT));
BKDG #21656, #21922, and #24141 for K7 were not published.
If you find them internally at AMD, consider publishing them. :)
That way they could be archived, and referenced from then on.
BKDG #26094 for K8 Fam Fh DDR1 documents 4 extended LVTs.
BKDG #32559 for K8 Fam Fh DDR2 documents 1 extended LVT.
BKDG #41256 for K8 Fam 11h (LG) documents 4 extended LVTs.
Fam 10h/12h, 14h and 16h, and 15h all have 4 – no surprises.
The Fam 10h BKDG (#31116) has an explicit entry in its "Major
Changes Relative to Family 0Fh Processors" section: "Number
of extended LVT interrupts in APIC increased to 4." – AMD may
want to clarify what was correct vs not for those old K8 models.
> + if (!apic_eilvt_count && boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
> + apic_eilvt_count = APIC_EILVT_NR_AMD_10H;
This seems... unsafe?
--
C.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/3] x86/apic: Introduce a variable to track the number of EILVT registers
2026-05-15 11:48 [PATCH v2 2/3] x86/apic: Introduce a variable to track the number of EILVT registers Christian Ludloff
@ 2026-05-15 13:30 ` Christian Ludloff
2026-05-15 13:50 ` Naveen N Rao
0 siblings, 1 reply; 4+ messages in thread
From: Christian Ludloff @ 2026-05-15 13:30 UTC (permalink / raw)
To: Naveen N Rao (AMD)
Cc: x86, Thomas Gleixner, Borislav Petkov, Dave Hansen,
H. Peter Anvin, Nikunj A Dadhania, Manali Shukla, Bharata B Rao,
linux-kernel
On Fri, May 15, 2026 at 4:48 AM Christian Ludloff <ludloff@gmail.com> wrote:
>
> > + if (cpu_feature_enabled(X86_FEATURE_EXTAPIC))
> > + apic_eilvt_count = APIC_EFEAT_XLC(apic_read(APIC_EFEAT));
>
> BKDG #21656, #21922, and #24141 for K7 were not published.
> If you find them internally at AMD, consider publishing them. :)
> That way they could be archived, and referenced from then on.
minor extra K7 quirk, documented in the K7 datasheet (#21016):
before model 2, the chip was missing two of the pins required for
proper APIC operation – so the APIC didn't quite work back then
> BKDG #26094 for K8 Fam Fh DDR1 documents 4 extended LVTs.
I mis-read that one – correction – it's 0 there, not 4
also, supposedly no bit 31 = 1 in the version register, but does have
registers 400h and 410h (but not the other/later extended registers)
> BKDG #32559 for K8 Fam Fh DDR2 documents 1 extended LVT.
> BKDG #41256 for K8 Fam 11h (LG) documents 4 extended LVTs.
>
> Fam 10h/12h, 14h and 16h, and 15h all have 4 – no surprises.
>
> The Fam 10h BKDG (#31116) has an explicit entry in its "Major
> Changes Relative to Family 0Fh Processors" section: "Number
> of extended LVT interrupts in APIC increased to 4." – AMD may
> want to clarify what was correct vs not for those old K8 models.
per the correction above – K8 went from 0 to 1 to 4 extended LVTs
> > + if (!apic_eilvt_count && boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
> > + apic_eilvt_count = APIC_EILVT_NR_AMD_10H;
>
> This seems... unsafe?
double-check it w.r.t. K7 and K8 Fam Fh DDR1, please
--
C.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/3] x86/apic: Introduce a variable to track the number of EILVT registers
2026-05-15 13:30 ` Christian Ludloff
@ 2026-05-15 13:50 ` Naveen N Rao
0 siblings, 0 replies; 4+ messages in thread
From: Naveen N Rao @ 2026-05-15 13:50 UTC (permalink / raw)
To: Christian Ludloff
Cc: x86, Thomas Gleixner, Borislav Petkov, Dave Hansen,
H. Peter Anvin, Nikunj A Dadhania, Manali Shukla, Bharata B Rao,
linux-kernel
On Fri, May 15, 2026 at 06:30:07AM -0700, Christian Ludloff wrote:
> On Fri, May 15, 2026 at 4:48 AM Christian Ludloff <ludloff@gmail.com> wrote:
> >
> > > + if (cpu_feature_enabled(X86_FEATURE_EXTAPIC))
> > > + apic_eilvt_count = APIC_EFEAT_XLC(apic_read(APIC_EFEAT));
> >
> > BKDG #21656, #21922, and #24141 for K7 were not published.
> > If you find them internally at AMD, consider publishing them. :)
> > That way they could be archived, and referenced from then on.
>
> minor extra K7 quirk, documented in the K7 datasheet (#21016):
>
> before model 2, the chip was missing two of the pins required for
> proper APIC operation – so the APIC didn't quite work back then
>
> > BKDG #26094 for K8 Fam Fh DDR1 documents 4 extended LVTs.
>
> I mis-read that one – correction – it's 0 there, not 4
>
> also, supposedly no bit 31 = 1 in the version register, but does have
> registers 400h and 410h (but not the other/later extended registers)
>
> > BKDG #32559 for K8 Fam Fh DDR2 documents 1 extended LVT.
> > BKDG #41256 for K8 Fam 11h (LG) documents 4 extended LVTs.
> >
> > Fam 10h/12h, 14h and 16h, and 15h all have 4 – no surprises.
> >
> > The Fam 10h BKDG (#31116) has an explicit entry in its "Major
> > Changes Relative to Family 0Fh Processors" section: "Number
> > of extended LVT interrupts in APIC increased to 4." – AMD may
> > want to clarify what was correct vs not for those old K8 models.
>
> per the correction above – K8 went from 0 to 1 to 4 extended LVTs
Right, I looked up what I could. The fallback below is explicitly for
addressing those.
>
> > > + if (!apic_eilvt_count && boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
> > > + apic_eilvt_count = APIC_EILVT_NR_AMD_10H;
> >
> > This seems... unsafe?
>
> double-check it w.r.t. K7 and K8 Fam Fh DDR1, please
This fallback exists purely to retain the current default (except that
it is now restricted to AMD processors)
The default being 4 (rather than 1 or even 0) is not really an issue
because this function won't be invoked for older processors. The common
case is for this to be invoked with a BIOS-provided offset. The only
exception is for IBS for family 0x10, but that family has 4 extended
LVTs present (see ibs_eilvt_setup()).
- Naveen
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] x86/apic: Introduce a variable to track the number of EILVT registers
2026-05-12 14:19 [PATCH v2 0/3] Support additional AMD " Naveen N Rao (AMD)
@ 2026-05-12 14:19 ` Naveen N Rao (AMD)
0 siblings, 0 replies; 4+ messages in thread
From: Naveen N Rao (AMD) @ 2026-05-12 14:19 UTC (permalink / raw)
To: x86
Cc: Thomas Gleixner, Borislav Petkov, Dave Hansen, H. Peter Anvin,
Nikunj A Dadhania, Manali Shukla, Bharata B Rao, linux-kernel
Future AMD processors will be increasing the number of EILVT registers.
Rather than hardcoding the maximum EILVT register count and using that
everywhere, introduce a variable to track the EILVT register count.
The number of EILVT registers is exposed through the extended APIC
Feature Register (APIC_EFEAT) bits 23:16. Use this to initialize the
count and fall back to the current default (APIC_EILVT_NR_AMD_10H) if
the count is not available.
Export the new variable for KVM since it needs this for supporting
extended APIC register space on AMD.
Signed-off-by: Naveen N Rao (AMD) <naveen@kernel.org>
Tested-by: Manali Shukla <manali.shukla@amd.com>
---
http://lore.kernel.org/r/20260204074452.55453-3-manali.shukla@amd.com as
a related series adding support for KVM and needing access to the EILVT
register count.
- Naveen
arch/x86/include/asm/apic.h | 2 ++
arch/x86/include/asm/apicdef.h | 1 +
arch/x86/kernel/apic/apic.c | 12 ++++++++++++
3 files changed, 15 insertions(+)
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 9cd493d467d4..8b03c7a14706 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -74,6 +74,8 @@ enum apic_intr_mode_id {
APIC_SYMMETRIC_IO_NO_ROUTING
};
+extern unsigned int apic_eilvt_count;
+
/*
* With 82489DX we can't rely on apic feature bit
* retrieved via cpuid but still have to deal with
diff --git a/arch/x86/include/asm/apicdef.h b/arch/x86/include/asm/apicdef.h
index bc125c4429dc..ba7657e75ad1 100644
--- a/arch/x86/include/asm/apicdef.h
+++ b/arch/x86/include/asm/apicdef.h
@@ -134,6 +134,7 @@
#define APIC_TDR_DIV_64 0x9
#define APIC_TDR_DIV_128 0xA
#define APIC_EFEAT 0x400
+#define APIC_EFEAT_XLC(x) (((x) >> 16) & 0xff)
#define APIC_ECTRL 0x410
#define APIC_SEOI 0x420
#define APIC_IER 0x480
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 8c614750a19b..ecbf15399399 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -342,6 +342,8 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
*/
static atomic_t eilvt_offsets[APIC_EILVT_NR_MAX];
+unsigned int apic_eilvt_count __ro_after_init;
+EXPORT_SYMBOL_FOR_KVM(apic_eilvt_count);
static inline int eilvt_entry_is_changeable(unsigned int old, unsigned int new)
{
@@ -410,6 +412,15 @@ int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
}
EXPORT_SYMBOL_GPL(setup_APIC_eilvt);
+static __init void init_eilvt(void)
+{
+ if (cpu_feature_enabled(X86_FEATURE_EXTAPIC))
+ apic_eilvt_count = APIC_EFEAT_XLC(apic_read(APIC_EFEAT));
+
+ if (!apic_eilvt_count && boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+ apic_eilvt_count = APIC_EILVT_NR_AMD_10H;
+}
+
/*
* Program the next event, relative to now
*/
@@ -2344,6 +2355,7 @@ static void __init apic_bsp_setup(bool upmode)
if (upmode)
apic_bsp_up_setup();
setup_local_APIC();
+ init_eilvt();
enable_IO_APIC();
end_local_APIC_setup();
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-15 13:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-15 11:48 [PATCH v2 2/3] x86/apic: Introduce a variable to track the number of EILVT registers Christian Ludloff
2026-05-15 13:30 ` Christian Ludloff
2026-05-15 13:50 ` Naveen N Rao
-- strict thread matches above, loose matches on Subject: below --
2026-05-12 14:19 [PATCH v2 0/3] Support additional AMD " Naveen N Rao (AMD)
2026-05-12 14:19 ` [PATCH v2 2/3] x86/apic: Introduce a variable to track the number of " Naveen N Rao (AMD)
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®