gem5  v20.1.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 ArmISA
50 {
51 
52  inline bool
54  {
55  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
56  return (el == EL1 || el == EL0 || (el == EL2 && hcr.e2h == 1));
57  }
58 
59  bool
60  calculateTBI(ThreadContext* tc, ExceptionLevel el, uint64_t ptr, bool data);
61 
62  int
64 
65  Fault
67 
68 
69 
70  // AddPAC()
71  // ========
72  // Calculates the pointer authentication code for a 64-bit quantity
73  // and then inserts that into pointer authentication code field of that
74  // 64-bit quantity.
75 
76  uint64_t
77  addPAC (ThreadContext* tc, ExceptionLevel el, uint64_t ptr,
78  uint64_t modifier, uint64_t k1, uint64_t k0, bool data);
79 
80 
81  uint64_t
82  auth(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, uint64_t modifier,
83  uint64_t k1, uint64_t K0, bool data, uint8_t errorcode);
84 
85  Fault
86  authDA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
87 
88  Fault
89  authDB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
90 
91 
92  Fault
93  authIA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
94 
95  Fault
96  authIB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
97 
98  Fault
99  addPACDA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
100 
101  Fault
102  addPACDB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
103 
104  Fault
105  addPACGA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
106 
107  Fault
108  addPACIA(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
109 
110  Fault
111  addPACIB(ThreadContext* tc, uint64_t X, uint64_t Y, uint64_t* out);
112 
113  // Strip()
114  // =======
115  // Strip() returns a 64-bit value containing A, but replacing the
116  // pointer authentication code field bits with the extension of the
117  // address bits. This can apply to either instructions or data, where,
118  // as the use of tagged pointers is distinct, it might be
119  // handled differently.
120 
121  Fault
122  stripPAC(ThreadContext* tc, uint64_t A, bool data, uint64_t* out);
123 
124 };
125 #endif //__ARCH_ARM_PAUTH_HELPERS_HH__
ArmISA::trapPACUse
Fault trapPACUse(ThreadContext *tc, ExceptionLevel el)
Definition: pauth_helpers.cc:114
ArmISA::EL2
@ EL2
Definition: types.hh:624
data
const char data[]
Definition: circlebuf.test.cc:42
ArmISA::calculateTBI
bool calculateTBI(ThreadContext *tc, ExceptionLevel el, uint64_t ptr, bool data)
Definition: pauth_helpers.cc:47
ArmISA::addPACGA
Fault addPACGA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:692
ArmISA::EL0
@ EL0
Definition: types.hh:622
ArmISA::upperAndLowerRange
bool upperAndLowerRange(ThreadContext *tc, ExceptionLevel el)
Definition: pauth_helpers.hh:53
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:222
ArmISA::stripPAC
Fault stripPAC(ThreadContext *tc, uint64_t A, bool data, uint64_t *out)
Definition: pauth_helpers.cc:861
X86ISA::X
Bitfield< 15, 0 > X
Definition: int.hh:53
qarma.hh
system.hh
ArmISA::addPACDA
Fault addPACDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:567
ArmISA
Definition: ccregs.hh:41
types.hh
ArmISA::calculateBottomPACBit
int calculateBottomPACBit(ThreadContext *tc, ExceptionLevel el, bool top_bit)
Definition: pauth_helpers.cc:77
ArmISA::authIB
Fault authIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:491
ArmISA::authIA
Fault authIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:417
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ArmISA::addPACDB
Fault addPACDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:631
bitfield.hh
ArmISA::ExceptionLevel
ExceptionLevel
Definition: types.hh:621
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:130
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
bitunion.hh
ArmISA::el
Bitfield< 3, 2 > el
Definition: miscregs_types.hh:69
ArmISA::MISCREG_HCR_EL2
@ MISCREG_HCR_EL2
Definition: miscregs.hh:578
ArmISA::EL1
@ EL1
Definition: types.hh:623
utility.hh
ThreadContext::readMiscReg
virtual RegVal readMiscReg(RegIndex misc_reg)=0
MipsISA::k0
Bitfield< 2, 0 > k0
Definition: pra_constants.hh:226
ArmISA::authDB
Fault authDB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:347
ArmISA::addPACIB
Fault addPACIB(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:799
ArmISA::addPACIA
Fault addPACIA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:740
ArmISA::authDA
Fault authDA(ThreadContext *tc, uint64_t X, uint64_t Y, uint64_t *out)
Definition: pauth_helpers.cc:279
thread_context.hh

Generated on Wed Sep 30 2020 14:02:01 for gem5 by doxygen 1.8.17