Page MenuHomeFreeBSD

EFIRT: SetVirtualAddressMap with 1:1 mapping after exiting boot services
ClosedPublic

Authored by kevans on Mar 13 2018, 1:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 22 2024, 3:23 PM
Unknown Object (File)
Nov 21 2024, 7:33 AM
Unknown Object (File)
Nov 17 2024, 7:41 PM
Unknown Object (File)
Nov 9 2024, 1:55 PM
Unknown Object (File)
Nov 7 2024, 6:02 PM
Unknown Object (File)
Nov 3 2024, 12:24 PM
Unknown Object (File)
Oct 28 2024, 11:06 PM
Unknown Object (File)
Oct 25 2024, 1:58 AM
Subscribers

Details

Summary

This fixes a problem encountered on the Thinkpad X220/Yoga 11e where runtime services would try to inexplicably jump to other parts of memory where it shouldn't be when attempting to enumerate EFI vars, causing a panic.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

stand/efi/loader/bootinfo.c
249

We already have NextMemoryDescriptor() macro.

259

Copy the whole structure, it is simpler IMO. Also you may assign to desc->VirtualStart before, then you only need to do it once.

358

A variable to request not calling SetVirtualAddressMap() might be useful.

Address feedback by @kib:

  • Use already defined NextMemoryDescriptor
  • Set VA = PA then memcpy whole descriptor
  • Allow efi_disable_vmap to be set in loader.conf(5) to disable virtual mapping
kevans added inline comments.
stand/efi/loader/bootinfo.c
249

I swear that wasn't there when I was throwing this together last night.

kib added inline comments.
stand/efi/loader/bootinfo.c
243

Why not put all three on the same line ?

259

*viter = *desc;

This revision is now accepted and ready to land.Mar 13 2018, 2:19 PM
kevans added inline comments.
stand/efi/loader/bootinfo.c
259

I wasn't sure if this was OK or not- mmsz seems to be larger than sizeof(*desc), and I wasn't sure if the excess was just padding or firmware-specific bits that should be preserved.

stand/efi/loader/bootinfo.c
259

Ok.

Address a couple more concerns:

  • Consolidate desc, viter, vmap declarations
  • Just set *viter = *desc; I thought I had observed that mmsz > sizeof(*desc) in early testing yesterday, but mmsz is explicitly set to sizeof(EFI_MEMORY_DESCRIPTOR)...
  • Don't use implicit boolean tresting for (attribute & EFI_MEMORY_RUNTIME)
This revision now requires review to proceed.Mar 13 2018, 2:46 PM
This revision was not accepted when it landed; it landed in state Needs Review.Mar 13 2018, 5:11 PM
This revision was automatically updated to reflect the committed changes.