Re: [RFC/INCOMPLETE 00/13] x86: Rewrite exit-to-userspace code

From: Ingo Molnar
Date: Wed Jun 17 2015 - 07:15:08 EST



* Ingo Molnar <mingo@xxxxxxxxxx> wrote:

> Basically there would be a single C function we'd call, which returns a
> condition (or fixes up its return address on the stack directly) to determine
> between the SYSRET and IRET return paths.

This we could do by returning the syscall result in RAX, and the SYSRET/IRET
choice in RDX - that's the natural return parameter for 128-bit return values in
the 64-bit C function ABI, and it's clobbered so it's available 'for free'.

We could do something similar for the IRQ entry/return code as well: there's no
reason why IRQ flag tracking has to be maintained in assembly. We could move all
but the IRQ stack switching code to C.

We can safely flip around the IRQ stack setting with the enter_from_user_mode
call, so that IRQ stack switching becomes part of the register saving and kernel
mode preparatory preamble.

This would allow further optimizations in the IRQ code as well: for example we
could inline enter_from_user_mode() and prepare_exit_to_usermode().

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/