EFI: Only set regions uncacheable if they support it
PATCH 1/1 EFI: Only set regions uncacheable if they support it
The EFI memory region attributes field indicates whether the region can be mapped with various cache attributes. Our current implementation always marks regions uncacheable if they don't have the writeback support flag. This causes us to mark some regions uncacheable even if they don't indicate support for being uncacheable, triggering a clflush that may cause an MCE. Ensure we only do this for regions which support it.
--- arch/x86/platform/efi/efi.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/platform/efi/efi.c +2 -1
@@ -682,7 +682,8 @@ void __init efi_enter_virtual_mode(void)continue ; } -if (!(md->attribute &EFI_MEMORY_WB )) { +if (md->attribute &EFI_MEMORY_UC && + !(md->attribute &EFI_MEMORY_WB )) { addr = md->virt_addr; npages = md->num_pages;memrange_efi_to_native (&addr, &npages);
Signature · 1 line
1.7.7.6
H. Peter Anvin
reviewerQuoted 8 lines · Matthew Garrett
The EFI memory region attributes field indicates whether the region can be mapped with various cache attributes. Our current implementation always marks regions uncacheable if they don't have the writeback support flag. This causes us to mark some regions uncacheable even if they don't indicate support for being uncacheable, triggering a clflush that may cause an MCE. Ensure we only do this for regions which support it.
Signed-off-by Matthew Garrett <[email protected]>
Could you be specific as to what you're seeing in the field? In particular, what *do* these memory regions claim to support?
-hpa
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines · Matthew Garrett
The EFI memory region attributes field indicates whether the region can be mapped with various cache attributes. Our current implementation always marks regions uncacheable if they don't have the writeback support flag. This causes us to mark some regions uncacheable even if they don't indicate support for being uncacheable, triggering a clflush that may cause an MCE. Ensure we only do this for regions which support it.
Quoted 4 lines
Quoted 1 line
Signed-off-by Matthew Garrett <[email protected]>Could you be specific as to what you're seeing in the field? In particular, what *do* these memory regions claim to support?
I have a report of a system that fails to boot with an MCE during EFI setup. The memory range is marked reserved and claims not to support any caching type, which I think probably translates as "Don't do anything to this region ever".
Signature · 1 line
Matthew Garrett | [email protected]
H. Peter Anvin
reviewerQuoted 6 lines · Matthew Garrett
I have a report of a system that fails to boot with an MCE during EFI setup. The memory range is marked reserved and claims not to support any caching type, which I think probably translates as "Don't do anything to this region ever".
In other words, "don't map me"... not something we really support at the moment, but perhaps we should; at least until we find systems in the field that break with that constraint :(
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Quoted 11 lines · H. Peter Anvin
Quoted 6 lines · Matthew Garrett
I have a report of a system that fails to boot with an MCE during EFI setup. The memory range is marked reserved and claims not to support any caching type, which I think probably translates as "Don't do anything to this region ever".
In other words, "don't map me"... not something we really support at the moment, but perhaps we should; at least until we find systems in the field that break with that constraint :(
Mapping should be harmless as long as we then don't touch it? I can't think of any circumstances where we would.
Signature · 1 line
Matthew Garrett | [email protected]
H. Peter Anvin
reviewerQuoted 9 lines · Matthew Garrett
Quoted 8 lines · H. Peter Anvin
Quoted 6 lines · Matthew Garrett
I have a report of a system that fails to boot with an MCE during EFI setup. The memory range is marked reserved and claims not to support any caching type, which I think probably translates as "Don't do anything to this region ever".
Quoted 7 lines
Quoted 3 lines
In other words, "don't map me"... not something we really support at the moment, but perhaps we should; at least until we find systems in the field that break with that constraint :(
Mapping should be harmless as long as we then don't touch it? I can't think of any circumstances where we would.
If we map it WB software can do speculative loads from that region which would bring it into the cache. If we map it UC we might have to CLFLUSH...
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Quoted 6 lines · H. Peter Anvin
Quoted 5 lines · Matthew Garrett
Quoted 3 lines · H. Peter Anvin
In other words, "don't map me"... not something we really support at the moment, but perhaps we should; at least until we find systems in the field that break with that constraint :(
Quoted 6 lines
Quoted 3 lines
Mapping should be harmless as long as we then don't touch it? I can't think of any circumstances where we would.
If we map it WB software can do speculative loads from that region which would bring it into the cache. If we map it UC we might have to CLFLUSH...
We've already mapped it at this point - we then go back and flag it UC if it's not writeback. The latter seems to be causing problems, I'm not sure we've seen any indication that the former is. And these regions are marked as runtime accessible, so per spec they do need to be mapped into address space...
Signature · 1 line
Matthew Garrett | [email protected]
H. Peter Anvin
reviewerQuoted 10 lines · Matthew Garrett
Quoted 3 lines
If we map it WB software can do speculative loads from that region which would bring it into the cache. If we map it UC we might have to CLFLUSH...
We've already mapped it at this point - we then go back and flag it UC if it's not writeback. The latter seems to be causing problems, I'm not sure we've seen any indication that the former is. And these regions are marked as runtime accessible, so per spec they do need to be mapped into address space...
In other words, it's totally f*cked. I guess at that point mapping it WB and letting the BIOS-configured MTRRs deal with the caching attributes is probably the right thing to do.
I would still really like to understand why we're seeing #MCs... that's bothersome all by itself.
-hpa
Quoted 2 lines · H. Peter Anvin
I would still really like to understand why we're seeing #MCs... that's bothersome all by itself.
The region is the legacy video RAM, so I can imagine there being something magic about it.
Signature · 1 line
Matthew Garrett | [email protected]
H. Peter Anvin
reviewerQuoted 8 lines · Matthew Garrett
Quoted 2 lines · H. Peter Anvin
I would still really like to understand why we're seeing #MCs... that's bothersome all by itself.
The region is the legacy video RAM, so I can imagine there being something magic about it.
WTF?! That should be UC at all times... it isn't even WC-capable. Furthermore, we may need this region (assuming there is actually a video card there.)
What do the fixed MTRRs look like?
-hpa
Quoted 3 lines · H. Peter Anvin
WTF?! That should be UC at all times... it isn't even WC-capable. Furthermore, we may need this region (assuming there is actually a video card there.)
I don't think we'll ever use this region on UEFI. What I have from Intel is:
"It looks like this is happening when the kernel iterates over the various regions in the EFI memory map. It hits a region starting at 0xA0000 and attempts to do a CLFLUSH instruction on that address. This is explicitly forbidden by the SAD in (codename), thus the Machine Check."
Quoted 1 line
What do the fixed MTRRs look like?
Unsure. I'll try to find out.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 7 lines · On Thu, 15 Mar 2012 14:42:36 +0000 Matthew Garrett <[email protected]> wrote:
Quoted 2 lines · H. Peter Anvin
I would still really like to understand why we're seeing #MCs... that's bothersome all by itself.
The region is the legacy video RAM, so I can imagine there being something magic about it.
Presumably by the point we are booting the firmware and our own early activities mean the pages are already marked write-combine and in our CPU caches somewhere. Is the current boot code flushing any legacy video mappings from cache before it plays with the cachability ?
Alan
Quoted 7 lines · On Thu, 15 Mar 2012 14:42:36 +0000 Matthew Garrett <[email protected]> wrote:
Quoted 2 lines · H. Peter Anvin
I would still really like to understand why we're seeing #MCs... that's bothersome all by itself.
The region is the legacy video RAM, so I can imagine there being something magic about it.
What hardware platforms are afflicted by this btw ?