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

test_dsp_r1_extpv.c (860B)


      1#include<stdio.h>
      2#include<assert.h>
      3
      4int main()
      5{
      6    int rt, ac, ach, acl, dsp;
      7    int result;
      8
      9    ach = 0x05;
     10    acl = 0xB4CB;
     11    dsp = 0x07;
     12    ac  = 0x03;
     13    result = 0x000C;
     14
     15    __asm
     16        ("wrdsp %1, 0x01\n\t"
     17         "mthi %2, $ac1\n\t"
     18         "mtlo %3, $ac1\n\t"
     19         "extpv %0, $ac1, %4\n\t"
     20         "rddsp %1\n\t"
     21         : "=r"(rt), "+r"(dsp)
     22         : "r"(ach), "r"(acl), "r"(ac)
     23        );
     24    dsp = (dsp >> 14) & 0x01;
     25    assert(dsp == 0);
     26    assert(result == rt);
     27
     28    ach = 0x05;
     29    acl = 0xB4CB;
     30    dsp = 0x01;
     31
     32    __asm
     33        ("wrdsp %1, 0x01\n\t"
     34         "mthi %2, $ac1\n\t"
     35         "mtlo %3, $ac1\n\t"
     36         "extpv %0, $ac1, %4\n\t"
     37         "rddsp %1\n\t"
     38         : "=r"(rt), "+r"(dsp)
     39         : "r"(ach), "r"(acl), "r"(ac)
     40        );
     41    dsp = (dsp >> 14) & 0x01;
     42    assert(dsp == 1);
     43
     44    return 0;
     45}