mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.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>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 2/2] x86: Replace this_cpu_sp0 with current_top_of_stack and fix it on x86_32
Date: Thu, 26 Mar 2015 09:30:06 -0400	[thread overview]
Message-ID: <551409DE.50702@oracle.com> (raw)
In-Reply-To: <d09dbe270883433776e0cbee3c7079433349e96d.1425692936.git.luto@amacapital.net>

On 03/06/2015 08:50 PM, Andy Lutomirski wrote:
> I broke 32-bit kernels.  The implementation of sp0 was correct as
> far as I can tell, but sp0 was much weirder on x86_32 than I
> realized.  It has the following issues:
>
>   - Init's sp0 is inconsistent with everything else's: non-init tasks
>     are offset by 8 bytes.  (I have no idea why, and the comment is unhelpful.)
>
>   - vm86 does crazy things to sp0.
>
> Fix it up by replacing this_cpu_sp0() with current_top_of_stack()
> and using a new percpu variable to track the top of the stack on
> x86_32.
>
> Fixes: 75182b1632a8 x86/asm/entry: Switch all C consumers of kernel_stack to this_cpu_sp0()
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> ---

...

> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index febc6aabc72e..759388c538cf 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -806,6 +806,8 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
>   #ifdef CONFIG_X86_32
>   	/* Stack for startup_32 can be just as for start_secondary onwards */
>   	irq_ctx_init(cpu);
> +	per_cpu(cpu_current_top_of_stack, cpu) =
> +		(unsigned long)task_stack_page(idle) + THREAD_SIZE;
>   #else
>   	clear_tsk_thread_flag(idle, TIF_FORK);
>   	initial_gs = per_cpu_offset(cpu);


Andy,

We need a similar change for Xen, otherwise 32-bit PV guests are not 
happy. Is the patch above final (and then should I submit a separate 
patch) or are you still working on it (and if so, please add the change 
below)?

-boris


diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 1c5e760..561d6f5 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -444,6 +444,8 @@ static int xen_cpu_up(unsigned int cpu, struct 
task_struct *idle)
         per_cpu(current_task, cpu) = idle;
  #ifdef CONFIG_X86_32
         irq_ctx_init(cpu);
+       per_cpu(cpu_current_top_of_stack, cpu) =
+                (unsigned long)task_stack_page(idle) + THREAD_SIZE;
  #else
         clear_tsk_thread_flag(idle, TIF_FORK);
  #endif


  parent reply	other threads:[~2015-03-26 13:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-07  1:50 [PATCH 0/2] x86: sp0 fixes Andy Lutomirski
2015-03-07  1:50 ` [PATCH 1/2] x86: Delay loading sp0 slightly on task switch Andy Lutomirski
2015-03-07  8:37   ` [tip:x86/asm] x86/asm/entry: " tip-bot for Andy Lutomirski
2015-03-07  1:50 ` [PATCH 2/2] x86: Replace this_cpu_sp0 with current_top_of_stack and fix it on x86_32 Andy Lutomirski
2015-03-07  8:37   ` [tip:x86/asm] x86/asm/entry: Replace this_cpu_sp0() with current_top_of_stack() " tip-bot for Andy Lutomirski
2015-03-09 13:04     ` Denys Vlasenko
2015-03-09 13:15       ` Andy Lutomirski
2015-03-26 13:30   ` Boris Ostrovsky [this message]
2015-03-26 18:33     ` [PATCH 2/2] x86: Replace this_cpu_sp0 with current_top_of_stack " 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=551409DE.50702@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=dvlasenk@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome