Hello!
I occurred a weird problem today, it is that I get a Undefined opcode interrupt whenever gcc uses a xmm register, even though bochs says mmx is supported (here)
This problem didn't occur before because I had the -mno-mmx flag set. But now I took reference (aka copied) the flags from ToaruOS and I got this error, so why is xmm registers crashing the computer? These are my cc flags https://github.com/cheyao/AchieveOS/blo ... akefile#L5 (The ones commented out were part of my old flags)
Undefined opcode
Re: Undefined opcode
Did you enable SSE? To my knowledge, there is a flag in CR4 that needs to be set. If not then all references to SSE registers will cause an undefined opcode exception.
Carpe diem!
-
- Member
- Posts: 78
- Joined: Tue Jun 07, 2022 11:23 am
- Libera.chat IRC: Cyao
- Location: France
- Contact:
Re: Undefined opcode
Ahh yes that was the problem! Didn't know that SSE was the same as MMX. Thanks for telling!nullplan wrote:Did you enable SSE? To my knowledge, there is a flag in CR4 that needs to be set. If not then all references to SSE registers will cause an undefined opcode exception.
Re: Undefined opcode
It isn't. MMX was the stuff with the MM registers (MM0-MM7, mapped to the FPU registers), whereas SSE was the stuff with the XMM registers. Different registers, different instructions. And then came AVX, which extended the XMM registers to the YMM registers, and now AVX512 extended it again to the ZMM registers. And also the register file now exceeds 2kB in size. Don't know what they will come up with next.Cyao wrote:Didn't know that SSE was the same as MMX. Thanks for telling!
MMX is rarely worth the effort these days, since the MM registers are only 64-bit and you can get that from the GP registers already.
Carpe diem!
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Undefined opcode
Also, enabling SSE in your kernel means you need to save and restore the SSE registers on kernel entry and exit.
Using SSE in your kernel can actually hurt performance, since you need to save and restore the SSE registers on every kernel entry and exit instead of only when switching tasks.
Using SSE in your kernel can actually hurt performance, since you need to save and restore the SSE registers on every kernel entry and exit instead of only when switching tasks.
-
- Member
- Posts: 78
- Joined: Tue Jun 07, 2022 11:23 am
- Libera.chat IRC: Cyao
- Location: France
- Contact:
Re: Undefined opcode
Why do I need to store them? Is this for multitasking or it also applies to my singletasking OS?Octocontrabass wrote:Also, enabling SSE in your kernel means you need to save and restore the SSE registers on kernel entry and exit.
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Undefined opcode
Interrupts can happen at any time, including while a program is using SSE registers. Doesn't your kernel handle interrupts?
...And what's the point of a single-tasking OS when modern CPUs have so many cores?
...And what's the point of a single-tasking OS when modern CPUs have so many cores?
-
- Member
- Posts: 78
- Joined: Tue Jun 07, 2022 11:23 am
- Libera.chat IRC: Cyao
- Location: France
- Contact:
Re: Undefined opcode
Ahh yea totally forgot about interruptsOctocontrabass wrote:Interrupts can happen at any time, including while a program is using SSE registers. Doesn't your kernel handle interrupts?
Because it's easy to implement and will have less bugsOctocontrabass wrote: ...And what's the point of a single-tasking OS when modern CPUs have so many cores?