All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Gottschlag <mathias-go@web.de>
To: kvm@vger.kernel.org
Subject: Bug in protected mode segments?
Date: Wed, 22 Oct 2008 19:38:26 +0200	[thread overview]
Message-ID: <48FF6512.5010202@web.de> (raw)

I am currently working on my own hobby kernel and tested it on kvm 
today. I think I found a bug in kvm with it (already discussed it on IRC):

I wanted my kernel to be at a higher virtual address, in my case 
0xE0000000. To get it there (Grub loaded it at physical addr 0x100000), 
I followed the steps at http://wiki.osdev.org/Higher_Half_With_GDT:

Grub inits the CPU with no paging and flat segmenting, I now activate 
segments to move the code to 0xE0000000 and later activate paging and 
reset the segments. When I run this code on qemu or on real hardware 
(Athlon XP), everything works well, but on kvm I get several hangs. For 
example I try to write to 0xE00B8000 to write into the VGA framebuffer. 
This addres should now get translated back to 0xB8000 by the segment 
which has the base address 0x20000000, and this definately works on real 
hardware, but on kvm I only notice a hang at the instruction which 
writes at that address (kvm still responds, but doesn't update eip 
anymore, execution stops.

Someone on IRC told me that this might be because address wrapping isn't 
implemented properly (this could have been unnoticed until now as no 
real OS uses such weird segmenting).

You can try it out yourself using the code at 
http://wiki.osdev.org/Higher_Half_With_GDT, this code will work for 
example in qemu, but not in kvm. I attached a version including a build 
script and a script to create the floppy image (you only need gcc, nasm 
and grub, type in "sh build.sh" and you get your image) for testing. It 
should show "Hello world" on a machine where it runs correctly.

Mathias Gottschlag

             reply	other threads:[~2008-10-22 17:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-22 17:38 Mathias Gottschlag [this message]
2008-10-22 17:48 ` Bug in protected mode segments? Anthony Liguori
2008-10-23  7:21   ` Avi Kivity

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=48FF6512.5010202@web.de \
    --to=mathias-go@web.de \
    --cc=kvm@vger.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.