Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Agares wrote:info gdt says base is 0x0 and limit 65535.
This makes me wonder if it crashed before the LGDT was executed.
Agares wrote:So my question is: what's going on? What did I do wrong? Where the hell did that xgetbv come from?
Maybe the CPU is executing "trash" and the xgetbv has nothing to do with the problem. Maybe Visual Studio 2010 thinks it should be able to use AVX instructions.
My advice is to use Bochs debugger and put "xchg bx,bx" breakpoints wherever they make it easier to step through the code (e.g. immediately before the "lgdt"); so you can figure out where things go wrong.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
After the "00045560726e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown" line, everything you read from Bochs will have been reset to the startup state.
I'd start by investigating why exception 0x6 is triggered.
OK. Thank you both very much for your help. My problem was, that I did lgdt eax, instead of lgdt [eax] (I still don't know why was is it interpreted as xgetbv). But that only happend accidentaly, while debugging. The real problem is that my GDT descriptors are wrong. What i thought before is that "info gdt" AFTER the exception will give me the state before the exception, so thanks for pointing that.
> I still don't know why was is it interpreted as xgetbv
These descriptor-registers instructions accept only memory-type operands and other encodings are reserved (i.e. cause illegal opcode exceptions) or decoded as other instructions (seems that it's your case).
Only question is "why did your compiler blindly generated encoding w/o any checks and warnings", although it's rather obvios: developers didn't waste time on checks about such rare instructions that are used by people who know deeply what they are doing".