cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

macros.inc (1729B)


      1#include "core-isa.h"
      2
      3.macro test_suite name
      4.data
      5status: .word result
      6result: .space 1024
      7.text
      8.global main
      9.align 4
     10main:
     11.endm
     12
     13.macro reset_ps
     14    movi    a2, 0x4000f
     15    wsr     a2, ps
     16    isync
     17.endm
     18
     19.macro test_suite_end
     20    reset_ps
     21    movi    a0, status
     22    l32i    a2, a0, 0
     23    movi    a0, result
     24    sub     a2, a2, a0
     25    movi    a3, 0
     26    beqz    a2, 2f
     271:
     28    l32i    a1, a0, 0
     29    or      a3, a3, a1
     30    addi    a0, a0, 4
     31    addi    a2, a2, -1
     32    bnez    a2, 1b
     332:
     34    exit
     35.endm
     36
     37.macro print text
     38.data
     3997: .ascii "\text\n"
     4098:
     41    .align 4
     42.text
     43    movi    a2, 4
     44    movi    a3, 2
     45    movi    a4, 97b
     46    movi    a5, 98b
     47    sub     a5, a5, a4
     48    simcall
     49.endm
     50
     51.macro test_init
     52.endm
     53
     54.macro test name
     55#ifdef DEBUG
     56    print test_\name
     57#endif
     58    test_init
     59test_\name:
     60.global test_\name
     61.endm
     62
     63.macro test_end
     6499:
     65    reset_ps
     66    movi    a2, status
     67    l32i    a3, a2, 0
     68    addi    a3, a3, 4
     69    s32i    a3, a2, 0
     70.endm
     71
     72.macro exit
     73    movi    a2, 1
     74    simcall
     75.endm
     76
     77.macro test_fail
     78    movi    a2, status
     79    l32i    a2, a2, 0
     80    movi    a3, 1
     81    s32i    a3, a2, 0
     82#ifdef DEBUG
     83    print   failed
     84#endif
     85    j       99f
     86.endm
     87
     88.macro assert cond, arg1, arg2
     89    b\cond  \arg1, \arg2, 90f
     90    test_fail
     9190:
     92    nop
     93.endm
     94
     95.macro set_vector vector, addr
     96    movi    a2, handler_\vector
     97    movi    a3, \addr
     98    s32i    a3, a2, 0
     99.endm
    100
    101.macro dump r
    102#ifdef DEBUG
    103.data
    104.align 4
    1051: .word 0
    106.text
    107    movi    a4, 1b
    108    s32i    a2, a4, 0
    109    movi    a2, 4
    110    movi    a3, 1
    111    movi    a5, 4
    112    simcall
    113    movi    a4, 1b
    114    l32i    a2, a4, 0
    115#endif
    116.endm
    117
    118#define glue(a, b) _glue(a, b)
    119#define _glue(a, b) a ## b
    120
    121#define glue3(a, b, c) _glue3(a, b, c)
    122#define _glue3(a, b, c) a ## b ## c