From patchwork Fri Jun 4 15:52:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 454083 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp566061jae; Fri, 4 Jun 2021 09:29:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1l+II/a4lWYbvIi/C7elk2cUzlc96T/r02taBx/lKFyL5wcevRtr3WD1B6dtjOu8xDuub X-Received: by 2002:a67:c90d:: with SMTP id w13mr3539686vsk.17.1622824177126; Fri, 04 Jun 2021 09:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622824177; cv=none; d=google.com; s=arc-20160816; b=A6sZwmwBrZgok782CUkaU9TMnEQV/kq0U7YTdfoZk6+SYJcf9wB74o0zo6o7L4vvVt O1ZjOL7PrgqvhmewGzgEyt9IfK/qTb1HeQw6AjiQbEsKeeb/bygCTP0FTOASjHLl3YiV Q9QAhDzX4XG6LWSxNiq1KKNRE7VuQTQ3NdIuKnpjZag7I+6D5Nc5brS+j3K/76ZXGbhs u+GOl2C4eHq3zuinCOebrpFGqwTdOOYoMktxXEPxELRlbsef7Z8991VVzvgcoNRo81To CbIrENn0yh/Izt5o/TbvsnldzjcAxD6tgTEfj37UyS3rigg/bZgEAAragdOIyjqj+Bqy 9DRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=wuU8nDRdcW3/99gtEo5hPanI3MwrgtDEgaxIpfRRswM=; b=F7Nq+9j35w8iwzAf9dPPcuXFk34eEzeK0Fpu8HteRVU6KVzby+k8MXQAPWI7obbugW hkhyxKqYsnTqNAGPg1GyM3tulqMUWvdDHH2D6CwqVRaBM06XBjsrIoscdyOtVDvg++2Y Mv2rEVqYVN1GF+UcCihYlxtZYZpBWM2vV+H4md5e8CzJRlbT4Og6tI/KdjnM1M9cBzEl psUJe7BHiLzYmx+qw6U9YitUeoHR7riyrcbtA3s/r1F0/TuxtPSCIr+4WEfCc97O7lOe +beY3sbqPhi94QKvdloYnNBlFL0Wzex7GuL7gBqUp5ZrJ2rSJdJBexL0MqRe0UgnSNi7 h4EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cUSanbjg; 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=fail (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 q123si3252674vkh.12.2021.06.04.09.29.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Jun 2021 09:29:37 -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=fail header.i=@linaro.org header.s=google header.b=cUSanbjg; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpChU-0001EV-7b for patch@linaro.org; Fri, 04 Jun 2021 12:29:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCI5-0008R1-1R for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:03:22 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:45919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpCHh-0005s9-Bi for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:03:20 -0400 Received: by mail-wr1-x435.google.com with SMTP id z8so9801975wrp.12 for ; Fri, 04 Jun 2021 09:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wuU8nDRdcW3/99gtEo5hPanI3MwrgtDEgaxIpfRRswM=; b=cUSanbjgU5p4C6tM8P66vDYmES/myvA0uhdkylnzBblqyHRqW9b0GNZmBQIqPbsa5r QHbpV/SzLedy8MGN9106VvzbIMxCWeSwNr8sQh0NWoEZzKA1Zrx4lSS+Xz41SWT8gHuv 3+shnUcvZLEwJ17aqehc0nul4DIUDcFN/E448E1uVg5QBnBD4Vk/G8RZAfpyDZScPzB+ k2gKGuaQF534bvGO31tmEfgY++6ZS/rSXDfzDwBCoy3GTVO1r+yTaKC+a44Kga7MA3Qg pJhDKskd/ngQMLLh77rBAi92pPNcfszJyVgS3IrfLZVPIzQlczb1FtXl9dgWNzJ51SBG TAiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wuU8nDRdcW3/99gtEo5hPanI3MwrgtDEgaxIpfRRswM=; b=ZPtS8SWCfKVbSZwBZmwKi//tQ+j2wLjYo6VBZxZBafF6W89NDX5m1ezxP/vbkUriCJ wbP/8y72UnoiPPqdMQPRwWbgcGL+XBO/xi/9TE/WYTn1eWgqiuibktQwWBIp7FkEXQkU 5DE87Agi2LPgC35MyYLaQ41u05tbPHh725y86GoUDaraMofeAGTllpyjbqA5IcCcMqmw aZ35PSTwfDRFFefLDpRaTPigr+Bu91V8zQektJTBjcpxkWMwHXthEzwvMt0XH9gk9X6D aDk/+TZ8KbSx63u+xQ8TEk+x5fCLwESryQYmeYt8a2aFsImfQvPQriNzPvTDvVivxU16 8jCw== X-Gm-Message-State: AOAM530h2UiRYqdkVocaOkxetmC87/UGuMsS4x7O4F4wjg9dhcu1pMPZ 1glW7PkJkcAEA9X/9R3xc1z+Yg== X-Received: by 2002:a5d:4c48:: with SMTP id n8mr4493694wrt.327.1622822575116; Fri, 04 Jun 2021 09:02:55 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b8sm5400497wmd.35.2021.06.04.09.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 09:02:53 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 378FA1FFDE; Fri, 4 Jun 2021 16:53:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v16 70/99] target/arm: move TCG gt timer creation code in tcg/ Date: Fri, 4 Jun 2021 16:52:43 +0100 Message-Id: <20210604155312.15902-71-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210604155312.15902-1-alex.bennee@linaro.org> References: <20210604155312.15902-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Richard Henderson , Claudio Fontana , Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Claudio Fontana we need to be careful not to use if (tcg_enabled()) here, because of the VMSTATE definitions in machine.c, which are only protected by CONFIG_TCG, and thus it would break the --enable-tcg --enable-kvm build. Signed-off-by: Claudio Fontana Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/arm/tcg/tcg-cpu.h | 1 + target/arm/cpu.c | 30 ++++--------------------- target/arm/tcg/sysemu/tcg-cpu.c | 40 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 26 deletions(-) -- 2.20.1 diff --git a/target/arm/tcg/tcg-cpu.h b/target/arm/tcg/tcg-cpu.h index dd08587949..3e4ce2c355 100644 --- a/target/arm/tcg/tcg-cpu.h +++ b/target/arm/tcg/tcg-cpu.h @@ -33,6 +33,7 @@ void tcg_arm_init_accel_cpu(AccelCPUClass *accel_cpu, CPUClass *cc); /* Do semihosting call and set the appropriate return value. */ void tcg_handle_semihosting(CPUState *cs); bool tcg_cpu_realizefn(CPUState *cs, Error **errp); +bool tcg_cpu_realize_gt_timers(CPUState *cs, Error **errp); #endif /* !CONFIG_USER_ONLY */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 945dfbbe9d..2fef8ca471 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -859,32 +859,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) bool no_aa32 = false; #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) - { - uint64_t scale; - - if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { - if (!cpu->gt_cntfrq_hz) { - error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", - cpu->gt_cntfrq_hz); - return; - } - scale = gt_cntfrq_period_ns(cpu); - } else { - scale = GTIMER_SCALE; - } - - cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, scale, - arm_gt_ptimer_cb, cpu); - cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, scale, - arm_gt_vtimer_cb, cpu); - cpu->gt_timer[GTIMER_HYP] = timer_new(QEMU_CLOCK_VIRTUAL, scale, - arm_gt_htimer_cb, cpu); - cpu->gt_timer[GTIMER_SEC] = timer_new(QEMU_CLOCK_VIRTUAL, scale, - arm_gt_stimer_cb, cpu); - cpu->gt_timer[GTIMER_HYPVIRT] = timer_new(QEMU_CLOCK_VIRTUAL, scale, - arm_gt_hvtimer_cb, cpu); - } -#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ + if (!tcg_cpu_realize_gt_timers(cs, errp)) { + return; + } +#endif cpu_exec_realizefn(cs, &local_err); if (local_err != NULL) { diff --git a/target/arm/tcg/sysemu/tcg-cpu.c b/target/arm/tcg/sysemu/tcg-cpu.c index 115ac523dc..1c6df15092 100644 --- a/target/arm/tcg/sysemu/tcg-cpu.c +++ b/target/arm/tcg/sysemu/tcg-cpu.c @@ -54,6 +54,46 @@ void tcg_handle_semihosting(CPUState *cs) } } +/* + * we cannot use tcg_enabled() to condition the call to this function, + * due to the fields VMSTATE definitions in machine.c : it would break + * the --enable-tcg --enable-kvm build. We need to run this code whenever + * CONFIG_TCG is true, regardless of the chosen accelerator. + * + * So we cannot call this from tcg_cpu_realizefn, as this needs to + * be called whenever TCG is built-in, regardless of whether it is + * enabled or not. + */ +bool tcg_cpu_realize_gt_timers(CPUState *cs, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + uint64_t scale; + + if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { + if (!cpu->gt_cntfrq_hz) { + error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", + cpu->gt_cntfrq_hz); + return false; + } + scale = gt_cntfrq_period_ns(cpu); + } else { + scale = GTIMER_SCALE; + } + + cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_ptimer_cb, cpu); + cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_vtimer_cb, cpu); + cpu->gt_timer[GTIMER_HYP] = timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_htimer_cb, cpu); + cpu->gt_timer[GTIMER_SEC] = timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_stimer_cb, cpu); + cpu->gt_timer[GTIMER_HYPVIRT] = timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_hvtimer_cb, cpu); + return true; +} + bool tcg_cpu_realizefn(CPUState *cs, Error **errp) { ARMCPU *cpu = ARM_CPU(cs);