Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8893839rwb; Thu, 24 Nov 2022 05:41:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Mz7qxmh8V2twHxhLWV/Vct+gSau37Wkd/ZqVhY5DbjnhY9n+NE5ijP0iCtqT3KmVwBd40 X-Received: by 2002:a17:906:b0cd:b0:78d:8c6b:397b with SMTP id bk13-20020a170906b0cd00b0078d8c6b397bmr14532286ejb.364.1669297307039; Thu, 24 Nov 2022 05:41:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669297307; cv=none; d=google.com; s=arc-20160816; b=QvToWqsskOuE4l9JQ17FXdN7lPZoGSn0W2Mb0fdncfefLJT55sp5N1Ejz/sSalh//L CIMZeJVoAwJF9UrNG15B6AtNr5SuetUIFBe/Yu53krxHRzJ/v24Kv+qNweilpPHVjEiB JqZNW77duWTyZMjnY8bDZ/ezSd3pZnbXiv3eRzks4j9NN5/yjksu7Jv8doBhAAYtIFvA RAVMuqLW2EfdVXRVfJhRsA0lPmLHsPu0WVtrL0q34IgWBED2PzUnMeoTzyuaNoltdTQL PktTn/E+GW0Fx4MJwxQzw3uRzJBlQ0C1bvvcZNrj1CZV5bbh9RmWcZt/cFQbNZYPKfwV R5Hw== 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=jWhjZ8Ik6udAxmU7OrnkH0fp8I0zGCvkX7BlR9Epea8=; b=YZeQpHseXJ4htEJMUl4FSXGf5urYIo1BSp75Egd/7+UE0ZTAj8rO/OEEgXtHY3i6fS C9+sq7svScnRVR2exO3os9LUe0oYB3Nb2qwAExZso3m+fANZjwcixWY5wW62cH1RXXWC 10WLDXcEk52D1evck62/tJkdk7holsAS8Pbu9mCYGOgUWzeoS7sGy2UF4SmbR8BEs9wF KeAG4ogJDv20U7abglA0UHu5bzLwrXK5mcbZlcqFM2EaaYjyQ7x2c49iQyFdZEoN1nG5 7J5rfp0fpSNXFoWKGWxJxlVDgdgGBg6s6HNDWlBvWf0ItKbSFnI9WIwAE97TOwTGebvY RN3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=IC3tTQJt; 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 hr42-20020a1709073faa00b0078e0e8508fbsi391705ejc.457.2022.11.24.05.41.24; Thu, 24 Nov 2022 05:41:47 -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=IC3tTQJt; 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 S229908AbiKXM7S (ORCPT + 86 others); Thu, 24 Nov 2022 07:59:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbiKXM7Q (ORCPT ); Thu, 24 Nov 2022 07:59:16 -0500 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE96F94A60 for ; Thu, 24 Nov 2022 04:59:15 -0800 (PST) Received: by mail-oi1-x235.google.com with SMTP id q186so1475768oia.9 for ; Thu, 24 Nov 2022 04:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jWhjZ8Ik6udAxmU7OrnkH0fp8I0zGCvkX7BlR9Epea8=; b=IC3tTQJtWUJQyjZrGL6F6TYNH5H29hlmfBUQkgCMCV/wz5PfN4ovrgjSXVW62CedRi QARU0pDSP2eRrKKPXeyJVL5Iuo2p7Zgxd0GtDE4j3fmQPMr/6YYTg+O0YkBYsab8T/tQ pdrDU0ljJOb85kDxDoU/GNjcYFxJO1APG9R/aaVJCCRqNw0NUld3q0P/3gDEugJqw80c 1zYvWHi2PK9FyJt+tN8GjidSP+kggtDWAnklLwAyHXuXhK5SarF7ki1tYcWBkMXe6zFa pp+4OsdhAzd2LNEfaXIYcD5Tu5tx4Xx0y8u3fEBmG6CsIi6hg8GmIRZO5kqq6DeG7Xcy FJMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jWhjZ8Ik6udAxmU7OrnkH0fp8I0zGCvkX7BlR9Epea8=; b=maU+BJvoiVdAxU/Q8Xn2nHdNEYF1CAjJCujyDis5+AeofUPKZgTcxxM2LcZH2jA6Q3 G3N2WIVx/YvxL3uTa8UbXTeCfx7AI3SEVs2lrUOAJMh0Gm91fVZJhBw1oB2uirHo3WQC yt9h4bc5up6FeaZ3HRzUUqnPE0zOMfg3RyE5xaQDUsfxhR50vXZIXVllroEkBOnB/YAO a6kbJz8cFDKv2tK5z/ftqw3pLJg00ggc8kZ2YqCpa1tzNUGdzTKldzYNqWx+oPONG6JF U6WbJl0eepLEnNo1cs2HBDXeEzV4yBwt51AYbEV7wcmMM8Fx4Wr5qDyA3PbhOMGIyhvv Xulw== X-Gm-Message-State: ANoB5pkuPNM4+/IzrRt5c8lZB4si1uhjlntKkqZHZbbzaaNlZJIu3BNg jqamlLzE3y3by6iMUAbc2RaS2GOmuSkJDXf5Hu/AX5peXLM= X-Received: by 2002:a05:6808:2102:b0:359:ac8d:4227 with SMTP id r2-20020a056808210200b00359ac8d4227mr6186334oiw.17.1669294754893; Thu, 24 Nov 2022 04:59:14 -0800 (PST) MIME-Version: 1.0 References: <20220718170205.2972215-1-atishp@rivosinc.com> <20220718170205.2972215-7-atishp@rivosinc.com> <20221101142631.du54p4kyhlgf54cr@kamzik> <20221123135842.uyw46kbybgb7unm2@kamzik> <20221124105051.hbsavj3bgf4mvlzb@kamzik> In-Reply-To: <20221124105051.hbsavj3bgf4mvlzb@kamzik> From: Anup Patel Date: Thu, 24 Nov 2022 18:29:04 +0530 Message-ID: Subject: Re: [RFC 6/9] RISC-V: KVM: Add SBI PMU extension support To: Andrew Jones Cc: Atish Patra , 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 Content-Type: text/plain; charset="UTF-8" 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 4:21 PM Andrew Jones wrote: > > On Thu, Nov 24, 2022 at 02:18:26AM -0800, Atish Patra wrote: > > On Wed, Nov 23, 2022 at 5:58 AM Andrew Jones wrote: > > > > > > On Tue, Nov 22, 2022 at 03:08:34PM -0800, Atish Patra wrote: > ... > > > > Currently, ARM64 enables pmu from user space using device control APIs > > > > on vcpu fd. > > > > Are you suggesting we should do something like that ? > > > > > > Yes. Although choosing which KVM API should be used could probably be > > > thought-out again. x86 uses VM ioctls. > > > > > > > How does it handle hetergenous systems in per VM ioctls ? > > I don't think it does, but neither does arm64. Afaik, the only way to run > KVM VMs on heterogeneous systems is to pin the VM to one set of the CPUs, > i.e. make sure the system it runs on is homogeneous. > > I agree we shouldn't paint ourselves into a homogeneous-only corner for > riscv, though, so if it's possible to use VCPU APIs, then I guess we > should. Although, one thing to keep in mind is that if the same ioctl > needs to be run on each VCPU, then, when we start building VMs with > hundreds of VCPUs, we'll see slow VM starts. > > > > > > > > > > > If PMU needs to have device control APIs (either via vcpu fd or its > > > > own), we can retrieve > > > > the hpmcounter width and count from there as well. > > > > > > Right. We need to decide how the VM/VCPU + PMU user interface should look. > > > A separate PMU device, like arm64 has, sounds good, but the ioctl > > > sequences for initialization may get more tricky. > > > > > > > Do we really need a per VM interface ? I was thinking we can just > > continue to use > > one reg interface for PMU as well. We probably need two of them. > > > > 1. To enable/disable SBI extension > > -- The probe function will depend on this > > 2. PMU specific get/set > > -- Number of hpmcounters > > -- hpmcounter width > > -- enable PMU > > ONE_REG is good for registers and virtual registers, which means the > number of hpmcounters and the hpmcounter width are probably good > candidates, but I'm not sure we should use it for enable/init types of > purposes. We are already using ONE_REG interface to enable/disable ISA extensions so we should follow the same pattern and have ONE_REG interface to enable/disable SBI extensions as well. Regards, Anup