Skip to contentSkip to conversation

x86/mm, mm/hwpoison: fix unmap kernel 1:1 pages

PATCH In review luofei 3 participants 5 messages Feb 7, 2022 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

luofei

author
#0 lore raw

PATCH 1/1 x86/mm, mm/hwpoison: fix unmap kernel 1:1 pages

Only unmap the page when the memory error is properly handled by calling memory_failure(), not the other way around.

Fixes 26f8c38bb466("x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages")
---
 arch/x86/kernel/cpu/mcheck/mce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce.c +1 -1
index 95c09db1bba2..d8399a689165 100644
@@ -589,7 +589,7 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
 
 	if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) {
 		pfn = mce->addr >> PAGE_SHIFT;
-		if (memory_failure(pfn, MCE_VECTOR, 0))
+		if (!memory_failure(pfn, MCE_VECTOR, 0))
 			mce_unmap_kpfn(pfn);
 	}
 
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 4 lines · luofei

Only unmap the page when the memory error is properly handled by calling memory_failure(), not the other way around.

Fixes 26f8c38bb466("x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages")

This commit is not in Linus's tree. Please use the correct commit id.

thanks,

greg k-h

maintainer
#2 lore raw
Quoted 7 lines · Greg KH
Quoted 4 lines · luofei

Only unmap the page when the memory error is properly handled by calling memory_failure(), not the other way around.

Fixes 26f8c38bb466("x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages")

This commit is not in Linus's tree. Please use the correct commit id.

I think he's trying to fix the backport:

see 26f8c38bb466c1a2d232d7609fb4bfb4bc121678 which is the stable tree backport:

@@ -582,7 +586,8 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,

        if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) {
                pfn = mce->addr >> PAGE_SHIFT;
-               memory_failure(pfn, MCE_VECTOR, 0);
+               if (memory_failure(pfn, MCE_VECTOR, 0))
+                       mce_unmap_kpfn(pfn);
        }

vs the upstream commit:

fd0e786d9d09024f67bd71ec094b110237dc3840

@@ -590,7 +594,8 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,

        if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) {
                pfn = mce->addr >> PAGE_SHIFT;
-               memory_failure(pfn, 0);
+               if (!memory_failure(pfn, 0))
+                       mce_unmap_kpfn(pfn);
        }
 
        return NOTIFY_OK;
Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#3 lore raw
Quoted 29 lines · Borislav Petkov
Quoted 7 lines · Greg KH
Quoted 4 lines · luofei

Only unmap the page when the memory error is properly handled by calling memory_failure(), not the other way around.

Fixes 26f8c38bb466("x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages")

This commit is not in Linus's tree. Please use the correct commit id.

I think he's trying to fix the backport:

see 26f8c38bb466c1a2d232d7609fb4bfb4bc121678 which is the stable tree backport:

arch/x86/kernel/cpu/mcheck/mce.c +2 -1
@@ -582,7 +586,8 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
 
        if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) {
                pfn = mce->addr >> PAGE_SHIFT;
-               memory_failure(pfn, MCE_VECTOR, 0);
+               if (memory_failure(pfn, MCE_VECTOR, 0))
+                       mce_unmap_kpfn(pfn);
        }
 
 

vs the upstream commit:

fd0e786d9d09024f67bd71ec094b110237dc3840

arch/x86/kernel/cpu/mcheck/mce.c static int srao_decode_notifier(struct notifier_block *nb, unsigned long val, · line 601

Quoted 9 lines
arch/x86/kernel/cpu/mcheck/mce.c +2 -1
@@ -590,7 +594,8 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
 
        if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) {
                pfn = mce->addr >> PAGE_SHIFT;
-               memory_failure(pfn, 0);
+               if (!memory_failure(pfn, 0))
+                       mce_unmap_kpfn(pfn);
        }
 
        return NOTIFY_OK;

Ah, ok, if so, this needs to be documented really really well in the changelog text so no one is confused. Like me :)

thanks,

greg k-h

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#5 lore raw
Quoted 27 lines · 罗飞
Quoted 27 lines

I think he's trying to fix the backport:

see 26f8c38bb466c1a2d232d7609fb4bfb4bc121678 which is the stable tree backport:

arch/x86/kernel/cpu/mcheck/mce.c +2 -1
@@ -582,7 +586,8 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
 
      if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) {
              pfn = mce->addr >> PAGE_SHIFT;
-               memory_failure(pfn, MCE_VECTOR, 0);
+               if (memory_failure(pfn, MCE_VECTOR, 0))
+                       mce_unmap_kpfn(pfn);
      }
 
 

vs the upstream commit:

fd0e786d9d09024f67bd71ec094b110237dc3840

arch/x86/kernel/cpu/mcheck/mce.c +2 -1
@@ -590,7 +594,8 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
 
       if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) {
              pfn = mce->addr >> PAGE_SHIFT;
-               memory_failure(pfn, 0);
+               if (!memory_failure(pfn, 0))
+                       mce_unmap_kpfn(pfn);
      }
 
Quoted 4 lines

Review static int srao_decode_notifier(struct notifier_block *nb, unsigned long val, · line 601

Quoted 1 line
(quoted diff) +0 -0
       return NOTIFY_OK;

Sorry for my not familiar with submitting patches to stable kernel tree, and here Borislav Petkov said exactly what I meant

Great, can you please resend this and document what this patch is doing and why it is not in upstream and why is it needed only in this one branch?

thanks,

greg k-h