On 9/9/26 17:14, Tom Lendacky wrote:
> On 9/2/26 10:06, Gerd Hoffmann wrote:
>>   Hi,
>>
>>> Commit 7735ed4f8eb3afaf1a97d27a8862f382c387f0bc
>>> ("OvmfPkg/PlatformInitLib: Set dynamic MMIO window size to 1/4")
>>> breaks boot for both SEV-ES and SEV-SNP guests. The guest never reaches
>>> the OS; firmware stops after binding the virtio-blk device.
>>
>>> Found Mass Storage device: PciRoot(0x0)/Pci(0x2,0x0)/Pci(0x0,0x0)
>>> InstallProtocolInterface: FA920010-6785-4941-B6EC-498C579F160A 7DD42020
>>
>> Reproduces with any kind of virtio device.
>>
>>> qemu-system-x86_64: Convert non guest_memfd backed memory region
>>> (0x8040000000 ,+ 0x1000) to private
>>
>>> 2026-08-27 03:16:02: MMIO using encrypted memory: 8040000014
>>
>> Hmm.  So the patch moves the mmio window around and makes it larger:
>>
>> -PlatformDynamicMmioWindow:   MMIO Space 0x2000000000 (128 GB)
>> +PlatformDynamicMmioWindow:   MMIO Space 0x4000000000 (256 GB)
>>
>> -PlatformDynamicMmioWindow:   Pci64 Base 0xC000000000
>> -PlatformDynamicMmioWindow:   Pci64 Size 0x2000000000
>> +PlatformDynamicMmioWindow:   Pci64 Base 0x8000000000
>> +PlatformDynamicMmioWindow:   Pci64 Size 0x4000000000
>>
>> In both cases the region is covered by an
>> MemEncryptSevClearMmioPageEncMask call, so the encryption bit
>> should not be set.  The error messages suggest it is set though.
>> There is absolutely no difference in the logs beside the changed
>> address and size.
>>
>> Test branch with some debug logging is here:
>> https://github.com/kraxel/edk2/commits/devel/sev-regression/
>>
>> The branch also has patches explicitly tagging the 64-bit pci
>> mmio window as mmio region.  Noticed this is not the case while
>> looking into this.  That change doesn't make any difference in
>> behavior though.
>>
>> Tom?  Any clue what this might be?  Maybe something in the page
>> table code?  IIRC you have a branch switching the home-grown
>> sev page table code to use CpuPageTableLib instead, maybe this
>> fixes the issue?
> 
> I rebased my CpuPageTableLib patch series on the main branch and it did
> work.
> 
> I did some instrumenting and the range from 180000000 to 0xFB80000000 is
> setup as a series of 1G pages all with the encryption bit cleared. When
> I dump the pagetable entry at the moment before the crash I see that
> particular entry has been split into 2M pages with the encryption bit
> set - which leads to the issue.
> 
> It looks like there's a bug in SetMemoryEncDec() and how it tries to
> mark page tables as read-only. Because the MMIO range now exceeds 512G,
> the call to EnablePageTableProtection() isn't pointing at the base of
> the page table and SetPageTablePoolReadOnly() is using an index value as
> if it is.
> 
> I'll post a fix shortly. FYI, the reason why my CpuPageTableLib patch
> series works is because I changed how the pagetable read-only protection
> was done.

Submitted pull request 13108:
  https://github.com/tianocore/edk2/pull/13108

> 
> Thanks,
> Tom
> 
>>
>> take care,
>>   Gerd
>>
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#122161): https://edk2.groups.io/g/devel/message/122161
Mute This Topic: https://groups.io/mt/120969895/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to