LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: tip-bot for Lianbo Jiang <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, thomas.lendacky@amd.com, tglx@linutronix.de,
x86@kernel.org, hpa@zytor.com, bp@suse.de, lijiang@redhat.com,
mingo@redhat.com, brijesh.singh@amd.com,
kirill.shutemov@linux.intel.com, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: [tip:x86/kdump] x86/kexec: Set the C-bit in the identity map page table when SEV is active
Date: Thu, 20 Jun 2019 03:02:34 -0700 [thread overview]
Message-ID: <tip-85784d16c2cf172cf1ebaf2390d6b7c4045d659c@git.kernel.org> (raw)
In-Reply-To: <20190430074421.7852-3-lijiang@redhat.com>
Commit-ID: 85784d16c2cf172cf1ebaf2390d6b7c4045d659c
Gitweb: https://git.kernel.org/tip/85784d16c2cf172cf1ebaf2390d6b7c4045d659c
Author: Lianbo Jiang <lijiang@redhat.com>
AuthorDate: Tue, 30 Apr 2019 15:44:20 +0800
Committer: Borislav Petkov <bp@suse.de>
CommitDate: Thu, 20 Jun 2019 10:07:12 +0200
x86/kexec: Set the C-bit in the identity map page table when SEV is active
When SEV is active, the second kernel image is loaded into encrypted
memory. For that, make sure that when kexec builds the identity mapping
page table, the memory is encrypted (i.e., _PAGE_ENC is set).
[ bp: Sort local args and OR in _PAGE_ENC for more clarity. ]
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>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: bhe@redhat.com
Cc: dyoung@redhat.com
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: kexec@lists.infradead.org
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190430074421.7852-3-lijiang@redhat.com
---
arch/x86/kernel/machine_kexec_64.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 3b38449028e0..16c37fe489bc 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -50,12 +50,13 @@ static void free_transition_pgtable(struct kimage *image)
static int init_transition_pgtable(struct kimage *image, pgd_t *pgd)
{
+ pgprot_t prot = PAGE_KERNEL_EXEC_NOENC;
+ unsigned long vaddr, paddr;
+ int result = -ENOMEM;
p4d_t *p4d;
pud_t *pud;
pmd_t *pmd;
pte_t *pte;
- unsigned long vaddr, paddr;
- int result = -ENOMEM;
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 |= _PAGE_ENC;
+ }
+
if (direct_gbpages)
info.direct_gbpages = true;
next prev parent reply other threads:[~2019-06-20 10:03 UTC|newest]
Thread overview: 12+ 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-06-20 10:01 ` [tip:x86/kdump] x86/kexec: Do not map " tip-bot for 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
2019-05-16 8:15 ` Boris Petkov
2019-05-16 11:35 ` lijiang
2019-06-12 1:34 ` lijiang
2019-06-20 10:02 ` tip-bot for Lianbo Jiang [this message]
2019-04-30 7:44 ` [PATCH 3/3 v3] kdump,proc/vmcore: Enable dumping encrypted memory when SEV was active Lianbo Jiang
2019-06-20 10:03 ` [tip:x86/kdump] fs/proc/vmcore: Enable dumping of " tip-bot for 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=tip-85784d16c2cf172cf1ebaf2390d6b7c4045d659c@git.kernel.org \
--to=tipbot@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=bp@suse.de \
--cc=brijesh.singh@amd.com \
--cc=hpa@zytor.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=lijiang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
--subject='Re: [tip:x86/kdump] x86/kexec: Set the C-bit in the identity map page table when SEV is active' \
/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
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).