Skip to contentSkip to conversation

x86/mcheck: keep the banks past the end of the CMCI map polled

PATCH Superseded Stefano Stabellini 2 participants 3 messages Oct 27

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mcheck: keep the banks past the end of the CMCI map polled

bitmap_copy() copies whole words, so in set_poll_bankmask() it clears the banks past the end of the CMCI map that bitmap_fill() had just set, leaving them neither polled nor reported by CMCI. Set those bits after the copy instead.

Fixes 560cf418c845 ("x86/mcheck: allow varying bank counts per CPU")
---
 xen/arch/x86/cpu/mcheck/mce.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
xen/arch/x86/cpu/mcheck/mce.c +7 -2
index 1888f22d15..f9a1389516 100644
@@ -621,9 +621,14 @@ static void set_poll_bankmask(struct cpuinfo_x86 *c)
     {
         const struct mca_banks *cmci = per_cpu(no_cmci_banks, cpu);
 
-        if ( unlikely(cmci->num < mb->num) )
-            bitmap_fill(mb->bank_map, mb->num);
         bitmap_copy(mb->bank_map, cmci->bank_map, min(mb->num, cmci->num));
+        /*
+         * Banks past the end of the CMCI map are not reported by CMCI
+         * either, so they need polling.  Set them after the copy, which
+         * works in whole words and would otherwise clear them again.
+         */
+        if ( unlikely(cmci->num < mb->num) )
+            bitmap_set(mb->bank_map, cmci->num, mb->num - cmci->num);
     }
     else
     {
Signature · 1 line
2.47.3
#1 lore raw
Quoted 4 lines · Stefano Stabellini

bitmap_copy() copies whole words, so in set_poll_bankmask() it clears the banks past the end of the CMCI map that bitmap_fill() had just set, leaving them neither polled nor reported by CMCI. Set those bits after the copy instead.

May I suggest

"bitmap_copy() copies whole words, so in set_poll_bankmask() it may clear
banks past the end of the CMCI map that bitmap_fill() may just have set, leaving them neither polled nor reported by CMCI. Set those bits after the copy instead."

Quoted 4 lines
Fixes 560cf418c845 ("x86/mcheck: allow varying bank counts per CPU")

No further tags needed, as it looks.

Jan

#2 lore raw

PATCH v2 1/1 x86/mcheck: keep the banks past the end of the CMCI map polled

In reply to Stefano Stabellini

bitmap_copy() copies whole words, so in set_poll_bankmask() it may clear banks past the end of the CMCI map that bitmap_fill() may just have set, leaving them neither polled nor reported by CMCI. Set those bits after the copy instead.

Fixes 560cf418c845 ("x86/mcheck: allow varying bank counts per CPU")

---
v2:
- reword the commit message as suggested by Jan

---
 xen/arch/x86/cpu/mcheck/mce.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
xen/arch/x86/cpu/mcheck/mce.c +7 -2
index 1888f22d15..f9a1389516 100644
@@ -621,9 +621,14 @@ static void set_poll_bankmask(struct cpuinfo_x86 *c)
     {
         const struct mca_banks *cmci = per_cpu(no_cmci_banks, cpu);
 
-        if ( unlikely(cmci->num < mb->num) )
-            bitmap_fill(mb->bank_map, mb->num);
         bitmap_copy(mb->bank_map, cmci->bank_map, min(mb->num, cmci->num));
+        /*
+         * Banks past the end of the CMCI map are not reported by CMCI
+         * either, so they need polling.  Set them after the copy, which
+         * works in whole words and would otherwise clear them again.
+         */
+        if ( unlikely(cmci->num < mb->num) )
+            bitmap_set(mb->bank_map, cmci->num, mb->num - cmci->num);
     }
     else
     {
Signature · 1 line
2.47.3