From patchwork Thu Feb 1 22:35:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 195492 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp68211dyc; Thu, 1 Feb 2024 14:37:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHf/DaSNspzSf/cVw3KsJqn1uNUcgqAuuT3ZS310/sELSrLQiKEh5EbESa9Mn9YOLFSYvH X-Received: by 2002:a05:622a:18a1:b0:42a:853e:1a4 with SMTP id v33-20020a05622a18a100b0042a853e01a4mr6694264qtc.36.1706827036312; Thu, 01 Feb 2024 14:37:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706827036; cv=pass; d=google.com; s=arc-20160816; b=yvPukUB0CS7x9S7VZN/dCyfrEDYBDdIKaUonsn14glsyAsO6CSNEejT8S7n+HhWQKE NotPwVPRmxELEeVEwNm6dg71LXnMUkYjxBjq4CxCg3UbFOeZQwvwmWJroghtQKXH+sRR Adynm4/J/Lpv0lxXS43MhmU4L4K1Zpo42uK3+4E37JsGbIiKe8/A+P0NMCGaqRLMwMTI tPD22onvpuUvlTgDaAJgOCW7hibW0LXVrVVd1QpnrlTP3MH8hk4bSsjM06fUTelXPcuG Z+Iro6Zekyu7L6JOzkcl4q1jk7AOrEOg5WxCr44bnfA6j403B4pNAWn/HM3P5cnVL86Y muuw== 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=nEYMAEcLnboWezMQhAxbZHegQwvukrxjj16o1Kwnlg4=; b=rmw+r2BSSqq6IOLYNmKyLSqcppTqKpgCTdi0rTfjzjQlq37c/5BETQ+CAs6tk2I5mZ V675LDCH4SboC1g+XeuFh8LPMDnaweoaP2dqx7MGzLa7ASCtJUbnMfdx5WcjNJ/Q1BvZ h3Xnkm9Tx8k8YlZQrhkPH4HH997GyVq0wFmZq5kKYRl60oJ+UHSPHNLfP3CbwIzA4Wzh N5VhZ6pcxSNlln503qW7bx/1QPqzfgEKA6q97do8Yb3M4coiH+UqIo9YMy2sntSALEj2 r/WsrLwoptw8Pn1SSROhNngKrqmuFGYVbJxhbtTP13v45R3BUHCGuJ0j5X8lDBRf/8vH PDqA==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48951-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCUJ5dpIHKsKIvWOP0vT/3jO5hme0gYyhDlbkuxK6oHFSyUUFh+8vqBUKmDRxV2kYZ0NMhCqCm1kWVeDUWt/jiE56D9P6Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bp11-20020a05622a1b8b00b0042bf8f59cc3si534692qtb.378.2024.02.01.14.37.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 14:37:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48951-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48951-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 214401C22AF6 for ; Thu, 1 Feb 2024 22:37:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3122C4122C; Thu, 1 Feb 2024 22:37:06 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789737866416428728 X-GMAIL-MSGID: 1789737866416428728 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: