nepx / halfix

x86 PC emulator that runs both natively and in the browser, via WebAssembly
https://nepx.github.io/halfix-demo/
GNU General Public License v3.0
681 stars 87 forks source link

Windows XP not working in halfix-demo #25

Open Pixelsuft opened 3 years ago

Pixelsuft commented 3 years ago

On Halfix for Windows: HalfFix In Browser, before loading screen VM resets: Browser

On Windows works with .img/splitted image. In browser in Safe Mode not works

Pixelsuft commented 3 years ago

bsod Next Boot, Maybe BSOD?

nepx commented 3 years ago

The WebAssembly version is notoriously unstable. WinXP occasionally works, other times it crashes. Based on the fact that it works in the native version but not in the browser, I have a feeling that there's some obscure translation bug regarding endianness, alignment, or something else.

When I was first debugging the WebAssembly version, I tested Win95 in the browser, and it crashed midway through boot. It worked fine in the native version, but there was a very minor quirk in how WASM compiled the MUL/IMUL instruction sequences, which caused them to produce the wrong value. I fixed it, but it goes to show how flaky support is.

Some things to check are:

You can comment out #define LOGGING_DISABLED on line 22 of include/util.h to get logging output like you do in the native version. You can call saveLog() in the console (line 439 of libhalfix.js) and inspect the tail end of the logging output.

I am working on a rewrite in Rust to get rid of stupid issues like these and hopefully improve performance. Sorry for the inconvenience.

On 4/16/21, @. @.> wrote:

bsod Next Boot, Maybe BSOD?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/nepx/halfix/issues/25#issuecomment-821142437

fuel-pcbox commented 3 years ago

Do you have APIC enabled? Windows XP will ordinarily triple fault (+restart) if you don't have it enabled

This sounds like a bug. 86Box doesn't emulate the APIC at all, yet Windows XP runs without any problems.

nepx commented 3 years ago

If you install XP on a system with APIC support, it will assume that it's present for all future boots, whether or not the current system has it or not. The exact sequence of events is that it tries to access 0xFEE00000 in physical memory, finds nothing there, tries to read the APIC base field from the MADT (which the BIOS sets up), the BIOS rightly doesn't detect an APIC and zeroes it, and XP crashes because it attempts to read from an invalid address. That was a lot of fun to debug. This bug also manifested when users created images in QEMU (which emulates the APIC) and running it in the v86 emulator (which at the time didn't support the APIC).

Images made on 86Box (or another emulator that doesn't support APIC, like jDosBox) will work without the APIC enabled because the system that it was installed on doesn't have it. In fact, I have a test image that I installed on jDosBox, and it works with the APIC disabled.

Both QEMU and Halfix enable the APIC by default, but the web version is a bit wonky, and it's a problem that I've experienced in the past when I had unwittingly turned off APIC support in the browser and had XP crash on me.

On 4/27/21, qeeg @.***> wrote:

Do you have APIC enabled? Windows XP will ordinarily triple fault (+restart) if you don't have it enabled

This sounds like a bug. 86Box doesn't emulate the APIC at all, yet Windows XP runs without any problems.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/nepx/halfix/issues/25#issuecomment-827836739

Pixelsuft commented 3 years ago

Oh, OK. I'm installed it with ACPI and APIC. Without APIC not works. And one question: When I'm running halfix for windows with Git Bash, it runs faster, than with cmd/powershell.

Pixelsuft commented 3 years ago

image

nepx commented 3 years ago

Sorry for the long wait, I'm very busy at the moment.

You may want to try enabling PCI as well. Taking a closer look at the error, it seems like the OS is intentionally triggering the reset, so this is likely a hardware configuration error or something similar.

On 4/28/21, @. @.> wrote:

image

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/nepx/halfix/issues/25#issuecomment-828419474

Pixelsuft commented 3 years ago

With PCI and ACPI not works. (I've installed without PCI)