|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v4 13/14] x86: Clamp reserved bits in eflags more aggressively
On 28.02.2026 00:16, Andrew Cooper wrote:
> ERETU, unlike IRET, requires the sticky-1 bit (bit 2) be set, and reserved
> bits to be clear. Notably this means that dom0_construct() must set
> X86_EFLAGS_MBS in order for a PV dom0 to start.
>
> Xen has been overly lax with reserved bit handling. Adjust
> arch_set_info_guest*() and hypercall_iret() which consume flags to clamp the
> reserved bits for all guest types.
>
> This is a minor ABI change, but by the same argument as commit
> 9f892f84c279 ("x86/domctl: Stop using XLAT_cpu_user_regs()"); the reserved
> bits would get clamped like this naturally by hardware when the vCPU is run.
>
> This allows PV guests to start when Xen is using FRED mode.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>
> Still slightly RFC. Testing still in progress.
>
> v3:
> * Rewrite the commit message.
> v2:
> * New
>
> The handling of VM is complicated.
>
> It turns out that it's simply ignored by IRET in Long Mode (i.e. clearing it
> commit 0e47f92b0725 ("x86: force EFLAGS.IF on when exiting to PV guests")
> wasn't actually necessary) but ERETU does care.
>
> But, it's unclear how to handle this in in arch_set_info(). We must preserve
> it for HVM guests (which can use vm86 mode). PV32 has special handling but
> only in hypercall_iret(), not in arch_set_info().
Any reason you don't ...
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -1244,7 +1244,7 @@ int arch_set_info_guest(
> v->arch.user_regs.rax = c.nat->user_regs.rax;
> v->arch.user_regs.rip = c.nat->user_regs.rip;
> v->arch.user_regs.cs = c.nat->user_regs.cs;
> - v->arch.user_regs.rflags = c.nat->user_regs.rflags;
> + v->arch.user_regs.rflags = (c.nat->user_regs.rflags &
> X86_EFLAGS_ALL) | X86_EFLAGS_MBS;
> v->arch.user_regs.rsp = c.nat->user_regs.rsp;
> v->arch.user_regs.ss = c.nat->user_regs.ss;
> v->arch.pv.es = c.nat->user_regs.es;
> @@ -1268,7 +1268,7 @@ int arch_set_info_guest(
> v->arch.user_regs.eax = c.cmp->user_regs.eax;
> v->arch.user_regs.eip = c.cmp->user_regs.eip;
> v->arch.user_regs.cs = c.cmp->user_regs.cs;
> - v->arch.user_regs.eflags = c.cmp->user_regs.eflags;
> + v->arch.user_regs.eflags = (c.cmp->user_regs.eflags &
> X86_EFLAGS_ALL) | X86_EFLAGS_MBS;
> v->arch.user_regs.esp = c.cmp->user_regs.esp;
> v->arch.user_regs.ss = c.cmp->user_regs.ss;
> v->arch.pv.es = c.cmp->user_regs.es;
... filter it out here conditionally upon domain type?
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |