Message ID | 20230629075538.4063701-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 k13csp9481345vqr; Thu, 29 Jun 2023 01:28:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6p1GwEI2FozSsZ7x0OFLLkmk8u20toyzSwJaOJ54GKKPTomf+xkoCypefFsnEAO3saIOi1 X-Received: by 2002:a17:902:f984:b0:1b8:811:b05a with SMTP id ky4-20020a170902f98400b001b80811b05amr11533574plb.6.1688027283432; Thu, 29 Jun 2023 01:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688027283; cv=none; d=google.com; s=arc-20160816; b=jPLtxJ7zUOLhJx83PcuCIdVfgxxKx2gLcI0mygIp2WAMHAEAse8T1siDp4Z458FXCi utlsX/GkYw53jKkVoTdu6DsTln1q+8+P+AmyvNjq9pgHFVxxIuaWXwBMPDb1QUo9u7+V SnI85fknyzW45hLDA5B75UlmFj9Bon/MB4w/gelbXUFUdWNJPrSremD+AG+QGgboc+3q Cm5yEam35HjoqLiVoW8+k+IysNK1dnrES+sLINPwrf0MDz0nKj3hcxZemnaZnLDYcHgI v1BJxPnL4F0ldca04OKza0RvihG7zqG4zXe+uBVv4EFiK063zSeHt7d8LNM4sM4GIOrc nC2A== 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=SsYeNTXdUDPXZ/N1KdW/9dOE9bYvOzjQsNXxsXYsEV8=; fh=5MymQ7GIBp7zNXW64cKeokietRhKQkEhpOBaNYPDGGU=; b=TrXsUwJ4y8+4y0yo3jXrk+aez4enhNq65cEs1saAhRCwXcypmc3kAcJkcw7Y0QyG0o 7MimOnwMvVEp7rMr/zNCLcOAgdbWextipA8oHCSJ1XGJR9kjqFoOVrLxr9OC00qgbWqV K2A1LQGGi5JbyUswXgaev+g+EJ1V0gQZq4+aiBbcedTgawYLpfGQEv/C4eD6m73NDZVq q7ah7yvi30Xmh6MyKPa7lIetL0YABP1omgTF1GXJcUUTZkYQNxC4ZaEgQ5Bqxwj7KlHG KR1lZAizW3eQWbmTes53P5ixKxFikzLoPtaJN9bqq9MesctWIxYFP3U9E1LdCL6r1BLU HKwA== 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 n7-20020a170902f60700b001b3fb1742e4si10019542plg.547.2023.06.29.01.27.47; Thu, 29 Jun 2023 01:28: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 S232890AbjF2H7q (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Thu, 29 Jun 2023 03:59:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232607AbjF2H6A (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Jun 2023 03:58:00 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 001EE4201; Thu, 29 Jun 2023 00:55:58 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxqMUDOZ1kUMUDAA--.6165S3; Thu, 29 Jun 2023 15:55:47 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxzyP6OJ1kYGYQAA--.18424S19; Thu, 29 Jun 2023 15:55:47 +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, tangyouling@loongson.cn, hejinyang@loongson.cn Subject: [PATCH v16 17/30] LoongArch: KVM: Implement virtual machine tlb operations Date: Thu, 29 Jun 2023 15:55:25 +0800 Message-Id: <20230629075538.4063701-18-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230629075538.4063701-1-zhaotianrui@loongson.cn> References: <20230629075538.4063701-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8AxzyP6OJ1kYGYQAA--.18424S19 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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?1770024896438652301?= X-GMAIL-MSGID: =?utf-8?q?1770024896438652301?= |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
June 29, 2023, 7:55 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. Reviewed-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn> --- arch/loongarch/kvm/tlb.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 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..0bcbd80ac631 --- /dev/null +++ b/arch/loongarch/kvm/tlb.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020-2023 Loongson Technology Corporation Limited + */ + +#include <linux/kvm_host.h> +#include <asm/tlb.h> +#include <asm/kvm_csr.h> + +int kvm_flush_tlb_gpa(struct kvm_vcpu *vcpu, unsigned long gpa) +{ + unsigned long flags; + + local_irq_save(flags); + gpa &= (PAGE_MASK << 1); + invtlb(INVTLB_GID_ADDR, read_csr_gstat() & CSR_GSTAT_GID, gpa); + local_irq_restore(flags); + 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); +}