Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1815120rwd; Fri, 9 Jun 2023 02:32:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KdEA0/ptlRmpAhkGjseVD02FrPiV5RwlWRJ8nOJVNmxcN0SMrKQ4Um0KgQWaC4ik4j8lL X-Received: by 2002:a05:6808:1508:b0:39a:9ea1:ce8e with SMTP id u8-20020a056808150800b0039a9ea1ce8emr1315366oiw.5.1686303159459; Fri, 09 Jun 2023 02:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686303159; cv=none; d=google.com; s=arc-20160816; b=I8vvncFqDDUsd3SzkCM32zqo4eatg8X0twkHJXm3D+1aVZfvmIyK49718e+N4eyDH1 JTnOC0c5sSe1qjfPb73hgV7G9dITCOdtfPSDpeJsmBTPRwEWlbOikAUNO/3aPECtiCNi KQLBI6rK2wp7lo1qQPPSsCfUZjBOpsMl6w1ePzY63aaNcRbO2VIFbKQNkY1gNuaCVkJW pdSzkEc/EaGNiJn/okKY/NXwH/prq1SMI7wEN9lUc6pu3BpwptGw1v9K7VnhcR1Z7UIN X+ruXccpfQSbEzY9BmUtGJbFMjri5P3SthJiEeNrTATKcEZ8ziIghR8O9R62NBlaMDK7 Fgyg== 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=fI5khc4BPlH2S+PeYqihlrKKQaHJnpJM0cMIR4gdPnk=; b=ebX2n/RgFo6dUiz7AcBZhxyplgVJRPzDDl0iYyUCFM/7XkdvSGnZjkRVFY/IRHEmXq iwTXTtvGYTibhy04bA/h4aCGrg2hD0SXFrOlNjEpyxIj79ERoyzpAASzR/YNSBgwxoST bj03dWAQi/McCwJysi9clIJxOu2KD5ewA+r5e99LWV61ITrXdKhVZrrOjIwm02CghhLd MpsVe+llds7oGEXELEt1gor7jAmx0KwxkEF+atnxrqdKpuRiwlEqFIdj84n3KAjn80YP dN23gUMlc980ZAKWOmTHxfravLCsyfzRjWnFtfKDeBP17Sd7XyBz2wrPXMXxHdtZK9l8 YqTA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a18-20020aa78e92000000b0066023827cf2si2261108pfr.31.2023.06.09.02.32.26; Fri, 09 Jun 2023 02:32:39 -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 S241349AbjFIJP5 (ORCPT + 99 others); Fri, 9 Jun 2023 05:15:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241517AbjFIJO5 (ORCPT ); Fri, 9 Jun 2023 05:14:57 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9AD985B85; Fri, 9 Jun 2023 02:10:59 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Dxi+oZ7IJkjv0AAA--.2946S3; Fri, 09 Jun 2023 17:08:41 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxFOQQ7IJkzHQKAA--.31790S19; Fri, 09 Jun 2023 17:08:40 +0800 (CST) From: Tianrui Zhao To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Huacai Chen , WANG Xuerui , Greg Kroah-Hartman , loongarch@lists.linux.dev, Jens Axboe , Mark Brown , Alex Deucher , Oliver Upton , maobibo@loongson.cn, Xi Ruoyao , zhaotianrui@loongson.cn, tangyouling@loongson.cn Subject: [PATCH v13 17/30] LoongArch: KVM: Implement virtual machine tlb operations Date: Fri, 9 Jun 2023 17:08:19 +0800 Message-Id: <20230609090832.2131037-18-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230609090832.2131037-1-zhaotianrui@loongson.cn> References: <20230609090832.2131037-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8DxFOQQ7IJkzHQKAA--.31790S19 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Tianrui Zhao --- arch/loongarch/kvm/tlb.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 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..3475b76492ad --- /dev/null +++ b/arch/loongarch/kvm/tlb.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020-2023 Loongson Technology Corporation Limited + */ + +#include +#include +#include + +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.39.1