linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: linux-numa@vger.kernel.org
Subject: [PATCH] fix building as PIEs on x86
Date: Mon, 18 Apr 2016 18:56:22 -0400	[thread overview]
Message-ID: <1461020182-20317-1-git-send-email-vapier@gentoo.org> (raw)

You can't declare ebx as clobbered with most versions of gcc when you
build as PIC/PIE.  Save/restore the code ourselves using xchg & esi.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 clearcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clearcache.c b/clearcache.c
index 82469c1..4acf024 100644
--- a/clearcache.c
+++ b/clearcache.c
@@ -57,7 +57,7 @@ void clearcache(unsigned char *mem, unsigned size)
 #if defined(__i386__) || defined(__x86_64__)
 	unsigned i, cl, eax, feat;
 	/* get clflush unit and feature */
-	asm("cpuid" : "=a" (eax), "=b" (cl), "=d" (feat) : "0" (1) : "cx");
+	asm("xchg %%ebx, %%esi; cpuid; xchg %%esi, %%ebx;" : "=a" (eax), "=S" (cl), "=d" (feat) : "0" (1) : "cx");
 	if (!(feat & (1 << 19)))
 		fallback_clearcache();
 	cl = ((cl >> 8) & 0xff) * 8;
-- 
2.7.4

                 reply	other threads:[~2016-04-18 22:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1461020182-20317-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=linux-numa@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).