By: nksingh (None.delete@this.none.non), October 19, 2022 2:05 pm
Room: Moderated Discussions
Ana Rodriguez (ana_rodriguez_riano.delete@this.protonmail.com) on October 19, 2022 1:27 pm wrote:
> Ana Rodriguez (ana_rodriguez_riano.delete@this.protonmail.com) on October 19, 2022 1:20 pm wrote:
> > Chester (lamchester.delete@this.gmail.com) on October 19, 2022 12:11 pm wrote:
> > > Ana Rodriguez (ana_rodriguez_riano.delete@this.protonmail.com) on October 19, 2022 11:12 am wrote:
> > > > If someone were to build a Linux system with proprietary,
> > > > private (undocumented) ISA extensions, how would they
> > > > do it given Linux is open source? Are there any examples of this being done? Would it be possible at all?
> > > >
> > > > I got inspiration from this (https://github.com/corsix/amx) and I wondered if someone has done
> > > > it before on a Linux-based system. I understand a userspace library could be created to access
> > > > those instructions from userspace, but how would then they be implemented in the kernel? Through
> > > > a proprietary kernel module built using a custom compiler? Or is that not needed at all and the
> > > > library could just run on the processor taking advantage of the proprietary extensions?
> > >
> > > If the instructions don't create any extra state that the kernel needs to save or be aware
> > > of, then you could use the instructions in userspace without any modification to the kernel.
> > > However, if you need the kernel to save extra state, you do need a kernel change.
> > >
> > > Example of something that doesn't need a kernel change: MMX. Intel specifically aliased the MMX registers
> > > to the x87 ones, so an OS doesn't even need to know that MMX is supported. It saves the x87 registers on
> > > a context switch, and by doing so it would also save the MMX registers (because ST0-7 == MM0-7).
> > >
> > > Example of something that does need a kernel change: SSE. SSE adds a set of separate vector/FP registers
> > > (xmm regs). The kernel has to save and restore those on a context switch, and thus needs a change.
> > >
> > > In Apple AMX's case, they introduce an extra 80 registers, each of which are 64 bytes wide.
> > > The kernel needs to save and restore these on a context switch. So, you need a kernel change.
> >
> > I see. Thank you for your response!
> >
> > I unfortunately this is one limitation of the GPL...
>
> I wonder, though. I thought Darwin was open source. How did Apple manage to keep it hidden if they're
> releasing the source code of their kernel and given the kernel had to explicitly support it?
Another option for the specific state save problem is the 'xsave' approach. Have a set of instructions and metadata registers that the OS uses to discover how to size its buffers and to save a register set without knowing the details.
> Ana Rodriguez (ana_rodriguez_riano.delete@this.protonmail.com) on October 19, 2022 1:20 pm wrote:
> > Chester (lamchester.delete@this.gmail.com) on October 19, 2022 12:11 pm wrote:
> > > Ana Rodriguez (ana_rodriguez_riano.delete@this.protonmail.com) on October 19, 2022 11:12 am wrote:
> > > > If someone were to build a Linux system with proprietary,
> > > > private (undocumented) ISA extensions, how would they
> > > > do it given Linux is open source? Are there any examples of this being done? Would it be possible at all?
> > > >
> > > > I got inspiration from this (https://github.com/corsix/amx) and I wondered if someone has done
> > > > it before on a Linux-based system. I understand a userspace library could be created to access
> > > > those instructions from userspace, but how would then they be implemented in the kernel? Through
> > > > a proprietary kernel module built using a custom compiler? Or is that not needed at all and the
> > > > library could just run on the processor taking advantage of the proprietary extensions?
> > >
> > > If the instructions don't create any extra state that the kernel needs to save or be aware
> > > of, then you could use the instructions in userspace without any modification to the kernel.
> > > However, if you need the kernel to save extra state, you do need a kernel change.
> > >
> > > Example of something that doesn't need a kernel change: MMX. Intel specifically aliased the MMX registers
> > > to the x87 ones, so an OS doesn't even need to know that MMX is supported. It saves the x87 registers on
> > > a context switch, and by doing so it would also save the MMX registers (because ST0-7 == MM0-7).
> > >
> > > Example of something that does need a kernel change: SSE. SSE adds a set of separate vector/FP registers
> > > (xmm regs). The kernel has to save and restore those on a context switch, and thus needs a change.
> > >
> > > In Apple AMX's case, they introduce an extra 80 registers, each of which are 64 bytes wide.
> > > The kernel needs to save and restore these on a context switch. So, you need a kernel change.
> >
> > I see. Thank you for your response!
> >
> > I unfortunately this is one limitation of the GPL...
>
> I wonder, though. I thought Darwin was open source. How did Apple manage to keep it hidden if they're
> releasing the source code of their kernel and given the kernel had to explicitly support it?
Another option for the specific state save problem is the 'xsave' approach. Have a set of instructions and metadata registers that the OS uses to discover how to size its buffers and to save a register set without knowing the details.