Fix guest2host and related optimizations to work on 64 bit host.

1) fixed the type of "hostPageAddr" and associated typecasts.
2) fixed the type of "pages" and associated typecasts (overloaded variable)
3) patch to cpu.cc to calculate "eipPageBias" correctly in 64 bit mode
This commit is contained in:
Peter Tattam 2003-02-28 02:37:18 +00:00
parent e6ed09aa3a
commit 94880d1412
4 changed files with 33 additions and 27 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: access.cc,v 1.36 2003-02-13 15:03:56 sshwarts Exp $
// $Id: access.cc,v 1.37 2003-02-28 02:37:17 ptrumpet Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -303,7 +303,7 @@ accessOK:
if ( (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf)))
{
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit8u *hostAddr;
// See if the TLB entry privilege level allows us write access
@ -369,7 +369,7 @@ accessOK:
if ( (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf))
) {
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit16u *hostAddr;
// See if the TLB entry privilege level allows us write access
@ -436,7 +436,7 @@ accessOK:
if ( (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf))
) {
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit32u *hostAddr;
// See if the TLB entry privilege level allows us write access
@ -504,7 +504,7 @@ accessOK:
// See if the TLB entry privilege level allows us read access
// from this CPL.
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit8u *hostAddr;
hostPageAddr = BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr;
@ -557,7 +557,7 @@ accessOK:
// See if the TLB entry privilege level allows us read access
// from this CPL.
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit16u *hostAddr;
hostPageAddr = BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr;
@ -611,7 +611,7 @@ accessOK:
// See if the TLB entry privilege level allows us read access
// from this CPL.
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit32u *hostAddr;
hostPageAddr = BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr;
@ -668,7 +668,7 @@ accessOK:
if ( (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf))
) {
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit8u *hostAddr;
// See if the TLB entry privilege level allows us write access
@ -689,7 +689,7 @@ accessOK:
#endif
) {
*data = *hostAddr;
BX_CPU_THIS_PTR address_xlation.pages = (Bit32u) hostAddr;
BX_CPU_THIS_PTR address_xlation.pages = (bx_ptr_equiv_t) hostAddr;
#if BX_SupportICache
(*pageStamp)--;
#endif
@ -738,7 +738,7 @@ accessOK:
if ( (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf))
) {
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit16u *hostAddr;
// See if the TLB entry privilege level allows us write access
@ -759,7 +759,7 @@ accessOK:
#endif
) {
ReadHostWordFromLittleEndian(hostAddr, *data);
BX_CPU_THIS_PTR address_xlation.pages = (Bit32u) hostAddr;
BX_CPU_THIS_PTR address_xlation.pages = (bx_ptr_equiv_t) hostAddr;
#if BX_SupportICache
(*pageStamp)--;
#endif
@ -806,7 +806,7 @@ accessOK:
if ( (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf))
) {
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit32u *hostAddr;
// See if the TLB entry privilege level allows us write access
@ -827,7 +827,7 @@ accessOK:
#endif
) {
ReadHostDWordFromLittleEndian(hostAddr, *data);
BX_CPU_THIS_PTR address_xlation.pages = (Bit32u) hostAddr;
BX_CPU_THIS_PTR address_xlation.pages = (bx_ptr_equiv_t) hostAddr;
#if BX_SupportICache
(*pageStamp)--;
#endif
@ -958,7 +958,7 @@ accessOK:
if ( (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf))
) {
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit64u *hostAddr;
// See if the TLB entry privilege level allows us write access
@ -1027,7 +1027,7 @@ accessOK:
// See if the TLB entry privilege level allows us read access
// from this CPL.
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit64u *hostAddr;
hostPageAddr = BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr;
@ -1116,7 +1116,7 @@ accessOK:
if ( (BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf == BX_TLB_LPF_VALUE(lpf))
) {
Bit32u accessBits;
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
Bit32u *hostAddr;
// See if the TLB entry privilege level allows us write access
@ -1137,7 +1137,7 @@ accessOK:
#endif
) {
ReadHostQWordFromLittleEndian(hostAddr, *data);
BX_CPU_THIS_PTR address_xlation.pages = (Bit32u) hostAddr;
BX_CPU_THIS_PTR address_xlation.pages = (bx_ptr_equiv_t) hostAddr;
#if BX_SupportICache
(*pageStamp)--;
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.cc,v 1.74 2003-02-13 15:03:57 sshwarts Exp $
// $Id: cpu.cc,v 1.75 2003-02-28 02:37:18 ptrumpet Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -752,7 +752,11 @@ BX_CPU_C::prefetch(void)
// }
// Linear address at the beginning of the page.
#if BX_SUPPORT_X86_64
laddrPageOffset0 = laddr & BX_CONST64(0xfffffffffffff000);
#else
laddrPageOffset0 = laddr & 0xfffff000;
#endif
// Calculate RIP at the beginning of the page.
eipPageOffset0 = RIP - (laddr - laddrPageOffset0);
BX_CPU_THIS_PTR eipPageBias = - eipPageOffset0;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.130 2003-02-26 02:41:30 ptrumpet Exp $
// $Id: cpu.h,v 1.131 2003-02-28 02:37:18 ptrumpet Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1052,11 +1052,13 @@ typedef struct {
#if BX_USE_TLB
typedef bx_ptr_equiv_t bx_hostpageaddr_t;
typedef struct {
bx_address lpf; // linear page frame
Bit32u ppf; // physical page frame
Bit32u accessBits; // Page Table Address for updating A & D bits
Bit32u hostPageAddr;
bx_hostpageaddr_t hostPageAddr;
} bx_TLB_entry;
#endif // #if BX_USE_TLB
@ -1543,7 +1545,7 @@ union {
Bit32u paddress2; // physical address after translation of 2nd len2 bytes of data
Bit32u len1; // Number of bytes in page 1
Bit32u len2; // Number of bytes in page 2
Bit32u pages; // Number of pages access spans (1 or 2). Also used
bx_ptr_equiv_t pages; // Number of pages access spans (1 or 2). Also used
// for the case when a native host pointer is
// available for the R-M-W instructions. The host
// pointer is stuffed here. Since this field has

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: paging.cc,v 1.40 2003-02-26 02:37:08 ptrumpet Exp $
// $Id: paging.cc,v 1.41 2003-02-28 02:37:18 ptrumpet Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -779,7 +779,7 @@ BX_CPU_C::dtranslate_linear(bx_address laddr, unsigned pl, unsigned rw)
// pointer in the TLB cache. Note if the request is vetoed, NULL
// will be returned, and it's OK to OR zero in anyways.
BX_CPU_THIS_PTR TLB.entry[TLB_index].hostPageAddr =
(Bit32u) BX_CPU_THIS_PTR mem->getHostMemAddr(this, A20ADDR(ppf), rw);
(bx_hostpageaddr_t) BX_CPU_THIS_PTR mem->getHostMemAddr(this, A20ADDR(ppf), rw);
#endif
return(paddress);
@ -963,7 +963,7 @@ BX_CPU_C::dtranslate_linear(bx_address laddr, unsigned pl, unsigned rw)
// pointer in the TLB cache. Note if the request is vetoed, NULL
// will be returned, and it's OK to OR zero in anyways.
BX_CPU_THIS_PTR TLB.entry[TLB_index].hostPageAddr =
(Bit32u) BX_CPU_THIS_PTR mem->getHostMemAddr(this, A20ADDR(ppf), rw);
(bx_hostpageaddr_t) BX_CPU_THIS_PTR mem->getHostMemAddr(this, A20ADDR(ppf), rw);
#endif
return(paddress);
@ -1222,11 +1222,11 @@ BX_CPU_C::access_linear(bx_address laddr, unsigned length, unsigned pl,
BX_CPU_THIS_PTR TLB.entry[tlbIndex].lpf = BX_TLB_LPF_VALUE(lpf);
BX_CPU_THIS_PTR TLB.entry[tlbIndex].ppf = lpf;
// Request a direct write pointer so we can do either R or W.
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (Bit32u)
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (bx_hostpageaddr_t)
BX_CPU_THIS_PTR mem->getHostMemAddr(this, A20ADDR(lpf), BX_WRITE);
if (!BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr) {
// Direct write vetoed. Try requesting only direct reads.
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (Bit32u)
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (bx_hostpageaddr_t)
BX_CPU_THIS_PTR mem->getHostMemAddr(this, A20ADDR(lpf), BX_READ);
if (BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr) {
// Got direct read pointer OK.
@ -1265,7 +1265,7 @@ BX_CPU_C::access_linear(bx_address laddr, unsigned length, unsigned pl,
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.
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (Bit32u)
BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr = (bx_hostpageaddr_t)
BX_CPU_THIS_PTR mem->getHostMemAddr(this, A20ADDR(lpf), BX_WRITE);
if (BX_CPU_THIS_PTR TLB.entry[tlbIndex].hostPageAddr) {
// Got direct write pointer OK. Mark for any operation to succeed.