Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15849514rwd; Mon, 26 Jun 2023 02:06:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41C+7Coonxzr/aTJQJiqyE6/SdU8a9RU34LuJJUGnameRJ2l5LuJ/v2IzHLodua9he24E+ X-Received: by 2002:a05:6a20:4e06:b0:125:56d8:6724 with SMTP id gk6-20020a056a204e0600b0012556d86724mr6605890pzb.58.1687770402140; Mon, 26 Jun 2023 02:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687770402; cv=none; d=google.com; s=arc-20160816; b=tI6H0wQvnjCLse9cve4k9Dmbv5Ui8e3IsIWHRZaLRRoUZXzUVbACpFDbvdI+Ppo+MZ 10vDdbjrJ12YNRuUdtqNC/KPwJ2UEnVcLGsKt1XbZb5SlBV3xNBOA3RpDx5QIuUb20mI 9+VlZj3gYdgKbmquivdY+7gdmlf0O8IG90KJJkQjIY5TwyXJnpx7UgqJKZhMzwBEMBoH KPlLNdHf5HvMFMijvhViUXzGewhf9hBBNJbzhKVzz+NaoIr/ZYCMkCsbPBaBYEcQoHr5 VQ8/BEgZ4S+Zkw5izNmtA3B4JEkeiXNfQhr8jKZAC/wxQ6E1k1zhzj25+s0V5m1Q090z iEtg== 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=; fh=FJJE1KfQOXNgUCxk/Gxke8tBG9gBLo3aFI+sNzAMBeU=; b=eXmblx69vY6MHMwEmainbbiR5jzf7Gj8IA/vSOg5o+w26B0VjE9uvME5yPOgIXCin8 tlS0Vu7m1EkJIApujE9gkz7cYdgjoDGHv7tqLyBt+XNdOnFfYXRJkesMWuSEEaeTGK7F N4qUmdmjrWk8oKWyVP2NE64tKG9cjmy1IhMFXOm9lFNUwJ8Beq79x8A2UfbJXPoKTSgz VlkeBx3/559CIipJO6g42u2kEvz9YhCW/Gbc4FCZXbd3Gh/sRRXCwkOv043NMzsM4XKr /Esa83Rrar9Uen1icCiD/vu7081aHzsMreg3ZvjMqNF9rNE041zbSeak2zVc+8sK7mGu Aa4A== 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 x124-20020a636382000000b005409058c8d7si4807283pgb.126.2023.06.26.02.06.30; Mon, 26 Jun 2023 02:06:42 -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 S230022AbjFZIuE (ORCPT + 99 others); Mon, 26 Jun 2023 04:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjFZIsy (ORCPT ); Mon, 26 Jun 2023 04:48:54 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BD6D610FD; Mon, 26 Jun 2023 01:48:10 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Dxc8TBUJlk1jQCAA--.3480S3; Mon, 26 Jun 2023 16:48:01 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxxsy5UJlk4hQJAA--.19269S19; Mon, 26 Jun 2023 16:48:00 +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 v15 17/30] LoongArch: KVM: Implement virtual machine tlb operations Date: Mon, 26 Jun 2023 16:47:39 +0800 Message-Id: <20230626084752.1138621-18-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230626084752.1138621-1-zhaotianrui@loongson.cn> References: <20230626084752.1138621-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Bxxsy5UJlk4hQJAA--.19269S19 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