Commit graph

5 commits

Author SHA1 Message Date
Fabian 4c61535b12 Slightly improve string instructions 2020-12-31 19:14:31 -06:00
Amaan Cheval a9bb4619ef cpu: Expand return_on_pagefault macro for cleanup 2020-08-30 19:29:54 -05:00
Amaan Cheval 8e7061eff5 cpu: Port test_privileges_for_io to Rust 2020-08-30 19:29:54 -05:00
Amaan Cheval 6cc262bdba cleanup: Use OrPageFault type alias for clarity 2020-08-30 19:29:54 -05:00
Fabian a88420910d Handle pagefaults without JS exceptions
This commit makes the return type of most basic memory access primitives
Result, where the Err(()) case means a page fault happened, the
instruction should be aborted and execution should continue at the page
fault handler.

The following primites have a Result return type: safe_{read,write}*,
translate_address_*, read_imm*, writable_or_pagefault, get_phys_eip,
modrm_resolve, push*, pop*.

Any instruction needs to handle the page fault cases and abort
execution appropriately. The return_on_pagefault! macro has been
provided to get the same behaviour as the previously used JS exceptions
(local to the function).

Calls from JavaScript abort on a pagefault, except for
writable_or_pagefault, which returns a boolean. JS needs to check
before calling any function that may pagefault.

This commit does not yet pervasively apply return_on_pagefault!, this
will be added in the next commit.

Jitted code does not yet properly handle the new form of page faults,
this will be added in a later commit.
2020-08-30 19:29:53 -05:00