Re: [PATCH v4 08/15] arm64: kvm: Duplicate hyp/tlb.c for VHE/nVHE

From: Marc Zyngier
Date: Sun Jul 05 2020 - 08:00:16 EST


On Thu, 25 Jun 2020 14:14:13 +0100,
David Brazdil <dbrazdil@xxxxxxxxxx> wrote:
>
> tlb.c contains code for flushing the TLB, with code shared between VHE/nVHE.
> Because common code is small, duplicate tlb.c and specialize each copy for
> VHE/nVHE.
>
> Signed-off-by: David Brazdil <dbrazdil@xxxxxxxxxx>
> ---
> arch/arm64/kernel/image-vars.h | 14 +--
> arch/arm64/kvm/hyp/Makefile | 2 +-
> arch/arm64/kvm/hyp/nvhe/Makefile | 2 +-
> arch/arm64/kvm/hyp/{ => nvhe}/tlb.c | 94 +---------------
> arch/arm64/kvm/hyp/vhe/Makefile | 2 +-
> arch/arm64/kvm/hyp/vhe/tlb.c | 162 ++++++++++++++++++++++++++++
> 6 files changed, 178 insertions(+), 98 deletions(-)
> rename arch/arm64/kvm/hyp/{ => nvhe}/tlb.c (62%)
> create mode 100644 arch/arm64/kvm/hyp/vhe/tlb.c

[...]

> diff --git a/arch/arm64/kvm/hyp/tlb.c b/arch/arm64/kvm/hyp/nvhe/tlb.c
> similarity index 62%
> rename from arch/arm64/kvm/hyp/tlb.c
> rename to arch/arm64/kvm/hyp/nvhe/tlb.c
> index d063a576d511..9513ad41db9a 100644
> --- a/arch/arm64/kvm/hyp/tlb.c
> +++ b/arch/arm64/kvm/hyp/nvhe/tlb.c
> @@ -4,8 +4,6 @@
> * Author: Marc Zyngier <marc.zyngier@xxxxxxx>
> */
>
> -#include <linux/irqflags.h>
> -
> #include <asm/kvm_hyp.h>
> #include <asm/kvm_mmu.h>
> #include <asm/tlbflush.h>
> @@ -16,52 +14,8 @@ struct tlb_inv_context {
> u64 sctlr;
> };

nit: You seem to have overlooked that some of the tlb_inv_context
fields are now unused. I plan to squash the following patch in:

diff --git a/arch/arm64/kvm/hyp/nvhe/tlb.c b/arch/arm64/kvm/hyp/nvhe/tlb.c
index 6fe190bb930a..d4475f8340c4 100644
--- a/arch/arm64/kvm/hyp/nvhe/tlb.c
+++ b/arch/arm64/kvm/hyp/nvhe/tlb.c
@@ -9,9 +9,7 @@
#include <asm/tlbflush.h>

struct tlb_inv_context {
- unsigned long flags;
u64 tcr;
- u64 sctlr;
};

static void __tlb_switch_to_guest(struct kvm *kvm, struct tlb_inv_context *cxt)


Otherwise, this looks good to me.

Thanks,

M.

--
Without deviation from the norm, progress is not possible.