Skip to content

Commit

Permalink
Added mp flag of cr0 to cpu hflags
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Jan 31, 2024
1 parent d28cfc3 commit db47c90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib86cpu/core/instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ uint32_t update_crN_helper(cpu_ctx_t *cpu_ctx, uint32_t new_cr, uint8_t idx)

if constexpr (idx1 != 2) {
cpu_ctx->hflags = (((new_cr & CR0_EM_MASK) << 3) | (cpu_ctx->hflags & ~HFLG_CR0_EM));
cpu_ctx->hflags = (((new_cr & CR0_MP_MASK) << 14) | (cpu_ctx->hflags & ~HFLG_CR0_MP));
}
cpu_ctx->hflags = (((new_cr & CR0_TS_MASK) << 7) | (cpu_ctx->hflags & ~HFLG_CR0_TS));

Expand Down
7 changes: 5 additions & 2 deletions lib86cpu/core/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void JIT_API tlb_invalidate_(cpu_ctx_t *cpu_ctx, addr_t addr);
// HFLG_CR4_OSFXSR: osfxsr flag of cr4
// HFLG_CR0_TS: ts flag of cr0
// HFLG_TIMEOUT: timeout check was emitted
// HFLG_CR0_MP: mp flag of cr0
// HFLG_CR0_VME: vme flag of cr4
// HFLG_CR0_PVI: pvi flag of cr4
#define CPL_SHIFT 0
Expand All @@ -50,6 +51,7 @@ void JIT_API tlb_invalidate_(cpu_ctx_t *cpu_ctx, addr_t addr);
#define CR0_TS_SHIFT 10
#define TIMEOUT_SHIFT 11
#define INHIBIT_INT_SHIFT 14
#define CR0_MP_SHIFT 15
#define CR4_VME_SHIFT 19
#define CR4_PVI_SHIFT 20
#define HFLG_INVALID (1 << 31) // this should use a bit position that doesn't overlap with either HFLG_CONST or EFLAGS_CONST
Expand All @@ -62,13 +64,14 @@ void JIT_API tlb_invalidate_(cpu_ctx_t *cpu_ctx, addr_t addr);
#define HFLG_DBG_TRAP (1 << DBG_TRAP_SHIFT)
#define HFLG_TIMEOUT (1 << TIMEOUT_SHIFT)
#define HFLG_INHIBIT_INT (1 << INHIBIT_INT_SHIFT)
#define HFLG_CR0_MP (1 << CR0_MP_SHIFT)
#define HFLG_CR0_TS (1 << CR0_TS_SHIFT)
#define HFLG_CR4_OSFXSR (1 << CR4_OSFXSR_SHIFT)
#define HFLG_CR4_VME (1 << CR4_VME_SHIFT)
#define HFLG_CR4_PVI (1 << CR4_PVI_SHIFT)
#define HFLG_CONST (HFLG_CPL | HFLG_CS32 | HFLG_SS32 | HFLG_PE_MODE | HFLG_CR0_EM | HFLG_TRAMP | HFLG_TIMEOUT | HFLG_INHIBIT_INT | HFLG_CR0_TS \
#define HFLG_CONST (HFLG_CPL | HFLG_CS32 | HFLG_SS32 | HFLG_PE_MODE | HFLG_CR0_EM | HFLG_TRAMP | HFLG_TIMEOUT | HFLG_INHIBIT_INT | HFLG_CR0_MP | HFLG_CR0_TS \
| HFLG_CR4_OSFXSR | HFLG_CR4_VME | HFLG_CR4_PVI)
#define HFLG_SAVED_MASK (HFLG_CPL | HFLG_CS32 | HFLG_SS32 | HFLG_PE_MODE | HFLG_CR0_EM | HFLG_INHIBIT_INT | HFLG_CR0_TS | HFLG_CR4_OSFXSR | HFLG_CR4_VME | HFLG_CR4_PVI)
#define HFLG_SAVED_MASK (HFLG_CPL | HFLG_CS32 | HFLG_SS32 | HFLG_PE_MODE | HFLG_CR0_EM | HFLG_INHIBIT_INT | HFLG_CR0_MP | HFLG_CR0_TS | HFLG_CR4_OSFXSR | HFLG_CR4_VME | HFLG_CR4_PVI)

// cpu interrupt flags
#define CPU_NO_INT 0
Expand Down
2 changes: 1 addition & 1 deletion lib86cpu/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#endif

// This should be updated whenever cpu members that need to be saved are added/removed
#define SAVE_STATE_ID 3
#define SAVE_STATE_ID 4


void
Expand Down

0 comments on commit db47c90

Please sign in to comment.