Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3057829pxb; Thu, 3 Feb 2022 23:34:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxlPo078OZW6lWkTzDDMp2ijngXFz1Vg7QyeNd0fL4vj02k3O6MRxMTrRZ+DuUMCVk7q6w X-Received: by 2002:aa7:88c7:: with SMTP id k7mr1777377pff.38.1643960043610; Thu, 03 Feb 2022 23:34:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643960043; cv=none; d=google.com; s=arc-20160816; b=GEnEEyFaM0q8U2vxnVmZTpLYDin/V8Vo0ZPRc6ENHR+xDwQNeeMzU8rdAxxYh458Ru sqJzp1JiswRu8GaRG+SCQwRgAzLkJdwKw3Pirqp53cvDs9K+t1D1dJDemzc88sH2uRA0 hIjMSVTrO0KchvvkpLOIifmDJpQnPxd369sgjqXsK+5GnEQ6XX7CQjj6LiRvjodVfeTq CwLfixAPjwMNaB+IZwFWmfHORFIcqcZanqlX27DGOtvibVhzjm9NBZAdUwcBolJCjJe/ awMjFZ5hz/QYrSfpajJ165JsbUsuV5wws3Icj21qJLvIqOXY/bQn0uu41YndaZvuX+wP EN1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=X+Ou2Ig8ojG1Q4rpLhdtlRjQ2QYsf4tk9df7vvSqqRQ=; b=oXoJHclL5TnPtJwUm/H70XDm3NwXngTU2Ff2ummIW/6Vg9vSUnMYkANUyPbaMx36Vp zBcdWBkttlaYTcr2UlOyD6d/mpB/W0uY2/Tqmzf9mUVzDzAf9QHPQSHKD7sVDwsnNvDh 8/UQ49T1let002+xrEN6OSYhJr132xLsA6YR/jAAkgAO7NTvNCrZlMto5PO2jJQAsWBi lbmiRdO1TLkAb6D313t9jW18EnPuc2PL4gqdFwFQHPr6ItZgs7EsHI3DPR52rQF4xfaS zbhD3bH9R1l+wIflpw+1/OtbXXozuWRccPntUdCLIgCB41rEKfbf5nPNcBC/vOpD4oOe 4+Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=HG7pcW+b; 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 d21si1073140pfl.97.2022.02.03.23.33.51; Thu, 03 Feb 2022 23:34:03 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=HG7pcW+b; 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 S1343698AbiBBLOc (ORCPT + 99 others); Wed, 2 Feb 2022 06:14:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbiBBLOW (ORCPT ); Wed, 2 Feb 2022 06:14:22 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 008DCC061714 for ; Wed, 2 Feb 2022 03:14:22 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id o30-20020a05600c511e00b0034f4c3186f4so4321503wms.3 for ; Wed, 02 Feb 2022 03:14:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X+Ou2Ig8ojG1Q4rpLhdtlRjQ2QYsf4tk9df7vvSqqRQ=; b=HG7pcW+bWSzCh9vAOoccHchduY1ExRfO/ZCl7GAs6q/Yy6zXSNA9QzaaJMyArPE/Ol Reu9Rg03Kq/hheJ9HMRhTkj+C8RViQoXugdWycbhyvY2HTpWsHQCzKxApaVH/qWpKjXb OteVz8qFVQK7ihQiirPEjYh5N6xFhmJpOcnr5hj1zzh2PG5qGY+Qo48SVaa9Oc8vyYl2 7fRoiGGG65RdE1bfofNDXBBAXnswoOmIUbszqbAlYO2EIsdkCsis7sXHcp3U31UTL6pX 8BwG2UOVY7O5KZ3CS7JWue5Nb2QkwYfMe3F0ZNw49cLUYq+LY8uutBrXnZ5Z+akLOV2T 8Y0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X+Ou2Ig8ojG1Q4rpLhdtlRjQ2QYsf4tk9df7vvSqqRQ=; b=wC/S3XQbEx/QfhDLAJgzbXORO7EXeZYsmAwzasA1esHQrDJihcg/MU3o66zrUOYjkL VLO0E+nudBJscUYZ8lPpiFRCUjxL7YfKl4TjfznmnauXRgkuEzZpwgKBz6zFNhOEfJei p1k6xsm5rkWmf+a+H77OEvnvwe+TYlo4UzWch55FVI5lzQY/qKLhF+KFuC3syQi3X5IH uXdDJhiLEMMUcN68hsroeR8ACsKdQaEcyAoeeELJiavfVC8JOmvkFpTLmweYAhMReSeI aXDYjWBN0Wnoghe02Vdisb1bNJXm+8AUk7/mYnw+BvN5m/ZU7Pfy2Ke7MMut2Z1xpils Ncag== X-Gm-Message-State: AOAM532qGgGWdYnlsLiC2EFAveZ0EH6SGxqQkLxIlzPNCw/DctJRFWoe NZdBhOBXk3yEi/NLxMYdadkPS7B+kM2eaSO5ZYCIyQ== X-Received: by 2002:a05:600c:21c1:: with SMTP id x1mr5689397wmj.59.1643800460371; Wed, 02 Feb 2022 03:14:20 -0800 (PST) MIME-Version: 1.0 References: <20220131110307.1684739-1-mchitale@ventanamicro.com> In-Reply-To: <20220131110307.1684739-1-mchitale@ventanamicro.com> From: Anup Patel Date: Wed, 2 Feb 2022 16:44:08 +0530 Message-ID: Subject: Re: [PATCH] RISC-V: KVM: make CY, TM, and IR counters accessible in VU mode To: Mayuresh Chitale Cc: Atish Patra , Palmer Dabbelt , kvm-riscv@lists.infradead.org, linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 31, 2022 at 4:33 PM Mayuresh Chitale wrote: > > Those applications that run in VU mode and access the time CSR cause > a virtual instruction trap as Guest kernel currently does not > initialize the scounteren CSR. > > To fix this, we should make CY, TM, and IR counters accessibile > by default in VU mode (similar to OpenSBI). > > Fixes: a33c72faf2d73 ("RISC-V: KVM: Implement VCPU create, init and > destroy functions") > Cc:stable@vger.kernel.org > Signed-off-by: Mayuresh Chitale Thanks, I have queued this for fixes. Regards, Anup > --- > arch/riscv/kvm/vcpu.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c > index 0c5239e05721..caaf824347b9 100644 > --- a/arch/riscv/kvm/vcpu.c > +++ b/arch/riscv/kvm/vcpu.c > @@ -90,6 +90,7 @@ int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id) > int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > { > struct kvm_cpu_context *cntx; > + struct kvm_vcpu_csr *reset_csr = &vcpu->arch.guest_reset_csr; > > /* Mark this VCPU never ran */ > vcpu->arch.ran_atleast_once = false; > @@ -106,6 +107,9 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > cntx->hstatus |= HSTATUS_SPVP; > cntx->hstatus |= HSTATUS_SPV; > > + /* By default, make CY, TM, and IR counters accessible in VU mode */ > + reset_csr->scounteren=0x7; > + > /* Setup VCPU timer */ > kvm_riscv_vcpu_timer_init(vcpu); > > -- > 2.25.1 >