Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1206303
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Peter Zijlstra <peterz@infradead.org> |
| Newsgroups | linux.kernel |
| Subject | Re: linux-next: manual merge of the xen-tip tree with the tip tree |
| Date | Wed, 12 Aug 2015 19:50:02 +0200 |
| Message-ID | <pWIk2-2ZP-29@gated-at.bofh.it> (permalink) |
| References | <pWwCd-2TC-11@gated-at.bofh.it> <pWEgp-5DF-1@gated-at.bofh.it> <pWI0G-2CX-11@gated-at.bofh.it> |
| X-Original-To | Boris Ostrovsky <boris.ostrovsky@oracle.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Disposition | inline |
| Content-Transfer-Encoding | 8bit |
| User-Agent | Mutt/1.5.21 (2012-12-30) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 131 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Stephen Rothwell <sfr@canb.auug.org.au>, Jeremy Fitzhardinge <jeremy@goop.org>, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Xen Devel <Xen-devel@lists.xensource.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>, linux-next@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>, David Vrabel <david.vrabel@citrix.com> |
| X-Original-Date | Wed, 12 Aug 2015 19:46:25 +0200 |
| X-Original-Message-ID | <20150812174625.GH18673@twins.programming.kicks-ass.net> |
| X-Original-References | <20150812150954.36bc605c@canb.auug.org.au> <55CB49CA.8050305@oracle.com> <20150812172105.GW16853@twins.programming.kicks-ass.net> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1206303 |
Show key headers only | View raw
On Wed, Aug 12, 2015 at 07:21:05PM +0200, Peter Zijlstra wrote:
> On Wed, Aug 12, 2015 at 09:27:38AM -0400, Boris Ostrovsky wrote:
>
> > Incidentally, 11276d53 ("locking/static_keys: Add a new static_key
> > interface") breaks old-ish compilers (gcc version 4.4.4 20100503 (Red Hat
> > 4.4.4-2) (GCC)):
> >
> >
> >
> > CC arch/x86/kernel/nmi.o
> > In file included from
> > /home/build/linux-boris/include/linux/jump_label.h:109,
> > from
> > /home/build/linux-boris/arch/x86/include/asm/spinlock.h:5,
> > from /home/build/linux-boris/include/linux/spinlock.h:88,
> > from /home/build/linux-boris/arch/x86/kernel/nmi.c:14:
> > /home/build/linux-boris/arch/x86/include/asm/jump_label.h: In function
> > ‘nmi_handle’:
> > /home/build/linux-boris/arch/x86/include/asm/jump_label.h:21: warning: asm
> > operand 0 probably doesn’t match constraints
> > /home/build/linux-boris/arch/x86/include/asm/jump_label.h:21: error:
> > impossible constraint in ‘asm’
> > make[3]: *** [arch/x86/kernel/nmi.o] Error 1
> > make[2]: *** [arch/x86/kernel] Error 2
> > make[1]: *** [arch/x86] Error 2
>
> Ugh bugger.
>
> I bet its that: &((char *)key)[branch] business, an earlier variant
> thereof tripped up more recent GCCs too.
>
> So its an __always_inline function, and both argument are always compile
> time constants, @key is the address of an object in static storage (a
> global) and @branch is a simple 0/1 at the call site.
>
> Now we wish to compute (unsigned long)key + branch at compile/link time
> to feed to the assembler as an immediate, which should be possible,
> given its all 'constants'.
>
> It just appears GCC is having a hard time with this.
>
> Let me see if I have a sufficiently old GCC around to play with.
Could you feed the below to your compiler? Its a bit cumbersome, but
its the next best I could come up with...
---
arch/x86/include/asm/jump_label.h | 56 ++++++++++++++++++++++++++++-----------
1 file changed, 41 insertions(+), 15 deletions(-)
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index 28d7a857f9d1..76c769ae4200 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -16,15 +16,30 @@
# define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC
#endif
+struct foo {
+ u8 zero;
+ u8 one;
+};
+
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
{
- asm_volatile_goto("1:"
- ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
- ".pushsection __jump_table, \"aw\" \n\t"
- _ASM_ALIGN "\n\t"
- _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
- ".popsection \n\t"
- : : "i" (&((char *)key)[branch]) : : l_yes);
+ if (!branch) {
+ asm_volatile_goto("1:"
+ ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
+ ".pushsection __jump_table, \"aw\" \n\t"
+ _ASM_ALIGN "\n\t"
+ _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
+ ".popsection \n\t"
+ : : "i" (&((struct foo *)key)->zero) : : l_yes);
+ } else {
+ asm_volatile_goto("1:"
+ ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
+ ".pushsection __jump_table, \"aw\" \n\t"
+ _ASM_ALIGN "\n\t"
+ _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
+ ".popsection \n\t"
+ : : "i" (&((struct foo *)key)->one) : : l_yes);
+ }
return false;
l_yes:
@@ -33,14 +48,25 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
{
- asm_volatile_goto("1:"
- ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
- "2:\n\t"
- ".pushsection __jump_table, \"aw\" \n\t"
- _ASM_ALIGN "\n\t"
- _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
- ".popsection \n\t"
- : : "i" (&((char *)key)[branch]) : : l_yes);
+ if (!branch) {
+ asm_volatile_goto("1:"
+ ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
+ "2:\n\t"
+ ".pushsection __jump_table, \"aw\" \n\t"
+ _ASM_ALIGN "\n\t"
+ _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
+ ".popsection \n\t"
+ : : "i" (&((struct foo *)key)->zero) : : l_yes);
+ } else {
+ asm_volatile_goto("1:"
+ ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
+ "2:\n\t"
+ ".pushsection __jump_table, \"aw\" \n\t"
+ _ASM_ALIGN "\n\t"
+ _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
+ ".popsection \n\t"
+ : : "i" (&((struct foo *)key)->one) : : l_yes);
+ }
return false;
l_yes:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
linux-next: manual merge of the xen-tip tree with the tip tree Stephen Rothwell <sfr@canb.auug.org.au> - 2015-08-12 07:20 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2015-08-12 15:30 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Peter Zijlstra <peterz@infradead.org> - 2015-08-12 19:30 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Peter Zijlstra <peterz@infradead.org> - 2015-08-12 19:40 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Peter Zijlstra <peterz@infradead.org> - 2015-08-12 19:50 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2015-08-12 20:20 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree "H. Peter Anvin" <hpa@zytor.com> - 2015-08-12 20:30 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Peter Zijlstra <peterz@infradead.org> - 2015-08-12 20:40 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2015-08-12 20:50 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Peter Zijlstra <peterz@infradead.org> - 2015-08-12 21:10 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Ingo Molnar <mingo@kernel.org> - 2015-08-13 08:50 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Andy Lutomirski <luto@amacapital.net> - 2015-08-12 20:30 +0200
Re: linux-next: manual merge of the xen-tip tree with the tip tree Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2015-08-12 20:40 +0200
csiph-web