Skip to contentSkip to conversation

Simple patches for Linux as a guest OS in a plex86 VM (please consider)

DISCUSSION Andi Kleen 10 participants 16 messages Jan 22, 2003 – Jan 27, 2003 1 message not in the archive Kbuild

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20030122182341.66324.qmail@web80309.mail.yahoo.com.suse.lists.linux.kernel

Andi Kleen

author
#1 lore raw
Quoted 4 lines · Kevin Lawton

I'm working on running Linux as a guest OS inside a lightweight cut-down plex86 environment. My goal is to run a stock Linux kernel, which can be slimmed down to

Wouldn't it be easier if you just compile the kernel
with a simple gcc wrapper that replaces all pushfl and popfl with your new sequences in the assembly code generated by gcc and also in assembly files compiled with the gcc wrapper?

I guess that would avoid much maintenance hazzle long term

-Andi

#2 lore raw
Quoted 10 lines · --- Andi Kleen
Quoted 4 lines · Kevin Lawton

I'm working on running Linux as a guest OS inside a lightweight cut-down plex86 environment. My goal is to run a stock Linux kernel, which can be slimmed down to

Wouldn't it be easier if you just compile the kernel
with a simple gcc wrapper that replaces all pushfl and popfl with your new sequences in the assembly code generated by gcc and also in assembly files compiled with the gcc wrapper?

I'm not big on the idea of scripts massaging code - especially when they do something unintended. It's easier to run a periodic find script that greps for use of such instructions, if new cases are introduced. Anyways, there were really only a few cases where pushf/popf would have even mattered. Some stuff was just EFLAGS.{ID/AC} identification. I greatly prefer the #define mods.

The new kernel source was quite clean of this stuff, and did a great job centrailizing stuff in include/asm-i386.

-Kevin

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

#3 lore raw
In reply to Andi Kleen

OK, here's my re-submit of patches, after some great clean-up/simplification ideas from Andrew Morton and Andi Kleen.

There are now no mods to any *.{c,S,h} files. Here's a summary of the mods:

o Added 'Documentation/x86-hal.txt'
o Simple mods to 'Makefile'
o Added menu entry to 'arch/i386/Kconfig'
o Simple mod to 'arch/i386/boot/Makefile'
o Added 'include/asm-i386/if.h'

Only when compiling after enabling this new option, the Makefile forces inclusion of the 'if.h' file, which macro'izes the use of PUSHF/POPF instructions, substituting a few lines of code which fix the broken-ness of such logic when running with PVI (protected mode virtual interrupts). No of this would be necessary if the VME (for vm86) semantics were carried over to PVI.

Also, I'm including the 'Documentation/x86-hal.txt' to state my case for getting these mods in sooner than later, and to familiarize folks with what they're for. My bad, not explaining it better the 1st time.

-Kevin

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

#4 lore raw

On Wed, 22 Jan 2003, Kevin Lawton wrote:

Three minor points:

o If you included the patch inline instead of as application/octet-stream, it'd be easier to reply ;)

Review

Quoted 3 lines
(quoted diff) +3 -0
+Nothing, it's Open Source.  Linux is obviously a GPL'd program.
+Plex86 is an LGPL'd kernel module.  Though it's a separate
+

o Something's missing there?

Makefile +16 -0
diff -urN linux-2.5.59/Makefile linux-2.5.59-hal/Makefile
@@ -264,6 +264,18 @@
 CFLAGS		+= -fomit-frame-pointer
 endif
 
+ifdef CONFIG_X86_HAL
+# On x86, if compiling for the Hardware Abstraction Layer
+# (running Linux as a guest OS in a Virtual Machine),
+# we need to insert some asm macros which redefine
+# the behaviour of instructions which modify the
+# interrupt flag.  You are probably not configuring for
+# this mode.  For more info, read 'Documentation/x86-hal.txt'.
+# This needs to be the first include any module sees.
+CFLAGS		+= -include include/asm/if.h
+AFLAGS		+= -include include/asm/if.h
+endif
+
 #
 # INSTALL_PATH specifies where to place the updated kernel and system map
 # images.  Uncomment if you want to place them anywhere other than root.
@@ -409,6 +421,10 @@
 #	their vmlinux.lds.S file
 
 AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
+
+ifdef CONFIG_X86_HAL
+AFLAGS_vmlinux.lds.o += -DNO_X86_HAL_INCLUDES
+endif
 
 arch/$(ARCH)/vmlinux.lds.s: %.s: %.S scripts FORCE
 	$(call if_changed_dep,as_s_S)

o These modifications should be done from arch/i386/Makefile instead, since they're obviously i386-specific.

#5 lore raw
Quoted 1 line · --- Kai Germaschewski

Three minor points:

OK, done. Here's my #3 submission. Some great
feedback from you guys. Mods are down to:

  o Documentation/x86-hal.txt      # added file
  o include/asm-i386/if.h          # added file (only used for VM)
  o arch/i386/Kconfig              # added one menu entry
  o arch/i386/Makefile             # added one ifdef..endif
  o arch/i386/boot/Makefile        # added one ifdef..endif

-Kevin

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

#6 lore raw
Quoted 6 lines · Kevin Lawton
Quoted 1 line · --- Kai Germaschewski

Three minor points:

OK, done. Here's my #3 submission.

Kinda cruel making you do all this work when Linus is unlikely to take the patch anyway ;)

Thanks for the explanation - all is much clearer - it looks like very cool technology.

- <asm/if.h> doesn't mean much to me. Network interface, if anything. How about <asm/asm-macros.h> ?

- It's quite conceivable that the infrastructure will be used for other forms of asm-mangling. Those "Q2" things hurt like hell. Is there no other way?

