I am trying to enable sse so I can use the xmm registers in fast memory copy.
I have a problem that whenever I call fxsave on qemu/kvm the machine reboots.
I tried it on bochs and it generates a lot of errors with the same message
Code: Select all
08153109086e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109145e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109204e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109263e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109322e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109381e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109440e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109499e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109558e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109617e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109676e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109735e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109794e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109853e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109912e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153109971e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153110030e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153110089e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
08153110148e[CPU0 ] write_linear_xmmword_aligned(): #GP misaligned access
(0).[8153110175] [0x00000001c3c3] 0008:000000000001c3c3 (unk. ctxt): call rax ; ffd0
08153110175e[CPU0 ] exception(): 3rd (14) exception with no resolution, shutdown status is 00h, resetting
Next at t=8153110176
(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b ; ea5be000f0
I have initialized sse following OSdev wiki as follows:
Code: Select all
mov eax, cr0
and ax, 0xFFFB
or ax, 0x2
mov cr0, eax
mov eax, cr4
or ax, 3 << 9
mov cr4, eax
I call the following inside my interrupt handler:
Code: Select all
extern "C" void idt_handler(InterruptContext * p_interruptContext)
{
asm volatile(" fxsave %0; "::"m"((uint64_t)fxsave_region));
.
.
.
.
.
.
.
.
.
asm volatile(" fxrstor %0; "::"m"((uint64_t)fxsave_region));
}
If any body can point out what might be the problem, I highly appreciate it.
Thanks.
Karim.