Messages in this thread | | | Subject | Re: [RFC][PATCH 08/24] x86/entry: Add C version of SWAPGS and SWAPGS_UNSAFE_STACK | From | Alexandre Chartre <> | Date | Mon, 9 Nov 2020 19:04:49 +0100 |
| |
On 11/9/20 6:38 PM, Andy Lutomirski wrote: > On Mon, Nov 9, 2020 at 3:22 AM Alexandre Chartre > <alexandre.chartre@oracle.com> wrote: >> >> SWAPGS and SWAPGS_UNSAFE_STACK are assembly macros. Add C versions >> of these macros (swapgs() and swapgs_unsafe_stack()). > > This needs a very good justification. It also needs some kind of > static verification that these helpers are only used by noinstr code, > and they need to be __always_inline. And I cannot fathom how C code > could possibly use SWAPGS_UNSAFE_STACK in a meaningful way. >
You're right, I probably need to revisit the usage of SWAPGS_UNSAFE_STACK in C code, that doesn't make sense. Looks like only SWAPGS is then needed.
Or maybe we can just use native_swapgs() instead?
I have added a C version of SWAPGS for moving paranoid_entry() to C because, in this function, we need to switch CR3 before doing the updating GS. But I really wonder if we need a paravirt swapgs here, and we can probably just use native_swapgs().
Also, if we map the per cpu offsets (__per_cpu_offset) in the user page-table then we will be able to update GS before switching CR3. That way we can keep the GS update in assembly code, and just do the CR3 switch in C code. This would also avoid having to disable stack-protector (patch 21).
alex.
| |