From: Dexuan Cui <decui@microsoft.com>
To: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
Borislav Petkov <bp@alien8.de>,
"sandipan.das@amd.com" <sandipan.das@amd.com>,
"Gupta, Pankaj" <pankaj.gupta@amd.com>,
"ray.huang@amd.com" <ray.huang@amd.com>,
"brijesh.singh@amd.com" <brijesh.singh@amd.com>,
"michael.roth@amd.com" <michael.roth@amd.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
Tianyu Lan <Tianyu.Lan@microsoft.com>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: Does earlyprintk=ttyS0 work for an AMD SNP guest on KVM?
Date: Thu, 16 Feb 2023 17:58:49 +0000 [thread overview]
Message-ID: <SA1PR21MB13358707043E2901958819AEBFA09@SA1PR21MB1335.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20230216091431.GA10166@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
> From: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
> 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.
next prev parent reply other threads:[~2023-02-16 17:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 4:40 Does earlyprintk=ttyS0 work for an AMD SNP guest on KVM? Dexuan Cui
2023-02-16 9:14 ` Jeremi Piotrowski
2023-02-16 17:58 ` Dexuan Cui [this message]
2023-02-17 12:51 ` Jeremi Piotrowski
2023-02-18 2:54 ` Dexuan Cui
2023-03-17 18:07 ` Tom Lendacky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SA1PR21MB13358707043E2901958819AEBFA09@SA1PR21MB1335.namprd21.prod.outlook.com \
--to=decui@microsoft.com \
--cc=Tianyu.Lan@microsoft.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=jpiotrowski@linux.microsoft.com \
--cc=kvm@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=pankaj.gupta@amd.com \
--cc=ray.huang@amd.com \
--cc=sandipan.das@amd.com \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).