[XEN][PATCH 2/3] x86/hvm: vmx: account for SHADOW_PAGING when use hvm_shadow_handle_cd()

Grygorii Strashko posted 3 patches 1 month, 2 weeks ago
There is a newer version of this series
[XEN][PATCH 2/3] x86/hvm: vmx: account for SHADOW_PAGING when use hvm_shadow_handle_cd()
Posted by Grygorii Strashko 1 month, 2 weeks ago
From: Grygorii Strashko <grygorii_strashko@epam.com>

The hvm_shadow_handle_cd() can be used only with SHADOW_PAGING=y,
so guard hvm_shadow_handle_cd() call with IS_ENABLED(CONFIG_SHADOW_PAGING).

bloat-o-meter
 add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-290 (-290)

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
 xen/arch/x86/hvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index a7ee0519957a..05b394840e59 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1506,7 +1506,7 @@ static int cf_check vmx_get_guest_pat(struct vcpu *v, u64 *gpat)
 
 static void cf_check vmx_handle_cd(struct vcpu *v, unsigned long value)
 {
-    if ( !paging_mode_hap(v->domain) )
+    if ( IS_ENABLED(CONFIG_SHADOW_PAGING) && !paging_mode_hap(v->domain) )
     {
         /*
          * For shadow, 'load IA32_PAT' VM-entry control is 0, so it cannot
-- 
2.34.1
Re: [XEN][PATCH 2/3] x86/hvm: vmx: account for SHADOW_PAGING when use hvm_shadow_handle_cd()
Posted by Jan Beulich 1 month, 2 weeks ago
On 30.10.2025 00:54, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> The hvm_shadow_handle_cd() can be used only with SHADOW_PAGING=y,
> so guard hvm_shadow_handle_cd() call with IS_ENABLED(CONFIG_SHADOW_PAGING).
> 
> bloat-o-meter
>  add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-290 (-290)
> 
> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>

Requested-by: <me> (or some other of the available tags)?

> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1506,7 +1506,7 @@ static int cf_check vmx_get_guest_pat(struct vcpu *v, u64 *gpat)
>  
>  static void cf_check vmx_handle_cd(struct vcpu *v, unsigned long value)
>  {
> -    if ( !paging_mode_hap(v->domain) )
> +    if ( IS_ENABLED(CONFIG_SHADOW_PAGING) && !paging_mode_hap(v->domain) )

I don't think there's a need for IS_ENABLED() here - you can simply switch to
using paging_mode_shadow(). That would be more correct anyway, for the abstract
case of there being a 3rd paging mode. With the adjustment:
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
Re: [XEN][PATCH 2/3] x86/hvm: vmx: account for SHADOW_PAGING when use hvm_shadow_handle_cd()
Posted by Grygorii Strashko 1 month, 2 weeks ago

On 30.10.25 13:12, Jan Beulich wrote:
> On 30.10.2025 00:54, Grygorii Strashko wrote:
>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>
>> The hvm_shadow_handle_cd() can be used only with SHADOW_PAGING=y,
>> so guard hvm_shadow_handle_cd() call with IS_ENABLED(CONFIG_SHADOW_PAGING).
>>
>> bloat-o-meter
>>   add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-290 (-290)
>>
>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> Requested-by: <me> (or some other of the available tags)?

Will do. or Suggested-by:?

> 
>> --- a/xen/arch/x86/hvm/vmx/vmx.c
>> +++ b/xen/arch/x86/hvm/vmx/vmx.c
>> @@ -1506,7 +1506,7 @@ static int cf_check vmx_get_guest_pat(struct vcpu *v, u64 *gpat)
>>   
>>   static void cf_check vmx_handle_cd(struct vcpu *v, unsigned long value)
>>   {
>> -    if ( !paging_mode_hap(v->domain) )
>> +    if ( IS_ENABLED(CONFIG_SHADOW_PAGING) && !paging_mode_hap(v->domain) )
> 
> I don't think there's a need for IS_ENABLED() here - you can simply switch to
> using paging_mode_shadow(). That would be more correct anyway, for the abstract
> case of there being a 3rd paging mode. 

Will do. I've seen it, but was not sure :(

>With the adjustment:
> Reviewed-by: Jan Beulich <jbeulich@suse.com>


-- 
Best regards,
-grygorii
Re: [XEN][PATCH 2/3] x86/hvm: vmx: account for SHADOW_PAGING when use hvm_shadow_handle_cd()
Posted by Jan Beulich 1 month, 2 weeks ago
On 30.10.2025 13:07, Grygorii Strashko wrote:
> 
> 
> On 30.10.25 13:12, Jan Beulich wrote:
>> On 30.10.2025 00:54, Grygorii Strashko wrote:
>>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>>
>>> The hvm_shadow_handle_cd() can be used only with SHADOW_PAGING=y,
>>> so guard hvm_shadow_handle_cd() call with IS_ENABLED(CONFIG_SHADOW_PAGING).
>>>
>>> bloat-o-meter
>>>   add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-290 (-290)
>>>
>>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
>>
>> Requested-by: <me> (or some other of the available tags)?
> 
> Will do. or Suggested-by:?

Your choice.

Jan