lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrW-B6JzmTWGA4KbLac9Q7tKB9XZeBXM86NjyS5qgEx2hw@mail.gmail.com>
Date:	Fri, 10 Apr 2015 11:50:58 -0700
From:	Andy Lutomirski <luto@...capital.net>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	X86 ML <x86@...nel.org>, Andrew Lutomirski <luto@...nel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 2/8] x86: Naturally align the debug IST stack

On Fri, Apr 10, 2015 at 8:50 AM, Andi Kleen <andi@...stfloor.org> wrote:
> From: Andi Kleen <ak@...ux.intel.com>
>
> The followon patch for RD*BASE requires the IST stacks to be naturally
> aligned because it uses and to access the bottom of the stack.
> This was true for everyone except for the debug ist stack.
> Make the debug ist stack naturally aligned too.
>
> Signed-off-by: Andi Kleen <ak@...ux.intel.com>
> ---
>  arch/x86/include/asm/page_64_types.h | 4 ++--
>  arch/x86/kernel/cpu/common.c         | 8 +++++++-
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
> index 4edd53b..b631f04 100644
> --- a/arch/x86/include/asm/page_64_types.h
> +++ b/arch/x86/include/asm/page_64_types.h
> @@ -22,8 +22,8 @@
>
>  #define DOUBLEFAULT_STACK 1
>  #define NMI_STACK 2
> -#define DEBUG_STACK 3
> -#define MCE_STACK 4
> +#define MCE_STACK 3
> +#define DEBUG_STACK 4 /* must be always last */
>  #define N_EXCEPTION_STACKS 4  /* hw limit: 7 */
>
>  #define PUD_PAGE_SIZE          (_AC(1, UL) << PUD_SHIFT)
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index 2346c95..33a0293 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -1158,8 +1158,12 @@ static const unsigned int exception_stack_sizes[N_EXCEPTION_STACKS] = {
>           [DEBUG_STACK - 1]                     = DEBUG_STKSZ
>  };
>
> +/* The IST stacks must be naturally aligned */
> +
>  static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
> -       [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]);
> +       [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ]);
> +static DEFINE_PER_CPU_2PAGE_ALIGNED(char, debug_stack
> +       [DEBUG_STKSZ]);

IMO this needs some kind of assertion that DEBUG_STKSZ == 2 *
PAGE_SIZE.  Or you could instead pass the required alignment to the
macro if you add a parameter.

--Andy

>
>  /* May not be marked __init: used by software suspend */
>  void syscall_init(void)
> @@ -1349,6 +1353,8 @@ void cpu_init(void)
>                 char *estacks = per_cpu(exception_stacks, cpu);
>
>                 for (v = 0; v < N_EXCEPTION_STACKS; v++) {
> +                       if (v == DEBUG_STACK - 1)
> +                               estacks = per_cpu(debug_stack, cpu);
>                         estacks += exception_stack_sizes[v];
>                         oist->ist[v] = t->x86_tss.ist[v] =
>                                         (unsigned long)estacks;
> --
> 1.9.3
>



-- 
Andy Lutomirski
AMA Capital Management, LLC
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