[lkml]   [2019]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v3 2/3] x86/kexec/64: Error out if try to jump to old 4-level kernel from 5-level kernel
On Tue, 12 Mar 2019, Baoquan He wrote:

> In relocate_kernel() CR4.LA57 flag is set before kexec jumping if
> the kernel has 5-level paging enabled. Then in boot/compressed/head_64.S,
> it will check if the booting kernel is in 4-level or 5-level paging
> mode, and handle accordingly. However, the old kernel which doesn't
> contain the 5-level codes doesn't know how to cope with it, then #GP
> triggered.

The above is more than confusing. I assume you want to say:

If the running kernel has 5-level paging activated, the 5-level paging
mode is preserved across kexec. If the kexec'ed kernel does not contain
support for handling active 5-level paging mode in the decompressor, the
decompressor will crash with #GP.

> Instead of triggering #GP during kexec kernel boot, error out during
> kexec loading if find out we are trying to jump to old 4-level kernel
> from 5-level kernel.

Prevent this situation at load time. If 5-level paging is active, check the
xloadflags whether the kexec kernel can handle 5-level paging at least in
the decompressor. If not, reject the load attempt.

> Signed-off-by: Baoquan He <>
> Acked-by: Kirill A. Shutemov <>
> ---
> arch/x86/kernel/kexec-bzimage64.c | 5 +++++
> 1 file changed, 5 insertions(+)
> diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
> index 1f3b77367948..4c9c079b5673 100644
> --- a/arch/x86/kernel/kexec-bzimage64.c
> +++ b/arch/x86/kernel/kexec-bzimage64.c
> @@ -321,6 +321,11 @@ static int bzImage64_probe(const char *buf, unsigned long len)
> return ret;
> }
> + if (!(header->xloadflags & XLF_5LEVEL) && pgtable_l5_enabled()) {
> + pr_err("Can not jump to old 4-level kernel from 5-level kernel.\n");

This is confusing at best.

"bzImage cannot handle 5-level paging mode\n"

or something like this.

> + return ret;



 \ /
  Last update: 2019-04-05 22:39    [W:0.062 / U:0.188 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site