Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
id: cache-kvm-unit-test
with:
path: tests/kvm-unit-tests/
key: ${{ runner.os }}-kvm-unit-test
key: ${{ runner.os }}-kvm-unit-test-${{ hashFiles('tests/kvm-unit-tests/**') }}

- name: Build kvm-unit-test
if: steps.cache-kvm-unit-test.outputs.cache-hit != 'true'
Expand All @@ -74,13 +74,15 @@ jobs:
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/taskswitch2.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/pat.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/nx.flat
DISABLE_JIT=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/nx.flat

- name: Fetch namsmtests cache
uses: actions/cache@v5
id: cache-nasmtests
with:
path: tests/nasm/build/
key: ${{ runner.os }}-nasmtests
key: ${{ runner.os }}-nasmtests-${{ hashFiles('gen/x86_table.js', 'tests/nasm/*.js', 'tests/nasm/*.asm', 'tests/nasm/*.inc', 'tests/nasm/gdb-extract-def') }}

- name: Run nasmtests
run: MAX_PARALLEL_TESTS=1 make nasmtests
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,15 @@ kvm-unit-test: build/v86-debug.wasm
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/taskswitch2.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/pat.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/nx.flat

kvm-unit-test-release: build/libv86.mjs build/v86.wasm
tests/kvm-unit-tests/build.sh
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/taskswitch.flat
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/taskswitch2.flat
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/pat.flat
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/nx.flat

expect-tests: build/v86-debug.wasm build/libwabt.cjs
make -C tests/expect/tests
Expand Down
4 changes: 4 additions & 0 deletions src/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export function CPU(bus, wm, stop_idling)
this.dreg = view(Int32Array, memory, 684, 8);

this.reg_pdpte = view(Int32Array, memory, 968, 8);
this.efer = view(Uint32Array, memory, 1280, 2);
this.pat = view(Uint32Array, memory, 1288, 2);

this.svga_dirty_bitmap_min_offset = view(Uint32Array, memory, 716, 1);
Expand Down Expand Up @@ -571,6 +572,7 @@ CPU.prototype.get_state = function()
state[89] = this.devices.vmware;
state[90] = this.devices.parallel0;
state[91] = this.devices.parallel1;
state[92] = this.efer;
state[93] = this.pat;

return state;
Expand Down Expand Up @@ -690,6 +692,8 @@ CPU.prototype.set_state = function(state)
this.dreg.set(state[41]);
state[42] && this.reg_pdpte.set(state[42]);
this.pat.set(state[93] || [0x00070406, 0x00070406]);
this.efer.fill(0);
state[92] && this.efer.set(state[92]);

this.set_tsc(state[43][0], state[43][1]);

Expand Down
15 changes: 10 additions & 5 deletions src/rust/codegen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::cpu::cpu::{
tlb_data, FLAG_CARRY, FLAG_OVERFLOW, FLAG_SIGN, FLAG_ZERO, OPSIZE_16, OPSIZE_32, OPSIZE_8,
TLB_GLOBAL, TLB_HAS_CODE, TLB_NO_USER, TLB_READONLY, TLB_VALID,
TLB_GLOBAL, TLB_HAS_CODE, TLB_NO_EXEC, TLB_NO_USER, TLB_READONLY, TLB_VALID,
};
use crate::cpu::global_pointers;
use crate::cpu::memory;
Expand Down Expand Up @@ -671,6 +671,7 @@ fn gen_safe_read(
& !TLB_READONLY
& !TLB_GLOBAL
& !TLB_HAS_CODE
& !TLB_NO_EXEC
& !(if ctx.cpu.cpl3() { 0 } else { TLB_NO_USER })) as i32,
);
ctx.builder.and_i32();
Expand Down Expand Up @@ -882,8 +883,10 @@ fn gen_safe_write(
.load_aligned_i32(unsafe { &tlb_data[0] as *const i32 as u32 });
let entry_local = ctx.builder.tee_new_local();

ctx.builder
.const_i32((0xFFF & !TLB_GLOBAL & !(if ctx.cpu.cpl3() { 0 } else { TLB_NO_USER })) as i32);
ctx.builder.const_i32(
(0xFFF & !TLB_GLOBAL & !TLB_NO_EXEC & !(if ctx.cpu.cpl3() { 0 } else { TLB_NO_USER }))
as i32,
);
ctx.builder.and_i32();

ctx.builder.const_i32(TLB_VALID as i32);
Expand Down Expand Up @@ -1034,8 +1037,10 @@ pub fn gen_safe_read_write(
.load_aligned_i32(unsafe { &tlb_data[0] as *const i32 as u32 });
let entry_local = ctx.builder.tee_new_local();

ctx.builder
.const_i32((0xFFF & !TLB_GLOBAL & !(if ctx.cpu.cpl3() { 0 } else { TLB_NO_USER })) as i32);
ctx.builder.const_i32(
(0xFFF & !TLB_GLOBAL & !TLB_NO_EXEC & !(if ctx.cpu.cpl3() { 0 } else { TLB_NO_USER }))
as i32,
);
ctx.builder.and_i32();

ctx.builder.const_i32(TLB_VALID as i32);
Expand Down
Loading
Loading