Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp994799pxp; Wed, 16 Mar 2022 23:50:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1Ra/vbCDZQkksEd6OJmyKnXNu9pMcsmM8VMd6KhI2PzQNROIkpdbPgPAh9dGx3T8a0tN5 X-Received: by 2002:a05:6a00:14c9:b0:4f7:763b:2efd with SMTP id w9-20020a056a0014c900b004f7763b2efdmr3506393pfu.55.1647499802193; Wed, 16 Mar 2022 23:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647499802; cv=none; d=google.com; s=arc-20160816; b=fm45PZNDMKqD0KK9iWWWfUKBcce3tcRdXKfWHPomKilZeqNv5QPL8aIMrpB5DupXV/ Kc29kdFphadHkVC/Z46hkyiSOKTe54xq4zeJT8lAM3WDx0HIGmwCADoCdFNprvPt5JIn s5Qptzz27kZ1sLCmTtr0SYRpRQZ42ZRMuE1pQDY7DISv4VnTQlblIu0o0lg2cYCuo+AZ 0iISOcoD/zcNszY6dZwpuWjaN1+8RLbx36DsUGaVtFmV+/Tm5xsTbtjIzLdeMNqP31Hq +ICf8DebmbwXjB/QEGH/kujvoIcH//NV1O5La0gsFfq79uWZqdobqoK9QbfQtOzCzHFG f2aQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=VvVRu/eQ4rluWWC4xLbR2tgbkWAUCRDnVAYNhV1Z6xc=; b=jcOV1YjF4mG0a2hM45W63U6CwLvu9bLa2rmHcooyJA4r80eykXXr1uVFwfxo4n+eqZ kUz9EVJB2YQ2t4wnsed78TP50utm2rk3vXxz5yS236iCD3hxN6uSemfp+fN21nAPcyW8 f2SXiHKet+ctTB18u8aQzjJ7gc/07CXWEFL1Zfk6WBiuowHPTpYUwC2Wy7ht5d9/8mhB FYVeZHzW/GGOotGhNA+EhLffM6MrXjh9JrU/5O91+mhitPXrrqhIvUvazVeGh4SgOA01 CvP67exgwjPvnQ8kWcHecWdqPRKN28V2Y9ST/DT+GHvqbYrFNEyV4IdRS82xB13HhbrX +9qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="M8svGS/i"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y6-20020a655286000000b003816043ee7dsi1134444pgp.114.2022.03.16.23.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:50:02 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="M8svGS/i"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D85A31BB7B9; Wed, 16 Mar 2022 22:35:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229464AbiCQFe4 (ORCPT + 99 others); Thu, 17 Mar 2022 01:34:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbiCQFez (ORCPT ); Thu, 17 Mar 2022 01:34:55 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E9182335F8 for ; Wed, 16 Mar 2022 22:02:36 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id kd12so3495348qvb.1 for ; Wed, 16 Mar 2022 22:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VvVRu/eQ4rluWWC4xLbR2tgbkWAUCRDnVAYNhV1Z6xc=; b=M8svGS/iYe/6Axq12vi5bRDCEMlzc6Ij8qRz9Jv2zShz/ObYi/K8LvxnXddnqwdlZ5 Hy8n9AmCKbusB4osSPTnHAVp8vUxmh7SSg9lwbwwufhybms+bvk63V8UIvo3q7mbeWUr ms0f7znXjC7cHbVmrOohql/i6f8ctFGbu8I9sNEgFyiZeOLtmREtacl8Yw4snmOA8pXM kQilYsz8Wh8v2crCMneeQf+7yJnPEZ2x4vdo/qdi/D/NOFRsSbZ+5MsxXFKvgaMYLpf+ WUk8rZ4g3h3S5QvnL30UOp/JJuMmWm3L6uvPr4rQBgKs/g6hiojbCciTRUP/h0N9SzjX D/YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VvVRu/eQ4rluWWC4xLbR2tgbkWAUCRDnVAYNhV1Z6xc=; b=AC1TZFB+NXjyApUwfjEqJG8AnFd/vH2QU5AKNbpXNYrAExtcGNlSTcCag1tS2Smuly zF7KoOxgCchy4RjquJQs74qtuVfrpHyJDMC7fS0xsAgrs3FuWKddp0A4fDQAg9DT05J4 hxuHjkDIyegAcXd14C5QLP7OBsdQlDvJfSqS1ySn33h7JTvbyWbxcYtMe2Zluv6TCTf9 yUCTMNzWVQshhIfuEcjdpnnFequB0h6QgjVI9hCR3S8qTYkcg4bWZ1E/oQMwtvNY+Tjg A1hK2v810M9grJuTknG0Gj5BUotgBx99IxYPo295sgHsLAxGalROff3Ljb3d8fmd8SPO eR4A== X-Gm-Message-State: AOAM533dvB6pb0wILK6ICz5KeFwWilIsokqi1hGXXOErbITuoriA38CH ddhWTKlzYqMSrsEm5NWPNo/f7/4p8+Xznw== X-Received: by 2002:a17:903:234d:b0:153:b63f:8abf with SMTP id c13-20020a170903234d00b00153b63f8abfmr3060697plh.51.1647489342392; Wed, 16 Mar 2022 20:55:42 -0700 (PDT) Received: from localhost.localdomain ([122.171.160.59]) by smtp.gmail.com with ESMTPSA id 132-20020a62168a000000b004f40e8b3133sm5074436pfw.188.2022.03.16.20.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:55:41 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Alistair Francis , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , stable@vger.kernel.org Subject: [PATCH] RISC-V: KVM: Don't clear hgatp CSR in kvm_arch_vcpu_put() Date: Thu, 17 Mar 2022 09:25:21 +0530 Message-Id: <20220317035521.272486-1-apatel@ventanamicro.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 We might have RISC-V systems (such as QEMU) where VMID is not part of the TLB entry tag so these systems will have to flush all TLB enteries upon any change in hgatp.VMID. Currently, we zero-out hgatp CSR in kvm_arch_vcpu_put() and we re-program hgatp CSR in kvm_arch_vcpu_load(). For above described systems, this will flush all TLB enteries whenever VCPU exits to user-space hence reducing performance. This patch fixes above described performance issue by not clearing hgatp CSR in kvm_arch_vcpu_put(). Fixes: 34bde9d8b9e6 ("RISC-V: KVM: Implement VCPU world-switch") Cc: stable@vger.kernel.org Signed-off-by: Anup Patel --- arch/riscv/kvm/vcpu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 624166004e36..6785aef4cbd4 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -653,8 +653,6 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) vcpu->arch.isa); kvm_riscv_vcpu_host_fp_restore(&vcpu->arch.host_context); - csr_write(CSR_HGATP, 0); - csr->vsstatus = csr_read(CSR_VSSTATUS); csr->vsie = csr_read(CSR_VSIE); csr->vstvec = csr_read(CSR_VSTVEC); -- 2.25.1