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


Groups > alt.os.development > #9976

Re: FYSOS: The Graphical User Interface

From Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam>
Newsgroups alt.os.development
Subject Re: FYSOS: The Graphical User Interface
Date 2016-08-24 07:00 -0400
Organization Aioe.org NNTP Server
Message-ID <20160824070006.0ef4cbd1@_> (permalink)
References (10 earlier) <npf8k6$h6f$1@dont-email.me> <npfcij$ahk$3@gioia.aioe.org> <nph9i3$iho$1@dont-email.me> <20160823175057.5a05e728@_> <npjl0o$s2o$1@dont-email.me>

Show all headers | View raw


On Wed, 24 Aug 2016 09:14:08 +0100
James Harris <james.harris.1@gmail.com> wrote:

> On 23/08/2016 22:50, Rod Pemberton wrote:
> > On Tue, 23 Aug 2016 11:46:20 +0100
> > James Harris <james.harris.1@gmail.com> wrote:

> >> One big difference between that and running the BIOS in real mode
> >> is that the emulator can check what the BIOS is trying to do and
> >> make sure that it is not doing anything that the OS would consider
> >> unsafe.  
> >
> > It's plenty of work to do this.  I was once considering this
> > too ...  
> 
> ISTM fairly easy to emulate an 8086. And that is what much BIOS code
> is all about.
> 
> Unfortunately, from what Wolfgang said recently, some BIOS code needs 
> far more - e.g. switching into protected mode temporarily.

(James, skip ahead, then come back to this ...)

IIRC, I think he also said they detected PM.  Without PM, they might
switch into SMM?  FYI, I'm making a really wild random guess here.  The
BIOS functions which wolfgang is discussing probably are on modern
processors that have SMM mode, which could work instead of 'unreal'
mode.  IIRC, SMM mode is like an unprotected RM with full machine
access.  Alternately, these functions could also simply just fail,
crash, GP fault, or reboot.  Obviously, you wouldn't want to call older
Int 15h, AH=87h or AH=89h as they most likely use 'unreal' mode or
simply switch into PM.

If you have an emulator, you can trap the PM instructions, either by
detecting the post 8086 instructions or by a processor fault or
exception etc when executed.  Since your emulator is already in PM, you
should be able to "simply" execute most of the PM instructions.  You
may have to emulate or skip other instructions.  You may have to copy
them to your OS' code space to maintain control over execution.
Wait, let's back up second and consider something else ...

Well, I should've said that copying and executing the code will only
work if the processor is in the same mode as the mode for which the
BIOS is compiled.  But, what mode of code is the BIOS using to access
memory above 1MB?  Is it using 'unreal' mode, SMM mode, 32-bit PM,
64-bit LM?  If the BIOS is using 32-bit PM code and your OS is 64-bit
LM code, then you have to emulate 32-bit PM code too, since you can't
copy the 32-bit PM BIOS code and execute it in 64-bit LM.  If the BIOS
is using 'unreal' mode, you'll have to simulate that. If the BIOS is
using SMM, uh, ...

Which mode of code is the BIOS using for this?  Can we even find out?
Can we assume they're all using the same mode?  Or, do we have to test
each one?  So, how do you know you won't be supporting emulation of a
bunch processor modes for the various BIOS vendors?  It's possible a
BIOS vendor might even use the mysterious 32-bit RM, if it
exists, since both 16-bit/32-bit RM have CR0.PE=0.  This theoretically
means that both could possibly support 'unreal' mode.  According to
the chart at the link below, you'd need to possibly emulate a few
modes, in addition too SMM and 'unreal' mode, such as the three 32-bit
modes, since they can access over 1MB.

That was rather chaotic and not well organized or edited.  I hope it
made sense.  There would seem to be the possibility of a mismatch
between the mode that your OS is compiled for and the mode that the
BIOS uses to access memory above 1MB.  I'm not sure how you could
guarantee that you could execute or emulate the BIOS code which
accesses memory above 1MB without a large amount of work.  The only
easy option seems to be the undesirable mode switch.

http://www.sandpile.org/x86/mode.htm

> A better option, therefore, may be to customise an existing emulator
> or, better, a binary translator.

You could always save the binary translations, like DEC Alpha's FX!32,
and incrementally accumulate the resulting translated code, as it does.

> Since 16-bit code cannot run natively under LM (Long Mode, i.e.
> 64-bit) an emulator would also be a way for the OS to run such legacy
> code.

It makes you wonder what 64-bit Linux and 64-bit Windows do to solve
this issue.  Switch out of LM?  Binary translation?  Program hardware
directly?

