All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andi Kleen <andi@firstfloor.org>,
	linux@sandersweb.net, linux-kernel@vger.kernel.org,
	the arch/x86 maintainers <x86@kernel.org>
Subject: Re: [BUG] x86 kenel won't boot under Virtual PC
Date: Mon, 08 Sep 2008 12:09:56 -0700	[thread overview]
Message-ID: <48C57884.30607@zytor.com> (raw)
In-Reply-To: <alpine.LFD.1.10.0809081028590.3117@nehalem.linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]

Linus Torvalds wrote:
>>>
>> Yes, it does:
>>
>>   /* We need to decide which NOP sequence to use for 32bit and
>>      64bit. When -mtune= is used:
>>
>>      1. For PROCESSOR_I386, PROCESSOR_I486, PROCESSOR_PENTIUM and
>>      PROCESSOR_GENERIC32, f32_patt will be used.
>>      2. For PROCESSOR_PENTIUMPRO, PROCESSOR_PENTIUM4, PROCESSOR_NOCONA,
>>      PROCESSOR_CORE, PROCESSOR_CORE2, and PROCESSOR_GENERIC64,
>>      alt_long_patt will be used.
>>      3. For PROCESSOR_ATHLON, PROCESSOR_K6, PROCESSOR_K8 and
>>      PROCESSOR_AMDFAM10, alt_short_patt will be used.
>>
>>      When -mtune= isn't used, alt_long_patt will be used if
>>      cpu_arch_isa_flags has Cpu686. Otherwise, f32_patt will
>>      be used.
>>
>> "alt_long_patt" uses NOPL and its variants.
> 
> That is A TOTAL PIECE OF SH*T, and against gcc's own documentation.
> 
> "-mtune=x" is very much defined to be a performance _tuning_ option, not 
> an "architectural" option. 
> 
> Quite frankly, this is a gcc bug. Plain and simple. 
> 

OK, digging some more into this garbage...

Apparently the situation isn't quite as dire as it first seems.
At least gcc 4.3.0 doesn't actually pass -mtune= to gas; it just drops 
the option on the floor.  This means this bug isn't manifest when 
calling from gcc (as opposed to invoking as directly.)

However, I would still like to push the following patch to be on the 
safe side, ok?

	-hpa


[-- Attachment #2: 0002-x86-prevent-binutils-from-being-smart-and-generat.patch --]
[-- Type: text/x-patch, Size: 1346 bytes --]

>From 0fbbf1008e5177677dbdb6292d94ec40df965d82 Mon Sep 17 00:00:00 2001
From: H. Peter Anvin <hpa@zytor.com>
Date: Mon, 8 Sep 2008 12:01:48 -0700
Subject: [PATCH] x86: prevent binutils from being "smart" and generating NOPLs for us

binutils, contrary to documented behaviour, will generate long NOPs (a
P6-or-higher instruction which is broken on at least some VIA chips,
Virtual PC/Virtual Server, and some versions of Qemu) depending on the
-mtune= option, which is not supposed to change architectural
behaviour.

Pass an explicit override to the assembler, in case ends up passing
the -mtune= parameter to gas (gcc 4.3.0 does not appear to.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/Makefile_32.cpu |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu
index e372b58..b72b4f7 100644
--- a/arch/x86/Makefile_32.cpu
+++ b/arch/x86/Makefile_32.cpu
@@ -45,3 +45,8 @@ cflags-$(CONFIG_MGEODEGX1)	+= -march=pentium-mmx
 # cpu entries
 cflags-$(CONFIG_X86_GENERIC) 	+= $(call tune,generic,$(call tune,i686))
 
+# Bug fix for binutils: this option is required in order to keep
+# binutils from generating NOPL instructions against our will.
+ifneq ($(CONFIG_X86_P6_NOP),y)
+cflags-y			+= $(call cc-option,-Wa$(comma)-mtune=generic32,)
+endif
-- 
1.5.5.1


  parent reply	other threads:[~2008-09-08 19:10 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-31 18:22 [BUG] x86 kenel won't boot under Virtual PC David Sanders
2008-08-31 18:47 ` Linus Torvalds
2008-08-31 19:27   ` Arjan van de Ven
2008-08-31 19:39     ` Linus Torvalds
2008-09-05 15:38       ` David Sanders
2008-09-05 16:15         ` Jan Beulich
2008-09-05 16:39           ` Linus Torvalds
2008-09-05 18:43             ` Ingo Molnar
2008-09-05 20:06               ` H. Peter Anvin
2008-09-05 19:08             ` Jeremy Fitzhardinge
2008-09-05 20:12           ` H. Peter Anvin
2008-09-05 16:30         ` Linus Torvalds
2008-09-05 17:55           ` Andi Kleen
2008-08-31 20:03   ` David Sanders
2008-09-01 20:23     ` David Sanders
2008-09-01 22:22       ` Linus Torvalds
2008-09-02 12:08         ` David Sanders
2008-09-02 18:12           ` Linus Torvalds
2008-09-02 18:44             ` David Sanders
2008-09-03 11:09               ` Peter Zijlstra
2008-09-03 11:20                 ` David Sanders
     [not found] ` <48C1C156.9080003@zytor.com>
2008-09-07 20:07   ` David Sanders
2008-09-07 23:22     ` David Sanders
2008-09-08  1:48       ` H. Peter Anvin
2008-09-08  2:49         ` David Sanders
2008-09-08  4:04           ` H. Peter Anvin
2008-09-08  9:42             ` Andi Kleen
2008-09-08 13:25             ` David Sanders
2008-09-08 15:09             ` Linus Torvalds
2008-09-08 15:23               ` Ingo Molnar
2008-09-08 15:36                 ` H. Peter Anvin
2008-09-08 15:38                 ` David Sanders
2008-09-08 15:38                 ` H. Peter Anvin
2008-09-08 15:45               ` Andi Kleen
2008-09-08 15:43                 ` H. Peter Anvin
2008-09-08 15:50                   ` H. Peter Anvin
2008-09-08 15:50                   ` Andi Kleen
2008-09-08 15:50                     ` H. Peter Anvin
2008-09-08 15:57                       ` Andi Kleen
2008-09-08 15:54                         ` H. Peter Anvin
2008-09-08 16:07                   ` Linus Torvalds
2008-09-08 16:13                     ` H. Peter Anvin
2008-09-08 16:15                       ` H. Peter Anvin
2008-09-08 16:26                         ` David Sanders
2008-09-08 16:20                       ` Linus Torvalds
2008-09-08 16:32                         ` H. Peter Anvin
2008-09-08 17:02                           ` Ingo Molnar
2008-09-08 16:34                         ` david
2008-09-08 16:42                           ` H. Peter Anvin
2008-09-08 18:51                             ` david
2008-09-08 16:59                           ` Linus Torvalds
2008-09-08 17:00                         ` Andi Kleen
2008-09-08 17:04                           ` Linus Torvalds
2008-09-08 17:08                             ` H. Peter Anvin
2008-09-08 17:12                               ` H. Peter Anvin
2008-09-08 17:41                                 ` Linus Torvalds
2008-09-08 17:38                               ` Linus Torvalds
2008-09-08 17:59                                 ` H. Peter Anvin
2008-09-08 19:09                                 ` H. Peter Anvin [this message]
2008-09-08 22:42                                   ` Linus Torvalds
2008-09-08 17:18                             ` Andi Kleen

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=48C57884.30607@zytor.com \
    --to=hpa@zytor.com \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@sandersweb.net \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.