From nobody Thu May 2 10:02:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148883381870110.899686560550208; Mon, 6 Mar 2017 12:56:58 -0800 (PST) Received: from localhost ([::1]:46086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckzgf-0000QJ-3l for importer@patchew.org; Mon, 06 Mar 2017 15:56:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckzg6-0000Om-Tl for qemu-devel@nongnu.org; Mon, 06 Mar 2017 15:56:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ckzg5-0004US-W9 for qemu-devel@nongnu.org; Mon, 06 Mar 2017 15:56:23 -0500 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:33800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ckzg5-0004UN-RJ for qemu-devel@nongnu.org; Mon, 06 Mar 2017 15:56:21 -0500 Received: by mail-qk0-x243.google.com with SMTP id v125so9349688qkh.1 for ; Mon, 06 Mar 2017 12:56:21 -0800 (PST) Received: from bigtime.twiddle.net.com ([2405:7f00:9a00:18bd:4683:197e:73c9:cea1]) by smtp.gmail.com with ESMTPSA id t2sm14193439qkh.0.2017.03.06.12.56.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 12:56:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=FTBJ5BLDXLZULu2Gqs4+FELCYkRgFLJk6buCF8//V8w=; b=ZDo4blpVg6cnyVNBNSEAacq/J45ue0IpNqQc78wUcevH9w5q2g7OhVEn3XqZSNjXt0 geakE+NfKA4lOfC4wg8DIYc/w1DHNEVkoF8uwTjIwjGEjpxpjrhiJ71Ok+ab3p0lCibY OvseP/lcolW+RYfNddMko0OBNRlO9y/pW6TmNtDezYOpLlEeYEzm+5UYx5QP7ajCaJlK pxelSCfaeNOxQh0cdBS+/lOF7ZoQneB3wPhD7DY9z6MUGAZaRenQt5FohX37qIME5Oq2 1aYe+06IfO4a8Q72Vmx1mw89uHLrScCE6fYnYW/ISs8r8uT678qcSSaBAaBGx6V87vSy XGUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=FTBJ5BLDXLZULu2Gqs4+FELCYkRgFLJk6buCF8//V8w=; b=HS8lY1zhAP3NebzxxIz1xVmREY2K3evHbnmV7EIP2xUNkRTsJv0liS6eClSnzD0Kky SfKHf89ZyBDWboAwv9nFLpZ1GaDGrJiTvdpTzos92aI3LIQOiUEXTSS5Nz+xVvN9oMZq lJGALrXtORhhg/9ktVc5V2SOtJscfM+ZGl5fH+If7yMMmbJncYnRSbo2ClGrGw6AvmAr EEYEBsCVmiXmIf9KHzPNkswbL1OH7tgXdej1Iokxhb2gi35CvwNgGNJTaJIN6i9FevYx B3J2QxLQV873PePm6U2eUscwul55xlbdwawIYuyA1HgFsgtOvqDVOQ9keEV3V8PM7KVN l6Vw== X-Gm-Message-State: AMke39nx0P4fN0Se0y0Y+aa7JZ1o+u4TlXE/LkFMPB/fZK8UX/lWQK7Df+bbl38IGEPJgQ== X-Received: by 10.237.35.218 with SMTP id k26mr8268256qtc.60.1488833781180; Mon, 06 Mar 2017 12:56:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 7 Mar 2017 07:56:09 +1100 Message-Id: <20170306205609.6525-1-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::243 Subject: [Qemu-devel] [PATCH] target/alpha: Take BQL around clock manipulations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- This is similar to the patch that I saw go by for MIPS. I hadn't noticed any problems caused by this lack of locking. This may be because interrupts cannot be delivered while in PALmode while these registers are being manipulated. However, it's always better to obey the rules, right? r~ --- target/alpha/sys_helper.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/target/alpha/sys_helper.c b/target/alpha/sys_helper.c index 652195d..6feb30b 100644 --- a/target/alpha/sys_helper.c +++ b/target/alpha/sys_helper.c @@ -28,11 +28,14 @@ uint64_t helper_load_pcc(CPUAlphaState *env) { #ifndef CONFIG_USER_ONLY + uint64_t pcc; /* In system mode we have access to a decent high-resolution clock. In order to make OS-level time accounting work with the RPCC, present it with a well-timed clock fixed at 250MHz. */ - return (((uint64_t)env->pcc_ofs << 32) - | (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) >> 2)); + qemu_mutex_lock_iothread(); + pcc =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) >> 2; + qemu_mutex_unlock_iothread(); + return deposit64(pcc, 32, 32, env->pcc_ofs); #else /* In user-mode, QEMU_CLOCK_VIRTUAL doesn't exist. Just pass through = the host cpu clock ticks. Also, don't bother taking PCC_OFS into account. */ @@ -68,24 +71,34 @@ void helper_halt(uint64_t restart) =20 uint64_t helper_get_vmtime(void) { - return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + uint64_t ret; + qemu_mutex_lock_iothread(); + ret =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + qemu_mutex_unlock_iothread(); + return ret; } =20 uint64_t helper_get_walltime(void) { - return qemu_clock_get_ns(rtc_clock); + uint64_t ret; + qemu_mutex_lock_iothread(); + ret =3D qemu_clock_get_ns(rtc_clock); + qemu_mutex_unlock_iothread(); + return ret; } =20 void helper_set_alarm(CPUAlphaState *env, uint64_t expire) { AlphaCPU *cpu =3D alpha_env_get_cpu(env); =20 + qemu_mutex_lock_iothread(); if (expire) { env->alarm_expire =3D expire; timer_mod(cpu->alarm_timer, expire); } else { timer_del(cpu->alarm_timer); } + qemu_mutex_unlock_iothread(); } =20 #endif /* CONFIG_USER_ONLY */ --=20 2.9.3