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


Groups > linux.kernel > #1457184

Re: [PATCH v2 04/44] x86/asm/head: use a common function for starting CPUs

From Nilay Vaish <nilayvaish@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 04/44] x86/asm/head: use a common function for starting CPUs
Date 2016-08-05 17:50 +0200
Message-ID <s2PxM-YZ-35@gated-at.bofh.it> (permalink)
References <s2zjj-7xL-9@gated-at.bofh.it> <s2zt0-7Bf-33@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 4 August 2016 at 17:22, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> There are two different pieces of code for starting a CPU: start_cpu0()
> and the end of secondary_startup_64().  They're identical except for the
> stack setup.  Combine the common parts into a shared start_cpu()
> function.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
>  arch/x86/kernel/head_64.S | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
> index aa10a53..8822c20 100644
> --- a/arch/x86/kernel/head_64.S
> +++ b/arch/x86/kernel/head_64.S
> @@ -264,13 +264,15 @@ ENTRY(secondary_startup_64)
>         movl    $MSR_GS_BASE,%ecx
>         movl    initial_gs(%rip),%eax
>         movl    initial_gs+4(%rip),%edx
> -       wrmsr
> +       wrmsr
>
>         /* rsi is pointer to real mode structure with interesting info.
>            pass it to C */
>         movq    %rsi, %rdi
> -
> -       /* Finally jump to run C code and to be on real kernel address
> +
> +ENTRY(start_cpu)
> +       /*
> +        * Jump to run C code and to be on a real kernel address.
>          * Since we are running on identity-mapped space we have to jump
>          * to the full 64bit address, this is only possible as indirect
>          * jump.  In addition we need to ensure %cs is set so we make this
> @@ -307,15 +309,11 @@ ENDPROC(secondary_startup_64)
>  /*
>   * Boot CPU0 entry point. It's called from play_dead(). Everything has been set
>   * up already except stack. We just set up stack here. Then call
> - * start_secondary().
> + * start_secondary() via start_cpu().
>   */
>  ENTRY(start_cpu0)
> -       movq initial_stack(%rip),%rsp
> -       movq    initial_code(%rip),%rax
> -       pushq   $0              # fake return address to stop unwinder
> -       pushq   $__KERNEL_CS    # set correct cs
> -       pushq   %rax            # target address in negative space
> -       lretq
> +       movq    initial_stack(%rip), %rsp
> +       jmp     start_cpu
>  ENDPROC(start_cpu0)
>  #endif
>

I have small suggestion here.  To me jumping from start_cpu0 into the
middle of secondary_startup_64 just seems strange.  May be we can
define separate ENTRY and ENDPROC pair for start_cpu and jump there
from start_cpu0 and also from secondary_startup_64.

--
Nilay

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/44] x86/dumpstack: rewrite x86 stack dump code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 07/44] x86/dumpstack: remove extra brackets around "<EOE>" Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 11/44] x86/dumpstack: remove unnecessary stack pointer arguments Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 06/44] x86/dumpstack: add IRQ_USABLE_STACK_SIZE define Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 14/44] x86/asm/head:  put real return address on idle task stack Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 02/44] x86/asm/head: remove unused init_rsp variable Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 18/44] ftrace: remove CONFIG_HAVE_FUNCTION_GRAPH_FP_TEST from config Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 17/44] proc: fix return address printk conversion specifer in /proc/<pid>/stack Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 20/44] ftrace: add return address pointer to ftrace_ret_stack Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 15/44] perf/x86: check perf_callchain_store() error Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 04/44] x86/asm/head: use a common function for starting CPUs Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
    Re: [PATCH v2 04/44] x86/asm/head: use a common function for starting CPUs Nilay Vaish <nilayvaish@gmail.com> - 2016-08-05 17:50 +0200
      Re: [PATCH v2 04/44] x86/asm/head: use a common function for  starting CPUs Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 18:20 +0200
  [PATCH v2 03/44] x86/asm/head: rename 'stack_start' -> 'initial_stack' Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
    Re: [PATCH v2 03/44] x86/asm/head: rename 'stack_start' -> 'initial_stack' Nilay Vaish <nilayvaish@gmail.com> - 2016-08-05 17:30 +0200
      Re: [PATCH v2 03/44] x86/asm/head: rename 'stack_start' ->  'initial_stack' Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 18:10 +0200
        Re: [PATCH v2 03/44] x86/asm/head: rename 'stack_start' ->  'initial_stack' Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-06 22:30 +0200
        Re: [PATCH v2 03/44] x86/asm/head: rename 'stack_start' ->  'initial_stack' Borislav Petkov <bp@alien8.de> - 2016-08-06 22:50 +0200
          Re: [PATCH v2 03/44] x86/asm/head: rename 'stack_start' ->  'initial_stack' Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-06 22:50 +0200
          Re: [PATCH v2 03/44] x86/asm/head: rename 'stack_start' -> 'initial_stack' Brian Gerst <brgerst@gmail.com> - 2016-08-07 00:30 +0200
  [PATCH v2 09/44] x86/dumpstack: fix x86_32 kernel_stack_pointer() previous stack access Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 22/44] x86/dumpstack/ftrace: convert dump_trace() callbacks to use ftrace_graph_ret_addr() Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200
  [PATCH v2 12/44] x86: move _stext marker to before head code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-05 00:40 +0200

csiph-web