Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4284898rdb; Thu, 14 Sep 2023 18:54:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXdULLOTuT7zeSpk1xJ2Ev6PU2/EhA6kCjYOUeU6dHlafnqxNIyTLA0t0XorxE2YzopriD X-Received: by 2002:a6b:c94d:0:b0:795:172f:977a with SMTP id z74-20020a6bc94d000000b00795172f977amr234196iof.1.1694742876084; Thu, 14 Sep 2023 18:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694742876; cv=none; d=google.com; s=arc-20160816; b=KdwdMznENg1e9FjzJVlenjJWqFFIwZd/gKXhx+cdtHfXVkhbBJWPMRoVvOM89QaMoD Vw9Y62OoAimo5lQTNIsRq5QWPZuqQQnttRP49XUzedNnfohZXbAwu8i5J+eXSENuivEq xRU5DpVXUu3gIB+sLZbE48r5w3cYAqMz75jmV35B3lGYLaXUhVtM3s7vg2Dfywoe+ACb m+tZLhCRPrGwdngsy0PLZQ9/gM+vyzCTvFF+lHtoqYsg4m+WEMI5g+qgxpm7Z0jH4vl1 WyjvlYXp65yPA4E5R1EK9i01Sak6wAQzSpy3+U4h6cCxMVtzAaYTsVtwkm+A2/0hhHD0 7kmQ== 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=YWEI/EMaxKsGk6pE9xXB+y/niKCE/P2Jl+SCRCRJc+0=; fh=ejoaVAUUbBXsA/6jM/beuI9xCYtV2osdR9SpI7hjY84=; b=IUt+9RQcNVfh42NW87Bw6bb+QjgEYsKNaDES/OrlyAWgaQPAMCVxXRj8R9ZRssXsz/ fGVQIivJoI+SeKqxDCMZzOpK6gKOL+SaRgBnh7SNi7/PbWYdQOD/LdhbPLcos7RKr/OG jA4oj8Uudl/k5kKX1xp+PB+1YAsBRHon/KdWQvSXZfq5+yM/pQ8qY3ZeTbiwaBdjTcmD NlhUMNhKnSz5UjlyfZnbHP/OTuwoEncGTLbUfW5qRg07SWp6ZN20AUenGAae1lU42cIy WHMS6pa2ZosRlox1CetQoApzK9sgMAlsVmmfilq0g8cm0TqRhIhQcwMLKKSOjG5wQY1e 9g4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id x5-20020a631705000000b0056534435116si2391390pgl.806.2023.09.14.18.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 18:54:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id EF30E84DC462; Thu, 14 Sep 2023 18:50:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231642AbjIOBuk (ORCPT + 99 others); Thu, 14 Sep 2023 21:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231549AbjIOBua (ORCPT ); Thu, 14 Sep 2023 21:50:30 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 657632722; Thu, 14 Sep 2023 18:50:06 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxtPBHuANlDv8nAA--.12417S3; Fri, 15 Sep 2023 09:49:59 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axndw9uANl+ioGAA--.11927S18; Fri, 15 Sep 2023 09:49:58 +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 Subject: [PATCH v21 16/29] LoongArch: KVM: Implement virtual machine tlb operations Date: Fri, 15 Sep 2023 09:49:36 +0800 Message-Id: <20230915014949.1222777-17-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230915014949.1222777-1-zhaotianrui@loongson.cn> References: <20230915014949.1222777-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Axndw9uANl+ioGAA--.11927S18 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 18:50:42 -0700 (PDT) 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 | 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 0000000000..0bcbd80ac6 --- /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 +#include +#include + +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); +} -- 2.39.1