gem5  v19.0.0.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 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 // Authors: Jordi Vaquero
39 
40 #ifndef __ARCH_ARM_PAUTH_HELPERS_HH__
41 #define __ARCH_ARM_PAUTH_HELPERS_HH__
42 
43 #include "arch/arm/qarma.hh"
44 #include "arch/arm/system.hh"
45 #include "arch/arm/types.hh"
46 #include "arch/arm/utility.hh"
47 #include "base/bitfield.hh"
48 #include "base/bitunion.hh"
49 #include "cpu/thread_context.hh"
50 
51 namespace ArmISA
52 {
53 
54  inline bool
56  {
57  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
58  return (el == EL1 || el == EL0 || (el == EL2 && hcr.e2h == 1));
59  }
60 
61  bool
62  calculateTBI(ThreadContext* tc, ExceptionLevel el, uint64_t ptr, bool data);
63 
64  int
65  calculateBottomPACBit(ThreadContext* tc, ExceptionLevel el, bool top_bit);
66 
67  Fault
69 
70 
71 
72  // AddPAC()
73  // ========
74  // Calculates the pointer authentication code for a 64-bit quantity
75  // and then inserts that into pointer authentication code field of that
76  // 64-bit quantity.
77 
78  uint64_t
79  addPAC (ThreadContext* tc, ExceptionLevel el, uint64_t ptr,
80  uint64_t modifier, uint64_t k1, uint64_t k0, bool data);
81 
82 
83  uint64_t
84  auth(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier,
85  uint64_t k1, uint64_t K0, bool data, uint8_t errorcode);
86 
87  Fault
88  authDA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
89 
90  Fault
91  authDB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
92 
93 
94  Fault
95  authIA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
96 
97  Fault
98  authIB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
99 
100  Fault
101  addPACDA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
102 
103  Fault
104  addPACDB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
105 
106  Fault
107  addPACGA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
108 
109  Fault
110  addPACIA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
111 
112  Fault
113  addPACIB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
114 
115  // Strip()
116  // =======
117  // Strip() 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 
123  Fault
124  stripPAC(ThreadContext* tc, uint64_t A, bool data, uint64_t* out);
125 
126 };
127 #endif //__ARCH_ARM_PAUTH_HELPERS_HH__
Fault authIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
bool upperAndLowerRange(ThreadContext *tc, ExceptionLevel el)
Fault authIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: ccregs.hh:42
Fault addPACGA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault stripPAC(ThreadContext *tc, uint64_t A, bool data, uint64_t *out)
ThreadContext is the external interface to all thread state for anything outside of the CPU...
ExceptionLevel
Definition: types.hh:585
Bitfield< 15, 0 > X
Definition: int.hh:55
Bitfield< 3, 2 > el
Fault addPACDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault authDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault addPACDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
int calculateBottomPACBit(ThreadContext *tc, ExceptionLevel el, bool top_bit)
uint64_t addPAC(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier, uint64_t k1, uint64_t k0, bool data)
Fault trapPACUse(ThreadContext *tc, ExceptionLevel el)
Bitfield< 2, 0 > k0
bool calculateTBI(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, bool data)
Fault addPACIB(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)
Fault addPACIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Fault authDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
virtual RegVal readMiscReg(RegIndex misc_reg)=0
const char data[]
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240

Generated on Fri Feb 28 2020 16:26:57 for gem5 by doxygen 1.8.13