From patchwork Tue Jul 16 08:28:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734159 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECEB5C3DA59 for ; Tue, 16 Jul 2024 08:29:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTdXw-0005Xr-I3; Tue, 16 Jul 2024 04:28:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTdXt-0005RN-N7 for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:25 -0400 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTdXr-0001xr-0d for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:24 -0400 Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-e05992214f9so3462473276.3 for ; Tue, 16 Jul 2024 01:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721118502; x=1721723302; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DvpsKqJKseTB8512E3EM/mcg58HxToRdE8EyOPRZHqA=; b=1Bg2hrKJmQVqfGSg+S/1OX+3mK+ItTFNeCA60qIGN8y6vpI6ZnDqLj6+Mdb9pRdp/A xfCyvG4S1e/uEzSdByufncPZPu45GJmvbx6tu1kbSGYwsoNp7dOQ/NGKXa9TmrJu3+cf /L93qZXCE6nPNjX/UQT50FSFHw3F7IBz3tMa+aF7Gubm5McFiBFRi4DXv6XP/gC9++2b 8+etHDp9HsIxlwKTIJYpgw28hZiNyFyEZmjyhjPVOpM8rFoKGOeogUImIxxbCjPKDGNt 1y8qybyLlFzOnuoJ/Jz5JF9OpoTtlv449DtMmbRiTLymHe17+v9bHMhhKW8zfZ4OZD7F HN6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721118502; x=1721723302; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DvpsKqJKseTB8512E3EM/mcg58HxToRdE8EyOPRZHqA=; b=HUSync+669YAlmBchKQg/Vb6ihmsG/jJflvUBKFl2hWPtBx3JtXkC4NosMgtx79Tq8 curZXpBOgYiJLSBfrhwo0dJ6fkp2+94sFda70bqePshnxu6jF2N1tz7RNlLaWdBlYSC5 M3Eh+7wx/oKmBK6RpsyhwZWvKFV6jDmUjx+ssJo93v5gvrI8GHqfpMQmKeAiHi8L8X2Q OiffHxYwMZGWS6NZQtmahmWxDXwOqC35oVBwhyt0pUIwR2s35Q3RO+6n2eVfb0r8Q6Xu Xfy3+8SHBYXArqy+KBcqBtVJdFd0PAA+UKNocP1y4Nf/DtSbsqtJTPMH7zeosbvIkQWH cOXA== X-Forwarded-Encrypted: i=1; AJvYcCV3CCIpl3ji3XSFrzOjIXZ1l8myCBjZU/USIQQDRd+56GHb7YnqAT3vmbTIgTKs2GuP2gfjT5Wu6o2fSJigUr/sEwpnbS8= X-Gm-Message-State: AOJu0YzI1ANJzMVw/SfNSP1j2A4CFRzZKRBdjaE1UCnNF7pVgwuJild4 rAy19h5MUnLJkdQJVYNRnNEiBZQHfy0mXzXEDHxyZehz6OTKNudjU4rJJc/4E/T2aNPcySnk9cR 6IUs= X-Google-Smtp-Source: AGHT+IFQ05MlplzP52qduKBfnd0ESRUZ3kDwmIURls30SB1PZNzPsUScFaoWpSnOmJbhKqG6+l2Hnw== X-Received: by 2002:a05:6902:118c:b0:e03:617c:b0ca with SMTP id 3f1490d57ef6-e05d57b9547mr1740748276.46.1721118501903; Tue, 16 Jul 2024 01:28:21 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-78e33cb61b7sm4469874a12.34.2024.07.16.01.28.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 01:28:21 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 17:28:13 +0900 Subject: [PATCH v2 1/5] tests/arm-cpu-features: Do not assume PMU availability MIME-Version: 1.0 Message-Id: <20240716-pmu-v2-1-f3e3e4b2d3d5@daynix.com> References: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> In-Reply-To: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> To: Peter Maydell , Thomas Huth , Laurent Vivier , Paolo Bonzini Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::b2a; envelope-from=akihiko.odaki@daynix.com; helo=mail-yb1-xb2a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Asahi Linux supports KVM but lacks PMU support. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé --- tests/qtest/arm-cpu-features.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c index 966c65d5c3e4..cfd6f7735354 100644 --- a/tests/qtest/arm-cpu-features.c +++ b/tests/qtest/arm-cpu-features.c @@ -509,6 +509,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data) assert_set_feature(qts, "host", "kvm-no-adjvtime", false); if (g_str_equal(qtest_get_arch(), "aarch64")) { + bool kvm_supports_pmu; bool kvm_supports_steal_time; bool kvm_supports_sve; char max_name[8], name[8]; @@ -537,11 +538,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data) assert_has_feature_enabled(qts, "host", "aarch64"); - /* Enabling and disabling pmu should always work. */ - assert_has_feature_enabled(qts, "host", "pmu"); - assert_set_feature(qts, "host", "pmu", false); - assert_set_feature(qts, "host", "pmu", true); - /* * Some features would be enabled by default, but they're disabled * because this instance of KVM doesn't support them. Test that the @@ -551,11 +547,18 @@ static void test_query_cpu_model_expansion_kvm(const void *data) assert_has_feature(qts, "host", "sve"); resp = do_query_no_props(qts, "host"); + kvm_supports_pmu = resp_get_feature(resp, "pmu"); kvm_supports_steal_time = resp_get_feature(resp, "kvm-steal-time"); kvm_supports_sve = resp_get_feature(resp, "sve"); vls = resp_get_sve_vls(resp); qobject_unref(resp); + if (kvm_supports_pmu) { + /* If we have pmu then we should be able to toggle it. */ + assert_set_feature(qts, "host", "pmu", false); + assert_set_feature(qts, "host", "pmu", true); + } + if (kvm_supports_steal_time) { /* If we have steal-time then we should be able to toggle it. */ assert_set_feature(qts, "host", "kvm-steal-time", false); From patchwork Tue Jul 16 08:28:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734163 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA728C3DA59 for ; Tue, 16 Jul 2024 08:29:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTdYF-0006Yh-Eb; Tue, 16 Jul 2024 04:28:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTdYD-0006QZ-Bc for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:45 -0400 Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTdXw-0001yr-GM for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:45 -0400 Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-5c69848ca98so2793534eaf.2 for ; Tue, 16 Jul 2024 01:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721118506; x=1721723306; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RYXhIuhb5B0Jyjgf4vjtjqsff5UW6UTsThhjedH3LOU=; b=X9kybmC3AyQ2/cancZTdKtxp3H6o3s0kTBH8qZ+j9ERBYLH7TH7cRmowT5NkMZSpmo c7mv46aCR0eVUD1mMhpQHMfoE+2MQmFh2THIDH10uerVFjk8WdWgf6UF47rF/6tCkzcH GCi4v+UK6ff18J7w+YZyfH4dQ8Kwti+jPJPHWDpVYAKKoyhJ1TqAQH+x/PRPij8uB8js RioTmC4BosNK7r0L/7FAAPr+F8EvwOCwSEeKbJ+9xsC2GL9te9R3elYbpYmtjs46AVC5 H+uxLvlnogvwiMREFsmb3PUukDCh7Sk0NG9f+xfNJDJqh7FQdoAGjnMt9ZcAJ/autbsJ rfBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721118506; x=1721723306; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RYXhIuhb5B0Jyjgf4vjtjqsff5UW6UTsThhjedH3LOU=; b=BRifR9+pDSRf633ZnBIY2o/kUGmXBHk1YavdsXXg+FUJa4MffWVTlfboWHH/LEzZ7k GrEtfWLZwjeOovMrPyXQamMAKHtFFfwhzDl1MvNtPqm2n5fciLHCJrO903OxcyS7SH92 8k3/vwt2iLeBIzB1Xrd5glpUq1jZNQ2nLv2/NwOBcyAzF3764mooj+Ns7hC0ZPv2BLaB Nqs+jqBpmgIMuYQ3GS9pDMWYCg/fhMwM6GmYclyb6ripIQr0Oe7eLdhAACOK/WBLn1kN zoUXaUB+E+jrpzcbNpAR95SKgm+MqLSnmznt9XJ7u9Y6FF5GRgEWYZV4zekJkdZEIfXe +JMw== X-Forwarded-Encrypted: i=1; AJvYcCVZZVofZ+8jYAO6tjz1LlmP24jEGJwC9NEJSW29dvdjEFQEor9dtAZeHYhS0SPKtFqcNb1yQggGNdCvFknjHjVfRPlhngs= X-Gm-Message-State: AOJu0YzwvYJ3Y0twlSaPdONpj82XCymcaFFruZEqK4dykBeWB94FLLk4 zHJu5p9OWFEG9LFearys0S0J7vA79yLNpaMIh87hA4/PWynRluED8fjouAhPUJ4FaDvGj3849yS Fb1c= X-Google-Smtp-Source: AGHT+IEX8BPbI+Uspvd6hlS1L6kD1r/n31SaoBBK7fdOERooqOo9yLQcoozSvCe+X8hABG0SUUEteQ== X-Received: by 2002:a05:6358:9486:b0:1a6:7af3:22ce with SMTP id e5c5f4694b2df-1ac901cd215mr127136755d.2.1721118505875; Tue, 16 Jul 2024 01:28:25 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7910f291ee4sm3222889a12.86.2024.07.16.01.28.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 01:28:25 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 17:28:14 +0900 Subject: [PATCH v2 2/5] target/arm: Allow setting 'pmu' only for host and max MIME-Version: 1.0 Message-Id: <20240716-pmu-v2-2-f3e3e4b2d3d5@daynix.com> References: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> In-Reply-To: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> To: Peter Maydell , Thomas Huth , Laurent Vivier , Paolo Bonzini Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::c34; envelope-from=akihiko.odaki@daynix.com; helo=mail-oo1-xc34.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Setting 'pmu' does not make sense for CPU types emulating physical CPUs. Signed-off-by: Akihiko Odaki --- target/arm/cpu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 14d4eca12740..8c180c679ce2 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1594,6 +1594,13 @@ static bool arm_get_pmu(Object *obj, Error **errp) static void arm_set_pmu(Object *obj, bool value, Error **errp) { ARMCPU *cpu = ARM_CPU(obj); + const char *typename = object_get_typename(obj); + + if (strcmp(typename, ARM_CPU_TYPE_NAME("host")) && + strcmp(typename, ARM_CPU_TYPE_NAME("max"))) { + error_setg(errp, "Setting 'pmu' is only supported by host and max"); + return; + } if (value) { if (kvm_enabled() && !kvm_arm_pmu_supported()) { From patchwork Tue Jul 16 08:28:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734162 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCBD5C41513 for ; Tue, 16 Jul 2024 08:29:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTdY7-00060H-0i; Tue, 16 Jul 2024 04:28:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTdY5-0005yF-Vo for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:38 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTdY1-000200-Ks for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:37 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-75cda3719efso3005460a12.3 for ; Tue, 16 Jul 2024 01:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721118512; x=1721723312; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=UCgdSp5pdNZ1XKq3c5okiNiCxhoyMDPUd6RYSX/QMYw=; b=MGAyWALEFzy5i0ZruckUoeIvN5q/xNfwaPCgJi6tNR4YVJV4t/gbSR95W6Qg08yZd0 qtL1M7XBrk+xPnuhgWvP/STy5JX8NqWH4RyrLCuzCrzunTW06vlXrMFDGJzLGpg+burk 72sqkdTOkJ4gSZSCqtFqWvkX9vju9RwttQTmtZBkegWS153CP8HhNjDrQS5ru/5xg0UB RKdSlVabKSfrmhCZ8TrtnTfCb03BLG2D57WZEDU6pcJDEuou/POHgJDVHr++94cK/Y2Q mZFbO4BabJDcaQM4V6c2y65FZcio41MhHCEy4imfkqbyg5JmWOiG/c6zq6Z0b+A3fxVf X5Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721118512; x=1721723312; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UCgdSp5pdNZ1XKq3c5okiNiCxhoyMDPUd6RYSX/QMYw=; b=emYGC97ROb48X5U2rsrmUMS6I+CTK3PLtHF6JJA0AytSGrDGQAzRQ6fraAe6a0qfUO ZmDe6TE9SUFVe6mNfrbhp7OUQNtHFTN5fk/6vXHOnyxzUNjyDvanBGNI7PRSsnih1ftK eke6JmrRK7jDmGAqfuTnxn2Fc5gKBrEDG8JzkwVl5Lq7AuRs4XDckmEhpwvlK1ijNaTF wq8WANJYsSy/qwQIwOl5p8vqrU/UGom5qrfBGGT9L4VmhCfmCZFKFub3NxDNEpQB/YRA hrPQ4R/Ukhk8qs+6UkTPobPjk3Os9yJdwThWHok0rtK/2GqEMnUZUvhVqHWb6Dyxdxe8 L8bw== X-Forwarded-Encrypted: i=1; AJvYcCX04GRIFCjDRCZRLYuzco1/ZnFkemutf9+C50zLlTUaBS/D1wgEvDLfeKRtHgxXg+mOSbfdCWlTx+xE5M2D/gG7Q9K9KRk= X-Gm-Message-State: AOJu0YxUj4CNu9SToHjrvQhCNZB1T/NEqbdH6WWD28PEnpMrSBQIaxbK yurlQHddQub0q6CW8Px0HU0QLLU11U3Wk1ZJyOXA7yuBGqhmAi3D5HGi1bl/Kg6n4tnm4ehDXvP sGaA= X-Google-Smtp-Source: AGHT+IG8ytNrN8j4Va7eZKqyNgFYDSFIbUseO3QJ7+TSFiRHQD01HvT+TL46FEhGt6SylN1T0a/n4g== X-Received: by 2002:a05:6a21:99a5:b0:1c2:88ad:b26d with SMTP id adf61e73a8af0-1c3f129e50bmr1720884637.48.1721118512001; Tue, 16 Jul 2024 01:28:32 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2caedbdb745sm5712692a91.7.2024.07.16.01.28.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 01:28:31 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 17:28:15 +0900 Subject: [PATCH v2 3/5] target/arm: Do not allow setting 'pmu' for hvf MIME-Version: 1.0 Message-Id: <20240716-pmu-v2-3-f3e3e4b2d3d5@daynix.com> References: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> In-Reply-To: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> To: Peter Maydell , Thomas Huth , Laurent Vivier , Paolo Bonzini Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::535; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x535.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org hvf currently does not support PMU. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 8c180c679ce2..9e1d15701468 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1603,6 +1603,10 @@ static void arm_set_pmu(Object *obj, bool value, Error **errp) } if (value) { + if (hvf_enabled()) { + error_setg(errp, "'pmu' feature not suported by hvf"); + return; + } if (kvm_enabled() && !kvm_arm_pmu_supported()) { error_setg(errp, "'pmu' feature not supported by KVM on this host"); return; From patchwork Tue Jul 16 08:28:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734161 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 55A0AC3DA61 for ; Tue, 16 Jul 2024 08:29:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTdY9-00067k-GW; Tue, 16 Jul 2024 04:28:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTdY6-0005zJ-Hi for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:38 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTdY4-00021V-W9 for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:38 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-70b03ffbb3aso4103444b3a.0 for ; Tue, 16 Jul 2024 01:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721118515; x=1721723315; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MzrJ2SIc0b0nCcptbEys+0+C2juhcCeb9eqlhLMneTY=; b=RjhIQy3Jn61z6pWbnUKBtfJ5E59Fc78RYzT0HLUCdq/S2QN48PdGZ5x2Wu7hQ9fmBm PFu26cX9z7fmRqgWmjd13KDrmQyz//w9MJgzo5CR28S8C7Udp6XHfTb5YpAvYrKK73il eSeS5rI/HHuyDId44GL+BRxEEe+3lxl41oDsSEYJUUKUmFGQoA9ChWpxTmH0RG/ZsZei 2RrEiZJNsIZda0KYkdscSLkVQBvAqUkL7iUhCuH70MP32xGTS9QzP2nG+PdCE+wheNQb 0IqcoD/sRpR5PAlLGhUBms+hhzytZ76gkgOpcbF11fARBFGu5KFT6dWmBe0RrgykIsYQ dcDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721118515; x=1721723315; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MzrJ2SIc0b0nCcptbEys+0+C2juhcCeb9eqlhLMneTY=; b=BbwZ+rRMjGTPCXNfUyBu4uKxpW8+C6HZuCF3dBVfoHHheW0yK9wkJeu9+otqLfoqTQ 4WummgoqkxxuX48mBQqo1ilF8BVUotENjUqS7OjRfMGmI2NlljD3YMC6hy/O593zvLI8 Hr+Lvr91V1PG/sVOltcPF1CGtP1owWpm9borL2RCiNbv/YrIhiKcWBH+s4KJiJu52zDq abDBFkwzCacodnGdsIY1z/xizW1vBDxnpdzv6zQ7Gsged/JRTQJXOkQZ42Sv49IXWPp3 i7R/PtRCg8E4P1ZWj782yFfs9WeKwjKyM+ZGVRuGepwdqkhjWOVYOc+Y4gABdOx8GplR EQTA== X-Forwarded-Encrypted: i=1; AJvYcCWLTrHITK07A+sB32duwP8iUFcarJmSTQ8UyfAuMJ1LTuyMmZXqZ9NpRL4jSiRcNj0jJd1toCbnYNJgCRtJ6Hp8uOVjK1o= X-Gm-Message-State: AOJu0YxTqw0HUWbdOi58K8roVXYH+Co3Zi9S3kLiZC72iujsoAHXrnOD mF0da8wZ+3ljqVNGkpLTYncqNM8z/27ofwBEuAQ2JVqphpJLHtB96byR4ppZyKTF22J6jOS6fak 2W/I= X-Google-Smtp-Source: AGHT+IEMIQeQRXNUb8ccsuZ8VrtU3dndgT6Vd8nvN3x21ZLqX5Ahg/3t5RVankt3OZCxhbx/gbmsPA== X-Received: by 2002:a05:6a21:6da9:b0:1c0:e629:3912 with SMTP id adf61e73a8af0-1c3f12a2231mr1826892637.48.1721118515601; Tue, 16 Jul 2024 01:28:35 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fc0bbc2e0csm52710255ad.106.2024.07.16.01.28.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 01:28:35 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 17:28:16 +0900 Subject: [PATCH v2 4/5] target/arm: Always add pmu property MIME-Version: 1.0 Message-Id: <20240716-pmu-v2-4-f3e3e4b2d3d5@daynix.com> References: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> In-Reply-To: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> To: Peter Maydell , Thomas Huth , Laurent Vivier , Paolo Bonzini Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org kvm-steal-time and sve properties are added for KVM even if the corresponding features are not available. Always add pmu property too. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé --- target/arm/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 9e1d15701468..32508644aee7 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1781,9 +1781,10 @@ void arm_cpu_post_init(Object *obj) if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { cpu->has_pmu = true; - object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); } + object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); + /* * Allow user to turn off VFP and Neon support, but only for TCG -- * KVM does not currently allow us to lie to the guest about its From patchwork Tue Jul 16 08:28:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734164 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 262BBC3DA59 for ; Tue, 16 Jul 2024 08:30:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTdYD-0006S6-Nf; Tue, 16 Jul 2024 04:28:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTdYB-0006GN-0e for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:43 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTdY9-00022B-DL for qemu-devel@nongnu.org; Tue, 16 Jul 2024 04:28:42 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1fb70169c23so40829995ad.1 for ; Tue, 16 Jul 2024 01:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721118519; x=1721723319; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1KxAC9/Pxe3NsDzOqPZpbEql5jfhTTEPjoaJwE6M8sE=; b=cuJiZasr5IZIIJxFtqh6PnNU875JUyI5Hkn5H94PaMFvxcK/9Tgl8kd+Dq36ZIU9l7 lMyVCmEmBDKMSsj2wSpyJiMqK/QZ4qF6rzapdqnA0RyRYfd1lnxx5vD6ZCmOfta0btUC CeCoG6RM80DP7u0VbPbyEgSrEmlayeM8BSmEso5o8aI9AfV8X+IZunRqqXjp8pSa/lBJ lsHP30FheeGwMbiZfVGSU1eOKjEz7lYzdDbQtm8Gw3DxLG3SSIq3IGzJs3VBfLXeSi4r s5QenjPx7uEbURg6YGuEczFf5h+wRB5wvMh2lzRqOF0zc5hfyFYzhVpyQkBjzTRkPvpd vLNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721118519; x=1721723319; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1KxAC9/Pxe3NsDzOqPZpbEql5jfhTTEPjoaJwE6M8sE=; b=vCXNdB47n82j7shFpXI+TBAPyxQ+ghwr1O3ANIjwj5i8jY8wQo8SSCVl+dijzlUWKt Y6JG5UZVn0WtGfd216n8FKH8ZCSaU3LH8EFM7+P55xBNgyRzf+owJcPtJqXeJtY4pbV4 eeZf6ZOsyzNpz74XCVIIdtQORYQmVaETWfouPLe9AHl/uQiQxSJIfba011z2wSXnzrp+ aDBSqmRJU4ZBXE2CJtyfEcVO/k3XLyyl+6g9vEu1IfFJ4Ar9AwbHxdGvf9Fjfv0oCxEl fg2A4IKWSm4xz5KU0uJQpjlfwEEPUDLWNvkdosRfgKg/ZHbwJ3pWIwkusxQhZymHZ+qA V0yg== X-Forwarded-Encrypted: i=1; AJvYcCUe/5hwTTor5hiHXh8dppMS9fO6I9PdHDUONpmmcXr+xt+OrELN6SXZiaU8LESPI1kZshVXaZ3BC79Uhb4qkrMSeG52LCk= X-Gm-Message-State: AOJu0YxDTplmvVYPCxHkulxQtsc23UcMbhq+4VBOa2LKtBbWaU8o+3Or vFtQ+1dakoh1i6DZpN94C9JiDI+PGCazGajeuAq4W3p5z9fY1vkFHS9Oxume5LJ3rxHM26VLbx2 QkMo= X-Google-Smtp-Source: AGHT+IFrqJjHfkW1n1U+uCFdO309idp+NxLuzCYnpw8ARqcXhMW5rN8oEf3Ut488eOfutxc39v5t2g== X-Received: by 2002:a17:903:234e:b0:1fb:b35:2fcb with SMTP id d9443c01a7336-1fc3d92d0c7mr11461215ad.2.1721118519582; Tue, 16 Jul 2024 01:28:39 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fc0bb6ffdesm54720525ad.53.2024.07.16.01.28.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 01:28:39 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 17:28:17 +0900 Subject: [PATCH v2 5/5] target/arm/kvm: Report PMU unavailability MIME-Version: 1.0 Message-Id: <20240716-pmu-v2-5-f3e3e4b2d3d5@daynix.com> References: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> In-Reply-To: <20240716-pmu-v2-0-f3e3e4b2d3d5@daynix.com> To: Peter Maydell , Thomas Huth , Laurent Vivier , Paolo Bonzini Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org target/arm/kvm.c checked PMU availability but claimed PMU is available even if it is not. In fact, Asahi Linux supports KVM but lacks PMU support. Only advertise PMU availability only when it is really available. Fixes: dc40d45ebd8e ("target/arm/kvm: Move kvm_arm_get_host_cpu_features and unexport") Signed-off-by: Akihiko Odaki --- target/arm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 70f79eda33cd..b20a35052f41 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -280,6 +280,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) if (kvm_arm_pmu_supported()) { init.features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; pmu_supported = true; + features |= 1ULL << ARM_FEATURE_PMU; } if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { @@ -448,7 +449,6 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) features |= 1ULL << ARM_FEATURE_V8; features |= 1ULL << ARM_FEATURE_NEON; features |= 1ULL << ARM_FEATURE_AARCH64; - features |= 1ULL << ARM_FEATURE_PMU; features |= 1ULL << ARM_FEATURE_GENERIC_TIMER; ahcf->features = features;