Skip to contentSkip to conversation

apic, x86: Use BIOS settings to setup AMD EILVT APIC registers

PATCH In review Robert Richter 2 participants 10 messages Oct 6, 2010 – Oct 20, 2010 x86

lore
Share & tools
lore
#0 lore raw

cover apic, x86: Use BIOS settings to setup AMD EILVT APIC registers

This patch set changes the way of setting up EILVT APIC registers (APIC500-530). See family 10h bkdg:

http://support.amd.com/us/Processor_TechDocs/31116.pdf

Until now, Linux has assigned fixed LVT offsets for IBS and MCE threshold. With the introduction of new cpu families we want to be more flexible and assign those LVT offsets dynamically. The general apporach here is to let the BIOS decide which offsets to use. Linux will then detect this by reading the corresponding hw registers that contain the LVT offsets.

This requires to check if the BIOS is correctly setting up the LVT offsets. Otherwise a firmware bug message will be thrown. This is implemented in patch #1.

Patch #2 implements the detection of MCE threshold and IBS LVT offsets and changes the subsystem initialization. The code to setup the IBS LVT offset on family 10h systems will remain as a workaround that will be only applied in case of an invalid IBS LVT BIOS setup.

-Robert

#1 lore raw

PATCH 1/2 apic, x86: Check if EILVT APIC registers are available (AMD only)

This patch implements checks for the availability of LVT entries (APIC500-530) and reserves it if used. The check becomes necessary since we want to let the BIOS provide the LVT offsets. The offsets should be determined by the subsystems using it like those for MCE threshold or IBS. On K8 only offset 0 (APIC500) and MCE interrupts are supported. Beginning with family 10h at least 4 offsets are available.

Since offsets must be consistent for all cores, we keep track of the LVT offsets in software and reserve the offset for the same vector also to be used on other cores. An offset is freed by setting the entry to APIC_EILVT_MASKED.

If the BIOS is right, there should be no conflicts. Otherwise a "[Firmware Bug]: ..." error message is generated. However, if software does not properly determines the offsets, it is not necessarily a BIOS bug.

---
 arch/x86/include/asm/apicdef.h |    1 +
 arch/x86/kernel/apic/apic.c    |   83 +++++++++++++++++++++++++++++++++++----
 2 files changed, 75 insertions(+), 9 deletions(-)
arch/x86/include/asm/apicdef.h +1 -0
index 7fe3b30..a859ca4 100644
@@ -131,6 +131,7 @@
 #define APIC_EILVTn(n)	(0x500 + 0x10 * n)
 #define		APIC_EILVT_NR_AMD_K8	1	/* # of extended interrupts */
 #define		APIC_EILVT_NR_AMD_10H	4
+#define		APIC_EILVT_NR_MAX	APIC_EILVT_NR_AMD_10H
 #define		APIC_EILVT_LVTOFF(x)	(((x) >> 4) & 0xF)
 #define		APIC_EILVT_MSG_FIX	0x0
 #define		APIC_EILVT_MSG_SMI	0x2
arch/x86/kernel/apic/apic.c +74 -9

104 lines not on this page · raw message

Signature · 1 line
1.7.2.2
#2 lore raw

[tip:irq/core] apic, x86: Check if EILVT APIC registers are available (AMD only)

Commit-ID:  a68c439b1966c91f0ef474e2bf275d6792312726
Gitweb:     http://git.kernel.org/tip/a68c439b1966c91f0ef474e2bf275d6792312726
Author:     Robert Richter <[email protected]>
AuthorDate: Wed, 6 Oct 2010 12:27:53 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 20 Oct 2010 04:42:13 +0200

apic, x86: Check if EILVT APIC registers are available (AMD only)

This patch implements checks for the availability of LVT entries (APIC500-530) and reserves it if used. The check becomes necessary since we want to let the BIOS provide the LVT offsets.
The offsets should be determined by the subsystems using it
like those for MCE threshold or IBS. On K8 only offset 0 (APIC500) and MCE interrupts are supported. Beginning with family 10h at least 4 offsets are available.

Since offsets must be consistent for all cores, we keep track of the LVT offsets in software and reserve the offset for the same vector also to be used on other cores. An offset is freed by setting the entry to APIC_EILVT_MASKED.

