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

Re: [XEN][PATCH] x86/hvm: revise "cpu_has_vmx" usage for !CONFIG_INTEL_VMX case


  • To: Grygorii Strashko <grygorii_strashko@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Tue, 30 Sep 2025 14:10:37 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=epam.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=C5BjB6WmfOKtawsjUtZVDnZSAImvsiUyn+Twwdywo2E=; b=Uiaui52hDSIkg4blT3TXtdqmmMHem7OMDmrUg6TPzarZFYyvBLmSU6muVUJGXkZBcT+TYHtnJq3Y7+d0rGJP9P2nZeTfExExRYKS3tHri1gOessByurwBYgslCaCxtso56u9Qy6kg1Q5cHA6x3kmEy/ia/UqTq8cCXtgvY0bI3FFoRFniTCMIeqtvCsEpH0GguM6S6wn2GneE23CNMepPj37nOkHFbew+eeFyYBzWr7n86lMxSnwyLbHfAoUR27qBssBI5ICaKSe+DkJOQBRRZeF2U7cE9Vm6zejQY+GYEjz9hpc2Vug800CE10ZP+G551ZDkIRp4xrJjZ+L/Duosg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bbwA2LS2DSQFN6qd6/yGX1kCyL5rLd72jdwlsp4HQsRYtBm68s5G+DhlvhJsF8rJ6T5ZnpPIeX3jyG/eRVr7jkvOAUiGI7Zj0au71WwFIkB/QgXgWfaYCsH8rN9NwYTyDHh9SNFk4Wz25gxIJtA8Fi1C/RJ0UwZNKBFOL/IB/xFt+qkrMYuUBoyzbh0YpvIOV4iWE51ws4xf5aLMJh97dA3sDsqVYlzoqoAp1jwnPbF0RgB/CI5POwwXrswK+/8B5+M5NIsoWACsKNTjYwKxvMYHnuvtMNnBX10i4KAx2NdhsFcrKiFsfvYr+yF0Up1m0tEJPt4wUByG0i3FoY4byg==
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 30 Sep 2025 12:10:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed Sep 24, 2025 at 12:14 PM CEST, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
>
> Since commit b99227347230 ("x86: Fix AMD_SVM and INTEL_VMX dependency") the
> HVM Intel VT-x support can be disabled, but it still keeps VMX
> code partially built-in. Particularly in HVM code there are two places:
>
> 1) hvm/dom0_build.c
>  dom0_construct_pvh()->pvh_populate_p2m()
>     ...
>     if ( cpu_has_vmx && paging_mode_hap(d) && !vmx_unrestricted_guest(v) )
>     {
>         ...
>         [unreachable for !cpu_has_vmx case]
>         rc = pvh_setup_vmx_realmode_helpers(d);
>
> pvh_setup_vmx_realmode_helpers() allocates memory and configures
>  HVM_PARAM_VM86_TSS_SIZED
>  HVM_PARAM_IDENT_PT
>
> 2) hvm/hvm.c
>  hvm_set_param()
>     ...
>     case HVM_PARAM_IDENT_PT:
>
>         if ( !paging_mode_hap(d) || !cpu_has_vmx )
>         {
>             d->arch.hvm.params[index] = value;
>             break;
>         }
>         [unreachable for !cpu_has_vmx case]
>         ...

nit: These (1) and (2) are rather large for a commit message. I wouldn't mind
if they went away and the rest of the commit message was adjusted to make it
a bit leaner.

Either way, with or without this change...

>
> Hence HVM_PARAM_IDENT_PT/HVM_PARAM_VM86_TSS_SIZED are used only by VMX code
> above code become unreachable in !cpu_has_vmx case and can be optimazed
> when !CONFIG_INTEL_VMX.
>
> Replace "cpu_has_vmx" with using_vmx() to account !CONFIG_INTEL_VMX and allow
> compiler DCE to optimize code.
>
> Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

... Reviewed-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>

Cheers,
Alejandro



 


Rackspace

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