More clean rewrite of the TLB access bits

This commit is contained in:
Stanislav Shwartsman 2008-08-07 22:14:38 +00:00
parent e19c25a234
commit bbf02a8bc5
6 changed files with 79 additions and 120 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: access.cc,v 1.116 2008-08-03 19:53:08 sshwarts Exp $ // $Id: access.cc,v 1.117 2008-08-07 22:14:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -282,7 +282,7 @@ BX_CPU_C::v2h_read_byte(bx_address laddr, bx_bool user)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + user)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | user))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
Bit8u *hostAddr = (Bit8u*) (hostPageAddr | pageOffset); Bit8u *hostAddr = (Bit8u*) (hostPageAddr | pageOffset);
@ -303,7 +303,7 @@ BX_CPU_C::v2h_write_byte(bx_address laddr, bx_bool user)
{ {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << user)) { if (! (tlbEntry->accessBits & (0x6 | user))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
Bit8u *hostAddr = (Bit8u*) (hostPageAddr | pageOffset); Bit8u *hostAddr = (Bit8u*) (hostPageAddr | pageOffset);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: access32.cc,v 1.7 2008-08-07 21:07:53 sshwarts Exp $ // $Id: access32.cc,v 1.8 2008-08-07 22:14:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2008 Stanislav Shwartsman // Copyright (c) 2008 Stanislav Shwartsman
@ -45,7 +45,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_WRITE);
@ -93,7 +93,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_WRITE);
@ -149,7 +149,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_WRITE);
@ -205,7 +205,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_WRITE);
@ -261,7 +261,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_WRITE);
@ -318,7 +318,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_WRITE);
@ -372,7 +372,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_READ);
@ -418,7 +418,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_READ);
@ -472,7 +472,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_READ);
@ -526,7 +526,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_READ);
@ -579,7 +579,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_READ);
@ -633,7 +633,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_READ);
@ -689,7 +689,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_RW); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_RW);
@ -739,7 +739,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_RW); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_RW);
@ -797,7 +797,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_RW); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_RW);
@ -855,7 +855,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_RW); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_RW);
@ -1079,7 +1079,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << user)) { if (! (tlbEntry->accessBits & (0x6 | user))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_WRITE);
@ -1135,7 +1135,7 @@ accessOK:
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << user)) { if (! (tlbEntry->accessBits & (0x6 | user))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_WRITE);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: access64.cc,v 1.12 2008-08-04 05:30:37 sshwarts Exp $ // $Id: access64.cc,v 1.13 2008-08-07 22:14:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2008 Stanislav Shwartsman // Copyright (c) 2008 Stanislav Shwartsman
@ -43,7 +43,7 @@ BX_CPU_C::write_virtual_byte_64(unsigned s, Bit64u offset, Bit8u data)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_WRITE);
@ -82,7 +82,7 @@ BX_CPU_C::write_virtual_word_64(unsigned s, Bit64u offset, Bit16u data)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_WRITE);
@ -130,7 +130,7 @@ BX_CPU_C::write_virtual_dword_64(unsigned s, Bit64u offset, Bit32u data)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_WRITE);
@ -178,7 +178,7 @@ BX_CPU_C::write_virtual_qword_64(unsigned s, Bit64u offset, Bit64u data)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_WRITE);
@ -226,7 +226,7 @@ BX_CPU_C::write_virtual_dqword_64(unsigned s, Bit64u offset, const BxPackedXmmRe
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_WRITE);
@ -275,7 +275,7 @@ BX_CPU_C::write_virtual_dqword_aligned_64(unsigned s, Bit64u offset, const BxPac
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_WRITE);
@ -320,7 +320,7 @@ BX_CPU_C::read_virtual_byte_64(unsigned s, Bit64u offset)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_READ);
@ -357,7 +357,7 @@ BX_CPU_C::read_virtual_word_64(unsigned s, Bit64u offset)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_READ);
@ -403,7 +403,7 @@ BX_CPU_C::read_virtual_dword_64(unsigned s, Bit64u offset)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_READ);
@ -449,7 +449,7 @@ BX_CPU_C::read_virtual_qword_64(unsigned s, Bit64u offset)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_READ);
@ -493,7 +493,7 @@ BX_CPU_C::read_virtual_dqword_64(unsigned s, Bit64u offset, BxPackedXmmRegister
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_READ);
@ -537,7 +537,7 @@ BX_CPU_C::read_virtual_dqword_aligned_64(unsigned s, Bit64u offset, BxPackedXmmR
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us read access // See if the TLB entry privilege level allows us read access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl)) { // Read this pl OK. if (! (tlbEntry->accessBits & (0x4 | USER_PL))) { // Read this pl OK.
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_READ); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 16, BX_READ);
@ -584,7 +584,7 @@ BX_CPU_C::read_RMW_virtual_byte_64(unsigned s, Bit64u offset)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_RW); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 1, BX_RW);
@ -625,7 +625,7 @@ BX_CPU_C::read_RMW_virtual_word_64(unsigned s, Bit64u offset)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_RW); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 2, BX_RW);
@ -675,7 +675,7 @@ BX_CPU_C::read_RMW_virtual_dword_64(unsigned s, Bit64u offset)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_RW); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 4, BX_RW);
@ -725,7 +725,7 @@ BX_CPU_C::read_RMW_virtual_qword_64(unsigned s, Bit64u offset)
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << BX_CPU_THIS_PTR user_pl)) { if (! (tlbEntry->accessBits & (0x6 | USER_PL))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_RW); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_RW);
@ -770,7 +770,7 @@ void BX_CPU_C::write_new_stack_qword_64(Bit64u laddr, unsigned curr_pl, Bit64u d
if (tlbEntry->lpf == lpf) { if (tlbEntry->lpf == lpf) {
// See if the TLB entry privilege level allows us write access // See if the TLB entry privilege level allows us write access
// from this CPL. // from this CPL.
if (tlbEntry->accessBits & (0x04 << user)) { if (! (tlbEntry->accessBits & (0x6 | user))) {
bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr;
Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u pageOffset = PAGE_OFFSET(laddr);
BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_WRITE); BX_INSTR_LIN_ACCESS(BX_CPU_ID, laddr, tlbEntry->ppf | pageOffset, 8, BX_WRITE);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: cpu.cc,v 1.234 2008-08-03 19:53:08 sshwarts Exp $ // $Id: cpu.cc,v 1.235 2008-08-07 22:14:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -644,7 +644,7 @@ void BX_CPU_C::prefetch(void)
bx_TLB_entry *tlbEntry = &BX_CPU_THIS_PTR TLB.entry[TLB_index]; bx_TLB_entry *tlbEntry = &BX_CPU_THIS_PTR TLB.entry[TLB_index];
Bit8u *fetchPtr = 0; Bit8u *fetchPtr = 0;
if (tlbEntry->lpf == lpf && (tlbEntry->accessBits & (0x01 + BX_CPU_THIS_PTR user_pl))) { if (tlbEntry->lpf == lpf && !(tlbEntry->accessBits & (0x4 | USER_PL))) {
pAddr = A20ADDR(tlbEntry->ppf | pageOffset); pAddr = A20ADDR(tlbEntry->ppf | pageOffset);
#if BX_SupportGuest2HostTLB #if BX_SupportGuest2HostTLB
fetchPtr = (Bit8u*) (tlbEntry->hostPageAddr); fetchPtr = (Bit8u*) (tlbEntry->hostPageAddr);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.499 2008-08-03 19:53:08 sshwarts Exp $ // $Id: cpu.h,v 1.500 2008-08-07 22:14:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -243,7 +243,9 @@
#endif #endif
#define CPL (BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.rpl) #define CPL (BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.rpl)
#define USER_PL (BX_CPU_THIS_PTR user_pl) /* CPL == 3 */
#if BX_SUPPORT_SMP #if BX_SUPPORT_SMP
#define BX_CPU_ID (BX_CPU_THIS_PTR bx_cpuid) #define BX_CPU_ID (BX_CPU_THIS_PTR bx_cpuid)

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: paging.cc,v 1.147 2008-08-04 14:46:28 sshwarts Exp $ // $Id: paging.cc,v 1.148 2008-08-07 22:14:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -331,41 +331,28 @@ static unsigned priv_check[BX_PRIV_CHECK_SIZE];
// value, necessitating a TLB flush when CR0.WP changes. // value, necessitating a TLB flush when CR0.WP changes.
// //
// The test is: // The test is:
// OK = 1 << ( (W<<1) | U ) [W:1=write, 0=read, U:1=CPL3,0=CPL0-2] // OK = (accessBits & ((W<<1) | U)) != 0 [W:1=write, 0=read, U:1=CPL3,0=CPL0-2]
//
// Thus for reads, it is:
// OK = 0x10 << ( U )
// And for writes:
// OK = 0x40 << ( U )
// //
// bit 7: a Write from User privilege is OK // Or when taking into account direct access according to Host Ptr:
// bit 6: a Write from System privilege is OK // OK = (accessBits & (TLB_HostPtr | (W<<1) | U)) != 0
// bit 5: a Read from User privilege is OK
// bit 4: a Read from System privilege is OK // Thus for direct reads, it is:
// OK = 0x4 << ( U )
// And for direct writes:
// OK = 0x6 << ( U )
// //
// And the lowest 4 bits are as above, except that they also indicate // Note, that the TLB accessBits should have TLB_HostPtr bit set when
// that hostPageAddr is valid, so we do not separately need to test // direct access through host pointer is NOT allowed for the page.
// that pointer against NULL. These have smaller constants for us // A memory operation asking for a direct access through host pointer
// to be able to use smaller encodings in the trace generators. Note // will set TLB_HostPtr bit in the accessBits and thus get non zero
// that whenever bit n (n=0,1,2,3) is set, then also n+4 is set. // result when the direct access is not allowed.
// (The opposite is of course not true)
//
// bit 3: a Write from User privilege is OK, hostPageAddr is valid
// bit 2: a Write from System privilege is OK, hostPageAddr is valid
// bit 1: a Read from User privilege is OK, hostPageAddr is valid
// bit 0: a Read from System privilege is OK, hostPageAddr is valid
// //
#define TLB_WriteUserOK 0x80 #define TLB_SysOnly (0x01)
#define TLB_WriteSysOK 0x40 #define TLB_ReadOnly (0x02)
#define TLB_ReadUserOK 0x20 #define TLB_HostPtr (0x04) /* set this bit when direct access is NOT allowed */
#define TLB_ReadSysOK 0x10
#define TLB_WriteUserPtrOK 0x08
#define TLB_WriteSysPtrOK 0x04
#define TLB_ReadUserPtrOK 0x02
#define TLB_ReadSysPtrOK 0x01
#define TLB_GlobalPage 0x80000000 #define TLB_GlobalPage (0x80000000)
// === TLB Instrumentation section ============================== // === TLB Instrumentation section ==============================
@ -920,7 +907,7 @@ bx_phy_address BX_CPU_C::translate_linear_PAE(bx_address laddr, Bit32u &combined
// Translate a linear address to a physical address // Translate a linear address to a physical address
bx_phy_address BX_CPU_C::translate_linear(bx_address laddr, unsigned curr_pl, unsigned rw, unsigned access_type) bx_phy_address BX_CPU_C::translate_linear(bx_address laddr, unsigned curr_pl, unsigned rw, unsigned access_type)
{ {
Bit32u accessBits, combined_access = 0; Bit32u combined_access = 0;
unsigned priv_index; unsigned priv_index;
// note - we assume physical memory < 4gig so for brevity & speed, we'll use // note - we assume physical memory < 4gig so for brevity & speed, we'll use
@ -941,7 +928,7 @@ bx_phy_address BX_CPU_C::translate_linear(bx_address laddr, unsigned curr_pl, un
{ {
paddress = tlbEntry->ppf | poffset; paddress = tlbEntry->ppf | poffset;
if (tlbEntry->accessBits & (0x10 << ((isWrite<<1) | pl))) if (! (tlbEntry->accessBits & ((isWrite<<1) | pl)))
return paddress; return paddress;
// The current access does not have permission according to the info // The current access does not have permission according to the info
@ -1084,29 +1071,14 @@ bx_phy_address BX_CPU_C::translate_linear(bx_address laddr, unsigned curr_pl, un
tlbEntry->lpf = lpf; tlbEntry->lpf = lpf;
tlbEntry->ppf = ppf; tlbEntry->ppf = ppf;
// b3: Write User OK Bit32u accessBits = TLB_HostPtr; // HostPtr is not allowed by default
// b2: Write Sys OK
// b1: Read User OK if ((combined_access & 4) == 0) // System
// b0: Read Sys OK accessBits |= TLB_SysOnly;
if (combined_access & 4) { // User
// User priv; read from {user,sys} OK. if (! isWrite) // Current operation is a read
accessBits = (TLB_ReadUserOK | TLB_ReadSysOK); accessBits |= TLB_ReadOnly; // Write NOT allowed
if (isWrite) { // Current operation is a write (Dirty bit updated)
if (combined_access & 2) {
// R/W access from {user,sys} OK.
accessBits |= (TLB_WriteUserOK | TLB_WriteSysOK);
}
else {
accessBits |= TLB_WriteSysOK; // read only page, only {sys} write allowed
}
}
}
else { // System
accessBits = TLB_ReadSysOK; // System priv; read from {sys} OK.
if (isWrite) { // Current operation is a write (Dirty bit updated)
accessBits |= TLB_WriteSysOK; // write from {sys} OK.
}
}
#if BX_SUPPORT_GLOBAL_PAGES #if BX_SUPPORT_GLOBAL_PAGES
if (combined_access & 0x100) // Global bit if (combined_access & 0x100) // Global bit
accessBits |= TLB_GlobalPage; accessBits |= TLB_GlobalPage;
@ -1124,7 +1096,7 @@ bx_phy_address BX_CPU_C::translate_linear(bx_address laddr, unsigned curr_pl, un
#if BX_X86_DEBUGGER #if BX_X86_DEBUGGER
if (! hwbreakpoint_check(laddr)) if (! hwbreakpoint_check(laddr))
#endif #endif
accessBits |= (accessBits & 0xF0) >> 4; accessBits &= ~TLB_HostPtr; // allow direct access with HostPtr
} }
#endif #endif
tlbEntry->accessBits = accessBits; tlbEntry->accessBits = accessBits;
@ -1314,8 +1286,7 @@ void BX_CPU_C::access_write_linear(bx_address laddr, unsigned len, unsigned curr
tlbEntry->ppf = (bx_phy_address) lpf; tlbEntry->ppf = (bx_phy_address) lpf;
tlbEntry->hostPageAddr = hostPageAddr; tlbEntry->hostPageAddr = hostPageAddr;
// Got direct write pointer OK. Mark for any operation to succeed. // Got direct write pointer OK. Mark for any operation to succeed.
tlbEntry->accessBits = (TLB_ReadSysOK | TLB_ReadUserOK | TLB_WriteSysOK | TLB_WriteUserOK | tlbEntry->accessBits = 0;
TLB_ReadSysPtrOK | TLB_ReadUserPtrOK | TLB_WriteSysPtrOK | TLB_WriteUserPtrOK);
} }
} }
} }
@ -1478,28 +1449,14 @@ void BX_CPU_C::access_read_linear(bx_address laddr, unsigned len, unsigned curr_
// Request a direct write pointer so we can do either R or W. // Request a direct write pointer so we can do either R or W.
bx_hostpageaddr_t hostPageAddr = (bx_hostpageaddr_t) bx_hostpageaddr_t hostPageAddr = (bx_hostpageaddr_t)
BX_MEM(0)->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_WRITE, DATA_ACCESS); BX_MEM(0)->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_READ, DATA_ACCESS);
if (hostPageAddr) { if (hostPageAddr) {
tlbEntry->lpf = lpf; tlbEntry->lpf = lpf;
tlbEntry->ppf = (bx_phy_address) lpf; tlbEntry->ppf = (bx_phy_address) lpf;
tlbEntry->hostPageAddr = hostPageAddr; tlbEntry->hostPageAddr = hostPageAddr;
// Got direct write pointer OK. Mark for any operation to succeed. // Got direct read pointer OK. Mark for any following read to succeed.
tlbEntry->accessBits = (TLB_ReadSysOK | TLB_ReadUserOK | TLB_WriteSysOK | TLB_WriteUserOK | tlbEntry->accessBits = TLB_ReadOnly;
TLB_ReadSysPtrOK | TLB_ReadUserPtrOK | TLB_WriteSysPtrOK | TLB_WriteUserPtrOK);
}
else {
// Direct write vetoed. Try requesting only direct reads.
hostPageAddr = (bx_hostpageaddr_t) BX_MEM(0)->getHostMemAddr(BX_CPU_THIS,
A20ADDR(lpf), BX_READ, DATA_ACCESS);
if (hostPageAddr) {
tlbEntry->lpf = lpf;
tlbEntry->ppf = (bx_phy_address) lpf;
tlbEntry->hostPageAddr = hostPageAddr;
// Got direct write pointer OK. Mark for any operation to succeed.
tlbEntry->accessBits = (TLB_ReadSysOK | TLB_ReadUserOK | TLB_ReadSysPtrOK | TLB_ReadUserPtrOK);
}
} }
} }
} }