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

Re: [PATCH] x86/svm: require VMSAVEvirt for nested virt


  • To: ross.lagerwall@xxxxxxxxxx
  • From: Stephen Cheng <stephen.cheng@xxxxxxxxxx>
  • Date: Tue, 28 Jul 2026 15:14:46 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=60Uq/mRUzXsfzG2pkARYh3m3TivgWpO84hW5IQSCk9Q=; b=wJ0Tf9yuCE3gHulNT7Oqq4LffDZAt+b+QRymh1TraBLTb/mkwl/Fu/GfRmepvVYKbXI3zc3/yEFuLt8+7ZpZTn4xM9NFgw12UBYloAr5w/Qx4uBg6OVyo0zJXj3voF1BacQq1C2qoVsWd+O6uo2DNW2N+U2mg1LLtwsX+FFav443Ah2a0zpVpFLCdy38VaXv3XJ4PGLbzSHU0nQKRJ8ql16GK5aQfh7cqS3apcIvYZctaglEpfM3mM4zUB6pnMrkhZLbfBuCefRYrb950exU1DnfymRN8LN5McFjNWq/hBD3o8mNFHuShttWCkUmsYQ6FwIf2U8D+B6Iv1NEHULfpQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AgkuIDnF7DANLWTORXLhEZS2PyAD/zxr8ch8Oh/A4gV6q93UR17WnvNsL3iPS3YWjLqtQ0w27K4Qu1P+C30cmL/Zg2ot7Sbpa1rx4awLd9zGQGkBbl/XIH9FK/iAnkWjr2unAhQwXa1oRlLOPytLUfK2CQJrsgfBEfYJLOTpo3IA+hVLP+ed4QoitmP+7qig4MSbkVEB3/RPrUTMj14bMnSQ0wY7pRz8lQrMSbFl7y6CoMv8S2GDw/1O6gNPmeDmEYldXslskax4HLUIbhvvF1SnQ/k5LHWKfDceOmer7COG02HPwpLSOBNGSzd6b3WpXO12qGVUJOOnmNgvF/QcGw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: teddy.astie@xxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, anthony.perard@xxxxxxxxxx, jason.andryuk@xxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, michal.orzel@xxxxxxx, roger@xxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 28 Jul 2026 07:15:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27/07/2026 10:50, Ross Lagerwall wrote:
> > @@ -837,7 +837,8 @@ static void __init calculate_hvm_max_policy(void)
> > -                               (1u << SVM_FEATURE_DECODEASSISTS));
> > +                               (1u << SVM_FEATURE_DECODEASSISTS) |
> > +                               (1u << SVM_FEATURE_VLOADSAVE));
>
> Exposing this feature to L1 is separate from requiring it in L0 and IMO should
> be a separate commit. If it's exposed to L1, there is a lot more to think
> about. E.g. whether L2 should follow L1's setting or L0's for vloadsave_enable
> and if it is not enabled what happens if L1 doesn't intercept VMLOAD/VMSAVE.

Agreed.  I'll drop the cpu-policy.c hunk from this patch and do the L1
side as a follow-up.

Worth noting that dropping it only removes the CPUID advertisement, not
the functionality: vmcb02 picks up vloadsave_enable from the virt_ext
merge in nsvm_vmcb_prepare4vmrun() regardless of what we advertise,
which is your third point below.

> Also note we discovered previously that contrary to what the APM documents:
>
> If the VMSAVE/VMLOAD intercept bits are clear, and virtual
> VMLOAD/VMSAVE is not enabled, then a VMSAVE instruction executed in
> guest mode executes as if it were in non-root mode, and operates on host
> physical addresses.

Thanks, I hadn't come across that.  It makes "vloadsave_enable clear
implies the intercepts are set" a hard requirement rather than a
tidiness thing, so I'll treat it as an invariant in the follow-up.

> I think there is also a separate bug that what Xen advertises doesn't
> necessarily control what the guest can use. E.g. previously we didn't 
> advertise
> SVM_FEATURE_VLOADSAVE but Xen would always merge in tthe virt_ext settings 
> from
> VMCB(L1-L2).

Agreed, and it's the same virt_ext merge.  I'll fix it as part of the
follow-up.

> > +        /*
> > +         * VMSAVEvirt is a hard requirement for nested virt (see
> > +         * start_nested_svm()), so it is guaranteed present here.
> > +         */
> > +        ASSERT(cpu_has_svm_vloadsave);
>
> Maybe just personal taste but I think this assert is unnecessary.
> cpu_has_svm_vloadsave is constant since boot and also checked at boot so
> further checks are unnecessary.

I'll drop it.

> >      case VMEXIT_VMLOAD:
> > -        svm_vmexit_do_vmload(vmcb, regs, v, regs->rax);
> > -        break;
> >      case VMEXIT_VMSAVE:
> > -        svm_vmexit_do_vmsave(vmcb, regs, v, regs->rax);
> > +        svm_vmexit_do_vmload_vmsave(v);
> >          break;
>
> I think it would be simpler to just move these case statements up to the
> VMEXIT_RDPRU section.

Will do.

Thanks for the review.

Stephen



 


Rackspace

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