From patchwork Wed Apr 19 22:16:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E208C77B7E for ; Wed, 19 Apr 2023 22:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OAICPAbWJIaCediYLz9gNl/5qWFEyzDYawF/SPkycBg=; b=tQHoLOJUUXET1F Y6kuGLpcK5PKcl38GqZa2hMiZWfGZG+rbAUQKTGegX9MU1ivZ7R7Lkrzan0z3miY1MKfmhWO658bS pDpi4l5nbsyahqrF+059MiNRQxzeI3yVCPfDQgtec6j6nNj+rY6zm1wUp3s61ItyiAzA98om+RVaG HwIUWtHlYDhygag+uakXkN4mxlj0ekSb0VBXcH+l4FDbAhpHmZ/ZyNxkIA5j6tot607a8S1IFNJAW W9i9dSXYKn3ByihxYeIoIJt2WJAH0j3tmHeKCaZe4umKPsftSo7xNoKi0lUHFwIN9JkTe98M1mJpP /EEWxUY4PA+pAZS6yNRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppG8H-006TJO-1c; Wed, 19 Apr 2023 22:18:33 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppG8B-006TCR-0t for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:18:31 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2466f65d7e0so177972a91.2 for ; Wed, 19 Apr 2023 15:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681942705; x=1684534705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UJcz91lEoSJqtalpSfBSHZNF30nj7YibjBRer+eosEg=; b=qMbw2bfkgktxDwIJo8enIEL5pLtnbolY3+JaaISTkIKsa3/Pbsco4zcJlI15aLKelR WFKrKF2Hz7v5krpEvYpYwDTqJPbGu3BuJcQtCe9xizDdAggE5jW1G4X8qqMenNOBqXz9 5gqd6GiYE1ZkgW2qNIjSboTRdUgFAKPx3ibrEbYtA8McCRZRHbdZdMvH67xn6xctz3io Yx4YAKRBSdhdHTVV7HAXUHddiREJjeIsjlNB/MFPQtt0zqpmQorHvJ8xpPjM9lkMYa3A PJWfAzX50ZJIGmvwtxGZ3PpJ/kZeMQBLQ0BYf7N4KMtYq6ZlC++uPwgnbCGRBd8idM/u /cyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681942705; x=1684534705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UJcz91lEoSJqtalpSfBSHZNF30nj7YibjBRer+eosEg=; b=Sq4ZYLcllf4b8jQxUdiQVKxZKjXjjK7ceFdYxOaY9/fsnZnPlrazsYAXzwUWeZnniB UFXxTFV4qjk9olnbQgvVTpEgmXqei+osekKGmLm4MpGNOURKHRrnj2nKJb/i/87yzhHd Yif79bQ3eQzTekV1Pmode+SJKenHoJ9LNZ33Hwi62Ul5NJc3L7LWek1n4wMaXE4zU3AA 1C2T87L7XBv4xGIeAgi6stfkT45HeP0scuHYtdkeUojdiMl1R0BHdSKbRwqPpzRhHnXO CZdSRla+eLoZep6rtG9VuRUebGA0Azd/fEhBXVBZyuZ9ShxXhB88aHCY8uWQAXE8fRZT Psdg== X-Gm-Message-State: AAQBX9cb86gGJh+aA8Sq7m/Ay8t3h+/AxqYpAn9ZQD7dtNcXQCzFom3D XQZAnkD3H/i1cDXUtYCo7bgSVg== X-Google-Smtp-Source: AKy350Z8cKy3RK/3X5ej3IZFoGxmT2xiFm/BExphbF3ahTLRykDnPstTsJrfduCst6vY0llDQCAqqw== X-Received: by 2002:a17:90b:890:b0:23a:333c:6bab with SMTP id bj16-20020a17090b089000b0023a333c6babmr4018734pjb.23.1681942704931; Wed, 19 Apr 2023 15:18:24 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id jn11-20020a170903050b00b00196807b5189sm11619190plb.292.2023.04.19.15.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:18:24 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Christoph Hellwig , Conor Dooley , Greg Kroah-Hartman , Guo Ren , Heiko Stuebner , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Mayuresh Chitale , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC 25/48] RISC-V: KVM: Skip HVIP update for TVMs Date: Wed, 19 Apr 2023 15:16:53 -0700 Message-Id: <20230419221716.3603068-26-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419221716.3603068-1-atishp@rivosinc.com> References: <20230419221716.3603068-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_151827_320183_24EA0BAF X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Skip HVIP update as the Host shouldn't be able to inject interrupt directly to a TVM. Signed-off-by: Atish Patra --- arch/riscv/kvm/vcpu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 43a0b8c..20d4800 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -822,7 +822,10 @@ void kvm_riscv_vcpu_sync_interrupts(struct kvm_vcpu *vcpu) /* Read current HVIP and VSIE CSRs */ csr->vsie = nacl_csr_read(CSR_VSIE); - /* Sync-up HVIP.VSSIP bit changes does by Guest */ + /* + * Sync-up HVIP.VSSIP bit changes does by Guest. For TVMs, + * the HVIP is not updated by the TSM. Expect it to be zero. + */ hvip = nacl_csr_read(CSR_HVIP); if ((csr->hvip ^ hvip) & (1UL << IRQ_VS_SOFT)) { if (hvip & (1UL << IRQ_VS_SOFT)) { @@ -1305,8 +1308,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) */ kvm_riscv_vcpu_flush_interrupts(vcpu); - /* Update HVIP CSR for current CPU */ - kvm_riscv_update_hvip(vcpu); + /* Update HVIP CSR for current CPU only for non TVMs */ + if (!is_cove_vcpu(vcpu)) + kvm_riscv_update_hvip(vcpu); if (ret <= 0 || kvm_riscv_gstage_vmid_ver_changed(vcpu->kvm) ||