From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DC91C4167D for ; Wed, 23 Nov 2022 13:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237722AbiKWNry (ORCPT ); Wed, 23 Nov 2022 08:47:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238920AbiKWNrW (ORCPT ); Wed, 23 Nov 2022 08:47:22 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90ECA13FA0 for ; Wed, 23 Nov 2022 05:36:39 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id p16so13080192wmc.3 for ; Wed, 23 Nov 2022 05:36:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hMgYAJPhRyqpy0UXUjrB3ea5pmGtcKs5Fqde6i7Nj3I=; b=SW/c4hJbN8TTlANr3vNJK5slrOe41QSdJUahynWVeaw6FftkA/D1M969Dg4QQXXFV6 GR2ncUeFn5gUnpSLm6ukuUfqPRt8Ca4GwFzVx9Kdzq5hv9btgU1O4mgNhNWS120gfd4E hzaahcWhaeXT2YCmHJla7yl6H+7EiZUPOEHwDL2bfk0rgRD23d+NsVTa20B/jl47MT0K ibpDPRWjVRGb0nAkvvNu8cHQ10x6ukbxL0Ju/cGV7YIkfjWS3aFRog5lEI72USAC78W/ Z9tLCNOjeOpkptob1pUoV036dzwMl4nLBstCpxxDpTnNFL8FxohNFTje5WAaqKKOv9Bn GBSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hMgYAJPhRyqpy0UXUjrB3ea5pmGtcKs5Fqde6i7Nj3I=; b=Ia6XMyPOIoJN4epqMDc+5htVaizw+f2xRg0xkKiabzjSqP8FPn7wTkUm8m3S0BzuDM F4Yk+WlYEXKo4w7UsnhDgHxLZxrmCEywJS7ocvosWvRyxu8e5Sg5E1tXJd50UyvYkUYm b88nE9pA02XqAhizdRePOBlRPqVm7W3kZkPLPW6QlZC+j0Wgb+eevekAFyiAV2ZYr5st rw0bIrGL2b7/5CcE1ssOm2qAJgVRGcQbquKARSZNHZFv02eRrmNrv1CzecAj9RTLi22R S7dW/dYUtJtkAZbnLJW4ctNGFnqd1vyjQ5NhzYWBNancqsTYNQR0xhzr8SmUVq/G5YCF /WGg== X-Gm-Message-State: ANoB5pkgWdcuQZ8MeoJFMU5ofaX28mjMzgb/SvdcWnBeLP936ucSrhz1 CYEsrqyV50aH2zadhrH7amY22A== X-Google-Smtp-Source: AA0mqf53LRFa5Bbp5he9If0mv7pYNlmgIJ7+W+KuA3BYsVtGKFjDhkCi0Sb0k6NCu1LaVjh9Ww7qBw== X-Received: by 2002:a05:600c:1ca4:b0:3cf:7125:fc1d with SMTP id k36-20020a05600c1ca400b003cf7125fc1dmr6594039wms.70.1669210598097; Wed, 23 Nov 2022 05:36:38 -0800 (PST) Received: from localhost (2001-1ae9-1c2-4c00-748-2a9a-a2a6-1362.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:748:2a9a:a2a6:1362]) by smtp.gmail.com with ESMTPSA id h17-20020a05600c315100b003cf483ee8e0sm2511573wmo.24.2022.11.23.05.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 05:36:37 -0800 (PST) Date: Wed, 23 Nov 2022 14:36:36 +0100 From: Andrew Jones To: Atish Patra Cc: Atish Patra , linux-kernel@vger.kernel.org, Albert Ou , Anup Patel , Guo Ren , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Will Deacon Subject: Re: [RFC 5/9] RISC-V: KVM: Add skeleton support for perf Message-ID: <20221123133636.gke3626aolfrnevy@kamzik> References: <20220718170205.2972215-1-atishp@rivosinc.com> <20220718170205.2972215-6-atishp@rivosinc.com> <20221101141329.j4qtvjf6kmqixt2r@kamzik> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ... > > > > - csr_write(CSR_HCOUNTEREN, -1UL); > > > > + /* VS should access only TM bit. Everything else should trap */ > > > > + csr_write(CSR_HCOUNTEREN, 0x02); > > > > > > This looks like something that should be broken out into a separate patch > > > with a description of what happens now when guests try to access the newly > > > trapping counter registers. We should probably also create a TM define. > > > > > > > Done. > > > > As we allow cycles & instret for host user space now [1], should we do the same > for guests as well ? I would prefer not to but same user space > software will start to break > they will run inside a guest. > > https://lore.kernel.org/all/20220928131807.30386-1-palmer@rivosinc.com/ > Yeah, it seems like we should either forbid access to unprivileged users or ensure the numbers include some random noise. For guests, a privileged KVM userspace should need to explicitly request access for them, ensuring that the creation of privileged guests is done by conscious choice. Thanks, drew