xref: /linux/tools/testing/selftests/arm64/pauth/helper.c (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2020 ARM Limited
3 
4 #include "helper.h"
5 
6 size_t keyia_sign(size_t ptr)
7 {
8 	asm volatile("paciza %0" : "+r" (ptr));
9 	return ptr;
10 }
11 
12 size_t keyib_sign(size_t ptr)
13 {
14 	asm volatile("pacizb %0" : "+r" (ptr));
15 	return ptr;
16 }
17 
18 size_t keyda_sign(size_t ptr)
19 {
20 	asm volatile("pacdza %0" : "+r" (ptr));
21 	return ptr;
22 }
23 
24 size_t keydb_sign(size_t ptr)
25 {
26 	asm volatile("pacdzb %0" : "+r" (ptr));
27 	return ptr;
28 }
29 
30 size_t keyg_sign(size_t ptr)
31 {
32 	/* output is encoded in the upper 32 bits */
33 	size_t dest = 0;
34 	size_t modifier = 0;
35 
36 	asm volatile("pacga %0, %1, %2" : "=r" (dest) : "r" (ptr), "r" (modifier));
37 
38 	return dest;
39 }
40