If the BIOS is right, there should be no conflicts. Otherwise a "[Firmware Bug]: ..." error message is generated. However, if software does not properly determines the offsets, it is not necessarily a BIOS bug.

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/apicdef.h |    1 +
 arch/x86/kernel/apic/apic.c    |   83 +++++++++++++++++++++++++++++++++++----
 2 files changed, 75 insertions(+), 9 deletions(-)
arch/x86/include/asm/apicdef.h +1 -0
index 7fe3b30..a859ca4 100644
@@ -131,6 +131,7 @@
 #define APIC_EILVTn(n)	(0x500 + 0x10 * n)
 #define		APIC_EILVT_NR_AMD_K8	1	/* # of extended interrupts */
 #define		APIC_EILVT_NR_AMD_10H	4
+#define		APIC_EILVT_NR_MAX	APIC_EILVT_NR_AMD_10H
 #define		APIC_EILVT_LVTOFF(x)	(((x) >> 4) & 0xF)
 #define		APIC_EILVT_MSG_FIX	0x0
 #define		APIC_EILVT_MSG_SMI	0x2
arch/x86/kernel/apic/apic.c +74 -9

104 lines not on this page · raw message

#3 lore raw

PATCH 2/2 apic, x86: Use BIOS settings for IBS and MCE threshold interrupt LVT offsets

In reply to Robert Richter

We want the BIOS to setup the EILVT APIC registers. The offsets were hardcoded and BIOS settings were overwritten by the OS. Now, the subsystems for MCE threshold and IBS determine the LVT offset from the registers the BIOS has setup. If the BIOS setup is buggy on a family 10h system, a workaround enables IBS. If the OS determines an invalid register setup, a "[Firmware Bug]: " error message is reported.

We need this change also for upcomming cpu families.

---
 arch/x86/include/asm/apic.h          |    4 +-
 arch/x86/kernel/apic/apic.c          |   19 +----
 arch/x86/kernel/cpu/mcheck/mce_amd.c |   27 ++++++-
 arch/x86/oprofile/op_model_amd.c     |  145 +++++++++++++++++++++++++++++----
 4 files changed, 154 insertions(+), 41 deletions(-)
arch/x86/include/asm/apic.h +1 -3
index 1fa03e0..286de34 100644
@@ -252,9 +252,7 @@ static inline int apic_is_clustered_box(void)
 }
 #endif
 
-extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
-extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
-
+extern int setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask);
 
 #else /* !CONFIG_X86_LOCAL_APIC */
 static inline void lapic_shutdown(void) { }
arch/x86/kernel/apic/apic.c +2 -17
index 2876f95..06ec876 100644
@@ -390,9 +390,6 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
  * necessarily a BIOS bug.
  */
 
-#define APIC_EILVT_LVTOFF_MCE 0
-#define APIC_EILVT_LVTOFF_IBS 1
-
 static atomic_t eilvt_offsets[APIC_EILVT_NR_MAX];
 
 static inline int eilvt_entry_is_changeable(unsigned int old, unsigned int new)
@@ -426,7 +423,7 @@ static unsigned int reserve_eilvt_offset(int offset, unsigned int new)
  * enables the vector. See also the BKDGs.
  */
 
-static int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
+int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
 {
 	unsigned long reg = APIC_EILVTn(offset);
 	unsigned int new, old, reserved;
@@ -454,19 +451,7 @@ static int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
 
 	return 0;
 }
