Path: blob/master/tools/testing/selftests/arm64/mte/mte_helper.S
26296 views
/* SPDX-License-Identifier: GPL-2.0 */1/* Copyright (C) 2020 ARM Limited */23#include "mte_def.h"45.arch armv8.5-a+memtag67#define ENTRY(name) \8.globl name ;\9.p2align 2;\10.type name, @function ;\11name:1213#define ENDPROC(name) \14.size name, .-name ;1516.text17/*18* mte_insert_random_tag: Insert random tag and might be same as the source tag if19* the source pointer has it.20* Input:21* x0 - source pointer with a tag/no-tag22* Return:23* x0 - pointer with random tag24*/25ENTRY(mte_insert_random_tag)26irg x0, x0, xzr27ret28ENDPROC(mte_insert_random_tag)2930/*31* mte_insert_new_tag: Insert new tag and different from the source tag if32* source pointer has it.33* Input:34* x0 - source pointer with a tag/no-tag35* Return:36* x0 - pointer with random tag37*/38ENTRY(mte_insert_new_tag)39gmi x1, x0, xzr40irg x0, x0, x141ret42ENDPROC(mte_insert_new_tag)4344/*45* mte_get_tag_address: Get the tag from given address.46* Input:47* x0 - source pointer48* Return:49* x0 - pointer with appended tag50*/51ENTRY(mte_get_tag_address)52ldg x0, [x0]53ret54ENDPROC(mte_get_tag_address)5556/*57* mte_set_tag_address_range: Set the tag range from the given address58* Input:59* x0 - source pointer with tag data60* x1 - range61* Return:62* none63*/64ENTRY(mte_set_tag_address_range)65cbz x1, 2f661:67stg x0, [x0, #0x0]68add x0, x0, #MT_GRANULE_SIZE69sub x1, x1, #MT_GRANULE_SIZE70cbnz x1, 1b712:72ret73ENDPROC(mte_set_tag_address_range)7475/*76* mt_clear_tag_address_range: Clear the tag range from the given address77* Input:78* x0 - source pointer with tag data79* x1 - range80* Return:81* none82*/83ENTRY(mte_clear_tag_address_range)84cbz x1, 2f851:86stzg x0, [x0, #0x0]87add x0, x0, #MT_GRANULE_SIZE88sub x1, x1, #MT_GRANULE_SIZE89cbnz x1, 1b902:91ret92ENDPROC(mte_clear_tag_address_range)9394/*95* mte_enable_pstate_tco: Enable PSTATE.TCO (tag check override) field96* Input:97* none98* Return:99* none100*/101ENTRY(mte_enable_pstate_tco)102msr tco, #MT_PSTATE_TCO_EN103ret104ENDPROC(mte_enable_pstate_tco)105106/*107* mte_disable_pstate_tco: Disable PSTATE.TCO (tag check override) field108* Input:109* none110* Return:111* none112*/113ENTRY(mte_disable_pstate_tco)114msr tco, #MT_PSTATE_TCO_DIS115ret116ENDPROC(mte_disable_pstate_tco)117118/*119* mte_get_pstate_tco: Get PSTATE.TCO (tag check override) field120* Input:121* none122* Return:123* x0124*/125ENTRY(mte_get_pstate_tco)126mrs x0, tco127ubfx x0, x0, #MT_PSTATE_TCO_SHIFT, #1128ret129ENDPROC(mte_get_pstate_tco)130131132