Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8710972rwb; Thu, 24 Nov 2022 03:20:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6v2UuAo6ySw8iELU1idFGlHu2AtQB9C5Xl9Sc3Z+mdFHkFplZAqmvXuCwvPCtxVvkr0/ko X-Received: by 2002:a05:6402:e04:b0:469:e6ef:9164 with SMTP id h4-20020a0564020e0400b00469e6ef9164mr11351864edh.185.1669288856783; Thu, 24 Nov 2022 03:20:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669288856; cv=none; d=google.com; s=arc-20160816; b=o1ng5lahegYi4GyAyVj+aEFQM+CWchLe8M+Yq45M6n1fGsV1jzJSBaO7PIU8aWw1xb wX8JPtFtR+IszfbAM48xKvSmlahISjrub4WsR+X0zf+cX8UdcX0y5IV51oOIc4cR9Cgf K0fD+O62rqWMhdayPi3fMJM7b3XZwO9ANOMMVea+QnF74Fo+24mtU7A4d1RlaDO+3SGC CNLDvQ7HtkvrjNQzzlETLaZouRus6S/L7dJyfKI8fztDUk59LiAJSCIXWSJkCwhRceTZ tUgmcFJVFfI9ecIsE2DMchEq20GsLuaLgKbGBJ/KxtSXELXMKQw0xQqSpWeO2v9j1KBe WZcA== 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=cDjZkRfpYrY5I/MR6Qn4PLWFtgP7s/Bq564G/WDROg8=; b=MJiOwg0YYeTuLFlZCCzPI14b3c57lqBj+2W0j/Tk0OB+G3gxLrvI1X4UiJBhSYjUIx hJur8XQ4XAy4ZueD+iik5w3Z9PU4J/CmjcS6mmuIrYwgDT7sfuhjuCH3L4/n5B6BAaPf xVfU1eHH90TP99ztNY7WJU+7M2jSce16l1KikLf7Bex+MQWcqbOa6f+wEmzGobcZmRhr m3oNxvg8fvpiLfsTIaTR57EiaoWXmealMpq/bHa48g+pywdpQpB08MC242mHdvAvbQmA 1PAQ0LuMe6B6ypytR6zWAv7v2KGmTaajqAYYyjHe/AuO0FSfQ4sgfRZ1CNH2VRxIbzQT UrlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=QO7D86ga; 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 xh13-20020a170906da8d00b007a6384d506csi681252ejb.643.2022.11.24.03.20.34; Thu, 24 Nov 2022 03:20:56 -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=QO7D86ga; 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 S229819AbiKXKzQ (ORCPT + 86 others); Thu, 24 Nov 2022 05:55:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbiKXKzO (ORCPT ); Thu, 24 Nov 2022 05:55:14 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52C93179A98 for ; Thu, 24 Nov 2022 02:55:13 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id m19so791948edj.8 for ; Thu, 24 Nov 2022 02:55:13 -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=cDjZkRfpYrY5I/MR6Qn4PLWFtgP7s/Bq564G/WDROg8=; b=QO7D86gaGFb5ZRyhP30L+tC9SacJbP+BnjiLVrXG1Hp1YNn8JYwTlPi5lxcrIDPR+a dnPFJq1vznqQ8DZIYdMjtsTvyr6fy+fBcUwdKOZA5MOZ5EHTRGfcCK8b150A8FCivC2l /xTKmQi1XygjlmKoT3qKOmrwHR+KDqrBvYfq3BMC/SfAV5Tye7wieU17VkZO08MCIh2u r7W0oOo4lwfhlVeMoeiKznszaFzh4unoLaPEcwyT5s7/rELHPpC5uIlZsRRONGgs9aF0 6atYfxlJSfwUXrZXo4kSH9QxNUwE3yOArldb/1+BjRqS56mPUocvI5YnZlCn67l4bOCl Jh6Q== 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=cDjZkRfpYrY5I/MR6Qn4PLWFtgP7s/Bq564G/WDROg8=; b=ofDdDzZw9w6n4YP5Z5Rc7W5YttVLujA4spQbiEASkobjD3iHknU09JC0L6S6hZJFBB sBkJh+ao0AZDOJPPtgiVnX0GXXNeTzLnyjQ3HIhgr5Pk7Ue8JsiVi5LSKoe1/llJod+V BTIEYA4fYjB++iF6MBhCTokAhO9GhQfYkWQDBDhqbYbMKcnYDkdggOsLzGtp99p1bbm2 fUZ7omGjR682CYoaPzpmV5SQUtnT/odRAonEp0vH3zwAjU8wF0GbGDZuy8Gz83jvUwpQ xqrZM6kUyWLrjzQ6EeegXEhtLwmB1F1p/0H6ikyTE+hMZiM72VLaJZGRQKe92slgOEv8 +CnQ== X-Gm-Message-State: ANoB5pni3fhdx5z2SMIeNG64G6PyKjGgeVrvr/WRYkftppr7ZT0w7vTr ZYYaasd5Hpm1SE2AsdptdN6Ohg== X-Received: by 2002:aa7:c9d0:0:b0:458:ed79:ed5 with SMTP id i16-20020aa7c9d0000000b00458ed790ed5mr13691602edt.374.1669287311864; Thu, 24 Nov 2022 02:55:11 -0800 (PST) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id x22-20020a1709064bd600b0078d3f96d293sm306881ejv.30.2022.11.24.02.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:55:11 -0800 (PST) Date: Thu, 24 Nov 2022 11:55:09 +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: <20221124105509.3kwnardcxvbbkf67@kamzik> References: <20220718170205.2972215-1-atishp@rivosinc.com> <20220718170205.2972215-6-atishp@rivosinc.com> <20221101141329.j4qtvjf6kmqixt2r@kamzik> <20221123133636.gke3626aolfrnevy@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 On Thu, Nov 24, 2022 at 01:04:15AM -0800, Atish Patra wrote: > On Wed, Nov 23, 2022 at 5:36 AM Andrew Jones wrote: > > > > ... > > > > > > - 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. > > > > If I understand you correctly, you are suggesting we only enable TM > bit in hcounteren ? Yeah, and also that I think it'd be nice to revisit this for userspace. > We also need a mechanism to enable the hcounteren bits from KVM guest userspace. > > I can think of the following approaches. > > 1. The CYCLE, INSTRET enabling can also be via one reg interface. > 2. We can enable it during first virtual instruction trap if these > bits in guest scounteren > are enabled. Those sound good to me. Thanks, drew