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_extx.c (1168B)


      1#include <stdio.h>
      2
      3int main(void)
      4{
      5    int a, b;
      6    int result;
      7
      8    b = 0x83;
      9    result = 0xffffff83;
     10    __asm
     11    ("l.extbs  %0, %1\n\t"
     12     : "=r"(a)
     13     : "r"(b)
     14    );
     15    if (a != result) {
     16        printf("extbs error\n");
     17        return -1;
     18    }
     19
     20    result = 0x83;
     21    __asm
     22    ("l.extbz  %0, %1\n\t"
     23     : "=r"(a)
     24     : "r"(b)
     25    );
     26    if (a != result) {
     27        printf("extbz error\n");
     28        return -1;
     29    }
     30
     31    b = 0x8083;
     32    result = 0xffff8083;
     33    __asm
     34    ("l.exths  %0, %1\n\t"
     35     : "=r"(a)
     36     : "r"(b)
     37    );
     38    if (a != result) {
     39        printf("exths error\n");
     40        return -1;
     41    }
     42
     43    result = 0x8083;
     44    __asm
     45    ("l.exthz  %0, %1\n\t"
     46     : "=r"(a)
     47     : "r"(b)
     48    );
     49    if (a != result) {
     50        printf("exthz error\n");
     51        return -1;
     52    }
     53
     54    b = 0x11;
     55    result = 0x11;
     56    __asm
     57    ("l.extws  %0, %1\n\t"
     58     : "=r"(a)
     59     : "r"(b)
     60    );
     61
     62    if (a != result) {
     63        printf("extws error\n");
     64        return -1;
     65    }
     66
     67    __asm
     68    ("l.extwz  %0, %1\n\t"
     69     : "=r"(a)
     70     : "r"(b)
     71    );
     72    if (a != result) {
     73        printf("extwz error\n");
     74        return -1;
     75    }
     76
     77    return 0;
     78}