gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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__
gem5::ArmISA::trapPACUse
Fault trapPACUse(ThreadContext *tc, ExceptionLevel el)
Definition: pauth_helpers.cc:117
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:636
gem5::ArmISA::addPACIB
Fault addPACIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:804
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::ArmISA::el
Bitfield< 3, 2 > el
Definition: misc_types.hh:73
gem5::ArmISA::stripPAC
void stripPAC(ThreadContext *tc, uint64_t A, bool data, uint64_t *out)
Definition: pauth_helpers.cc:866
gem5::ArmISA::EL1
@ EL1
Definition: types.hh:274
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:135
types.hh
gem5::ArmISA::addPACDA
Fault addPACDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:572
bitfield.hh
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
gem5::Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
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:422
gem5::ArmISA::upperAndLowerRange
bool upperAndLowerRange(ThreadContext *tc, ExceptionLevel el)
Definition: pauth_helpers.hh:57
gem5::ArmISA::EL2
@ EL2
Definition: types.hh:275
bitunion.hh
gem5::ArmISA::authIB
Fault authIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:496
utility.hh
gem5::ArmISA::addPACGA
Fault addPACGA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:697
gem5::ArmISA::EL0
@ EL0
Definition: types.hh:273
gem5::ArmISA::calculateTBI
bool calculateTBI(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, bool data)
Definition: pauth_helpers.cc:50
gem5::MipsISA::int_reg::K0
constexpr RegId K0
Definition: int.hh:168
gem5::ArmISA::authDB
Fault authDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:352
gem5::ArmISA::MISCREG_HCR_EL2
@ MISCREG_HCR_EL2
Definition: misc.hh:591
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:227
gem5::SparcISA::int_reg::Y
constexpr RegId Y
Definition: int.hh:131
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::X86ISA::X
Bitfield< 15, 0 > X
Definition: int.hh:58
thread_context.hh
gem5::ArmISA::addPACIA
Fault addPACIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:745
gem5::ArmISA::authDA
Fault authDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:284
gem5::ArmISA::ExceptionLevel
ExceptionLevel
Definition: types.hh:271
gem5::ArmISA::calculateBottomPACBit
int calculateBottomPACBit(ThreadContext *tc, ExceptionLevel el, bool top_bit)
Definition: pauth_helpers.cc:80

Generated on Sun Jul 30 2023 01:56:49 for gem5 by doxygen 1.8.17