Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp484619rdb; Thu, 1 Feb 2024 14:43:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqBPfxmfim32WIfLuZIqM7k+jH/oFA9FhqdJcVMrNQiJHvF7uuw1LrMhUm9qxtuhQ/xP3n X-Received: by 2002:a05:6358:703:b0:178:b0c9:118f with SMTP id e3-20020a056358070300b00178b0c9118fmr7005867rwj.26.1706827395457; Thu, 01 Feb 2024 14:43:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706827395; cv=pass; d=google.com; s=arc-20160816; b=toEBc/IDJqQa5ru+WS1ISUvUfH5egkV9s1axI4Mz6kJgVT2wPigOYw0C2Sw0Bbfvru ESXKEt5L6aMxgVOa2glxdPv+jfYydZWw/Q7gR7HlOKrywwRoFXdzqRJJuEXycWDMy0fb EKXIUf9Bmk6Pf9UgUPxeaZ+MbChDaeqM5uGtENeEKiU4bOTH0cwePmBSMfQQBXwNpeP7 BctCPyPLUklb8Mf/X1EcaQa40CTxq7Zk/h0xRvhIzIxZ+bp/mhY40A6IOX3swghhYIZX yC2zzg31EkBAL3wciY08wWwtnipqeYtBWUrKqTFkudacvnA41lkVTb7LVOZjEDNQTDIl VAmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=3B3tF1HYvRY1UkQ2K7cnSqpuGaSyeDgjRqaJd9RSiXg=; fh=i8Rzeq7yiIk43UqbuEQrVLLVRhA+OnGiotE/kFHwyUc=; b=aUmDd3Swu6mETBaedNFmI+kPBkYeF3u0ppJRFKS4QmYRSObeSXtJ3uZs5A+Fwx/bgi xqaDLEnZzP3KS4VS1r7/d0DnKBa7fHDOovAXrEmvKNL1RNM3eEFZZgc7nf0ZH+1w4h6+ okhZkRRue8tvRS6aJKh4tUVCrVlrYWVAHF3HaveAT2J6Qlv8TyE+BjnDdd/oZqOMBNq1 w2eNy11O50rWPuWa6Vw5PvSOu+Mmt6L3/Ba3Lq04Q+JpzwUNQpTWV3gopSwSmAeNLkGj kfW5559riBDjPTSyS7r5Ds0m/Et8dpGmwDxj6S9+/ZyVAstpcHJxeyE3mFeJGE2t7XpQ s7eA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zUrQV2Up; arc=pass (i=1 spf=pass spfdomain=flex--maskray.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-48951-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48951-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCVOOC8Sh6B/yz6PTmKRQyFJIZY5nBQejSd/VdnI1I7mOp33ej2D2NL/NlwAhI81R/V0ak3QV95A5kubwLKT4OBL8986biFNXvhYDPD+RQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b14-20020a63eb4e000000b005d42e7a9195si426726pgk.713.2024.02.01.14.43.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 14:43:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48951-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zUrQV2Up; arc=pass (i=1 spf=pass spfdomain=flex--maskray.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-48951-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48951-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BD0E42906A8 for ; Thu, 1 Feb 2024 22:37:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E1AE41211; Thu, 1 Feb 2024 22:37:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zUrQV2Up" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDEF23FB1D for ; Thu, 1 Feb 2024 22:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706827023; cv=none; b=epv29azH9CG58p0d6iCKfE1Ka/qmwQBOgVmFA/3J4Yy4lsxt2C5olrmsrjX+rx8Zrbs+70GWDz/URbkYy5K0/VgboTyRXRzw3kay8vuxESAqKP6G5r0NROR931MsbDH0mbumcXQ6ic5gCmesNMaRYgxUz32UvKeOxITgP1c24Tg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706827023; c=relaxed/simple; bh=C1Td7LS6mQYWKcz4HPRMpRrQao7T6kT+I564bAgKsBU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=pmZb8wSnC4kazbLHEoRgjgValAzKYAaThQH/qg6tCfwFFqVo7BlPhILOn/+blyGO1oxQiNVciYnDOibD8N/dcYi4+umci/W3FL4Lekh30Yp/rd0kbCBNDCjC+nEuSVSpM4FV+n+sfuojNkMupTCel8ALZsHZ+TJfygL5bSS8zKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--maskray.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zUrQV2Up; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--maskray.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbf618042daso2114982276.0 for ; Thu, 01 Feb 2024 14:37:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706827021; x=1707431821; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=3B3tF1HYvRY1UkQ2K7cnSqpuGaSyeDgjRqaJd9RSiXg=; b=zUrQV2Upjx8/DfFBOJflmwchTh9DcgyYDnSJXqn3q5/OwLg5BLdy8Ah8HZfKJYtlJS 28Nc+A+2y8rrdqcetumgwLd1QBqm2nzHrV/AHX6rTWyaP93zmLl6z1GqX8oEoChaaEjp tcQmn2OakN+SUmpSU6B6Cn59B3bCyFcssKyH2Sn30EGoFbSBoosWgHezncRzeq71YmnM H3MmsplIjTHtElydFCsQTSc1BvIicbnl1+DdWFDlRFkaMFxrzD4qUHqV68xys0prd3Q6 4wqmRhDfPyC/yYA4H+gBqMA27L1EJryhphVVPS2Il/nZDyeOZFR4r6+khYwKz5Pzet8a XCJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706827021; x=1707431821; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3B3tF1HYvRY1UkQ2K7cnSqpuGaSyeDgjRqaJd9RSiXg=; b=Uk5r86SfktO1MfavuKIp/ZlXLLeKV8HmMjJI27F98bbQs67w/Uj1gmeUVFKvYSMhMu bEXznZtZLo3WvTqXlCFalnxfuYoQLWgRVf+lTFTVXeq9s+mGSb2b1w5jWT+Ae1oMepy2 Ydmc189IJnUWoa8BlKXItM8oU6dT3CKxFbciFEScYIR0QKJCv3pi+D2la+s+kgX0SZEQ RX1YWQJQ+N7P0N6ZoZRAyd7qTdoExN9lvRcvOBk4BMqQaEBVQJTUe10nVPiu7renA5Zp 0HN0Ri6lr4UQLeyMM20D++e+97Ow69xsbgqVN25Aoxeoz+iAaMfa0lQJRCsLQUePsRRt J2zw== X-Gm-Message-State: AOJu0YxSM4u98CZpzX2nkbKOmzsJMBA/sm81uCdsaYdegabSLHbE9uQO TxY+PpMVzqtREgALOfFOqJrlwHD3jVgEFibUb0xtYzDr9YMM5wY1aoZVfSdrg8SmchXn8uYlICt epdHR9Q== X-Received: from maskray.svl.corp.google.com ([2620:15c:2d3:205:7de7:721a:241f:7455]) (user=maskray job=sendgmr) by 2002:a05:6902:cc9:b0:dc2:57c9:b44d with SMTP id cq9-20020a0569020cc900b00dc257c9b44dmr149539ybb.8.1706827021012; Thu, 01 Feb 2024 14:37:01 -0800 (PST) Date: Thu, 1 Feb 2024 14:35:45 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Message-ID: <20240201223545.728028-1-maskray@google.com> Subject: [PATCH] arm64: jump_label: use constraints "Si" instead of "i" From: Fangrui Song To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Cc: Jisheng Zhang , Dave Martin , Ard Biesheuvel , Peter Smith , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Fangrui Song Content-Type: text/plain; charset="UTF-8" The generic constraint "i" seems to be copied from x86 or arm (and with a redundant generic operand modifier "c"). It works with -fno-PIE but not with -fPIE/-fPIC in GCC's aarch64 port. The machine constraint "S", which denotes a symbol or label reference with a constant offset, supports PIC and has been available in GCC since 2012 and in Clang since 7.0. However, Clang before 19 does not support "S" on a symbol with a constant offset [1] (e.g. `static_key_false(&nf_hooks_needed[pf][hook])` in include/linux/netfilter.h), so we use "i" as a fallback. Suggested-by: Ard Biesheuvel Signed-off-by: Fangrui Song Link: https://github.com/llvm/llvm-project/pull/80255 [1] --- Changes from arm64: jump_label: use constraint "S" instead of "i" (https://lore.kernel.org/all/20240131065322.1126831-1-maskray@google.com/) * Use "Si" as Ard suggested to support Clang<19 * Make branch a separate operand --- arch/arm64/include/asm/jump_label.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h index 48ddc0f45d22..1f7d529be608 100644 --- a/arch/arm64/include/asm/jump_label.h +++ b/arch/arm64/include/asm/jump_label.h @@ -15,6 +15,10 @@ #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE +/* + * Prefer the constraint "S" to support PIC with GCC. Clang before 19 does not + * support "S" on a symbol with a constant offset, so we use "i" as a fallback. + */ static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch) { @@ -23,9 +27,9 @@ static __always_inline bool arch_static_branch(struct static_key * const key, " .pushsection __jump_table, \"aw\" \n\t" " .align 3 \n\t" " .long 1b - ., %l[l_yes] - . \n\t" - " .quad %c0 - . \n\t" + " .quad %0 + %1 - . \n\t" " .popsection \n\t" - : : "i"(&((char *)key)[branch]) : : l_yes); + : : "Si"(key), "i"(branch) : : l_yes); return false; l_yes: @@ -40,9 +44,9 @@ static __always_inline bool arch_static_branch_jump(struct static_key * const ke " .pushsection __jump_table, \"aw\" \n\t" " .align 3 \n\t" " .long 1b - ., %l[l_yes] - . \n\t" - " .quad %c0 - . \n\t" + " .quad %0 + %1 - . \n\t" " .popsection \n\t" - : : "i"(&((char *)key)[branch]) : : l_yes); + : : "Si"(key), "i"(branch) : : l_yes); return false; l_yes: -- 2.43.0.594.gd9cf4e227d-goog