From patchwork Mon Feb 27 22:50:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 9594401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EB11B60453 for ; Mon, 27 Feb 2017 22:50:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC68D27F9E for ; Mon, 27 Feb 2017 22:50:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D08A42849E; Mon, 27 Feb 2017 22:50:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4D68F27F9E for ; Mon, 27 Feb 2017 22:50:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FGNwY97ikOeYx/k9/q1h6ql6rR26dCn/HmNNX6+bnQM=; b=umMCEkmeM4ZXaeGo4O2Rtkvu2 ST5tt24G9e22VJMfxREUP6pK2LK3X+RD0x9RM+YHyZwY/oBVBI88Cl2B5GSJLCc5yaxWLecxNozfF 0htJwKDVBrME/udMFcC9+48i2Vlsg4QpxBpS5ChHq+CC7AcR4AJBD6vIH2KaAdN3tgDNLBnUt54Qs 5++p8CsxA6/tyrmEV/VD6NwSjq/dqAljqdYeEYjdT/1xeOaUM+dpve1FmDOatO/Wbj1H+qNziiczZ uf7TTXx3AntiwbFRaD5jlVXle7WE5kzZojjGM/4WDI0Xx4VWDOLgGzieUCFxCdFWAfGhfJ6c5Y54Y QylQZyYRA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ciU86-0006j3-T2; Mon, 27 Feb 2017 22:50:54 +0000 Received: from prod-mail-xrelay07.akamai.com ([23.79.238.175]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ciU82-0006Sb-1R for linux-arm-kernel@lists.infradead.org; Mon, 27 Feb 2017 22:50:53 +0000 Received: from prod-mail-xrelay07.akamai.com (localhost.localdomain [127.0.0.1]) by postfix.imss70 (Postfix) with ESMTP id E5EF643342D; Mon, 27 Feb 2017 22:50:25 +0000 (GMT) Received: from prod-mail-relay11.akamai.com (prod-mail-relay11.akamai.com [172.27.118.250]) by prod-mail-xrelay07.akamai.com (Postfix) with ESMTP id BD4CD433417; Mon, 27 Feb 2017 22:50:25 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; s=a1; t=1488235825; bh=0ydoRGjMz3Yc1wMdvMpmFAuqvTm65Y5yNGwPyIu8Ijc=; l=3562; h=To:References:Cc:From:Date:In-Reply-To:From; b=HMnTfa3XMKtF9MnrvOmaEFkqP4jRbHcNOmnr25wl6SrvdcoK6QualokpUdvS5Q9tw nIuDWbHxN48S3cuA27iG6omqfdOkXoZyTbHEJAjp2uNzW8+UOkFfxYDRmPxGPnqjVI ev3Ki4oGJA+pR7Jiub3utH3LVQgEC8OTG2sHuEpM= Received: from [172.28.13.148] (bos-lpjec.kendall.corp.akamai.com [172.28.13.148]) by prod-mail-relay11.akamai.com (Postfix) with ESMTP id AA6C91FC88; Mon, 27 Feb 2017 22:50:25 +0000 (GMT) Subject: Re: [PATCH] jump_label: align jump_entry table to at least 4-bytes To: David Daney , Steven Rostedt , Sachin Sant References: <1488221364-13905-1-git-send-email-jbaron@akamai.com> <93219edf-0f6d-5cc7-309c-c998f16fe7ac@akamai.com> <20170227160601.5b79a1fe@gandalf.local.home> <6db89a8d-6053-51d1-5fd4-bae0179a5ebd@caviumnetworks.com> <20170227170911.2280ca3e@gandalf.local.home> <7fa95eea-20be-611c-2b63-fca600779465@caviumnetworks.com> <20170227173630.57fff459@gandalf.local.home> <7bd72716-feea-073f-741c-04212ebd0802@caviumnetworks.com> From: Jason Baron Message-ID: <68fe24ea-7795-24d8-211b-9d8a50affe9f@akamai.com> Date: Mon, 27 Feb 2017 17:50:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <7bd72716-feea-073f-741c-04212ebd0802@caviumnetworks.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170227_145050_402469_E221C508 X-CRM114-Status: GOOD ( 16.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Chris Metcalf , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Ralf Baechle , Russell King , Rabin Vincent , Paul Mackerras , Anton Blanchard , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Ingo Molnar , linux-arm-kernel@lists.infradead.org, Zhigang Lu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 02/27/2017 05:45 PM, David Daney wrote: > On 02/27/2017 02:36 PM, Steven Rostedt wrote: >> On Mon, 27 Feb 2017 14:21:21 -0800 >> David Daney wrote: >> >>> See attached for mips. It seems to do the right thing. >>> >>> I leave it as an exercise to the reader to fix the other architectures. >>> >>> Consult your own binutils experts to verify that what I say is true. >> >> It may still just be safer to do the pointers instead. That way we >> don't need to worry about some strange arch or off by one binutils >> messing it up. > > Obviously it is your choice, but this is bog standard ELF linking. In > theory even the arrays of power-of-2 sized objects should also supply an > entity size. Think __ex_table and its ilk. > > > The benefit of supplying an entsize is that you don't have to change the > structure of the existing code and risk breaking something in the process. > > David Daney > > Thanks for the suggestion! I would like to see if this resolves the ppc issue we had. I'm attaching a powerpc patch based on your suggestion. Hopefully, Sachin can try it. Thanks, -Jason diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h index 9a287e0ac8b1..3c5660e50f9a 100644 --- a/arch/powerpc/include/asm/jump_label.h +++ b/arch/powerpc/include/asm/jump_label.h @@ -19,14 +19,26 @@ #define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG) #define JUMP_LABEL_NOP_SIZE 4 +#ifdef CONFIG_PPC64 +typedef u64 jump_label_t; +#else +typedef u32 jump_label_t; +#endif + +struct jump_entry { + jump_label_t code; + jump_label_t target; + jump_label_t key; +}; + static __always_inline bool arch_static_branch(struct static_key *key, bool branch) { asm_volatile_goto("1:\n\t" "nop # arch_static_branch\n\t" - ".pushsection __jump_table, \"aw\"\n\t" + ".pushsection __jump_table, \"awM\",@progbits, %1\n\t" JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t" ".popsection \n\t" - : : "i" (&((char *)key)[branch]) : : l_yes); + : : "i" (&((char *)key)[branch]), "i" (sizeof(struct jump_entry)) : : l_yes); return false; l_yes: @@ -37,32 +49,24 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool { asm_volatile_goto("1:\n\t" "b %l[l_yes] # arch_static_branch_jump\n\t" - ".pushsection __jump_table, \"aw\"\n\t" + ".pushsection __jump_table, \"awM\",@progbits, %1\n\t" JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t" ".popsection \n\t" - : : "i" (&((char *)key)[branch]) : : l_yes); + : : "i" (&((char *)key)[branch]), "i" (sizeof(struct jump_entry)) : : l_yes); return false; l_yes: return true; } -#ifdef CONFIG_PPC64 -typedef u64 jump_label_t; + #else -typedef u32 jump_label_t; -#endif -struct jump_entry { - jump_label_t code; - jump_label_t target; - jump_label_t key; -}; +#define ENTRY_SIZE (ULONG_SIZE * 3) -#else #define ARCH_STATIC_BRANCH(LABEL, KEY) \ 1098: nop; \ - .pushsection __jump_table, "aw"; \ + .pushsection __jump_table, "awM",@progbits,ENTRY_SIZE; \ FTR_ENTRY_LONG 1098b, LABEL, KEY; \ .popsection #endif