From nobody Mon May 6 05:59:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1596483321; cv=none; d=zohomail.com; s=zohoarc; b=NrvauvU95F7RuiopoOItcfsdEWf5ty01+fz6ksccAJhI/Yqb5Y4/pxaABsDJQ5yq0To2YvT1DxchQUIMqdFkcNCYIzDbWEn4niQZGNbP2vN3xWoOFMGFyaEvaXJR/wuQWm0hKPK7y6ZGynCtvaFVGQu2Ct4GGULq9f2C7192Xqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596483321; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u2p6IyQ9jI8fq1z/3i+bly/o4Cwa7bYMinoZHh/imvg=; b=ZpNcgyUNmcQt8LHk9ac1fASKULUDsNLvUNgpcLurjU7spIiG1M8gLctaLigbNFGXwKRHQY7zfZ6nVDsFbxR1uSHt7t7QK+kZXzHU7l3aeOfPOlLEicmZCC7+NfmfgN9GtDFjT4kEUBZqPhX7s+JrSR31iOlC2MslnpHTLYVC794= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596483321780841.4917936884889; Mon, 3 Aug 2020 12:35:21 -0700 (PDT) Received: from localhost ([::1]:42134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2gEy-0002HT-5P for importer@patchew.org; Mon, 03 Aug 2020 15:35:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2gDq-0001Oe-PX for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:10 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:55871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2gDm-0003Z8-JE for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:10 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 9so594600wmj.5 for ; Mon, 03 Aug 2020 12:34:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r206sm985565wma.6.2020.08.03.12.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 12:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=u2p6IyQ9jI8fq1z/3i+bly/o4Cwa7bYMinoZHh/imvg=; b=QuQN4YZ5aI45iJpZLOpXQRYzBsZbInYXUWnprGAR5T+WX4t3xfc+92QD9b87EGy7vD P1eZwCfZu8UH4DZmcH+r0OE2grJ7DdkvL9eLjdjllb0LOLry3ezpBM04wwN1nERSwL7E ILJuV+Balnji9JWjLFOwcKooGyFR/MbkqqUtc6Eluk79EH9IDk0oH6mj91Ko+tRHCRIn BPbxEOvmjwW3CuQiqWONsz6pzd+N2n/qFFo0Kw5hZSI8d99WuEgEpLZf5wEZTX/ZD9KT AbJL4hJYyyI65KNOC4Ri4aIEoCsV59WRTWhm3kMbQE5DiurUu+3QHzrpIsJI2ljf7v7M 8O5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u2p6IyQ9jI8fq1z/3i+bly/o4Cwa7bYMinoZHh/imvg=; b=XrNQbXhn6rEADMTZuaXRNbub+a1rzjxunqG1QN5Mmos5W5APmv3D13rKKtklJOnbG5 kV3SZAjlU7lh1gPRArFY+TCijVMRA9mOXlQDJ6i9QhHa659K7eb7d96SRcdWZJgVL5Xn WBFZRTKvd64aGxw9q33H/xH8NIgk0Gn4TosgnGGo1wCryAdrOxEMYMcrcz0AhMs+eXa8 OVNxp6d4wxgqH4InkwCe+wwPk6wwoeUeqcCm0dpgh82mchECX1Jcv8V82hUAbY37vs/b VTTYKuhYQ1+mqd3QNbl68Fc4gM8QAyQtAaV4N9JWCgUEn/YKrN/mVwcXTK1yJHwnZxna CUdA== X-Gm-Message-State: AOAM531ge+0PZ4EocoGNn1GEuDNBabcBO1FcqXpahP1u+CtstS7Z9Kdd ec0da7f5X7DEQC332KdkgpBA5S/7XmqsNw== X-Google-Smtp-Source: ABdhPJzqjNxjLcBY4qTkrR5ZiEEMhuB23EaX6PdOyiFSYLDF/7xnUmFTXiZadlCMo6irUeHUxZX3Wg== X-Received: by 2002:a7b:c3d2:: with SMTP id t18mr660693wmj.92.1596483244402; Mon, 03 Aug 2020 12:34:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/8] hw/arm/netduino2, netduinoplus2: Set system_clock_scale Date: Mon, 3 Aug 2020 20:33:52 +0100 Message-Id: <20200803193359.12936-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200803193359.12936-1-peter.maydell@linaro.org> References: <20200803193359.12936-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The netduino2 and netduinoplus2 boards forgot to set the system_clock_scale global, which meant that if guest code used the systick timer in "use the processor clock" mode it would hang because time never advances. Set the global to match the documented CPU clock speed of these boards. Judging by the data sheet this is slightly simplistic because the SoC allows configuration of the SYSCLK source and frequency via the RCC (reset and clock control) module, but we don't model that. Fixes: https://bugs.launchpad.net/qemu/+bug/1876187 Signed-off-by: Peter Maydell Reviewed-by: Alistair Francis Message-id: 20200727162617.26227-1-peter.maydell@linaro.org --- hw/arm/netduino2.c | 10 ++++++++++ hw/arm/netduinoplus2.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c index 79e19392b56..8f103341443 100644 --- a/hw/arm/netduino2.c +++ b/hw/arm/netduino2.c @@ -30,10 +30,20 @@ #include "hw/arm/stm32f205_soc.h" #include "hw/arm/boot.h" =20 +/* Main SYSCLK frequency in Hz (120MHz) */ +#define SYSCLK_FRQ 120000000ULL + static void netduino2_init(MachineState *machine) { DeviceState *dev; =20 + /* + * TODO: ideally we would model the SoC RCC and let it handle + * system_clock_scale, including its ability to define different + * possible SYSCLK sources. + */ + system_clock_scale =3D NANOSECONDS_PER_SECOND / SYSCLK_FRQ; + dev =3D qdev_new(TYPE_STM32F205_SOC); qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c index 958d21dd9f9..68abd3ec69d 100644 --- a/hw/arm/netduinoplus2.c +++ b/hw/arm/netduinoplus2.c @@ -30,10 +30,20 @@ #include "hw/arm/stm32f405_soc.h" #include "hw/arm/boot.h" =20 +/* Main SYSCLK frequency in Hz (168MHz) */ +#define SYSCLK_FRQ 168000000ULL + static void netduinoplus2_init(MachineState *machine) { DeviceState *dev; =20 + /* + * TODO: ideally we would model the SoC RCC and let it handle + * system_clock_scale, including its ability to define different + * possible SYSCLK sources. + */ + system_clock_scale =3D NANOSECONDS_PER_SECOND / SYSCLK_FRQ; + dev =3D qdev_new(TYPE_STM32F405_SOC); qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); --=20 2.20.1 From nobody Mon May 6 05:59:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1596483450; cv=none; d=zohomail.com; s=zohoarc; b=McYNp8aECCryF7rwzvBuxYhA/mJip5yv0ze5HRRazOIktmShXUTP/mLk1RU6hUJ8YpIMku9jWNs80MD1CWCouKpPrz2RuNe+hDZ++V8slituZv+eXDrXaIzZtxJcgeQgynNgw1h5bGpvR19Ocxd2eaeYjtDhbczCnociE0sOu0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596483450; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4vDGqZ2ldUksfvaG7R4N/0YfoKdcIGpfPr3KnIZ9SRY=; b=GxVNSWGavjdg6t+34TgXJVBuJ7RmQdgCfRTL3desmDhnj34w+wOpom0cf46zJ8n7AE/nrgyBAABkmz0n31K2MESoaGsRnQHIdPVE4rgWO8Fl1qgH65qDZHlJosjL/COo5H48cmqD6DjnvGYrq9dU0mTaL6zOXg8H9AwZv6e1BDo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596483450826909.3737496805007; Mon, 3 Aug 2020 12:37:30 -0700 (PDT) Received: from localhost ([::1]:47540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2gH3-0004Xr-9T for importer@patchew.org; Mon, 03 Aug 2020 15:37:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2gDr-0001Ou-Ts for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:11 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:37110) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2gDo-0003ZK-PV for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:11 -0400 Received: by mail-wm1-x342.google.com with SMTP id k8so685743wma.2 for ; Mon, 03 Aug 2020 12:34:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r206sm985565wma.6.2020.08.03.12.34.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 12:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4vDGqZ2ldUksfvaG7R4N/0YfoKdcIGpfPr3KnIZ9SRY=; b=Ugy0lGItCz3Nm6a3O/KpSLAhDFACL8+BtOQZ5re6E/LR9EM0fObTM4gz5QGNn+/Dss LT314GOx3WqTCIV41akU5UFovcU0Uot0sKcGuD64Z11CGajsNor2Rlawe0vNDJ7YfYL4 ErN/OoBKKSxRehStevX6EI5VeEGkbbv76QzKEeZn7NLnvzT7SyUbgN4nJsLziXcvh0dE jW/qi/FrzuzRQ4X0wLjW3Jm5KUk6XdxXVS8I37iAqzmbiiP0PHopS17t3M9mMXAuLgwU 9OhbemoxOFplTu/KlcJNLlffe1SYLtvrbNel39+gmUH/9lB9tMXgav8i7JCnzlFyx1xn gY6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4vDGqZ2ldUksfvaG7R4N/0YfoKdcIGpfPr3KnIZ9SRY=; b=gRGUTEs/BlBi3zdQnh5LlwotBzmC2g9xjwG+XS0Xsh1ixAfM0NZobTsZnudbgzZOnR HT6Ba36VR+h3Wabc7wY39pWd/UxXsTDkhza3Xg2RcpsQlCNxLHcbNsWjUUEEopUxPx5q CC+oQkRQFnNS398B4CMUk/Mg+yFQqAIA1wO8alwOA0hMgxP2tf6z6JFc2pyqD3EHNXeZ P+AW27OGvkaO/tJcxGlF3/UNS3izyxOaxEovnF8WI41Od27OpxKN/WSQ1XbDgpXqE212 ipVite7k1prTJqFM8VpGgXYv7CHJqE6+bojNT67DNuZnl3eS68mZyjMfGKGlicrJ66aL Ji1g== X-Gm-Message-State: AOAM533XG7d9FeoPMbh98mGldM2hENIlZTfycgCK2VmCGYYSbbETP9Ge QVzMNypuNCtRu/KPuT+xx0YA03EWkHTuiA== X-Google-Smtp-Source: ABdhPJydnLk7uj5DcidOAm072wFtsVKMEul6iuuy2pwYGAssaOKcMO8V9v1rYtMynLT3GECC3RSJww== X-Received: by 2002:a1c:e008:: with SMTP id x8mr626549wmg.75.1596483246200; Mon, 03 Aug 2020 12:34:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/8] include/hw/irq.h: New function qemu_irq_is_connected() Date: Mon, 3 Aug 2020 20:33:53 +0100 Message-Id: <20200803193359.12936-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200803193359.12936-1-peter.maydell@linaro.org> References: <20200803193359.12936-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Mostly devices don't need to care whether one of their output qemu_irq lines is connected, because functions like qemu_set_irq() silently do nothing if there is nothing on the other end. However sometimes a device might want to implement default behaviour for the case where the machine hasn't wired the line up to anywhere. Provide a function qemu_irq_is_connected() that devices can use for this purpose. (The test is trivial but encapsulating it in a function makes it easier to see where we're doing it in case we need to change the implementation later.) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-id: 20200728103744.6909-2-peter.maydell@linaro.org --- include/hw/irq.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/hw/irq.h b/include/hw/irq.h index 24ba0ece116..dc7abf199e3 100644 --- a/include/hw/irq.h +++ b/include/hw/irq.h @@ -55,4 +55,22 @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); on an existing vector of qemu_irq. */ void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, in= t n); =20 +/** + * qemu_irq_is_connected: Return true if IRQ line is wired up + * + * If a qemu_irq has a device on the other (receiving) end of it, + * return true; otherwise return false. + * + * Usually device models don't need to care whether the machine model + * has wired up their outbound qemu_irq lines, because functions like + * qemu_set_irq() silently do nothing if there is nothing on the other + * end of the line. However occasionally a device model will want to + * provide default behaviour if its output is left floating, and + * it can use this function to identify when that is the case. + */ +static inline bool qemu_irq_is_connected(qemu_irq irq) +{ + return irq !=3D NULL; +} + #endif --=20 2.20.1 From nobody Mon May 6 05:59:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1596483549; cv=none; d=zohomail.com; s=zohoarc; b=gBUMygIE0DKb9OUagKUDMM2FnpExB4GFhDc54JyILNz6AL9mmp+t7PRfaPmI7ImgNp1oAfnu9QHREq5O+gMz0aeiltIBSxKFjIaBvOiH0onisPOf/vm1FND1FjO9Co3fxpAU6GVSEbKgXE/8dPMJYqB+Gby1ScGrZzZLSNKgY6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596483549; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3dVcMoMLCTb5XdSyz5C0L7sWyDj1NgAifJ97Hu5p/DY=; b=IheYuzk7n9tCKT4XcEGAZsjAukFHpqgEVvpnfGx2cijRcX/iWkQD/gPmOcBUsfQnTOKtPWNL4xlUYEqQu3TqOyyjrA2YmDiqYTUp2fRYHC5aR+PQCADl8wjPY4fGbJajooIgwMACRPTl+MtS5emPF8Da6IrmnN6jXvx+fHVj4X8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596483549516901.1104288117263; Mon, 3 Aug 2020 12:39:09 -0700 (PDT) Received: from localhost ([::1]:52730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2gIe-0006kC-8l for importer@patchew.org; Mon, 03 Aug 2020 15:39:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2gDs-0001Pc-7x for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:12 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:35478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2gDq-0003Zb-Fw for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:11 -0400 Received: by mail-wm1-x344.google.com with SMTP id 184so696656wmb.0 for ; Mon, 03 Aug 2020 12:34:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r206sm985565wma.6.2020.08.03.12.34.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 12:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3dVcMoMLCTb5XdSyz5C0L7sWyDj1NgAifJ97Hu5p/DY=; b=MjqwgFh1A97KaIwja73fCeOs6g21gNpsa25tCy5HsvIriATT6tl5M+WtZEwg3bHOBt zb6JlD3FdxvbzT9vrCO8s6MDfbhlYuFmIRDf/Xx/To6Vd6RPgB4DwbcQPJ2mnyLhkFH8 AEniiuBQK6bMOWYZCCFGCrtMb83FKOFMWW1edUlLMc0EVWzI/f6EdhPmGgp2ta0BpwRG 1RSpVYBj+Zcg05s48ZUv1f4Ud+7Ws8pnztQeL/Bf/VlBm2eo2yuO22TUsLaBkADRwlzF VjikOrPz0OzxodD8Jh6yOkkz+UhVxMwvgfN1YAq48vPgOweyXz5na9zEdb64OISn/dlR iJnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3dVcMoMLCTb5XdSyz5C0L7sWyDj1NgAifJ97Hu5p/DY=; b=JHru02RTX+A5sVZQjpQRDhMNPx8SxL0RETi5LJBWc9uOzCVsG40erR7DQ0yuLmhsBE v4th5zVDLFBl6T/1jtQO60LKozA6Z5mElgp1dBTXQDCcngIbgdOqk7i4QsJJR27uAu5J eVu/JJRUqIJ8reSrfzLUYE+yq59ZVvou/PjlwrwTOdMIJ9DJiI9Xddm+IwCCGAr6qhWE N5KtplhHjYsReR7iG82PVmNHjO8b/wM2wlDB4rE5OMNZ3yHqT+DV7VW+Unan4jclisdW 0CXxQqTcUr7i9oVQLjbG5z83Tx5FFwTiTE2mMgoE3ErVYY23kSmIqQUiOVMXclhhbvQz 33nw== X-Gm-Message-State: AOAM530Z1JRDO/hm0m7WdNuSL4V84Q3DFIFTNJX/jJ9tasAuV5QtlZ0p x77xgP3Qr8dF/nhlpRAJE1vgs34pxskTKg== X-Google-Smtp-Source: ABdhPJyxFo5yaoU0JY9MGZfhVvC1/6ltiVum6h0k9O88gDsBph39dVs2WWJIMpPJBoMOpXc0HLqCIg== X-Received: by 2002:a1c:ba83:: with SMTP id k125mr655825wmf.160.1596483247770; Mon, 03 Aug 2020 12:34:07 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/8] hw/intc/armv7m_nvic: Provide default "reset the system" behaviour for SYSRESETREQ Date: Mon, 3 Aug 2020 20:33:54 +0100 Message-Id: <20200803193359.12936-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200803193359.12936-1-peter.maydell@linaro.org> References: <20200803193359.12936-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, URIBL_BLOCKED=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals when the guest sets the SYSRESETREQ bit in the AIRCR register. This matches the hardware design (where the CPU has a signal of this name and it is up to the SoC to connect that up to an actual reset mechanism), but in QEMU it mostly results in duplicated code in SoC objects and bugs where SoC model implementors forget to wire up the SYSRESETREQ line. Provide a default behaviour for the case where SYSRESETREQ is not actually connected to anything: use qemu_system_reset_request() to perform a system reset. This will allow us to remove the implementations of SYSRESETREQ handling from the boards where that's exactly what it does, and also fixes the bugs in the board models which forgot to wire up the signal: * microbit * mps2-an385 * mps2-an505 * mps2-an511 * mps2-an521 * musca-a * musca-b1 * netduino * netduinoplus2 We still allow the board to wire up the signal if it needs to, in case we need to model more complicated reset controller logic or to model buggy SoC hardware which forgot to wire up the line itself. But defaulting to "reset the system" is more often going to be correct than defaulting to "do nothing". Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-id: 20200728103744.6909-3-peter.maydell@linaro.org --- include/hw/arm/armv7m.h | 4 +++- hw/intc/armv7m_nvic.c | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h index d2c74d3872a..a30e3c64715 100644 --- a/include/hw/arm/armv7m.h +++ b/include/hw/arm/armv7m.h @@ -35,7 +35,9 @@ typedef struct { =20 /* ARMv7M container object. * + Unnamed GPIO input lines: external IRQ lines for the NVIC - * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ + * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ. + * If this GPIO is not wired up then the NVIC will default to performing + * a qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET). * + Property "cpu-type": CPU type to instantiate * + Property "num-irq": number of external IRQ lines * + Property "memory": MemoryRegion defining the physical address space diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 3c4b6e6d701..277a98b87b9 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -19,6 +19,7 @@ #include "hw/intc/armv7m_nvic.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "sysemu/runstate.h" #include "target/arm/cpu.h" #include "exec/exec-all.h" #include "exec/memop.h" @@ -64,6 +65,20 @@ static const uint8_t nvic_id[] =3D { 0x00, 0xb0, 0x1b, 0x00, 0x0d, 0xe0, 0x05, 0xb1 }; =20 +static void signal_sysresetreq(NVICState *s) +{ + if (qemu_irq_is_connected(s->sysresetreq)) { + qemu_irq_pulse(s->sysresetreq); + } else { + /* + * Default behaviour if the SoC doesn't need to wire up + * SYSRESETREQ (eg to a system reset controller of some kind): + * perform a system reset via the usual QEMU API. + */ + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); + } +} + static int nvic_pending_prio(NVICState *s) { /* return the group priority of the current pending interrupt, @@ -1524,7 +1539,7 @@ static void nvic_writel(NVICState *s, uint32_t offset= , uint32_t value, if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) { if (attrs.secure || !(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK))= { - qemu_irq_pulse(s->sysresetreq); + signal_sysresetreq(s); } } if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) { --=20 2.20.1 From nobody Mon May 6 05:59:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1596483453; cv=none; d=zohomail.com; s=zohoarc; b=Roxq/UsIfoM8a2GmZ87bsym73+bnbauw1X7x/OBqCsRf4zbovfde7BEDVbY8dd/SVtbfGohuob+GgpiwWhCfzOxirEJlhWvp4SBw4xrY23maNNM9m9wieNyaGmpg/v6XGarSV5hEm4l3gpgfjas9UT2KnCRGZrbozT78D3HKcn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596483453; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=40piShayyQWcskVekKLi2etxoD3Oho/QcZJcKds9zsk=; b=QQwbYtCisngA60TM67t2LPDwOzt5bTTJy67ggjULIdNWfLYSMqjSsPvhPC4XLN11vSNDMpxCoQwIfH0xjSkfa1J4cocJckAu178t9ngDPcxaAiDsp9aCn9ozFF56EA02Z5ILZTipfL5vXYRWbFiVjKBmb1wvGuaLg37TtPRfaZY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596483453475598.6128756094595; Mon, 3 Aug 2020 12:37:33 -0700 (PDT) Received: from localhost ([::1]:47750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2gH6-0004dL-4k for importer@patchew.org; Mon, 03 Aug 2020 15:37:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2gDt-0001S8-HE for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:13 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:54921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2gDr-0003Zq-Ka for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:13 -0400 Received: by mail-wm1-x344.google.com with SMTP id d190so600737wmd.4 for ; Mon, 03 Aug 2020 12:34:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r206sm985565wma.6.2020.08.03.12.34.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 12:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=40piShayyQWcskVekKLi2etxoD3Oho/QcZJcKds9zsk=; b=XJXsfYgJS/ElZbXx4mdZM1ymgEQ1107Y2Vb7TTETqIJE2fyx5IFGOkrPEMB3BJtRMX Qj8OIfOk/afLBBzkdg3Zd/bunc8nTejEkVLyKC8SK3snAZXRLiC3BtRm7DP8KebvaJC1 uHnFjrmNpi0Ack6dTrCillZYl1luWCp1ppNS7+zGPM+UMA1pIkxbpOhVCx3mvtdU3/Hi emKo6/9Ozq95Uf1v1v3OGX0KMlijCWzRw4RzsQoeFCk3XsHohPSmMqaqzPj9Jv7DitTx 1jK9A704ygVJQ6rA8tX5caST+8HrWqObudjoQxK6BI78KV5GYE1EflOzI8oiAn1DQW2+ Kpxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=40piShayyQWcskVekKLi2etxoD3Oho/QcZJcKds9zsk=; b=X+mU1CiB5zO8z/ydpaTggImx/GqNO2bnfF459Dvr5x/lIQ6z8AJKRf/WiM4a5Y/ymK iyi2hUnxzH8kIJVD/oKRV1qdPCBnmrx+wT1UWkUb5yQ5HNdhMJ7vi23t+Dd2l0eBfwH3 joC6o+DODkY9ca7jhecoY+SzgrR1/boIJB0+edRunrsj6lbtPNi/nz8mDAVqo53Azh+c dE4VUKB+IDKvRsPvekjW5SkPOtr4wM4oS2YqKEmBbj7uNrIwqZ+I19i74z/gDoDqxrD3 2ZjkrcqJhN/HRJ2OXd5NUpjzvf9hl9Oj99UG8EsZDo4vqjv/l1+I+9yM2fk1sylmLSCj Qufw== X-Gm-Message-State: AOAM531pBc8N4qFyD5hkdyXh1ALKnxk6m1BPZQwELXae8W4i4UVm0zDu V3peEY3U9bjVaTj7trGaXch7grsYpty6/Q== X-Google-Smtp-Source: ABdhPJwERxrkhg/LHEBTsidoRmqEHmqkFy9hJBvHB2R5rRdUJIx5CVm2oh4XoOHAFyxwaZZtklCzfQ== X-Received: by 2002:a1c:7204:: with SMTP id n4mr610126wmc.161.1596483249471; Mon, 03 Aug 2020 12:34:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/8] msf2-soc, stellaris: Don't wire up SYSRESETREQ Date: Mon, 3 Aug 2020 20:33:55 +0100 Message-Id: <20200803193359.12936-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200803193359.12936-1-peter.maydell@linaro.org> References: <20200803193359.12936-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) The MSF2 SoC model and the Stellaris board code both wire SYSRESETREQ up to a function that just invokes qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); This is now the default action that the NVIC does if the line is not connected, so we can delete the handling code. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-id: 20200728103744.6909-4-peter.maydell@linaro.org --- hw/arm/msf2-soc.c | 11 ----------- hw/arm/stellaris.c | 12 ------------ 2 files changed, 23 deletions(-) diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c index 33ea7df342c..d2c29e82d13 100644 --- a/hw/arm/msf2-soc.c +++ b/hw/arm/msf2-soc.c @@ -30,7 +30,6 @@ #include "hw/irq.h" #include "hw/arm/msf2-soc.h" #include "hw/misc/unimp.h" -#include "sysemu/runstate.h" #include "sysemu/sysemu.h" =20 #define MSF2_TIMER_BASE 0x40004000 @@ -59,13 +58,6 @@ static const int spi_irq[MSF2_NUM_SPIS] =3D { 2, 3 }; static const int uart_irq[MSF2_NUM_UARTS] =3D { 10, 11 }; static const int timer_irq[MSF2_NUM_TIMERS] =3D { 14, 15 }; =20 -static void do_sys_reset(void *opaque, int n, int level) -{ - if (level) { - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); - } -} - static void m2sxxx_soc_initfn(Object *obj) { MSF2State *s =3D MSF2_SOC(obj); @@ -130,9 +122,6 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Er= ror **errp) return; } =20 - qdev_connect_gpio_out_named(DEVICE(&s->armv7m.nvic), "SYSRESETREQ", 0, - qemu_allocate_irq(&do_sys_reset, NULL, 0)); - system_clock_scale =3D NANOSECONDS_PER_SECOND / s->m3clk; =20 for (i =3D 0; i < MSF2_NUM_UARTS; i++) { diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 28eb15c76ca..5f9d0801807 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -18,7 +18,6 @@ #include "hw/boards.h" #include "qemu/log.h" #include "exec/address-spaces.h" -#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "hw/arm/armv7m.h" #include "hw/char/pl011.h" @@ -1206,14 +1205,6 @@ static void stellaris_adc_init(Object *obj) qdev_init_gpio_in(dev, stellaris_adc_trigger, 1); } =20 -static -void do_sys_reset(void *opaque, int n, int level) -{ - if (level) { - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); - } -} - /* Board init. */ static stellaris_board_info stellaris_boards[] =3D { { "LM3S811EVB", @@ -1317,9 +1308,6 @@ static void stellaris_init(MachineState *ms, stellari= s_board_info *board) /* This will exit with an error if the user passed us a bad cpu_type */ sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal); =20 - qdev_connect_gpio_out_named(nvic, "SYSRESETREQ", 0, - qemu_allocate_irq(&do_sys_reset, NULL, 0)); - if (board->dc1 & (1 << 16)) { dev =3D sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, qdev_get_gpio_in(nvic, 14), --=20 2.20.1 From nobody Mon May 6 05:59:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1596483630; cv=none; d=zohomail.com; s=zohoarc; b=e9kwax/0qWJdpmKXLOrlwM4eq4KKwfvTKyzzIdga2pK+DrJ15RpYVgkSl8kHKz3t/m5QtdqBs3Ip0wrUuYG++hf/WY7X9huDUCe2zWkHW0S08rpyQvOruW4KPFoMwvqkI4P7ICHMuiQJ6CuKeS/WhazxwPhhxhODRE0PEz5GQR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596483630; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+x86j1nJrSJr/whqOt2lTLFOKpP51a1MJPUQH0taM0Q=; b=LlS5tq6sn04HC0ZzR8RoBM4GLGXIGilOK0O2yYtMnQvpAMUipLnkE7q6+OQ5RnRqJjjEBLpLnKp3lwB97W0WTbCfs95AfgRUN2/YD8BTauUbzongCHuxzsP3NS8YQw1cg3wux91t+8SF/qseu5miEzdS/GtU4aDu5vNxZwEbNU4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596483630453726.2930688134159; Mon, 3 Aug 2020 12:40:30 -0700 (PDT) Received: from localhost ([::1]:57000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2gJw-00004s-Pm for importer@patchew.org; Mon, 03 Aug 2020 15:40:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2gDw-0001X8-5i for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:16 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:52088) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2gDu-0003aG-D6 for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:15 -0400 Received: by mail-wm1-x331.google.com with SMTP id p14so617122wmg.1 for ; Mon, 03 Aug 2020 12:34:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r206sm985565wma.6.2020.08.03.12.34.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 12:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+x86j1nJrSJr/whqOt2lTLFOKpP51a1MJPUQH0taM0Q=; b=hbC4wh87oMNGJ5bjEWJdWrbeq4uYGls/z5u3D9cunMcNwQW2sJrOlVD/cNixowzqeY ZzD5rfYAr8GgIcjeBK6ZUH0sFp0+1IDiF3tkmiJEoAor7JW/KgDK6dqueQflKZmFDgzw GddAqhnx07FwwZqh6UqEMLg9yzRZMeuUmz0nRqj/hf5KDLj5gittGSox9CVxnuVm5IPX tjRVBeCOH5CM9Ny0t5iFi/gUi7Kc9QRpuwcw2wMm0xV0vW3Z6tHQ5eUXQj6FM9/IdlFg Gh5LG7axxX3Tj8rlWAugskBQjZArAzo4fD7q2ir2xo4wxQuRb0qxDM49NrVrrKZX6ESp HDcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+x86j1nJrSJr/whqOt2lTLFOKpP51a1MJPUQH0taM0Q=; b=XKW24OIDuCyj4UVZ0H5IqwL3205VLSTlhUpfx57rhOwzA+2cocB/cz+HZDjRCJuwyL QLGPjXmtl3Xzv0KZL4Ccg/vurRCJlHPMFH+VJX7BXQ1E+mdyaZpbbbqk/xq0esQcFvBV Bbc8YTvmdOu6zTyTdvQ0cVvaORqThyuoq/QHDhcWxiw1EJEKtnHEV9cKo5yVxQT+b7uh N4M8G6qX8Xf9T7bMNtDAaMCdBD2sIwYrOC4ZzNs0YU5rD2Wl+1XOXQBiCK+nMtEt6YNT qDGXFhakbmlfm20fHzNgFNyb5aX/ztAiV+gZDgDYTIyCQNJQ+RALWLUnEFOhmbb/3dnS L2Jw== X-Gm-Message-State: AOAM531y7X1ctH1DF3X5omkJjcxPMnquapi7MT4Kl5GVyRrLbkRb6/TN UNfOvZRxR2q1S6SLWRclxc2WbIUDYvzw5A== X-Google-Smtp-Source: ABdhPJzGwkzdF0bb/NhbEUduUbrviOZ4KXBxNOY78UNrroaYp87PSzvJbaypocN5D6cY3iO+GqmV1w== X-Received: by 2002:a1c:a7d1:: with SMTP id q200mr604191wme.131.1596483251719; Mon, 03 Aug 2020 12:34:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/8] target/arm: Fix AddPAC error indication Date: Mon, 3 Aug 2020 20:33:56 +0100 Message-Id: <20200803193359.12936-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200803193359.12936-1-peter.maydell@linaro.org> References: <20200803193359.12936-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, URIBL_BLOCKED=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson The definition of top_bit used in this function is one higher than that used in the Arm ARM psuedo-code, which put the error indication at top_bit - 1 at the wrong place, which meant that it wasn't visible to Auth. Fixing the definition of top_bit requires more changes, because its most common use is for the count of bits in top_bit:bot_bit, which would then need to be computed as top_bit - bot_bit + 1. For now, prefer the minimal fix to the error indication alone. Fixes: 63ff0ca94cb Reported-by: Derrick McKee Signed-off-by: Richard Henderson Message-id: 20200728195706.11087-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell [PMM: added comment about the divergence from the pseudocode] Signed-off-by: Peter Maydell --- target/arm/pauth_helper.c | 6 +++++- tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/aarch64/pauth-5.c diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index b909630317e..6dbab037683 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -300,7 +300,11 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_= t ptr, uint64_t modifier, */ test =3D sextract64(ptr, bot_bit, top_bit - bot_bit); if (test !=3D 0 && test !=3D -1) { - pac ^=3D MAKE_64BIT_MASK(top_bit - 1, 1); + /* + * Note that our top_bit is one greater than the pseudocode's + * version, hence "- 2" here. + */ + pac ^=3D MAKE_64BIT_MASK(top_bit - 2, 1); } =20 /* diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c new file mode 100644 index 00000000000..67c257918b9 --- /dev/null +++ b/tests/tcg/aarch64/pauth-5.c @@ -0,0 +1,33 @@ +#include + +static int x; + +int main() +{ + int *p0 =3D &x, *p1, *p2, *p3; + unsigned long salt =3D 0; + + /* + * With TBI enabled and a 48-bit VA, there are 7 bits of auth, and so + * a 1/128 chance of auth =3D pac(ptr,key,salt) producing zero. + * Find a salt that creates auth !=3D 0. + */ + do { + salt++; + asm("pacda %0, %1" : "=3Dr"(p1) : "r"(salt), "0"(p0)); + } while (p0 =3D=3D p1); + + /* + * This pac must fail, because the input pointer bears an encryption, + * and so is not properly extended within bits [55:47]. This will + * toggle bit 54 in the output... + */ + asm("pacda %0, %1" : "=3Dr"(p2) : "r"(salt), "0"(p1)); + + /* ... so that the aut must fail, setting bit 53 in the output ... */ + asm("autda %0, %1" : "=3Dr"(p3) : "r"(salt), "0"(p2)); + + /* ... which means this equality must not hold. */ + assert(p3 !=3D p0); + return 0; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index b617f2ac7e0..e7249915e7e 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -19,7 +19,7 @@ run-fcvt: fcvt =20 # Pauth Tests ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_3),) -AARCH64_TESTS +=3D pauth-1 pauth-2 pauth-4 +AARCH64_TESTS +=3D pauth-1 pauth-2 pauth-4 pauth-5 pauth-%: CFLAGS +=3D -march=3Darmv8.3-a run-pauth-%: QEMU_OPTS +=3D -cpu max run-plugin-pauth-%: QEMU_OPTS +=3D -cpu max --=20 2.20.1 From nobody Mon May 6 05:59:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1596483710; cv=none; d=zohomail.com; s=zohoarc; b=l3z+S6mEDP6R7/nfjmVz2MLzvw6BqIE51ujHpS/QaM5eq98ZAkwqfp2RGcvp9jpQZaGB2RZS/vJDAoX1vh9Dn83j18NeD/LBxdsI6EO9CHkR4jEJ11htscdpac+9mDgvPrzVR71u6ZDoR085GT8fuhCwzsP/ymk6fhoEs0AgwOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596483710; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j1c+F8DYbSwCT13YFoz0sEvQBiVdlsCam126Zkl/q/Y=; b=ngZe1wD4/Vu5Fu8795lRf3G6OwIzHg9pznm9czJLLujBTcTjNk9XFRObWEYNoruWH1hp1/FxC/20tTftVuIxisDCnkJqSkGyiV9OwRZhnnb4halda9lqxwQhzrHC8EZxQxLXDwiuoyEcCIyu9Sf9x4GkVOcWI2K2vkv/SIAzZrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596483710062601.627862832156; Mon, 3 Aug 2020 12:41:50 -0700 (PDT) Received: from localhost ([::1]:32768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2gLE-0001sX-Kd for importer@patchew.org; Mon, 03 Aug 2020 15:41:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2gDx-0001Zv-RS for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:17 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:33491) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2gDw-0003aW-2d for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:17 -0400 Received: by mail-wr1-x42d.google.com with SMTP id p20so358546wrf.0 for ; Mon, 03 Aug 2020 12:34:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r206sm985565wma.6.2020.08.03.12.34.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 12:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=j1c+F8DYbSwCT13YFoz0sEvQBiVdlsCam126Zkl/q/Y=; b=DkERSRw2DpNV1ecAeLJnOB/pwkZ/LiAzpuW7jRapT4QU3Yf4UH9tcgTpUo78Wi8PhE lGxEaSHVMJb79zWZTkbfIs0cpclEsB9fL96O9B4QzpUwlwe/0VHlgPtWE6GOO1SyI4fA 2UvqTC04/AhcDqn/KRz4lrIndSx+Eo4C8fpzPjLoea7cxMISf5Vt131rKeAQdbrUzA2a 1++kPlF7QOi7kjHxS/0214LwWtT87nqvF5s2C7PzYLAK5yavvLLHyBqeVj/Vi5YcGhxB XMzmjhRXeaa8w3aAfufXoBvzPMbYo0Rrgx/Buq2rjJG0x9UwyBdYZ/UjY2e5a6CZYYiz 1sHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j1c+F8DYbSwCT13YFoz0sEvQBiVdlsCam126Zkl/q/Y=; b=KiNObMW/c138LhR5SX45a0UCYpvmdJv6DvyN5j50ReWoopHAqfXg6otvI1U65wwm6Z Tv8dz+UBk9cOoMVfkvJainmpo7TYjD05HJ4/OOeevneYRK7TLk7j3tdxiIO6nS4fAkAX G5pDv/ghC5+miJVcMfwLmCr9jLuczsv1COjpFZGqmC+YNsGij/P7VE6gTCvT9z43feLS 2x4zCAGeqn/Qyj6RNyemRMtdUmAapbs+cV/OsMu3kb07GqqJw7i5jbFN40CVqe/sFAy8 DwS+rYsnlBJLrND07JmEFHegMm+1HHI0kCHFagJSBJp0bOzgqgkdarZ1Sy3MkK+mFsQ7 rDLg== X-Gm-Message-State: AOAM533unTxi/povc5tA5gFrRwEi9uuRBxE/z7fQ3if9YhS149YM83Oo SAtXeYzAvwgo3J+P3AIfDC9VctRME2lceQ== X-Google-Smtp-Source: ABdhPJywWxrJ3tzqTIbHNIgR6m7Y3U7brQDRKgK3L5EPzkeBbAh+JZFDBgsDGMEF0P88XKWMhvzWcw== X-Received: by 2002:adf:8486:: with SMTP id 6mr16371550wrg.109.1596483253792; Mon, 03 Aug 2020 12:34:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 6/8] target/arm: Avoid maybe-uninitialized warning with gcc 4.9 Date: Mon, 3 Aug 2020 20:33:57 +0100 Message-Id: <20200803193359.12936-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200803193359.12936-1-peter.maydell@linaro.org> References: <20200803193359.12936-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Kaige Li GCC version 4.9.4 isn't clever enough to figure out that all execution paths in disas_ldst() that use 'fn' will have initialized it first, and so it warns: /home/LiKaige/qemu/target/arm/translate-a64.c: In function =E2=80=98disas_l= dst=E2=80=99: /home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: =E2=80=98fn=E2= =80=99 may be used uninitialized in this function [-Werror=3Dmaybe-uninitia= lized] fn(cpu_reg(s, rt), clean_addr, tcg_rs, get_mem_index(s), ^ /home/LiKaige/qemu/target/arm/translate-a64.c:3318:22: note: =E2=80=98fn=E2= =80=99 was declared here AtomicThreeOpFn *fn; ^ Make it happy by initializing the variable to NULL. Signed-off-by: Kaige Li Message-id: 1596110248-7366-2-git-send-email-likaige@loongson.cn Reviewed-by: Peter Maydell [PMM: Clean up commit message and note which gcc version this was] Signed-off-by: Peter Maydell --- target/arm/translate-a64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 8c0764957c8..c98dfb17a83 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -3315,7 +3315,7 @@ static void disas_ldst_atomic(DisasContext *s, uint32= _t insn, bool r =3D extract32(insn, 22, 1); bool a =3D extract32(insn, 23, 1); TCGv_i64 tcg_rs, clean_addr; - AtomicThreeOpFn *fn; + AtomicThreeOpFn *fn =3D NULL; =20 if (is_vector || !dc_isar_feature(aa64_atomics, s)) { unallocated_encoding(s); --=20 2.20.1 From nobody Mon May 6 05:59:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1596483794; cv=none; d=zohomail.com; s=zohoarc; b=CSnQxw3fKL+P1qztpBDSmrHRg9987sBbQmF2rmD1M04IxAz8mCWGEmUl1UIyIM4ECeWHREtwle1/fMOmKODeaLbsfp9D4KNyUpWUjkcrXgfANLtIfavhNxFhAf2mPT5MLCFAgi/I9tY8VClicrkdOTM6P0M7shu00zUgFWK/Sto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596483794; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gk3VwwKe4KQ5WfGGFSh7CZcjxUAI5pDxJotIx+KqNXY=; b=oIOEaKhKlCBd4g3EzXk+7CB1KNTJx2emMUnW96VRKGyFBTOESMmHnYnuQWh7aiPpOncbmnrOBU+Yaea2z/MEka7Gra0CCcSwN2q2Hy+qgdLtoARbT+NxVzMvI2BkWTFgHqqu6aGkgHYLHirBb8MK2Ati4CFc8YIkDG2p0mLqX9w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596483793940373.5616896230707; Mon, 3 Aug 2020 12:43:13 -0700 (PDT) Received: from localhost ([::1]:35576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2gMa-00035T-Oh for importer@patchew.org; Mon, 03 Aug 2020 15:43:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2gDz-0001cY-H4 for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:19 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:37276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2gDx-0003ah-Pp for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:19 -0400 Received: by mail-wr1-x443.google.com with SMTP id y3so35261622wrl.4 for ; Mon, 03 Aug 2020 12:34:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r206sm985565wma.6.2020.08.03.12.34.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 12:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gk3VwwKe4KQ5WfGGFSh7CZcjxUAI5pDxJotIx+KqNXY=; b=sYIT0E1+lBCt9kzzyCy2Grgbf+N0dU3+CeFOPnFlYbOG27PzQpKqQJrI9rwTCZwAPC ZcpvXb8eS1cfpUQubearTPCrUkvxA6HwITFzbdm/GY2U+Fx/GyJYfectWGR3WtdE1Ka9 Z2gY7+bAwm5wc//rPrehI5r06V/t+byDcubzIZyI7SYfiWWyKA93swmEfmabOL6d58iI ZqGQpTEox9BXS0u8uWS16jlpJeqGVGO9LoEeVeOt6VnTvM0II2TRv/cWn299ferNAJLo dZD4dSXuSrqnaodxJsDgaLj5wudeaEyWs6AMfsDDrkFJwdzWWdkCBzuXlk1NvtBQB7F9 2WXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gk3VwwKe4KQ5WfGGFSh7CZcjxUAI5pDxJotIx+KqNXY=; b=kfGFCuh7h1+Y5AqFUF6SRR00w3h4NM0qYjDvfAQVGJ0Ayva1hszgbAZ25mdrtx1PRj K6ptHYWD4zyh16quwFZiE0fdMxg8Hph3zYAxWPnX9k4FQ33ryqrpQ/eJKqS4Yps3cf9x ULG0tZZd1d90to5Ue34BGlwJcmaG+iFMq2danwQ3F40zi+V8ixjHXjBfVpBMQoPM/Qmc Plgerm0/Dr3f6IGu2qpNz5CyvxxCoVAJquf3tv9mX6+L+XwG5qkgPexHi5BE1sz9Zep1 Vk6NWmZ9BtwA20kKSuSWsSR39Zk2qvqoS57BJgtu3o09H3ycWSljfgk3U0amGeGZo1/6 Kcog== X-Gm-Message-State: AOAM5304TAxEtq8o7zEYKn+8GbnXJ2fAqa/EBcgtw7hJnOMsKblI3x31 r75pmMn6kVwGg/qWcAnn2mhwcjkAQq5DCg== X-Google-Smtp-Source: ABdhPJzQmSwTkc/fDz9YzqQiJMOocg+14DVWn/ioBXehRVVe7rgkcnmBTpj0Vshy7uIQNh15QsQkrQ== X-Received: by 2002:adf:83c5:: with SMTP id 63mr16001028wre.321.1596483255542; Mon, 03 Aug 2020 12:34:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 7/8] hw/arm/nrf51_soc: Set system_clock_scale Date: Mon, 3 Aug 2020 20:33:58 +0100 Message-Id: <20200803193359.12936-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200803193359.12936-1-peter.maydell@linaro.org> References: <20200803193359.12936-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) The nrf51 SoC model wasn't setting the system_clock_scale global.which meant that if guest code used the systick timer in "use the processor clock" mode it would hang because time never advances. Set the global to match the documented CPU clock speed for this SoC. This SoC in fact doesn't have a SysTick timer (which is the only thing currently that cares about the system_clock_scale), because it's a configurable option in the Cortex-M0. However our Cortex-M0 and thus our nrf51 and our micro:bit board do provide a SysTick, so we ought to provide a functional one rather than a broken one. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20200727193458.31250-1-peter.maydell@linaro.org --- hw/arm/nrf51_soc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c index 45e6cc97d70..e15981e019f 100644 --- a/hw/arm/nrf51_soc.c +++ b/hw/arm/nrf51_soc.c @@ -32,6 +32,9 @@ =20 #define BASE_TO_IRQ(base) ((base >> 12) & 0x1F) =20 +/* HCLK (the main CPU clock) on this SoC is always 16MHz */ +#define HCLK_FRQ 16000000 + static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size) { qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n", @@ -65,6 +68,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error= **errp) return; } =20 + system_clock_scale =3D NANOSECONDS_PER_SECOND / HCLK_FRQ; + object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->contain= er), &error_abort); if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { --=20 2.20.1 From nobody Mon May 6 05:59:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1596483576; cv=none; d=zohomail.com; s=zohoarc; b=HbC66citHqz6ya3GG5uR8rC5aoE2ug6sH6tsbSN54/g0w2T5Gdj/iaWZH7e+TPkDUYrm9bk+8sn7i9PaJyuQMx7OLHMMbc84yCxA56/NInrSDYWTXC4mn0HFi75yqJMTL9bWmJLoWeZJeyNzuNZia1gFkn5wSHA7gG8b+m4Le4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596483576; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p3Oj1hHYVSfEnmzR1MqlL9GNka397sl/NrXlR449zEg=; b=hboUhva/4/PR7Lz3EmK1QqgvUamH7/1q821f4xXXdrqQZh/o+U6OgCQcMA3CCYjI6xscN6bLUHFas13d5UjfR062dnh541Yt9pKIAuUfho2Hxvx8uMWTR+2VlfVYyh1tGES98c7fvh45ZxWBYZ3xgsddgftFujHXMsAE9ZCrrCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596483576687862.1735001408382; Mon, 3 Aug 2020 12:39:36 -0700 (PDT) Received: from localhost ([::1]:54462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2gJ5-0007Tu-Hv for importer@patchew.org; Mon, 03 Aug 2020 15:39:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2gE1-0001fg-36 for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:21 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:35803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2gDz-0003au-8i for qemu-devel@nongnu.org; Mon, 03 Aug 2020 15:34:20 -0400 Received: by mail-wr1-x430.google.com with SMTP id f1so34716375wro.2 for ; Mon, 03 Aug 2020 12:34:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r206sm985565wma.6.2020.08.03.12.34.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 12:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=p3Oj1hHYVSfEnmzR1MqlL9GNka397sl/NrXlR449zEg=; b=EBHkjwcZniqt2OC4srTa97XVJ1EeN8RbgN4nAsqUrRhiMaOQM0HEtqDwNsXsg+gyjj hUBCWBygTQJP1JVVawlECAzFpluBf4aW3Zx3uztRxvS5fLSv2RcTWrjEnD3UFCsCttJy AZRTJa4pTy6EbyYJrs4BhuWq+LoQgAzjR6IU4tUhDZIzKQG3b/nNP1bfystH1Sv0loGw 3NSVdowVAFKvVDwRqBDHjMduUvtPwe7+2SV9Ehexvtt+YfRp/BngIobfl6bEaNvDYiWW VHFO4vYgDt7niaVunzjYOGSC9sIKO/yPXt9u+u8xJfvzK2MoOT+Mp7CBElh0sHQfOhBJ AjRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p3Oj1hHYVSfEnmzR1MqlL9GNka397sl/NrXlR449zEg=; b=fD55cCKuvr2OxcmxGHheLcZhYqm3RBNt0oBzVQlwmXXMeWDIJ3+Xtzhe7wTy63lVGx EWGWqcZe0hPm/VkUktVeawMF5wt7SgNWKI9N3aADzGJ56yN+IUUnjyJFkt8b/t1dtOeg dcwqRhK9fuJQuF6+i96FhFi4I/gh3+pOnmMyoKSzKKzARL9lWBCsZYkj3fd0D93IxUgx 17XQBHfFtylVLckkHxeEfr00n9PmCGYys4qWqcsXpHpRskVENQAl1TSjHYEi3i6GIGxm Li30OqLWOORRUzGQ9TEKBAPBoIe6vWq56iigSHRCGkc7ahbZTrK/6/jdnUMsQOIz70HS hYjA== X-Gm-Message-State: AOAM532S1WCvQao+NzmibkU+sp58qigg2D0RYuKTXKhtB13K6uu3eI1w wzi0BZCP1kweL92kto8APw53rb2AJQFvBQ== X-Google-Smtp-Source: ABdhPJy4iJeumKA6Hoe3tZrF2vYF/WxXZNJSHg99q0V3BIPEr8FboBhm9Yoyx0noRqtoOirbjHSBWg== X-Received: by 2002:a5d:544f:: with SMTP id w15mr16428537wrv.208.1596483257125; Mon, 03 Aug 2020 12:34:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 8/8] hw/timer/imx_epit: Avoid assertion when CR.SWR is written Date: Mon, 3 Aug 2020 20:33:59 +0100 Message-Id: <20200803193359.12936-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200803193359.12936-1-peter.maydell@linaro.org> References: <20200803193359.12936-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) The imx_epit device has a software-controllable reset triggered by setting the SWR bit in the CR register. An error in commit cc2722ec83ad9 means that we will end up assert()ing if the guest does this, because the code in imx_epit_write() starts ptimer transactions, and then imx_epit_reset() also starts ptimer transactions, triggering "ptimer_transaction_begin: Assertion `!s->in_transaction' failed". The cleanest way to avoid this double-transaction is to move the start-transaction for the CR write handling down below the check of the SWR bit. Fixes: https://bugs.launchpad.net/qemu/+bug/1880424 Fixes: cc2722ec83ad944505fe Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20200727154550.3409-1-peter.maydell@linaro.org --- hw/timer/imx_epit.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c index baf6338e1a6..ebd58254d15 100644 --- a/hw/timer/imx_epit.c +++ b/hw/timer/imx_epit.c @@ -199,15 +199,22 @@ static void imx_epit_write(void *opaque, hwaddr offse= t, uint64_t value, =20 switch (offset >> 2) { case 0: /* CR */ - ptimer_transaction_begin(s->timer_cmp); - ptimer_transaction_begin(s->timer_reload); =20 oldcr =3D s->cr; s->cr =3D value & 0x03ffffff; if (s->cr & CR_SWR) { /* handle the reset */ imx_epit_reset(DEVICE(s)); - } else { + /* + * TODO: could we 'break' here? following operations appear + * to duplicate the work imx_epit_reset() already did. + */ + } + + ptimer_transaction_begin(s->timer_cmp); + ptimer_transaction_begin(s->timer_reload); + + if (!(s->cr & CR_SWR)) { imx_epit_set_freq(s); } =20 --=20 2.20.1