From patchwork Thu Mar 16 22:21:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 70997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp26041wrt; Thu, 16 Mar 2023 15:24:27 -0700 (PDT) X-Google-Smtp-Source: AK7set/GwrnumeIaPfO20Om/PoYRYdDVAwwy8nhyLXq0vkXrarDuCiJGGcIWjUgLxPfDcFPB7nme X-Received: by 2002:a17:90b:3a83:b0:237:a500:eca6 with SMTP id om3-20020a17090b3a8300b00237a500eca6mr749152pjb.22.1679005467468; Thu, 16 Mar 2023 15:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679005467; cv=none; d=google.com; s=arc-20160816; b=WrJi3F9J1OMG2JPYvvq6QYjuIAsuhuh8o1r0YlgqXSe5JtqADBPyRGdN2g8n25zgAP FHhKiKJwe9Pt4aLIEPvDIjz+dXZkVxlW1XGr3qa7R3d3eGJCZmdROo7LhULipjAH2wAN a+B2gmonerq+laYkrewH22TcxT8QXBdnJA4XzfnjYXoA8fYnyEh3aSmi1Qjq92ks+GMj 86JRUMgXp0h+/ULT1YuiNu6pjb5v8QMx9HWHSK7ROI37x9Mk+9ubwO9dVP9PiEscsFRx sA+E9V5uK348D4ru6Sb5wEbpmAnHbvzBrTmLTjS682q6eqNQfcLyi7h48+UVpXGcKpJV 30KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A1Nso70j7TcOLvyUcSWwhrfhUH4RnAbpnDIgeFc4TIk=; b=szHWUhWaxFk2fg/Yai1DXthL3MqIAk9JVYXy9/s6w0ciRO2OfqxnXEZ+UpJiOYw5aJ g/AvLAbknhY0sFi6zjELM+XihgayfKUU21Gx0z8KAFkHwNMRbdWDNqdAdxisDlHRer0t Drqeiau8y+hjVN9dGZPB7VoV4zLYeGyCRhZEYHYb1KFawx8cdrhS74dcSQ9aCjHGwQEK GhkEwm3uOVwXKkcxPNtXZ2/E/6jOBB5TZb/FwzCa6JxbrV+sKJA8WOHpnuA6HNJW/79+ leD2xcmaFTrdSfSOzFyAY+2x5Wi1fixqQfBu0Uxb3PhzKz4sfP2BHiz72rog5qglssyx waxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=kUrA8WNT; 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=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v3-20020a17090a6b0300b00225c981fee5si5731695pjj.112.2023.03.16.15.24.12; Thu, 16 Mar 2023 15:24:27 -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=@bytedance.com header.s=google header.b=kUrA8WNT; 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=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbjCPWVx (ORCPT + 99 others); Thu, 16 Mar 2023 18:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229985AbjCPWVo (ORCPT ); Thu, 16 Mar 2023 18:21:44 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DA6CB5AAE for ; Thu, 16 Mar 2023 15:21:20 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id o7so2872083wrg.5 for ; Thu, 16 Mar 2023 15:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1679005278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A1Nso70j7TcOLvyUcSWwhrfhUH4RnAbpnDIgeFc4TIk=; b=kUrA8WNTnCZR7ZN8Y0MlY/qQ5ggU/8FvF9S6J9RiR8OsjerRCbOCfFcUrWEG9OWok2 shAGMGXwdC0cfh8K+fST9Hd04rigk8xYonifLmItP2Uo0hYOKUGn6SDNCV5HSkavNxsQ lIZ6+KGIgc3p6so7ukucolEoG0m65RHF1FSn4br3vbx/RZgJMlhRPusonBL+Jo1KmUHu CqCseNQ2/ivXBykeEPFerRkcZHzXzus9v7qJy/E9WXGSFk/f9MYmzcpW9yfFGmuHIx8+ 5jy+s+dimL5VaC7CkVSv5YpOhVikFmNqcATCn4hCJZdoSAegg3AJ3rZuUiEmyGIOjsTk cYGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679005278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A1Nso70j7TcOLvyUcSWwhrfhUH4RnAbpnDIgeFc4TIk=; b=0MfYoaCcSR6Zhgz8eN5D0QEft8rPn/u/yU22uq6jYZ9g2dohk8Vu0pSsAPUnz8LM3r +FuQHX3Mgt9szQP79FhH4kkYr0LLAMvm1A5zUWen3s5zwGG+XSe/PiBz7961yzvTjNNS eUDMX2eDqK5Hp+hAWmlFvpOfrbbhPIyWtLzOVvVIqVxHUOoHehnhYGxO7UBSv4cw/aVB 5eqmeUjD2G0fGhRU5oAnG+dds2G6kRMpvAgMl9nKFSwTmByaXjGY+zkL6tAagIzoXHD4 AMOhRiAWuZJPtZLxxrsq8DgryEvOuauqQZz261wF0KDhQ8BjayDc4TgfgJt8nQBIc4y3 2Kuw== X-Gm-Message-State: AO0yUKVU18fmplAC9v18xLIMqHJD39xpQPw68EY5Qdxt3ruO6Qdx2HJS dY3pSNsE3k1eQxUmd6L0Z8URAQ== X-Received: by 2002:a05:6000:1111:b0:2cf:e315:10b8 with SMTP id z17-20020a056000111100b002cfe31510b8mr6039732wrw.10.1679005278388; Thu, 16 Mar 2023 15:21:18 -0700 (PDT) Received: from usaari01.cust.communityfibre.co.uk ([2a02:6b6a:b566:0:4b87:78c3:3abe:7b0d]) by smtp.gmail.com with ESMTPSA id f9-20020adff989000000b002cea392f000sm439256wrr.69.2023.03.16.15.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 15:21:18 -0700 (PDT) From: Usama Arif To: dwmw2@infradead.org, tglx@linutronix.de, kim.phillips@amd.com, brgerst@gmail.com Cc: piotrgorski@cachyos.org, oleksandr@natalenko.name, arjan@linux.intel.com, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, paulmck@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, rcu@vger.kernel.org, mimoja@mimoja.de, hewenliang4@huawei.com, thomas.lendacky@amd.com, seanjc@google.com, pmenzel@molgen.mpg.de, fam.zheng@bytedance.com, punit.agrawal@bytedance.com, simon.evans@bytedance.com, liangma@liangbit.com, gpiccoli@igalia.com, David Woodhouse , Usama Arif Subject: [PATCH v15 07/12] x86/smpboot: Remove early_gdt_descr on 64-bit Date: Thu, 16 Mar 2023 22:21:04 +0000 Message-Id: <20230316222109.1940300-8-usama.arif@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316222109.1940300-1-usama.arif@bytedance.com> References: <20230316222109.1940300-1-usama.arif@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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?1760564836725363446?= X-GMAIL-MSGID: =?utf-8?q?1760564836725363446?= From: Brian Gerst Build the GDT descriptor on the stack instead. Signed-off-by: Brian Gerst Reviewed-by: David Woodhouse Signed-off-by: David Woodhouse Tested-by: Usama Arif Signed-off-by: Usama Arif Tested-by: Guilherme G. Piccoli --- arch/x86/kernel/acpi/sleep.c | 2 -- arch/x86/kernel/head_64.S | 11 ++++++----- arch/x86/kernel/smpboot.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index 1b4c43d0819a..de89bb4719d0 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c @@ -127,8 +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); - early_gdt_descr.address = - (unsigned long)get_cpu_gdt_rw(smp_processor_id()); initial_gs = per_cpu_offset(smp_processor_id()); smpboot_control = smp_processor_id(); #endif diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index cc1b145055ac..a5b46c2fba05 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -265,7 +265,12 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL) * addresses where we're currently running on. We have to do that here * because in 32bit we couldn't load a 64bit linear address. */ - lgdt early_gdt_descr(%rip) + subq $16, %rsp + movw $(GDT_SIZE-1), (%rsp) + leaq gdt_page(%rdx), %rax + movq %rax, 2(%rsp) + lgdt (%rsp) + addq $16, %rsp /* set up data segments */ xorl %eax,%eax @@ -667,10 +672,6 @@ SYM_DATA_END(level1_fixmap_pgt) .data .align 16 -SYM_DATA(early_gdt_descr, .word GDT_ENTRIES*8-1) -SYM_DATA_LOCAL(early_gdt_descr_base, .quad INIT_PER_CPU_VAR(gdt_page)) - - .align 16 SYM_DATA(smpboot_control, .long 0) .align 16 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index ab8decac6294..67224e61310c 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1110,10 +1110,10 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle, start_ip = real_mode_header->trampoline_start64; #endif idle->thread.sp = (unsigned long)task_pt_regs(idle); - early_gdt_descr.address = (unsigned long)get_cpu_gdt_rw(cpu); initial_code = (unsigned long)start_secondary; if (IS_ENABLED(CONFIG_X86_32)) { + early_gdt_descr.address = (unsigned long)get_cpu_gdt_rw(cpu); initial_stack = idle->thread.sp; } else { smpboot_control = cpu;