LKML Archive on lore.kernel.org
 help / color / Atom feed
From: "H. Peter Anvin" <hpa@linux.intel.com>
To: "H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Mario Gzuk <mariogzuk@technikz.de>,
	"H. Peter Anvin" <hpa@linux.intel.com>
Subject: [PATCH 8/8] x86, cleanups: Simplify sync_core() in the case of no CPUID
Date: Wed, 28 Nov 2012 11:50:30 -0800
Message-ID: <1354132230-21854-9-git-send-email-hpa@linux.intel.com> (raw)
In-Reply-To: <1354132230-21854-1-git-send-email-hpa@linux.intel.com>

From: "H. Peter Anvin" <hpa@linux.intel.com>

Simplify the implementation of sync_core() for the case where we may
not have the CPUID instruction available.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/processor.h | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 9a4ee46..b381df7 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -673,17 +673,24 @@ static inline void sync_core(void)
 	int tmp;
 
 #ifdef CONFIG_M486
-	if (boot_cpu_data.x86 < 5)
-		/* There is no speculative execution.
-		 * jmp is a barrier to prefetching. */
-		asm volatile("jmp 1f\n1:\n" ::: "memory");
-	else
+	/*
+	 * Do a CPUID if available, otherwise do a jump.  The jump
+	 * can conveniently enough be the jump around CPUID.
+	 */
+	asm volatile("cmpl %2,%1\n\t"
+		     "jl 1f\n\t"
+		     "cpuid\n"
+		     "1:"
+		     : "=a" (tmp)
+		     : "rm" (boot_cpu_data.cpuid_level), "ri" (0), "0" (1)
+		     : "ebx", "ecx", "edx", "memory");
+#else
+	/* cpuid is a barrier to speculative execution.
+	 * Prefetched instructions are automatically
+	 * invalidated when modified. */
+	asm volatile("cpuid" : "=a" (tmp) : "0" (1)
+		     : "ebx", "ecx", "edx", "memory");
 #endif
-		/* cpuid is a barrier to speculative execution.
-		 * Prefetched instructions are automatically
-		 * invalidated when modified. */
-		asm volatile("cpuid" : "=a" (tmp) : "0" (1)
-			     : "ebx", "ecx", "edx", "memory");
 }
 
 static inline void __monitor(const void *eax, unsigned long ecx,
-- 
1.7.11.7


  parent reply index

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28 19:50 [PATCH 0/8] RFC: Remove 386 support H. Peter Anvin
2012-11-28 19:50 ` [PATCH 1/8] x86, 386 removal: Remove CONFIG_M386 from Kconfig H. Peter Anvin
2012-12-01  0:34   ` [tip:x86/nuke386] " tip-bot for H. Peter Anvin
2012-11-28 19:50 ` [PATCH 2/8] x86, 386 removal: Remove CONFIG_CMPXCHG H. Peter Anvin
2012-12-01  0:35   ` [tip:x86/nuke386] " tip-bot for H. Peter Anvin
2012-11-28 19:50 ` [PATCH 3/8] x86, 386 removal: Remove CONFIG_XADD H. Peter Anvin
2012-11-28 20:30   ` Borislav Petkov
2012-12-01  0:36   ` [tip:x86/nuke386] " tip-bot for H. Peter Anvin
2012-11-28 19:50 ` [PATCH 4/8] x86, 386 removal: Remove CONFIG_BSWAP H. Peter Anvin
2012-12-01  0:37   ` [tip:x86/nuke386] " tip-bot for H. Peter Anvin
2012-11-28 19:50 ` [PATCH 5/8] x86, 386 removal: Remove CONFIG_INVLPG H. Peter Anvin
2012-12-01  0:38   ` [tip:x86/nuke386] " tip-bot for H. Peter Anvin
2012-11-28 19:50 ` [PATCH 6/8] x86, 386 removal: Remove CONFIG_X86_WP_WORKS_OK H. Peter Anvin
2012-11-28 20:52   ` Alan Cox
2012-11-28 23:11     ` H. Peter Anvin
2012-12-01  0:42     ` [tip:x86/nuke386] x86, 386 removal: Document Nx586 as a 386 and thus unsupported tip-bot for H. Peter Anvin
2012-12-01  0:39   ` [tip:x86/nuke386] x86, 386 removal: Remove CONFIG_X86_WP_WORKS_OK tip-bot for H. Peter Anvin
2012-11-28 19:50 ` [PATCH 7/8] x86, 386 removal: Remove CONFIG_X86_POPAD_OK H. Peter Anvin
2012-12-01  0:40   ` [tip:x86/nuke386] " tip-bot for H. Peter Anvin
2012-11-28 19:50 ` H. Peter Anvin [this message]
2012-11-28 20:41   ` [PATCH 8/8] x86, cleanups: Simplify sync_core() in the case of no CPUID Borislav Petkov
2012-11-29  0:14     ` H. Peter Anvin
2012-11-29  9:13       ` Borislav Petkov
2012-11-29 21:06         ` H. Peter Anvin
2012-11-29 21:18           ` Borislav Petkov
2012-11-29 21:20             ` H. Peter Anvin
2012-11-29 21:31               ` Borislav Petkov
2012-11-29 21:24     ` H. Peter Anvin
2012-11-29 21:34       ` Borislav Petkov
2012-11-30 17:01       ` Linus Torvalds
2012-11-30 17:28         ` Borislav Petkov
2012-11-30 18:03         ` H. Peter Anvin
2012-11-30 18:10           ` Borislav Petkov
2012-11-30 18:40             ` H. Peter Anvin
2012-12-01  0:41   ` [tip:x86/nuke386] " tip-bot for H. Peter Anvin

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=1354132230-21854-9-git-send-email-hpa@linux.intel.com \
    --to=hpa@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mariogzuk@technikz.de \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git