All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denys Vlasenko <dvlasenk@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Borislav Petkov <bp@alien8.de>, Oleg Nesterov <oleg@redhat.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [RFC 2/3] x86: Switch all C consumers of kernel_stack to this_cpu_sp0
Date: Fri, 27 Feb 2015 17:13:17 +0100	[thread overview]
Message-ID: <54F0979D.5060001@redhat.com> (raw)
In-Reply-To: <fd258af7c2d1d0f180ab7a56da0e97220b168924.1424994489.git.luto@amacapital.net>

On 02/27/2015 01:07 AM, Andy Lutomirski wrote:
> This will make modifying the semantics of kernel_stack easier.
> 
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> ---
>  arch/x86/include/asm/thread_info.h | 3 +--
>  arch/x86/kernel/traps.c            | 2 +-
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
> index e82e95abc92b..92549053d86d 100644
> --- a/arch/x86/include/asm/thread_info.h
> +++ b/arch/x86/include/asm/thread_info.h
> @@ -163,8 +163,7 @@ DECLARE_PER_CPU(unsigned long, kernel_stack);
>  static inline struct thread_info *current_thread_info(void)
>  {
>  	struct thread_info *ti;
> -	ti = (void *)(this_cpu_read_stable(kernel_stack) +
> -		      KERNEL_STACK_OFFSET - THREAD_SIZE);
> +	ti = (void *)(this_cpu_sp0() - THREAD_SIZE);
>  	return ti;
>  }
>  
> diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> index c74f2f5652da..d287ea779728 100644
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -174,7 +174,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)
>  	 * will catch asm bugs and any attempt to use ist_preempt_enable
>  	 * from double_fault.
>  	 */
> -	BUG_ON(((current_stack_pointer() ^ this_cpu_read_stable(kernel_stack))
> +	BUG_ON(((current_stack_pointer() ^ (this_cpu_sp0() - 1))
>  		& ~(THREAD_SIZE - 1)) != 0);

While we are at it, I propose a more readable version of this check:

BUG_ON(this_cpu_sp0() - current_stack_pointer() >= THREAD_SIZE);

Yes, I am aware that it is not equivalent to the existing condition
- it uses the fact that this_cpu_sp0(), previous check
wasn't making that assumption. But that assumption is true,
so shouldn't be a problem.

  reply	other threads:[~2015-02-27 16:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 23:52 [RFC 0/3] Baby steps toward cleaning up KERNEL_STACK_OFFSET Andy Lutomirski
2015-02-27  0:07 ` [RFC 1/3] x86: Add this_cpu_sp0() to read sp0 for the current cpu Andy Lutomirski
2015-03-04  8:02   ` Ingo Molnar
2015-03-04 18:51     ` Andy Lutomirski
2015-03-04 20:39       ` Ingo Molnar
2015-03-04 20:41         ` Andy Lutomirski
2015-03-04 21:05           ` Borislav Petkov
2015-03-04 22:12           ` Ingo Molnar
2015-03-04 22:20             ` Andy Lutomirski
2015-02-27  0:07 ` [RFC 2/3] x86: Switch all C consumers of kernel_stack to this_cpu_sp0 Andy Lutomirski
2015-02-27 16:13   ` Denys Vlasenko [this message]
2015-02-27 19:56     ` Andy Lutomirski
2015-02-27 21:11       ` Denys Vlasenko
2015-02-27 22:39         ` Andy Lutomirski
2015-02-27 16:52   ` Denys Vlasenko
2015-02-27 20:02     ` Andy Lutomirski
2015-02-27  0:07 ` [RFC 3/3] x86, asm: Change the 32-bit sysenter code to use sp0 Andy Lutomirski

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=54F0979D.5060001@redhat.com \
    --to=dvlasenk@redhat.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=x86@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.