@@ -169,9 +169,77 @@ os.environ['UNICORN_LOG_DETAIL_LEVEL'] = "1" # full filename with line info
169
169
Please note that file names are statically compiled in and can reveal the paths
170
170
of the file system used during compilation.
171
171
172
+ ## Does Unicorn support ARM PAC (Pointer Authentication)?
173
+
174
+ Yes! However, Unicorn by default disables it and enabling it involves a few coding and document reading.
175
+
176
+ TLDR:
177
+
178
+ Taken from [ #1789 ] ( https://github.com/unicorn-engine/unicorn/issues/1789 ) .
179
+
180
+ ``` C
181
+ uc_arm64_cp_reg reg;
182
+
183
+ // SCR_EL3
184
+ reg.op0 = 0b11 ;
185
+ reg.op1 = 0b110 ;
186
+ reg.crn = 0b0001 ;
187
+ reg.crm = 0b0001 ;
188
+ reg.op2 = 0b000 ;
189
+
190
+ err = uc_reg_read(uc, UC_ARM64_REG_CP_REG, ®);
191
+ assert (err == UC_ERR_OK);
192
+
193
+ // NS && RW && API
194
+ reg.val |= (1 | (1<<10) | (1<<17));
195
+
196
+ err = uc_reg_write(uc, UC_ARM64_REG_CP_REG, ®);
197
+ assert(err == UC_ERR_OK);
198
+
199
+ // SCTLR_EL1
200
+ reg.op0 = 0b11;
201
+ reg.op1 = 0b000;
202
+ reg.crn = 0b0001;
203
+ reg.crm = 0b0000;
204
+ reg.op2 = 0b000;
205
+
206
+ err = uc_reg_read(uc, UC_ARM64_REG_CP_REG, ®);
207
+ assert(err == UC_ERR_OK);
208
+
209
+ // EnIA && EnIB
210
+ reg.val |= (1<<31) | (1<<30);
211
+
212
+ err = uc_reg_write(uc, UC_ARM64_REG_CP_REG, ®);
213
+ assert(err == UC_ERR_OK);
214
+
215
+ // HCR_EL2
216
+ reg.op0 = 0b11;
217
+ reg.op1 = 0b100;
218
+ reg.crn = 0b0001;
219
+ reg.crm = 0b0001;
220
+ reg.op2 = 0b000;
221
+
222
+ // HCR.API
223
+ reg.val |= (1ULL<<41);
224
+
225
+ err = uc_reg_write(uc, UC_ARM64_REG_CP_REG, ®);
226
+ assert(err == UC_ERR_OK);
227
+ ```
228
+
229
+ For further explanation, refer to related ARM documents. Here is an incomplete list:
230
+
231
+ - [System register control of pointer authentication](https://developer.arm.com/documentation/ddi0487/latest/)
232
+ - [EnIA & EnIB](https://developer.arm.com/documentation/ddi0595/2021-12/AArch64-Registers/SCTLR-EL1--System-Control-Register--EL1-?lang=en#fieldset_0-31_31-1)
233
+ - [HCR.API](https://developer.arm.com/documentation/ddi0601/2020-12/AArch64-Registers/HCR-EL2--Hypervisor-Configuration-Register?lang=en#fieldset_0-41_41-1)
234
+ Note you could find the definitions of these registers at the end of corresponding documents.
235
+
236
+ ## I debug my application but soon get an access violation inside unicorn.
237
+
238
+ This is intended for Windows. See discussion in [#1841](https://github.com/unicorn-engine/unicorn/issues/1841).
239
+
172
240
## My code does not do what I would expect - is this a bug?
173
241
174
- Please create an github issue and provide as much details as possible.
242
+ Please create a github issue and provide as many details as possible.
175
243
176
244
- [ ] Simplified version of your script / source
177
245
- Make sure that "no" external dependencies are needed.
0 commit comments