-
-u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask)
-{
-	setup_APIC_eilvt(APIC_EILVT_LVTOFF_MCE, vector, msg_type, mask);
-	return APIC_EILVT_LVTOFF_MCE;
-}
-
-u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask)
-{
-	setup_APIC_eilvt(APIC_EILVT_LVTOFF_IBS, vector, msg_type, mask);
-	return APIC_EILVT_LVTOFF_IBS;
-}
-EXPORT_SYMBOL_GPL(setup_APIC_eilvt_ibs);
+EXPORT_SYMBOL_GPL(setup_APIC_eilvt);
 
 /*
  * Program the next event, relative to now
arch/x86/kernel/cpu/mcheck/mce_amd.c +24 -3
index 5e97529..e13d4bd 100644
@@ -131,7 +131,8 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
 	u32 low = 0, high = 0, address = 0;
 	unsigned int bank, block;
 	struct thresh_restart tr;
-	u8 lvt_off;
+	int lvt_off = -1;
+	u8 offset;
 
 	for (bank = 0; bank < NR_BANKS; ++bank) {
 		for (block = 0; block < NR_BLOCKS; ++block) {
@@ -165,8 +166,28 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
 			if (shared_bank[bank] && c->cpu_core_id)
 				break;
 #endif
-			lvt_off = setup_APIC_eilvt_mce(THRESHOLD_APIC_VECTOR,
-						       APIC_EILVT_MSG_FIX, 0);
+			offset = (high & MASK_LVTOFF_HI) >> 20;
+			if (lvt_off < 0) {
+				if (setup_APIC_eilvt(offset,
+						     THRESHOLD_APIC_VECTOR,
+						     APIC_EILVT_MSG_FIX, 0)) {
+					pr_err(FW_BUG "cpu %d, failed to "
+					       "setup threshold interrupt "
+					       "for bank %d, block %d "
+					       "(MSR%08X=0x%x%08x)",
+					       smp_processor_id(), bank, block,
+					       address, high, low);
+					continue;
+				}
+				lvt_off = offset;
+			} else if (lvt_off != offset) {
+				pr_err(FW_BUG "cpu %d, invalid threshold "
+				       "interrupt offset %d for bank %d,"
+				       "block %d (MSR%08X=0x%x%08x)",
+				       smp_processor_id(), lvt_off, bank,
+				       block, address, high, low);
+				continue;
+			}
 
 			high &= ~MASK_LVTOFF_HI;
 			high |= lvt_off << 20;
arch/x86/oprofile/op_model_amd.c +127 -18

198 lines not on this page · raw message

Signature · 1 line
1.7.2.2
#4 lore raw

Re: [PATCH 2/2] apic, x86: Use BIOS settings for IBS and MCE threshold interrupt LVT offsets

Quoted 11 lines · Robert Richter

We want the BIOS to setup the EILVT APIC registers. The offsets were hardcoded and BIOS settings were overwritten by the OS. Now, the subsystems for MCE threshold and IBS determine the LVT offset from the registers the BIOS has setup. If the BIOS setup is buggy on a family 10h system, a workaround enables IBS. If the OS determines an invalid register setup, a "[Firmware Bug]: " error message is reported.

We need this change also for upcomming cpu families.

---

Hi Robert, a few comments

...

Quoted 27 lines

/*
* Program the next event, relative to now

arch/x86/kernel/cpu/mcheck/mce_amd.c +7 -3
index 5e97529..e13d4bd 100644
@@ -131,7 +131,8 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
 	u32 low = 0, high = 0, address = 0;
 	unsigned int bank, block;
 	struct thresh_restart tr;
-	u8 lvt_off;
+	int lvt_off = -1;
+	u8 offset;
 
 	for (bank = 0; bank < NR_BANKS; ++bank) {
 		for (block = 0; block < NR_BLOCKS; ++block) {
@@ -165,8 +166,28 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
 			if (shared_bank[bank] && c->cpu_core_id)
 				break;
 #endif
-			lvt_off = setup_APIC_eilvt_mce(THRESHOLD_APIC_VECTOR,
-						       APIC_EILVT_MSG_FIX, 0);
+			offset = (high & MASK_LVTOFF_HI) >> 20;
+			if (lvt_off < 0) {
+				if (setup_APIC_eilvt(offset,
+						     THRESHOLD_APIC_VECTOR,
+						     APIC_EILVT_MSG_FIX, 0)) {

arch/x86/kernel/cpu/mcheck/mce_amd.c void mce_amd_feature_init(struct cpuinfo_x86 *c) · line 183

Quoted 10 lines
arch/x86/kernel/cpu/mcheck/mce_amd.c +10 -0
+					pr_err(FW_BUG "cpu %d, failed to "
+					       "setup threshold interrupt "
+					       "for bank %d, block %d "
+					       "(MSR%08X=0x%x%08x)",
+					       smp_processor_id(), bank, block,
+					       address, high, low);
+					continue;
+				}
+				lvt_off = offset;
+			} else if (lvt_off != offset) {

Could we put explicit type specificator here? For better readbility.
...

arch/x86/kernel/cpu/mcheck/mce_amd.c void mce_amd_feature_init(struct cpuinfo_x86 *c) · line 190

Quoted 7 lines
arch/x86/kernel/cpu/mcheck/mce_amd.c +7 -0
+static int force_ibs_eilvt_setup(void)
+{
+	int i;
+	int ret;
+
+	/* find the next free available EILVT entry */
+	for (i = 1; i < 4; i++) {

APIC_EILVT_NR_MAX here, no?

arch/x86/kernel/cpu/mcheck/mce_amd.c void mce_amd_feature_init(struct cpuinfo_x86 *c)

Quoted 8 lines
arch/x86/kernel/cpu/mcheck/mce_amd.c +6 -0
+		if (!eilvt_is_available(i))
+			continue;
+		ret = setup_ibs_ctl(i);
+		if (ret)
+			return ret;
+		return 0;
 	}

