gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pagetable.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Advanced Micro Devices, Inc.
3  * Copyright (c) 2007 The Hewlett-Packard Development Company
4  * All rights reserved.
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions are
17  * met: redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer;
19  * redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution;
22  * neither the name of the copyright holders nor the names of its
23  * contributors may be used to endorse or promote products derived from
24  * this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef __ARCH_X86_PAGETABLE_HH__
40 #define __ARCH_X86_PAGETABLE_HH__
41 
42 #include <cstdint>
43 
44 #include "arch/x86/isa_traits.hh"
45 #include "base/bitunion.hh"
46 #include "base/types.hh"
47 #include "base/trie.hh"
48 #include "mem/port_proxy.hh"
49 #include "sim/serialize.hh"
50 
51 class ThreadContext;
52 
53 namespace X86ISA
54 {
55  struct TlbEntry;
56 }
57 
59 
60 namespace X86ISA
61 {
62  struct TlbEntry : public Serializable
63  {
64  // The base of the physical page.
66 
67  // The beginning of the virtual page this entry maps.
69  // The size of the page this represents, in address bits.
70  unsigned logBytes;
71 
72  // Read permission is always available, assuming it isn't blocked by
73  // other mechanisms.
74  bool writable;
75  // Whether this page is accesible without being in supervisor mode.
76  bool user;
77  // Whether to use write through or write back. M5 ignores this and
78  // lets the caches handle the writeback policy.
79  //bool pwt;
80  // Whether the page is cacheable or not.
82  // Whether or not to kick this page out on a write to CR3.
83  bool global;
84  // A bit used to form an index into the PAT table.
85  bool patBit;
86  // Whether or not memory on this page can be executed.
87  bool noExec;
88  // A sequence number to keep track of LRU.
89  uint64_t lruSeq;
90 
92 
93  TlbEntry(Addr asn, Addr _vaddr, Addr _paddr,
94  bool uncacheable, bool read_only);
95  TlbEntry();
96 
97  void
98  updateVaddr(Addr new_vaddr)
99  {
100  vaddr = new_vaddr;
101  }
102 
104  {
105  return paddr;
106  }
107 
108  // Return the page size in bytes
109  int size()
110  {
111  return (1 << logBytes);
112  }
113 
114  void serialize(CheckpointOut &cp) const override;
115  void unserialize(CheckpointIn &cp) override;
116  };
117 
118 
119  BitUnion64(VAddr)
120  Bitfield<20, 12> longl1;
121  Bitfield<29, 21> longl2;
122  Bitfield<38, 30> longl3;
123  Bitfield<47, 39> longl4;
124 
125  Bitfield<20, 12> pael1;
126  Bitfield<29, 21> pael2;
127  Bitfield<31, 30> pael3;
128 
129  Bitfield<21, 12> norml1;
130  Bitfield<31, 22> norml2;
131  EndBitUnion(VAddr)
132 
133  // Unfortunately, the placement of the base field in a page table entry is
134  // very erratic and would make a mess here. It might be moved here at some
135  // point in the future.
136  BitUnion64(PageTableEntry)
137  Bitfield<63> nx;
138  Bitfield<51, 12> base;
139  Bitfield<11, 9> avl;
140  Bitfield<8> g;
141  Bitfield<7> ps;
142  Bitfield<6> d;
143  Bitfield<5> a;
144  Bitfield<4> pcd;
145  Bitfield<3> pwt;
146  Bitfield<2> u;
147  Bitfield<1> w;
148  Bitfield<0> p;
149  EndBitUnion(PageTableEntry)
150 
151  template <int first, int last>
153  {
154  public:
155  Addr paddr() { return pte.base << PageShift; }
156  void paddr(Addr addr) { pte.base = addr >> PageShift; }
157 
158  bool present() { return pte.p; }
159  void present(bool p) { pte.p = p ? 1 : 0; }
160 
161  bool uncacheable() { return pte.pcd; }
162  void uncacheable(bool u) { pte.pcd = u ? 1 : 0; }
163 
164  bool readonly() { return !pte.w; }
165  void readonly(bool r) { pte.w = r ? 0 : 1; }
166 
167  void
169  {
170  entryAddr = table;
171  entryAddr += bits(vaddr, first, last) * sizeof(PageTableEntry);
172  pte = p.read<PageTableEntry>(entryAddr);
173  }
174 
175  void
176  reset(Addr _paddr, bool _present=true,
177  bool _uncacheable=false, bool _readonly=false)
178  {
179  pte = 0;
180  pte.u = 1;
181  paddr(_paddr);
182  present(_present);
183  uncacheable(_uncacheable);
184  readonly(_readonly);
185  };
186 
187  void write(PortProxy &p) { p.write(entryAddr, pte); }
188 
189  static int
191  {
192  return 1 << ((first - last) + 4 - PageShift);
193  }
194 
195  protected:
196  PageTableEntry pte;
198  };
199 }
200 
201 #endif
X86ISA::r
Bitfield< 41 > r
Definition: misc.hh:934
X86ISA::TlbEntry::updateVaddr
void updateVaddr(Addr new_vaddr)
Definition: pagetable.hh:98
serialize.hh
X86ISA::LongModePTE::paddr
void paddr(Addr addr)
Definition: pagetable.hh:156
Trie< Addr, X86ISA::TlbEntry >::Handle
Node * Handle
Definition: trie.hh:122
Serializable
Basic support for object serialization.
Definition: serialize.hh:175
X86ISA::LongModePTE::readonly
void readonly(bool r)
Definition: pagetable.hh:165
X86ISA::TlbEntry
Definition: pagetable.hh:62
X86ISA::present
Bitfield< 7 > present
Definition: misc.hh:992
X86ISA::BitUnion64
BitUnion64(VAddr) Bitfield< 20
X86ISA::LongModePTE::reset
void reset(Addr _paddr, bool _present=true, bool _uncacheable=false, bool _readonly=false)
Definition: pagetable.hh:176
X86ISA::longl4
Bitfield< 47, 39 > longl4
Definition: pagetable.hh:123
X86ISA::LongModePTE::write
void write(PortProxy &p)
Definition: pagetable.hh:187
X86ISA::TlbEntry::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pagetable.cc:78
X86ISA::TlbEntry::logBytes
unsigned logBytes
Definition: pagetable.hh:70
X86ISA::base
Bitfield< 51, 12 > base
Definition: pagetable.hh:138
X86ISA::TlbEntry::vaddr
Addr vaddr
Definition: pagetable.hh:68
X86ISA::TlbEntry::uncacheable
bool uncacheable
Definition: pagetable.hh:81
X86ISA::TlbEntry::TlbEntry
TlbEntry()
Definition: pagetable.cc:48
Trie< Addr, X86ISA::TlbEntry >
TlbEntryTrie
Trie< Addr, X86ISA::TlbEntry > TlbEntryTrie
Definition: pagetable.hh:58
X86ISA::LongModePTE::pte
PageTableEntry pte
Definition: pagetable.hh:196
X86ISA::LongModePTE::tableSize
static int tableSize()
Definition: pagetable.hh:190
X86ISA::pwt
Bitfield< 3 > pwt
Definition: pagetable.hh:145
X86ISA::TlbEntry::pageStart
Addr pageStart()
Definition: pagetable.hh:103
X86ISA::TlbEntry::trieHandle
TlbEntryTrie::Handle trieHandle
Definition: pagetable.hh:91
X86ISA::LongModePTE::present
bool present()
Definition: pagetable.hh:158
X86ISA::longl3
Bitfield< 38, 30 > longl3
Definition: pagetable.hh:122
X86ISA::TlbEntry::paddr
Addr paddr
Definition: pagetable.hh:65
cp
Definition: cprintf.cc:37
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
X86ISA::LongModePTE::entryAddr
Addr entryAddr
Definition: pagetable.hh:197
X86ISA::LongModePTE::uncacheable
void uncacheable(bool u)
Definition: pagetable.hh:162
MipsISA::vaddr
vaddr
Definition: pra_constants.hh:275
X86ISA::LongModePTE::read
void read(PortProxy &p, Addr table, Addr vaddr)
Definition: pagetable.hh:168
X86ISA::PageShift
const Addr PageShift
Definition: isa_traits.hh:48
bitunion.hh
port_proxy.hh
X86ISA::TlbEntry::writable
bool writable
Definition: pagetable.hh:74
X86ISA::LongModePTE
Definition: pagetable.hh:152
isa_traits.hh
X86ISA::TlbEntry::lruSeq
uint64_t lruSeq
Definition: pagetable.hh:89
X86ISA::u
Bitfield< 2 > u
Definition: pagetable.hh:146
X86ISA::avl
Bitfield< 11, 9 > avl
Definition: pagetable.hh:139
X86ISA::TlbEntry::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pagetable.cc:63
X86ISA::pael1
Bitfield< 20, 12 > pael1
Definition: pagetable.hh:125
X86ISA::longl1
longl1
Definition: pagetable.hh:120
X86ISA::TlbEntry::global
bool global
Definition: pagetable.hh:83
X86ISA::w
Bitfield< 1 > w
Definition: pagetable.hh:147
X86ISA
This is exposed globally, independent of the ISA.
Definition: acpi.hh:55
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
X86ISA::TlbEntry::noExec
bool noExec
Definition: pagetable.hh:87
X86ISA::norml1
Bitfield< 21, 12 > norml1
Definition: pagetable.hh:129
X86ISA::a
Bitfield< 5 > a
Definition: pagetable.hh:143
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:80
X86ISA::norml2
Bitfield< 31, 22 > norml2
Definition: pagetable.hh:130
X86ISA::LongModePTE::paddr
Addr paddr()
Definition: pagetable.hh:155
X86ISA::longl2
Bitfield< 29, 21 > longl2
Definition: pagetable.hh:121
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
X86ISA::p
Bitfield< 0 > p
Definition: pagetable.hh:148
types.hh
X86ISA::d
Bitfield< 6 > d
Definition: pagetable.hh:142
X86ISA::EndBitUnion
EndBitUnion(TriggerIntMessage) namespace DeliveryMode
Definition: intmessage.hh:49
X86ISA::pcd
Bitfield< 4 > pcd
Definition: pagetable.hh:144
X86ISA::LongModePTE::readonly
bool readonly()
Definition: pagetable.hh:164
bits
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:73
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:64
X86ISA::LongModePTE::present
void present(bool p)
Definition: pagetable.hh:159
X86ISA::TlbEntry::patBit
bool patBit
Definition: pagetable.hh:85
X86ISA::ps
Bitfield< 7 > ps
Definition: pagetable.hh:141
X86ISA::LongModePTE::uncacheable
bool uncacheable()
Definition: pagetable.hh:161
X86ISA::pael3
Bitfield< 31, 30 > pael3
Definition: pagetable.hh:127
X86ISA::TlbEntry::size
int size()
Definition: pagetable.hh:109
X86ISA::g
Bitfield< 8 > g
Definition: pagetable.hh:140
CheckpointIn
Definition: serialize.hh:68
trie.hh
X86ISA::TlbEntry::user
bool user
Definition: pagetable.hh:76
X86ISA::pael2
Bitfield< 29, 21 > pael2
Definition: pagetable.hh:126

Generated on Tue Mar 23 2021 19:41:20 for gem5 by doxygen 1.8.17