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_shll_ph.c (1073B)


      1#include<stdio.h>
      2#include<assert.h>
      3
      4int main()
      5{
      6    int rd, rt, dsp;
      7    int result, resultdsp;
      8
      9    rt        = 0x12345678;
     10    result    = 0xA000C000;
     11    resultdsp = 1;
     12
     13    __asm
     14        ("wrdsp $0\n\t"
     15         "shll.ph %0, %2, 0x0B\n\t"
     16         "rddsp %1\n\t"
     17         : "=r"(rd), "=r"(dsp)
     18         : "r"(rt)
     19        );
     20    dsp = (dsp >> 22) & 0x01;
     21    assert(dsp == resultdsp);
     22    assert(rd  == result);
     23
     24    rt        = 0x7fff8000;
     25    result    = 0xfffe0000;
     26    resultdsp = 1;
     27
     28    __asm
     29        ("wrdsp $0\n\t"
     30         "shll.ph %0, %2, 0x01\n\t"
     31         "rddsp %1\n\t"
     32         : "=r"(rd), "=r"(dsp)
     33         : "r"(rt)
     34        );
     35    dsp = (dsp >> 22) & 0x01;
     36    assert(dsp == resultdsp);
     37    assert(rd  == result);
     38
     39    rt        = 0x00000001;
     40    result    = 0x00008000;
     41    resultdsp = 1;
     42
     43    __asm
     44        ("wrdsp $0\n\t"
     45         "shll.ph %0, %2, 0x0F\n\t"
     46         "rddsp %1\n\t"
     47         : "=r"(rd), "=r"(dsp)
     48         : "r"(rt)
     49        );
     50    dsp = (dsp >> 22) & 0x01;
     51    assert(dsp == resultdsp);
     52    assert(rd  == result);
     53
     54    return 0;
     55}