Cyrill

#5 lore raw

Re: [PATCH 2/2] apic, x86: Use BIOS settings for IBS and MCE threshold interrupt LVT offsets

Quoted 48 lines · Cyrill Gorcunov
Quoted 11 lines · Robert Richter

We want the BIOS to setup the EILVT APIC registers. The offsets were hardcoded and BIOS settings were overwritten by the OS. Now, the subsystems for MCE threshold and IBS determine the LVT offset from the registers the BIOS has setup. If the BIOS setup is buggy on a family 10h system, a workaround enables IBS. If the OS determines an invalid register setup, a "[Firmware Bug]: " error message is reported.

We need this change also for upcomming cpu families.

---

Hi Robert, a few comments

...

Quoted 32 lines

/*
* Program the next event, relative to now

arch/x86/kernel/cpu/mcheck/mce_amd.c +12 -3
index 5e97529..e13d4bd 100644
@@ -131,7 +131,8 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
 	u32 low = 0, high = 0, address = 0;
 	unsigned int bank, block;
 	struct thresh_restart tr;
-	u8 lvt_off;
+	int lvt_off = -1;
+	u8 offset;
 
 	for (bank = 0; bank < NR_BANKS; ++bank) {
 		for (block = 0; block < NR_BLOCKS; ++block) {
@@ -165,8 +166,28 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
 			if (shared_bank[bank] && c->cpu_core_id)
 				break;
 #endif
-			lvt_off = setup_APIC_eilvt_mce(THRESHOLD_APIC_VECTOR,
-						       APIC_EILVT_MSG_FIX, 0);
+			offset = (high & MASK_LVTOFF_HI) >> 20;
+			if (lvt_off < 0) {
+				if (setup_APIC_eilvt(offset,
+						     THRESHOLD_APIC_VECTOR,
+						     APIC_EILVT_MSG_FIX, 0)) {
+					pr_err(FW_BUG "cpu %d, failed to "
+					       "setup threshold interrupt "
+					       "for bank %d, block %d "
+					       "(MSR%08X=0x%x%08x)",
+					       smp_processor_id(), bank, block,
Quoted 8 lines

arch/x86/kernel/cpu/mcheck/mce_amd.c void mce_amd_feature_init(struct cpuinfo_x86 *c) · line 183

Quoted 5 lines
arch/x86/kernel/cpu/mcheck/mce_amd.c +5 -0
+					       address, high, low);
+					continue;
+				}
+				lvt_off = offset;
+			} else if (lvt_off != offset) {

Could we put explicit type specificator here? For better readbility.
...

Cyrill,

Do you mean an explicit type cast here, or something else?

Quoted 10 lines

arch/x86/kernel/cpu/mcheck/mce_amd.c void mce_amd_feature_init(struct cpuinfo_x86 *c) · line 190

Quoted 8 lines
arch/x86/kernel/cpu/mcheck/mce_amd.c +7 -0
+static int force_ibs_eilvt_setup(void)
+{
+	int i;
+	int ret;
+
+	/* find the next free available EILVT entry */
+	for (i = 1; i < 4; i++) {

APIC_EILVT_NR_MAX here, no?

Yes, will update this if a -v2 patch set will be necessary.

Thanks for review,

-Robert

Quoted 12 lines

arch/x86/kernel/cpu/mcheck/mce_amd.c void mce_amd_feature_init(struct cpuinfo_x86 *c)

Quoted 9 lines
arch/x86/kernel/cpu/mcheck/mce_amd.c +6 -0
+		if (!eilvt_is_available(i))
+			continue;
+		ret = setup_ibs_ctl(i);
+		if (ret)
+			return ret;
+		return 0;
 	}

