Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1883745lqa; Tue, 30 Apr 2024 01:59:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXc1B7Ly7AHVt+mMaIKLo24WpTrE29vB5ea90yMAHNrgD4VThchXZo7ekySsaSzwmz4tyfvb5xBS0pf7F6aL9hySa4bwQIDLWZsNLd1iQ== X-Google-Smtp-Source: AGHT+IEUx+qmG/U2nThPhpm9e0yCFZYfM8hohh39sf0giMtlLl/Kf3o1rTiKbLnoSN6XxVo2ZbVh X-Received: by 2002:a05:6122:1788:b0:4c0:2d32:612f with SMTP id o8-20020a056122178800b004c02d32612fmr11743867vkf.15.1714467557253; Tue, 30 Apr 2024 01:59:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714467557; cv=pass; d=google.com; s=arc-20160816; b=SiEmaCjJFBTcwgk+Y9PononWVbdEmMrlgWZ2DaPIuDmMRCVxiRoleabIgzMNzHkNLl 6nc3ogAROzYOn/IYqlgICveEbIde2r6lkY6yflZ71k9JMVbZst3c0rdX0wAw8rfHl+YU aVHi4Zh/IM436fml04SHZEM7It7Mt7SZbt0+j9/Ct63WTaevGFUkg9G9bNZZIrw/S7LX yLF6JlTnKxHT4ec6uih5xgVpaw9ut4afkaRKg8+SIuLB9bZ7K54Y7ARrMgDd75bPJv5S hetMwfbXCZ7NqifKAJsm0CAXU1h7WY4EXUEgYS0dTeLPFiPu6SpYhmA7VNSpXwByR2Du pFWQ== 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=coNJgQXJx6rWysDXjwJJAKNcI1CfudjLlaUiK4+GVcc=; fh=hyRTPyIvt9LCA9RJVNXJQ4MWZ2svUAfhgZ7mKxgiTYU=; b=p9g5N3J9CuQO8h6LVEQn2XXpeaIxhoJmbNRQ6SKuOwtZnwDaU79JE+drAC+NP/1hnX EiBHJpUeIkYtQ3vMUpTGQwOzVeeJthWbKSCTHGRPSzg6SUL6SnTJKhiv2aaPQwaghcH7 zO3ROgdxwnn+o7Mormb5qmnlIBK7zHuoD3R6nor8Z96+nvifIDoUg4hAwTIsiLZD/cVe 7NBTUPdw3I6XaHCZQHeE4LdJk1BdXFd/3H4GAhFvusCTN1CQ0SwvVc1GbMVGaclMbw25 Cg/YdYwe89ErpCJvhYeGb8xxsmInzDGowftOQShsWehmNQcguY2xWusBVmlwYDf37FEH ih6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jy7WzJOZ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-163612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id vu3-20020a05620a560300b00790ec77c086si5430688qkn.678.2024.04.30.01.59.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 01:59:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163612-linux.lists.archive=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=@linux.dev header.s=key1 header.b=jy7WzJOZ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-163612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 EC8691C225C4 for ; Tue, 30 Apr 2024 08:59:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C00EA129E66; Tue, 30 Apr 2024 08:57:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="jy7WzJOZ" Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 607BF128813 for ; Tue, 30 Apr 2024 08:57:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714467439; cv=none; b=TdT8qe8rCg7bEdFh/KIXSnTzbOaj0PlHxRUlUrBQ9Uz3FcAtaBbB1cm750oTq33y7NGainZNQ7tyHXs1PZrLOkM97txBhcH1Hjvn+Ld+/I+h/VYwH0+qp1tjdwPgY7ZmhUzZP77U8k3wx4iEdPfBmmPbsSCDqas4h1Juql8ANCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714467439; c=relaxed/simple; bh=rEosPRTdG06gJvJ1UJqnR8e29NPloE5LAew93gOUQpg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LlwLIXNDhyUKSHD5CQrpvEUTSVKu+3ntmcO2SrW8BU8WlAbZ2xZOOkhkCxI1LIyuzy6ojGokhZSJcqU+XWdf3C02JltioQo8D6mwMx8qsNLn2gYvlbIpN1iSa+MaLD8mXjWGEcTBFJihGL//BR/NJ6l2LllyqzSdadMLc7aRatk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=jy7WzJOZ; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714467435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=coNJgQXJx6rWysDXjwJJAKNcI1CfudjLlaUiK4+GVcc=; b=jy7WzJOZ6T5WSb8bk6k7Bh9Gj8OYkNbzSSk0MyWTg+AiBtGq7C/zT+u9tKTJSbLcN0qoMV 8Y5IjGMoWMwyvuSCrYgMJ7EosEijGpRJjzUcH5d4AuOpjSGLYXZukj4FXN2xLzJWE6ryVo YDImg3xCi5CpbQSdYpsZOgotWfbP4zU= From: George Guo To: mark.rutland@arm.com Cc: ardb@kernel.org, catalin.marinas@arm.com, dongtai.guo@linux.dev, guodongtai@kylinos.cn, jbaron@akamai.com, jpoimboe@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, peterz@infradead.org, rostedt@goodmis.org, will@kernel.org Subject: [PATCH v3 1/1] arm64: simplify arch_static_branch/_jump function Date: Tue, 30 Apr 2024 16:56:55 +0800 Message-Id: <20240430085655.2798551-2-dongtai.guo@linux.dev> In-Reply-To: <20240430085655.2798551-1-dongtai.guo@linux.dev> References: <20240430085655.2798551-1-dongtai.guo@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: George Guo Extracted the jump table definition code from the arch_static_branch and arch_static_branch_jump functions into a macro JUMP_TABLE_ENTRY to reduce code duplication. Signed-off-by: George Guo --- arch/arm64/include/asm/jump_label.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h index 6aafbb789991..d43fce47feb9 100644 --- a/arch/arm64/include/asm/jump_label.h +++ b/arch/arm64/include/asm/jump_label.h @@ -15,17 +15,23 @@ #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE +#define JUMP_TABLE_ENTRY(key, label) \ + ".pushsection __jump_table, \"aw\"\n\t" \ + ".align 3\n\t" \ + ".long 1b - ., %l["#label"] - .\n\t" \ + ".quad %c0 - .\n\t" \ + ".popsection\n\t" \ + : : "i"(key) : : label + static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch) { + char *k = &((char *)key)[branch]; + asm goto( "1: nop \n\t" - " .pushsection __jump_table, \"aw\" \n\t" - " .align 3 \n\t" - " .long 1b - ., %l[l_yes] - . \n\t" - " .quad %c0 - . \n\t" - " .popsection \n\t" - : : "i"(&((char *)key)[branch]) : : l_yes); + JUMP_TABLE_ENTRY(k, l_yes) + ); return false; l_yes: @@ -35,15 +41,11 @@ static __always_inline bool arch_static_branch(struct static_key * const key, static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch) { + char *k = &((char *)key)[branch]; asm goto( "1: b %l[l_yes] \n\t" - " .pushsection __jump_table, \"aw\" \n\t" - " .align 3 \n\t" - " .long 1b - ., %l[l_yes] - . \n\t" - " .quad %c0 - . \n\t" - " .popsection \n\t" - : : "i"(&((char *)key)[branch]) : : l_yes); - + JUMP_TABLE_ENTRY(k, l_yes) + ); return false; l_yes: return true; -- 2.34.1