From patchwork Fri Apr 28 09:50:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Wenlong X-Patchwork-Id: 88564 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp819334vqo; Fri, 28 Apr 2023 03:07:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5LWMxTqVHs+ZhJ/NY7BtmFjznR7YEI2qZ8uqvtgugy6CmFNdh0dnONmS4bayTIuwE6XpdM X-Received: by 2002:a05:6a20:1455:b0:ee:d266:32b9 with SMTP id a21-20020a056a20145500b000eed26632b9mr6294303pzi.10.1682676473695; Fri, 28 Apr 2023 03:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682676473; cv=none; d=google.com; s=arc-20160816; b=VDtakxni9BLmgoUHwAa7UtD8387ccKdVNlPiHG8jveuivdfBW6faQP16I2QORxx1Qx ykJ1IBNYV2TNz99Zt1h/CRx0F549yL3jSY5KjAKRTF+dqBPTB8OUPb/SMvqC8aylKrNR S8/3A1FI4ppupYUKkyGC3zZKWYCtlGXL9OzjL2PinpUAvP8pTyQdSIvzIFb7ShAsSXjw nwdzGmI4ObbZWHI8ce/bjJCvkEmCGkFvYZ9qwUlJvYMDb75rHWiYi4WOunSonZcRZr86 oDHISw9ERDFhQBvKk3CksAHpRiPRGtKtGTEwfy4ghULrL7i0gNq9lY3pdqlPwwkbNLGK hGOA== 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=PBYiiSI3kD7uz/xUeuO8fV8NvPtrztGj5TD65Y8Qtu0=; b=XuHN3KkIlSPLAm9rG2Jn8PGsNvFlo/3DetzzLCoNioAXnVfM2mmMTln0gMi5JF9cUo /Tq7SaHLgWHWsyt4xMl11rj+mjk/s+8Cd0j9jXLiWcKwL7Nz9t3Rnt+UPoOwrqaRguqI vqkdkXZYs1KB+1LGu368C307V/ENsAI+e15S04XZ1xSc8r0bIQ3KKtcLTiJlKCmGa2JX +1g4wxSXK0PlhePGOlGfSZxV81BASkwlGSzAOYiuIw33yhd9P1DR2rKD+oYV6DbexIhS uZXZeuapN7y4T478xaElAUkhR3jSU7o8pMq2rH8uSe5gqrqYebeLGbYOypH489t6opWB b9gg== 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 w190-20020a6382c7000000b0050fb7c5a656si21350952pgd.190.2023.04.28.03.07.38; Fri, 28 Apr 2023 03:07:53 -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 S1345403AbjD1Jw2 (ORCPT + 99 others); Fri, 28 Apr 2023 05:52:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345760AbjD1JwP (ORCPT ); Fri, 28 Apr 2023 05:52:15 -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 0A67755BD for ; Fri, 28 Apr 2023 02:52:03 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R471e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047205;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---.STDfru9_1682675517; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.STDfru9_1682675517) by smtp.aliyun-inc.com; Fri, 28 Apr 2023 17:51:57 +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" Subject: [PATCH RFC 06/43] x86/CPU: Adapt assembly for PIE support Date: Fri, 28 Apr 2023 17:50:46 +0800 Message-Id: <86defd5e8ee1328bbfbe7f6b293bacb4f1b7d23a.1682673543.git.houwenlong.hwl@antgroup.com> 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?1764414165979378386?= X-GMAIL-MSGID: =?utf-8?q?1764414165979378386?= 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/include/asm/sync_core.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/sync_core.h b/arch/x86/include/asm/sync_core.h index ab7382f92aff..fa5b1fe1a692 100644 --- a/arch/x86/include/asm/sync_core.h +++ b/arch/x86/include/asm/sync_core.h @@ -31,10 +31,12 @@ static inline void iret_to_self(void) "pushfq\n\t" "mov %%cs, %0\n\t" "pushq %q0\n\t" - "pushq $1f\n\t" + "leaq 1f(%%rip), %q0\n\t" + "pushq %q0\n\t" "iretq\n\t" "1:" - : "=&r" (tmp), ASM_CALL_CONSTRAINT : : "cc", "memory"); + : "=&r" (tmp), ASM_CALL_CONSTRAINT + : : "cc", "memory"); } #endif /* CONFIG_X86_32 */