Cyrill

Signature · 2 lines
Advanced Micro Devices, Inc.
Operating System Research Center
#6 lore raw

Re: [PATCH 2/2] apic, x86: Use BIOS settings for IBS and MCE threshold interrupt LVT offsets

On Fri, Oct 8, 2010 at 1:24 PM, Robert Richter <[email protected]> wrote:
...

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

+                   } else if (lvt_off != offset) {

Could we put explicit type specificator here? For better readbility.
...

Cyrill,

Do you mean an explicit type cast here, or something else?

Yeah, explicit type cast (not a big deal though since at moment of course nothing can fire in this snippet, but I think for future modifications better to have explicit cast).

Quoted 5 lines

Thanks for review,

-Robert

Cyrill

#7 lore raw

Re: [PATCH 2/2] apic, x86: Use BIOS settings for IBS and MCE threshold interrupt LVT offsets

Quoted 7 lines · Cyrill Gorcunov

On Fri, Oct 8, 2010 at 1:24 PM, Robert Richter <[email protected]> wrote:
...

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

+                   } else if (lvt_off != offset) {

Could we put explicit type specificator here? For better readbility.
...

Quoted 8 lines
Quoted 4 lines

Cyrill,

Do you mean an explicit type cast here, or something else?

Yeah, explicit type cast (not a big deal though since at moment of course nothing can fire in this snippet, but I think for future modifications better to have explicit cast).

Hmm, don't think this is really necessary. As an alternative we could make variable offset an int too and then do an explicit cast when calling setup_APIC_eilvt().

But I rather tend to leave it as it is.

-Robert

Quoted 9 lines
Quoted 6 lines

Thanks for review,

-Robert

Cyrill

Signature · 2 lines
Advanced Micro Devices, Inc.
Operating System Research Center
#8 lore raw

Re: [PATCH 2/2] apic, x86: Use BIOS settings for IBS and MCE threshold interrupt LVT offsets

Quoted 17 lines · Robert Richter
Quoted 7 lines · Cyrill Gorcunov

On Fri, Oct 8, 2010 at 1:24 PM, Robert Richter <[email protected]> wrote:
...

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

+                   } else if (lvt_off != offset) {

Could we put explicit type specificator here? For better readbility.
...

Quoted 8 lines
Quoted 4 lines

Cyrill,

Do you mean an explicit type cast here, or something else?

Yeah, explicit type cast (not a big deal though since at moment of course nothing can fire in this snippet, but I think for future modifications better to have explicit cast).

Quoted 5 lines

Hmm, don't think this is really necessary. As an alternative we could make variable offset an int too and then do an explicit cast when calling setup_APIC_eilvt().

But I rather tend to leave it as it is.

Well, I don't insist at all. Lets leave it as is.

Cyrill

#9 lore raw

[tip:irq/core] apic, x86: Use BIOS settings for IBS and MCE threshold interrupt LVT offsets

In reply to Robert Richter
Commit-ID:  27afdf2008da0b8878a73e32e4eb12381b84e224
Gitweb:     http://git.kernel.org/tip/27afdf2008da0b8878a73e32e4eb12381b84e224
Author:     Robert Richter <[email protected]>
AuthorDate: Wed, 6 Oct 2010 12:27:54 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 20 Oct 2010 04:42:13 +0200

apic, x86: Use BIOS settings for IBS and MCE threshold interrupt LVT offsets

We want the BIOS to setup the EILVT APIC registers. The offsets were hardcoded and BIOS settings were overwritten by the OS. Now, the subsystems for MCE threshold and IBS determine the LVT offset from the registers the BIOS has setup. If the BIOS setup is buggy on a family 10h system, a workaround enables IBS. If the OS determines an invalid register setup, a "[Firmware Bug]:
" error message is reported.

We need this change also for upcomming cpu families.

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/apic.h          |    4 +-
 arch/x86/kernel/apic/apic.c          |   19 +----
 arch/x86/kernel/cpu/mcheck/mce_amd.c |   27 ++++++-
 arch/x86/oprofile/op_model_amd.c     |  145 +++++++++++++++++++++++++++++----
 4 files changed, 154 insertions(+), 41 deletions(-)
arch/x86/include/asm/apic.h +1 -3
index 1fa03e0..286de34 100644
@@ -252,9 +252,7 @@ static inline int apic_is_clustered_box(void)
 }
 #endif
 
-extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
-extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
-
+extern int setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask);
 
 #else /* !CONFIG_X86_LOCAL_APIC */
 static inline void lapic_shutdown(void) { }
arch/x86/kernel/apic/apic.c +2 -17
index 2bfeafd..850657d 100644
@@ -390,9 +390,6 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
  * necessarily a BIOS bug.
  */
 
-#define APIC_EILVT_LVTOFF_MCE 0
-#define APIC_EILVT_LVTOFF_IBS 1
-
 static atomic_t eilvt_offsets[APIC_EILVT_NR_MAX];
 
 static inline int eilvt_entry_is_changeable(unsigned int old, unsigned int new)
@@ -426,7 +423,7 @@ static unsigned int reserve_eilvt_offset(int offset, unsigned int new)
  * enables the vector. See also the BKDGs.
  */
 
-static int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
+int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
 {
 	unsigned long reg = APIC_EILVTn(offset);
 	unsigned int new, old, reserved;
@@ -454,19 +451,7 @@ static int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
 
 	return 0;
 }
-
-u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask)
-{
-	setup_APIC_eilvt(APIC_EILVT_LVTOFF_MCE, vector, msg_type, mask);
-	return APIC_EILVT_LVTOFF_MCE;
-}
-
-u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask)
-{
-	setup_APIC_eilvt(APIC_EILVT_LVTOFF_IBS, vector, msg_type, mask);
-	return APIC_EILVT_LVTOFF_IBS;
-}
-EXPORT_SYMBOL_GPL(setup_APIC_eilvt_ibs);
+EXPORT_SYMBOL_GPL(setup_APIC_eilvt);
 
 /*
  * Program the next event, relative to now
arch/x86/kernel/cpu/mcheck/mce_amd.c +24 -3
index 39aaee5..80c4823 100644
@@ -131,7 +131,8 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
 	u32 low = 0, high = 0, address = 0;
 	unsigned int bank, block;
 	struct thresh_restart tr;
-	u8 lvt_off;
+	int lvt_off = -1;
+	u8 offset;
 
 	for (bank = 0; bank < NR_BANKS; ++bank) {
 		for (block = 0; block < NR_BLOCKS; ++block) {
@@ -162,8 +163,28 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
 			if (shared_bank[bank] && c->cpu_core_id)
 				break;
 #endif
-			lvt_off = setup_APIC_eilvt_mce(THRESHOLD_APIC_VECTOR,
-						       APIC_EILVT_MSG_FIX, 0);
+			offset = (high & MASK_LVTOFF_HI) >> 20;
+			if (lvt_off < 0) {
+				if (setup_APIC_eilvt(offset,
+						     THRESHOLD_APIC_VECTOR,
+						     APIC_EILVT_MSG_FIX, 0)) {
+					pr_err(FW_BUG "cpu %d, failed to "
+					       "setup threshold interrupt "
+					       "for bank %d, block %d "
+					       "(MSR%08X=0x%x%08x)",
+					       smp_processor_id(), bank, block,
+					       address, high, low);
+					continue;
+				}
+				lvt_off = offset;
+			} else if (lvt_off != offset) {
+				pr_err(FW_BUG "cpu %d, invalid threshold "
+				       "interrupt offset %d for bank %d,"
+				       "block %d (MSR%08X=0x%x%08x)",
+				       smp_processor_id(), lvt_off, bank,
+				       block, address, high, low);
+				continue;
+			}
 
 			high &= ~MASK_LVTOFF_HI;
 			high |= lvt_off << 20;
arch/x86/oprofile/op_model_amd.c +127 -18

198 lines not on this page · raw message