[PATCH v2 6/8] KVM: arm64: Refactor exit handlers

Will Deacon will at kernel.org
Mon Feb 10 08:37:59 PST 2025


On Thu, Feb 06, 2025 at 02:11:00PM +0000, Mark Rutland wrote:
> The hyp exit handling logic is largely shared between VHE and nVHE/hVHE,
> with common logic in arch/arm64/kvm/hyp/include/hyp/switch.h. The code
> in the header depends on function definitions provided by
> arch/arm64/kvm/hyp/vhe/switch.c and arch/arm64/kvm/hyp/nvhe/switch.c
> when they include the header.
> 
> This is an unusual header dependency, and prevents the use of
> arch/arm64/kvm/hyp/include/hyp/switch.h in other files as this would
> result in compiler warnings regarding missing definitions, e.g.
> 
> | In file included from arch/arm64/kvm/hyp/nvhe/hyp-main.c:8:
> | ./arch/arm64/kvm/hyp/include/hyp/switch.h:733:31: warning: 'kvm_get_exit_handler_array' used but never defined
> |   733 | static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu);
> |       |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~
> | ./arch/arm64/kvm/hyp/include/hyp/switch.h:735:13: warning: 'early_exit_filter' used but never defined
> |   735 | static void early_exit_filter(struct kvm_vcpu *vcpu, u64 *exit_code);
> |       |             ^~~~~~~~~~~~~~~~~
> 
> Refactor the logic such that the header doesn't depend on anything from
> the C files. There should be no functional change as a result of this
> patch.
> 
> Signed-off-by: Mark Rutland <mark.rutland at arm.com>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Fuad Tabba <tabba at google.com>
> Cc: Marc Zyngier <maz at kernel.org>
> Cc: Mark Brown <broonie at kernel.org>
> Cc: Oliver Upton <oliver.upton at linux.dev>
> Cc: Will Deacon <will at kernel.org>
> ---
>  arch/arm64/kvm/hyp/include/hyp/switch.h | 30 +++++--------------------
>  arch/arm64/kvm/hyp/nvhe/switch.c        | 30 ++++++++++++++-----------
>  arch/arm64/kvm/hyp/vhe/switch.c         |  9 ++++----
>  3 files changed, 27 insertions(+), 42 deletions(-)

Acked-by: Will Deacon <will at kernel.org>

Will



More information about the linux-arm-kernel mailing list