gem5  v22.1.0.0
pauth_helpers.hh
Go to the documentation of this file.
1 // -*- mode:c++ -*-
2 
3 // Copyright (c) 2020 ARM Limited
4 // Copyright (c) 2020 Metempsy Technology Consulting
5 // All rights reserved
6 //
7 // The license below extends only to copyright in the software and shall
8 // not be construed as granting a license to any other intellectual
9 // property including but not limited to intellectual property relating
10 // to a hardware implementation of the functionality of the software
11 // licensed hereunder. You may use the software subject to the license
12 // terms below provided that you ensure that this notice is replicated
13 // unmodified and in its entirety in all distributions of the software,
14 // modified or unmodified, in source code or in binary form.
15 //
16 // Redistribution and use in source and binary forms, with or without
17 // modification, are permitted provided that the following conditions are
18 // met: redistributions of source code must retain the above copyright
19 // notice, this list of conditions and the following disclaimer;
20 // redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution;
23 // neither the name of the copyright holders nor the names of its
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39 #ifndef __ARCH_ARM_PAUTH_HELPERS_HH__
40 #define __ARCH_ARM_PAUTH_HELPERS_HH__
41 
42 #include "arch/arm/qarma.hh"
43 #include "arch/arm/system.hh"
44 #include "arch/arm/types.hh"
45 #include "arch/arm/utility.hh"
46 #include "base/bitfield.hh"
47 #include "base/bitunion.hh"
48 #include "cpu/thread_context.hh"
49 
50 namespace gem5
51 {
52 
53 namespace ArmISA
54 {
55 
56  inline bool
58  {
59  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
60  return (el == EL1 || el == EL0 || (el == EL2 && hcr.e2h == 1));
61  }
62 
63  bool
64  calculateTBI(ThreadContext* tc, ExceptionLevel el, uint64_t ptr, bool data);
65 
66  int
68 
69  Fault
71 
72 
73 
74  // AddPAC()
75  // ========
76  // Calculates the pointer authentication code for a 64-bit quantity
77  // and then inserts that into pointer authentication code field of that
78  // 64-bit quantity.
79 
80  uint64_t
81  addPAC (ThreadContext* tc, ExceptionLevel el, uint64_t ptr,
82  uint64_t modifier, uint64_t k1, uint64_t k0, bool data);
83 
84 
85  uint64_t
86  auth(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier,
87  uint64_t k1, uint64_t K0, bool data, uint8_t errorcode);
88 
89  Fault
90  authDA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
91 
92  Fault
93  authDB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
94 
95 
96  Fault
97  authIA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
98 
99  Fault
100  authIB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
101 
102  Fault
103  addPACDA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
104 
105  Fault
106  addPACDB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
107 
108  Fault
109  addPACGA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
110 
111  Fault
112  addPACIA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
113 
114  Fault
115  addPACIB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
116 
117  // stripPAC returns a 64-bit value containing A, but replacing the
118  // pointer authentication code field bits with the extension of the
119  // address bits. This can apply to either instructions or data, where,
120  // as the use of tagged pointers is distinct, it might be
121  // handled differently.
122  void
123  stripPAC(ThreadContext* tc, uint64_t A, bool data, uint64_t* out);
124 
125 } // namespace ArmISA
126 } // namespace gem5
127 
128 #endif //__ARCH_ARM_PAUTH_HELPERS_HH__
const char data[]
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal readMiscReg(RegIndex misc_reg)=0
bool calculateTBI(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, bool data)
int calculateBottomPACBit(ThreadContext *tc, ExceptionLevel el, bool top_bit)
Fault trapPACUse(ThreadContext *tc, ExceptionLevel el)
Fault authDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
uint64_t addPAC(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier, uint64_t k1, uint64_t k0, bool data)
Fault addPACDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault authDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault addPACGA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
void stripPAC(ThreadContext *tc, uint64_t A, bool data, uint64_t *out)
bool upperAndLowerRange(ThreadContext *tc, ExceptionLevel el)
@ MISCREG_HCR_EL2
Definition: misc.hh:591
Fault authIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault authIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Bitfield< 3, 2 > el
Definition: misc_types.hh:73
Fault addPACIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault addPACIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault addPACDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
uint64_t auth(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier, uint64_t k1, uint64_t K0, bool data, uint8_t errorcode)
constexpr RegId K0
Definition: int.hh:168
Bitfield< 2, 0 > k0
constexpr RegId Y
Definition: int.hh:131
Bitfield< 15, 0 > X
Definition: int.hh:58
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248

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