copy / v86

x86 PC emulator and x86-to-wasm JIT, running in the browser

Home Page:https://copy.sh/v86/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boot Windows XP

Creeper20428 opened this issue · comments

Windows XP and OS/2 don't boot because of an unhandled double fault exception.

At the page fault handler, I tried doing this:

if(this.page_fault)
    {
        dbg_trace(LOG_CPU);
        //throw this.debug.unimpl("Double fault");
        this.interrupt(6, false, false); // I also fiddled around with these:
/*
this.interrupt(6, false, true);
this.interrupt(6, true, true);
this.interrupt(6, true, false);
*/
    }

but then there were more #GP exceptions and it would have triple-faulted anyways.

It would be really cool to see Windows or OS/2 booting.

Windows XP and OS/2 don't boot because of an unhandled double fault exception.

It's not the double fault exception that causes this. The double fault shouldn't happen in the first place. If you want to see how far Windows XP gets, set ENABLE_ACPI to true here. It's experimental and will cause some other OSes to stop working. After that Windows XP gets stuck on a black screen. The APIC needs some more work.

What version of OS/2 are you testing? If possible, can you upload a disk image?

I have managed to get Windows NT 4.0 to start properly in copy.sh if you want to see a Windows NT-based operating system working in it, you can use NT 4.0. Just letting you know!

That's very cool, I'm also testing a (probably different) version of Windows NT and it doesn't work for me. Did you apply some fixes? Can you upload a disk image somewhere?

I'm guessing that the ACPI interpreter is failing (it's very strict, according to what I heard).
According to osdev.org, the ACPI tables seem to be very complex.
Couldn't we just copy the tables from an emulator like Bochs and insert it into the memory? Something like this:
if(ENABLE_ACPI){ cpu.memory.u8.set([ 1, 2, 3, 4, cpu.something | someValue, ...], 0x1234567]); }
These are tables, after all. How hard could it be to copy tables?

BTW I am using OS/2 Warp 4.52 (I think). I created the disk image in QEMU and I'll try to upload it somewhere. There used to be a 16-bit iret problem but now it's gone, thanks to a recent commit. :)

I think I figured out why some OSes don't work when ACPI is enabled. It's not the emulator's fault (although it might be -- you never know). Early OSes have no support for ACPI at all (see https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface#Operating_systems). When an OS, such as DOS sees random AML bytecode in spots where x86 code is supposed to be, then things go south....

These are tables, after all. How hard could it be to copy tables?

This isn't necessary, the bios sets up ACPI tables: https://github.com/KevinOConnor/seabios/blob/master/src/fw/acpi.c

Early OSes have no support for ACPI at all

That's good to know, this will need to be a runtime option then.

Then what's the problem? Is there an I/O port that's mis-reading/writing?

And BTW, how do you debug things like this?

Then what's the problem? Is there an I/O port that's mis-reading/writing?

The APIC implementation is quite incomplete, so there are just many parts missing (or wrong).

And BTW, how do you debug things like this?

Run the emulator in debug.html. You'll see a rather verbose log in the JavaScript console, XP produces this: https://gist.github.com/copy/c4de5225317922d035d3

You can see what is being used. There are some unimplemented IO ports. Then Windows goes to sleep waiting for something to happen, probably an interrupt. Could also be related to that RTC register.

Is it ACPI or APIC?

In the code, I saw "APIC" in acpi.js.

Is it ACPI or APIC?

ACPI needs to be enabled for it to work at all. APIC implementation is incomplete.

In the code, I saw "APIC" in acpi.js.

Do you have the latest version?

I have one from a while ago -- it still has traces of the dynamic translator in it.

So, let me get these things straight:
Windows XP doesn't boot because of incomplete ACPI ports and an incomplete APIC implementation.
OS/2 Warp 4.52 doesn't boot because of... I don't know. I'm uploading to Dropbox right now.

Thanks for the disk image. After a bit of fixing small things, I found that OS/2 uses far call gates, which aren't implemented yet.

Windows XP doesn't boot because of incomplete ACPI ports and an incomplete APIC implementation.

Probably the latter, yes.

