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

Re: [RFC] docs: FRED support in Xen


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 7 Jan 2025 08:52:43 +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: Tue, 07 Jan 2025 07:53:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.01.2025 17:06, Andrew Cooper wrote:
> On 06/01/2025 2:28 pm, Jan Beulich wrote:
>> On 03.01.2025 21:47, Andrew Cooper wrote:
>>> + #. In x86_emulate.c's ``put_fpu()``.  As far as I can tell, this is
>>> +    completely buggy; the values will be poisoned for HVM guests, and stale
>>> +    from the prior context switch for PV guests.
>> For HVM guests the ->read_segment() hook will be populated, so the path isn't
>> taken (leaving aside the odd case of the hook failing). For PV guests I don't
>> see any staleness concern: When the vCPU was switched in, the fields were set
>> (restored), weren't they?
> 
> There is up to 30ms of guest runtime between the last schedule in and
> this emulation, and segment loads don't generally trap for PV guests.

Oh, yes, I see now what you mean. Luckily even pv/emul-priv-op.c sets the hook.
Hence what's affected here are the two uses of the emulator from
pv/ro-page-fault.c. Sadly HVM isn't entirely unaffected, as the shadow mode use
of the emulator doesn't set the hook. Neither of the three cases are likely to
involve FPU insns, yet it's not excluded.

Question is what to do: Simply failing the entire emulation feels too heavy
handed. We could choose to simply store nul selectors instead. That would be
kind of wrong though for (in the hypervisor: hypothetical) cases where the
incoming regs are fully populated.

Regardless of what we're going to do, the underlying issue of callers passing
in partially inapplicable (to avoid calling it uninitialized) state remains,
...

>> For the purpose of FRED this doesn't matter much - wherever the values are to
>> be held, they'll be taken from by put_fpu().
> 
> I maybe wasn't clear.  To support FRED, I need to delete the vm86 fields.
> 
> @@ -54,10 +54,6 @@ struct cpu_user_regs
>      DECL_REG_LO16(flags); /* rflags.IF == !saved_upcall_mask */
>      DECL_REG_LO8(sp);
>      uint16_t ss, _pad2[3];
> -    uint16_t es, _pad3[3];
> -    uint16_t ds, _pad4[3];
> -    uint16_t fs, _pad5[3];
> -    uint16_t gs, _pad6[3];
> +    uint64_t edata, _rsvd;
>  };
>  
>  #undef DECL_REG_HI

... at least until your rework is in place. I did understand that you mean
to remove the struct fields. You made clear though that you'd re-introduce
them elsewhere (struct pv_vcpu) instead. And without (yet) recognizing the
staleness aspect I was implying we could read the values from there.

Jan



 


Rackspace

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