Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7418319rwb; Wed, 23 Nov 2022 06:21:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf77iIoHOSwbNzD8WqtJI4j+6LUBKS85ffv4foeedL43UCEC7BIWj3xdUHa8d/xC+eE65RAW X-Received: by 2002:a17:906:a257:b0:7ae:3f79:4d0a with SMTP id bi23-20020a170906a25700b007ae3f794d0amr24211809ejb.120.1669213270582; Wed, 23 Nov 2022 06:21:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669213270; cv=none; d=google.com; s=arc-20160816; b=fqT/DJuQDH45oRIzPAwsiJ5rHB/PPfwaiuXLkViq58UkMKZb3yKNrYSujvTokvtHgN JKsS/FfQhMLuUak7SZrCDxTZRE987MkW+ppln6fbp4Gi31/XCFpeqKxAAPhhysxirrX4 csL2o2rfcN/MUp6UigkFaLMeIlVq0bjl2tmqtR3IEQDOdUCnIpOXSEZ89o1S02J2glM7 wf8RsV5hwpX4EVLTIPQjJwzOET1eztPhRkSAlgoXK97OllF9xWag/E0kYKTZI63D0KwF F8rdz6aFLoPfwi6WkYKl7PymDXve4YC5NWQYsqwu1cFSVcYRksEq7O6nBAg2uWq/lVSc 2tfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hMgYAJPhRyqpy0UXUjrB3ea5pmGtcKs5Fqde6i7Nj3I=; b=I7Ms1AZDOJTxNBVY/5F5cHptTH0AJiEP45Dez4j7CYXZQ+F8IhET+x9HYwpQ5h0wcD /N/TcpgA5RPkd4HMIQ+2j1MrdCq5LDJMj9nGnhbNpE3WxxsULcdEisVZwEtarLI3oVgp YjMcT4yko3DDu00an+DTMVUIRS4UgcNF8C+UjU4/ykE3sH8RPdcQSM9PIFPS4czXJTA9 +788yE7Yclf6IQbDNrU9Xm1FQm+s3ovlJeLEgi+HADBm/Y9InxJ0jN/DG/iADziHbc/q QDkXwtub2rPRZu8PbVvPmIcMTPzgcvNgHPlHyGSexwdFhqzOuHXxJ8YbYelg2gcfOp6K GgTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="SW/c4hJb"; 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 j3-20020aa7c0c3000000b00469cb714827si4944595edp.170.2022.11.23.06.20.38; Wed, 23 Nov 2022 06:21:10 -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=@ventanamicro.com header.s=google header.b="SW/c4hJb"; 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 S237681AbiKWNrx (ORCPT + 90 others); Wed, 23 Nov 2022 08:47:53 -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-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: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 ... > > > > - 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