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: lijiang@redhat.com, mingo@kernel.org, tglx@linutronix.de,
bp@suse.de, akpm@linux-foundation.org, thomas.lendacky@amd.com,
kirill.shutemov@linux.intel.com, hpa@zytor.com,
linux-kernel@vger.kernel.org, x86@kernel.org,
brijesh.singh@amd.com, mingo@redhat.com
Subject: [tip:x86/kdump] x86/kexec: Do not map kexec area as decrypted when SEV is active
Date: Thu, 20 Jun 2019 03:01:52 -0700 [thread overview]
Message-ID: <tip-1a79c1b8a04153c4c387518967ce851f89e22733@git.kernel.org> (raw)
In-Reply-To: <20190430074421.7852-2-lijiang@redhat.com>
Commit-ID: 1a79c1b8a04153c4c387518967ce851f89e22733
Gitweb: https://git.kernel.org/tip/1a79c1b8a04153c4c387518967ce851f89e22733
Author: Lianbo Jiang <lijiang@redhat.com>
AuthorDate: Tue, 30 Apr 2019 15:44:19 +0800
Committer: Borislav Petkov <bp@suse.de>
CommitDate: Thu, 20 Jun 2019 10:06:46 +0200
x86/kexec: Do not map kexec area as decrypted when SEV is active
When a virtual machine panics, its memory needs to be dumped for
analysis. With memory encryption in the picture, special care must be
taken when loading a kexec/kdump kernel in a SEV guest.
A SEV guest starts and runs fully encrypted. In order to load a kexec
kernel and initrd, arch_kexec_post_{alloc,free}_pages() need to not map
areas as decrypted unconditionally but differentiate whether the kernel
is running as a SEV guest and if so, leave kexec area encrypted.
[ bp: Reduce commit message to the relevant information pertaining to
this commit only. ]
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: Brijesh Singh <brijesh.singh@amd.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-2-lijiang@redhat.com
---
arch/x86/kernel/machine_kexec_64.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index ceba408ea982..3b38449028e0 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -559,8 +559,20 @@ void arch_kexec_unprotect_crashkres(void)
kexec_mark_crashkres(false);
}
+/*
+ * During a traditional boot under SME, SME will encrypt the kernel,
+ * so the SME kexec kernel also needs to be un-encrypted in order to
+ * replicate a normal SME boot.
+ *
+ * During a traditional boot under SEV, the kernel has already been
+ * loaded encrypted, so the SEV kexec kernel needs to be encrypted in
+ * order to replicate a normal SEV boot.
+ */
int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, gfp_t gfp)
{
+ if (sev_active())
+ return 0;
+
/*
* If SME is active we need to be sure that kexec pages are
* not encrypted because when we boot to the new kernel the
@@ -571,6 +583,9 @@ int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, gfp_t gfp)
void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages)
{
+ if (sev_active())
+ return;
+
/*
* If SME is active we need to reset the pages back to being
* an encrypted mapping before freeing them.
next prev parent reply other threads:[~2019-06-20 10:02 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-bot for Lianbo Jiang [this message]
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:x86/kdump] " tip-bot for Lianbo Jiang
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-1a79c1b8a04153c4c387518967ce851f89e22733@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: Do not map kexec area as decrypted 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).