Skip to content

Commit

Permalink
Implement cpuid
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed May 25, 2018
1 parent 392da98 commit feeb59f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
30 changes: 30 additions & 0 deletions emu/gadgets-x86/misc.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,33 @@
.gadget rdtsc
rdtsc
gret

.gadget cpuid
push %rsi
push %rdi
push %r8
push %r9
push %r10
push %r11
subq $0x10, %rsp
movl %eax, 0xc(%rsp)
movl %ebx, 0x8(%rsp)
movl %ecx, 0x4(%rsp)
movl %edx, 0x0(%rsp)
leaq 0xc(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x4(%rsp), %rdx
leaq 0x0(%rsp), %rcx
call do_the_cpuid
movl 0xc(%rsp), %eax
movl 0x8(%rsp), %ebx
movl 0x4(%rsp), %ecx
movl 0x0(%rsp), %edx
addq $0x10, %rsp
pop %r11
pop %r10
pop %r9
pop %r8
pop %rdi
pop %rsi
gret
7 changes: 6 additions & 1 deletion emu/gen.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <assert.h>
#include "emu/modrm.h"
#include "emu/gen.h"
#include "emu/cpuid.h"
#include "emu/interrupt.h"

// This should stay in sync with the definition of .gadget_array in gadgets.h
Expand Down Expand Up @@ -226,7 +227,7 @@ static inline void gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a
#define XADD(src, dst,z) UNDEFINED

#define RDTSC g(rdtsc)
#define CPUID() UNDEFINED
#define CPUID() g(cpuid)

// sse
#define XORP(src, dst) UNDEFINED
Expand Down Expand Up @@ -280,3 +281,7 @@ static inline void gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a
#define OP_SIZE 16
#include "emu/decode.h"
#undef OP_SIZE

void do_the_cpuid(dword_t *a, dword_t *b, dword_t *c, dword_t *d) {
do_cpuid(a, b, c, d);
}

0 comments on commit feeb59f

Please sign in to comment.