So Win XP doesn't boot because of APIC problems and OS/2 doesn't boot because of far call gates.

Sounds fun!

I did some research yesterday and I discovered this:
http://lifehacker.com/5827222/jpc-2-lets-your-run-windows-xp-and-ubuntu-in-your-web-browser

I just thought it was interesting.
Unfortunately, it's not up anymore :(

Actually, from what I saw, it worked more like the Windows 98 demo: http://copy.sh/v86?profile=windows98

I looked a bit more and apparently, it emulates the code, but loads the hard disk over the Internet.
It would have been really neat to see it in action and see the source code, but it's down now -- and all traces of the jar file are gone!

I dug some more and it's by a company named "eMediaTrack" in Great Britan (because they say "optimised" instead of "optimized"). I went to eMediaTrack.net and saw their demos -- it's called "Proteus" or something. Then, I looked up "Proteus" online and came up with proteuscc.sourceforge.net. I found out that they compiled Bochs to Java. Somehow.

Then, I went back to archive.org and looked at the page source. The main class is com.emt.proteus.vmimpl.?. I decompiled the demos and found out that there was no "vmimpl" class there...

Finally, I looked backwards in time and found something new! Apparently, they compiled Bochs to Java with their "Proteus-S" product.

The company got liquidated in October 2015. I saw this in the British "Companies' House" web site. They owed a bunch of money to other companies. Maybe the file is owned by one of them now..?

Oh, BTW a site called ww45.jpc2.com was up in 2014 but now it's down.

Just discovered this (http://sandpile.org/x86/cpuid.htm#level_0000_0001h)

The (fixed) default APIC ID is encoded in bits 31...24.

Maybe the lack of this is causing the double faults.

jsbochs is Bochs compiled to JavaScript via Emscripten.
JPC-2 is basically JPC but with more features (according to their web site).

In unrelated news, Windows XP launched for retail sale on October 25, 2001. It would be cool to have it work in the browser as a "15th anniversary" thing.

There's a difference between regular Windows XP and the "small variants". For example, I tried a PEBuilder ISO and it faults with a BSOD (after taking like 50 minutes to boot). However, Windows XP SP3 (It's a 1.5 GB image, so I can't post it online like my OS/2 one) just stops in the middle[1]. The IPS counter just goes down to 0. That's because a "double fault" exception is being thrown (AKA no ACPI/APIC support).

[1] It's been a while since I checked, so who knows? :D

I could probably implement ACPI in a few days, but I'm busy at the moment (and I don't know a lot about hardware stuff)

PEBuilder web site

I had an interesting idea: I saved an instance of Windows XP on Bochs when I had a little too much free time on my hands. So, it would be relatively easy to convert the Bochs format (which is like JSON but with equal signs) into the v86 format, because I believe that ACPI tables are only parsed on startup and aren't used unless you want to shut down the computer or mess around with the power options.

On the other hand, implementing ACPI/APIC can make some more operating systems work and I personally think that this is a bit like cheating.

That's true...
Anyways, it is possible to install Win XP without ACPI and APIC. But it takes XP a LOOOOOOOOOOOONG time to install (3 hrs. for me in QEMU).
Anyways, I'll try to implement ACPI/APIC soon.
Speed is not an issue. Windows XP can run on 8 MHz, and I'm sure the speed here is more than 10 MHz... I hope.

Imagine Vista at 8 MHz! >:-)
Sometimes, the computer gets the clock speed wrong.

XP said the computer was a 5 MHz Pentium IV. I can't see the entire IPS counter in the UI, though. But that's pretty fast compared to a Pentium 60 (but people say the Pentium IV was slow, though...)

By the way, did anybody have any success implementing ACPI yet?

I'm not actually sure if the copy.sh CPU is at 8 MHz, but I checked four different operating systems

They're just measuring the TSC, which runs at a constant speed, defined here.

By the way, did anybody have any success implementing ACPI yet?

There's not much to do as far as I know, most work is done by the bios: https://github.com/coreboot/seabios/blob/master/src/fw/acpi.c

Oops I meant APIC.

