tyfkda / xv6

64bit port of xv6
Other
6 stars 0 forks source link

Enable floating point numbers #13

Closed tyfkda closed 6 years ago

tyfkda commented 6 years ago

Trap 6(Invalid opcode) occurred on 64bit environment. It caused by SSE?

takeharukato commented 6 years ago

Hi, tyfkda,

I'm happy to see your great work.

I met same issue before when I made my own x64 kernel. This might be caused by wrong initialization of x64 cpu in xv6. Apparently, xv6 on x64 does not set OSFXSR and OSXMMEXCPT bits when it boots. The following patch might fix this problem. Would you please give it a try.

diff --git a/kernel/entry64.S b/kernel/entry64.S
index ac6083f..713b171 100644
--- a/kernel/entry64.S
+++ b/kernel/entry64.S
@@ -92,6 +92,7 @@ entry32mp:
 # Enable PAE - CR4.PAE=1
   mov %cr4, %eax
   bts $5, %eax
+  orl $0x600, %eax      # enable OSFXSR and OSXMMEXCPT for SSE instructions
   mov %eax, %cr4
tyfkda commented 6 years ago

It works, thank you for your information!

@takeharukato , do you have a time to send me a pull request for this change? (then I can reflect your contribution to this repository).

tyfkda commented 6 years ago

I didn't see your PR #21 , I'm sorry about that.

takeharukato commented 6 years ago

Hi, tyfkda,

No, Problem. > I didn't see your PR #21 , I'm sorry about that.

I would have added a link to PR #21 on this issue. As I can show how to solve most of other issues,
I'll comment or some suggestions if I can have a time for it and if you want this. Anyway your activities are interesting, cheers!

Thanks, Regards,

tyfkda commented 6 years ago

Merged c775a5df5090f03a47ce096b07beea73dbe6a360