Re: Does earlyprintk=ttyS0 work for an AMD SNP guest on KVM?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16/02/2023 18:58, Dexuan Cui wrote:
>> From: Jeremi Piotrowski <jpiotrowski@xxxxxxxxxxxxxxxxxxx>
>> Sent: Thursday, February 16, 2023 1:15 AM
>>> ...
>>> alloc_pgt_page() fails to allocate memory because both
>>> pages->pgt_buf_offset and pages->pgt_buf_size are zero.
>>>
>>>
>>> pgt_data.pgt_buf_size is zero because of this line in
>>> initialize_identity_maps()
>>>      pgt_data.pgt_buf_size = BOOT_PGT_SIZE - BOOT_INIT_PGT_SIZE;
>>>
>>> void initialize_identity_maps(void *rmode)
>>> {
>>> ...
>>>         top_level_pgt = read_cr3_pa();
>>>         if (p4d_offset((pgd_t *)top_level_pgt, 0) == (p4d_t *)_pgtable) {
>>>                 pgt_data.pgt_buf = _pgtable + BOOT_INIT_PGT_SIZE;
>>>                 pgt_data.pgt_buf_size = BOOT_PGT_SIZE -
>>> BOOT_INIT_PGT_SIZE;
>>>                 memset(pgt_data.pgt_buf, 0, pgt_data.pgt_buf_size);
>>>         } else {
>>>                 pgt_data.pgt_buf = _pgtable;
>>>                 pgt_data.pgt_buf_size = BOOT_PGT_SIZE;
>>>                 memset(pgt_data.pgt_buf, 0, pgt_data.pgt_buf_size);
>>>                 top_level_pgt = (unsigned
>>> long)alloc_pgt_page(&pgt_data);
>>
>> I just tested an SNP guest on KVM with and without
>> CONFIG_RANDOMIZE_BASE.
>> In both cases we end up in the else() branch.
>> With CONFIG_RANDOMIZE_BASE BOOT_PGT_SIZE=0x13000
>> Without CONFIG_RANDOMMIZE_BASE BOOT_PGT_SIZE=0x6000.
>>
>> So in both cases pgt_data.pgt_buf_size != 0.
>>
>> Getting into that first branch would require having 5-level paging supported
>> (CONFIG_X86_5LEVEL=y) and enabled inside the guest, I don't have that on
>> any
>> hardware I have access to.
>>
>> Jeremi
> 
> CONFIG_X86_5LEVEL is not set for my kernel.
> 
> The comment before the first branch says:
>   On 4-level paging, p4d_offset(top_level_pgt, 0) is equal to 'top_level_pgt'.
> 
> IIUC this means 'top_level_pgt' is equal to '_pgtable'? i.e. without 
> CONFIG_RANDOMIZE_BASE, pgt_data.pgt_buf_size should be 0.
> 
> Not sure why it's not getting into the first branch for you.

Sorry, I got two things confused here. The relevant part of the comment is this:
"If we came here via startup_32(), cr3 will be _pgtable already".

Booting a (non-SNP) guest via BIOS I end up in the first branch. Upstream SNP support
requires OVMF (UEFI) so we'll always reach the kernel in 64-bit mode (startup_64?),
and end up in the second branch.

Jeremi



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux