Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1859565rwr; Fri, 28 Apr 2023 02:53:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oPDwucsaNPikNgZcZ/YWMWKi/F6aduLMJrc8GS0mOvAMxwWtlCboKdeKaQpCH1IeBsWd2 X-Received: by 2002:a05:6a21:788d:b0:ef:957f:5a2b with SMTP id bf13-20020a056a21788d00b000ef957f5a2bmr5880456pzc.48.1682675630198; Fri, 28 Apr 2023 02:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682675630; cv=none; d=google.com; s=arc-20160816; b=MXTcUcdovykgTX46el7QBDqNEUPnKTouO6rWdZ+IMPckj0KeaJPQblPNmgAvZwOIq0 Rk02RWwoTu2/6A5LM5/QJtFkHN6DVsyHOTFrJ7qq1iheDTStY6Ok5/0YSuinuOHiWrJE TYltcAm/mQsOVLmnviryhx1JT9vKUWd+jfSLU4SDia37S39PBM9TARvbhqPFWPzw0dxb +Cnjn6sbXI6fXd5+3OrgX2/FjbBUtbTkmYrEHCdNpphRO4T3YlyAzWkWCvXo2Q0JMiWZ LRnxvxn1s3g1RQ28OoxLX/fPguEqCHXpafjuHcnWOmhScBByjJKekG2TITOJonmwlarT O9AA== 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; bh=JHz4rktsjMBkmXN5gXY4fWOXWZpj6qs1BumvDReuGe4=; b=T/HcPEOMnHldPa2KPs7jh/MdWl+VudUPNrsDphTsaaPSaKwukEIVQvlMWQ88xjvgqm D6CMDg1ZQuW/hqPrQ/3pcytXo43/BhsQHigm09h82tvKQg5ULj4DZUA7QnuUT85kllRk 4qO3b2JLtYQFOMG/zdC43mXplcSo3lGxJ4kfM1troURueGw42Seovlsnbkp/Q5ah3jys Qd01QDUMy34bYDpeXacXl4jQ7urQvkj2IPR8L5UEhvFzHtxzltKiWRK0q9iXX0TX1Qzm OByvjXCdIkynngBTl7gwkA1JkQPqk851r5q6RtOXaSgNAolPYNuk6uffABtCyJBlZZqF kjWA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v64-20020a638943000000b00513f070aa97si21877910pgd.832.2023.04.28.02.53.38; Fri, 28 Apr 2023 02:53:50 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345364AbjD1Jwi (ORCPT + 99 others); Fri, 28 Apr 2023 05:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345704AbjD1JwR (ORCPT ); Fri, 28 Apr 2023 05:52:17 -0400 Received: from out0-216.mail.aliyun.com (out0-216.mail.aliyun.com [140.205.0.216]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3FE85B95; Fri, 28 Apr 2023 02:52:07 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R981e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047207;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---.STCEPKJ_1682675519; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.STCEPKJ_1682675519) by smtp.aliyun-inc.com; Fri, 28 Apr 2023 17:52:00 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Thomas Garnier" , "Lai Jiangshan" , "Kees Cook" , "Hou Wenlong" , "Rafael J. Wysocki" , "Len Brown" , "Pavel Machek" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , , Subject: [PATCH RFC 07/43] x86/acpi: Adapt assembly for PIE support Date: Fri, 28 Apr 2023 17:50:47 +0800 Message-Id: <8b90798cb41604b2e2d47c8fcbb67913daafd85d.1682673543.git.houwenlong.hwl@antgroup.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 From: Thomas Garnier From: Thomas Garnier Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Signed-off-by: Thomas Garnier Signed-off-by: Hou Wenlong Cc: Lai Jiangshan Cc: Kees Cook --- arch/x86/kernel/acpi/wakeup_64.S | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S index d5d8a352eafa..fe688bd87d72 100644 --- a/arch/x86/kernel/acpi/wakeup_64.S +++ b/arch/x86/kernel/acpi/wakeup_64.S @@ -17,7 +17,7 @@ * Hooray, we are in Long 64-bit mode (but still running in low memory) */ SYM_FUNC_START(wakeup_long64) - movq saved_magic, %rax + movq saved_magic(%rip), %rax movq $0x123456789abcdef0, %rdx cmpq %rdx, %rax je 2f @@ -33,14 +33,14 @@ SYM_FUNC_START(wakeup_long64) movw %ax, %es movw %ax, %fs movw %ax, %gs - movq saved_rsp, %rsp + movq saved_rsp(%rip), %rsp - movq saved_rbx, %rbx - movq saved_rdi, %rdi - movq saved_rsi, %rsi - movq saved_rbp, %rbp + movq saved_rbx(%rip), %rbx + movq saved_rdi(%rip), %rdi + movq saved_rsi(%rip), %rsi + movq saved_rbp(%rip), %rbp - movq saved_rip, %rax + movq saved_rip(%rip), %rax ANNOTATE_RETPOLINE_SAFE jmp *%rax SYM_FUNC_END(wakeup_long64) @@ -51,7 +51,7 @@ SYM_FUNC_START(do_suspend_lowlevel) xorl %eax, %eax call save_processor_state - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq %rsp, pt_regs_sp(%rax) movq %rbp, pt_regs_bp(%rax) movq %rsi, pt_regs_si(%rax) @@ -70,13 +70,14 @@ SYM_FUNC_START(do_suspend_lowlevel) pushfq popq pt_regs_flags(%rax) - movq $.Lresume_point, saved_rip(%rip) + leaq .Lresume_point(%rip), %rax + movq %rax, saved_rip(%rip) - movq %rsp, saved_rsp - movq %rbp, saved_rbp - movq %rbx, saved_rbx - movq %rdi, saved_rdi - movq %rsi, saved_rsi + movq %rsp, saved_rsp(%rip) + movq %rbp, saved_rbp(%rip) + movq %rbx, saved_rbx(%rip) + movq %rdi, saved_rdi(%rip) + movq %rsi, saved_rsi(%rip) addq $8, %rsp movl $3, %edi @@ -88,7 +89,7 @@ SYM_FUNC_START(do_suspend_lowlevel) .align 4 .Lresume_point: /* We don't restore %rax, it must be 0 anyway */ - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq saved_context_cr4(%rax), %rbx movq %rbx, %cr4 movq saved_context_cr3(%rax), %rbx -- 2.31.1