Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp535685lqb; Thu, 29 Feb 2024 07:58:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXyYBAZVt0skVCC5agKla1sLSwZmZ/5Ci9xRply36iUXVq0WBkV3n27F7FaJIvfrfK5VK8p3CLGhojizYw2Ezz87HUDVR+iZuoVjafnfg== X-Google-Smtp-Source: AGHT+IHv6+Ohbp8bYhxPZ3YGCLu6n30heC7wvlleQBc6Wd0TdMEsMxxQH9xcu6QswMwRQA9+KGA9 X-Received: by 2002:a17:906:4714:b0:a3f:cd6b:80fd with SMTP id y20-20020a170906471400b00a3fcd6b80fdmr1937902ejq.7.1709222298297; Thu, 29 Feb 2024 07:58:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709222298; cv=pass; d=google.com; s=arc-20160816; b=eTY07RbJ3XI8SkiaB9jO3E8o1ClenE4wzrziDV/FyB88RMvfpx+8Pf/J4MkSIr6sMt ARg53OG6+sSwnSSqD8VtAhdHNoQiTHelaWxXQ6p5mr/P6T3wQmppG1OFFLImVlJrV8/6 tOWKHVqoyMX7bf1aeThu/UPbacmnYW2klUXJtlv4zrsNSSpwNmUuU5T91DVhcFK5GUhO w9E0fHoxOypq7AOF2m7/yZBZGHr7Glxwbo6lSHZo/Ep8SiJJedr8xqUWXl87SKAmrU1e MQdLvBypDMU7y5oJvnwQbVg1bWRLwIShRlFEGkHui1DtVhAE2PqmB7OFHM9TYWuBcb98 yn3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZvMV21YSnTpAWg7Mwk9gB1QIuErJf9v0v9+NBluT7/M=; fh=OlFmkO9ImKM9Na6Ox8Cfo/6sz5XcxIaHYbqLhu4D2h8=; b=mfmDs17SoAmL/7vZpvdhwh8QGcrWQWKxVnodu1jTMBm444n95qUMIDPHbu4MioA6Xt shXuk81NCUIJckc0li6PLDE4HOZMRmzJSmbHyiqhtQ5tu/lkvRbbtiKWe7xLnlWv8edf wnNPIXbAzHnoYayjWI598s1055//9u+IXtHy6m1xY3xHMIViooaP0RpOJmNs2RXBXHW4 eoWhn3Z8lU5ZkAyIQOybWVVWqOosWbB2iJ9eZV3xFwFetQD/iiIly7Bxg26T1qDHz+2J eGbP+3Sfc7cwnkW3Y4AU1ltmI+ZgUn8oVoUuDdT4N+004MXgfmZtKJphb/+wT5UvV+sp s55A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XkOEhK7E; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86981-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g12-20020a170906348c00b00a43fb65eca0si650771ejb.220.2024.02.29.07.58.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 07:58:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XkOEhK7E; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86981-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D2C411F21767 for ; Thu, 29 Feb 2024 15:58:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 540DD7A154; Thu, 29 Feb 2024 15:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XkOEhK7E" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66D897A144; Thu, 29 Feb 2024 15:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709221799; cv=none; b=Btwc0Mlhy1axJbkjiwgn83tO9me2UfTSXAoqSuMBsaxEuulvml1sjl2ssNT8zu7YA0tgpn5kLRHaKqSw8nccbVQ9u7dhxhiHdp+QOvObhwtZPpMeL5cngrrGoVl1LvcSQ4Os+NR2oU0XWDCpAF9GrhtJmU4RfMkqmV72mdjXuuQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709221799; c=relaxed/simple; bh=KcTNPiFwNY84hKxY/REFym2TAOMI7OjhJJXCHAPfAWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FFJ06XyOwtMJgSwzaJSzkbQMt6sgs9HCe/jkdTg1IxzU0meHomw8BUeu76NFstIIt4KmaEi3KN1x1SBqOdot5qGqD4M58NeTJuNadRdMcK3XEVY4tpKtVt8vbeD/pLefzAbUC6Z/gaXMiBPKVt/UpU2HUz6Z92/bT/xkeN7qvoU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XkOEhK7E; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 519E0C433B1; Thu, 29 Feb 2024 15:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709221799; bh=KcTNPiFwNY84hKxY/REFym2TAOMI7OjhJJXCHAPfAWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XkOEhK7ELb9lyjGf5gwUs1g0TQ6u2qNy1O3ApbGea9JmIrhHsgi3nG6vqIetvMhLH VLhtRMY5Tp/hZr9K7efacbd27sFudyLxylUk5aXx2iCQPwHIpic0eoCDFxdCc3tL+c zo/qhJhP62P+cBmkXniUF0/9HuANcIoXzjQvtQx2pdYE+R1ZyHBRpO9Up5sHzHcGgv o63O6RCwVzgVWCGldeAv4KmCRCmc2F6y9fPgRFlzzh8Z6V2w2u/Nar1BKUnqiDLfbT 1RHh/r/83ynJ+UxMBzELNoIofOX2qJMkPLknbDfW0YeyNcLjOjI76ppVi/xCmmzRJo 9RsxqVJcs8HiQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Fangrui Song , Ard Biesheuvel , Mark Rutland , Will Deacon , Sasha Levin , peterz@infradead.org, jpoimboe@kernel.org, jbaron@akamai.com, catalin.marinas@arm.com, nathan@kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 6.6 06/21] arm64: jump_label: use constraints "Si" instead of "i" Date: Thu, 29 Feb 2024 10:49:26 -0500 Message-ID: <20240229154946.2850012-6-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229154946.2850012-1-sashal@kernel.org> References: <20240229154946.2850012-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.18 Content-Transfer-Encoding: 8bit From: Fangrui Song [ Upstream commit f9daab0ad01cf9d165dbbbf106ca4e61d06e7fe8 ] 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] Acked-by: Mark Rutland Link: https://lore.kernel.org/r/20240206074552.541154-1-maskray@google.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- 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 48ddc0f45d228..b7716b215f91a 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 (%[key] - .) + %[bit0] \n\t" " .popsection \n\t" - : : "i"(&((char *)key)[branch]) : : l_yes); + : : [key]"Si"(key), [bit0]"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 (%[key] - .) + %[bit0] \n\t" " .popsection \n\t" - : : "i"(&((char *)key)[branch]) : : l_yes); + : : [key]"Si"(key), [bit0]"i"(branch) : : l_yes); return false; l_yes: -- 2.43.0