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_lf_gts.c (1519B)


      1#include <stdio.h>
      2
      3int main(void)
      4{
      5    int a, result;
      6    float b, c;
      7
      8    a = 0;
      9    b = 122.5;
     10    c = 123.5;
     11    result = 0x1;
     12    __asm
     13    ("lfgts:\n\t"
     14     "l.addi    %0, %0, 0x1\n\t"
     15     "lf.sfgt.s %1, %2\n\t"
     16     "l.bf      lfgts\n\t"
     17     "l.nop\n\t"
     18     : "+r"(a)
     19     : "r"(b), "r"(c)
     20    );
     21    if (a != result) {
     22        printf("lf.sfgt.s error\n");
     23        return -1;
     24    }
     25
     26    b = 133.5;
     27    c = 13.5;
     28    result = 0x1;
     29    __asm
     30    ("lf.sfgt.s %1, %2\n\t"
     31     "l.bf      1f\n\t"
     32     "l.nop\n\t"
     33     "l.addi    %0, %0, 0x1\n\t"
     34     "l.addi    %0, %0, 0x1\n\t"
     35     "1:\n\t"
     36     : "+r"(a)
     37     : "r"(b), "r"(c)
     38    );
     39    if (a != result) {
     40        printf("lf.sfgt.s error\n");
     41        return -1;
     42    }
     43
     44/*    int a, result;
     45    double b, c;
     46
     47    a = 0;
     48    b = 122.5;
     49    c = 123.5;
     50    result = 0x1;
     51    __asm
     52    ("lfgtd:\n\t"
     53     "l.addi    %0, %0, 0x1\n\t"
     54     "lf.sfgt.d %1, %2\n\t"
     55     "l.bf      lfgtd\n\t"
     56     "l.nop\n\t"
     57     : "+r"(a)
     58     : "r"(b), "r"(c)
     59    );
     60    if (a != result) {
     61        printf("lf.sfgt.d error\n");
     62        return -1;
     63    }
     64
     65    b = 133.5;
     66    c = 13.5;
     67    result = 0x3;
     68    __asm
     69    ("l.addi    %0, %0, 0x1\n\t"
     70     "l.addi    %0, %0, 0x1\n\t"
     71     "lf.sfgt.d %1, %2\n\t"
     72     "l.bf      1f\n\t"
     73     "l.nop\n\t"
     74     "l.addi    %0, %0, 0x1\n\t"
     75     "l.addi    %0, %0, 0x1\n\t"
     76     "1:\n\t"
     77     : "+r"(a)
     78     : "r"(b), "r"(c)
     79    );
     80    if (a != result) {
     81        printf("lf.sfgt.d error, %x\n", a);
     82        return -1;
     83    }*/
     84
     85    return 0;
     86}