Re: the x86 sysret_rip test fails on the Intel FRED architecture

From: Andrew Cooper
Date: Fri Jan 20 2023 - 16:10:23 EST


On 20/01/2023 8:50 pm, H. Peter Anvin wrote:
> On January 20, 2023 10:52:02 AM PST, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx> wrote:
>> On 20/01/2023 5:45 pm, Dave Hansen wrote:
>>> On 1/19/23 23:49, Li, Xin3 wrote:
>>>> The x86 sysret_rip test has the following assertion:
>>>>
>>>> /* R11 and EFLAGS should already match. */
>>>> assert(ctx->uc_mcontext.gregs[REG_EFL] ==
>>>> ctx->uc_mcontext.gregs[REG_R11]);
>>>>
>>>> This is being tested to avoid kernel state leak due to sysret vs iret,
>>>> but that on FRED r11 is *always* preserved, and the test just fails.
>>> Let's figure out the reason that FRED acts differently, first. Right
>>> now, the SDM says:
>>>
>>> SYSCALL also saves RFLAGS into R11
>>>
>>> so that behavior of SYSCALL _looks_ architectural to me. Was this
>>> change in SYSCALL behavior with FRED intentional?
>> FRED 3.0 Section 7.4 says the only changes for the SYSCALL and SYSENTER
>> instructions are the enablement conditions.  Nowhere else is there
>> mention of a FRED OS needing to emulate legacy syscall behaviour by
>> adjusting %r11/%rcx
>>
>> However, ERETU does handle flags different to SYSRET (in particular, I
>> think you can establish TF on the instruction boundary after SYSCALL
>> now).  What are the raw values of REG_EFL and REG_R11 ?
>>
>> ~Andrew
>>
> Just to avoid any confusion:
>
> Syscall and sysenter in a FRED system are treated equivalently to software interrupts, e.g. INT 0x80. They do not modify any registers.

In which case can Intel please publish a v4 spec which actually says this?

I can't see anything in the v3 spec which mentions a change in register
behaviour for SYSCALL.

~Andrew