[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/8] x86/domctl: Stop using XLAT_cpu_user_regs()


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 17 Mar 2025 12:38:15 +0100
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 17 Mar 2025 11:38:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11.03.2025 22:10, Andrew Cooper wrote:
> In order to support FRED, we're going to have to remove the {ds..gs} fields
> from struct cpu_user_regs, meaning that it is going to have to become a
> different type to the structure embedded in vcpu_guest_context_u.
> 
> In both arch_{get,set}_info_guest(), expand the memcpy()/XLAT_cpu_user_regs()
> to copy the fields individually.  This will allow us to eventually make them
> different types.
> 
> No practical change.  The compat cases are identical, while the non-compat
> cases no longer copy _pad fields.

That's fine for "set", but potentially not for "get": Someone simply doing
memcmp() on two pieces of output might then break.

> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> Should we really be copying error_code/entry_vector?  They're already listed
> as explicitly private fields, and I don't think anything good can come of
> providing/consuming them.

I don't see a reason why we'd need to copy them in arch_set_info_guest();
arch_set_info_hvm_guest() doesn't copy them either. For
arch_get_info_guest() it's less clear - toolstack components may have
grown a dependency on them (e.g. introspection?), so I'd err on the side
of retaining prior behavior. (Of course there's then the corner case of
someone calling "get" right after "set", expecting the two fields to come
back unchanged.)

> @@ -1204,7 +1223,26 @@ int arch_set_info_guest(
>  #ifdef CONFIG_COMPAT
>      else
>      {
> -        XLAT_cpu_user_regs(&v->arch.user_regs, &c.cmp->user_regs);
> +        v->arch.user_regs.ebx               = c.cmp->user_regs.ebx;
> +        v->arch.user_regs.ecx               = c.cmp->user_regs.ecx;
> +        v->arch.user_regs.edx               = c.cmp->user_regs.edx;
> +        v->arch.user_regs.esi               = c.cmp->user_regs.esi;
> +        v->arch.user_regs.edi               = c.cmp->user_regs.edi;
> +        v->arch.user_regs.ebp               = c.cmp->user_regs.ebp;
> +        v->arch.user_regs.eax               = c.cmp->user_regs.eax;
> +        v->arch.user_regs.error_code        = c.cmp->user_regs.error_code;
> +        v->arch.user_regs.entry_vector      = c.cmp->user_regs.entry_vector;
> +        v->arch.user_regs.eip               = c.cmp->user_regs.eip;
> +        v->arch.user_regs.cs                = c.cmp->user_regs.cs;
> +        v->arch.user_regs.saved_upcall_mask = 
> c.cmp->user_regs.saved_upcall_mask;
> +        v->arch.user_regs.eflags            = c.cmp->user_regs.eflags;
> +        v->arch.user_regs.esp               = c.cmp->user_regs.esp;
> +        v->arch.user_regs.ss                = c.cmp->user_regs.ss;
> +        v->arch.user_regs.es                = c.cmp->user_regs.es;
> +        v->arch.user_regs.ds                = c.cmp->user_regs.ds;
> +        v->arch.user_regs.fs                = c.cmp->user_regs.fs;
> +        v->arch.user_regs.gs                = c.cmp->user_regs.gs;

Just to mention it (there's no change in behavior here afaict): Us writing
only half of the register fields looks like a latent (but perhaps only
theoretical) problem to me. A dis-aggregated toolstack may set 64-bit PV
context, then toggle address size, then set 32-bit context. That'll leave
the high halves of respective fields non-zero. I didn't check whether any
badness could result from that, as for the time being
XEN_DOMCTL_set_address_size isn't marked dis-aggregation-safe, and hence
this at least isn't of immediate concern.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.