VOGONS


First post, by danoon

User metadata
Rank Member
Rank
Member

@peterfirefly posted this question to me in Some free online sources for things that might help with emulator development? and I decided to answer in a new thread

Running Boxedwine didn't really go well... […]
Show full quote

Running Boxedwine didn't really go well...

Finding the executable was easy.

The GUI is nice. I love that it checks for a Wine and offers to download one for me (Wine 9.0).

Unfortunately, I haven't been able to make it run anything.

I tried installing some of the demos. That didn't go well.

I tried Age of Empires first. I got "alloc64kBlock: failed to commit memory : Cannot allocate memory" and the install failed.

I tried Abiword. It installed but launching it gave me the same error.

I tried Diablo II shareware. Same error, won't even install.

It also seems to be very, very slow.

Quitting Boxedwine by closing the window sorta worked: it took a really long time to react and this was what was printed on the terminal:

€ ./boxedwine

Starting ...

alloc64kBlock: failed to commit memory : Cannot allocate memory

alloc64kBlock: failed to commit memory : Cannot allocate memory

alloc64kBlock: failed to commit memory : Cannot allocate memory

Boxedwine shutdown

Segmentation fault (core dumped)

I thought I maybe got the "Normal" CPU, perhaps even without caching of decode blocks.

Seems like BT_FLAGS (in the makefile) isn't used unless I specify 'multiThreaded' on the command line when I run make.

So I tried rebuilding Boxedwine with "CC=gcc-12 CXX=g++-12 make multiThreaded" and doing it again. It still didn't work.

I tried installing Wine 6.0. Still didn't work.

Clicking the close button of the window didn't work anymore. After several minutes, I had to give up by using "killall -9 boxedwine". Just "killall boxedwine" doesn't work for some reason.
The weird thing is that the GUI runs a "please wait" animation flawlessly, so why doesn't it react when I click the "close window" button?

Is there a way to get the executable to tell me how it was compiled? Something like uname, /etc/lsb-release, compiler, compiler version, important #define's?

I'm curious about you system.

You can try "make release" to get the Normal CPU core.

And thanks for the reminder, I definitely need to update my docs to say that gcc 12 or later is required to compile.

The normal CPU core without the binary translator on Linux will be slow. In the last year I have been working on the a normal CPU core that supports multi-threading which speeds things up about 50%, but I haven't added that option to the Linux makefile yet. Currently that option is only on Windows and Emscripten/Wasm.

As for the binary translator running out of memory, I have seen that before. Boxedwine's binary translator uses way too much memory, 2GB+. It is on my list of things to do to reduce that memory usage. But it is still surprising to see that error, I haven't tested it in a while, but at one point I was actively testing on the Raspberry Pi which didn't have much memory.

How do you detect instructions > 15 bytes (due to repeated prefixes) so you can generate an exception for that?

I don't handle this since I have never seen a game that does that.

My first question was how you handle the x86 memory model on ARM hosts (only relevant for SMP, of course). A quick glance didn't spot any memory barriers in armv8btAsm.cpp, for example.

I have read a lot on this and from my understanding, I probably don't handle that perfectly. I add "dmb ish" for memory instructions that have the lock prefix

https://github.com/danoon2/Boxedwine/blob/21c … 587C18-L1587C35

https://github.com/danoon2/Boxedwine

Reply 1 of 4, by danoon

User metadata
Rank Member
Rank
Member

@peterfirefly

Looks like your decoder system pretends that prefixes are instructions -- which also explains why you talk about LOCK as if it were an instruction:

Each instruction gets decoded and cached as a DecodedOp, the lock prefix is just a flag on that op

https://github.com/danoon2/Boxedwine/blob/21c … decoder.h#L1493

But one thing that makes this approach difficult is that ops are linked together by one op pointing to the "next" op. And sometimes code will do something like this

The attachment lock.jpg is no longer available

I don't make the lock prefix its own op, but I do have to code like it is one sometimes when the code tries to be cleaver and skip the lock prefix.

https://github.com/danoon2/Boxedwine

Reply 2 of 4, by peterfirefly

User metadata
Rank Newbie
Rank
Newbie
danoon wrote on 2025-02-22, 16:26:
@peterfirefly posted this question to me in Some free online sources for things that might help with emulator development? and I […]
Show full quote

@peterfirefly posted this question to me in Some free online sources for things that might help with emulator development? and I decided to answer in a new thread

Running Boxedwine didn't really go well... […]
Show full quote

Running Boxedwine didn't really go well...

Finding the executable was easy.

The GUI is nice. I love that it checks for a Wine and offers to download one for me (Wine 9.0).

