[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>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 13 Nov 2025 08:31:21 +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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 13 Nov 2025 07:31:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 12.11.2025 21:25, Grygorii Strashko wrote:
> Could it be merged if no other comments, please?

It's on my list of things to put in. However, since you ask: You do realize that
all your recent postings were while the tree was frozen? That's okay-ish, but
when preparing a release people would preferably focus on the release, not on
what is to come afterwards. This change of yours, like quite a few from others,
will need to wait until the tree is fully open again. It having been progressed
to the point where it can in principle go in was already a courtesy, considering
the timing.

Jan

> On 24.09.25 13:14, 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]
>>          ...
>>
>> 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>
>> ---
>> add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-604 (-604)
>> Function                                     old     new   delta
>> hvm_set_param                               1602    1473    -129
>> dom0_construct_pvh                          4438    3963    -475
>> Total: Before=3567191, After=3566587, chg -0.02%
>>
>>   xen/arch/x86/hvm/dom0_build.c | 2 +-
>>   xen/arch/x86/hvm/hvm.c        | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
>> index 5551f9044836..5ac2cf8394d8 100644
>> --- a/xen/arch/x86/hvm/dom0_build.c
>> +++ b/xen/arch/x86/hvm/dom0_build.c
>> @@ -473,7 +473,7 @@ static int __init pvh_populate_p2m(struct domain *d)
>>           }
>>       }
>>   
>> -    if ( cpu_has_vmx && paging_mode_hap(d) && !vmx_unrestricted_guest(v) )
>> +    if ( using_vmx() && paging_mode_hap(d) && !vmx_unrestricted_guest(v) )
>>       {
>>           /*
>>            * Since Dom0 cannot be migrated, we will only setup the
>> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
>> index 95a80369b9b8..70331aeec9a0 100644
>> --- a/xen/arch/x86/hvm/hvm.c
>> +++ b/xen/arch/x86/hvm/hvm.c
>> @@ -4302,7 +4302,7 @@ static int hvm_set_param(struct domain *d, uint32_t 
>> index, uint64_t value)
>>            * Only actually required for VT-x lacking unrestricted_guest
>>            * capabilities.  Short circuit the pause if possible.
>>            */
>> -        if ( !paging_mode_hap(d) || !cpu_has_vmx )
>> +        if ( !paging_mode_hap(d) || !using_vmx() )
>>           {
>>               d->arch.hvm.params[index] = value;
>>               break;
> 




 


Rackspace

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