I think the original Windows XP should work, since it booted in safe mode in JDosbox[1]. When I tried SP3 on it, it double faulted. A closer inspection of the project revealed that there was no ACPI or APIC. A forum thread[2] didn't say anything about ACPI or APIC.

But, I can't find any original (non "service pack"ed) ISOs out there.

[1] http://jdosbox.sourceforge.net/
[2] http://www.vogons.org/viewtopic.php?t=27467

PS: There is a cool OS on the last page that you should try: http://ftp.unixdev.net/pub/iso/QNX/qnxnc621.iso
But its 237 MB.

Sure! That would be great! Can you post it online somewhere so that I can test it/install it?
I think the disk is about 200 MB, won't take me that long to download.
But it installs to a 1 GB hard disk.
Which leads me to wonder: how does it make 5 times more data than there was on the CD-ROM itself?

There's a way to disable APIC during install, but I couldn't find it. And people are typing in ACPI instead of APIC and vice versa. Driving me crazy.

Well, after all that, what is the status of Windows XP support ?

Well, after all that, what is the status of Windows XP support ?

A few related changes, but no support yet.

@copy Please point me what should be fixed. Maybe I can help ? I have interest in that area again.

@socketpair I'd suggest to clone the repository and try running it yourself. Currently there's some missing code here. After that it tries to use the APIC and fails. You can change log levels here and don't forget to use debug.html (it has assertions and logging enabled and you don't need to compile).

Status update: I've implemented all APIC features that are required by Windows XP and fixed a few small bugs. It's more-or-less usable now.

I'll need to do some more testing before pushing the code.

screenshot_2017-03-31_14-29-56

screenshot_2017-03-31_15-23-06

