Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1689769pxy; Thu, 6 May 2021 13:23:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+USZlBXOusxZI8NDXBN2PW13WtEG7mbkhmKgBeXdSMeE15E/5zYF76b2pCK3de5JQ++HN X-Received: by 2002:a17:90a:5885:: with SMTP id j5mr19851167pji.102.1620332604281; Thu, 06 May 2021 13:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620332604; cv=none; d=google.com; s=arc-20160816; b=AFscle7mvSgeye0JQl9pVxedwXnfSh7KxZa7qQHtJr/x3iX2mLYnaJB7XLNoRrGUwS fdFVeKXGGrA7uFRltU5fDC51R1gDQDCvM8qq41BizyKEbH4xF/uvC6Qd+jnUvg329+eI TFR45xthCxbV7Bh34DAGI6mgq7Azts1ygESGYyCUK8TJkM3aR1qqyOQffWnB8Mz2eIGU WsPhzNr0+n5F4W4Q5Npm5Ki5U7FBK+hCRFmd90eku/wiAdHGKzsIxoJnZZNDNB3PWYGm 9o7JYc0M49ZwBPyDMRPqit3Xd+YEp0lnhjvkEIUijSWUiZ0NFN5EdbO6KYiRd0t66lzf 8sLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=hkvQMeUwV3lUUZcHckLdVsZKUO+Em/Rb7jbt+jRJULk=; b=mhP/lJ1906r5PXoGrKrG9bUoiSjJkxmDap/nqiTZDvqn0eKv8sS6v9JcOgT3CcWOnG msZPnaqwrG/eoHYqzi1aEbUDh1GbGhArRgbZN3r9cLk0GFXrrqP8FfHythw20zpUL8qX QnSm441enpeoGIjW4Xf+tuw3r9Wivvh7WZuvyYx4R2o3Nwc0X9HCdG+B8cjOYrPcMReD dGR5xJ75yxMUyl3JaekNK3KdD6x0a0SZF1Gz/1553IQt61YUS+iIfsIOOQjYySSbePBC I0h9zvr7rIMs74Y0eQaiq38UHPGyHvZWw37yQ2UVra3umcR8x3dCX8fZQU54S3juQdv7 Opfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qHh1CFEY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si3632662pfe.55.2021.05.06.13.22.38; Thu, 06 May 2021 13:23:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qHh1CFEY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235911AbhEFTpN (ORCPT + 99 others); Thu, 6 May 2021 15:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235740AbhEFTox (ORCPT ); Thu, 6 May 2021 15:44:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E7E1C06138D for ; Thu, 6 May 2021 12:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=hkvQMeUwV3lUUZcHckLdVsZKUO+Em/Rb7jbt+jRJULk=; b=qHh1CFEY5Egi+5dlDfqjtG8qnh e/E4EDMvesLbzbdOP0+edu/8Z2Mczm1iDDAhSlvEIBqnjfnv1qkv7XpXvk8ksws+nwhyIkidseBPX /i6g+RLjkI55PcX00sVTzih1PGaI1JtiyALRoOGanfRwWqXqsGtjg3b50Qi49hRZ3isaHI/TvCnlw 8f9S4zgwkZTenV8+zWtG82yQ9zhdpuMgHE3abJpSraAKgCiD6i1hmO4YRftUJsByLu2FghlyI1ktd PDO8HSwradtzmIZhPnyBi+wuNP9Fx17GKRG39bmJvtVLjDcVT5O5LSMS9qcky8/sxrGO49Nr0eTFH rmlPdU1w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lejtS-002ADE-Cm; Thu, 06 May 2021 19:42:48 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 18A29300356; Thu, 6 May 2021 21:42:39 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id B1F2320B96F8B; Thu, 6 May 2021 21:42:38 +0200 (CEST) Message-ID: <20210506194157.786777050@infradead.org> User-Agent: quilt/0.66 Date: Thu, 06 May 2021 21:33:58 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 06/13] jump_label, x86: Introduce jump_entry_size() References: <20210506193352.719596001@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows architectures to have variable sized jumps. Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/include/asm/jump_label.h | 4 ++-- arch/x86/kernel/jump_label.c | 7 +++++++ include/linux/jump_label.h | 9 +++++++++ kernel/jump_label.c | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -4,8 +4,6 @@ #define HAVE_JUMP_LABEL_BATCH -#define JUMP_LABEL_NOP_SIZE 5 - #include #include @@ -47,6 +45,8 @@ static __always_inline bool arch_static_ return true; } +extern int arch_jump_entry_size(struct jump_entry *entry); + #endif /* __ASSEMBLY__ */ #endif --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -16,6 +16,13 @@ #include #include +#define JUMP_LABEL_NOP_SIZE JMP32_INSN_SIZE + +int arch_jump_entry_size(struct jump_entry *entry) +{ + return JMP32_INSN_SIZE; +} + static const void * __jump_label_set_jump_code(struct jump_entry *entry, enum jump_label_type type) { --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -176,6 +176,15 @@ static inline void jump_entry_set_init(s entry->key |= 2; } +static inline int jump_entry_size(struct jump_entry *entry) +{ +#ifdef JUMP_LABEL_NOP_SIZE + return JUMP_LABEL_NOP_SIZE; +#else + return arch_jump_entry_size(entry); +#endif +} + #endif #endif --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -309,7 +309,7 @@ EXPORT_SYMBOL_GPL(jump_label_rate_limit) static int addr_conflict(struct jump_entry *entry, void *start, void *end) { if (jump_entry_code(entry) <= (unsigned long)end && - jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE > (unsigned long)start) + jump_entry_code(entry) + jump_entry_size(entry) > (unsigned long)start) return 1; return 0;