gem5  v20.1.0.0
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 <iostream>
43 #include <string>
44 #include <vector>
45 
46 #include "arch/x86/isa_traits.hh"
47 #include "base/bitunion.hh"
48 #include "base/types.hh"
49 #include "base/trie.hh"
50 #include "debug/MMU.hh"
51 #include "mem/port_proxy.hh"
52 
53 class Checkpoint;
54 class ThreadContext;
55 
56 namespace X86ISA
57 {
58  struct TlbEntry;
59 }
60 
62 
63 namespace X86ISA
64 {
65  struct TlbEntry : public Serializable
66  {
67  // The base of the physical page.
69 
70  // The beginning of the virtual page this entry maps.
72  // The size of the page this represents, in address bits.
73  unsigned logBytes;
74 
75  // Read permission is always available, assuming it isn't blocked by
76  // other mechanisms.
77  bool writable;
78  // Whether this page is accesible without being in supervisor mode.
79  bool user;
80  // Whether to use write through or write back. M5 ignores this and
81  // lets the caches handle the writeback policy.
82  //bool pwt;
83  // Whether the page is cacheable or not.
85  // Whether or not to kick this page out on a write to CR3.
86  bool global;
87  // A bit used to form an index into the PAT table.
88  bool patBit;
89  // Whether or not memory on this page can be executed.
90  bool noExec;
91  // A sequence number to keep track of LRU.
92  uint64_t lruSeq;
93 
95 
96  TlbEntry(Addr asn, Addr _vaddr, Addr _paddr,
97  bool uncacheable, bool read_only);
98  TlbEntry();
99 
100  void
101  updateVaddr(Addr new_vaddr)
102  {
103  vaddr = new_vaddr;
104  }
105 
107  {
108  return paddr;
109  }
110 
111  // Return the page size in bytes
112  int size()
113  {
114  return (1 << logBytes);
115  }
116 
117  void serialize(CheckpointOut &cp) const override;
118  void unserialize(CheckpointIn &cp) override;
119  };
120 
121 
122  BitUnion64(VAddr)
123  Bitfield<20, 12> longl1;
124  Bitfield<29, 21> longl2;
125  Bitfield<38, 30> longl3;
126  Bitfield<47, 39> longl4;
127 
128  Bitfield<20, 12> pael1;
129  Bitfield<29, 21> pael2;
130  Bitfield<31, 30> pael3;
131 
132  Bitfield<21, 12> norml1;
133  Bitfield<31, 22> norml2;
134  EndBitUnion(VAddr)
135 
136  // Unfortunately, the placement of the base field in a page table entry is
137  // very erratic and would make a mess here. It might be moved here at some
138  // point in the future.
139  BitUnion64(PageTableEntry)
140  Bitfield<63> nx;
141  Bitfield<51, 12> base;
142  Bitfield<11, 9> avl;
143  Bitfield<8> g;
144  Bitfield<7> ps;
145  Bitfield<6> d;
146  Bitfield<5> a;
147  Bitfield<4> pcd;
148  Bitfield<3> pwt;
149  Bitfield<2> u;
150  Bitfield<1> w;
151  Bitfield<0> p;
152  EndBitUnion(PageTableEntry)
153 
154  template <int first, int last>
156  {
157  public:
158  Addr paddr() { return pte.base << PageShift; }
159  void paddr(Addr addr) { pte.base = addr >> PageShift; }
160 
161  bool present() { return pte.p; }
162  void present(bool p) { pte.p = p ? 1 : 0; }
163 
164  bool uncacheable() { return pte.pcd; }
165  void uncacheable(bool u) { pte.pcd = u ? 1 : 0; }
166 
167  bool readonly() { return !pte.w; }
168  void readonly(bool r) { pte.w = r ? 0 : 1; }
169 
170  void
172  {
173  entryAddr = table;
174  entryAddr += bits(vaddr, first, last) * sizeof(PageTableEntry);
175  pte = p.read<PageTableEntry>(entryAddr);
176  }
177 
178  void
179  reset(Addr _paddr, bool _present=true,
180  bool _uncacheable=false, bool _readonly=false)
181  {
182  pte = 0;
183  pte.u = 1;
184  paddr(_paddr);
185  present(_present);
186  uncacheable(_uncacheable);
187  readonly(_readonly);
188  };
189 
190  void write(PortProxy &p) { p.write(entryAddr, pte); }
191 
192  static int
194  {
195  return 1 << ((first - last) + 4 - PageShift);
196  }
197 
198  protected:
199  PageTableEntry pte;
201  };
202 }
203 
204 #endif
X86ISA::r
Bitfield< 41 > r
Definition: misc.hh:934
X86ISA::TlbEntry::updateVaddr
void updateVaddr(Addr new_vaddr)
Definition: pagetable.hh:101
X86ISA::LongModePTE::paddr
void paddr(Addr addr)
Definition: pagetable.hh:159
Trie< Addr, X86ISA::TlbEntry >::Handle
Node * Handle
Definition: trie.hh:122
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
X86ISA::LongModePTE::readonly
void readonly(bool r)
Definition: pagetable.hh:168
X86ISA::TlbEntry
Definition: pagetable.hh:65
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:179
X86ISA::longl4
Bitfield< 47, 39 > longl4
Definition: pagetable.hh:126
X86ISA::LongModePTE::write
void write(PortProxy &p)
Definition: pagetable.hh:190
X86ISA::TlbEntry::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pagetable.cc:78
X86ISA::TlbEntry::logBytes
unsigned logBytes
Definition: pagetable.hh:73
X86ISA::base
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
X86ISA::TlbEntry::vaddr
Addr vaddr
Definition: pagetable.hh:71
X86ISA::TlbEntry::uncacheable
bool uncacheable
Definition: pagetable.hh:84
X86ISA::TlbEntry::TlbEntry
TlbEntry()
Definition: pagetable.cc:48
Trie< Addr, X86ISA::TlbEntry >
TlbEntryTrie
Trie< Addr, X86ISA::TlbEntry > TlbEntryTrie
Definition: pagetable.hh:61
X86ISA::LongModePTE::pte
PageTableEntry pte
Definition: pagetable.hh:199
X86ISA::LongModePTE::tableSize
static int tableSize()
Definition: pagetable.hh:193
X86ISA::pwt
Bitfield< 3 > pwt
Definition: pagetable.hh:148
X86ISA::TlbEntry::pageStart
Addr pageStart()
Definition: pagetable.hh:106
X86ISA::TlbEntry::trieHandle
TlbEntryTrie::Handle trieHandle
Definition: pagetable.hh:94
X86ISA::LongModePTE::present
bool present()
Definition: pagetable.hh:161
X86ISA::longl3
Bitfield< 38, 30 > longl3
Definition: pagetable.hh:125
X86ISA::TlbEntry::paddr
Addr paddr
Definition: pagetable.hh:68
cp
Definition: cprintf.cc:40
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:200
X86ISA::LongModePTE::uncacheable
void uncacheable(bool u)
Definition: pagetable.hh:165
MipsISA::vaddr
vaddr
Definition: pra_constants.hh:275
X86ISA::LongModePTE::read
void read(PortProxy &p, Addr table, Addr vaddr)
Definition: pagetable.hh:171
X86ISA::PageShift
const Addr PageShift
Definition: isa_traits.hh:47
bitunion.hh
port_proxy.hh
X86ISA::TlbEntry::writable
bool writable
Definition: pagetable.hh:77
X86ISA::LongModePTE
Definition: pagetable.hh:155
isa_traits.hh
X86ISA::TlbEntry::lruSeq
uint64_t lruSeq
Definition: pagetable.hh:92
X86ISA::u
Bitfield< 2 > u
Definition: pagetable.hh:149
X86ISA::avl
Bitfield< 11, 9 > avl
Definition: pagetable.hh:142
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:128
X86ISA::longl1
longl1
Definition: pagetable.hh:123
X86ISA::TlbEntry::global
bool global
Definition: pagetable.hh:86
X86ISA::w
Bitfield< 1 > w
Definition: pagetable.hh:150
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:142
X86ISA::TlbEntry::noExec
bool noExec
Definition: pagetable.hh:90
X86ISA::norml1
Bitfield< 21, 12 > norml1
Definition: pagetable.hh:132
X86ISA::a
Bitfield< 5 > a
Definition: pagetable.hh:146
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:79
X86ISA::norml2
Bitfield< 31, 22 > norml2
Definition: pagetable.hh:133
X86ISA::LongModePTE::paddr
Addr paddr()
Definition: pagetable.hh:158
X86ISA::longl2
Bitfield< 29, 21 > longl2
Definition: pagetable.hh:124
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:151
types.hh
X86ISA::d
Bitfield< 6 > d
Definition: pagetable.hh:145
X86ISA::EndBitUnion
EndBitUnion(TriggerIntMessage) namespace DeliveryMode
Definition: intmessage.hh:49
X86ISA::pcd
Bitfield< 4 > pcd
Definition: pagetable.hh:147
X86ISA::LongModePTE::readonly
bool readonly()
Definition: pagetable.hh:167
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
X86ISA::LongModePTE::present
void present(bool p)
Definition: pagetable.hh:162
X86ISA::TlbEntry::patBit
bool patBit
Definition: pagetable.hh:88
X86ISA::ps
Bitfield< 7 > ps
Definition: pagetable.hh:144
X86ISA::LongModePTE::uncacheable
bool uncacheable()
Definition: pagetable.hh:164
X86ISA::pael3
Bitfield< 31, 30 > pael3
Definition: pagetable.hh:130
X86ISA::TlbEntry::size
int size()
Definition: pagetable.hh:112
X86ISA::g
Bitfield< 8 > g
Definition: pagetable.hh:143
CheckpointIn
Definition: serialize.hh:67
trie.hh
X86ISA::TlbEntry::user
bool user
Definition: pagetable.hh:79
X86ISA::pael2
Bitfield< 29, 21 > pael2
Definition: pagetable.hh:129
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75

Generated on Wed Sep 30 2020 14:02:01 for gem5 by doxygen 1.8.17