2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2005-04-14 20:44:40 +04:00
|
|
|
// $Id: paging.cc,v 1.59 2005-04-14 16:44:40 sshwarts Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2001-04-10 06:20:02 +04:00
|
|
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
// Notes from merge of x86-64 enhancements: (KPL)
|
|
|
|
// Looks like for x86-64/PAE=1/PTE with PSE=1, the
|
|
|
|
// CR4.PSE field is not consulted by the processor?
|
|
|
|
// Fix the PAE case to not update the page table tree entries
|
|
|
|
// until the final protection check? This is how it is on
|
|
|
|
// P6 for non-PAE anyways...
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-24 22:46:34 +04:00
|
|
|
#define NEED_CPU_REG_SHORTCUTS 1
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "bochs.h"
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
#define LOG_THIS BX_CPU_THIS_PTR
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
// X86 Registers Which Affect Paging:
|
|
|
|
// ==================================
|
|
|
|
//
|
|
|
|
// CR0:
|
|
|
|
// bit 31: PG, Paging (386+)
|
|
|
|
// bit 16: WP, Write Protect (486+)
|
|
|
|
// 0: allow supervisor level writes into user level RO pages
|
|
|
|
// 1: inhibit supervisor level writes into user level RO pages
|
|
|
|
//
|
|
|
|
// CR3:
|
|
|
|
// bit 31..12: PDBR, Page Directory Base Register (386+)
|
|
|
|
// bit 4: PCD, Page level Cache Disable (486+)
|
|
|
|
// Controls caching of current page directory. Affects only the processor's
|
|
|
|
// internal caches (L1 and L2).
|
|
|
|
// This flag ignored if paging disabled (PG=0) or cache disabled (CD=1).
|
|
|
|
// Values:
|
|
|
|
// 0: Page Directory can be cached
|
|
|
|
// 1: Page Directory not cached
|
|
|
|
// bit 3: PWT, Page level Writes Transparent (486+)
|
|
|
|
// Controls write-through or write-back caching policy of current page
|
|
|
|
// directory. Affects only the processor's internal caches (L1 and L2).
|
|
|
|
// This flag ignored if paging disabled (PG=0) or cache disabled (CD=1).
|
|
|
|
// Values:
|
|
|
|
// 0: write-back caching enabled
|
|
|
|
// 1: write-through caching enabled
|
|
|
|
//
|
|
|
|
// CR4:
|
|
|
|
// bit 4: PSE, Page Size Extension (Pentium+)
|
|
|
|
// 0: 4KByte pages (typical)
|
|
|
|
// 1: 4MByte or 2MByte pages
|
|
|
|
// bit 5: PAE, Physical Address Extension (Pentium Pro+)
|
|
|
|
// 0: 32bit physical addresses
|
|
|
|
// 1: 36bit physical addresses
|
|
|
|
// bit 7: PGE, Page Global Enable (Pentium Pro+)
|
|
|
|
// The global page feature allows frequently used or shared pages
|
|
|
|
// to be marked as global (PDE or PTE bit 8). Global pages are
|
|
|
|
// not flushed from TLB on a task switch or write to CR3.
|
|
|
|
// Values:
|
|
|
|
// 0: disables global page feature
|
|
|
|
// 1: enables global page feature
|
|
|
|
//
|
|
|
|
// Page size extention and physical address size extention matrix
|
|
|
|
// ====================================================================
|
|
|
|
// CR0.PG CR4.PAE CR4.PSE PDE.PS | page size physical address size
|
|
|
|
// ====================================================================
|
|
|
|
// 0 X X X | - paging disabled
|
|
|
|
// 1 0 0 X | 4K 32bits
|
|
|
|
// 1 0 1 0 | 4K 32bits
|
|
|
|
// 1 0 1 1 | 4M 32bits
|
|
|
|
// 1 1 X 0 | 4K 36bits
|
|
|
|
// 1 1 X 1 | 2M 36bits
|
|
|
|
|
|
|
|
|
|
|
|
// Page Directory/Table Entry format when P=0:
|
|
|
|
// ===========================================
|
|
|
|
//
|
|
|
|
// 31.. 1: available
|
|
|
|
// 0: P=0
|
|
|
|
|
|
|
|
// Page Directory Entry format when P=1 (4-Kbyte Page Table):
|
|
|
|
// ==========================================================
|
|
|
|
//
|
|
|
|
// 31..12: page table base address
|
|
|
|
// 11.. 9: available
|
|
|
|
// 8: G (Pentium Pro+), 0=reserved otherwise
|
|
|
|
// 7: PS (Pentium+), 0=reserved otherwise
|
|
|
|
// 6: 0=reserved
|
|
|
|
// 5: A (386+)
|
|
|
|
// 4: PCD (486+), 0=reserved otherwise
|
|
|
|
// 3: PWT (486+), 0=reserved otherwise
|
|
|
|
// 2: U/S (386+)
|
|
|
|
// 1: R/W (386+)
|
|
|
|
// 0: P=1 (386+)
|
|
|
|
|
|
|
|
// Page Table Entry format when P=1 (4-Kbyte Page):
|
|
|
|
// ================================================
|
|
|
|
//
|
2004-12-14 01:26:36 +03:00
|
|
|
// 63..63: NX |
|
2004-10-21 22:20:40 +04:00
|
|
|
// 62..52: available | Long mode
|
2004-12-14 01:26:36 +03:00
|
|
|
// 51..32: page base address |
|
2001-04-10 05:04:59 +04:00
|
|
|
// 31..12: page base address
|
|
|
|
// 11.. 9: available
|
|
|
|
// 8: G (Pentium Pro+), 0=reserved otherwise
|
2004-10-21 22:20:40 +04:00
|
|
|
// 7: PAT
|
2001-04-10 05:04:59 +04:00
|
|
|
// 6: D (386+)
|
|
|
|
// 5: A (386+)
|
|
|
|
// 4: PCD (486+), 0=reserved otherwise
|
|
|
|
// 3: PWT (486+), 0=reserved otherwise
|
|
|
|
// 2: U/S (386+)
|
|
|
|
// 1: R/W (386+)
|
|
|
|
// 0: P=1 (386+)
|
|
|
|
|
|
|
|
// Page Directory/Table Entry Fields Defined:
|
|
|
|
// ==========================================
|
2004-10-21 22:20:40 +04:00
|
|
|
// NX: No Execute
|
|
|
|
// This bit controls the ability to execute code from all physical
|
|
|
|
// pages mapped by the table entry.
|
|
|
|
// 0: Code can be executed from the mapped physical pages
|
|
|
|
// 1: Code cannot be executed
|
|
|
|
// The NX bit can only be set when the no-execute page-protection
|
|
|
|
// feature is enabled by setting EFER.NXE=1, If EFER.NXE=0, the
|
|
|
|
// NX bit is treated as reserved. In this case, #PF occurs if the
|
|
|
|
// NX bit is not cleared to zero.
|
|
|
|
//
|
2001-04-10 05:04:59 +04:00
|
|
|
// G: Global flag
|
|
|
|
// Indiciates a global page when set. When a page is marked
|
|
|
|
// global and the PGE flag in CR4 is set, the page table or
|
|
|
|
// directory entry for the page is not invalidated in the TLB
|
|
|
|
// when CR3 is loaded or a task switch occurs. Only software
|
|
|
|
// clears and sets this flag. For page directory entries that
|
|
|
|
// point to page tables, this flag is ignored and the global
|
|
|
|
// characteristics of a page are set in the page table entries.
|
|
|
|
//
|
|
|
|
// PS: Page Size flag
|
|
|
|
// Only used in page directory entries. When PS=0, the page
|
|
|
|
// size is 4KBytes and the page directory entry points to a
|
|
|
|
// page table. When PS=1, the page size is 4MBytes for
|
|
|
|
// normal 32-bit addressing and 2MBytes if extended physical
|
2004-10-21 22:20:40 +04:00
|
|
|
// addressing.
|
|
|
|
//
|
|
|
|
// PAT: Page-Attribute Table
|
|
|
|
// This bit is only present in the lowest level of the page
|
|
|
|
// translation hierarchy. The PAT bit is the high-order bit
|
|
|
|
// of a 3-bit index into the PAT register. The other two
|
|
|
|
// bits involved in forming the index are the PCD and PWT
|
|
|
|
// bits.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// D: Dirty bit:
|
|
|
|
// Processor sets the Dirty bit in the 2nd-level page table before a
|
|
|
|
// write operation to an address mapped by that page table entry.
|
|
|
|
// Dirty bit in directory entries is undefined.
|
|
|
|
//
|
|
|
|
// A: Accessed bit:
|
|
|
|
// Processor sets the Accessed bits in both levels of page tables before
|
|
|
|
// a read/write operation to a page.
|
|
|
|
//
|
|
|
|
// PCD: Page level Cache Disable
|
|
|
|
// Controls caching of individual pages or page tables.
|
|
|
|
// This allows a per-page based mechanism to disable caching, for
|
|
|
|
// those pages which contained memory mapped IO, or otherwise
|
|
|
|
// should not be cached. Processor ignores this flag if paging
|
|
|
|
// is not used (CR0.PG=0) or the cache disable bit is set (CR0.CD=1).
|
|
|
|
// Values:
|
|
|
|
// 0: page or page table can be cached
|
|
|
|
// 1: page or page table is not cached (prevented)
|
|
|
|
//
|
|
|
|
// PWT: Page level Write Through
|
|
|
|
// Controls the write-through or write-back caching policy of individual
|
|
|
|
// pages or page tables. Processor ignores this flag if paging
|
|
|
|
// is not used (CR0.PG=0) or the cache disable bit is set (CR0.CD=1).
|
|
|
|
// Values:
|
|
|
|
// 0: write-back caching
|
|
|
|
// 1: write-through caching
|
|
|
|
//
|
|
|
|
// U/S: User/Supervisor level
|
|
|
|
// 0: Supervisor level - for the OS, drivers, etc.
|
|
|
|
// 1: User level - application code and data
|
|
|
|
//
|
|
|
|
// R/W: Read/Write access
|
|
|
|
// 0: read-only access
|
|
|
|
// 1: read/write access
|
|
|
|
//
|
|
|
|
// P: Present
|
|
|
|
// 0: Not present
|
|
|
|
// 1: Present
|
|
|
|
// ==========================================
|
|
|
|
|
|
|
|
|
|
|
|
// Combined page directory/page table protection:
|
|
|
|
// ==============================================
|
|
|
|
// There is one column for the combined effect on a 386
|
|
|
|
// and one column for the combined effect on a 486+ CPU.
|
|
|
|
//
|
|
|
|
// +----------------+-----------------+----------------+----------------+
|
|
|
|
// | Page Directory| Page Table | Combined 386 | Combined 486+ |
|
|
|
|
// |Privilege Type | Privilege Type | Privilege Type| Privilege Type|
|
|
|
|
// |----------------+-----------------+----------------+----------------|
|
|
|
|
// |User R | User R | User R | User R |
|
|
|
|
// |User R | User RW | User R | User R |
|
|
|
|
// |User RW | User R | User R | User R |
|
|
|
|
// |User RW | User RW | User RW | User RW |
|
|
|
|
// |User R | Supervisor R | User R | Supervisor RW |
|
|
|
|
// |User R | Supervisor RW | User R | Supervisor RW |
|
|
|
|
// |User RW | Supervisor R | User R | Supervisor RW |
|
|
|
|
// |User RW | Supervisor RW | User RW | Supervisor RW |
|
|
|
|
// |Supervisor R | User R | User R | Supervisor RW |
|
|
|
|
// |Supervisor R | User RW | User R | Supervisor RW |
|
|
|
|
// |Supervisor RW | User R | User R | Supervisor RW |
|
|
|
|
// |Supervisor RW | User RW | User RW | Supervisor RW |
|
|
|
|
// |Supervisor R | Supervisor R | Supervisor RW | Supervisor RW |
|
|
|
|
// |Supervisor R | Supervisor RW | Supervisor RW | Supervisor RW |
|
|
|
|
// |Supervisor RW | Supervisor R | Supervisor RW | Supervisor RW |
|
|
|
|
// |Supervisor RW | Supervisor RW | Supervisor RW | Supervisor RW |
|
|
|
|
// +----------------+-----------------+----------------+----------------+
|
|
|
|
|
|
|
|
// Page Fault Error Code Format:
|
|
|
|
// =============================
|
|
|
|
//
|
|
|
|
// bits 31..4: Reserved
|
|
|
|
// bit 3: RSVD (Pentium Pro+)
|
|
|
|
// 0: fault caused by reserved bits set to 1 in a page directory
|
|
|
|
// when the PSE or PAE flags in CR4 are set to 1
|
|
|
|
// 1: fault was not caused by reserved bit violation
|
|
|
|
// bit 2: U/S (386+)
|
|
|
|
// 0: fault originated when in supervior mode
|
|
|
|
// 1: fault originated when in user mode
|
|
|
|
// bit 1: R/W (386+)
|
|
|
|
// 0: access causing the fault was a read
|
|
|
|
// 1: access causing the fault was a write
|
|
|
|
// bit 0: P (386+)
|
|
|
|
// 0: fault caused by a nonpresent page
|
|
|
|
// 1: fault caused by a page level protection violation
|
|
|
|
|
|
|
|
|
|
|
|
// Some paging related notes:
|
|
|
|
// ==========================
|
|
|
|
//
|
|
|
|
// - When the processor is running in supervisor level, all pages are both
|
|
|
|
// readable and writable (write-protect ignored). When running at user
|
|
|
|
// level, only pages which belong to the user level are accessible;
|
|
|
|
// read/write & read-only are readable, read/write are writable.
|
|
|
|
//
|
|
|
|
// - If the Present bit is 0 in either level of page table, an
|
|
|
|
// access which uses these entries will generate a page fault.
|
|
|
|
//
|
|
|
|
// - (A)ccess bit is used to report read or write access to a page
|
|
|
|
// or 2nd level page table.
|
|
|
|
//
|
|
|
|
// - (D)irty bit is used to report write access to a page.
|
|
|
|
//
|
|
|
|
// - Processor running at CPL=0,1,2 maps to U/S=0
|
|
|
|
// Processor running at CPL=3 maps to U/S=1
|
|
|
|
//
|
|
|
|
// - Pentium+ processors have separate TLB's for data and instruction caches
|
|
|
|
// - Pentium Pro+ processors maintain separate 4K and 4M TLBs.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_SUPPORT_PAGING
|
|
|
|
|
|
|
|
#define BX_INVALID_TLB_ENTRY 0xffffffff
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2002-09-06 23:21:55 +04:00
|
|
|
#if BX_USE_QUICK_TLB_INVALIDATE
|
2002-09-06 18:58:56 +04:00
|
|
|
#define BX_MAX_TLB_INVALIDATE 0xffe
|
2002-09-06 23:21:55 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
#define BX_USE_TLB_GENERATION 1
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#if BX_CPU_LEVEL >= 4
|
|
|
|
# define BX_PRIV_CHECK_SIZE 32
|
|
|
|
#else
|
|
|
|
# define BX_PRIV_CHECK_SIZE 16
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// The 'priv_check' array is used to decide if the current access
|
|
|
|
// has the proper paging permissions. An index is formed, based
|
|
|
|
// on parameters such as the access type and level, the write protect
|
|
|
|
// flag and values cached in the TLB. The format of the index into this
|
|
|
|
// array is:
|
|
|
|
//
|
|
|
|
// |4 |3 |2 |1 |0 |
|
|
|
|
// |wp|us|us|rw|rw|
|
|
|
|
// | | | | |
|
|
|
|
// | | | | +---> r/w of current access
|
|
|
|
// | | +--+------> u/s,r/w combined of page dir & table (cached)
|
|
|
|
// | +------------> u/s of current access
|
|
|
|
// +---------------> Current CR0.wp value
|
2002-09-05 07:09:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
// Each entry in the TLB cache has 3 entries:
|
|
|
|
// lpf: Linear Page Frame (page aligned linear address of page)
|
2002-09-06 18:58:56 +04:00
|
|
|
// bits 32..12 Linear page frame.
|
|
|
|
// bits 11..0 Invalidate index.
|
2002-09-05 07:09:59 +04:00
|
|
|
// ppf: Physical Page Frame (page aligned phy address of page)
|
|
|
|
// accessBits:
|
|
|
|
// bits 32..11: Host Page Frame address used for direct access to
|
|
|
|
// the mem.vector[] space allocated for the guest physical
|
|
|
|
// memory. If this is zero, it means that a pointer
|
|
|
|
// to the host space could not be generated, likely because
|
|
|
|
// that page of memory is not standard memory (it might
|
|
|
|
// be memory mapped IO, ROM, etc).
|
|
|
|
// bits 10..4: (currently unused)
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
2002-09-05 07:09:59 +04:00
|
|
|
// The following 4 bits are used for a very efficient permissions
|
|
|
|
// check. The goal is to be able, using only the current privilege
|
|
|
|
// level and access type, to determine if the page tables allow the
|
|
|
|
// access to occur or at least should rewalk the page tables. On
|
|
|
|
// the first read access, permissions are set to only read, so a
|
|
|
|
// rewalk is necessary when a subsequent write fails the tests.
|
|
|
|
// This allows for the dirty bit to be set properly, but for the
|
|
|
|
// test to be efficient. Note that the CR0.WP flag is not present.
|
|
|
|
// The values in the following flags is based on the current CR0.WP
|
|
|
|
// value, necessitating a TLB flush when CR0.WP changes.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
2002-09-05 07:09:59 +04:00
|
|
|
// The test is:
|
|
|
|
// OK = 1 << ( (W<<1) | U ) [W:1=write, 0=read, U:1=CPL3,0=CPL0-2]
|
|
|
|
//
|
|
|
|
// Thus for reads, it's simply:
|
|
|
|
// OK = 1 << ( U )
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
2002-09-10 07:52:32 +04:00
|
|
|
// bit 8: Page is a global page.
|
2002-09-05 07:09:59 +04:00
|
|
|
// bit 3: a Write from User privilege is OK
|
|
|
|
// bit 2: a Write from System privilege is OK
|
|
|
|
// bit 1: a Read from User privilege is OK
|
|
|
|
// bit 0: a Read from System privilege is OK
|
2001-04-10 05:04:59 +04:00
|
|
|
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
#define WriteUserOK 0x08
|
2002-09-05 07:09:59 +04:00
|
|
|
#define WriteSysOK 0x04
|
|
|
|
#define ReadUserOK 0x02
|
|
|
|
#define ReadSysOK 0x01
|
|
|
|
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
|
|
|
|
|
2002-10-25 16:36:44 +04:00
|
|
|
#ifdef __GNUC__
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#warning "Move priv_check to CPU fields, or init.cc"
|
2002-09-03 19:56:24 +04:00
|
|
|
#endif
|
|
|
|
|
2002-09-04 12:59:13 +04:00
|
|
|
static unsigned priv_check[BX_PRIV_CHECK_SIZE];
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
#define PAGE_DIRECTORY_NX_BIT (BX_CONST64(0x8000000000000000))
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
// === TLB Instrumentation section ==============================
|
|
|
|
|
|
|
|
// Note: this is an approximation of what Peter Tattam had.
|
|
|
|
|
|
|
|
#define InstrumentTLB 0
|
|
|
|
|
|
|
|
#if InstrumentTLB
|
|
|
|
static unsigned tlbLookups=0;
|
|
|
|
static unsigned tlbMisses=0;
|
|
|
|
static unsigned tlbGlobalFlushes=0;
|
|
|
|
static unsigned tlbNonGlobalFlushes=0;
|
|
|
|
static unsigned tlbEntryFlushes=0;
|
|
|
|
static unsigned tlbEntryInvlpg=0;
|
|
|
|
|
|
|
|
#define InstrTLB_StatsMask 0xfffff
|
|
|
|
|
|
|
|
#define InstrTLB_Stats() {\
|
|
|
|
if ((tlbLookups & InstrTLB_StatsMask) == 0) { \
|
|
|
|
BX_INFO(("TLB lookup:%8d miss:%8d %6.2f%% flush:%8d %6.2f%%", \
|
|
|
|
tlbLookups, \
|
|
|
|
tlbMisses, \
|
|
|
|
tlbMisses * 100.0 / tlbLookups, \
|
|
|
|
(tlbGlobalFlushes+tlbNonGlobalFlushes), \
|
|
|
|
(tlbGlobalFlushes+tlbNonGlobalFlushes) * 100.0 / tlbLookups \
|
|
|
|
)); \
|
|
|
|
tlbLookups = tlbMisses = tlbGlobalFlushes = tlbNonGlobalFlushes = 0; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define InstrTLB_Increment(v) (v)++
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define InstrTLB_Stats()
|
|
|
|
#define InstrTLB_Increment(v)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
void BX_CPP_AttrRegparmN(2)
|
2002-09-07 09:21:28 +04:00
|
|
|
BX_CPU_C::pagingCR0Changed(Bit32u oldCR0, Bit32u newCR0)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-07 09:21:28 +04:00
|
|
|
// Modification of PG,PE flushes TLB cache according to docs.
|
|
|
|
// Additionally, the TLB strategy is based on the current value of
|
|
|
|
// WP, so if that changes we must also flush the TLB.
|
|
|
|
if ( (oldCR0 & 0x80010001) != (newCR0 & 0x80010001) )
|
|
|
|
TLB_flush(1); // 1 = Flush Global entries also.
|
|
|
|
|
|
|
|
if (bx_dbg.paging)
|
|
|
|
BX_INFO(("pagingCR0Changed(0x%x -> 0x%x):", oldCR0, newCR0));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
void BX_CPP_AttrRegparmN(2)
|
2002-09-07 09:21:28 +04:00
|
|
|
BX_CPU_C::pagingCR4Changed(Bit32u oldCR4, Bit32u newCR4)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-07 09:21:28 +04:00
|
|
|
// Modification of PGE,PAE,PSE flushes TLB cache according to docs.
|
|
|
|
if ( (oldCR4 & 0x000000b0) != (newCR4 & 0x000000b0) )
|
|
|
|
TLB_flush(1); // 1 = Flush Global entries also.
|
|
|
|
|
|
|
|
if (bx_dbg.paging)
|
|
|
|
BX_INFO(("pagingCR4Changed(0x%x -> 0x%x):", oldCR4, newCR4));
|
2005-04-14 20:44:40 +04:00
|
|
|
|
|
|
|
#if BX_SupportPAE
|
|
|
|
if ( (oldCR4 & 0x00000020) != (newCR4 & 0x00000020) ) {
|
|
|
|
if (BX_CPU_THIS_PTR cr4.get_PAE())
|
|
|
|
BX_CPU_THIS_PTR cr3_masked = BX_CPU_THIS_PTR cr3 & 0xffffffe0;
|
|
|
|
else
|
|
|
|
BX_CPU_THIS_PTR cr3_masked = BX_CPU_THIS_PTR cr3 & 0xfffff000;
|
|
|
|
}
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1)
|
2002-09-17 00:23:38 +04:00
|
|
|
BX_CPU_C::CR3_change(bx_address value)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
if (bx_dbg.paging) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("CR3_change(): flush TLB cache"));
|
2002-09-17 00:23:38 +04:00
|
|
|
BX_INFO(("Page Directory Base %08x", (unsigned) value));
|
2005-03-03 23:24:52 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// flush TLB even if value does not change
|
2002-09-07 09:21:28 +04:00
|
|
|
TLB_flush(0); // 0 = Don't flush Global entries.
|
2002-09-17 00:23:38 +04:00
|
|
|
BX_CPU_THIS_PTR cr3 = value;
|
2004-06-18 18:11:11 +04:00
|
|
|
#if BX_SupportPAE
|
|
|
|
if (BX_CPU_THIS_PTR cr4.get_PAE())
|
|
|
|
BX_CPU_THIS_PTR cr3_masked = value & 0xffffffe0;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
BX_CPU_THIS_PTR cr3_masked = value & 0xfffff000;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
void
|
|
|
|
BX_CPU_C::pagingA20Changed(void)
|
|
|
|
{
|
2002-09-07 09:21:28 +04:00
|
|
|
TLB_flush(1); // 1 = Flush Global entries too.
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
}
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
void
|
|
|
|
BX_CPU_C::TLB_init(void)
|
|
|
|
{
|
|
|
|
// Called to initialize the TLB upon startup.
|
|
|
|
// Unconditional initialization of all TLB entries.
|
|
|
|
|
|
|
|
#if BX_USE_TLB
|
|
|
|
unsigned i;
|
|
|
|
unsigned wp, us_combined, rw_combined, us_current, rw_current;
|
|
|
|
|
2004-10-21 22:20:40 +04:00
|
|
|
for (i=0; i<BX_TLB_SIZE; i++)
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[i].lpf = BX_INVALID_TLB_ENTRY;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Setup privilege check matrix.
|
|
|
|
//
|
|
|
|
|
|
|
|
for (i=0; i<BX_PRIV_CHECK_SIZE; i++) {
|
|
|
|
wp = (i & 0x10) >> 4;
|
|
|
|
us_current = (i & 0x08) >> 3;
|
|
|
|
us_combined = (i & 0x04) >> 2;
|
|
|
|
rw_combined = (i & 0x02) >> 1;
|
|
|
|
rw_current = (i & 0x01) >> 0;
|
|
|
|
if (wp) { // when write protect on
|
|
|
|
if (us_current > us_combined) // user access, supervisor page
|
|
|
|
priv_check[i] = 0;
|
|
|
|
else if (rw_current > rw_combined) // RW access, RO page
|
|
|
|
priv_check[i] = 0;
|
|
|
|
else
|
|
|
|
priv_check[i] = 1;
|
2005-03-03 23:24:52 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else { // when write protect off
|
|
|
|
if (us_current == 0) // Supervisor mode access, anything goes
|
|
|
|
priv_check[i] = 1;
|
|
|
|
else {
|
|
|
|
// user mode access
|
|
|
|
if (us_combined == 0) // user access, supervisor Page
|
|
|
|
priv_check[i] = 0;
|
|
|
|
else if (rw_current > rw_combined) // RW access, RO page
|
|
|
|
priv_check[i] = 0;
|
|
|
|
else
|
|
|
|
priv_check[i] = 1;
|
|
|
|
}
|
|
|
|
}
|
2005-03-03 23:24:52 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-09-06 23:21:55 +04:00
|
|
|
#if BX_USE_QUICK_TLB_INVALIDATE
|
2002-09-06 18:58:56 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.tlb_invalidate = BX_MAX_TLB_INVALIDATE;
|
2002-09-06 23:21:55 +04:00
|
|
|
#endif
|
2002-09-06 18:58:56 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif // #if BX_USE_TLB
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-25 15:44:41 +04:00
|
|
|
BX_CPU_C::TLB_flush(bx_bool invalidateGlobal)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-17 00:23:38 +04:00
|
|
|
#if InstrumentTLB
|
|
|
|
if (invalidateGlobal)
|
|
|
|
InstrTLB_Increment(tlbGlobalFlushes);
|
|
|
|
else
|
|
|
|
InstrTLB_Increment(tlbNonGlobalFlushes);
|
2002-09-06 23:21:55 +04:00
|
|
|
#endif
|
2002-09-06 18:58:56 +04:00
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
#if BX_USE_TLB
|
|
|
|
for (unsigned i=0; i<BX_TLB_SIZE; i++) {
|
|
|
|
// To be conscious of the native cache line usage, only
|
|
|
|
// write to (invalidate) entries which need it.
|
|
|
|
if (BX_CPU_THIS_PTR TLB.entry[i].lpf != BX_INVALID_TLB_ENTRY) {
|
2002-09-10 07:52:32 +04:00
|
|
|
#if BX_SupportGlobalPages
|
2002-09-17 00:23:38 +04:00
|
|
|
if ( invalidateGlobal ||
|
2002-09-17 01:10:31 +04:00
|
|
|
!(BX_CPU_THIS_PTR TLB.entry[i].accessBits & 0x100) )
|
2002-09-10 07:52:32 +04:00
|
|
|
#endif
|
2005-03-03 23:24:52 +03:00
|
|
|
{
|
2002-09-17 00:23:38 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[i].lpf = BX_INVALID_TLB_ENTRY;
|
|
|
|
InstrTLB_Increment(tlbEntryFlushes); // A TLB entry flush occurred.
|
2002-09-07 09:21:28 +04:00
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
}
|
2005-03-03 23:24:52 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif // #if BX_USE_TLB
|
|
|
|
}
|
|
|
|
|
2004-10-06 00:25:06 +04:00
|
|
|
void BX_CPU_C::INVLPG(bxInstruction_c* i)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
2002-09-17 00:23:38 +04:00
|
|
|
bx_address laddr;
|
2002-09-07 09:21:28 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
invalidate_prefetch_q();
|
|
|
|
|
|
|
|
// Operand must not be a register
|
2002-09-20 07:52:59 +04:00
|
|
|
if (i->modC0()) {
|
2002-10-08 18:43:18 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2004-10-06 00:25:06 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Opcode 0F 01:
|
|
|
|
//
|
|
|
|
|
|
|
|
// ----------------------------------------------------
|
|
|
|
// MOD REG RM | non 64 bit mode | 64 bit mode
|
|
|
|
// ----------------------------------------------------
|
|
|
|
// MOD <> 11 7 --- | INVLPG | INVLPG
|
|
|
|
// MOD == 11 7 0 | #UD | SWAPGS
|
|
|
|
// MOD == 11 7 1-7 | #UD | #UD
|
|
|
|
|
2002-10-08 18:43:18 +04:00
|
|
|
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) {
|
|
|
|
if ((i->rm() == 0) && (i->nnn() == 7)) {
|
|
|
|
BX_CPU_THIS_PTR SWAPGS(i);
|
|
|
|
return;
|
|
|
|
}
|
2005-03-03 23:24:52 +03:00
|
|
|
}
|
2004-10-06 00:25:06 +04:00
|
|
|
|
2002-10-08 18:43:18 +04:00
|
|
|
#endif
|
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
BX_INFO(("INVLPG: op is a register"));
|
2001-04-10 05:04:59 +04:00
|
|
|
UndefinedOpcode(i);
|
2004-10-06 00:25:06 +04:00
|
|
|
}
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
// Can not be executed in v8086 mode
|
|
|
|
if (v8086_mode())
|
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
|
|
|
|
|
|
|
// Protected instruction: CPL0 only
|
|
|
|
if (BX_CPU_THIS_PTR cr0.pe) {
|
|
|
|
if (CPL!=0) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("INVLPG: CPL!=0"));
|
2001-04-10 05:04:59 +04:00
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
|
|
|
}
|
2005-03-03 23:24:52 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_USE_TLB
|
2005-02-28 21:56:05 +03:00
|
|
|
laddr = BX_CPU_THIS_PTR get_segment_base(i->seg()) + RMAddr(i);
|
2004-10-21 22:20:40 +04:00
|
|
|
Bit32u TLB_index = BX_TLB_INDEX_OF(laddr);
|
2002-09-07 09:21:28 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[TLB_index].lpf = BX_INVALID_TLB_ENTRY;
|
2002-09-17 00:23:38 +04:00
|
|
|
InstrTLB_Increment(tlbEntryInvlpg);
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif // BX_USE_TLB
|
2004-10-06 00:25:06 +04:00
|
|
|
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_TLB_CNTRL(BX_CPU_ID, BX_INSTR_INVLPG, 0);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#else
|
|
|
|
// not supported on < 486
|
|
|
|
UndefinedOpcode(i);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Translate a linear address to a physical address, for
|
|
|
|
// a data access (D)
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
Bit32u BX_CPP_AttrRegparmN(3)
|
2004-12-17 01:21:35 +03:00
|
|
|
BX_CPU_C::translate_linear(bx_address laddr, unsigned pl, unsigned rw, unsigned access_type)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-10-21 22:20:40 +04:00
|
|
|
bx_address lpf;
|
2005-03-03 23:24:52 +03:00
|
|
|
Bit32u accessBits, combined_access = 0, error_code = 0;
|
2002-09-04 12:59:13 +04:00
|
|
|
unsigned priv_index;
|
2004-10-21 22:20:40 +04:00
|
|
|
#if BX_USE_TLB
|
2004-12-14 01:26:36 +03:00
|
|
|
Bit32u TLB_index;
|
2004-10-21 22:20:40 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
InstrTLB_Increment(tlbLookups);
|
|
|
|
InstrTLB_Stats();
|
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
// note - we assume physical memory < 4gig so for brevity & speed, we'll use
|
|
|
|
// 32 bit entries although cr3 is expanded to 64 bits.
|
|
|
|
Bit32u ppf, poffset, paddress;
|
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
bx_bool isWrite = (rw >= BX_WRITE); // write or r-m-w
|
2004-10-30 01:15:48 +04:00
|
|
|
|
2002-09-17 01:55:57 +04:00
|
|
|
#if BX_SupportPAE
|
2004-12-14 01:26:36 +03:00
|
|
|
if (BX_CPU_THIS_PTR cr4.get_PAE())
|
|
|
|
{
|
|
|
|
bx_address pde, pdp;
|
|
|
|
Bit32u pde_addr;
|
|
|
|
Bit32u pdp_addr;
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
lpf = laddr & BX_CONST64(0xfffffffffffff000); // linear page frame
|
|
|
|
poffset = laddr & 0x00000fff; // physical offset
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2004-10-21 22:20:40 +04:00
|
|
|
#if BX_USE_TLB
|
|
|
|
TLB_index = BX_TLB_INDEX_OF(lpf);
|
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR TLB.entry[TLB_index].lpf == BX_TLB_LPF_VALUE(lpf))
|
|
|
|
{
|
2002-09-17 00:23:38 +04:00
|
|
|
paddress = BX_CPU_THIS_PTR TLB.entry[TLB_index].ppf | poffset;
|
|
|
|
accessBits = BX_CPU_THIS_PTR TLB.entry[TLB_index].accessBits;
|
2004-10-21 22:20:40 +04:00
|
|
|
|
|
|
|
if (accessBits & (1 << ((isWrite<<1) | pl)))
|
2002-09-17 00:23:38 +04:00
|
|
|
return(paddress);
|
|
|
|
|
|
|
|
// The current access does not have permission according to the info
|
|
|
|
// in our TLB cache entry. Re-walk the page tables, in case there is
|
|
|
|
// updated information in the memory image, and let the long path code
|
|
|
|
// generate an exception if one is warranted.
|
2004-10-21 22:20:40 +04:00
|
|
|
}
|
|
|
|
#endif
|
2002-09-17 00:23:38 +04:00
|
|
|
|
|
|
|
InstrTLB_Increment(tlbMisses);
|
|
|
|
|
2002-09-17 01:55:57 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-12-14 01:26:36 +03:00
|
|
|
if (BX_CPU_THIS_PTR msr.lma)
|
|
|
|
{
|
|
|
|
bx_address pml4;
|
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
// Get PML4 entry
|
2004-12-14 01:26:36 +03:00
|
|
|
Bit32u pml4_addr = BX_CPU_THIS_PTR cr3_masked |
|
2002-09-17 00:23:38 +04:00
|
|
|
((laddr & BX_CONST64(0x0000ff8000000000)) >> 36);
|
2004-12-14 01:26:36 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, pml4_addr, 8, &pml4);
|
2005-01-20 22:37:43 +03:00
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
if ( !(pml4 & 0x01) ) {
|
2004-12-17 01:21:35 +03:00
|
|
|
goto page_fault_not_present; // PML4 Entry NOT present
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2005-01-20 22:37:43 +03:00
|
|
|
if (pml4 & PAGE_DIRECTORY_NX_BIT) {
|
|
|
|
if (! BX_CPU_THIS_PTR msr.nxe)
|
|
|
|
goto page_fault_reserved;
|
|
|
|
else if (access_type == CODE_ACCESS)
|
|
|
|
goto page_fault_access;
|
|
|
|
}
|
2004-12-17 01:21:35 +03:00
|
|
|
if ( !(pml4 & 0x20) )
|
|
|
|
{
|
2002-09-17 00:23:38 +04:00
|
|
|
pml4 |= 0x20;
|
2004-12-14 01:26:36 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pml4_addr, 8, &pml4);
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
|
|
|
|
// Get PDP entry
|
|
|
|
pdp_addr = (pml4 & 0xfffff000) |
|
|
|
|
((laddr & BX_CONST64(0x0000007fc0000000)) >> 27);
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2002-09-17 01:55:57 +04:00
|
|
|
else
|
|
|
|
#endif
|
2004-10-30 01:15:48 +04:00
|
|
|
{
|
2004-12-14 01:26:36 +03:00
|
|
|
pdp_addr = BX_CPU_THIS_PTR cr3_masked | ((laddr & 0xc0000000) >> 27);
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, pdp_addr, sizeof(bx_address), &pdp);
|
2005-01-20 22:37:43 +03:00
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
if ( !(pdp & 0x01) ) {
|
2004-12-17 01:21:35 +03:00
|
|
|
goto page_fault_not_present; // PDP Entry NOT present
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2005-01-20 22:37:43 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (BX_CPU_THIS_PTR msr.lma)
|
|
|
|
{
|
|
|
|
if (pdp & PAGE_DIRECTORY_NX_BIT) {
|
|
|
|
if (! BX_CPU_THIS_PTR msr.nxe)
|
|
|
|
goto page_fault_reserved;
|
|
|
|
else if (access_type == CODE_ACCESS)
|
|
|
|
goto page_fault_access;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2002-09-17 00:23:38 +04:00
|
|
|
if ( !(pdp & 0x20) ) {
|
|
|
|
pdp |= 0x20;
|
2004-12-14 01:26:36 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pdp_addr, sizeof(bx_address), &pdp);
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
|
|
|
|
// Get page dir entry
|
2004-12-14 01:26:36 +03:00
|
|
|
pde_addr = (pdp & 0xfffff000) | ((laddr & 0x3fe00000) >> 18);
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, pde_addr, sizeof(bx_address), &pde);
|
2005-01-20 22:37:43 +03:00
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
if ( !(pde & 0x01) ) {
|
2004-12-17 01:21:35 +03:00
|
|
|
goto page_fault_not_present; // Page Directory Entry NOT present
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2005-01-20 22:37:43 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (pde & PAGE_DIRECTORY_NX_BIT) {
|
|
|
|
if (! BX_CPU_THIS_PTR msr.nxe)
|
|
|
|
goto page_fault_reserved;
|
|
|
|
else if (access_type == CODE_ACCESS)
|
|
|
|
goto page_fault_access;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
#if BX_SUPPORT_4MEG_PAGES
|
|
|
|
// (KPL) Weird. I would think the processor would consult CR.PSE?
|
|
|
|
// if ((pde & 0x80) && (BX_CPU_THIS_PTR cr4.get_PSE())) {}
|
|
|
|
if (pde & 0x80) {
|
|
|
|
// 4M pages are enabled, and this is a 4Meg page.
|
|
|
|
|
|
|
|
// Combined access is just access from the pde (no pte involved).
|
2004-12-14 01:26:36 +03:00
|
|
|
combined_access = pde & 0x06; // U/S and R/W
|
2002-09-17 00:23:38 +04:00
|
|
|
// Make up the physical page frame address.
|
|
|
|
ppf = (pde & 0xffe00000) | (laddr & 0x001ff000);
|
|
|
|
|
|
|
|
#if BX_SupportGlobalPages
|
2004-12-14 01:26:36 +03:00
|
|
|
if (BX_CPU_THIS_PTR cr4.get_PGE()) { // PGE==1
|
|
|
|
combined_access |= (pde & 0x100); // G
|
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
priv_index =
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
|
|
|
(BX_CPU_THIS_PTR cr0.wp<<4) | // bit 4
|
|
|
|
#endif
|
|
|
|
(pl<<3) | // bit 3
|
|
|
|
(combined_access & 0x06) | // bit 2,1
|
|
|
|
isWrite; // bit 0
|
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
if (!priv_check[priv_index]) goto page_fault_access;
|
2002-09-17 00:23:38 +04:00
|
|
|
|
|
|
|
// Update PDE if A/D bits if needed.
|
2004-12-14 01:26:36 +03:00
|
|
|
if ( ((pde & 0x20)==0) || (isWrite && ((pde&0x40)==0)) )
|
|
|
|
{
|
2002-09-17 00:23:38 +04:00
|
|
|
pde |= (0x20 | (isWrite<<6)); // Update A and possibly D bits
|
2004-12-14 01:26:36 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pde_addr, sizeof(bx_address), &pde);
|
2002-09-17 00:23:38 +04:00
|
|
|
}
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
else
|
|
|
|
#endif
|
2004-10-30 01:15:48 +04:00
|
|
|
{ // 4k pages.
|
2004-12-14 01:26:36 +03:00
|
|
|
bx_address pte;
|
2002-09-17 00:23:38 +04:00
|
|
|
|
|
|
|
// Get page table entry
|
2004-12-14 01:26:36 +03:00
|
|
|
Bit32u pte_addr = (pde & 0xfffff000) | ((laddr & 0x001ff000) >> 9);
|
|
|
|
|
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, pte_addr, sizeof(bx_address), &pte);
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2005-01-20 22:37:43 +03:00
|
|
|
if ( !(pte & 0x01) ) {
|
|
|
|
goto page_fault_not_present;
|
|
|
|
}
|
2005-03-03 23:24:52 +03:00
|
|
|
|
2005-01-20 22:37:43 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2005-03-03 23:24:52 +03:00
|
|
|
if (pte & PAGE_DIRECTORY_NX_BIT) {
|
|
|
|
if (! BX_CPU_THIS_PTR msr.nxe)
|
|
|
|
goto page_fault_reserved;
|
|
|
|
else if (access_type == CODE_ACCESS)
|
|
|
|
goto page_fault_access;
|
|
|
|
}
|
2005-01-20 22:37:43 +03:00
|
|
|
#endif
|
|
|
|
|
2005-03-03 23:24:52 +03:00
|
|
|
combined_access = (pde & pte) & 0x06; // U/S and R/W
|
|
|
|
|
2002-09-17 00:23:38 +04:00
|
|
|
// Make up the physical page frame address.
|
|
|
|
ppf = pte & 0xfffff000;
|
|
|
|
|
|
|
|
#if BX_SupportGlobalPages
|
2004-12-14 01:26:36 +03:00
|
|
|
if (BX_CPU_THIS_PTR cr4.get_PGE()) { // PGE==1
|
|
|
|
combined_access |= (pte & 0x100); // G
|
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
priv_index =
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
|
|
|
(BX_CPU_THIS_PTR cr0.wp<<4) | // bit 4
|
|
|
|
#endif
|
|
|
|
(pl<<3) | // bit 3
|
|
|
|
(combined_access & 0x06) | // bit 2,1
|
|
|
|
isWrite; // bit 0
|
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
if (!priv_check[priv_index]) goto page_fault_access;
|
2002-09-17 00:23:38 +04:00
|
|
|
|
|
|
|
// Update PDE A bit if needed.
|
|
|
|
if ( (pde & 0x20)==0 ) {
|
|
|
|
pde |= 0x20; // Update A bit.
|
2004-12-14 01:26:36 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pde_addr, sizeof(bx_address), &pde);
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2002-09-17 00:23:38 +04:00
|
|
|
|
|
|
|
// Update PTE A/D bits if needed.
|
2004-10-30 01:15:48 +04:00
|
|
|
if (((pte & 0x20)==0) || (isWrite && ((pte&0x40)==0)))
|
|
|
|
{
|
2002-09-17 00:23:38 +04:00
|
|
|
pte |= (0x20 | (isWrite<<6)); // Update A and possibly D bits
|
2004-12-14 01:26:36 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pte_addr, sizeof(bx_address), &pte);
|
2002-09-17 00:23:38 +04:00
|
|
|
}
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2004-10-21 22:20:40 +04:00
|
|
|
}
|
2004-12-14 01:26:36 +03:00
|
|
|
else
|
2002-09-17 01:55:57 +04:00
|
|
|
#endif // #if BX_SupportPAE
|
2004-12-14 01:26:36 +03:00
|
|
|
{
|
|
|
|
// CR4.PAE==0 (and MSR.LMA==0)
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
lpf = laddr & 0xfffff000; // linear page frame
|
|
|
|
poffset = laddr & 0x00000fff; // physical offset
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-10-21 22:20:40 +04:00
|
|
|
#if BX_USE_TLB
|
2004-12-14 01:26:36 +03:00
|
|
|
TLB_index = BX_TLB_INDEX_OF(lpf);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
if (BX_CPU_THIS_PTR TLB.entry[TLB_index].lpf == BX_TLB_LPF_VALUE(lpf))
|
|
|
|
{
|
|
|
|
paddress = BX_CPU_THIS_PTR TLB.entry[TLB_index].ppf | poffset;
|
|
|
|
accessBits = BX_CPU_THIS_PTR TLB.entry[TLB_index].accessBits;
|
2005-03-03 23:24:52 +03:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
if (accessBits & (1 << ((isWrite<<1) | pl)))
|
|
|
|
return(paddress);
|
|
|
|
|
|
|
|
// The current access does not have permission according to the info
|
|
|
|
// in our TLB cache entry. Re-walk the page tables, in case there is
|
|
|
|
// updated information in the memory image, and let the long path code
|
|
|
|
// generate an exception if one is warranted.
|
|
|
|
}
|
2004-10-21 22:20:40 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
InstrTLB_Increment(tlbMisses);
|
|
|
|
|
|
|
|
Bit32u pde, pde_addr;
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
// Get page dir entry
|
|
|
|
pde_addr = BX_CPU_THIS_PTR cr3_masked | ((laddr & 0xffc00000) >> 20);
|
|
|
|
|
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, pde_addr, 4, &pde);
|
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
if ( !(pde & 0x01) ) {
|
|
|
|
goto page_fault_not_present; // Page Directory Entry NOT present
|
2004-12-14 01:26:36 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#if BX_SUPPORT_4MEG_PAGES
|
2004-12-14 01:26:36 +03:00
|
|
|
if ((pde & 0x80) && (BX_CPU_THIS_PTR cr4.get_PSE()))
|
|
|
|
{
|
|
|
|
// 4M pages are enabled, and this is a 4Meg page.
|
|
|
|
// Note: when the PSE and PAE flags in CR4 are set,
|
|
|
|
// the processor generates a PF if the reserved bits are not
|
|
|
|
// set to 0. (We don't handle PAE yet, just a note for
|
|
|
|
// the future).
|
|
|
|
|
|
|
|
// Combined access is just access from the pde (no pte involved).
|
2005-03-03 23:24:52 +03:00
|
|
|
combined_access = pde & 0x006; // {US,RW}
|
2004-12-14 01:26:36 +03:00
|
|
|
// make up the physical frame number
|
|
|
|
ppf = (pde & 0xFFC00000) | (laddr & 0x003FF000);
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2002-09-10 07:52:32 +04:00
|
|
|
#if BX_SupportGlobalPages
|
2004-12-14 01:26:36 +03:00
|
|
|
if (BX_CPU_THIS_PTR cr4.get_PGE()) { // PGE==1
|
|
|
|
combined_access |= pde & 0x100; // {G}
|
|
|
|
}
|
2002-09-10 07:52:32 +04:00
|
|
|
#endif
|
2002-06-19 19:49:07 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
priv_index =
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#if BX_CPU_LEVEL >= 4
|
2004-12-14 01:26:36 +03:00
|
|
|
(BX_CPU_THIS_PTR cr0.wp<<4) | // bit 4
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#endif
|
2004-12-14 01:26:36 +03:00
|
|
|
(pl<<3) | // bit 3
|
|
|
|
(combined_access & 0x06) | // bit 2,1
|
|
|
|
isWrite; // bit 0
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
if (!priv_check[priv_index]) goto page_fault_access;
|
2002-06-19 19:49:07 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
// Update PDE if A/D bits if needed.
|
|
|
|
if (((pde & 0x20)==0) || (isWrite && ((pde&0x40)==0)))
|
|
|
|
{
|
|
|
|
pde |= (0x20 | (isWrite<<6)); // Update A and possibly D bits
|
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pde_addr, 4, &pde);
|
|
|
|
}
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
}
|
2004-12-14 01:26:36 +03:00
|
|
|
else // Else normal 4Kbyte page...
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#endif
|
2004-12-14 01:26:36 +03:00
|
|
|
{
|
|
|
|
Bit32u pte, pte_addr;
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
|
|
|
#if (BX_CPU_LEVEL < 6)
|
2004-12-14 01:26:36 +03:00
|
|
|
// update PDE if A bit was not set before
|
|
|
|
if ( !(pde & 0x20) ) {
|
|
|
|
pde |= 0x20;
|
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pde_addr, 4, &pde);
|
|
|
|
}
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
// Get page table entry
|
|
|
|
pte_addr = (pde & 0xfffff000) | ((laddr & 0x003ff000) >> 10);
|
|
|
|
|
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, pte_addr, 4, &pte);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-01-20 22:37:43 +03:00
|
|
|
if ( !(pte & 0x01) ) {
|
|
|
|
goto page_fault_not_present; // Page Table Entry NOT present
|
|
|
|
}
|
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
// 386 and 486+ have different bahaviour for combining
|
|
|
|
// privilege from PDE and PTE.
|
2001-04-10 05:04:59 +04:00
|
|
|
#if BX_CPU_LEVEL == 3
|
2004-12-14 01:26:36 +03:00
|
|
|
combined_access = (pde | pte) & 0x04; // U/S
|
|
|
|
combined_access |= (pde & pte) & 0x02; // R/W
|
2001-04-10 05:04:59 +04:00
|
|
|
#else // 486+
|
2004-12-14 01:26:36 +03:00
|
|
|
combined_access = (pde & pte) & 0x06; // U/S and R/W
|
2002-09-10 07:52:32 +04:00
|
|
|
#if BX_SupportGlobalPages
|
2004-12-14 01:26:36 +03:00
|
|
|
if (BX_CPU_THIS_PTR cr4.get_PGE()) {
|
|
|
|
combined_access |= (pte & 0x100); // G
|
|
|
|
}
|
2002-09-10 07:52:32 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
// Make up the physical page frame address.
|
|
|
|
ppf = pte & 0xfffff000;
|
2002-09-17 00:23:38 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
priv_index =
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#if BX_CPU_LEVEL >= 4
|
2004-12-14 01:26:36 +03:00
|
|
|
(BX_CPU_THIS_PTR cr0.wp<<4) | // bit 4
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#endif
|
2004-12-14 01:26:36 +03:00
|
|
|
(pl<<3) | // bit 3
|
|
|
|
(combined_access & 0x06) | // bit 2,1
|
|
|
|
isWrite; // bit 0
|
2002-06-19 19:49:07 +04:00
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
if (!priv_check[priv_index]) goto page_fault_access;
|
2002-06-19 19:49:07 +04:00
|
|
|
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#if (BX_CPU_LEVEL >= 6)
|
2004-12-14 01:26:36 +03:00
|
|
|
// update PDE if A bit was not set before
|
|
|
|
if ( !(pde & 0x20) ) {
|
|
|
|
pde |= 0x20;
|
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pde_addr, 4, &pde);
|
|
|
|
}
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#endif
|
2002-06-19 19:49:07 +04:00
|
|
|
|
2004-12-14 01:26:36 +03:00
|
|
|
// Update PTE if A/D bits if needed.
|
|
|
|
if (((pte & 0x20)==0) || (isWrite && ((pte&0x40)==0)))
|
|
|
|
{
|
|
|
|
pte |= (0x20 | (isWrite<<6)); // Update A and possibly D bits
|
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, pte_addr, 4, &pte);
|
|
|
|
}
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
}
|
2004-10-30 01:15:48 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
// Calculate physical memory address and fill in TLB cache entry
|
|
|
|
paddress = ppf | poffset;
|
2004-10-21 22:20:40 +04:00
|
|
|
#if BX_USE_TLB
|
2002-09-06 23:21:55 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[TLB_index].lpf = BX_TLB_LPF_VALUE(lpf);
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[TLB_index].ppf = ppf;
|
2004-10-21 22:20:40 +04:00
|
|
|
#endif
|
2002-09-04 12:59:13 +04:00
|
|
|
|
|
|
|
// b3: Write User OK
|
2005-03-03 23:24:52 +03:00
|
|
|
// b2: Write Sys OK
|
|
|
|
// b1: Read User OK
|
|
|
|
// b0: Read Sys OK
|
2002-09-04 12:59:13 +04:00
|
|
|
if ( combined_access & 4 ) { // User
|
2004-12-17 01:21:35 +03:00
|
|
|
accessBits = 0x3; // User priv; read from {user,sys} OK.
|
2005-03-03 23:24:52 +03:00
|
|
|
if ( isWrite ) // Current operation is a write (Dirty bit updated)
|
|
|
|
{
|
|
|
|
if (combined_access & 2) {
|
|
|
|
accessBits |= 0x8; // R/W access from {user,sys} OK.
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
accessBits |= 0x4; // read only page, only {sys} write allowed
|
|
|
|
}
|
2002-09-04 12:59:13 +04:00
|
|
|
}
|
2004-12-14 01:26:36 +03:00
|
|
|
}
|
2002-09-04 12:59:13 +04:00
|
|
|
else { // System
|
2004-12-17 01:21:35 +03:00
|
|
|
accessBits = 0x1; // System priv; read from {sys} OK.
|
|
|
|
if ( isWrite ) { // Current operation is a write (Dirty bit updated)
|
2005-03-03 23:24:52 +03:00
|
|
|
accessBits |= 0x4; // write from {sys} OK.
|
2002-09-04 12:59:13 +04:00
|
|
|
}
|
2004-12-14 01:26:36 +03:00
|
|
|
}
|
2002-09-10 07:52:32 +04:00
|
|
|
#if BX_SupportGlobalPages
|
|
|
|
accessBits |= combined_access & 0x100; // Global bit
|
|
|
|
#endif
|
2004-10-21 22:20:40 +04:00
|
|
|
#if BX_USE_TLB
|
2002-09-04 12:59:13 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[TLB_index].accessBits = accessBits;
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
#if BX_SupportGuest2HostTLB
|
2004-12-14 01:26:36 +03:00
|
|
|
// Attempt to get a host pointer to this physical page. Put that
|
|
|
|
// pointer in the TLB cache. Note if the request is vetoed, NULL
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
// will be returned, and it's OK to OR zero in anyways.
|
2002-09-10 04:01:01 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[TLB_index].hostPageAddr =
|
2004-12-14 01:26:36 +03:00
|
|
|
(bx_hostpageaddr_t) BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(ppf), rw);
|
2004-10-21 22:20:40 +04:00
|
|
|
#endif
|
2002-09-05 08:56:11 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
return(paddress);
|
|
|
|
|
2005-01-19 23:48:51 +03:00
|
|
|
// error checking order - page not present, reserved bits, protection
|
2004-12-17 01:21:35 +03:00
|
|
|
#define ERROR_NOT_PRESENT 0x00
|
|
|
|
#define ERROR_PROTECTION 0x01
|
|
|
|
#define ERROR_RESERVED 0x08
|
2005-01-19 23:48:51 +03:00
|
|
|
#define ERROR_CODE_ACCESS 0x10
|
2004-12-17 01:21:35 +03:00
|
|
|
|
2005-02-28 21:56:05 +03:00
|
|
|
#if BX_SUPPORT_X86_64 // keep compiler happy
|
2004-12-17 01:21:35 +03:00
|
|
|
page_fault_reserved:
|
|
|
|
error_code |= ERROR_RESERVED; // RSVD = 1
|
2005-02-28 21:56:05 +03:00
|
|
|
#endif
|
2004-12-17 01:21:35 +03:00
|
|
|
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
page_fault_access:
|
2004-12-17 01:21:35 +03:00
|
|
|
error_code |= ERROR_PROTECTION; // P = 1
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
page_fault_not_present:
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
error_code |= (pl << 2) | (isWrite << 1);
|
2004-12-17 01:21:35 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (BX_CPU_THIS_PTR msr.nxe && (access_type == CODE_ACCESS))
|
2005-01-19 23:48:51 +03:00
|
|
|
error_code |= ERROR_CODE_ACCESS; // I/D = 1
|
2004-12-17 01:21:35 +03:00
|
|
|
#endif
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR cr2 = laddr;
|
Integrated patches for:
- Paging code rehash. You must now use --enable-4meg-pages to
use 4Meg pages, with the default of disabled, since we don't well
support 4Meg pages yet. Paging table walks model a real CPU
more closely now, and I fixed some bugs in the old logic.
- Segment check redundancy elimination. After a segment is loaded,
reads and writes are marked when a segment type check succeeds, and
they are skipped thereafter, when possible.
- Repeated IO and memory string copy acceleration. Only some variants
of instructions are available on all platforms, word and dword
variants only on x86 for the moment due to alignment and endian issues.
This is compiled in currently with no option - I should add a configure
option.
- Added a guest linear address to host TLB. Actually, I just stick
the host address (mem.vector[addr] address) in the upper 29 bits
of the field 'combined_access' since they are unused. Convenient
for now. I'm only storing page frame addresses. This was the
simplest for of such a TLB. We can likely enhance this. Also,
I only accelerated the normal read/write routines in access.cc.
Could also modify the read-modify-write versions too. You must
use --enable-guest2host-tlb, to try this out. Currently speeds
up Win95 boot time by about 3.5% for me. More ground to cover...
- Minor mods to CPUI/MOV_CdRd for CMOV.
- Integrated enhancements from Volker to getHostMemAddr() for PCI
being enabled.
2002-09-02 00:12:09 +04:00
|
|
|
// Invalidate TLB entry.
|
2004-10-21 22:20:40 +04:00
|
|
|
#if BX_USE_TLB
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[TLB_index].lpf = BX_INVALID_TLB_ENTRY;
|
2004-10-21 22:20:40 +04:00
|
|
|
#endif
|
2002-10-08 18:43:18 +04:00
|
|
|
#if BX_EXTERNAL_DEBUGGER
|
2002-11-04 08:27:26 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2003-02-26 05:37:08 +03:00
|
|
|
printf("page fault for address %08x%08x @ %08x%08x\n",
|
|
|
|
(Bit32u)(laddr >> 32),(Bit32u)(laddr & 0xffffffff),
|
|
|
|
(Bit32u)(RIP >> 32),(Bit32u)(RIP & 0xffffffff));
|
2002-11-04 08:27:26 +03:00
|
|
|
#else
|
2004-10-21 22:20:40 +04:00
|
|
|
printf("page fault for address %08x:%08x\n",
|
|
|
|
(Bit32u)(laddr >> 32),(Bit32u)(laddr & 0xffffffff));
|
2002-11-04 08:27:26 +03:00
|
|
|
#endif
|
2002-10-08 18:43:18 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
exception(BX_PF_EXCEPTION, error_code, 0);
|
|
|
|
return(0); // keep compiler happy
|
|
|
|
}
|
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
Bit32u BX_CPP_AttrRegparmN(3)
|
|
|
|
BX_CPU_C::dtranslate_linear(bx_address laddr, unsigned pl, unsigned rw)
|
|
|
|
{
|
|
|
|
return translate_linear(laddr, pl, rw, DATA_ACCESS);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
Bit32u BX_CPP_AttrRegparmN(2)
|
2002-09-17 00:23:38 +04:00
|
|
|
BX_CPU_C::itranslate_linear(bx_address laddr, unsigned pl)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-12-17 01:21:35 +03:00
|
|
|
return translate_linear(laddr, pl, BX_READ, CODE_ACCESS);
|
2002-09-17 00:23:38 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-10-03 08:53:53 +04:00
|
|
|
#if BX_DEBUGGER || BX_DISASM || BX_INSTRUMENTATION || BX_GDBSTUB
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-02-24 00:18:24 +03:00
|
|
|
void BX_CPU_C::dbg_xlate_linear2phy(bx_address laddr, Bit32u *phy, bx_bool *valid)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-02-16 21:58:48 +03:00
|
|
|
bx_address lpf, poffset, paddress;
|
|
|
|
Bit32u TLB_index;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR cr0.pg == 0) {
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
*phy = laddr;
|
2001-04-10 05:04:59 +04:00
|
|
|
*valid = 1;
|
|
|
|
return;
|
2004-12-17 01:21:35 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-02-16 21:58:48 +03:00
|
|
|
lpf = laddr & BX_CONST64(0xfffffffffffff000); // linear page frame
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
poffset = laddr & 0x00000fff; // physical offset
|
2001-04-10 05:04:59 +04:00
|
|
|
TLB_index = BX_TLB_INDEX_OF(lpf);
|
|
|
|
|
|
|
|
// see if page is in the TLB first
|
2004-10-21 22:20:40 +04:00
|
|
|
#if BX_USE_TLB
|
2002-09-06 23:21:55 +04:00
|
|
|
if (BX_CPU_THIS_PTR TLB.entry[TLB_index].lpf == BX_TLB_LPF_VALUE(lpf)) {
|
2005-02-16 21:58:48 +03:00
|
|
|
paddress = BX_CPU_THIS_PTR TLB.entry[TLB_index].ppf | poffset;
|
2001-04-10 05:04:59 +04:00
|
|
|
*phy = paddress;
|
|
|
|
*valid = 1;
|
|
|
|
return;
|
2004-10-21 22:20:40 +04:00
|
|
|
}
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-02-16 21:58:48 +03:00
|
|
|
if (BX_CPU_THIS_PTR cr4.get_PAE()) {
|
|
|
|
Bit64u pt_address;
|
|
|
|
int levels = 3;
|
2005-02-24 00:18:24 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2005-02-16 21:58:48 +03:00
|
|
|
if (BX_CPU_THIS_PTR msr.lme)
|
|
|
|
levels = 4;
|
|
|
|
#endif
|
|
|
|
pt_address = BX_CPU_THIS_PTR cr3_masked;
|
|
|
|
Bit64u offset_mask = 0xfff;
|
|
|
|
for (int level = levels - 1; level >= 0; --level) {
|
|
|
|
Bit64u pte;
|
|
|
|
pt_address += 8 * ((laddr >> (12 + 9*level)) & 511);
|
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, pt_address, 8, &pte);
|
|
|
|
if (!(pte & 1))
|
|
|
|
goto page_fault;
|
|
|
|
pt_address = pte & BX_CONST64(0x000ffffffffff000);
|
|
|
|
if (level == 1 && (pte & 0x80)) { // PSE page
|
|
|
|
offset_mask = 0x1fffff;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paddress = pt_address + (laddr & offset_mask);
|
|
|
|
} else { // not PAE
|
|
|
|
Bit32u pt_address;
|
|
|
|
pt_address = BX_CPU_THIS_PTR cr3_masked;
|
|
|
|
Bit32u offset_mask = 0xfff;
|
|
|
|
for (int level = 1; level >= 0; --level) {
|
|
|
|
Bit32u pte;
|
|
|
|
pt_address += 4 * ((laddr >> (12 + 10*level)) & 1023);
|
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, pt_address, 4, &pte);
|
|
|
|
if (!(pte & 1))
|
|
|
|
goto page_fault;
|
|
|
|
pt_address = pte & 0xfffff000;
|
|
|
|
if (level == 1 && (pte & 0x80)) { // PSE page
|
|
|
|
offset_mask = 0x3fffff;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paddress = pt_address + (laddr & offset_mask);
|
2005-01-20 22:37:43 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
*phy = paddress;
|
|
|
|
*valid = 1;
|
|
|
|
return;
|
|
|
|
|
|
|
|
page_fault:
|
|
|
|
*phy = 0;
|
|
|
|
*valid = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
void BX_CPP_AttrRegparmN(3)
|
2002-09-17 00:23:38 +04:00
|
|
|
BX_CPU_C::access_linear(bx_address laddr, unsigned length, unsigned pl,
|
2001-04-10 05:04:59 +04:00
|
|
|
unsigned rw, void *data)
|
|
|
|
{
|
|
|
|
|
|
|
|
#if BX_X86_DEBUGGER
|
|
|
|
if ( BX_CPU_THIS_PTR dr7 & 0x000000ff ) {
|
|
|
|
// Only compare debug registers if any breakpoints are enabled
|
|
|
|
Bit32u dr6_bits;
|
|
|
|
unsigned opa, opb;
|
|
|
|
opa = BX_HWDebugMemRW; // Read or Write always compares vs 11b
|
|
|
|
if (rw==BX_READ) // only compares vs 11b
|
|
|
|
opb = opa;
|
|
|
|
else // BX_WRITE or BX_RW; also compare vs 01b
|
|
|
|
opb = BX_HWDebugMemW;
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
dr6_bits = hwdebug_compare(laddr, length, opa, opb);
|
2001-04-10 05:04:59 +04:00
|
|
|
if (dr6_bits) {
|
|
|
|
BX_CPU_THIS_PTR debug_trap |= dr6_bits;
|
|
|
|
BX_CPU_THIS_PTR async_event = 1;
|
|
|
|
}
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
2004-10-30 01:15:48 +04:00
|
|
|
Bit32u pageOffset = laddr & 0x00000fff;
|
|
|
|
unsigned xlate_rw = rw;
|
|
|
|
if (rw==BX_RW) rw = BX_READ;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (BX_CPU_THIS_PTR cr0.pg) {
|
|
|
|
/* check for reference across multiple pages */
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
if ( (pageOffset + length) <= 4096 ) {
|
|
|
|
// Access within single page.
|
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1 =
|
|
|
|
dtranslate_linear(laddr, pl, xlate_rw);
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.pages = 1;
|
|
|
|
|
|
|
|
if (rw == BX_READ) {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr, BX_CPU_THIS_PTR address_xlation.paddress1, length);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1, length, data);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr, BX_CPU_THIS_PTR address_xlation.paddress1, length);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1, length, data);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2005-02-16 21:58:48 +03:00
|
|
|
return;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
|
|
|
// access across 2 pages
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1 =
|
|
|
|
dtranslate_linear(laddr, pl, xlate_rw);
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1 = 4096 - pageOffset;
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2 = length -
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1;
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.pages = 2;
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2 =
|
|
|
|
dtranslate_linear(laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
|
|
|
pl, xlate_rw);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
if (rw == BX_READ) {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, BX_CPU_THIS_PTR address_xlation.paddress1,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.len1, data);
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, BX_CPU_THIS_PTR address_xlation.paddress2,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.len2,
|
|
|
|
((Bit8u*)data) + BX_CPU_THIS_PTR address_xlation.len1);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, BX_CPU_THIS_PTR address_xlation.paddress1,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.len1, data);
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, BX_CPU_THIS_PTR address_xlation.paddress2,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.len2,
|
|
|
|
((Bit8u*)data) + BX_CPU_THIS_PTR address_xlation.len1);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
if (rw == BX_READ) {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, BX_CPU_THIS_PTR address_xlation.paddress1,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.len1,
|
|
|
|
((Bit8u*)data) + (length - BX_CPU_THIS_PTR address_xlation.len1));
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, BX_CPU_THIS_PTR address_xlation.paddress2,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.len2, data);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, BX_CPU_THIS_PTR address_xlation.paddress1,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.len1,
|
|
|
|
((Bit8u*)data) + (length - BX_CPU_THIS_PTR address_xlation.len1));
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, BX_CPU_THIS_PTR address_xlation.paddress2,
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.len2, data);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
// Paging off.
|
|
|
|
if ( (pageOffset + length) <= 4096 ) {
|
|
|
|
// Access within single page.
|
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1 = laddr;
|
|
|
|
BX_CPU_THIS_PTR address_xlation.pages = 1;
|
|
|
|
if (rw == BX_READ) {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr, laddr, length);
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
#if BX_SupportGuest2HostTLB
|
2004-09-04 22:22:22 +04:00
|
|
|
Bit32u tlbIndex = BX_TLB_INDEX_OF(laddr);
|
|
|
|
Bit32u lpf = laddr & 0xfffff000;
|
2002-09-06 23:21:55 +04:00
|
|
|
if (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf)) {
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, laddr, length, data);
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
return;
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
// We haven't seen this page, or it's been bumped before.
|
|
|
|
|
2002-09-06 23:21:55 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf = BX_TLB_LPF_VALUE(lpf);
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].ppf = lpf;
|
|
|
|
// Request a direct write pointer so we can do either R or W.
|
2003-02-28 05:37:18 +03:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (bx_hostpageaddr_t)
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_WRITE);
|
2002-09-10 04:01:01 +04:00
|
|
|
if (!BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr) {
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
// Direct write vetoed. Try requesting only direct reads.
|
2003-02-28 05:37:18 +03:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (bx_hostpageaddr_t)
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_READ);
|
2002-09-10 04:01:01 +04:00
|
|
|
if (BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr) {
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
// Got direct read pointer OK.
|
2002-09-10 04:01:01 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].accessBits =
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
(ReadSysOK | ReadUserOK);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2002-09-10 04:01:01 +04:00
|
|
|
else
|
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].accessBits = 0;
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
else {
|
|
|
|
// Got direct write pointer OK. Mark for any operation to succeed.
|
2002-09-10 04:01:01 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].accessBits =
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
(ReadSysOK | ReadUserOK | WriteSysOK | WriteUserOK);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
#endif // BX_SupportGuest2HostTLB
|
|
|
|
|
|
|
|
// Let access fall through to the following for this iteration.
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, laddr, length, data);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
else { // Write
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr, laddr, length);
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
#if BX_SupportGuest2HostTLB
|
2004-09-04 22:22:22 +04:00
|
|
|
Bit32u tlbIndex = BX_TLB_INDEX_OF(laddr);
|
|
|
|
Bit32u lpf = laddr & 0xfffff000;
|
2002-09-06 23:21:55 +04:00
|
|
|
if (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf)) {
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, laddr, length, data);
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
return;
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
// We haven't seen this page, or it's been bumped before.
|
|
|
|
|
2002-09-06 23:21:55 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf = BX_TLB_LPF_VALUE(lpf);
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].ppf = lpf;
|
|
|
|
// TLB.entry[tlbIndex].ppf field not used for PG==0.
|
|
|
|
// Request a direct write pointer so we can do either R or W.
|
2003-02-28 05:37:18 +03:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (bx_hostpageaddr_t)
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->getHostMemAddr(BX_CPU_THIS, A20ADDR(lpf), BX_WRITE);
|
2002-09-10 04:01:01 +04:00
|
|
|
if (BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr) {
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
// Got direct write pointer OK. Mark for any operation to succeed.
|
2002-09-10 04:01:01 +04:00
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].accessBits =
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
(ReadSysOK | ReadUserOK | WriteSysOK | WriteUserOK);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2002-09-10 04:01:01 +04:00
|
|
|
else
|
|
|
|
BX_CPU_THIS_PTR TLB.entry[tlbIndex].accessBits = 0;
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
#endif // BX_SupportGuest2HostTLB
|
|
|
|
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, laddr, length, data);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
// Access spans two pages.
|
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1 = laddr;
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1 = 4096 - pageOffset;
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2 = length -
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1;
|
|
|
|
BX_CPU_THIS_PTR address_xlation.pages = 2;
|
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2 = laddr +
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1;
|
|
|
|
|
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
|
|
|
if (rw == BX_READ) {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1, data);
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2,
|
|
|
|
((Bit8u*)data) + BX_CPU_THIS_PTR address_xlation.len1);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
else {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1, data);
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2,
|
|
|
|
((Bit8u*)data) + BX_CPU_THIS_PTR address_xlation.len1);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
|
|
|
|
#else // BX_BIG_ENDIAN
|
|
|
|
if (rw == BX_READ) {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1,
|
|
|
|
((Bit8u*)data) + (length - BX_CPU_THIS_PTR address_xlation.len1));
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_READ(BX_CPU_ID, laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2, data);
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
else {
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress1,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len1,
|
|
|
|
((Bit8u*)data) + (length - BX_CPU_THIS_PTR address_xlation.len1));
|
2003-02-13 18:04:11 +03:00
|
|
|
BX_INSTR_LIN_WRITE(BX_CPU_ID, laddr + BX_CPU_THIS_PTR address_xlation.len1,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2);
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS,
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_THIS_PTR address_xlation.paddress2,
|
|
|
|
BX_CPU_THIS_PTR address_xlation.len2, data);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2005-02-16 21:58:48 +03:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#else // BX_SUPPORT_PAGING
|
|
|
|
|
|
|
|
// stub functions for non-support of paging
|
|
|
|
|
|
|
|
void
|
|
|
|
BX_CPU_C::CR3_change(Bit32u value32)
|
|
|
|
{
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("CR3_change(): flush TLB cache"));
|
|
|
|
BX_INFO(("Page Directory Base %08x", (unsigned) value32));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_CPU_C::access_linear(Bit32u laddr, unsigned length, unsigned pl,
|
2001-04-10 05:04:59 +04:00
|
|
|
unsigned rw, void *data)
|
|
|
|
{
|
|
|
|
/* perhaps put this check before all code which calls this function,
|
|
|
|
* so we don't have to here
|
|
|
|
*/
|
|
|
|
if (BX_CPU_THIS_PTR cr0.pg == 0) {
|
|
|
|
if (rw == BX_READ)
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->readPhysicalPage(BX_CPU_THIS, laddr, length, data);
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
2004-11-15 00:25:42 +03:00
|
|
|
BX_CPU_THIS_PTR mem->writePhysicalPage(BX_CPU_THIS, laddr, length, data);
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
2005-02-16 21:58:48 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("access_linear: paging not supported"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2001-08-10 22:42:24 +04:00
|
|
|
void
|
2002-09-18 02:50:53 +04:00
|
|
|
BX_CPU_C::INVLPG(bxInstruction_c* i)
|
2001-08-10 22:42:24 +04:00
|
|
|
{}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#endif // BX_SUPPORT_PAGING
|