From: lijiang <lijiang@redhat.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Thomas.Lendacky@amd.com, brijesh.singh@amd.com, bhe@redhat.com,
x86@kernel.org, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org, mingo@redhat.com, hpa@zytor.com,
tglx@linutronix.de, dyoung@redhat.com, akpm@linux-foundation.org
Subject: Re: [PATCH 2/3 v3] x86/kexec: Set the C-bit in the identity map page table when SEV is active
Date: Thu, 16 May 2019 09:12:26 +0800 [thread overview]
Message-ID: <4707fb2d-b7d3-34e3-a488-8aa9bdca05f1@redhat.com> (raw)
In-Reply-To: <20190515133006.GG24212@zn.tnic>
在 2019年05月15日 21:30, Borislav Petkov 写道:
> On Tue, Apr 30, 2019 at 03:44:20PM +0800, Lianbo Jiang wrote:
>> When SEV is active, the second kernel image is loaded into the
>> encrypted memory. Lets make sure that when kexec builds the
>> identity mapping page table it adds the memory encryption mask(C-bit).
>>
>> Co-developed-by: Brijesh Singh <brijesh.singh@amd.com>
>> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
>> Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
>> ---
>> arch/x86/kernel/machine_kexec_64.c | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
>> index f60611531d17..11fe352f7344 100644
>> --- a/arch/x86/kernel/machine_kexec_64.c
>> +++ b/arch/x86/kernel/machine_kexec_64.c
>> @@ -56,6 +56,7 @@ static int init_transition_pgtable(struct kimage *image, pgd_t *pgd)
>> pte_t *pte;
>> unsigned long vaddr, paddr;
>> int result = -ENOMEM;
>> + pgprot_t prot = PAGE_KERNEL_EXEC_NOENC;
>>
>> vaddr = (unsigned long)relocate_kernel;
>> paddr = __pa(page_address(image->control_code_page)+PAGE_SIZE);
>> @@ -92,7 +93,11 @@ static int init_transition_pgtable(struct kimage *image, pgd_t *pgd)
>> set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
>> }
>> pte = pte_offset_kernel(pmd, vaddr);
>> - set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, PAGE_KERNEL_EXEC_NOENC));
>> +
>> + if (sev_active())
>> + prot = PAGE_KERNEL_EXEC;
>> +
>> + set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, prot));
>> return 0;
>> err:
>> return result;
>> @@ -129,6 +134,11 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
>> level4p = (pgd_t *)__va(start_pgtable);
>> clear_page(level4p);
>>
>> + if (sev_active()) {
>> + info.page_flag |= _PAGE_ENC;
>> + info.kernpg_flag = _KERNPG_TABLE;
>
> kernpg_flag above is initialized to _KERNPG_TABLE_NOENC so you can do here
>
> info.kernpg_flag |= _PAGE_ENC;
>
> too, to make it even more clear what this does, right?
>
OK, i will modify it according to your suggestion and post again.
Thanks.
Lianbo
> IOW:
>
> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
> index 783ce5184405..16c37fe489bc 100644
> --- a/arch/x86/kernel/machine_kexec_64.c
> +++ b/arch/x86/kernel/machine_kexec_64.c
> @@ -135,8 +135,8 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
> clear_page(level4p);
>
> if (sev_active()) {
> - info.page_flag |= _PAGE_ENC;
> - info.kernpg_flag = _KERNPG_TABLE;
> + info.page_flag |= _PAGE_ENC;
> + info.kernpg_flag |= _PAGE_ENC;
> }
>
> if (direct_gbpages)
>
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2019-05-16 1:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 7:44 [PATCH 0/3 v3] Add kdump support for the SEV enabled guest Lianbo Jiang
2019-04-30 7:44 ` [PATCH 1/3 v3] x86/kexec: Do not map the kexec area as decrypted when SEV is active Lianbo Jiang
2019-04-30 7:44 ` [PATCH 2/3 v3] x86/kexec: Set the C-bit in the identity map page table " Lianbo Jiang
2019-05-15 13:30 ` Borislav Petkov
2019-05-16 1:12 ` lijiang [this message]
2019-05-16 8:15 ` Boris Petkov
2019-05-16 11:35 ` lijiang
2019-06-12 1:34 ` lijiang
2019-04-30 7:44 ` [PATCH 3/3 v3] kdump, proc/vmcore: Enable dumping encrypted memory when SEV was active Lianbo Jiang
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=4707fb2d-b7d3-34e3-a488-8aa9bdca05f1@redhat.com \
--to=lijiang@redhat.com \
--cc=Thomas.Lendacky@amd.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=dyoung@redhat.com \
--cc=hpa@zytor.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--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