brintos

brintos / linux-shallow public Read only

0
0
Text · 2.4 KiB · a55dbbc Raw
131 lines · plain
1/* SPDX-License-Identifier: GPL-2.0 */2/* Copyright (C) 2020 ARM Limited */3 4#include "mte_def.h"5 6.arch	armv8.5-a+memtag7 8#define ENTRY(name) \9	.globl name ;\10	.p2align 2;\11	.type name, @function ;\12name:13 14#define ENDPROC(name) \15	.size name, .-name ;16 17	.text18/*19 * mte_insert_random_tag: Insert random tag and might be same as the source tag if20 *			  the source pointer has it.21 * Input:22 *		x0 - source pointer with a tag/no-tag23 * Return:24 *		x0 - pointer with random tag25 */26ENTRY(mte_insert_random_tag)27	irg	x0, x0, xzr28	ret29ENDPROC(mte_insert_random_tag)30 31/*32 * mte_insert_new_tag: Insert new tag and different from the source tag if33 *		       source pointer has it.34 * Input:35 *		x0 - source pointer with a tag/no-tag36 * Return:37 *		x0 - pointer with random tag38 */39ENTRY(mte_insert_new_tag)40	gmi	x1, x0, xzr41	irg	x0, x0, x142	ret43ENDPROC(mte_insert_new_tag)44 45/*46 * mte_get_tag_address: Get the tag from given address.47 * Input:48 *		x0 - source pointer49 * Return:50 *		x0 - pointer with appended tag51 */52ENTRY(mte_get_tag_address)53	ldg	x0, [x0]54	ret55ENDPROC(mte_get_tag_address)56 57/*58 * mte_set_tag_address_range: Set the tag range from the given address59 * Input:60 *		x0 - source pointer with tag data61 *		x1 - range62 * Return:63 *		none64 */65ENTRY(mte_set_tag_address_range)66	cbz	x1, 2f671:68	stg	x0, [x0, #0x0]69	add	x0, x0, #MT_GRANULE_SIZE70	sub	x1, x1, #MT_GRANULE_SIZE71	cbnz	x1, 1b722:73	ret74ENDPROC(mte_set_tag_address_range)75 76/*77 * mt_clear_tag_address_range: Clear the tag range from the given address78 * Input:79 *		x0 - source pointer with tag data80 *		x1 - range81 * Return:82 *		none83 */84ENTRY(mte_clear_tag_address_range)85	cbz	x1, 2f861:87	stzg	x0, [x0, #0x0]88	add	x0, x0, #MT_GRANULE_SIZE89	sub	x1, x1, #MT_GRANULE_SIZE90	cbnz	x1, 1b912:92	ret93ENDPROC(mte_clear_tag_address_range)94 95/*96 * mte_enable_pstate_tco: Enable PSTATE.TCO (tag check override) field97 * Input:98 *		none99 * Return:100 *		none101 */102ENTRY(mte_enable_pstate_tco)103	msr	tco, #MT_PSTATE_TCO_EN104	ret105ENDPROC(mte_enable_pstate_tco)106 107/*108 * mte_disable_pstate_tco: Disable PSTATE.TCO (tag check override) field109 * Input:110 *		none111 * Return:112 *		none113 */114ENTRY(mte_disable_pstate_tco)115	msr	tco, #MT_PSTATE_TCO_DIS116	ret117ENDPROC(mte_disable_pstate_tco)118 119/*120 * mte_get_pstate_tco: Get PSTATE.TCO (tag check override) field121 * Input:122 *		none123 * Return:124 *		x0125 */126ENTRY(mte_get_pstate_tco)127	mrs	x0, tco128	ubfx	x0, x0, #MT_PSTATE_TCO_SHIFT, #1129	ret130ENDPROC(mte_get_pstate_tco)131