On Thu, Mar 21, 2024 at 03:53:45PM +0000, Marc Zyngier wrote: > It has become obvious that HCR_EL2.NV serves the exact same use > as VCPU_HYP_CONTEXT, only in an architectural way. So just drop > the flag for good. > > Reviewed-by: Joey Gouly <joey.gouly@xxxxxxx> > Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx> > --- > arch/arm64/include/asm/kvm_host.h | 2 -- > arch/arm64/kvm/hyp/vhe/switch.c | 7 +------ > 2 files changed, 1 insertion(+), 8 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 839c76529bb2..3f1c3c91e5c2 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -816,8 +816,6 @@ struct kvm_vcpu_arch { > #define DEBUG_STATE_SAVE_SPE __vcpu_single_flag(iflags, BIT(5)) > /* Save TRBE context if active */ > #define DEBUG_STATE_SAVE_TRBE __vcpu_single_flag(iflags, BIT(6)) > -/* vcpu running in HYP context */ > -#define VCPU_HYP_CONTEXT __vcpu_single_flag(iflags, BIT(7)) > > /* SVE enabled for host EL0 */ > #define HOST_SVE_ENABLED __vcpu_single_flag(sflags, BIT(0)) > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c > index 1581df6aec87..58415783fd53 100644 > --- a/arch/arm64/kvm/hyp/vhe/switch.c > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > @@ -197,7 +197,7 @@ static void early_exit_filter(struct kvm_vcpu *vcpu, u64 *exit_code) > * If we were in HYP context on entry, adjust the PSTATE view > * so that the usual helpers work correctly. > */ > - if (unlikely(vcpu_get_flag(vcpu, VCPU_HYP_CONTEXT))) { > + if (unlikely(read_sysreg(hcr_el2) & HCR_NV)) { Can this be additionally predicated on vcpu_has_nv() so we condition on the NV cpucap and avoid the sysreg read on non-nesting hardware? -- Thanks, Oliver