holbe@ideapad ~ % cat via-rng-test.c #include #include static inline unsigned long xstore(unsigned long *addr, unsigned long edx) { unsigned long eax_out; unsigned long ecx = 0xaa55aa55; int ts_state; printf("ecx: %08lx\tedx: %08lx\tedi: %p\n", ecx, edx, addr); asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */" : "=m" (*addr), "=a" (eax_out), "+D" (addr), "+d" (edx), "+c" (ecx)); printf("ecx: %08lx\tedx: %08lx\tedi: %p\n", ecx, edx, addr); return eax_out; } int main(void) { unsigned long addr[8]; memset(addr, 0, sizeof(addr)); printf("%p: %08lx\n", addr, *(unsigned long *)addr); xstore(addr, 0xffffff03); /* 8 rand bits, 32 stored bits */ printf("%p: %08lx\n", addr, *(unsigned long *)addr); return 0; } holbe@ideapad ~ % gcc -o via-rng-test via-rng-test.c holbe@ideapad ~ % ./via-rng-test 0xbff09d40: 00000000 ecx: aa55aa55 edx: ffffff03 edi: 0xbff09d40 ecx: aa55aa55 edx: 00000003 edi: 0xbff09d48 0xbff09d40: 339d4525 holbe@ideapad ~ %