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: 13734152 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E04493224 for ; Tue, 16 Jul 2024 08:28:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118504; cv=none; b=jxp5+0JtBqqd9SckPvdeDbi6pslCMpTFxzdd/KuxPlnUos17KR9tAbOG14JFZyv1Ty2X2frPmp9151Ekkgk+Tbw/1N1TiZoFveW0LPIFouEF+Q1rt5onmj7v+w3nNkuN9pcN4Vnmajzw7DNUAavYdvBfKuebmWVarEjy8x93BFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118504; c=relaxed/simple; bh=hH0C+hMRrQebClCKrwJVUyAUbkOPif1mOqS4Fo/9xAg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SWp94HGVOhW/Qr4JigUvHXQFd3KCqUiIYV0d6LYRuyRiv5lxDUSqWFqJrsnKCZjJaXfiq6T/tjnG099p7SH4EA2j9b8ryFtpgHngl5wmeNI5KkeTq8C1fBlJbfBbHTiZOiY9qpX+j8CFSm9S8QRXEfHaRVOYmJ9tzN8llPHt2mQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=none smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=IyXJleL+; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="IyXJleL+" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e03db345b0cso4922075276.1 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=vger.kernel.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=IyXJleL+EKXIZpq0zh/7muMoo8e8pRR/o4U5ipfnS0lPYNwMuVrmMVmtZtRfMvSZFl NAOcrFiMfi9vrtT43Ij9CYdmoO8lRynB/GEk1HqBanA9wOv6midOCvWaFBRnWIcgm2UU 6kMwBRXpRaTGyyisS6LFXzaV/xPnHhu10YRd33VjgEHwcgPOdh55LZ42WCgPqXbni3pJ SFv/jlRfx3q22DvA/1G0ohdVhBxNkX/aVNJCMpQ0hZkGWzzHFzsSu0t/DdnYLU/tlQqk 2kFy+IjZpSmsHsqBrsBfVNz3SQTkMAXubFT2zpu0Z8/0OLFYH9p/VPEk//ItgtCmTH4a F3WA== 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=TgihJA+llVoLnagIFETujXmXxTX0bQpFYaZUvY7QyxNTbDQw2RgDI7EIv9Yp9FSgJy uLNI/NiRYJZc+e7Zr1SJLznIHqn7VbMQTGLtyo2+myK2+UcJ+niYuCvjvjaOc5prwrfW EC4Ehq/rpu+YvluqZQSf2iGziijynAXpo8PtspLl/ifPLcsVDsYoiyLo2mrDgZqE9vTm CnsgLNj5HKHXYq4lBd7Ixd16iy/REq/INGLwsXVr45HsvH55/OegoaD6ZKhFOgRXt34Y x/HfeFnPH0Kny6WHr1BMPxPFWKej0aNRhuvWwl0Cyjzosnw3jh87dVNwMWBFydxDL/hI OIMQ== X-Forwarded-Encrypted: i=1; AJvYcCU4/3/QpZ0p4jP9DuwxoaGfeYDgBwGSr7DWs/J++Lt758H7FsyZmxL/TJn5/BFKJHgEnJDCGTkriMq2baXqSqO1SZgc X-Gm-Message-State: AOJu0YzUim1BhP7BUXguwfztrzIKyltmqBnaPCRQAa2R/2WeMNNDMG14 P6bZHUgVz/7kAsEXj1N1tzuEOF1PI7H13XxIiBTBweq0nSiSsiFCJIYEZaZyoVM= 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 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13734153 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F276B3224 for ; Tue, 16 Jul 2024 08:28:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118508; cv=none; b=FiK2gOk/8ECH7n2hL/Ov3UFU6+BQmAPmFXYMjcYNNz5sZ4V827jsdxDg5UlYVGN/kUCQzWGPkl3GpYYAjP/RxgBomltUlwPlMVyxH2A3/xjTeBvlQ0PnLxslInLTVGVAFPqI+7RPKAOK2G1rLDqF7gR2F1M9f1HwOg7XmO/olIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118508; c=relaxed/simple; bh=ANeRDeVKrn1slVo8/usBgQLuXAbDE+JjV0j595GRo9k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IEazoa9qQAPqAa8QSK3GA7vJR44OPNvSF6h7DcJoMyuhpi3zbRyGmVNI+LcQgshf+3qrqQztkLDJBBgw6TxVqMCrWrkipVRyWLZyCcwFU5g5FV3VLOLcns6ohwChtYkaCDc8SGsQmcSX46//ZyYnmsZE76HGnViG2n5ufNp54eM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=none smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=0DwFqljL; arc=none smtp.client-ip=209.85.161.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="0DwFqljL" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5caad707f74so2556059eaf.1 for ; Tue, 16 Jul 2024 01:28:26 -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=vger.kernel.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=0DwFqljLFs1JFF8Kfa2K0fTO1OJ2w7m0y0fNyEAKXwnqP1FXE/GEnDvvCj949u2x7a uABQdEpRA5Y0FXQ/JwYap5OTARYVs4Dpha5P9WE6eTqXgJ2F+2ZYmvOKDSnI2XTyPsU2 oGZSRqVrgzJL2YUEvmEeJd7/BQQdb7LjIPl9PkoGsbDIkLMdiG22t0vzyEsprRcObvWG NliEDeZrDYf8zUFjD+Onc3yGFqIcDQFfcdImREI0OOZayu+KHH8CRar7Pc0/1jDENvw2 OrqQADGShJ4b4rV6rhrW/LgU6td9HBYsTip7G8dPy1RBxHZnqSxSl+EHxqB/m2abwXhl gtcw== 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=s1qPqfBPJ1ZMviPfanIq0jNlmd72oV48TUqi4CFVE47uJY6YXvpLHxkCAQpn9VcHEg s24uPVyAvBNCF4AtieYwkH7v501d7UXtizshMzJIWQqyQAR9Pri/tvxsoYR8E7mG02Ja cDURMgNwYBCNESqwwpDEXYC4DkJEAV44sfy+3PALCgE3Up/yjGvuwZXU9pE94H5n0+PP ZkrGIzhCBFy14kFtvgUakkXN5QOwLxm7jAvK6MG2aPlcsEDAwFGpb6mcVlx1zOwqu2L6 SAu2CywZvCtP1J4QzVd2CTkQepkN7BcHk+ceF6HAaW5P9ON9gW4bH7ksNS+Ev4G1M5ss vUKQ== X-Forwarded-Encrypted: i=1; AJvYcCXlNdPzqO1/D/FOSrVWzL4l/yJSv1kDKIZDlWwwVwHGl8A4nvfd7WNi2UWjQGoPFY5VaTRsW+zno30uD89gQbP8GRyz X-Gm-Message-State: AOJu0Yy4NQ0jY2im9AzGvG1/QWoZqOJvAFM3ZFwcZv735cBuDJeQLVi3 v59bgVepRXNT+facwQCHpvWivV2HtECy6yz/b8naZOdcODsq0RWp4rGc9CXjDG4= 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 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13734154 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96FEA56B8C for ; Tue, 16 Jul 2024 08:28:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118513; cv=none; b=MGexvGf2+q57JoAlcswj1A6tmZrVHIH9BIRcXP3VIWKryg04j7NSjhgAHiB92v0VAI9+ffz5PeofKdQsCfnj9M7g+BW4RRQKESE5We79jgBbd+pfQs4c1hY2OdgSu/WJI1O2UApgkjbEiMThoOlqES/c/yzM34M3MR5l8kYDjnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118513; c=relaxed/simple; bh=40OgbpTySEQ6YEs03MghFUDuwn3oADg13liRJNSUy2s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uNWmPpFp7sq+yoRis47uhqx/VEhtkHRfhIBPxd6OGGfs6BHrEljAtcsqannvgdzvZxpnphS8/ijjup/wuVe9j88CzXvDrzhXCwj3tKLwdwG9askAehQ8M3K3q3pnzZjxMvaAIzCfu/yzX/cEqLSa9IFMumw414gNA3vIKg3n8Ns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=none smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=bKDwSxnO; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="bKDwSxnO" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7669d62b5bfso3033881a12.1 for ; Tue, 16 Jul 2024 01:28:32 -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=vger.kernel.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=bKDwSxnO7pBs8qP2A26wb//ZHswgIhiP0tABEaDqj+meNY2fSsVpNEyUSrmhLp66IW KRuHAlG3QUJxP83L41zhjDLqWmSskhu7eSqfiCmy6XShAv0uIsgd7e9sPkDPWLrRZQ5y PvzMI6dCyec56H6pGrOAcq4K0t8CFH+oUyI4bQUdlcd4NHZRFf97WZiZMco7HJZzOlRG AetRq8DdspDMsibAaM2tngZywHdHo+Oqt1iDzOble1xHH/Y5h91MnX4D7SuI5D6QfG72 ZdFYJ4LSnvsqzF2ehwiIRUPSw5KypKMuXdHYLOeVzGa4LfQGlL0rT1PMZWhfgHYs6jBk sMEg== 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=MxPQnuCfPCH4akR/9ErKgXLysfC0AQrWd+uggZB2JZ7rGwLd+n7F9g4feqXTCaqiwV Yt9J2KU0oWk/CWNLGgSwQedExB6J9dxRGHeHFITyNCcv3HYsDTqfb6kCt7eFgXOyYs5z 7P9qmjnCP/YjqXk/PEPSUEhIcT8yfSMSxh+gSc3t3y/7qBpHCFOSi3VJE9WmhSs3QN5Z 2y3qeCU1+sVQmbmi9U+7WPLXjvlR8UehldM5Abt+SLcq5F39icOr8sv5Yn01KlAeMKqc Yev7dYEKX365eyNOurclG4u8cAZZfUsUw5SdVbd8B3YT6uanNHUK6XrFVbaXAbVBa1nB Nz+w== X-Forwarded-Encrypted: i=1; AJvYcCX1Ux1SagYgJsoGb6F9xDWLXWrcl7ruFkd3d4VAHcuwDKn/4nHhe5f+oYZfpNYaTuGVyRI7HIv0B1xf6alKK3gVlVV8 X-Gm-Message-State: AOJu0YwoobmRH8d3FXkB740QQz3zGCwjyaiHyiA+EkEWc25po8TIpIg7 XwZ//owP+VBYTfYGN6YOaSAKUdGkPkdhdpM9Qd9SJthD8c8KpyBS9mPRjstO5xI= 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 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13734155 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A836502B1 for ; Tue, 16 Jul 2024 08:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118517; cv=none; b=BZXfpnuFh4GK3cZ0TyTlrGCeUNZuBQhFi1Cfwciuv41GBVMzI8k58uof3Qe/o9E48dz1czQHtHM51qrC/CoP/dipXtLiGJpkctvdyNJaulRTN2e7LdO8WqzRVW9NaRC0qAHg6+Z+DkOgIMdUn5tzSyocNyWzI3jnyEjF27R168U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118517; c=relaxed/simple; bh=d13S3u6zvOUNam380BtLBXtLj2ddDqg65Tj7QN5dUj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X4/aW4qj64j12tKtLfJXwsB1m2WFopTiIeAys/pDiDxjwIcIrcjvOgqH5Qyj4WS4Zoa06CdqQ42x1Hlw9l9PmDFpx2ajZ+m9mKbF/d+9lZVMG5MRW73O2lHDmnyNasEjZC8zicjv0XeJmQqyEXwnziZaHfpqD4sQODF41camt6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=none smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=lGL4kPLZ; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="lGL4kPLZ" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-70b1207bc22so4388367b3a.3 for ; Tue, 16 Jul 2024 01:28:35 -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=vger.kernel.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=lGL4kPLZZLAWoNicTjO8N2WRv1dDpsVaBCOY1OPmwl1qcHjxlJpjaFJvTFFl0tCtKc TTCm8YmVnbEzJecbmXNu0gnfRyomvXnkoAO3CoQ5utoiZ2ZYlobeVMwh5F3N+rOS2cvZ rpZJ3IoqyhKwoPg3853UA/ot7iHqtVI6y2Vu3JDPH4WGdRdxq4mBlMfXK3R4Cavu/LU/ bGUF3Z2q6a0wwkHvIwaViqmAnzur+S5fuVw53oAhP2cjcAQXslbsE/h6OuTItpgxNIUr Pdjbc2ZJtvHrrJr2Gz4i7/PEB1fgQGPpPnehSHGnIKfjRqwvuy5IeOZnATOT5Q+nwvDM CGMA== 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=YA59anZlSltZBoTDu5A5cujsuPnX+b3xKHdavKfBRJCLhCbd2dauQquMb+DK4z0jhL CHPbUnBlwAb3UTUr7fpgoBYPmE8ci6MA1P5whj6kY3xK1vK/l3LfUUXvlVlDJJD3VIqX Kr1w014PjZFehy9QAZAW818WsQMgQKB6NREXbFsKzVBlEzgbVd/e9Gy935xJ4OOKOYs2 pQC9bLrukn0GDv/m1gM9g+iM5IWyt+6Hg2MuyEQj7tXtKUIP6oM8tF1ZwVqg1oAVRFyR VAyZOuIA/XiRNAidG84z+kXoxfUDsGRKwXPXQ/F60ILGmDwJkbuAc9KDrNBT75gavH8a /8FA== X-Forwarded-Encrypted: i=1; AJvYcCU3zpxBM8MLWjWvnNpdve0/Fjzgfm2biwabnYgOqj7wv+iL3WZ/Nf+DKQK+x//OQzaC1EJOuBeX8JCYY9l9Yxfp4lfK X-Gm-Message-State: AOJu0YyPswM4onNB0tnijmvQVhvIPcsBNn5OqB9wwVn4/Tk7b1L4z6vL VOEWqFO4JwDZy7oFzbuAF+E/Vrm2Ux3ByE4Wn1q6SpqYt2NubzcuYp+XVChNbkg= 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 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13734156 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 352DE502B1 for ; Tue, 16 Jul 2024 08:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118521; cv=none; b=pCUwOzexA88H9TWlVCmFuGup2SH5D9B4F1ka9bobkYa62og1S2JnjoVuWskqUteSOxG1vXsTI/KBURjoMZMqZPWJY3c7vB5j1I3GlXnYW0r4sD3jpBgqzAwEvkkZnIJoyDHNBItabYKsCdXHK5VDAwUeUcjoOCSUxv/+Us00oFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721118521; c=relaxed/simple; bh=r4LklVSQBJdNnKbC3afcFb6NZPieSYOqMCDcO+aKjE0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BCCkzuXEKwyNQ3+KtfBu1x49x1sNgVo/oZdNBATQ9NZi3bGkX5m8DyY3iXtpU0SP+lR68t+ZQe1XsKcrw/66jAZHSBkQtgkWOibCWtEftaMVOPaEMhBx87K+TyY1lr28KCPcE/9H31QtRbxSHRovDKXs6e0JzGV/N7quXjwTYfw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=none smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=rdUBMAUG; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="rdUBMAUG" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1fbfb7cdb54so24450275ad.2 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=vger.kernel.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=rdUBMAUGDbsHE0de72/LH5C8/rhD8Cjso8O9I6gCks/DmZIXks0eiFXnichdgRt0pH 68NW0zPlgQZGEZXiloo4zMIsfffpji1o/XBQst2kIg845Ri1bnUzFPt+5r2YKQtV/8qH eog9owjxNKEeUhtLfGSv66rtrVGsTKxYJJWsGRilJsgtU4HyjTUjCVt0Lw/rY6WFDBZ0 g0Kwk3JlaCUF+OudECdubUNZtfYEhKWUxsYgSc4YlW66kSo5tgKKPXXgtQPw3c4c3qnJ qXtS1GEXSClAasj2Fsti72e5keQu0CdAlU/ouhV/Czp4LTa4rkGAJhTKTiXSrWwZlROg Eg6w== 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=oFngvcyneHbo0xTE4rX8NtM/mWcXbCwd0XU+zdiEVD+vBkNU0K/K/zh9dL8pmrAlf5 K3lI1auWyrrevVgJRh37CmT6EpEFoq5flnvSaP1ggVWgvdQz3rx+hdsjrOX+/bw5fXYA ydWBewW/lHad7A5i5un6w3bj27R4cnt8MaMG/GDwbb6TXdZvNkYUFRt5Aq/8T/PJf6BV 9B+KrOY0E349KMTsDgJm4B8Bc8caBDI627L0WKGbkKkZkF6ipmLvBXV5YQ3eoW4i47WU Du5lLofhPuo8lhY8Izo9sU8nOCwbnEzwh9IJBB40NvNngHvg7dR+P9484WsgS48c00S1 pq5g== X-Forwarded-Encrypted: i=1; AJvYcCXmQq2zu5XVMzWfb9twqVUewFQdEhbuVaVKwDRJ9gztDhMGKzniTwyj0x1GwaeRlROPaHyQ8mKFnNCNDFqYIU+mVl7O X-Gm-Message-State: AOJu0Yx1vZig7uI0/P3SOjOZARbwixjxJsUaP9pJnwjBOpqxEQ4PoDkk NyauZ0D6gQ2YEBw0R0W7bi3g/ZmCZnSt7e0SHnWIDXsXrKzQI/D8m6uHPaVq3pM= 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 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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;