Message ID | 20230417094649.874671-18-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1999755vqo; Mon, 17 Apr 2023 02:58:04 -0700 (PDT) X-Google-Smtp-Source: AKy350Zg0iZSkg1dAG0TdSOGlOCUpQhxlpX01Tx2bHgNDQNMv9AC4rOIawgbAQqDzVkt7iDq/UVl X-Received: by 2002:a05:6a00:23c8:b0:623:e4d2:d13e with SMTP id g8-20020a056a0023c800b00623e4d2d13emr22155732pfc.34.1681725483975; Mon, 17 Apr 2023 02:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681725483; cv=none; d=google.com; s=arc-20160816; b=VQmKIesFhqqproN2LMNT7OKygAWWcA1NkS/FnrayEjDfxctsloCCY5aLp6EoQ9cI1b ZAOgYh6rCXB7AavNTvrtbX2F9ZXUz/QKEdmjxnVaxnvj5sqGSN7PotzNEBAWNwEdlGGF 79LMz1cMkQ4Ed7V62OJaRjZD+tT1L2Rzm8zeHWgQPxQBm0Q2Yjcq4RJ0vcWtJFbPNQgO q6GvULSh5LAwlPP3HLmCDVNRwppJI5k7dee8XRReIXs8EgIz8YlfF+8jt4VuwGZcDbhs j7qZNpEewq7ZLy/3opeCvO77+iByMdCVLglst6c7q73MqhGjk8RGZk50rV71etaqdxmt YuOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wY/LAZI9h71fcrGTkcVOz0yNhpLsuosql9Dz2QErK70=; b=COwgWCALT3/srX8BBODjOK9kuQmnmwIYrNtlKvlJoZn2usfjrNexoppknFSN2crrgu 4Rm0gqj42it7LIYqI2gavEDXzisHwOv68w9stWhjO3d6ELmZFVzeGEaZKs1YuNzzLxWz 2HdsSqTIwh9rJnJrcoMGTbOoF3sYVyA2gOAfdn64lwgLpAdTVBONiUML+GZQUPRGu/k3 /qhHGVE8Ri622p+Eos6/JcZlZB976Suz/cBlsHenCHO9ByH8CaOSy++Jtxsdtnk+N6hd FVPfJkiU7CJKztB5YC4dMHcNK12FqA6lHwXILicXkdwa2sTFOTCy5RfBhuC2MSO1ZuIF othA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g32-20020a635660000000b0050beec91e30si11670206pgm.768.2023.04.17.02.57.49; Mon, 17 Apr 2023 02:58:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231162AbjDQJsp (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Mon, 17 Apr 2023 05:48:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230414AbjDQJsA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Apr 2023 05:48:00 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 04030558A; Mon, 17 Apr 2023 02:47:22 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxidmQFT1kleMdAA--.34948S3; Mon, 17 Apr 2023 17:46:57 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxtryKFT1kyagqAA--.47974S19; Mon, 17 Apr 2023 17:46:56 +0800 (CST) From: Tianrui Zhao <zhaotianrui@loongson.cn> To: Paolo Bonzini <pbonzini@redhat.com> Cc: Huacai Chen <chenhuacai@kernel.org>, WANG Xuerui <kernel@xen0n.name>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Jens Axboe <axboe@kernel.dk>, Mark Brown <broonie@kernel.org>, Alex Deucher <alexander.deucher@amd.com>, Oliver Upton <oliver.upton@linux.dev>, maobibo@loongson.cn, Xi Ruoyao <xry111@xry111.site>, zhaotianrui@loongson.cn Subject: [PATCH v7 17/30] LoongArch: KVM: Implement virtual machine tlb operations Date: Mon, 17 Apr 2023 17:46:36 +0800 Message-Id: <20230417094649.874671-18-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230417094649.874671-1-zhaotianrui@loongson.cn> References: <20230417094649.874671-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8CxtryKFT1kyagqAA--.47974S19 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7WrW7Xw4fGF4xGw1xtw43KFg_yoW8JF4kpF yfurs5Kw4fX3ZxW39xXwn7Wr13Xr4vkF17ZFW3ua4rZrsrtr1vyFnakrykJFWUtayrCr48 W34ftF4jgFWUJw7anT9S1TB71UUUUbUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b4AFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4 AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF 7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6x kF7I0E14v26F4UJVW0owAaw2AFwI0_JF0_Jw1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAq jxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E74AGY7Cv6c x26rWlOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkF7I0En4kS14v26r1q 6r43MxAIw28IcxkI7VAKI48JMxAIw28IcVCjz48v1sIEY20_WwCFx2IqxVCFs4IE7xkEbV WUJVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWDJVCq3wCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr1j6F4UJwCI42IY6I8E87Iv6x kF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7xREWSoJUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763416980901667376?= X-GMAIL-MSGID: =?utf-8?q?1763416980901667376?= |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
April 17, 2023, 9:46 a.m. UTC
Implement loongarch virtual machine tlb operations such as flush tlb by
specific gpa parameter and flush all of the virt machines tlb.
Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
---
arch/loongarch/kvm/tlb.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 arch/loongarch/kvm/tlb.c
Comments
Hi, Tianrui, On Mon, Apr 17, 2023 at 5:47 PM Tianrui Zhao <zhaotianrui@loongson.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@loongson.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 >
在 2023年04月19日 10:02, Huacai Chen 写道: > Hi, Tianrui, > > On Mon, Apr 17, 2023 at 5:47 PM Tianrui Zhao <zhaotianrui@loongson.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 Ok, I will replace loongarch with LoongArch, thanks. Thanks Tianrui Zhao >> Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.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 >>
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); +}