From patchwork Tue Mar 21 14:14:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 72900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1808690wrt; Tue, 21 Mar 2023 07:24:55 -0700 (PDT) X-Google-Smtp-Source: AK7set+GAAqJ6PyXX+dQHkeev3lMPPS/cIddgF9esezlQ/ryWg4FVM6yv0pKijGqxjt2Tvovz7Fs X-Received: by 2002:a17:90b:1d05:b0:23f:7e48:4f20 with SMTP id on5-20020a17090b1d0500b0023f7e484f20mr2853677pjb.41.1679408695245; Tue, 21 Mar 2023 07:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679408695; cv=none; d=google.com; s=arc-20160816; b=kUfEPYlpjBt3o5N6fBuif9HBGQ1SumPPc4GqcCtJ3LwWjIhqehC8clFqxauhdPcV73 r6I9aZZ5lcniEPArFyJNxUJZnWfusqrGBte+ZAwSXRf/Ae4oqtykB1prEWSOo6ih2OIa YzOKs9/qdE8D5ILYt6iI0Jx0YYdZqQKYi7UELiHzBLtL0Iut16K9EXPFwXc9mpuMDJUK Pa9dbTLo2DlidhKXRphXpuxaOsEavVHN3YNO5hkR/rwCYC5hinabN1LRM7V+Dl549Z2U 0Ms3RGY2xE0wC9KVF68MrpXdmksv5u6RyBPlFXwSOhGKGxUsPyzmsIV1r1c/GsMwoYro su/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=f5MnfF2EKQmcBPChd5GzmYqDlY/Yu4LaZwgKbnkyhv4=; b=o+lOYvLdEelKlAFrAXukgMdh+Gd3psAnMQ/SUyi7BQi50x/Yd5Y1IzGkbzDJaDpeC5 5e/3kySmMP247qyJwVdzMKD2OrikvaqMsrhO7FYRGCz2uOeOq0dR5LjU/hajDmEHfKh3 qh5HYQCRlcu+8ZcqohHWy7md/lwNSqXqdnEiO/l5jF6WkFtepflnwq2S0fGHzbDanG31 wxVkFeWIKvpLBaOHjuigN9wCSLYpjgjStARg41cXHcy4CXGPeTEK7r/dCyNIildE//5O zUk1eMQF8Lymq5nhUddE+nHLLJnnkNZ3TLO/2aDUAPZzKoyoMhG2VZwYezZ/lHoAbxvC o5ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Cn4YDXFG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=pWeRxxhx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id on11-20020a17090b1d0b00b0023d23393339si20152737pjb.117.2023.03.21.07.24.36; Tue, 21 Mar 2023 07:24:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Cn4YDXFG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=pWeRxxhx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231302AbjCUOO0 (ORCPT + 99 others); Tue, 21 Mar 2023 10:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbjCUOOS (ORCPT ); Tue, 21 Mar 2023 10:14:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7305ACC1F; Tue, 21 Mar 2023 07:14:17 -0700 (PDT) Date: Tue, 21 Mar 2023 14:14:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679408056; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f5MnfF2EKQmcBPChd5GzmYqDlY/Yu4LaZwgKbnkyhv4=; b=Cn4YDXFG0D2pnUYU6Ln4STtobdBd23aQm0Gx7XDxiy+xePQgz5256PEivpEIHdVZVkXm3G Dkma6PWcONgzke6V7snlHTrxnCEL89WeYbtCOvS6r4aYwbzlLZCAyU0pHnSpuU5ND0hRUi JK/pOgkSdFQOuF+iJ9eqBGVrEKpGLE9XLxymj03xEJgAsqxH9kB+gCw1/w4zb0epVFf8sC 53suOPPdxJzKkGaEPLrch1VknkSZu3VOqSPwEbqwfAiUQyj1c5ledY1m/x+lijvinangR/ VpL80X1RM2ck86Hr2ifJHfiyVKYAPCtAH0CJpSFNPqggXFMfj9A0m1b8bqS+Bg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679408056; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f5MnfF2EKQmcBPChd5GzmYqDlY/Yu4LaZwgKbnkyhv4=; b=pWeRxxhxwUKy1Muz/BcDv+54hdTYO0E63aKIlWUWg/sk/0L/smIBE2BmYUjQIqsJ/xHM+O oV9+kUvfaSrAteAQ== From: "tip-bot2 for Brian Gerst" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/apic] x86/smpboot: Remove initial_gs Cc: Brian Gerst , David Woodhouse , Usama Arif , Thomas Gleixner , "Guilherme G. Piccoli" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230316222109.1940300-9-usama.arif@bytedance.com> References: <20230316222109.1940300-9-usama.arif@bytedance.com> MIME-Version: 1.0 Message-ID: <167940805556.5837.6271690017311442602.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760564980697133778?= X-GMAIL-MSGID: =?utf-8?q?1760987651938358365?= The following commit has been merged into the x86/apic branch of tip: Commit-ID: 8f6be6d870e8a078fcc956fc2ff8d7cff67795ee Gitweb: https://git.kernel.org/tip/8f6be6d870e8a078fcc956fc2ff8d7cff67795ee Author: Brian Gerst AuthorDate: Thu, 16 Mar 2023 22:21:05 Committer: Thomas Gleixner CommitterDate: Tue, 21 Mar 2023 13:35:53 +01:00 x86/smpboot: Remove initial_gs Given its CPU#, each CPU can find its own per-cpu offset, and directly set GSBASE accordingly. The global variable can be eliminated. Signed-off-by: Brian Gerst Signed-off-by: David Woodhouse Signed-off-by: Usama Arif Signed-off-by: Thomas Gleixner Tested-by: Usama Arif Tested-by: Guilherme G. Piccoli Reviewed-by: David Woodhouse Link: https://lore.kernel.org/r/20230316222109.1940300-9-usama.arif@bytedance.com --- arch/x86/include/asm/realmode.h | 1 - arch/x86/kernel/acpi/sleep.c | 1 - arch/x86/kernel/head_64.S | 22 ++++++++-------------- arch/x86/kernel/smpboot.c | 2 -- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h index a336fee..f6a1737 100644 --- a/arch/x86/include/asm/realmode.h +++ b/arch/x86/include/asm/realmode.h @@ -59,7 +59,6 @@ extern struct real_mode_header *real_mode_header; extern unsigned char real_mode_blob_end[]; extern unsigned long initial_code; -extern unsigned long initial_gs; extern unsigned long initial_stack; #ifdef CONFIG_AMD_MEM_ENCRYPT extern unsigned long initial_vc_handler; diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index de89bb4..1328c22 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c @@ -127,7 +127,6 @@ int x86_acpi_suspend_lowlevel(void) * value is in the actual %rsp register. */ current->thread.sp = (unsigned long)temp_stack + sizeof(temp_stack); - initial_gs = per_cpu_offset(smp_processor_id()); smpboot_control = smp_processor_id(); #endif initial_code = (unsigned long)wakeup_long64; diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index a5b46c2..6a82387 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -66,18 +66,10 @@ SYM_CODE_START_NOALIGN(startup_64) leaq _text(%rip), %rdi - /* - * initial_gs points to initial fixed_percpu_data struct with storage for - * the stack protector canary. Global pointer fixups are needed at this - * stage, so apply them as is done in fixup_pointer(), and initialize %gs - * such that the canary can be accessed at %gs:40 for subsequent C calls. - */ + /* Setup GSBASE to allow stack canary access for C code */ movl $MSR_GS_BASE, %ecx - movq initial_gs(%rip), %rax - movq $_text, %rdx - subq %rdx, %rax - addq %rdi, %rax - movq %rax, %rdx + leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx + movl %edx, %eax shrq $32, %rdx wrmsr @@ -294,8 +286,11 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL) * the per cpu areas are set up. */ movl $MSR_GS_BASE,%ecx - movl initial_gs(%rip),%eax - movl initial_gs+4(%rip),%edx +#ifndef CONFIG_SMP + leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx +#endif + movl %edx, %eax + shrq $32, %rdx wrmsr /* Setup and Load IDT */ @@ -437,7 +432,6 @@ SYM_CODE_END(vc_boot_ghcb) __REFDATA .balign 8 SYM_DATA(initial_code, .quad x86_64_start_kernel) -SYM_DATA(initial_gs, .quad INIT_PER_CPU_VAR(fixed_percpu_data)) #ifdef CONFIG_AMD_MEM_ENCRYPT SYM_DATA(initial_vc_handler, .quad handle_vc_boot_ghcb) #endif diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 94e6c54..b7d478d 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1059,8 +1059,6 @@ int common_cpu_up(unsigned int cpu, struct task_struct *idle) #ifdef CONFIG_X86_32 /* Stack for startup_32 can be just as for start_secondary onwards */ per_cpu(pcpu_hot.top_of_stack, cpu) = task_top_of_stack(idle); -#else - initial_gs = per_cpu_offset(cpu); #endif return 0; }