From patchwork Fri Jan 19 11:34:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 763924 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a08:0:b0:337:62d3:c6d5 with SMTP id m8csp399177wrq; Fri, 19 Jan 2024 03:42:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyFBZactTuJ6zm31BihvC14gbSiE2ZNO9tfF7bCwgD36m9g44bUvpdjQb0i6/F2rrrDbuW X-Received: by 2002:a05:6214:da6:b0:680:b72b:7d7f with SMTP id h6-20020a0562140da600b00680b72b7d7fmr2393450qvh.127.1705664551447; Fri, 19 Jan 2024 03:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705664551; cv=none; d=google.com; s=arc-20160816; b=hTf+rsyn/NfdcmqcPgVUtRdtR0Pak7G/G7eAh+8WjbixUZlQ6ZdnecqXgyfvGoHj+D aYvm9neLIs7xVBbpIcvKE6YZ59CjxvTDvmmOrDmYqR2g6cGh3i90N3vZbj5WtGIc69IT 39yDn+oN9/v6EToJlOva7auWcquYHOgqY5BHJB1eej/nTetWobEEwJqWVIJtN2RzZ2aR NEw41o8t08A+yvWW9Ac/3H358kZGZN9qXY8bThcnf0t2bb3P5O/pt+zRzKw+qFZjqT0u wQKS7xKovtaClqihq1S8pBGPx76AZekZFw6hCm9aBJbRAKfqwn8jvzPYeDSuJYV4fOnZ mxXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uEVuIq2fAugiO07WlgkO+R3+5CVkxIv0WR9Gtc3uhxc=; fh=XLY9/kD9LztQxqN909aTdcehMZxtcAiCmiec2r3FPyM=; b=GIPc+BLuB0s8WpoO+XeTAGW/IHOmByAZH9ebjq/eBHka8lb88Rq/qc61ETRsAGZcnh GSkKMBnuudFoNs1svZePhp6fj9wjgAqcROT8cEjHqnTgRCv2RE7fTFXMlaevYfhjX2MV WwueIlmziuWGEcBs/GKdZ+0/5n/JVZhPbL2C7vbU8ucfFdDnTCnXgQQ0VoE7zfNwnGFQ PHGUmaCyu+6GMl30gqAnCd7AywmIjg4zq1SPgDwruqzA8MNr/lritqjERXM+hwMsmbQm 6cnxzptYH37DLRPZ2/RxLDaxyZSnZrt9rCwmRSaxg5fajnDaXIfH62/5IlhQYiUC3K/M Kqbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="crG/ilcE"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f12-20020a0ccc8c000000b006819736ce2csi2846282qvl.221.2024.01.19.03.42.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jan 2024 03:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="crG/ilcE"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQnAV-0002it-T4; Fri, 19 Jan 2024 06:36:15 -0500 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 1rQnAS-0002bj-LV for qemu-devel@nongnu.org; Fri, 19 Jan 2024 06:36:13 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQnAO-0001gd-KH for qemu-devel@nongnu.org; Fri, 19 Jan 2024 06:36:12 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40e8801221cso5963765e9.1 for ; Fri, 19 Jan 2024 03:36:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705664167; x=1706268967; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uEVuIq2fAugiO07WlgkO+R3+5CVkxIv0WR9Gtc3uhxc=; b=crG/ilcE51nUFWJXGdgDdvo4UpscOiNrOgxcA1fkKxfx5saDy0xuCs6O7pAdkk3A+e bBVB0gIYGAfj2FmH9kO7LxMRaa9Hk/9wdthUAs4pDdIdmZY3jM8GJD3fcvmagDlBt1aK V5X4Pw8BPKg91p6x4qMybO2hmG+hr1YIyL9zkSZxAq3olLE+0M5HhuxAj/dSWengmCqZ R4p1A+SJDojWwhq+akJizpqmpB5bO+KLZOPq5PPoByapklbGQ4RvUXupX5lDjoPs2cvI jDElsE0jOKOJ4a1bug1yBTcT+zZVxF4uRso3M87n4bqa/R6j5buv0n9/pIGmqpuGsjQG HMcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705664167; x=1706268967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uEVuIq2fAugiO07WlgkO+R3+5CVkxIv0WR9Gtc3uhxc=; b=DT7IA2RsKzRX1a/Z8bMxomtFKx0f7Eq4hmako+5NH+l1rxuZ2B15H54wm4f+zKjDoi yTx2mNOPDwnxbDhC4F4NVS2npGH7aGYj8ld2AP2jx7V74W3TZCB8Qb3E6hb7h9zoLK0m 9wpFpB/isDsLBGeKGVMWQVNWneaqlQy12gvU+lM2kUo+VB/MvWdm3nanoqjpR1oFJpE5 m5QIOCrw7MvNJPluAVaMwymgGbGCKqaTlYJSMzzrtZQMoWiQGMfKP/khP9xfjBt5PGIc j1z8+68TBchFoR7eG4dPDV21hgA+4xs6X04+EXU0kNSyMfaHo4mMk3dIyL7Die0mHhPn UxRw== X-Gm-Message-State: AOJu0YyPcFYrvkpK+CUbCZYCPed7m65rsNp+f/4B3bltKS3pQdVqARHe xBs7qUXGe1aCcLCfSrcZhcXL+5J3JqVKTzbc5HQc4mPSiqR7rPoTgHn+DVQOfhvlmf66UtFc2wW L5WSwBg== X-Received: by 2002:a5d:49cc:0:b0:339:2248:3e30 with SMTP id t12-20020a5d49cc000000b0033922483e30mr342492wrs.138.1705664167141; Fri, 19 Jan 2024 03:36:07 -0800 (PST) Received: from localhost.localdomain (91-163-26-170.subs.proxad.net. [91.163.26.170]) by smtp.gmail.com with ESMTPSA id p1-20020adfe601000000b00337bf461385sm6296931wrm.26.2024.01.19.03.36.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jan 2024 03:36:06 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, qemu-block@nongnu.org, qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Peter Maydell Subject: [PULL 13/36] target/arm: Ensure icount is enabled when emulating INST_RETIRED Date: Fri, 19 Jan 2024 12:34:42 +0100 Message-ID: <20240119113507.31951-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240119113507.31951-1-philmd@linaro.org> References: <20240119113507.31951-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org pmu_init() register its event checking the pm_event::supported() handler. For INST_RETIRED, the event is only registered and the bit enabled in the PMU Common Event Identification register when icount is enabled as ICOUNT_PRECISE. PMU events are TCG-only, hardware accelerators handle them directly. Unfortunately we register the events in non-TCG builds, leading to linking error such: ld: Undefined symbols: _icount_to_ns, referenced from: _instructions_ns_per in target_arm_helper.c.o clang: error: linker command failed with exit code 1 (use -v to see invocation) As a kludge, give a hint to the compiler by asserting the pm_event::get_count() and pm_event::ns_per_count() handler will only be called under this icount mode. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20231208113529.74067-5-philmd@linaro.org> --- target/arm/helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 49665bb763..e068d35383 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -954,11 +954,13 @@ static bool instructions_supported(CPUARMState *env) static uint64_t instructions_get_count(CPUARMState *env) { + assert(icount_enabled() == ICOUNT_PRECISE); return (uint64_t)icount_get_raw(); } static int64_t instructions_ns_per(uint64_t icount) { + assert(icount_enabled() == ICOUNT_PRECISE); return icount_to_ns((int64_t)icount); } #endif