gem5  v22.1.0.0
tlb.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 The Hewlett-Packard Development Company
3  * All rights reserved.
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __ARCH_X86_TLB_HH__
39 #define __ARCH_X86_TLB_HH__
40 
41 #include <list>
42 #include <vector>
43 
44 #include "arch/generic/tlb.hh"
45 #include "arch/x86/pagetable.hh"
46 #include "base/trie.hh"
47 #include "mem/request.hh"
48 #include "params/X86TLB.hh"
49 #include "sim/stats.hh"
50 
51 namespace gem5
52 {
53 
54 class ThreadContext;
55 
56 namespace X86ISA
57 {
58  class Walker;
59 
60  class TLB : public BaseTLB
61  {
62  protected:
63  friend class Walker;
64 
66 
67  uint32_t configAddress;
68 
69  public:
70 
71  typedef X86TLBParams Params;
72  TLB(const Params &p);
73 
74  void takeOverFrom(BaseTLB *otlb) override {}
75 
76  TlbEntry *lookup(Addr va, bool update_lru = true);
77 
78  void setConfigAddress(uint32_t addr);
79  //concatenate Page Addr and pcid
80  inline Addr concAddrPcid(Addr vpn, uint64_t pcid)
81  {
82  return (vpn | pcid);
83  }
84 
85  protected:
86 
87  EntryList::iterator lookupIt(Addr va, bool update_lru = true);
88 
90 
91  public:
92  Walker *getWalker();
93 
94  void flushAll() override;
95 
96  void flushNonGlobal();
97 
98  void demapPage(Addr va, uint64_t asn) override;
99 
100  protected:
101  uint32_t size;
102 
104 
106 
108  uint64_t lruSeq;
109 
111 
112  struct TlbStats : public statistics::Group
113  {
114  TlbStats(statistics::Group *parent);
115 
120  } stats;
121 
122  Fault translateInt(bool read, RequestPtr req, ThreadContext *tc);
123 
124  Fault translate(const RequestPtr &req, ThreadContext *tc,
126  bool &delayedResponse, bool timing);
127 
128  public:
129 
130  void evictLRU();
131 
132  uint64_t
134  {
135  return ++lruSeq;
136  }
137 
139  const RequestPtr &req, ThreadContext *tc,
140  BaseMMU::Mode mode) override;
142  const RequestPtr &req, ThreadContext *tc,
143  BaseMMU::Mode mode) override;
144  void translateTiming(
145  const RequestPtr &req, ThreadContext *tc,
146  BaseMMU::Translation *translation, BaseMMU::Mode mode) override;
147 
162  BaseMMU::Mode mode) const override;
163 
164  TlbEntry *insert(Addr vpn, const TlbEntry &entry, uint64_t pcid);
165 
166  // Checkpointing
167  void serialize(CheckpointOut &cp) const override;
168  void unserialize(CheckpointIn &cp) override;
169 
180  Port *getTableWalkerPort() override;
181  };
182 
183 } // namespace X86ISA
184 } // namespace gem5
185 
186 #endif // __ARCH_X86_TLB_HH__
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:82
Ports are used to interface objects to each other.
Definition: port.hh:62
ThreadContext is the external interface to all thread state for anything outside of the CPU.
TlbEntry * lookup(Addr va, bool update_lru=true)
Definition: tlb.cc:136
Walker * walker
Definition: tlb.hh:89
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.cc:273
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:145
uint32_t size
Definition: tlb.hh:101
TlbEntryTrie trie
Definition: tlb.hh:107
uint64_t lruSeq
Definition: tlb.hh:108
uint32_t configAddress
Definition: tlb.hh:67
void evictLRU()
Definition: tlb.cc:94
void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode) override
Definition: tlb.cc:551
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Definition: tlb.cc:508
void setConfigAddress(uint32_t addr)
Definition: tlb.cc:158
Addr concAddrPcid(Addr vpn, uint64_t pcid)
Definition: tlb.hh:80
Fault translateInt(bool read, RequestPtr req, ThreadContext *tc)
Definition: tlb.cc:210
std::list< TlbEntry * > EntryList
Definition: tlb.hh:65
void flushNonGlobal()
Definition: tlb.cc:164
TLB(const Params &p)
Definition: tlb.cc:65
gem5::X86ISA::TLB::TlbStats stats
TlbEntry * insert(Addr vpn, const TlbEntry &entry, uint64_t pcid)
Definition: tlb.cc:100
Walker * getWalker()
Definition: tlb.cc:88
AddrRange m5opRange
Definition: tlb.hh:110
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:584
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:599
X86TLBParams Params
Definition: tlb.hh:71
Port * getTableWalkerPort() override
Get the table walker port.
Definition: tlb.cc:621
std::vector< TlbEntry > tlb
Definition: tlb.hh:103
void demapPage(Addr va, uint64_t asn) override
Definition: tlb.cc:177
Fault translate(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode, bool &delayedResponse, bool timing)
Definition: tlb.cc:322
EntryList freeList
Definition: tlb.hh:105
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Definition: tlb.cc:516
EntryList::iterator lookupIt(Addr va, bool update_lru=true)
uint64_t nextSeq()
Definition: tlb.hh:133
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:74
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
STL vector class.
Definition: stl.hh:37
Bitfield< 8 > va
Definition: misc_types.hh:282
Bitfield< 3 > addr
Definition: types.hh:84
Bitfield< 3 > mode
Definition: types.hh:192
Bitfield< 0 > p
Definition: pagetable.hh:151
Bitfield< 11, 0 > pcid
Definition: misc.hh:624
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
statistics::Scalar rdMisses
Definition: tlb.hh:118
statistics::Scalar wrAccesses
Definition: tlb.hh:117
statistics::Scalar rdAccesses
Definition: tlb.hh:116
TlbStats(statistics::Group *parent)
Definition: tlb.cc:519
statistics::Scalar wrMisses
Definition: tlb.hh:119

Generated on Wed Dec 21 2022 10:22:15 for gem5 by doxygen 1.9.1