gem5  v21.2.0.0
pauth_helpers.hh
Go to the documentation of this file.
1 // -*- mode:c++ -*-
2 
3 // Copyright (c) 2020 Metempsy Technology Consulting
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 #ifndef __ARCH_ARM_PAUTH_HELPERS_HH__
39 #define __ARCH_ARM_PAUTH_HELPERS_HH__
40 
41 #include "arch/arm/qarma.hh"
42 #include "arch/arm/system.hh"
43 #include "arch/arm/types.hh"
44 #include "arch/arm/utility.hh"
45 #include "base/bitfield.hh"
46 #include "base/bitunion.hh"
47 #include "cpu/thread_context.hh"
48 
49 namespace gem5
50 {
51 
52 namespace ArmISA
53 {
54 
55  inline bool
57  {
58  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
59  return (el == EL1 || el == EL0 || (el == EL2 && hcr.e2h == 1));
60  }
61 
62  bool
63  calculateTBI(ThreadContext* tc, ExceptionLevel el, uint64_t ptr, bool data);
64 
65  int
67 
68  Fault
70 
71 
72 
73  // AddPAC()
74  // ========
75  // Calculates the pointer authentication code for a 64-bit quantity
76  // and then inserts that into pointer authentication code field of that
77  // 64-bit quantity.
78 
79  uint64_t
80  addPAC (ThreadContext* tc, ExceptionLevel el, uint64_t ptr,
81  uint64_t modifier, uint64_t k1, uint64_t k0, bool data);
82 
83 
84  uint64_t
85  auth(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier,
86  uint64_t k1, uint64_t K0, bool data, uint8_t errorcode);
87 
88  Fault
89  authDA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
90 
91  Fault
92  authDB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
93 
94 
95  Fault
96  authIA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
97 
98  Fault
99  authIB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
100 
101  Fault
102  addPACDA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
103 
104  Fault
105  addPACDB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
106 
107  Fault
108  addPACGA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
109 
110  Fault
111  addPACIA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
112 
113  Fault
114  addPACIB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
115 
116  // Strip()
117  // =======
118  // Strip() returns a 64-bit value containing A, but replacing the
119  // pointer authentication code field bits with the extension of the
120  // address bits. This can apply to either instructions or data, where,
121  // as the use of tagged pointers is distinct, it might be
122  // handled differently.
123 
124  Fault
125  stripPAC(ThreadContext* tc, uint64_t A, bool data, uint64_t* out);
126 
127 } // namespace ArmISA
128 } // namespace gem5
129 
130 #endif //__ARCH_ARM_PAUTH_HELPERS_HH__
gem5::ArmISA::trapPACUse
Fault trapPACUse(ThreadContext *tc, ExceptionLevel el)
Definition: pauth_helpers.cc:116
gem5::ThreadContext::readMiscReg
virtual RegVal readMiscReg(RegIndex misc_reg)=0
gem5::ArmISA::addPACDB
Fault addPACDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:633
gem5::ArmISA::addPACIB
Fault addPACIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:801
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::ArmISA::el
Bitfield< 3, 2 > el
Definition: misc_types.hh:73
gem5::ArmISA::EL1
@ EL1
Definition: types.hh:267
qarma.hh
system.hh
gem5::ArmISA::addPAC
uint64_t addPAC(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier, uint64_t k1, uint64_t k0, bool data)
Definition: pauth_helpers.cc:132
types.hh
gem5::ArmISA::addPACDA
Fault addPACDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:569
gem5::ArmISA::stripPAC
Fault stripPAC(ThreadContext *tc, uint64_t A, bool data, uint64_t *out)
Definition: pauth_helpers.cc:863
bitfield.hh
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:94
gem5::Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:255
gem5::MipsISA::k0
Bitfield< 2, 0 > k0
Definition: pra_constants.hh:229
gem5::ArmISA::authIA
Fault authIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:419
gem5::ArmISA::upperAndLowerRange
bool upperAndLowerRange(ThreadContext *tc, ExceptionLevel el)
Definition: pauth_helpers.hh:56
gem5::ArmISA::EL2
@ EL2
Definition: types.hh:268
bitunion.hh
gem5::ArmISA::authIB
Fault authIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:493
utility.hh
gem5::ArmISA::addPACGA
Fault addPACGA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:694
gem5::ArmISA::EL0
@ EL0
Definition: types.hh:266
gem5::ArmISA::calculateTBI
bool calculateTBI(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, bool data)
Definition: pauth_helpers.cc:49
gem5::ArmISA::authDB
Fault authDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:349
gem5::ArmISA::MISCREG_HCR_EL2
@ MISCREG_HCR_EL2
Definition: misc.hh:586
gem5::ArmISA::auth
uint64_t auth(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier, uint64_t k1, uint64_t K0, bool data, uint8_t errorcode)
Definition: pauth_helpers.cc:224
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::X86ISA::X
Bitfield< 15, 0 > X
Definition: int.hh:55
thread_context.hh
gem5::ArmISA::addPACIA
Fault addPACIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:742
gem5::ArmISA::authDA
Fault authDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:281
gem5::ArmISA::ExceptionLevel
ExceptionLevel
Definition: types.hh:264
gem5::ArmISA::calculateBottomPACBit
int calculateBottomPACBit(ThreadContext *tc, ExceptionLevel el, bool top_bit)
Definition: pauth_helpers.cc:79

Generated on Tue Dec 21 2021 11:34:21 for gem5 by doxygen 1.8.17