Message ID | 20230530015223.147755-18-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1877216vqr; Mon, 29 May 2023 18:54:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ429bG8x4TNdwyKatNbYixeGwYF2v6tQgbYwNi+1bMjOtDWZ968PF3qosLHPcQCKN3pnHtQ X-Received: by 2002:a17:90b:33ce:b0:256:2ef:92ec with SMTP id lk14-20020a17090b33ce00b0025602ef92ecmr1000447pjb.1.1685411667130; Mon, 29 May 2023 18:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685411667; cv=none; d=google.com; s=arc-20160816; b=C2PLjkaQ4NPYraBdUTfK+QlAFq6y8zH+YU9TxYjyTu2vrvT2KVmB9VjN1CVw+U5+qr sDOovshcx7K9shWycHXdr6Usw3JP+sGUax5AgYy2CwAETxP7gdPo8H9zcQ5hSr7ctv5d 0kH5JLZF22+aL32qpZVx5sZzpVXdaHvN6Dvc+qAPu3vg/uSmnqDO05yok7opl8qlCGVL DZ1PVGcEzacZWY4Hf2IzbrYbCTXC2aNo6LaedkrtXJIxyyvOVJq+yZXIoD2+k7I+4J67 qGgDR4zsvQ9YYlmlacd6sNmLswmdnMSX20yj9Zc+1vCBi1Hzz7R7DkMHL3yepKKM5/wN HC+w== 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=cgeeBshqN/qidVqk7OLHA6hQyK3oK/IRm/Qr3W1dkWw=; b=v0Wvi1HqCw7gS6JyqCfqfroBB7j3elvkzXVTlFFBgf/pKDwVfA2dL4s179QAptWTBk bg1pEcS0ojhiufWtvG9dkLBh+Y3CN6sdoqBHUpuY1YX9VqxssnmBcMsDhSbEBIhNof/H B49eb+FJbQPIzxrO6WAgjm90a+/wrQ+IblAdW0jpLgd+6UnxzSBeMBlh5qiNkwTSSthh 9oYtaWj4iGmGKe02h6/vuHTPJf48SA48Xs58600R32revjmOIr3EDhGF/aVYPIi5hKNm VoypAKh5b0Mssr4ZU7VpMM9rlD+TPYDvZRsYhr21c+RZs1EMQU2bu4e8QRDQp0E6j8af mI4Q== 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 x22-20020a17090a789600b002505f319c27si4748722pjk.100.2023.05.29.18.54.15; Mon, 29 May 2023 18:54:27 -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 S230246AbjE3Bxg (ORCPT <rfc822;andrewvogler123@gmail.com> + 99 others); Mon, 29 May 2023 21:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjE3Bwl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 29 May 2023 21:52:41 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4BB34116; Mon, 29 May 2023 18:52:33 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Bx1fDeVnVkiGoCAA--.5514S3; Tue, 30 May 2023 09:52:30 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxQbTYVnVkQNZ_AA--.12077S19; Tue, 30 May 2023 09:52:29 +0800 (CST) From: Tianrui Zhao <zhaotianrui@loongson.cn> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini <pbonzini@redhat.com>, Huacai Chen <chenhuacai@kernel.org>, WANG Xuerui <kernel@xen0n.name>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, loongarch@lists.linux.dev, 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 v12 17/31] LoongArch: KVM: Implement virtual machine tlb operations Date: Tue, 30 May 2023 09:52:09 +0800 Message-Id: <20230530015223.147755-18-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230530015223.147755-1-zhaotianrui@loongson.cn> References: <20230530015223.147755-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8AxQbTYVnVkQNZ_AA--.12077S19 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7WrW7Xw4fGF4xGw1xtw43KFg_yoW8JF4kpF yfurs5Gw4fX3ZIg39xXwn7Wr13Xr4vkF17ZFW3ua4rZrZrtr1vyFnakrykJFy8tayrCr48 W34ftF4jgFWUJw7anT9S1TB71UUUUjJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bx8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4 AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF 7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aV CY1x0267AKxVWxJr0_GcWln4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l 57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6x8ErcxFaV Av8VWrMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY1x0262kKe7AKxVWU AVWUtwCF04k20xvY0x0EwIxGrwCF04k20xvE74AGY7Cv6cx26rWl4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1l4IxYO2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_tr0E3s1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4UJVWxJr1lIxAIcVC2z280aV CY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0zR9iSdUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, 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?1767282224388090796?= X-GMAIL-MSGID: =?utf-8?q?1767282224388090796?= |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
May 30, 2023, 1:52 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
Reviewed-by: Bibo, Mao <maobibo@loongson.cn> 在 2023/5/30 09:52, Tianrui Zhao 写道: > 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 > > 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); > +}
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); +}