flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Hypervisor from Blue Pill ported to FASM?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
booter



Joined: 08 Dec 2006
Posts: 67
booter
I always prefer to start with something workig Smile
My idea is to port Blue Pill to FASM first.
Then play with it adding new functionality and learning.
Learn how to run several VMs.
Learn how to control ACPI and provide "hardware partitioning" (splitting hardware between VMs).
Establish inter-VM communications (develop protocols).
Write (port from QEMU) device emulators.
Develop specifications on virtual hardware, write emulators (to export virtual hardware) and drivers (to use virtual hardware in existing OS).
The result would be something close to what I brifly explained here http://board.flatassembler.net/topic.php?t=11068
Obviously it's a project for several(many?) years Sad
However, virtualization is a very popular and interesting topic.
Such development would be an adventures and educational for anybody.
What about making it FASM community project?
I specifically mean Hypervisor that would provide multi-VM environment and distribute physical hardware among VMs.
Post 22 Jan 2010, 05:17
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
booter said:
What about making it FASM community project?

bitshifter says:
Very unlikely, how many times you seen
this community get together on anything?
(excluding the occasional pissing contest)
Post 22 Jan 2010, 07:12
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 692
Location: Adelaide
sinsi
Just reverse-engineer hyper-v, it will be easier.

>pissing contest
hasn't that got 'bigger' lately...
Post 22 Jan 2010, 07:17
View user's profile Send private message Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 454
Location: Czech republic, Slovak republic
Feryno
forget bluepill, start your own project, I may give you some advices but I'm not allowed to post skeleton/executable of hypervisor written in FASM
- at first you must be able to do some simple driver written in FASM (download it from forum or from FASM download section)
- then you may extend the driver to start the hypervisor:
- allocate notpageable memory
- prepare hypervisor data / registers / stack space (a lot of things to do, set up correctly about 100 things or even slightly more, the most of time consumes studying CPU system manuals)
- prepare handler for vm_exits - for intel CPU it is approx at least 100 instructions for the minimal skeleton - for all unconditional vm exits at intel CPU - should be less instructions for AMD CPU (I didn't that yet for AMD)
- launch it
- if you manage to launch it at 1 cpu, then you may think about SMP support (I suggest you to start SMP support from begin of project, if you start it later, you will have a lot of things to edit/change)

if you manage to run the hypervisor, then you may start to be interested how to shut down running hypervisor - you may find some ideas in one presentation at Myjava 2009 FASM conference

to have some image about the size of project, the skeleton (*.sys driver) would be about 12 kB for 64 bit mode hypervisor (yesterday I counted that one specialized hypervisor performing some specialized tasks had code written in FASM with about 3900 instructions, but the bare skeleton should be about half of that)

disassembling hyper-v... a waste of time, ask some questions here

prepare yourself to be resistant to BSODs and reboots (may be at range of 10 or more reboots per 1 day)

btw writing hypervisor is something like writing minimal OS, you will prepare the same system things, only for hypervisor you must set them more complicatelly into VMCS (Intel) (AMD names it differently), for OS you will write them directly, currently there is no free emulator emulating virtualization so you must launch hypervisor at bare CPU, if you are developping an OS you may launch it under some emulator and save time by reboots and recoveries from reboots

for the skeleton, you don't need community, you may do it yourself
Post 22 Jan 2010, 12:16
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
booter wrote:
My idea is to port Blue Pill to FASM first.
Feryno wrote:
forget bluepill,
Since I am usually about 15-25 years behind the times, I don't feel bad, acknowledging that I am only four years behind the times with regard to "blue pill", which I had thought, probably incorrectly, had been mainly rumors and hype and propaganda, aimed at getting money, rather than a serious threat....

To the more serious question, and the rationale for this post: Do we have a list, finally, of motherboards capable of supporting this technology? Last I heard, Don and Martin had run around like the proverbial chicken sans tete seeking a motherboard that would run their exotic software....

Is this hypervisor based only on "virtualization", or does it require the more advanced replacement for the traditional BIOS?

If it only runs on Intel Core I7, that's fine, but it will be another decade before I can afford one....

Smile
Post 22 Jan 2010, 13:42
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
On one hand you say RAM is cheap, on the other you say i7 is so expensive that you need a decade to afford it.

Weird as it gets.
Post 22 Jan 2010, 17:53
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
http://www.pricewatch.com/gallery/cpu/i7-860
My entire computer costs less than this.
Post 22 Jan 2010, 18:39
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
tom tobias wrote:
To the more serious question, and the rationale for this post: Do we have a list, finally, of motherboards capable of supporting this technology? Last I heard, Don and Martin had run around like the proverbial chicken sans tete seeking a motherboard that would run their exotic software....

Since then, the technology of course became present in more CPUs.

Quote:
Is this hypervisor based only on "virtualization", or does it require the more advanced replacement for the traditional BIOS?

Nothing extra is needed in BIOS for virtualization to work.
Post 23 Jan 2010, 14:26
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
tom tobias wrote:
http://www.pricewatch.com/gallery/cpu/i7-860
My entire computer costs less than this.
In a decade i7 will cost $10 or maybe less Laughing

_________________
Previously known as The_Grey_Beast
Post 23 Jan 2010, 20:20
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Feryno wrote:
currently there is no free emulator emulating virtualization so you must launch hypervisor at bare CPU, if you are developping an OS you may launch it under some emulator and save time by reboots and recoveries from reboots
There's VMX support in recent bochs versions, afaik. Dunno about QEMU though.

vid wrote:
tom tobias wrote:
Is this hypervisor based only on "virtualization", or does it require the more advanced replacement for the traditional BIOS?

Nothing extra is needed in BIOS for virtualization to work.

Some BIOSes disable VMX support though, and won't let you enable the feature. Dunno if it's done to sell "VMX capable motherboards" at a higher price tag, or if there might be some legitimate reasons (ie, BIOS having SMM code that somehow conflicts with VMX).
Post 24 Jan 2010, 17:08
View user's profile Send private message Visit poster's website Reply with quote
booter



Joined: 08 Dec 2006
Posts: 67
booter
Feryno wrote:
forget bluepill, start your own project, I may give you some advices but I'm not allowed to post skeleton/executable of hypervisor written in FASM
- at first you must be able to do some simple driver written in FASM (download it from forum or from FASM download section)
- then you may extend the driver to start the hypervisor:
- allocate notpageable memory
- prepare hypervisor data / registers / stack space (a lot of things to do, set up correctly about 100 things or even slightly more, the most of time consumes studying CPU system manuals)
- prepare handler for vm_exits - for intel CPU it is approx at least 100 instructions for the minimal skeleton - for all unconditional vm exits at intel CPU - should be less instructions for AMD CPU (I didn't that yet for AMD)
- launch it
- if you manage to launch it at 1 cpu, then you may think about SMP support (I suggest you to start SMP support from begin of project, if you start it later, you will have a lot of things to edit/change)

if you manage to run the hypervisor, then you may start to be interested how to shut down running hypervisor - you may find some ideas in one presentation at Myjava 2009 FASM conference

to have some image about the size of project, the skeleton (*.sys driver) would be about 12 kB for 64 bit mode hypervisor (yesterday I counted that one specialized hypervisor performing some specialized tasks had code written in FASM with about 3900 instructions, but the bare skeleton should be about half of that)

disassembling hyper-v... a waste of time, ask some questions here

prepare yourself to be resistant to BSODs and reboots (may be at range of 10 or more reboots per 1 day)

btw writing hypervisor is something like writing minimal OS, you will prepare the same system things, only for hypervisor you must set them more complicatelly into VMCS (Intel) (AMD names it differently), for OS you will write them directly, currently there is no free emulator emulating virtualization so you must launch hypervisor at bare CPU, if you are developping an OS you may launch it under some emulator and save time by reboots and recoveries from reboots

for the skeleton, you don't need community, you may do it yourself

As I mentioned, the idea with blue pill was to begin with something that already works. Otherwise I would not know where to look for a problem if it all (as you said approx 2000 lines of code) just doesn't work Sad I need some initial core to provide debugging/logging capabilities.
I feel more comfortable with boot loaders then with drivers, so initial loading of the Hypervisor is not a problem (though handling "interceptions" of some OS booting in real mode may be uneasy).
I hope you won't mind taking a look at my first code (when I write one) to see what's wrong Smile
As soon as it begins working I would be able to get some debugging info and then go by myself.
Post 26 Jan 2010, 01:29
View user's profile Send private message Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 454
Location: Czech republic, Slovak republic
Feryno
hi booter
I may read it and try to find possible problems
I'm working on hypervisor at Intel CPU (skeleton seems to be very stable, currently I'm implementing parts watching and doing some things to running guest OS)
perhaps when I finish that I may port its skeleton to AMD virtualization also
do you want to implement your hypervisor for intel or for amd?
loading through bootloader - no problem (I'm loading it under running OS as a driver because request for watching and controlling running guest OS)
what guest do you then plane to run after you load hypervisor at boot stage and which way your guest will be loaded (if your guest will be loaded through 16 bit BIOS routines, then you will need to emulate 16 bit instructions under Intel - for AMD there is a special mode so no necessity to emulate 16 bit instructions)
I just wanted to say, that for Intel CPU - establishing hypervisor itself is a bit less complicated than correctly running a guest then... if you plane to do it through boot loader, then running a guest may be even more difficult
Post 26 Jan 2010, 09:10
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
booter



Joined: 08 Dec 2006
Posts: 67
booter
Feryno wrote:
hi booter
I may read it and try to find possible problems
I'm working on hypervisor at Intel CPU (skeleton seems to be very stable, currently I'm implementing parts watching and doing some things to running guest OS)
perhaps when I finish that I may port its skeleton to AMD virtualization also
do you want to implement your hypervisor for intel or for amd?
loading through bootloader - no problem (I'm loading it under running OS as a driver because request for watching and controlling running guest OS)
what guest do you then plane to run after you load hypervisor at boot stage and which way your guest will be loaded (if your guest will be loaded through 16 bit BIOS routines, then you will need to emulate 16 bit instructions under Intel - for AMD there is a special mode so no necessity to emulate 16 bit instructions)
I just wanted to say, that for Intel CPU - establishing hypervisor itself is a bit less complicated than correctly running a guest then... if you plane to do it through boot loader, then running a guest may be even more difficult
Hi Feryno,
I'm going to go with AMD. The reasons are:
- I don't like Intel's "manners" (how it bevaves and where it goes).
- I have some AMD PCs to play with.
- AMD provides free public version of the SimNow™ Simulator that looks like the right tool for the job, see
http://developer.amd.com/Assets/SimNowUsersManual4.5.2.pdf
Post 04 Feb 2010, 18:42
View user's profile Send private message Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 454
Location: Czech republic, Slovak republic
Feryno
Yes, if I remember correctly, AMD implemented virtualization before intel so AMD is leader.
The first intel virtualization wasn't complete - perhaps because implementing it in hurry (AMD was ahead) - e.g. lacked virtualization of guest memory, intel had to release the second version. But the first intel VMX version was enough for me to watch running guest and intercept events necessary in my project (accessing guest memory wasn't problem for me without its virtualization, I simple map any physical memory into hypervisor virtual memory space - but if it was virtualized, memory accesses would be faster).
AMD has also the chance of "paged real mode" so you can easier run 16 bit guest under 64 bit hypervisor.
I didn't start to port hypervisor from intel into AMD yet (perhaps I'll do it when tasks done under current intel version will be stable).

