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_bf.c (749B)


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