Skip to contentSkip to conversation

x86/cpuid: gate the hypervisor PV-only leaf on is_pv_domain()

PATCH In review Jiaqing Zhao 3 participants 3 messages Aug 26 – Aug 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/cpuid: gate the hypervisor PV-only leaf on is_pv_domain()

Hypervisor leaf 5 is PV-specific, but is gated with !is_hvm_domain(), which stays a runtime test in a build without PV support. Test for a PV domain directly so the compiler can discard the leaf when CONFIG_PV is disabled.

---
 xen/arch/x86/cpuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpuid.c +1 -1
index 6e9b15c9c3..a9aeb2d268 100644
@@ -157,7 +157,7 @@ static void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf,
         break;
 
     case 5: /* PV-specific parameters */
-        if ( is_hvm_domain(d) || subleaf != 0 )
+        if ( !is_pv_domain(d) || subleaf != 0 )
             break;
 
         res->b = flsl(get_upper_mfn_bound()) + PAGE_SHIFT;
Signature · 1 line
2.53.0
Acked-by on v1 1/1
#2 lore raw
In reply to Jiaqing Zhao
Quoted 1 line · Jiaqing Zhao

Hypervisor leaf 5 is PV-specific, but is gated with !is_hvm_domain(),

I would maybe write "..., but is gated using is_hvm_domain()".

Quoted 6 lines

which stays a runtime test in a build without PV support. Test for a PV domain directly so the compiler can discard the leaf when CONFIG_PV is disabled.

Thanks, Roger.