[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H4Ca18bo-DV8gzaJeVCDT8o_dqFfX4+ruQLHL+V+HrmOg@mail.gmail.com>
Date: Wed, 19 Apr 2023 10:02:07 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Tianrui Zhao <zhaotianrui@...ngson.cn>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
WANG Xuerui <kernel@...0n.name>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org, Jens Axboe <axboe@...nel.dk>,
Mark Brown <broonie@...nel.org>,
Alex Deucher <alexander.deucher@....com>,
Oliver Upton <oliver.upton@...ux.dev>, maobibo@...ngson.cn,
Xi Ruoyao <xry111@...111.site>
Subject: Re: [PATCH v7 17/30] LoongArch: KVM: Implement virtual machine tlb operations
Hi, Tianrui,
On Mon, Apr 17, 2023 at 5:47 PM Tianrui Zhao <zhaotianrui@...ngson.cn> wrote:
>
> Implement loongarch virtual machine tlb operations such as flush tlb by
> specific gpa parameter and flush all of the virt machines tlb.
Use LoongArch instead of loongarch in commit messages and comments, please.
Huacai
>
> Signed-off-by: Tianrui Zhao <zhaotianrui@...ngson.cn>
> ---
> arch/loongarch/kvm/tlb.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
> create mode 100644 arch/loongarch/kvm/tlb.c
>
> diff --git a/arch/loongarch/kvm/tlb.c b/arch/loongarch/kvm/tlb.c
> new file mode 100644
> index 000000000000..66e116cf2486
> --- /dev/null
> +++ b/arch/loongarch/kvm/tlb.c
> @@ -0,0 +1,31 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
> + */
> +
> +#include <linux/kvm_host.h>
> +#include <asm/tlb.h>
> +
> +int kvm_flush_tlb_gpa(struct kvm_vcpu *vcpu, unsigned long gpa)
> +{
> + preempt_disable();
> + gpa &= (PAGE_MASK << 1);
> + invtlb(INVTLB_GID_ADDR, read_csr_gstat() & CSR_GSTAT_GID, gpa);
> + preempt_enable();
> + return 0;
> +}
> +
> +/**
> + * kvm_flush_tlb_all() - Flush all root TLB entries for
> + * guests.
> + *
> + * Invalidate all entries including GVA-->GPA and GPA-->HPA mappings.
> + */
> +void kvm_flush_tlb_all(void)
> +{
> + unsigned long flags;
> +
> + local_irq_save(flags);
> + invtlb_all(INVTLB_ALLGID, 0, 0);
> + local_irq_restore(flags);
> +}
> --
> 2.31.1
>
Powered by blists - more mailing lists