gem5  v22.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 <cstdint>
43 
44 #include "arch/x86/page_size.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 namespace gem5
52 {
53 
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.
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;
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:
201  };
202 
203 } // namespace X86ISA
204 } // namespace gem5
205 
206 #endif
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:87
Basic support for object serialization.
Definition: serialize.hh:170
A trie is a tree-based data structure used for data retrieval.
Definition: trie.hh:55
void read(PortProxy &p, Addr table, Addr vaddr)
Definition: pagetable.hh:171
void uncacheable(bool u)
Definition: pagetable.hh:165
void write(PortProxy &p)
Definition: pagetable.hh:190
void paddr(Addr addr)
Definition: pagetable.hh:159
void reset(Addr _paddr, bool _present=true, bool _uncacheable=false, bool _readonly=false)
Definition: pagetable.hh:179
Base class for formula statistic node.
Definition: statistics.hh:1524
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:76
Bitfield< 1 > w
Definition: pagetable.hh:150
Bitfield< 8 > g
Definition: pagetable.hh:143
Bitfield< 21, 12 > norml1
Definition: pagetable.hh:132
Bitfield< 20, 12 > pael1
Definition: pagetable.hh:128
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
Bitfield< 29, 21 > pael2
Definition: pagetable.hh:129
Bitfield< 31, 22 > norml2
Definition: pagetable.hh:133
Bitfield< 6 > d
Definition: pagetable.hh:145
Bitfield< 7 > present
Definition: misc.hh:999
const Addr PageShift
Definition: page_size.hh:48
Bitfield< 3 > addr
Definition: types.hh:84
BitUnion64(VAddr) Bitfield< 20
Bitfield< 47, 39 > longl4
Definition: pagetable.hh:126
Bitfield< 31, 30 > pael3
Definition: pagetable.hh:130
Bitfield< 4 > pcd
Definition: pagetable.hh:147
Bitfield< 0 > p
Definition: pagetable.hh:151
Bitfield< 41 > r
Definition: misc.hh:941
EndBitUnion(TriggerIntMessage) GEM5_DEPRECATED_NAMESPACE(DeliveryMode
Bitfield< 2 > u
Definition: pagetable.hh:149
Bitfield< 38, 30 > longl3
Definition: pagetable.hh:125
Bitfield< 29, 21 > longl2
Definition: pagetable.hh:124
Bitfield< 7 > ps
Definition: pagetable.hh:144
Bitfield< 5 > a
Definition: pagetable.hh:146
Bitfield< 3 > pwt
Definition: pagetable.hh:148
Bitfield< 11, 9 > avl
Definition: pagetable.hh:142
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Trie< Addr, X86ISA::TlbEntry > TlbEntryTrie
Definition: pagetable.hh:61
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
PortProxy Object Declaration.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pagetable.cc:81
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pagetable.cc:66
void updateVaddr(Addr new_vaddr)
Definition: pagetable.hh:101
TlbEntryTrie::Handle trieHandle
Definition: pagetable.hh:94

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