Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp138470rwe; Tue, 18 Apr 2023 19:13:01 -0700 (PDT) X-Google-Smtp-Source: AKy350aX7Vj4PjKTyiV6BOOnML7as5L7Tx2v330QZrB3JSS3HwiuK3DFIy9BAS0aKmMIQ0lTDzug X-Received: by 2002:a05:6a00:98d:b0:63b:5496:7afa with SMTP id u13-20020a056a00098d00b0063b54967afamr1810716pfg.11.1681870381278; Tue, 18 Apr 2023 19:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681870381; cv=none; d=google.com; s=arc-20160816; b=Jnrt9uCqLP5mSsbn+PLmE5AYBwFVRTg6jpJ9nbYrA6XhoPPf0dxfoP+VCF4up7IR3v T+qT2siRY23PaZIrHTaStCHHaW4xNjaN1Rr/L247X9WP0ngZ4rN9eP+MysU4SHVISEEm la4zVB3MhBpHf+liLhc/CkzApYjTwi0OmJG61BOHSz1p2FJHnGJ2XMKKP4CnGfsnbSW6 PZt3ajOlOEjdCSHAGB5aUqIqaaK8qaFK9wu4T7KQViiThMWzTvZXIaO9p8/S1O949zTC 0q+pfDNLbOlHRddH15txJuaPh3gLUTL6jLSMP0UC1CdxCBz7d14JWAew28aTvPmgL32e PmYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=WrGdrn0VRvLK27+NbwArEPf4iTD6uvNHyol/1Fz4tmU=; b=MvXg3KBZXK8i9ozGEdJFhWqqLS0OfQl6eIutKDYTOtN90hjcB3i4HUInSFyEVfzuIb SMX+lndwfQTO1E1tEOmdcrFSbwZWwB65SVHw3f35Vfigwo3JiMaCYCiK0RV0gbTUQGua R0AfpJI6GadkV0y+5iV8+ZYCQo3+kInCstor67yC1X/puBNuflJ7UJ4FVo8hxU5oNtpi Ts4YgsEYg443wXQ7+s/XeNFhkBIcNbJmoy+4IzRoQkPO4/9MxuwroX4F1UGphghI3O8A lMPr1BSjqB7oriW4aTc64ay1bioY7v/X6aN78LYGrpVl+KA7YJXDdA/OUB4KVDEy+WMm PNJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Qmd/xeWC"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g7-20020aa79dc7000000b0063b8a36cbedsi5762489pfq.148.2023.04.18.19.12.49; Tue, 18 Apr 2023 19:13:01 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Qmd/xeWC"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231753AbjDSCCY (ORCPT + 99 others); Tue, 18 Apr 2023 22:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230340AbjDSCCX (ORCPT ); Tue, 18 Apr 2023 22:02:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE344B1; Tue, 18 Apr 2023 19:02:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 67DD9637E9; Wed, 19 Apr 2023 02:02:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1580C433A0; Wed, 19 Apr 2023 02:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681869741; bh=lm0q5w4aW9UWr5JFvmc6VHFT17ZREurre436iTeCi1U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Qmd/xeWCMmjfr5V0h3IPBWzprvdmr1dJKpf26mvmJZJLOggXCCOqQz9mqHndc6FaQ tFZkaFQhTztnafLms20hmTl1owNqne78IBPhRRds6YL5o1yXYTDCAHsRbpyp8HQxIo 0NLmsOEWmUyI04pcrX1U8dzmSg636dmEYuge5E21QAjesnU7sTSW6Ema7HBmstC9Tq pI6cc+z1S1PPFKRAPLFBFLV2kk8ItPG2tLtcJ661io2OmQ/mveurMYKUntvNEqjVBF jRWH7HlLGiBMbWIE7Hkl9MxteCknegmuhJQne4PB1C8DQfJAHeZict91Z/vmqDzE+Z ipncC8sQCXjBA== Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-94f1d0d2e03so214061866b.0; Tue, 18 Apr 2023 19:02:21 -0700 (PDT) X-Gm-Message-State: AAQBX9dgGes0C7iLITNvpUB/o/Z/2pgg7JtNxbvKJV5NOQbTEmNwrJV9 XGw3SF02E1Vv/6fKXdtc+r8tYGhXqdwAApFiARg= X-Received: by 2002:a50:999d:0:b0:506:6f14:47d8 with SMTP id m29-20020a50999d000000b005066f1447d8mr421936edb.1.1681869740123; Tue, 18 Apr 2023 19:02:20 -0700 (PDT) MIME-Version: 1.0 References: <20230417094649.874671-1-zhaotianrui@loongson.cn> <20230417094649.874671-18-zhaotianrui@loongson.cn> In-Reply-To: <20230417094649.874671-18-zhaotianrui@loongson.cn> From: Huacai Chen Date: Wed, 19 Apr 2023 10:02:07 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 17/30] LoongArch: KVM: Implement virtual machine tlb operations To: Tianrui Zhao Cc: Paolo Bonzini , WANG Xuerui , Greg Kroah-Hartman , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Jens Axboe , Mark Brown , Alex Deucher , Oliver Upton , maobibo@loongson.cn, Xi Ruoyao Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Hi, Tianrui, On Mon, Apr 17, 2023 at 5:47=E2=80=AFPM Tianrui Zhao wrote: > > Implement loongarch virtual machine tlb operations such as flush tlb by > specific gpa parameter and flush all of the virt machines tlb. Use LoongArch instead of loongarch in commit messages and comments, please. Huacai > > Signed-off-by: Tianrui Zhao > --- > 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 > +#include > + > +int kvm_flush_tlb_gpa(struct kvm_vcpu *vcpu, unsigned long gpa) > +{ > + preempt_disable(); > + gpa &=3D (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.31.1 >