Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1315189 > unrolled thread

[RFC PATCH] x86/head_64.S: remove redundant check that kernel address is 2M aligned

Started byAlexander Kuleshov <kuleshovmail@gmail.com>
First post2016-01-22 19:20 +0100
Last post2016-01-23 07:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RFC PATCH] x86/head_64.S: remove redundant check that kernel address is 2M aligned Alexander Kuleshov <kuleshovmail@gmail.com> - 2016-01-22 19:20 +0100
    Re: [RFC PATCH] x86/head_64.S: remove redundant check that kernel  address is 2M aligned Brian Gerst <brgerst@gmail.com> - 2016-01-23 02:50 +0100
      Re: [RFC PATCH] x86/head_64.S: remove redundant check that kernel  address is 2M aligned Alexander Kuleshov <kuleshovmail@gmail.com> - 2016-01-23 07:50 +0100

#1315189 — [RFC PATCH] x86/head_64.S: remove redundant check that kernel address is 2M aligned

FromAlexander Kuleshov <kuleshovmail@gmail.com>
Date2016-01-22 19:20 +0100
Subject[RFC PATCH] x86/head_64.S: remove redundant check that kernel address is 2M aligned
Message-ID<qTOtr-7NF-13@gated-at.bofh.it>
We check that the base address of the kernel is 2M aligned in
the arch/x86/kernel/head_65.S right after jump to the decompressed
kernel. But we already have a check in the decompress_kernel()
which validates that kernel location is MIN_KERNEL_ALIGN aligned
which is 2M too for x86_64.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 arch/x86/kernel/head_64.S | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index ffdc0e8..4967cba 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -75,12 +75,6 @@ startup_64:
 	leaq	_text(%rip), %rbp
 	subq	$_text - __START_KERNEL_map, %rbp
 
-	/* Is the address not 2M aligned? */
-	movq	%rbp, %rax
-	andl	$~PMD_PAGE_MASK, %eax
-	testl	%eax, %eax
-	jnz	bad_address
-
 	/*
 	 * Is the address too large?
 	 */
-- 
2.7.0.25.gfc10eb5

[toc] | [next] | [standalone]


#1315484 — Re: [RFC PATCH] x86/head_64.S: remove redundant check that kernel address is 2M aligned

FromBrian Gerst <brgerst@gmail.com>
Date2016-01-23 02:50 +0100
SubjectRe: [RFC PATCH] x86/head_64.S: remove redundant check that kernel address is 2M aligned
Message-ID<qTVuV-3XO-1@gated-at.bofh.it>
In reply to#1315189
On Fri, Jan 22, 2016 at 1:13 PM, Alexander Kuleshov
<kuleshovmail@gmail.com> wrote:
> We check that the base address of the kernel is 2M aligned in
> the arch/x86/kernel/head_65.S right after jump to the decompressed
> kernel. But we already have a check in the decompress_kernel()
> which validates that kernel location is MIN_KERNEL_ALIGN aligned
> which is 2M too for x86_64.
>
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
> ---
>  arch/x86/kernel/head_64.S | 6 ------
>  1 file changed, 6 deletions(-)
>
> diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
> index ffdc0e8..4967cba 100644
> --- a/arch/x86/kernel/head_64.S
> +++ b/arch/x86/kernel/head_64.S
> @@ -75,12 +75,6 @@ startup_64:
>         leaq    _text(%rip), %rbp
>         subq    $_text - __START_KERNEL_map, %rbp
>
> -       /* Is the address not 2M aligned? */
> -       movq    %rbp, %rax
> -       andl    $~PMD_PAGE_MASK, %eax
> -       testl   %eax, %eax
> -       jnz     bad_address
> -
>         /*
>          * Is the address too large?
>          */

I think we still need to do the check, in case we came from a 64-bit
bootloader that directly jumped to startup_64.  However, this check
can be simplified to:

    testl $~PMD_PAGE_MASK, %ebp
    jnz bad_address

--
Brian Gerst

[toc] | [prev] | [next] | [standalone]


#1315526 — Re: [RFC PATCH] x86/head_64.S: remove redundant check that kernel address is 2M aligned

FromAlexander Kuleshov <kuleshovmail@gmail.com>
Date2016-01-23 07:50 +0100
SubjectRe: [RFC PATCH] x86/head_64.S: remove redundant check that kernel address is 2M aligned
Message-ID<qU0bf-7h2-3@gated-at.bofh.it>
In reply to#1315484
Hello Brian,

On 01-22-16, Brian Gerst wrote:
> >
> > -       /* Is the address not 2M aligned? */
> > -       movq    %rbp, %rax
> > -       andl    $~PMD_PAGE_MASK, %eax
> > -       testl   %eax, %eax
> > -       jnz     bad_address
> > -
> >         /*
> >          * Is the address too large?
> >          */
> 
> I think we still need to do the check, in case we came from a 64-bit
> bootloader that directly jumped to startup_64.  However, this check
> can be simplified to:
> 
>     testl $~PMD_PAGE_MASK, %ebp
>     jnz bad_address

Ah, ok, in this way we can't trust a bootloader. I just thought that
64-bit entry point is startup_64 from arch/x86/boot/compressed/head_64.S

Thank you.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web