Skip to content

Commit

Permalink
Honor CR0.WP in vTLB.
Browse files Browse the repository at this point in the history
  • Loading branch information
udosteinberg committed Nov 2, 2012
1 parent 9e35d89 commit 85b0e55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/regs.cpp
Expand Up @@ -398,7 +398,7 @@ void Exc_regs::write_cr (unsigned cr, mword val)
toggled = get_cr0<T>() ^ val;

if (!nst_on)
if (toggled & (Cpu::CR0_PG | Cpu::CR0_PE))
if (toggled & (Cpu::CR0_PG | Cpu::CR0_WP | Cpu::CR0_PE))
tlb_flush<T> (true);

set_cr0<T> (val);
Expand Down
4 changes: 4 additions & 0 deletions src/vtlb.cpp
Expand Up @@ -33,6 +33,7 @@ size_t Vtlb::gwalk (Exc_regs *regs, mword gla, mword &gpa, mword &attr, mword &e

bool pse = regs->cr4_shadow & (Cpu::CR4_PSE | Cpu::CR4_PAE);
bool pge = regs->cr4_shadow & Cpu::CR4_PGE;
bool wp = regs->cr0_shadow & Cpu::CR0_WP;

unsigned lev = max();

Expand All @@ -56,6 +57,9 @@ size_t Vtlb::gwalk (Exc_regs *regs, mword gla, mword &gpa, mword &attr, mword &e
continue;
}

if (EXPECT_FALSE (!wp && error == ERR_W))
attr = (attr & ~TLB_U) | TLB_W;

if (EXPECT_FALSE ((attr & error) != error)) {
error |= ERR_P;
return 0;
Expand Down

0 comments on commit 85b0e55

Please sign in to comment.