Thanks for tip, I'll try AMD simulator.
I recently tried bochs 2.4.2 which is capable to do intel vmx emulation.
Post 05 Feb 2010, 08:47
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 454
Location: Czech republic, Slovak republic
Feryno
SimNow is available here:
http://developer.amd.com/cpu/simnow/Pages/default.aspx
(free registration required)
to run it - it requires Linux 64 bit or x64 version of windows XP/2003 server (I have both platforms already installed in both my home PCs) - so I may start to play with it.
Post 05 Feb 2010, 09:09
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
maybe reactos is something like you want.
it is a virtual hardware (win32) with a set of drivers from XP.

it is still at an advanced development stautus, (like a win3.11).

but it is not fasm coded.
Post 05 Feb 2010, 19:49
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
edfed: reactos has nothing to do with virtualization whatsoeve; it's simply an alternative implementation of the NT kernel. And it's much further technology-wise than Win3.x, you can't compare them at all.

A CPU emulator like bochs, funnily enough mentioned above, is useful for testing.

edfed wrote:
but it is not fasm coded.
Who cares, usability is not determined by what something is written in.
Post 05 Feb 2010, 19:52
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
Quote:
Who cares, usability is not determined by what something is written in.


of course yes it does.
if you write an OS in asm, and then, put a compiler inside the os with enough privilege to modify in real time running code, it will give a great usability.
a usability that gives you the power to add a special feature with only a single compilation of ASM in real time.

for other languages, it is the same problem, and the same solution.
make a real time run & compile of all code in the ram. (or virtual ram).
it increases usability and capability with a single feature.

that's why the language of a system is important. in my opinion.
Post 05 Feb 2010, 20:02
View user's profile Send private message Visit poster's website Reply with quote
booter



Joined: 08 Dec 2006
Posts: 67
booter
edfed, "usability" is not my goal and we don't discuss "regular" OS on this thread.
I'm going to develop Hypervisor that would protect OS components from each other because "by design" I'm going to treat each OS component as potentially dangerous Smile
Ideally, protection from intentionally harmful hardware is also desirable Smile
Post 06 Feb 2010, 11:37
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2906
Location: [RSP+8*5]
bitRAKE
Y'all seen the rkanalyzer project? (Based on BitVisor.)
Post 07 Feb 2010, 01:06
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.