I have now pushed the remaining pieces to run Windows XP in v86. You can clone the repository, set ENABLE_ACPI = true here and try it out locally. I recommend installing XP in QEMU with the default disk configuration (otherwise you'll likely get INACCESSIBLE_BOOT_DEVICE).

In order to make a release on the website, a few pieces are still missing:

  1. Speed is too slow to really do anything, we're working on this (see #122)
  2. The legality isn't certain, at least WinWorld doesn't consider XP abandonware: https://winworldpc.com/winboards/viewtopic.php?f=1&t=6612
  3. ENABLE_ACPI must become a runtime option since it breaks some other OSes

What is the status of ACPI enabled with the Linux kernel booting? I compiled a test script and ran Linux 4.11.x kernel and received a kernel panic indicating to run as "noacpid." I know it might not be necessary for Linux but I was just playing around. Is there any logs I can gather to help out to make this more stable of a feature? I have yet to test Windows XP which I plan to this week.

What is the status of ACPI enabled with the Linux kernel booting? I compiled a test script and ran Linux 4.11.x kernel and received a kernel panic indicating to run as "noacpid." I know it might not be necessary for Linux but I was just playing around. Is there any logs I can gather to help out to make this more stable of a feature? I have yet to test Windows XP which I plan to this week.

I can boot it (4.11.2-1). Are you on latest master?

There are still a few problems with ACPI. Logs probably won't help me diagnose the problem, I'd need more details on the VM image.

I'll check my image. I have been creating my images with Buildroot targeting the i586 platform. Maybe I have a configuration problem within the defconfig. The Linux kernel is Linux 4.11.3 # 1 SMP i686 GNU/Linux.

I'll check my image. I have been creating my images with Buildroot targeting the i586 platform. Maybe I have a configuration problem within the defconfig. The Linux kernel is Linux 4.11.3 # 1 SMP i686 GNU/Linux.

In that case, if the image is small and the problem still persists, could you upload the image somewhere so I can have a look?

@copy APIC and ACPI aren't really required for XP to work AT ALL. 86Box runs it and it emulates neither.

@copy APIC and ACPI aren't really required for XP to work AT ALL. 86Box runs it and it emulates neither.

That may be the case, but I couldn't make it run without an APIC. Maybe this was due to a newer service pack or something hard-coded during installation. Either way, Windows XP works now.

Is anyone else having issues with Windows XP now? I can't get it to work

Is anyone else having issues with Windows XP now? I can't get it to work

Can you describe your problem with more detail?

Is anyone else having issues with Windows XP now?

I just tried a Windows XP SP2 image in v86 with ACPI enabled, and I got a BSOD screen similar to @BenNottelling's:

image

The hda image was created using:

qemu-system-i386.exe -cdrom winxp.iso -hda winxp.img

where winxp.iso is from an install disk.

I did some logging and naive googling, and I think I found something interesting. Apparently, the stop code 0x7E is SYSTEM_THREAD_EXCEPTION_NOT_HANDLED, and I think the exception code (param 1) 0xC000001D represents illegal instruction. I ran v86 in debug mode, and it encountered a failed assert for unimplemented SSE (t[0x2B]), and if we skip over the failed assert, the BSOD gets drawn almost immediately after that.

Could the BSOD be because of unimplemented SSE instructions?

Could the BSOD be because of unimplemented SSE instructions?

That's certainly possible. If you run in debug mode you should see this assertion failing. You can also disable the four relevant bits in cpuid (this line), then Windows should stop using SSE instructions

Thanks! Clearing the cpuid SSE bits did the trick. @BenNottelling, this probably helps you too.

I'll make sure to try it tonight

@copy XP without ACPI should work if select "Standard PC" HAL when hit F5 on install screen

win10
just something really cool, windows 10 boots to a recovery screen, but at least it boots

Unfortunately v86 is far from emulating windows 10, so it won't work as we just don't have every cpu instruction needed to run it

Also, i got a diagnostic windows pe modified portable version (basically windows xp) working. It runs after like booting for 8 min.
winxponv86
its called bartpe

I tried Mini Windows XP which is on Hiren's Boot CD v15.2

On loading:
Screenshot1

When loading finished:
Screenshot2

When clicking OK or X:
Screenshot3

GUYS! I HAVE GOT COOL NEWS! WINDOWS WHISTLER BUILD 2296 (BETA 1) POCKET EDITION WORKS!

Screenshots:
pic1
pic2
pic3
pic4
pic5
pic6
pic7
pic8
pic9
pic10

GUYS! I HAVE GOT COOL NEWS! WINDOWS WHISTLER BUILD 2296 (BETA 1) POCKET EDITION WORKS!

Screenshots:
pic1
pic2
pic3
pic4
pic5
pic6
pic7
pic8
pic9
pic10

Thats really interesting!

So, I decided to get the Mini Windows XP 26 MB Live CD from one of the YouTube videos, and decided to test this Live CD out via copy.sh!

Screen Shot 2021-01-19 at 2 19 17 PM
The boot

Screen Shot 2021-01-19 at 2 21 07 PM
The Windows XP Boot Screen

Screen Shot 2021-01-19 at 2 23 34 PM
The part where an error appears before the desktop.

Screen Shot 2021-01-19 at 2 23 56 PM
Screen Shot 2021-01-19 at 2 24 37 PM
And Voila! I finally got this Windows XP Live CD to work on copy.sh! By the way, this Live CD is not made by me. It's by someone.

So, I decided to get the Mini Windows XP 26 MB Live CD from one of the YouTube videos, and decided to test this Live CD out via copy.sh!

Screen Shot 2021-01-19 at 2 19 17 PM
The boot

Screen Shot 2021-01-19 at 2 21 07 PM
The Windows XP Boot Screen

Screen Shot 2021-01-19 at 2 23 34 PM
The part where an error appears before the desktop.

Screen Shot 2021-01-19 at 2 23 56 PM
Screen Shot 2021-01-19 at 2 24 37 PM
And Voila! I finally got this Windows XP Live CD to work on copy.sh! By the way, this Live CD is not made by me. It's by someone.

would you mind sharing the iso?

It's on YouTube. Search up something like "Windows XP SP3 Super Lite 26 MB". Be warned though: When the desktop loads, there are errors, but the desktop should work, though.

Then, once you find the video, look at the description, then download the file using MEGA.

So we know that nlite Super Lite versions work, But if we want to see how to make it work, we might as well try using betas.

Maybe start by using XP build 2202.1. eventually we can probably find out what was the last windows build that can boot on copy.sh

win10
just something really cool, windows 10 boots to a recovery screen, but at least it boots
windows 11 virtual x 86
I also got Windows 11 booting too (It boots to a message saying its not an x86 cpu)

@Unzor Maybe the video itself got taken down... Here's another way you can use Windows XP on your web browser, and it's known as "VirtualXP".

VirtualXP is based on halfix that is buggy and uncompleted

@copy XP without ACPI should work if select "Standard PC" HAL when hit F5 on install screen

This also works if you:

  1. Install XP in QEMU (Don't bother with disabling ACPI)
  2. Open Device Management
  3. Select "Computer" > right-click > "Update Driver"
  4. Select "Search for a driver"
  5. Select "Choose from a list"
  6. Select "Standard PC"
  7. Reboot your VM when prompted.
  8. Shut down your VM and use it in v86.

@copy XP without ACPI should work if select "Standard PC" HAL when hit F5 on install screen

This also works if you:

  1. Install XP in QEMU (Don't bother with disabling ACPI)
  2. Open Device Management
  3. Select "Computer" > right-click > "Update Driver"
  4. Select "Search for a driver"
  5. Select "Choose from a list"
  6. Select "Standard PC"
  7. Reboot your VM when prompted.
  8. Shut down your VM and use it in v86.

I did this with my VM, and it's booting perfectly. 9 minutes after booting in v86, the date is supposedly January 1, 1601 and all is right with Windows. I even have a network connection!
Screenshot

Strangely, I now have 2 "Standard PC" devices listed.
Screenshot of devmgmt.msc

Map of devmgmt:
Screenshot

  • QEMU-XP-9PFS
    • Computer
      • Standard PC
      • Standard PC
    • Disk drives
      • v86 HD
    • Floppy disk controllers
      • Standard floppy disk controller
    • IDE ATA/ATAPI controllers
      • Intel(R) 82371SB PCI Bus Master IDE Controller
      • Primary IDE Channel
      • Secondary IDE Channel
    • Keyboards
      • PC/AT Enhanced PS/2 Keyboard (101/102-Key)
    • Mice and other pointing devices
      • Microsoft PS/2 Mouse
    • Network adapters
      • Realtek RTL8029(AS)-based Ethernet Adapter (Generic)
    • Other devices
      • PCI Device
      • Video Controller (VGA Compatible)
    • Sound, video, and game controllers
      • Audio Codecs
      • Legacy Audio Drivers
      • Legacy Video Capture Devices
      • Media Control Devices
      • Video Codecs
    • System devices
      • Intel 82371SB PCI to ISA bridge
      • Intel 82441FX Pentium(R) Pro Processor to PCI bridge
      • ISAPNP Read Data Port
      • Microcode Update Device
      • Microsoft System Management BIOS Driver
      • PCI bus
      • Plug and Play Software Device Enumerator
      • Terminal Server Device Redirector

Could you give a save state or disk image of it? I want to do this but don't have enough storage space or RAM.

You only need 4 GB of storage, but okay. I'll see if I can get it small enough.
Wait, I don't think I can share it because Windows is activated. @copy Can I?

I think you can, a huge company like Microsoft will not care. Plus, it's pretty old and unsupported, no one would pay for an old OS like this one anyways when there are other newer ones.

If @copy says I can, I'll share it. It's only about 500 MB with NTFS compression, so I would probably be able to put it on the Internet Archive. Still, I don't want to risk it. (Remember who owns GitHub? )

Yes, but would they care? Not really, as it's pretty old and mostly only used for playing around. There is not much risk either. I don't think Copy would really care either. Plus, you pretty much did what you didn't want to do: pirate. You already have a copy of it so it won't matter anyways.

I'm not going to risk it.

Windows the year is 1600 has some strange side affects. For example, it made shutdown /r say it was going to shut down in over 68 years.

After the first boot of XP in v86, it takes XP:

  • 35 seconds to get a graphical boot logo
  • 5 minutes before it complains about the date
  • 6 minutes until it gives the welcome screen
  • 9 minutes to get to the desktop background
  • 9 minutes 22 seconds for the taskbar
  • 9 minutes 40 seconds for desktop icons
  • 10 minutes 55 seconds until the cursor on the taskbar is not the loading cursor (the system is fully interactive then)
  • 11 minutes 37 seconds until the new hardware wizard shows up
  • 11 minutes 47 seconds until Windows complains about not having an antivirus

Just for reference.

the date is supposedly January 1, 1601

To fix this:

  1. Get your VM (in v86) onto a network.
  2. Set the time so it's somewhere in the 2000s. (2022 worked for me, increase this if you read this in a different year)
  3. Sync your VM with a NTP server using the "Internet Time" tab of the Date and Time Properties control panel.

Yes, but would they care? Not really, as it's pretty old and mostly only used for playing around. There is not much risk either. I don't think Copy would really care either. Plus, you pretty much did what you didn't want to do: pirate. You already have a copy of it so it won't matter anyways.

I'm not going to risk it.

What risk?

/ignore Unzor

@hello-smile6 I got a question, since you got Windows XP working on v86, which application did you use to create an .img file?

@hello-smile6 I got a question, since you got Windows XP working on v86, which application did you use to create an .img file?

Used QEMU to install.

I'm checking my email with Windows XP right now. It works well, you just have to use ncat on Arch to allow accessing email without SSL from the XP VM.

ncat -l -k 0.0.0.0 995 -c "ncat --ssl youremail.com 995"

Not the best, but it works!

Try using browservice (https://github.com/ttalvitie/browservice). Its supports as far back as windows 95 and runs on windows and Linux (to do modern web stuff

96 megabytes? I'd either need a floppy with it or a non-throttled WebSocket proxy, neither of which I have. It seems like the floppy driver might not work anyway.

It’s to host on the host os, not on the guest.

Oh. But that doesn't help with email. I'm using email, not a web browser. Anyway, I could probably use the Internet Archive for browsing.

I don’t think you quite understand what it does. Why don’t you take a look at the project, read through the readme. If I’m correct it would even allow you to upload a YouTube video

surprisingly usable if the network connection between the proxy server and the client is fast (such as 100 Mbit/s Ethernet LAN).

relay.widgetry.org is anything but fast, and I don't know of an alternative.

It probably wouldn’t be too hard to write one. I’ve thought about doing it but haven’t ever gotten around to it

It probably wouldn’t be too hard to write one. I’ve thought about doing it but haven’t ever gotten around to it

One of what? A network relay? Can't you just use docker run?

Yeah. I’m not familiar with docker so i wouldn’t know. You could try it

Yeah. I’m not familiar with docker so i wouldn’t know. You could try it

I couldn't, because I don't have a server to run it on. If there was a way to not need direct network access (similar to QEMU with -net user), I'd already have my own network relay!

@Unzor It's possible to create a bootable hard disk image from a Docker container, I wonder if someone could do that with the websockproxy Docker container. If so, it could be run with QEMU and -net user.

It seems like you just have to open it and run docker run --rm --privileged -p 8080:80 --name jor1k-relay bennottelling/websockproxy:latest to start a server.

@copy XP without ACPI should work if select "Standard PC" HAL when hit F5 on install screen

This also works if you:

  1. Install XP in QEMU (Don't bother with disabling ACPI)
  2. Open Device Management
  3. Select "Computer" > right-click > "Update Driver"
  4. Select "Search for a driver"
  5. Select "Choose from a list"
  6. Select "Standard PC"
  7. Reboot your VM when prompted.
  8. Shut down your VM and use it in v86.

I did this with my VM, and it's booting perfectly. 9 minutes after booting in v86, the date is supposedly January 1, 1601 and all is right with Windows. I even have a network connection! Screenshot

Windows XP Works!!!

@hello-smile6 Can you please release that image file for Windows XP for us?

@hello-smile6 Can you please release that image file for Windows XP for us?

It's been a few years, so I might not have it anymore.

@hello-smile6 Can you create it with QEMU again please? I tried to install QEMU on Arch but it is being weird.

Why is this issue still open? Heck, we even got Windows 8 (tho, build 8133) support now