From patchwork Fri Apr 28 09:50:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Wenlong X-Patchwork-Id: 88552 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp815915vqo; Fri, 28 Apr 2023 03:01:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Y8xvOqa+kgz6vMTqz8WQV8fW16b32qY7WOHEsK7z8Kh2jZ5pPN67Ev0B7meU4c98/kDy5 X-Received: by 2002:a05:6a00:2ea6:b0:63f:24f1:adac with SMTP id fd38-20020a056a002ea600b0063f24f1adacmr7832536pfb.25.1682676104142; Fri, 28 Apr 2023 03:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682676104; cv=none; d=google.com; s=arc-20160816; b=C+iKBfwnd4rRQxqKDCOsdWKfYJRSqZNUSX1FlVjczo39y+yTeuP2ENcubcCSyMhieD OH6y2pE7CmopjRFtoJceTqsFMbpJnnJZ3z4Fthwu4gfK8xRWMzB/dZR9j6AfziJa933k TLIBEZhkNUure6Xvihs51jB7+hXnCU0iH4QKC471wuEK8AIfs9dUcncvQXOGOX6y2nvB doJnqeSO4034+ZunhibmysZaYcvVYB+qXMiXIBL1mG69EkPz8pvsA27M8UmWlocz7Rzd qLSNvCyPRMBgdemyahVFYgxXLqYtnpfIsF6FlBQRDq4YdDi+OO2klHjhwo1uZ43SPfJv WHFg== 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=kNzViBjhN5Ze8gUicJ75SGyKKI+ewsaHwplG0KEKdWo=; b=FcAczKCGmEK2ik+XZlcAiX2sedsEiGOl7/v6y+bwKHILVXNikRA7h/lcZQH5qXBDTS 7lcjIpNE7PKrA+H01XLC0NxuupFB/lMESnbYeQ2DxK5zo8PNfjZ2bP/uCf4RuRoC5RMu yme8PvE2Y/Y2i1uAtzzExSRZ6F5sR43J+w1C7ULRT4v5N+5z6MA6ZStS9ehOBiK74eEf DKcvj50/2sv4Df4FymYN205D8GZZtlDfy9RhQYJXu0JAa+gNe95S244LFyuw3g08ET7f 1wdaojDSTntjtuBzw8mD1kGlhyUaGvTUONAjeSY+sw+hgLxaKpFLVy5wFKYt4NezsuMp sYAw== 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 g38-20020a632026000000b0051ef3e0cdaesi20030287pgg.260.2023.04.28.03.01.30; Fri, 28 Apr 2023 03:01:44 -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 S1345854AbjD1JxB (ORCPT + 99 others); Fri, 28 Apr 2023 05:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345815AbjD1Jwh (ORCPT ); Fri, 28 Apr 2023 05:52:37 -0400 Received: from out0-194.mail.aliyun.com (out0-194.mail.aliyun.com [140.205.0.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8293759F2 for ; Fri, 28 Apr 2023 02:52:16 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;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=13;SR=0;TI=SMTPD_---.STFoGBM_1682675527; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.STFoGBM_1682675527) by smtp.aliyun-inc.com; Fri, 28 Apr 2023 17:52:08 +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" , "Peter Zijlstra" , "Willy Tarreau" Subject: [PATCH RFC 10/43] x86/alternatives: Adapt assembly for PIE support Date: Fri, 28 Apr 2023 17:50:50 +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?1764413778608703414?= X-GMAIL-MSGID: =?utf-8?q?1764413778608703414?= From: Thomas Garnier From: Thomas Garnier Change the assembly options to work with pointers instead of integers. The generated code is the same PIE just ensures input is a pointer. Signed-off-by: Thomas Garnier Signed-off-by: Hou Wenlong Cc: Lai Jiangshan Cc: Kees Cook --- arch/x86/include/asm/alternative.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index d7da28fada87..cbf7c93087c8 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -307,7 +307,7 @@ static inline int alternatives_text_reserved(void *start, void *end) /* Like alternative_io, but for replacing a direct call with another one. */ #define alternative_call(oldfunc, newfunc, ft_flags, output, input...) \ asm_inline volatile (ALTERNATIVE("call %P[old]", "call %P[new]", ft_flags) \ - : output : [old] "i" (oldfunc), [new] "i" (newfunc), ## input) + : output : [old] "X" (oldfunc), [new] "X" (newfunc), ## input) /* * Like alternative_call, but there are two features and respective functions. @@ -320,8 +320,8 @@ static inline int alternatives_text_reserved(void *start, void *end) asm_inline volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", ft_flags1,\ "call %P[new2]", ft_flags2) \ : output, ASM_CALL_CONSTRAINT \ - : [old] "i" (oldfunc), [new1] "i" (newfunc1), \ - [new2] "i" (newfunc2), ## input) + : [old] "X" (oldfunc), [new1] "X" (newfunc1), \ + [new2] "X" (newfunc2), ## input) /* * use this macro(s) if you need more than one output parameter