Unfortunately, I haven't been able to make it run anything.

I tried installing some of the demos. That didn't go well.

I tried Age of Empires first. I got "alloc64kBlock: failed to commit memory : Cannot allocate memory" and the install failed.

I tried Abiword. It installed but launching it gave me the same error.

I tried Diablo II shareware. Same error, won't even install.

It also seems to be very, very slow.

Quitting Boxedwine by closing the window sorta worked: it took a really long time to react and this was what was printed on the terminal:

€ ./boxedwine

Starting ...

alloc64kBlock: failed to commit memory : Cannot allocate memory

alloc64kBlock: failed to commit memory : Cannot allocate memory

alloc64kBlock: failed to commit memory : Cannot allocate memory

Boxedwine shutdown

Segmentation fault (core dumped)

I thought I maybe got the "Normal" CPU, perhaps even without caching of decode blocks.

Seems like BT_FLAGS (in the makefile) isn't used unless I specify 'multiThreaded' on the command line when I run make.

So I tried rebuilding Boxedwine with "CC=gcc-12 CXX=g++-12 make multiThreaded" and doing it again. It still didn't work.

I tried installing Wine 6.0. Still didn't work.

Clicking the close button of the window didn't work anymore. After several minutes, I had to give up by using "killall -9 boxedwine". Just "killall boxedwine" doesn't work for some reason.
The weird thing is that the GUI runs a "please wait" animation flawlessly, so why doesn't it react when I click the "close window" button?

Is there a way to get the executable to tell me how it was compiled? Something like uname, /etc/lsb-release, compiler, compiler version, important #define's?

I'm curious about you system.

You can try "make release" to get the Normal CPU core.

And thanks for the reminder, I definitely need to update my docs to say that gcc 12 or later is required to compile.

I'll try "make release".

There are about a dozen other minor inconsistencies across your docs. Nothing major but slightly confusing nonetheless.

The normal CPU core without the binary translator on Linux will be slow. In the last year I have been working on the a normal CPU core that supports multi-threading which speeds things up about 50%, but I haven't added that option to the Linux makefile yet. Currently that option is only on Windows and Emscripten/Wasm.

As for the binary translator running out of memory, I have seen that before. Boxedwine's binary translator uses way too much memory, 2GB+. It is on my list of things to do to reduce that memory usage. But it is still surprising to see that error, I haven't tested it in a while, but at one point I was actively testing on the Raspberry Pi which didn't have much memory.

The WSL2 VM has 10GB of RAM (+3 GB swap) so 2-3GB should not be an issue 😀

What really puzzled me was how long the emulator just twiddled its thumbs before throwing that error. It was either being very, very slow or it was doing something it really shouldn't have been doing.

I have read a lot on this and from my understanding, I probably don't handle that perfectly. I add "dmb ish" for memory instruc […]
Show full quote
My first question was how you handle the x86 memory model on ARM hosts (only relevant for SMP, of course). A quick glance didn't spot any memory barriers in armv8btAsm.cpp, for example.

I have read a lot on this and from my understanding, I probably don't handle that perfectly. I add "dmb ish" for memory instructions that have the lock prefix

https://github.com/danoon2/Boxedwine/blob/21c … 587C18-L1587C35

You definitely don't 😉
There are plenty of games that work fine anyway and the rest can be restricted to one CPU, I guess.

Reply 3 of 4, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie
peterfirefly wrote on 2025-02-23, 11:34:

What really puzzled me was how long the emulator just twiddled its thumbs before throwing that error. It was either being very, very slow or it was doing something it really shouldn't have been doing.

Not sure how Boxedwine in particular is handling page permissions for generated code (i.e. if it's making the memory writable only as needed or just leaving it always writable), but windows defender tends to freak out and behave terribly when apps modify memory marked as writable+executable. Add WSL into the mix and I could see that being the perfect storm for unresponsiveness.

Reply 4 of 4, by danoon

User metadata
Rank Member
Rank
Member
jmarsh wrote on 2025-02-23, 12:20:

Not sure how Boxedwine in particular is handling page permissions for generated code (i.e. if it's making the memory writable only as needed or just leaving it always writable), but windows defender tends to freak out and behave terribly when apps modify memory marked as writable+executable. Add WSL into the mix and I could see that being the perfect storm for unresponsiveness.

Thanks for that, I'll have to look into that more. Currently I give it the permission PAGE_EXECUTE_READWRITE and leave it at that.

https://github.com/danoon2/Boxedwine/blob/21c … atform.cpp#L614

https://github.com/danoon2/Boxedwine