Introduce export_on_unmap() to make the code more readable Move the #ifdef inside is_ucontrol(), make kvm_is_ucontrol() into a wrapper around is_ucontrol(). This way the compiler can remove more code when CONFIG_KVM_S390_UCONTROL is disabled. Signed-off-by: Claudio Imbrenda --- arch/s390/kvm/gmap/gmap.c | 2 +- arch/s390/kvm/gmap/gmap.h | 9 +++++++++ arch/s390/kvm/s390/s390.h | 6 +----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/s390/kvm/gmap/gmap.c b/arch/s390/kvm/gmap/gmap.c index cb8f247cff60..c23da6fad92a 100644 --- a/arch/s390/kvm/gmap/gmap.c +++ b/arch/s390/kvm/gmap/gmap.c @@ -414,7 +414,7 @@ static long _gmap_unmap_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct if (!old.h.fc) return 0; - if (old.s.fc1.pr && test_bit(GMAP_FLAG_EXPORT_ON_UNMAP, &priv->gmap->flags)) + if (old.s.fc1.pr && export_on_unmap(priv->gmap)) folio = phys_to_folio(crste_origin_large(old)); /* * No races should happen because kvm->mmu_lock is held in write mode, diff --git a/arch/s390/kvm/gmap/gmap.h b/arch/s390/kvm/gmap/gmap.h index c40a49b30618..6824507706ed 100644 --- a/arch/s390/kvm/gmap/gmap.h +++ b/arch/s390/kvm/gmap/gmap.h @@ -123,7 +123,16 @@ static inline bool pfault_enabled(struct gmap *gmap) static inline bool is_ucontrol(struct gmap *gmap) { +#ifdef CONFIG_KVM_S390_UCONTROL return test_bit(GMAP_FLAG_IS_UCONTROL, &gmap->flags); +#else + return 0; +#endif +} + +static inline bool export_on_unmap(struct gmap *gmap) +{ + return test_bit(GMAP_FLAG_EXPORT_ON_UNMAP, &gmap->flags); } static inline bool is_shadow(struct gmap *gmap) diff --git a/arch/s390/kvm/s390/s390.h b/arch/s390/kvm/s390/s390.h index aa0d1d062f8d..daf3b0d004a4 100644 --- a/arch/s390/kvm/s390/s390.h +++ b/arch/s390/kvm/s390/s390.h @@ -115,11 +115,7 @@ static inline int is_vcpu_idle(struct kvm_vcpu *vcpu) static inline int kvm_is_ucontrol(struct kvm *kvm) { -#ifdef CONFIG_KVM_S390_UCONTROL - return test_bit(GMAP_FLAG_IS_UCONTROL, &kvm->arch.gmap->flags); -#else - return 0; -#endif + return is_ucontrol(kvm->arch.gmap); } #define GUEST_PREFIX_SHIFT 12 -- 2.56.0