Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp34315rdb; Thu, 31 Aug 2023 02:04:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhMmgz6G43xUet6HRugQ13XjINU2FwVsrmwB6x7jd1bUvAEnQFvwYZKtSL4QU4PP5gGMo7 X-Received: by 2002:a17:902:e752:b0:1b6:7f96:42ca with SMTP id p18-20020a170902e75200b001b67f9642camr4782358plf.66.1693472644052; Thu, 31 Aug 2023 02:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693472644; cv=none; d=google.com; s=arc-20160816; b=lV8RSnlKdkIDtK8T1u+Lj4yfl0Yy36h6xssd9j78mzzzHb/UvEzq6pklT5UXaYvX1y iThDLfTinM9dhF/MpBTOkiQFIgPTV8XMenGjQBRQ9hVur05htIGIpBE0dLaVe8aXUj81 paQUx+2Uqkd615Qg6gzgs2LiWFltITV2TRyYkAt3CsCbjHl0FiQHbbgqtWzR6WjPaYQH kuRR3bL9zbMNGj3Zfs/12qH7D3Cv5Vlc1bJntmf8soT029zcv8TLxZBos0u8y0GxHOGv OhGpeIvcevLEdlR8yh1q93g+HRy71saXEwXVhySeJ/8kvtUKQ/wPDf7klJjCjHVX8eO5 DItQ== 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=Kxtv34grJG+AjT/+h4+aqaZeB/km4ZjyPWNEbvqIBhc=; fh=ejoaVAUUbBXsA/6jM/beuI9xCYtV2osdR9SpI7hjY84=; b=aTd5tFJsC/AmTfd86y1GtP03wWVtsKzqGokL6/GhBsbkvaKvGRzfF1YKtYzYFzoCHY H0ywEK/3PZQH2QALF2p9rg1pZgU+QAnyHBxRi5BrQLuBSMMloLfDFe0822lQ06KquhVU XO+Fl9r27hrJS75Lgz00H9vc7o4EpcrhYKPi6lLD4oX5sgQb5JFkRZO3fArT8bgZQ/WH rtXrMTi6oxOvNJQ+FZIqiLPtd0/5c8Hq9+FFOjTENLlO3IT8V2tInDMv2EUTHasvT+41 z+W4hOTn73AIgP7x9gHJvxKxYuHEg8U5EH8lKZHbuy3LC2V/YeV0p09MJfaqeN3vqvlo aW0Q== 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 jd14-20020a170903260e00b001bc5f13c67esi758236plb.589.2023.08.31.02.03.34; Thu, 31 Aug 2023 02:04:04 -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 S244035AbjHaIbk (ORCPT + 99 others); Thu, 31 Aug 2023 04:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245131AbjHaIbQ (ORCPT ); Thu, 31 Aug 2023 04:31:16 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E4CCBE64; Thu, 31 Aug 2023 01:30:40 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8BxHOuqT_Bkh14dAA--.55397S3; Thu, 31 Aug 2023 16:30:34 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Ax3c6gT_BkOPVnAA--.55892S19; Thu, 31 Aug 2023 16:30:33 +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 v20 17/30] LoongArch: KVM: Implement virtual machine tlb operations Date: Thu, 31 Aug 2023 16:30:07 +0800 Message-Id: <20230831083020.2187109-18-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230831083020.2187109-1-zhaotianrui@loongson.cn> References: <20230831083020.2187109-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Ax3c6gT_BkOPVnAA--.55892S19 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, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 | 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.27.0