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

Re: [XEN][PATCH] x86/hvm: move hvm_shadow_handle_cd() under CONFIG_INTEL_VMX ifdef


  • To: Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 29 Oct 2025 15:46:42 +0000
  • 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=PwTUZqOVnz7g9NgDUa0VcR7tpC4eF9Zj01MdhJRW7BA=; b=jDWhMUgU8pS1wkooSmkUxPxq8FBDvks5+BTD3WXeuTeNjRQhSawl1DCrATi6+Ek/YKsBgoSu74liGlsCO1ZLFjh7ihsLPhmeGjEfhSOFqNAqR7yVar/eDOoDHRENWhr+6KJ4+f+1Mt+bh8yOAueu0/qEFp71V8nVJRxMA/zYMbFAyhY2AmBnIeoulm+03dPZi7XGmsxBZr3fe+H1Z3QoXeOPzOwQqLF1qm4wQ3ax2JUwdvo4Klswtf6WghMkpU/nSSh/KMvudaxjgvNSwVDRVWwItHbhNzKzuLCJv3Tu3KZc39ZiYfN6GtvpYrt73tI+LKMGUxUPgTirvzUwt7H5jA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oGWLKsQkYwAPk/wtzgZI/wJvKjWeO/MlWWCuOyHWbETUMwJmAzhomsKhbJE2PcQFzssPgOhXj8JpuauR6EctsZvAaZE6RtOUP3VaJhTzFGOXi8q09ja5Ichk9aAZF4XDnuj4e6rMRyIioinA3eEeqnxVwmd5KA1SJC9GScaMmcK61UKxea5689F/t7foOekGQNq7Gw5HwYnYVrEv4Qk86CrQA2RNln9vcJuHlcoqd8uFa+6gCbI9SrxKq0PwCLKyyW7Ho/6HlvBY+0CAQu63FrH07fW2zHdpRwcAmAE6y0bdBoreckaMNCuSa2Odf9lOOkNr/z/mFWurMf3AW3P6eQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jason Andryuk <Jason.Andryuk@xxxxxxx>
  • Delivery-date: Wed, 29 Oct 2025 15:47:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 28/10/2025 12:43 pm, Grygorii Strashko wrote:
> On 25.10.25 21:10, Teddy Astie wrote:
>> Le 23/10/2025 à 17:22, Grygorii Strashko a écrit :
>>> From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
>>>
>>> Functions:
>>>    hvm_shadow_handle_cd()
>>>    hvm_set_uc_mode()
>>>    domain_exit_uc_mode()
>>> are used only by Intel VMX code, so move them under CONFIG_INTEL_VMX
>>> ifdef.
>>>
>>
>> If they are actually Intel VMX specific, they should rather be moved to
>> VMX code (and named appropriately) rather than if-defed in shared hvm
>> code. If AMD code happens to need these functions in the future, it
>> would make things break pretty confusingly (as headers are not updated
>> consistently).
>
> I agree and like it even better. Can try if there is no objections?
>
> There is hvm_prepare_vm86_tss() also which is also used by VMX code only.


There is some horrible complexity here.

With SVM, we can run guests perfectly well in Cache Disable mode (i.e.
gCR0.CD=1).  Nothing extra is needed.

With VT-x, for unknown reasons, entering a VM explicitly leaves
CR0.{CD,NW} unmodified, i.e. always the Xen settings, which will be
neither bit set.  As a result, when the guest wishes to set
gCR0.{CD,NW}, we have to jump through hoops to make this happen.

Without going into the details, the upshot is that this "handle uc mode"
logic is VT-x specific, and oughtn't to be in hvm.c.  Moving it seems
fine, but the data, d->arch.hvm.uc_*, wants to move into the vmx union too.


hvm_prepare_vm86_tss() is rather different.  It, ultimately, is because
of limitations in early VT-x and it's probably fine to move too,
although the infrastructure surrounding it has bigger changes needed.

~Andrew



 


Rackspace

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