From patchwork Fri Jan 27 18:25:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 49585 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp980734wrn; Fri, 27 Jan 2023 10:28:57 -0800 (PST) X-Google-Smtp-Source: AK7set9wNL9eTxwA1BJPb26XebAQdW/ScVnhEqxJxrLEPUJ8CLRd/XCYPlOxTjjxcdapcF/czwIM X-Received: by 2002:a17:90a:14a5:b0:22b:b25a:d0a0 with SMTP id k34-20020a17090a14a500b0022bb25ad0a0mr7612377pja.15.1674844137118; Fri, 27 Jan 2023 10:28:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674844137; cv=none; d=google.com; s=arc-20160816; b=DDJJPwKippk5NKug0H8yonf1cGyQVEy5T/T+E3zENPh3V3aAHPC7KdQnUDEfaM2LmJ O9o2L5vxO45dUP3sBKAkYoxYNlf05CpXONZ7C6KGxaAQjRxjDZtZ8Hu02SyBCyeNBkHe rlV0AfX79ucfb18Y+eykexkWGLrEiQxHlv/l4Y1vzHq5Jav5mxEUqSANgqfSKWnSKeQb 5Iu7gpPXyr6Eg09BSDGdgeGJ27xhxC5zDtr41cjSrCH1LanHnhQrOrJ0EcmROFNKF0Bm xiTi9tHycUSER8pvaaBgJ2Z4pmrIV2dt31UWJ3OYSJ/84sXgO7CIUKCt8p+pB3TSzL0y eFgQ== 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 :dkim-signature; bh=+UCsgdBat0A/X8QbgW8UxlHki/znQOwLUkBQOZIZWgo=; b=m848bajIOYzY961IMKACB/xpDKVvrytgJ/fF4q32mO1PqPS432Sgc5eVgzLA46X/l5 1dS82MQgXPO4BIex3dpdrAjb7/05W6CTfb4uaYQ5x168D2/qKNMa5qgfXo3zm/ztZUpM gyjebJMqH7z368Znrp7avFmUbRWgKu7tabcHdaUel8TQ1rgBFxh9uYDyS6dnVxrlNop+ uuJbxIjw77Jai0zUwoUVJOqbloOPi+7616kWENth74t7nLbdWGDFB8ekLPeP92i6t508 hacbT5Ny7hmSuAWb0Imi5QezxDx+jeT4LpjfKZ18DFcHl3XldbXU2VfmYl5UJToIfJgg K2NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=qTZC1QY7; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id in2-20020a17090b438200b0022a8b5c12a3si5254883pjb.50.2023.01.27.10.28.45; Fri, 27 Jan 2023 10:28:57 -0800 (PST) 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=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=qTZC1QY7; 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 S235375AbjA0S1K (ORCPT + 99 others); Fri, 27 Jan 2023 13:27:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235377AbjA0S0p (ORCPT ); Fri, 27 Jan 2023 13:26:45 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6553C86EBE for ; Fri, 27 Jan 2023 10:26:27 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id z13so5869546plg.6 for ; Fri, 27 Jan 2023 10:26:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; 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=+UCsgdBat0A/X8QbgW8UxlHki/znQOwLUkBQOZIZWgo=; b=qTZC1QY7AeVzJn+28DVAop48QwDUY48K0u17ecV9zQxbYCz8Bg0s0HQDbQQdG3i41g v5X9wikUTMaYjBauUozPB+4ZVT9+zlxxRx2QVnto/2ZSqEoEJmJJvGXq93/NWmNM7qty iyCV3IWGqunMwM2I0qqk/L2qU/CbnX27dkHi0Tj+ci20TWqvQq40vIYzLE4pAndkjDkA +esrjVhQT9YpuS8LApEcU6yXB8A7qt0g5+RlwG6LwG3XsiKOzFZM8V0bgCeGoE9p7Dd5 fOs1D/B65zdExuEvvvu7GjNNTmZkd0G73g3i8rKtDa47KKPlK3mBmyTY/KuRBKY4dNWj FNRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=+UCsgdBat0A/X8QbgW8UxlHki/znQOwLUkBQOZIZWgo=; b=mQ1QGuRhQniTIU3CFqcIuHld1S53j6fhg5INCL8LOas7VpyPiNTj90Tkzo76/1yc0u VvvMBkIgfWNlEf2uoKp6WU2dOXEwy4adv4KbGL40FjVSMbWl8yhL/NC5o25pXWEGvfmk m7A/ltC+W1z6fyVaov1t81N+FB6NYzJhGH89NFP/XYLAg4K9XZqPeE5NtOHJj5pup9pV JxjB/5nLAntq7YiYq14S76do8dChsW5xDzAkbDdfHdquLe2R9WmS+mT4yhHn9TswBIuv IBfB8twbcDwr4cz+EpNYLPx4wlggtIo8+fLxloQeXTu4FNczMJN0h7BMbyhYs4M5kdfJ T0gg== X-Gm-Message-State: AO0yUKVa53pjx37IExqfbi6sStTGUc/pRP855snbaRMrgTirIWQ6mwtI rRGKl4rsR2YKO1q8pTMRMTQxvR4VOGnQaRux X-Received: by 2002:a17:902:da8e:b0:194:6f3b:3aa1 with SMTP id j14-20020a170902da8e00b001946f3b3aa1mr7245179plx.55.1674843986465; Fri, 27 Jan 2023 10:26:26 -0800 (PST) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id jc5-20020a17090325c500b00189d4c666c8sm3195219plb.153.2023.01.27.10.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 10:26:26 -0800 (PST) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Anup Patel , Atish Patra , Guo Ren , Heiko Stuebner , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Sergey Matyukevich , Will Deacon Subject: [PATCH v3 14/14] RISC-V: KVM: Increment firmware pmu events Date: Fri, 27 Jan 2023 10:25:58 -0800 Message-Id: <20230127182558.2416400-15-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127182558.2416400-1-atishp@rivosinc.com> References: <20230127182558.2416400-1-atishp@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756201366185816236?= X-GMAIL-MSGID: =?utf-8?q?1756201366185816236?= KVM supports firmware events now. Invoke the firmware event increment function from appropriate places. Signed-off-by: Atish Patra Reviewed-by: Anup Patel --- arch/riscv/kvm/tlb.c | 4 ++++ arch/riscv/kvm/vcpu_sbi_replace.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/arch/riscv/kvm/tlb.c b/arch/riscv/kvm/tlb.c index 309d79b..b797f7c 100644 --- a/arch/riscv/kvm/tlb.c +++ b/arch/riscv/kvm/tlb.c @@ -181,6 +181,7 @@ void kvm_riscv_local_tlb_sanitize(struct kvm_vcpu *vcpu) void kvm_riscv_fence_i_process(struct kvm_vcpu *vcpu) { + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_FENCE_I_RCVD); local_flush_icache_all(); } @@ -264,15 +265,18 @@ void kvm_riscv_hfence_process(struct kvm_vcpu *vcpu) d.addr, d.size, d.order); break; case KVM_RISCV_HFENCE_VVMA_ASID_GVA: + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_HFENCE_VVMA_ASID_RCVD); kvm_riscv_local_hfence_vvma_asid_gva( READ_ONCE(v->vmid), d.asid, d.addr, d.size, d.order); break; case KVM_RISCV_HFENCE_VVMA_ASID_ALL: + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_HFENCE_VVMA_ASID_RCVD); kvm_riscv_local_hfence_vvma_asid_all( READ_ONCE(v->vmid), d.asid); break; case KVM_RISCV_HFENCE_VVMA_GVA: + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_HFENCE_VVMA_RCVD); kvm_riscv_local_hfence_vvma_gva( READ_ONCE(v->vmid), d.addr, d.size, d.order); diff --git a/arch/riscv/kvm/vcpu_sbi_replace.c b/arch/riscv/kvm/vcpu_sbi_replace.c index abeb55f..71a671e 100644 --- a/arch/riscv/kvm/vcpu_sbi_replace.c +++ b/arch/riscv/kvm/vcpu_sbi_replace.c @@ -11,6 +11,7 @@ #include #include #include +#include #include static int kvm_sbi_ext_time_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, @@ -25,6 +26,7 @@ static int kvm_sbi_ext_time_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, return 0; } + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_SET_TIMER); #if __riscv_xlen == 32 next_cycle = ((u64)cp->a1 << 32) | (u64)cp->a0; #else @@ -57,6 +59,7 @@ static int kvm_sbi_ext_ipi_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, return 0; } + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_IPI_SENT); kvm_for_each_vcpu(i, tmp, vcpu->kvm) { if (hbase != -1UL) { if (tmp->vcpu_id < hbase) @@ -67,6 +70,7 @@ static int kvm_sbi_ext_ipi_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, ret = kvm_riscv_vcpu_set_interrupt(tmp, IRQ_VS_SOFT); if (ret < 0) break; + kvm_riscv_vcpu_pmu_incr_fw(tmp, SBI_PMU_FW_IPI_RECVD); } return ret; @@ -90,6 +94,7 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run switch (funcid) { case SBI_EXT_RFENCE_REMOTE_FENCE_I: kvm_riscv_fence_i(vcpu->kvm, hbase, hmask); + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_FENCE_I_SENT); break; case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA: if (cp->a2 == 0 && cp->a3 == 0) @@ -97,6 +102,7 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run else kvm_riscv_hfence_vvma_gva(vcpu->kvm, hbase, hmask, cp->a2, cp->a3, PAGE_SHIFT); + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_HFENCE_VVMA_SENT); break; case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID: if (cp->a2 == 0 && cp->a3 == 0) @@ -107,6 +113,7 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run hbase, hmask, cp->a2, cp->a3, PAGE_SHIFT, cp->a4); + kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_HFENCE_VVMA_ASID_SENT); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA: case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID: