From patchwork Fri Apr 28 09:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Wenlong X-Patchwork-Id: 88572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp821659vqo; Fri, 28 Apr 2023 03:12:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Y70YRk83qVUjaxF7lS1SONVjdoLEqJITiqahYCW3ETW4tgGbS/Aa07jzlRsomdrNhZ0IH X-Received: by 2002:aa7:88c7:0:b0:63b:5f78:d6db with SMTP id k7-20020aa788c7000000b0063b5f78d6dbmr6672234pff.21.1682676731655; Fri, 28 Apr 2023 03:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682676731; cv=none; d=google.com; s=arc-20160816; b=CzkwjKygEPM/2TTA7QT2M6QtaDKczYeu3VaoCm1eZC8sum9S+TtsMpR8YIyhx1Rzr1 wH/QqYp+EecCw2R+IUgoJxOlBb6GD+lp5Dr9g7NX/aujPuQfXBu3AqsYBveadspqTUqL lCmmL0/JPm1DTlSYH4tGO7nyycLtknXf9XrQyXBH2ckGkKxXmru81SzyxnZuc8NMZY3P 37wVVbOw8MY5CBv+bjLDo2qwLOZk2r4ICxVMcpUsDedQrofwvMN0VPx8V55wN56XTlu1 73+uqEEDrslH0rlKlVeIZ0bc6SXoL5tNkP7VuJiYCT9yLYqROHbJIo6wZEA8/feVCvNI JJkA== 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=SuGEPPR0BEZ6H4/WwAPmBpJv/32hD1Vv44O7qBAYt3g=; b=PuarJO4QbfLSbxgITsRNKNK33IKGh7MebCyIwvnf2quk4/lutDc14c+hwNsRMvOnuD TuVfuLq3sgyexTXX2Lh4kynWxhFrobTwRi6UqEafFa42y13EcTxJdfJg45Wr5EzNe0lK M2OT6U+5+RnSjvKidwnzypTGjfJHV6vtQxRTo+TqCGmaMj7uG0RVXacpK3mLpJ7otLzZ /HsEJOVAZYIVS0P6A/MpSbmc/tmWAsrz8B9FzWv5EFBuqB1xJtnUct64yaWAiKRzr+Em RArHBp774T3NAhyc5Qs7U3OwOcONreT0YJ8YR0UpzjlWhRca7M5e9zFg1mhCukho4uQD QVBg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020aa7950a000000b0063b7f1093e1si5166589pfp.110.2023.04.28.03.11.59; Fri, 28 Apr 2023 03:12:11 -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 S1345489AbjD1JwO (ORCPT + 99 others); Fri, 28 Apr 2023 05:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345704AbjD1JwB (ORCPT ); Fri, 28 Apr 2023 05:52:01 -0400 Received: from out0-201.mail.aliyun.com (out0-201.mail.aliyun.com [140.205.0.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DF244699 for ; Fri, 28 Apr 2023 02:51:56 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R511e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047202;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---.STFQG9j_1682675508; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.STFQG9j_1682675508) by smtp.aliyun-inc.com; Fri, 28 Apr 2023 17:51:49 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Thomas Garnier" , "Lai Jiangshan" , "Kees Cook" , "Hou Wenlong" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , " =?utf-8?q?Peter_Zijlstra_=28Intel=29?= " , "Alexandre Chartre" , "Josh Poimboeuf" , "Konrad Rzeszutek Wilk" Subject: [PATCH RFC 03/43] x86: relocate_kernel - Adapt assembly for PIE support Date: Fri, 28 Apr 2023 17:50:43 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764414436564618698?= X-GMAIL-MSGID: =?utf-8?q?1764414436564618698?= From: Thomas Garnier From: Thomas Garnier Change the assembly code to use only absolute 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/relocate_kernel_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index 56cab1bb25f5..05d916e9df47 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -223,7 +223,7 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) movq %rax, %cr3 lea PAGE_SIZE(%r8), %rsp call swap_pages - movq $virtual_mapped, %rax + movabsq $virtual_mapped, %rax pushq %rax ANNOTATE_UNRET_SAFE ret