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_sfgts.c (657B)


      1#include <stdio.h>
      2
      3int main(void)
      4{
      5    int a, b, c;
      6    int result;
      7
      8    a = 0;
      9    b = 3;
     10    result = 1;
     11    __asm
     12    ("1:\n\t"
     13     "l.addi   %0, %0, 1\n\t"
     14     "l.sfgts  %0, %1\n\t"
     15     "l.bf 1b\n\t"
     16     "l.nop\n\t"
     17     : "+r"(a)
     18     : "r"(b)
     19    );
     20    if (a != result) {
     21        printf("sfgts error\n");
     22        return -1;
     23    }
     24
     25
     26    a = 0xff;
     27    b = 3;
     28    c = 1;
     29    result = 3;
     30    __asm
     31    ("1:\n\t"
     32     "l.sub    %0, %0, %2\n\t"
     33     "l.sfgts  %0, %1\n\t"
     34     "l.bf 1b\n\t"
     35     "l.nop\n\t"
     36     : "+r"(a)
     37     : "r"(b), "r"(c)
     38    );
     39    if (a != result) {
     40        printf("sfgts error\n");
     41        return -1;
     42    }
     43
     44    return 0;
     45}