xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
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>
Subject: Re: linux-next: manual merge of the xen-tip tree with the tip tree
Date: Wed, 12 Aug 2015 19:46:25 +0200	[thread overview]
Message-ID: <20150812174625.GH18673@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20150812172105.GW16853@twins.programming.kicks-ass.net>

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:

  parent reply	other threads:[~2015-08-12 17:46 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12  5:09 linux-next: manual merge of the xen-tip tree with the tip tree Stephen Rothwell
2015-08-12 13:27 ` Boris Ostrovsky
2015-08-12 17:21   ` Peter Zijlstra
2015-08-12 17:38     ` Peter Zijlstra
2015-08-12 17:46     ` Peter Zijlstra [this message]
2015-08-12 18:17       ` Boris Ostrovsky
2015-08-12 18:26         ` Andy Lutomirski
2015-08-12 18:30           ` Boris Ostrovsky
2015-08-12 18:26         ` H. Peter Anvin
2015-08-12 18:36           ` Peter Zijlstra
2015-08-12 18:44             ` Boris Ostrovsky
2015-08-12 19:04               ` Peter Zijlstra
2015-08-13  6:45                 ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2021-10-28  6:16 Stephen Rothwell
2017-08-31  4:37 Stephen Rothwell
2017-08-31  4:26 Stephen Rothwell
2017-08-31  8:10 ` Thomas Gleixner
2017-08-31  9:00   ` Thomas Gleixner
2017-08-31  9:16     ` Ingo Molnar
2017-08-31 12:36       ` Joe Perches
2017-08-31 10:11     ` Juergen Gross
2017-08-31 12:00       ` Thomas Gleixner
2017-08-31 14:01         ` Boris Ostrovsky
2017-08-31 14:03           ` Juergen Gross
2017-08-31 18:30           ` Thomas Gleixner
2017-08-28  5:20 Stephen Rothwell
2017-08-17  4:03 Stephen Rothwell
2017-06-28  4:21 Stephen Rothwell
2017-04-12  4:30 Stephen Rothwell
2017-04-26  4:57 ` Stephen Rothwell
2017-04-12  4:20 Stephen Rothwell
2017-03-29  3:36 Stephen Rothwell
2017-03-29  3:37 ` Stephen Rothwell
2017-03-29  3:35 Stephen Rothwell
2017-03-29  8:37 ` Juergen Gross
2017-03-29  8:59   ` Ingo Molnar
2017-03-29  9:28     ` Juergen Gross
2017-03-29 10:06       ` Vitaly Kuznetsov
2017-04-03 18:03         ` Juergen Gross
2017-04-04 16:04           ` Vitaly Kuznetsov
2017-04-04 16:09             ` Juergen Gross
2017-04-05  6:25             ` Juergen Gross
2017-04-03 14:38       ` Ingo Molnar
2017-04-03 14:55         ` Juergen Gross
2017-03-29  9:54     ` Juergen Gross
2017-03-29 10:41       ` Ingo Molnar
2017-03-29 11:13       ` Stephen Rothwell
2016-10-03  1:29 Stephen Rothwell
2016-07-26  4:02 Stephen Rothwell
2016-07-26  4:01 Stephen Rothwell
2016-07-26 13:58 ` Boris Ostrovsky
2016-07-18  6:17 Stephen Rothwell
2016-05-02  4:51 Stephen Rothwell
2016-04-29  4:20 Stephen Rothwell
2014-03-20  4:15 Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150812174625.GH18673@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=Xen-devel@lists.xensource.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@elte.hu \
    --cc=sfr@canb.auug.org.au \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).