From patchwork Fri Sep 30 13:35:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 610948 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1538494pvb; Fri, 30 Sep 2022 06:52:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ydmIx1n0+ew9dn7RxTWi+YYQe9mBCoYEnh2kGF7CRSUKS6qR/jROJJJsB1hnpeNIkC9ER X-Received: by 2002:ac8:5706:0:b0:35c:bd27:bdd4 with SMTP id 6-20020ac85706000000b0035cbd27bdd4mr6806589qtw.68.1664545928467; Fri, 30 Sep 2022 06:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664545928; cv=none; d=google.com; s=arc-20160816; b=h+1A5uGkfiaMvLPLsgtaPuVqmhbR3wPHPqpFSHElBjrnFIdecy8M/8/tFNMmmb/nbW ZI+dl2pybLgxBXAmatHujMvyUyvZGYHvyLEin6yNkuDyInDhRbgsGBd8/tbn7FfurzCO yS6rsIXvpYzyjOU/kSjXAmF9JObDOUrzvINsfUm7nIa5d1OnNOsCHpnhhaz62GLf+i8p ZiFqeysSbqV/6OOrIIS/WSapkHRL3rqXP1jI46eOXGQmxfsJAl5QkY/6A6FYeCokxtNq 9hz4lDjvLdbfUZcLX1T+1WpgesjhBCxc7/rlL5C1zIp8Chc+pwrExcDKy9m/fE2JKuvC GT3Q== 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:to:from :dkim-signature; bh=73I/YN0PohfN/LqwegA1J/BEgnb2qX8LZ5lHJjg4/5M=; b=sPmCWgEW/50Zvc7yuf2hvM2Lt6dDcooSHnO8VzgcGwopO2HcgWM2WWI4ZNCbq1pW7K M9s2E4OSm/SLTzeP4hbaeiEXz/hMH4PRUH1w7A00kojL6/nUbkENL66AoOO/e3YpcX0J zxnxC0OUvTNRTt3PUDsm5Nhb4PFNauy1ul7lkF5ECiEOMuyVcMKkTVtID5LA4lV1ruu6 Vha9AoHbXdefIxYyYXpX8wYV7a9jUZh9sBr93+vDgD5kKD85y7+lVAFT0IlAuVAricU5 3BbZj3b5/iTa76BcRCsBrQY12YI65BrKJ2bH4ZBwRg/RgO+DuOCImJbLCQhmHFU9fQCf 7VCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eHwEFu3e; 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 15-20020a0562140d4f00b00496f722fd1esi1217114qvr.113.2022.09.30.06.52.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Sep 2022 06:52:08 -0700 (PDT) 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=eHwEFu3e; 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]:33964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oeGQx-0001OJ-VK for patch@linaro.org; Fri, 30 Sep 2022 09:52:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oeGAr-0000Lq-4Z for qemu-devel@nongnu.org; Fri, 30 Sep 2022 09:35:29 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:38505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oeGAf-0006Td-KA for qemu-devel@nongnu.org; Fri, 30 Sep 2022 09:35:28 -0400 Received: by mail-wm1-x32a.google.com with SMTP id c192-20020a1c35c9000000b003b51339d350so5050202wma.3 for ; Fri, 30 Sep 2022 06:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=73I/YN0PohfN/LqwegA1J/BEgnb2qX8LZ5lHJjg4/5M=; b=eHwEFu3esV1/kGkXdAd0JUt3YzZ/nRMkSZXGloMvmZrksYcJUSiaxGPejnxYkzqJtz 0BxCU1cdpx5KSKfYiF1Jp209m6xzuEH1Cr8wj4rOvfY1WBgDFYaiMWmS+eFnt9XOjOv4 6y8glS9llj/HHtEcOo6Io3vJJHWqhDr5atxc8B7p404C7gVHhVGmh/56oiuEFLczvFHk 3itvkTVCd9SJlCQGVaZAIpSgcX3aeANl0CBLap9sil4eOcrI92UcLPwEpPTUXgmLDOIC ieOAubo9TjtI5CqmgqAxSvGvp2hEdUCxuDKIWi4DbIT0yvJFTSclZB+Jev6TCsxXnwuJ bGmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=73I/YN0PohfN/LqwegA1J/BEgnb2qX8LZ5lHJjg4/5M=; b=xU0GViN+/UxkhT3WiIzieOUKYP5H29Yu9AScHlKzB7Xb+Y8nF54HDI3tSPfIyDLrEt iRBu5m/FL326RV75bUvQHk96NWTKZCfIZEBgH0kpUCFjk/lkbm71rG0zNBW6U3KMwpLS OUWnNcBLiQLq/QC9NELvbqt6xpF5VUoupDbFA0CynH5QST3sB6BqixnSsPfItS2beGwE QFEdyjeSHtqKwlw7iF5aBEMY9WOp2bXIsI9cZ79/DY0KwOVOR8LWmF8Kb8ITJRpV6kZx ZEuV1ndC8DpR6diSqfP1hTLO+820PGlIEfjfK1r6L8qdQtNpFxpOuDmwPyt2gX+HDvgZ zIrA== X-Gm-Message-State: ACrzQf2JMEscsnHCeq3+Y+UppMHNFmMEpXl63+NQVN/tPw/AdOJipEWw 6afczj6NQqTHXByTjKtF6bivl79qineB3Q== X-Received: by 2002:a7b:c3c8:0:b0:3b4:7279:c2c2 with SMTP id t8-20020a7bc3c8000000b003b47279c2c2mr6062202wmj.186.1664544915942; Fri, 30 Sep 2022 06:35:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id q12-20020adfcd8c000000b0021e4829d359sm1982551wrj.39.2022.09.30.06.35.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 06:35:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/10] target/arm: Make writes to MDCR_EL3 use PMU start/finish calls Date: Fri, 30 Sep 2022 14:35:03 +0100 Message-Id: <20220930133511.2112734-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930133511.2112734-1-peter.maydell@linaro.org> References: <20220930133511.2112734-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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, SPF_HELO_NONE=0.001, SPF_PASS=-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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In commit 01765386a88868 we fixed a bug where we weren't correctly bracketing changes to some registers with pmu_op_start() and pmu_op_finish() calls for changes which affect whether the PMU counters might be enabled. However, we missed the case of writes to the AArch64 MDCR_EL3 register, because (unlike its AArch32 counterpart) they are currently done directly to the CPU state struct without going through the sdcr_write() function. Give MDCR_EL3 a writefn which handles the PMU start/finish calls. The SDCR writefn then simplfies to "call the MDCR_EL3 writefn after masking off the bits which don't exist in the AArch32 register". Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220923123412.1214041-3-peter.maydell@linaro.org --- target/arm/helper.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index fadeed0b6bb..24c592ffef8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4756,8 +4756,8 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, } } -static void sdcr_write(CPUARMState *env, const ARMCPRegInfo *ri, - uint64_t value) +static void mdcr_el3_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) { /* * Some MDCR_EL3 bits affect whether PMU counters are running: @@ -4769,12 +4769,19 @@ static void sdcr_write(CPUARMState *env, const ARMCPRegInfo *ri, if (pmu_op) { pmu_op_start(env); } - env->cp15.mdcr_el3 = value & SDCR_VALID_MASK; + env->cp15.mdcr_el3 = value; if (pmu_op) { pmu_op_finish(env); } } +static void sdcr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* Not all bits defined for MDCR_EL3 exist in the AArch32 SDCR */ + mdcr_el3_write(env, ri, value & SDCR_VALID_MASK); +} + static void mdcr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -5122,9 +5129,12 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[BANK_FIQ]) }, { .name = "MDCR_EL3", .state = ARM_CP_STATE_AA64, + .type = ARM_CP_IO, .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 3, .opc2 = 1, .resetvalue = 0, - .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el3) }, + .access = PL3_RW, + .writefn = mdcr_el3_write, + .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el3) }, { .name = "SDCR", .type = ARM_CP_ALIAS | ARM_CP_IO, .cp = 15, .opc1 = 0, .crn = 1, .crm = 3, .opc2 = 1, .access = PL1_RW, .accessfn = access_trap_aa32s_el1,