- application/octet-stream!

#7 lore raw
Quoted 2 lines · --- Andrew Morton

Kinda cruel making you do all this work when Linus is unlikely to take the patch anyway ;)

If there's a misunderstanding of the potential here, of the commercial potential, or the user-demand for these patches (which now touch absolutely no existing *.{c,S,h} files, then I'm willing to communicate those things to whomever needs it.

This is not a toy. The goal is not to continue modifying the kernel or make anybody's life hard. The contrary is true - I don't want any modifications. These are extremely simple patches to fix one pair of broken instructions in PVI mode.

Coming from an x86 company, I'm betting Linus will get this in a nano-second. Let's not speak for him.

-Kevin

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

#8 lore raw
In reply to Kevin Lawton

Hi!

Quoted 2 lines

OK, here's my re-submit of patches, after some great clean-up/simplification ideas from Andrew Morton and Andi Kleen.

Please try to inline the patches, it makes it easier to comment.

How is plex86-aware-linux running under plex86 different from user mode linux? Do you think you can make it faster?
Pavel

Signature · 2 lines
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?
#9 lore raw
Quoted 2 lines · --- Pavel Machek

How is plex86-aware-linux running under plex86 different from user mode linux?

With plex86, the goal is to run the stock x86 port. Plex86 is also x86-specific.

Quoted 1 line

Do you think you can make it faster?

To get any level of security with UML, you need to use "jailed mode" in which performance takes a big beating. To fix this, you need patches to Linux as a host, to make it offer a better environment for running UML guests. From a commercial perspective, then you have a patched Linux host + totally different port of a Linux guest.

Quoted 1 line

From a fun perspective, I think UML is fantastic achievement.

What I'm aiming for is a stock Linux host and a stock Linux guest, the small mods to macroize PUSHF/POPF being a minor concession to accomodate a broken PVI support in x86.

-Kevin

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

#10 lore raw
Quoted 5 lines · Kevin Lawton

To get any level of security with UML, you need to use "jailed mode" in which performance takes a big beating. To fix this, you need patches to Linux as a host, to make it offer a better environment for running UML guests. From a commercial perspective, then you have a patched Linux host + totally different port of a Linux guest.

That commercial perspective is then completely misguided.

All alternatives I have seen to UML (plex, vmware, UMLinux) suck IMHO. They are inherently much more platform specific than UML. The necessary modifications on the host for UML ska mode are minimal and I think besides bashing out whether it should be a syscall, proc file or whatever, everybody seems pretty much set on integrating them into the kernel.

Sincerely,
Lars Marowsky-Brée <[email protected]>

Signature · 5 lines
Principal Squirrel 
SuSE Labs - Research & Development, SuSE Linux AG
  
"If anything can go wrong, it will." "Chance favors the prepared (mind)."
  -- Capt. Edward A. Murphy            -- Louis Pasteur
#11 lore raw
Quoted 1 line · Lars Marowsky-Bree

All alternatives I have seen to UML (plex, vmware, UMLinux) suck IMHO.

It seems plausible to expect that it might be easier to verify security in plex86-based approaches than it is to verify security in UML.

#12 lore raw
Quoted 5 lines · David Wagner
Quoted 1 line · Lars Marowsky-Bree

All alternatives I have seen to UML (plex, vmware, UMLinux) suck IMHO.

It seems plausible to expect that it might be easier to verify security in plex86-based approaches than it is to verify security in UML.

IIRC plex86 requires quite large module on the host. And I am not sure it's does not have any privilegies. Umlinux requires no or very minimal (thus easy to check for insecurities) patch to kernel and does not need any privilegies (except the helper that sets up networking, but that's pretty minimalistic too). If you properly chroot the umlinux process, it's very secure (the skas mode will only work in chroot once it's made to use syscall).

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#13 lore raw
In reply to David Wagner

Hi!

Quoted 4 lines
Quoted 1 line

All alternatives I have seen to UML (plex, vmware, UMLinux) suck IMHO.

It seems plausible to expect that it might be easier to verify security in plex86-based approaches than it is to verify security in UML.

As plex86 uses pretty obscure tricks (like PVI -- is it even documented in official Intel docs?), I doubt it is going to be easier to verify.
Pavel

Signature · 2 lines
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?
#14 lore raw
In reply to Lars Marowsky-Bree

Hi!

Quoted 10 lines
Quoted 5 lines

To get any level of security with UML, you need to use "jailed mode" in which performance takes a big beating. To fix this, you need patches to Linux as a host, to make it offer a better environment for running UML guests. From a commercial perspective, then you have a patched Linux host + totally different port of a Linux guest.

That commercial perspective is then completely misguided.

All alternatives I have seen to UML (plex, vmware, UMLinux) suck IMHO. They

I know UML, but what is UMLinux?
Pavel

Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
#15 lore raw
Quoted 1 line · Pavel Machek

I know UML, but what is UMLinux?

Google, 3 seconds: http://www.umlinux.de/ :-)

Sincerely,
Lars Marowsky-Brée <[email protected]>

Signature · 5 lines
Principal Squirrel 
SuSE Labs - Research & Development, SuSE Linux AG
  
"If anything can go wrong, it will." "Chance favors the prepared (mind)."
  -- Capt. Edward A. Murphy            -- Louis Pasteur
#16 lore raw
In reply to Kevin Lawton

Hello!

Why don't you take the route that Jeff Dike did with UML's skas mode?

List the patches in your site and release plex86-v2 that requires this host patches to run.

If the results are really good lots of people will use it and you'll end up with a number of people asking in lkml "why is the plex86-v2 patch not available in Linus' tree?" ;)

Regards,
Nuno Silva