Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1526154

What exactly do 32-bit x86 exceptions push on the stack in the CS slot?

From Andy Lutomirski <luto@kernel.org>
Newsgroups linux.kernel
Subject What exactly do 32-bit x86 exceptions push on the stack in the CS slot?
Date 2016-11-20 03:00 +0100
Message-ID <sFpAe-4sJ-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


This is a question for the old-timers here, since I can't find
anything resembling an answer in the SDM.

Suppose an exception happens (#UD in this case, but I assume it
doesn't really matter).  We're not in long mode, and the IDT is set up
to deliver to a normal 32-bit kernel code segment.  We're running in
that very same code segment when the exception hits, so no CPL change
occurs and the TSS doesn't particularly matter.

The CPU will push EFLAGS, CS, and RIP.  Here's the question: what
happens to the high word of CS on the stack?

The SDM appears to say nothing at all about this.  Modern systems
(e.g. my laptop running in 32-bit legacy mode under KVM) appear to
zero-extend CS.  But Matthew's 486DX appears to put garbage in the
high bits (or maybe just leave whatever was already on the stack in
place).

Do any of you happen to know what's going on and when the behavior
changed?  I'd like to know just how big of a problem this is.  Because
if lots of CPUs work like Matthew's, we have lots of subtle bugs on
them.

--Andy

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Andy Lutomirski <luto@kernel.org> - 2016-11-20 03:00 +0100
  Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Brian Gerst <brgerst@gmail.com> - 2016-11-20 03:20 +0100
    Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Andy Lutomirski <luto@amacapital.net> - 2016-11-20 03:20 +0100
      Re: What exactly do 32-bit x86 exceptions push on the stack in the  CS slot? Ingo Molnar <mingo@kernel.org> - 2016-11-21 08:30 +0100
        Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Linus Torvalds <torvalds@linux-foundation.org> - 2016-11-21 19:10 +0100
          Re: What exactly do 32-bit x86 exceptions push on the stack in the CS  slot? "H. Peter Anvin" <hpa@zytor.com> - 2016-11-21 19:40 +0100
            Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Linus Torvalds <torvalds@linux-foundation.org> - 2016-11-21 22:30 +0100
              Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Linus Torvalds <torvalds@linux-foundation.org> - 2016-11-21 23:30 +0100
              Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? hpa@zytor.com - 2016-11-21 23:30 +0100
              Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Andy Lutomirski <luto@amacapital.net> - 2016-11-24 18:20 +0100
          Re: What exactly do 32-bit x86 exceptions push on the stack in the  CS slot? Ingo Molnar <mingo@kernel.org> - 2016-11-22 09:40 +0100
            Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Andy Lutomirski <luto@amacapital.net> - 2016-11-22 18:40 +0100
              Re: What exactly do 32-bit x86 exceptions push on the stack in the  CS slot? Ingo Molnar <mingo@kernel.org> - 2016-11-23 10:00 +0100
  Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? hpa@zytor.com - 2016-11-21 07:00 +0100
    Re: What exactly do 32-bit x86 exceptions push on the stack in the CS  slot? "H. Peter Anvin" <hpa@zytor.com> - 2016-11-21 17:10 +0100
      Re: What exactly do 32-bit x86 exceptions push on the stack in the CS slot? Linus Torvalds <torvalds@linux-foundation.org> - 2016-11-21 19:30 +0100

csiph-web