> > If your OS isn't making plenty of BIOS calls, it's probably less
> > painful to just do a mode switch.  
> 
> I have two problems with making a mode switch to RM:
> 
> 1. Handling interrupts. Either we duplicate the PM interrupt handling 
> code in RM or we disable interrupts or we catch the interrupt in RM
> and vector to PM to handle it. Even if feasible to vector back and
> forth, there will still be a marked increase in latency.

DJGPP (GCC for DOS) does a *large* amount of switching from PM to RM
via a DPMI host, like well over 95% of an apps' execution time.  It's
hardly noticeable.  That's probably due to a combination of code
efficiency and fast machines, I'm guessing.  The DJGPP apps do run
somewhat faster under (single threaded) 32-bit Windows 98/SE DOS
console.  This was likely due to more buffering and direct harddisk
drivers instead of BIOS.  I haven't timed any of my C code on
multi-core 64-bit Linux yet ...  Maybe, it's even faster yet.

> 2. Lack of security. While the machine is running in RM we don't have 
> control. Not everyone will bother about that but 'full control once
> the OS is running' is something I would like to have as a feature.

Why wouldn't you be able to maintain execution control?  The BIOS
code is trusted and shouldn't call non-BIOS code, but will call
other interrupts.  You have full control over the BIOS IVT values. You
can set them or change them.  You can relocate the IVT from 0h via LIDT
instruction on the 286 or later. This prevents RM code from changing
the actual IVT values. With a relocated IVT, you can wipe the default
IVT locations starting at 0h too just in case the BIOS or other code
uses direct IVT access. Set them to a trap vector.  You have control
over 40:72h and CMOS 0Fh, the cold and warm reboot settings and 40:67h
286 jump vector.  How else could you lose execution control?


Rod Pemberton

Back to alt.os.development | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

FYSOS: The Graphical User Interface "Benjamin David Lunt" <zfysz@fysnet.net> - 2016-07-08 11:52 -0700
  Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-16 11:00 +0200
    Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-16 11:14 +0100
      Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-16 19:07 +0200
        Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-16 19:42 +0100
          Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-16 21:32 +0200
            Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-16 23:22 -0400
              Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-17 13:50 +0200
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-18 01:41 -0400
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-18 10:47 +0200
            Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-17 08:45 +0100
              Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-17 13:57 +0200
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-18 01:47 -0400
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-18 10:59 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-18 11:37 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-18 17:38 -0400
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-19 10:03 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-19 22:34 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-22 17:43 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-22 19:04 +0200
    Re: FYSOS: The Graphical User Interface "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-08-16 04:18 -0700
      Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-16 12:25 +0100
        Re: FYSOS: The Graphical User Interface "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-08-16 04:41 -0700
        Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-16 19:19 +0200
      Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-16 19:14 +0200
    Re: FYSOS: The Graphical User Interface "Benjamin David Lunt" <zfysz@fysnet.net> - 2016-08-16 19:24 -0700
      Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-17 12:26 +0200
        Re: FYSOS: The Graphical User Interface "Mike Gonta" <mikegonta@gmail.com> - 2016-08-17 10:42 -0400
          Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-18 01:16 +0200
            Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-18 12:17 +0100
              Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-18 19:23 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-19 17:29 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-19 22:55 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-22 17:18 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-22 19:23 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-23 11:46 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-23 23:44 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-24 08:29 +0100
                Re: FYSOS: The Graphical User Interface "Alexei A. Frounze" <alexfrunews@gmail.com> - 2016-08-24 02:39 -0700
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-24 17:43 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-24 11:25 +0200
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-23 17:50 -0400
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-24 09:14 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-24 12:39 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-25 10:46 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-25 12:40 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-25 12:10 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-25 14:43 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-27 13:56 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-27 15:59 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-27 17:03 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-27 22:43 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-28 09:22 +0100
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-28 11:51 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-28 13:08 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-27 19:12 -0400
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-28 10:41 +0200
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-28 08:48 -0400
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-27 19:12 -0400
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-28 10:16 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-28 08:46 -0400
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-28 18:45 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-28 17:51 -0400
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-29 07:55 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-29 06:40 -0400
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-31 06:43 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-24 07:00 -0400
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-25 11:37 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-25 18:45 -0400
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-26 10:00 +0200
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-26 16:16 -0400
                Re: FYSOS: The Graphical User Interface "wolfgang kern" <nowhere@never.at> - 2016-08-27 15:10 +0200
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-27 17:59 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-27 19:11 -0400
                Re: FYSOS: The Graphical User Interface James Harris <james.harris.1@gmail.com> - 2016-08-28 10:56 +0100
                Re: FYSOS: The Graphical User Interface Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-08-28 08:45 -0400
        Re: FYSOS: The Graphical User Interface "Benjamin David Lunt" <zfysz@fysnet.net> - 2016-08-17 20:12 -0700

csiph-web