Skip to contentSkip to conversation

x86/hvm: vlapic: move vlapic_set_ppr/apicv_write() under CONFIG_INTEL_VMX

PATCH In review Grygorii Strashko 4 participants 4 messages Oct 23, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hvm: vlapic: move vlapic_set_ppr/apicv_write() under CONFIG_INTEL_VMX

From: Grygorii Strashko <[email protected]>

Functions:
- vlapic_apicv_write()
- vlapic_set_ppr()
are used by Intel VMX code only, so move them under CONFIG_INTEL_VMX ifdef.

---
 xen/arch/x86/hvm/vlapic.c | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/x86/hvm/vlapic.c +4 -0
index 98a54efc7bdc..4121285daef8 100644
@@ -215,6 +215,7 @@ static uint32_t vlapic_get_ppr(const struct vlapic *vlapic)
     return ppr;
 }
 
+#ifdef CONFIG_INTEL_VMX
 uint32_t vlapic_set_ppr(struct vlapic *vlapic)
 {
    uint32_t ppr = vlapic_get_ppr(vlapic);
@@ -222,6 +223,7 @@ uint32_t vlapic_set_ppr(struct vlapic *vlapic)
    vlapic_set_reg(vlapic, APIC_PROCPRI, ppr);
    return ppr;
 }
+#endif
 
 static bool vlapic_match_logical_addr(const struct vlapic *vlapic, uint32_t mda)
 {
@@ -984,6 +986,7 @@ static int cf_check vlapic_mmio_write(
     return X86EMUL_OKAY;
 }
 
+#ifdef CONFIG_INTEL_VMX
 int vlapic_apicv_write(struct vcpu *v, unsigned int offset)
 {
     struct vlapic *vlapic = vcpu_vlapic(v);
@@ -1002,6 +1005,7 @@ int vlapic_apicv_write(struct vcpu *v, unsigned int offset)
 
     return X86EMUL_OKAY;
 }
+#endif
 
 int guest_wrmsr_x2apic(struct vcpu *v, uint32_t msr, uint64_t val)
 {
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 lines · Grygorii Strashko

From: Grygorii Strashko <[email protected]>

Functions:
- vlapic_apicv_write()
- vlapic_set_ppr()
are used by Intel VMX code only, so move them under CONFIG_INTEL_VMX ifdef.

Yes and no.  Yes right now, but this is needed for AMD AVIC, which I understand is one one of the plans.

Throwing #ifdef's around like this in common files is fragile and will lead to a randconfig nightmare.

There is an alternative which ought to work.  Turning on -ffunction-sections (we already have this for livepatching), and implementing link time --gc-sections (new work).

That way, the compiler/linker simply drops functions that are not referenced in the final binary.

Personally I think it will be far nicer and more scalable than the #ifdefary, (not to mention far easier - it gets rid of everything unreferenced with one fell swoop).

Thoughts?

~Andrew

#2 lore raw
Quoted 20 lines · Andrew Cooper
Quoted 8 lines · Grygorii Strashko

From: Grygorii Strashko <[email protected]>

Functions:
- vlapic_apicv_write()
- vlapic_set_ppr()
are used by Intel VMX code only, so move them under CONFIG_INTEL_VMX ifdef.

Yes and no.  Yes right now, but this is needed for AMD AVIC, which I understand is one one of the plans.

Throwing #ifdef's around like this in common files is fragile and will lead to a randconfig nightmare.

There is an alternative which ought to work.  Turning on -ffunction-sections (we already have this for livepatching), and implementing link time --gc-sections (new work).

Quoted 8 lines

That way, the compiler/linker simply drops functions that are not referenced in the final binary.

Personally I think it will be far nicer and more scalable than the #ifdefary, (not to mention far easier - it gets rid of everything unreferenced with one fell swoop).

Thoughts?

We'd need to have Misra buy-off on such an approach. I'm not sure if Eclair's scanning would take --gc-sections effects into account.

Jan

#3 lore raw
Quoted 28 lines · Jan Beulich
Quoted 27 lines · Andrew Cooper
Quoted 8 lines · Grygorii Strashko

From: Grygorii Strashko <[email protected]>

Functions:
- vlapic_apicv_write()
- vlapic_set_ppr()
are used by Intel VMX code only, so move them under CONFIG_INTEL_VMX ifdef.

Yes and no.  Yes right now, but this is needed for AMD AVIC, which I understand is one one of the plans.

Throwing #ifdef's around like this in common files is fragile and will lead to a randconfig nightmare.

There is an alternative which ought to work.  Turning on -ffunction-sections (we already have this for livepatching), and implementing link time --gc-sections (new work).

That way, the compiler/linker simply drops functions that are not referenced in the final binary.

Personally I think it will be far nicer and more scalable than the #ifdefary, (not to mention far easier - it gets rid of everything unreferenced with one fell swoop).

Quoted 6 lines
Quoted 1 line

Thoughts?

We'd need to have Misra buy-off on such an approach. I'm not sure if Eclair's scanning would take --gc-sections effects into account.

Jan

Currently it doesn't, but we do have plans to implement something similar in the future. What might help in the meantime is using ECLAIR Code Scout to tag and hide unused program entities. Not sure if the mailing list is the best place to present the idea, but I'd be happy to illustrate it in a community call or something similar.

Basically the idea is that if something is possibly reachable it will be captured by Code Scout, and then a second analysis can use that input to selectively find and tag (e.g. "unused") the definitely unreachable entities. This could be limited to functions for instance, and then when the rule for unreachable code finds something unreachable, it can be silenced selectively for tagged functions, because we know that these are unreachable due to that reason. It's not 1:1 with the --gc-sections behaviour, but realistically it's much closer without resorting to #ifdefary all over the place.

Signature · 4 lines
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253