2007-11-13 03:06:57 +01:00
|
|
|
/*
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
* Copyright (c) 2012 ARM Limited
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The license below extends only to copyright in the software and shall
|
|
|
|
* not be construed as granting a license to any other intellectual
|
|
|
|
* property including but not limited to intellectual property relating
|
|
|
|
* to a hardware implementation of the functionality of the software
|
|
|
|
* licensed hereunder. You may use the software subject to the license
|
|
|
|
* terms below provided that you ensure that this notice is replicated
|
|
|
|
* unmodified and in its entirety in all distributions of the software,
|
|
|
|
* modified or unmodified, in source code or in binary form.
|
|
|
|
*
|
2007-11-13 03:06:57 +01:00
|
|
|
* Copyright (c) 2007 The Hewlett-Packard Development Company
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2010-05-24 07:44:15 +02:00
|
|
|
* The license below extends only to copyright in the software and shall
|
|
|
|
* not be construed as granting a license to any other intellectual
|
|
|
|
* property including but not limited to intellectual property relating
|
|
|
|
* to a hardware implementation of the functionality of the software
|
|
|
|
* licensed hereunder. You may use the software subject to the license
|
|
|
|
* terms below provided that you ensure that this notice is replicated
|
|
|
|
* unmodified and in its entirety in all distributions of the software,
|
|
|
|
* modified or unmodified, in source code or in binary form.
|
2007-11-13 03:06:57 +01:00
|
|
|
*
|
2010-05-24 07:44:15 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
2007-11-13 03:06:57 +01:00
|
|
|
* contributors may be used to endorse or promote products derived from
|
2010-05-24 07:44:15 +02:00
|
|
|
* this software without specific prior written permission.
|
2007-11-13 03:06:57 +01:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Authors: Gabe Black
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "arch/x86/pagetable.hh"
|
|
|
|
#include "arch/x86/pagetable_walker.hh"
|
|
|
|
#include "arch/x86/tlb.hh"
|
2011-02-07 07:14:18 +01:00
|
|
|
#include "arch/x86/vtophys.hh"
|
2007-11-13 03:06:57 +01:00
|
|
|
#include "base/bitfield.hh"
|
2012-04-15 08:24:18 +02:00
|
|
|
#include "base/trie.hh"
|
2007-11-13 03:06:57 +01:00
|
|
|
#include "cpu/base.hh"
|
2011-04-15 19:44:06 +02:00
|
|
|
#include "cpu/thread_context.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/PageTableWalker.hh"
|
2007-11-13 03:06:57 +01:00
|
|
|
#include "mem/packet_access.hh"
|
|
|
|
#include "mem/request.hh"
|
|
|
|
|
|
|
|
namespace X86ISA {
|
|
|
|
|
|
|
|
// Unfortunately, the placement of the base field in a page table entry is
|
|
|
|
// very erratic and would make a mess here. It might be moved here at some
|
|
|
|
// point in the future.
|
|
|
|
BitUnion64(PageTableEntry)
|
|
|
|
Bitfield<63> nx;
|
|
|
|
Bitfield<11, 9> avl;
|
|
|
|
Bitfield<8> g;
|
|
|
|
Bitfield<7> ps;
|
|
|
|
Bitfield<6> d;
|
|
|
|
Bitfield<5> a;
|
|
|
|
Bitfield<4> pcd;
|
|
|
|
Bitfield<3> pwt;
|
|
|
|
Bitfield<2> u;
|
|
|
|
Bitfield<1> w;
|
|
|
|
Bitfield<0> p;
|
|
|
|
EndBitUnion(PageTableEntry)
|
|
|
|
|
2009-02-25 19:16:21 +01:00
|
|
|
Fault
|
2011-02-07 07:14:18 +01:00
|
|
|
Walker::start(ThreadContext * _tc, BaseTLB::Translation *_translation,
|
|
|
|
RequestPtr _req, BaseTLB::Mode _mode)
|
|
|
|
{
|
|
|
|
// TODO: in timing mode, instead of blocking when there are other
|
|
|
|
// outstanding requests, see if this request can be coalesced with
|
|
|
|
// another one (i.e. either coalesce or start walk)
|
|
|
|
WalkerState * newState = new WalkerState(this, _translation, _req);
|
|
|
|
newState->initState(_tc, _mode, sys->getMemoryMode() == Enums::timing);
|
|
|
|
if (currStates.size()) {
|
|
|
|
assert(newState->isTiming());
|
|
|
|
DPRINTF(PageTableWalker, "Walks in progress: %d\n", currStates.size());
|
|
|
|
currStates.push_back(newState);
|
|
|
|
return NoFault;
|
|
|
|
} else {
|
|
|
|
currStates.push_back(newState);
|
|
|
|
Fault fault = newState->startWalk();
|
|
|
|
if (!newState->isTiming()) {
|
|
|
|
currStates.pop_front();
|
|
|
|
delete newState;
|
|
|
|
}
|
|
|
|
return fault;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Fault
|
2012-04-15 08:24:18 +02:00
|
|
|
Walker::startFunctional(ThreadContext * _tc, Addr &addr, unsigned &logBytes,
|
2011-02-07 07:14:18 +01:00
|
|
|
BaseTLB::Mode _mode)
|
|
|
|
{
|
|
|
|
funcState.initState(_tc, _mode);
|
2012-04-15 08:24:18 +02:00
|
|
|
return funcState.startFunctional(addr, logBytes);
|
2011-02-07 07:14:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
Walker::WalkerPort::recvTimingResp(PacketPtr pkt)
|
2011-02-07 07:14:18 +01:00
|
|
|
{
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
return walker->recvTimingResp(pkt);
|
2011-02-07 07:14:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
Walker::recvTimingResp(PacketPtr pkt)
|
2011-02-07 07:14:18 +01:00
|
|
|
{
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
WalkerSenderState * senderState =
|
|
|
|
dynamic_cast<WalkerSenderState *>(pkt->senderState);
|
|
|
|
pkt->senderState = senderState->saved;
|
|
|
|
WalkerState * senderWalk = senderState->senderWalk;
|
|
|
|
bool walkComplete = senderWalk->recvPacket(pkt);
|
|
|
|
delete senderState;
|
|
|
|
if (walkComplete) {
|
|
|
|
std::list<WalkerState *>::iterator iter;
|
|
|
|
for (iter = currStates.begin(); iter != currStates.end(); iter++) {
|
|
|
|
WalkerState * walkerState = *(iter);
|
|
|
|
if (walkerState == senderWalk) {
|
|
|
|
iter = currStates.erase(iter);
|
|
|
|
break;
|
2011-02-07 07:14:18 +01:00
|
|
|
}
|
|
|
|
}
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
delete senderWalk;
|
|
|
|
// Since we block requests when another is outstanding, we
|
|
|
|
// need to check if there is a waiting request to be serviced
|
|
|
|
if (currStates.size()) {
|
|
|
|
WalkerState * newState = currStates.front();
|
|
|
|
if (!newState->wasStarted())
|
|
|
|
newState->startWalk();
|
|
|
|
}
|
2011-02-07 07:14:18 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Walker::WalkerPort::recvRetry()
|
|
|
|
{
|
|
|
|
walker->recvRetry();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Walker::recvRetry()
|
|
|
|
{
|
|
|
|
std::list<WalkerState *>::iterator iter;
|
|
|
|
for (iter = currStates.begin(); iter != currStates.end(); iter++) {
|
|
|
|
WalkerState * walkerState = *(iter);
|
|
|
|
if (walkerState->isRetrying()) {
|
|
|
|
walkerState->retry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Walker::sendTiming(WalkerState* sendingState, PacketPtr pkt)
|
|
|
|
{
|
|
|
|
pkt->senderState = new WalkerSenderState(sendingState, pkt->senderState);
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
return port.sendTimingReq(pkt);
|
2011-02-07 07:14:18 +01:00
|
|
|
}
|
|
|
|
|
2012-10-15 14:12:35 +02:00
|
|
|
BaseMasterPort &
|
|
|
|
Walker::getMasterPort(const std::string &if_name, PortID idx)
|
2011-02-07 07:14:18 +01:00
|
|
|
{
|
|
|
|
if (if_name == "port")
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
return port;
|
2011-02-07 07:14:18 +01:00
|
|
|
else
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
return MemObject::getMasterPort(if_name, idx);
|
2011-02-07 07:14:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Walker::WalkerState::initState(ThreadContext * _tc,
|
|
|
|
BaseTLB::Mode _mode, bool _isTiming)
|
|
|
|
{
|
|
|
|
assert(state == Ready);
|
|
|
|
started = false;
|
|
|
|
tc = _tc;
|
|
|
|
mode = _mode;
|
|
|
|
timing = _isTiming;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fault
|
|
|
|
Walker::WalkerState::startWalk()
|
|
|
|
{
|
|
|
|
Fault fault = NoFault;
|
|
|
|
assert(started == false);
|
|
|
|
started = true;
|
|
|
|
setupWalk(req->getVaddr());
|
|
|
|
if (timing) {
|
|
|
|
nextState = state;
|
|
|
|
state = Waiting;
|
|
|
|
timingFault = NoFault;
|
|
|
|
sendPackets();
|
|
|
|
} else {
|
|
|
|
do {
|
|
|
|
walker->port.sendAtomic(read);
|
|
|
|
PacketPtr write = NULL;
|
|
|
|
fault = stepWalk(write);
|
|
|
|
assert(fault == NoFault || read == NULL);
|
|
|
|
state = nextState;
|
|
|
|
nextState = Ready;
|
|
|
|
if (write)
|
|
|
|
walker->port.sendAtomic(write);
|
|
|
|
} while(read);
|
|
|
|
state = Ready;
|
|
|
|
nextState = Waiting;
|
|
|
|
}
|
|
|
|
return fault;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fault
|
2012-04-15 08:24:18 +02:00
|
|
|
Walker::WalkerState::startFunctional(Addr &addr, unsigned &logBytes)
|
2011-02-07 07:14:18 +01:00
|
|
|
{
|
|
|
|
Fault fault = NoFault;
|
|
|
|
assert(started == false);
|
|
|
|
started = true;
|
|
|
|
setupWalk(addr);
|
|
|
|
|
|
|
|
do {
|
|
|
|
walker->port.sendFunctional(read);
|
|
|
|
// On a functional access (page table lookup), writes should
|
|
|
|
// not happen so this pointer is ignored after stepWalk
|
|
|
|
PacketPtr write = NULL;
|
|
|
|
fault = stepWalk(write);
|
|
|
|
assert(fault == NoFault || read == NULL);
|
|
|
|
state = nextState;
|
|
|
|
nextState = Ready;
|
|
|
|
} while(read);
|
2012-04-15 08:24:18 +02:00
|
|
|
logBytes = entry.logBytes;
|
2011-02-07 07:14:18 +01:00
|
|
|
addr = entry.paddr;
|
|
|
|
|
|
|
|
return fault;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fault
|
|
|
|
Walker::WalkerState::stepWalk(PacketPtr &write)
|
2007-11-13 03:06:57 +01:00
|
|
|
{
|
|
|
|
assert(state != Ready && state != Waiting);
|
2011-02-07 07:14:18 +01:00
|
|
|
Fault fault = NoFault;
|
2007-11-13 03:06:57 +01:00
|
|
|
write = NULL;
|
|
|
|
PageTableEntry pte;
|
2011-02-07 07:14:18 +01:00
|
|
|
if (dataSize == 8)
|
2007-11-13 03:06:57 +01:00
|
|
|
pte = read->get<uint64_t>();
|
|
|
|
else
|
|
|
|
pte = read->get<uint32_t>();
|
|
|
|
VAddr vaddr = entry.vaddr;
|
|
|
|
bool uncacheable = pte.pcd;
|
|
|
|
Addr nextRead = 0;
|
|
|
|
bool doWrite = false;
|
2011-02-07 07:14:18 +01:00
|
|
|
bool doTLBInsert = false;
|
|
|
|
bool doEndWalk = false;
|
2009-04-13 13:14:15 +02:00
|
|
|
bool badNX = pte.nx && mode == BaseTLB::Execute && enableNX;
|
2007-11-13 03:06:57 +01:00
|
|
|
switch(state) {
|
|
|
|
case LongPML4:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got long mode PML4 entry %#016x.\n", (uint64_t)pte);
|
2011-02-07 07:14:18 +01:00
|
|
|
nextRead = ((uint64_t)pte & (mask(40) << 12)) + vaddr.longl3 * dataSize;
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = pte.w;
|
|
|
|
entry.user = pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (badNX || !pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
entry.noExec = pte.nx;
|
|
|
|
nextState = LongPDP;
|
|
|
|
break;
|
|
|
|
case LongPDP:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got long mode PDP entry %#016x.\n", (uint64_t)pte);
|
2011-02-07 07:14:18 +01:00
|
|
|
nextRead = ((uint64_t)pte & (mask(40) << 12)) + vaddr.longl2 * dataSize;
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = entry.writable && pte.w;
|
|
|
|
entry.user = entry.user && pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (badNX || !pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
nextState = LongPD;
|
|
|
|
break;
|
|
|
|
case LongPD:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got long mode PD entry %#016x.\n", (uint64_t)pte);
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = entry.writable && pte.w;
|
|
|
|
entry.user = entry.user && pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (badNX || !pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
if (!pte.ps) {
|
|
|
|
// 4 KB page
|
2012-04-15 08:24:18 +02:00
|
|
|
entry.logBytes = 12;
|
2007-11-13 03:06:57 +01:00
|
|
|
nextRead =
|
2011-02-07 07:14:18 +01:00
|
|
|
((uint64_t)pte & (mask(40) << 12)) + vaddr.longl1 * dataSize;
|
2007-11-13 03:06:57 +01:00
|
|
|
nextState = LongPTE;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
// 2 MB page
|
2012-04-15 08:24:18 +02:00
|
|
|
entry.logBytes = 21;
|
2007-11-13 03:06:57 +01:00
|
|
|
entry.paddr = (uint64_t)pte & (mask(31) << 21);
|
|
|
|
entry.uncacheable = uncacheable;
|
|
|
|
entry.global = pte.g;
|
|
|
|
entry.patBit = bits(pte, 12);
|
|
|
|
entry.vaddr = entry.vaddr & ~((2 * (1 << 20)) - 1);
|
2011-02-07 07:14:18 +01:00
|
|
|
doTLBInsert = true;
|
|
|
|
doEndWalk = true;
|
|
|
|
break;
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
|
|
|
case LongPTE:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got long mode PTE entry %#016x.\n", (uint64_t)pte);
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = entry.writable && pte.w;
|
|
|
|
entry.user = entry.user && pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (badNX || !pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
entry.paddr = (uint64_t)pte & (mask(40) << 12);
|
|
|
|
entry.uncacheable = uncacheable;
|
|
|
|
entry.global = pte.g;
|
|
|
|
entry.patBit = bits(pte, 12);
|
|
|
|
entry.vaddr = entry.vaddr & ~((4 * (1 << 10)) - 1);
|
2011-02-07 07:14:18 +01:00
|
|
|
doTLBInsert = true;
|
|
|
|
doEndWalk = true;
|
|
|
|
break;
|
2007-11-13 03:06:57 +01:00
|
|
|
case PAEPDP:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got legacy mode PAE PDP entry %#08x.\n", (uint32_t)pte);
|
2011-02-07 07:14:18 +01:00
|
|
|
nextRead = ((uint64_t)pte & (mask(40) << 12)) + vaddr.pael2 * dataSize;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (!pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
nextState = PAEPD;
|
|
|
|
break;
|
|
|
|
case PAEPD:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got legacy mode PAE PD entry %#08x.\n", (uint32_t)pte);
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = pte.w;
|
|
|
|
entry.user = pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (badNX || !pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
if (!pte.ps) {
|
|
|
|
// 4 KB page
|
2012-04-15 08:24:18 +02:00
|
|
|
entry.logBytes = 12;
|
2011-02-07 07:14:18 +01:00
|
|
|
nextRead = ((uint64_t)pte & (mask(40) << 12)) + vaddr.pael1 * dataSize;
|
2007-11-13 03:06:57 +01:00
|
|
|
nextState = PAEPTE;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
// 2 MB page
|
2012-04-15 08:24:18 +02:00
|
|
|
entry.logBytes = 21;
|
2007-11-13 03:06:57 +01:00
|
|
|
entry.paddr = (uint64_t)pte & (mask(31) << 21);
|
|
|
|
entry.uncacheable = uncacheable;
|
|
|
|
entry.global = pte.g;
|
|
|
|
entry.patBit = bits(pte, 12);
|
|
|
|
entry.vaddr = entry.vaddr & ~((2 * (1 << 20)) - 1);
|
2011-02-07 07:14:18 +01:00
|
|
|
doTLBInsert = true;
|
|
|
|
doEndWalk = true;
|
|
|
|
break;
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
|
|
|
case PAEPTE:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got legacy mode PAE PTE entry %#08x.\n", (uint32_t)pte);
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = entry.writable && pte.w;
|
|
|
|
entry.user = entry.user && pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (badNX || !pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
entry.paddr = (uint64_t)pte & (mask(40) << 12);
|
|
|
|
entry.uncacheable = uncacheable;
|
|
|
|
entry.global = pte.g;
|
|
|
|
entry.patBit = bits(pte, 7);
|
|
|
|
entry.vaddr = entry.vaddr & ~((4 * (1 << 10)) - 1);
|
2011-02-07 07:14:18 +01:00
|
|
|
doTLBInsert = true;
|
|
|
|
doEndWalk = true;
|
|
|
|
break;
|
2007-11-13 03:06:57 +01:00
|
|
|
case PSEPD:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got legacy mode PSE PD entry %#08x.\n", (uint32_t)pte);
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = pte.w;
|
|
|
|
entry.user = pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (!pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
if (!pte.ps) {
|
|
|
|
// 4 KB page
|
2012-04-15 08:24:18 +02:00
|
|
|
entry.logBytes = 12;
|
2007-11-13 03:06:57 +01:00
|
|
|
nextRead =
|
2011-02-07 07:14:18 +01:00
|
|
|
((uint64_t)pte & (mask(20) << 12)) + vaddr.norml2 * dataSize;
|
2007-11-13 03:06:57 +01:00
|
|
|
nextState = PTE;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
// 4 MB page
|
2012-04-15 08:24:18 +02:00
|
|
|
entry.logBytes = 21;
|
2007-11-13 03:06:57 +01:00
|
|
|
entry.paddr = bits(pte, 20, 13) << 32 | bits(pte, 31, 22) << 22;
|
|
|
|
entry.uncacheable = uncacheable;
|
|
|
|
entry.global = pte.g;
|
|
|
|
entry.patBit = bits(pte, 12);
|
|
|
|
entry.vaddr = entry.vaddr & ~((4 * (1 << 20)) - 1);
|
2011-02-07 07:14:18 +01:00
|
|
|
doTLBInsert = true;
|
|
|
|
doEndWalk = true;
|
|
|
|
break;
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
|
|
|
case PD:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got legacy mode PD entry %#08x.\n", (uint32_t)pte);
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = pte.w;
|
|
|
|
entry.user = pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (!pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
// 4 KB page
|
2012-04-15 08:24:18 +02:00
|
|
|
entry.logBytes = 12;
|
2011-02-07 07:14:18 +01:00
|
|
|
nextRead = ((uint64_t)pte & (mask(20) << 12)) + vaddr.norml2 * dataSize;
|
2007-11-13 03:06:57 +01:00
|
|
|
nextState = PTE;
|
|
|
|
break;
|
|
|
|
case PTE:
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker,
|
|
|
|
"Got legacy mode PTE entry %#08x.\n", (uint32_t)pte);
|
2007-11-13 03:06:57 +01:00
|
|
|
doWrite = !pte.a;
|
|
|
|
pte.a = 1;
|
|
|
|
entry.writable = pte.w;
|
|
|
|
entry.user = pte.u;
|
2009-02-25 19:16:21 +01:00
|
|
|
if (!pte.p) {
|
2011-02-07 07:14:18 +01:00
|
|
|
doEndWalk = true;
|
|
|
|
fault = pageFault(pte.p);
|
|
|
|
break;
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
entry.paddr = (uint64_t)pte & (mask(20) << 12);
|
|
|
|
entry.uncacheable = uncacheable;
|
|
|
|
entry.global = pte.g;
|
|
|
|
entry.patBit = bits(pte, 7);
|
|
|
|
entry.vaddr = entry.vaddr & ~((4 * (1 << 10)) - 1);
|
2011-02-07 07:14:18 +01:00
|
|
|
doTLBInsert = true;
|
|
|
|
doEndWalk = true;
|
|
|
|
break;
|
2007-11-13 03:06:57 +01:00
|
|
|
default:
|
|
|
|
panic("Unknown page table walker state %d!\n");
|
|
|
|
}
|
2011-02-07 07:14:18 +01:00
|
|
|
if (doEndWalk) {
|
|
|
|
if (doTLBInsert)
|
|
|
|
if (!functional)
|
|
|
|
walker->tlb->insert(entry.vaddr, entry);
|
|
|
|
endWalk();
|
2007-11-13 03:06:57 +01:00
|
|
|
} else {
|
2011-02-07 07:14:18 +01:00
|
|
|
PacketPtr oldRead = read;
|
|
|
|
//If we didn't return, we're setting up another read.
|
|
|
|
Request::Flags flags = oldRead->req->getFlags();
|
|
|
|
flags.set(Request::UNCACHEABLE, uncacheable);
|
|
|
|
RequestPtr request =
|
2012-02-12 23:07:38 +01:00
|
|
|
new Request(nextRead, oldRead->getSize(), flags, walker->masterId);
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
read = new Packet(request, MemCmd::ReadReq);
|
2011-02-07 07:14:18 +01:00
|
|
|
read->allocate();
|
|
|
|
// If we need to write, adjust the read packet to write the modified
|
|
|
|
// value back to memory.
|
|
|
|
if (doWrite) {
|
|
|
|
write = oldRead;
|
|
|
|
write->set<uint64_t>(pte);
|
|
|
|
write->cmd = MemCmd::WriteReq;
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
write->clearDest();
|
2011-02-07 07:14:18 +01:00
|
|
|
} else {
|
|
|
|
write = NULL;
|
|
|
|
delete oldRead->req;
|
|
|
|
delete oldRead;
|
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
2011-02-07 07:14:18 +01:00
|
|
|
return fault;
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
|
|
|
|
2011-02-07 07:14:18 +01:00
|
|
|
void
|
|
|
|
Walker::WalkerState::endWalk()
|
2007-11-13 03:06:57 +01:00
|
|
|
{
|
2011-02-07 07:14:18 +01:00
|
|
|
nextState = Ready;
|
|
|
|
delete read->req;
|
|
|
|
delete read;
|
|
|
|
read = NULL;
|
|
|
|
}
|
2007-11-13 03:06:57 +01:00
|
|
|
|
2011-02-07 07:14:18 +01:00
|
|
|
void
|
|
|
|
Walker::WalkerState::setupWalk(Addr vaddr)
|
|
|
|
{
|
2007-11-13 03:06:57 +01:00
|
|
|
VAddr addr = vaddr;
|
|
|
|
CR3 cr3 = tc->readMiscRegNoEffect(MISCREG_CR3);
|
|
|
|
// Check if we're in long mode or not
|
|
|
|
Efer efer = tc->readMiscRegNoEffect(MISCREG_EFER);
|
2011-02-07 07:14:18 +01:00
|
|
|
dataSize = 8;
|
|
|
|
Addr topAddr;
|
2007-11-13 03:06:57 +01:00
|
|
|
if (efer.lma) {
|
|
|
|
// Do long mode.
|
|
|
|
state = LongPML4;
|
2011-02-07 07:14:18 +01:00
|
|
|
topAddr = (cr3.longPdtb << 12) + addr.longl4 * dataSize;
|
2009-02-25 19:16:21 +01:00
|
|
|
enableNX = efer.nxe;
|
2007-11-13 03:06:57 +01:00
|
|
|
} else {
|
|
|
|
// We're in some flavor of legacy mode.
|
|
|
|
CR4 cr4 = tc->readMiscRegNoEffect(MISCREG_CR4);
|
|
|
|
if (cr4.pae) {
|
|
|
|
// Do legacy PAE.
|
|
|
|
state = PAEPDP;
|
2011-02-07 07:14:18 +01:00
|
|
|
topAddr = (cr3.paePdtb << 5) + addr.pael3 * dataSize;
|
2009-02-25 19:16:21 +01:00
|
|
|
enableNX = efer.nxe;
|
2007-11-13 03:06:57 +01:00
|
|
|
} else {
|
2011-02-07 07:14:18 +01:00
|
|
|
dataSize = 4;
|
|
|
|
topAddr = (cr3.pdtb << 12) + addr.norml2 * dataSize;
|
2007-11-13 03:06:57 +01:00
|
|
|
if (cr4.pse) {
|
|
|
|
// Do legacy PSE.
|
|
|
|
state = PSEPD;
|
|
|
|
} else {
|
|
|
|
// Do legacy non PSE.
|
|
|
|
state = PD;
|
|
|
|
}
|
2009-02-25 19:16:21 +01:00
|
|
|
enableNX = false;
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nextState = Ready;
|
|
|
|
entry.vaddr = vaddr;
|
|
|
|
|
2008-11-10 20:51:17 +01:00
|
|
|
Request::Flags flags = Request::PHYSICAL;
|
|
|
|
if (cr3.pcd)
|
|
|
|
flags.set(Request::UNCACHEABLE);
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
RequestPtr request = new Request(topAddr, dataSize, flags,
|
|
|
|
walker->masterId);
|
|
|
|
read = new Packet(request, MemCmd::ReadReq);
|
2007-11-13 03:06:57 +01:00
|
|
|
read->allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-02-07 07:14:18 +01:00
|
|
|
Walker::WalkerState::recvPacket(PacketPtr pkt)
|
2007-11-13 03:06:57 +01:00
|
|
|
{
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
assert(pkt->isResponse());
|
2012-08-22 17:39:59 +02:00
|
|
|
assert(inflight);
|
|
|
|
assert(state == Waiting);
|
|
|
|
assert(!read);
|
|
|
|
inflight--;
|
|
|
|
if (pkt->isRead()) {
|
|
|
|
state = nextState;
|
|
|
|
nextState = Ready;
|
|
|
|
PacketPtr write = NULL;
|
|
|
|
read = pkt;
|
|
|
|
timingFault = stepWalk(write);
|
|
|
|
state = Waiting;
|
|
|
|
assert(timingFault == NoFault || read == NULL);
|
|
|
|
if (write) {
|
|
|
|
writes.push_back(write);
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
2012-08-22 17:39:59 +02:00
|
|
|
sendPackets();
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02:00
|
|
|
} else {
|
2012-08-22 17:39:59 +02:00
|
|
|
sendPackets();
|
|
|
|
}
|
|
|
|
if (inflight == 0 && read == NULL && writes.size() == 0) {
|
|
|
|
state = Ready;
|
|
|
|
nextState = Waiting;
|
|
|
|
if (timingFault == NoFault) {
|
|
|
|
/*
|
|
|
|
* Finish the translation. Now that we now the right entry is
|
|
|
|
* in the TLB, this should work with no memory accesses.
|
|
|
|
* There could be new faults unrelated to the table walk like
|
|
|
|
* permissions violations, so we'll need the return value as
|
|
|
|
* well.
|
|
|
|
*/
|
|
|
|
bool delayedResponse;
|
|
|
|
Fault fault = walker->tlb->translate(req, tc, NULL, mode,
|
|
|
|
delayedResponse, true);
|
|
|
|
assert(!delayedResponse);
|
|
|
|
// Let the CPU continue.
|
|
|
|
translation->finish(fault, req, tc, mode);
|
|
|
|
} else {
|
|
|
|
// There was a fault during the walk. Let the CPU know.
|
|
|
|
translation->finish(timingFault, req, tc, mode);
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
2012-08-22 17:39:59 +02:00
|
|
|
return true;
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
2012-08-22 17:39:59 +02:00
|
|
|
|
2011-02-07 07:14:18 +01:00
|
|
|
return false;
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-02-07 07:14:18 +01:00
|
|
|
Walker::WalkerState::sendPackets()
|
2007-11-13 03:06:57 +01:00
|
|
|
{
|
|
|
|
//If we're already waiting for the port to become available, just return.
|
|
|
|
if (retrying)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Reads always have priority
|
|
|
|
if (read) {
|
2009-02-25 19:16:34 +01:00
|
|
|
PacketPtr pkt = read;
|
|
|
|
read = NULL;
|
|
|
|
inflight++;
|
2011-02-07 07:14:18 +01:00
|
|
|
if (!walker->sendTiming(this, pkt)) {
|
2007-11-13 03:06:57 +01:00
|
|
|
retrying = true;
|
2009-02-25 19:16:34 +01:00
|
|
|
read = pkt;
|
|
|
|
inflight--;
|
2007-11-13 03:06:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Send off as many of the writes as we can.
|
|
|
|
while (writes.size()) {
|
|
|
|
PacketPtr write = writes.back();
|
2009-02-25 19:16:34 +01:00
|
|
|
writes.pop_back();
|
|
|
|
inflight++;
|
2011-02-07 07:14:18 +01:00
|
|
|
if (!walker->sendTiming(this, write)) {
|
2007-11-13 03:06:57 +01:00
|
|
|
retrying = true;
|
2009-02-25 19:16:34 +01:00
|
|
|
writes.push_back(write);
|
|
|
|
inflight--;
|
2007-11-13 03:06:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-07 07:14:18 +01:00
|
|
|
bool
|
|
|
|
Walker::WalkerState::isRetrying()
|
2007-11-13 03:06:57 +01:00
|
|
|
{
|
2011-02-07 07:14:18 +01:00
|
|
|
return retrying;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Walker::WalkerState::isTiming()
|
|
|
|
{
|
|
|
|
return timing;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Walker::WalkerState::wasStarted()
|
|
|
|
{
|
|
|
|
return started;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Walker::WalkerState::retry()
|
|
|
|
{
|
|
|
|
retrying = false;
|
|
|
|
sendPackets();
|
2007-11-13 03:06:57 +01:00
|
|
|
}
|
|
|
|
|
2009-02-25 19:16:21 +01:00
|
|
|
Fault
|
2011-02-07 07:14:18 +01:00
|
|
|
Walker::WalkerState::pageFault(bool present)
|
2009-02-25 19:16:21 +01:00
|
|
|
{
|
2009-02-25 19:17:27 +01:00
|
|
|
DPRINTF(PageTableWalker, "Raising page fault.\n");
|
2009-02-25 19:16:21 +01:00
|
|
|
HandyM5Reg m5reg = tc->readMiscRegNoEffect(MISCREG_M5_REG);
|
2009-04-09 07:21:27 +02:00
|
|
|
if (mode == BaseTLB::Execute && !enableNX)
|
|
|
|
mode = BaseTLB::Read;
|
|
|
|
return new PageFault(entry.vaddr, present, mode, m5reg.cpl == 3, false);
|
2009-02-25 19:16:21 +01:00
|
|
|
}
|
|
|
|
|
2011-02-07 07:14:18 +01:00
|
|
|
/* end namespace X86ISA */ }
|
2007-11-13 03:06:57 +01:00
|
|
|
|
|
|
|
X86ISA::Walker *
|
|
|
|
X86PagetableWalkerParams::create()
|
|
|
|
{
|
|
|
|
return new X86ISA::Walker(this);
|
|
|
|
}
|