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_r2_mul_ph.c (833B)


      1#include<stdio.h>
      2#include<assert.h>
      3
      4int main()
      5{
      6    int rd, rs, rt, dsp;
      7    int result, resultdsp;
      8
      9    rs = 0x03FB1234;
     10    rt = 0x0BCC4321;
     11    result = 0xF504F4B4;
     12    resultdsp = 1;
     13
     14    __asm
     15        ("mul.ph %0, %2, %3\n\t"
     16         "rddsp %1\n\t"
     17         : "=r"(rd), "=r"(dsp)
     18         : "r"(rs), "r"(rt)
     19        );
     20    dsp = (dsp >> 21) & 0x01;
     21    assert(rd  == result);
     22    assert(dsp == resultdsp);
     23
     24    dsp = 0;
     25    __asm
     26        ("wrdsp %0\n\t"
     27         :
     28         : "r"(dsp)
     29        );
     30
     31    rs = 0x00210010;
     32    rt = 0x00110005;
     33    result = 0x2310050;
     34    resultdsp = 0;
     35
     36    __asm
     37        ("mul.ph %0, %2, %3\n\t"
     38         "rddsp %1\n\t"
     39         : "=r"(rd), "=r"(dsp)
     40         : "r"(rs), "r"(rt)
     41        );
     42    dsp = (dsp >> 21) & 0x01;
     43    assert(rd  == result);
     44    assert(dsp == resultdsp);
     45
     46    return 0;
     47}