cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

mte_helper.S (2412B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/* Copyright (C) 2020 ARM Limited */
      3
      4#include "mte_def.h"
      5
      6#define ENTRY(name) \
      7	.globl name ;\
      8	.p2align 2;\
      9	.type name, @function ;\
     10name:
     11
     12#define ENDPROC(name) \
     13	.size name, .-name ;
     14
     15	.text
     16/*
     17 * mte_insert_random_tag: Insert random tag and might be same as the source tag if
     18 *			  the source pointer has it.
     19 * Input:
     20 *		x0 - source pointer with a tag/no-tag
     21 * Return:
     22 *		x0 - pointer with random tag
     23 */
     24ENTRY(mte_insert_random_tag)
     25	irg	x0, x0, xzr
     26	ret
     27ENDPROC(mte_insert_random_tag)
     28
     29/*
     30 * mte_insert_new_tag: Insert new tag and different from the source tag if
     31 *		       source pointer has it.
     32 * Input:
     33 *		x0 - source pointer with a tag/no-tag
     34 * Return:
     35 *		x0 - pointer with random tag
     36 */
     37ENTRY(mte_insert_new_tag)
     38	gmi	x1, x0, xzr
     39	irg	x0, x0, x1
     40	ret
     41ENDPROC(mte_insert_new_tag)
     42
     43/*
     44 * mte_get_tag_address: Get the tag from given address.
     45 * Input:
     46 *		x0 - source pointer
     47 * Return:
     48 *		x0 - pointer with appended tag
     49 */
     50ENTRY(mte_get_tag_address)
     51	ldg	x0, [x0]
     52	ret
     53ENDPROC(mte_get_tag_address)
     54
     55/*
     56 * mte_set_tag_address_range: Set the tag range from the given address
     57 * Input:
     58 *		x0 - source pointer with tag data
     59 *		x1 - range
     60 * Return:
     61 *		none
     62 */
     63ENTRY(mte_set_tag_address_range)
     64	cbz	x1, 2f
     651:
     66	stg	x0, [x0, #0x0]
     67	add	x0, x0, #MT_GRANULE_SIZE
     68	sub	x1, x1, #MT_GRANULE_SIZE
     69	cbnz	x1, 1b
     702:
     71	ret
     72ENDPROC(mte_set_tag_address_range)
     73
     74/*
     75 * mt_clear_tag_address_range: Clear the tag range from the given address
     76 * Input:
     77 *		x0 - source pointer with tag data
     78 *		x1 - range
     79 * Return:
     80 *		none
     81 */
     82ENTRY(mte_clear_tag_address_range)
     83	cbz	x1, 2f
     841:
     85	stzg	x0, [x0, #0x0]
     86	add	x0, x0, #MT_GRANULE_SIZE
     87	sub	x1, x1, #MT_GRANULE_SIZE
     88	cbnz	x1, 1b
     892:
     90	ret
     91ENDPROC(mte_clear_tag_address_range)
     92
     93/*
     94 * mte_enable_pstate_tco: Enable PSTATE.TCO (tag check override) field
     95 * Input:
     96 *		none
     97 * Return:
     98 *		none
     99 */
    100ENTRY(mte_enable_pstate_tco)
    101	msr	tco, #MT_PSTATE_TCO_EN
    102	ret
    103ENDPROC(mte_enable_pstate_tco)
    104
    105/*
    106 * mte_disable_pstate_tco: Disable PSTATE.TCO (tag check override) field
    107 * Input:
    108 *		none
    109 * Return:
    110 *		none
    111 */
    112ENTRY(mte_disable_pstate_tco)
    113	msr	tco, #MT_PSTATE_TCO_DIS
    114	ret
    115ENDPROC(mte_disable_pstate_tco)
    116
    117/*
    118 * mte_get_pstate_tco: Get PSTATE.TCO (tag check override) field
    119 * Input:
    120 *		none
    121 * Return:
    122 *		x0
    123 */
    124ENTRY(mte_get_pstate_tco)
    125	mrs	x0, tco
    126	ubfx	x0, x0, #MT_PSTATE_TCO_SHIFT, #1
    127	ret
    128ENDPROC(mte_get_pstate_tco)