From nobody Mon May 6 10:55:00 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 1498728655697327.64312424167167; Thu, 29 Jun 2017 02:30:55 -0700 (PDT) Received: from localhost ([::1]:37967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQVmo-0003BH-7v for importer@patchew.org; Thu, 29 Jun 2017 05:30:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQVlQ-0002Aa-8x for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQVlM-0001XO-D5 for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:28 -0400 Received: from mel.act-europe.fr ([194.98.77.210]:43360 helo=smtp.eu.adacore.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQVlM-0001Wp-6P for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:24 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id BAB9C81372; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kr3CEaS4BEZt; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) Received: from wifi-guest-252.act-europe.fr (wifi-guest-252.act-europe.fr [10.10.126.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id A169981443; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at eu.adacore.com From: KONRAD Frederic To: qemu-devel@nongnu.org Date: Thu, 29 Jun 2017 11:28:51 +0200 Message-Id: <1498728533-23160-2-git-send-email-frederic.konrad@adacore.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1498728533-23160-1-git-send-email-frederic.konrad@adacore.com> References: <1498728533-23160-1-git-send-email-frederic.konrad@adacore.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 194.98.77.210 Subject: [Qemu-devel] [PATCH v1 1/3] add memory_region_get_offset_within_address_space 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: peter.maydell@linaro.org, frederic.konrad@adacore.com, alistair@alistair23.me, alex.bennee@linaro.org, pbonzini@redhat.com 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" This is helpful in the next patch to know if a rom is pointed by an alias. Signed-off-by: KONRAD Frederic --- include/exec/memory.h | 10 ++++++++++ memory.c | 22 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 8503685..e342412 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1270,6 +1270,16 @@ void memory_region_set_size(MemoryRegion *mr, uint64= _t size); void memory_region_set_alias_offset(MemoryRegion *mr, hwaddr offset); =20 +/* + * memory_region_get_offset_within_address_space: get the offset of a regi= on + * + * Returns the offset of a region within its address space. @mr must be ma= pped + * to an #AddressSpace. + * + * @mr: the #MemoryRegion to check. + */ +hwaddr memory_region_get_offset_within_address_space(MemoryRegion *mr); + /** * memory_region_present: checks if an address relative to a @container * translates into #MemoryRegion within @container diff --git a/memory.c b/memory.c index 1044bba..2b7439b 100644 --- a/memory.c +++ b/memory.c @@ -598,11 +598,18 @@ static MemTxResult access_with_adjusted_size(hwaddr a= ddr, return r; } =20 -static AddressSpace *memory_region_to_address_space(MemoryRegion *mr) +static AddressSpace *memory_region_to_address_space(MemoryRegion *mr, + hwaddr *offset) { AddressSpace *as; =20 + if (offset) { + *offset =3D 0; + } while (mr->container) { + if (offset) { + *offset +=3D mr->addr; + } mr =3D mr->container; } QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { @@ -613,6 +620,17 @@ static AddressSpace *memory_region_to_address_space(Me= moryRegion *mr) return NULL; } =20 +hwaddr memory_region_get_offset_within_address_space(MemoryRegion *mr) +{ + hwaddr offset; + AddressSpace *as; + + as =3D memory_region_to_address_space(mr, &offset); + assert(as); + + return offset; +} + /* Render a memory region into the global view. Ranges in @view obscure * ranges in @mr. */ @@ -2251,7 +2269,7 @@ static MemoryRegionSection memory_region_find_rcu(Mem= oryRegion *mr, addr +=3D root->addr; } =20 - as =3D memory_region_to_address_space(root); + as =3D memory_region_to_address_space(root, NULL); if (!as) { return ret; } --=20 1.8.3.1 From nobody Mon May 6 10:55:00 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 1498728920395565.6966946076406; Thu, 29 Jun 2017 02:35:20 -0700 (PDT) Received: from localhost ([::1]:37983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQVr3-0006Zu-Ta for importer@patchew.org; Thu, 29 Jun 2017 05:35:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQVlQ-0002Ac-9d for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQVlM-0001Xh-MT for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:28 -0400 Received: from mel.act-europe.fr ([194.98.77.210]:43365 helo=smtp.eu.adacore.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQVlM-0001Wq-Fq for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:24 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id C55C681443; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GX42rPfiKgSr; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) Received: from wifi-guest-252.act-europe.fr (wifi-guest-252.act-europe.fr [10.10.126.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id AB61B81463; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at eu.adacore.com From: KONRAD Frederic To: qemu-devel@nongnu.org Date: Thu, 29 Jun 2017 11:28:52 +0200 Message-Id: <1498728533-23160-3-git-send-email-frederic.konrad@adacore.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1498728533-23160-1-git-send-email-frederic.konrad@adacore.com> References: <1498728533-23160-1-git-send-email-frederic.konrad@adacore.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 194.98.77.210 Subject: [Qemu-devel] [PATCH v1 2/3] arm: fix the armv7m reset state 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: peter.maydell@linaro.org, frederic.konrad@adacore.com, alistair@alistair23.me, alex.bennee@linaro.org, pbonzini@redhat.com 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" This fixes an odd bug when a ROM is present somewhere and an alias @0x00000= 000 is pointing to the ROM. The "if (rom)" test fails and we don't get a valid = reset state. QEMU later crashes with an exception because the ARMv7-M starts with= the ARM instruction set. (eg: PC & 0x01 is 0). This patch uses memory_region_get_offset_within_address_space introduced be= fore to check if an alias doesn't point to a flash somewhere. Signed-off-by: KONRAD Frederic --- target/arm/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 28a9141..b8afd97 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -201,6 +201,20 @@ static void arm_cpu_reset(CPUState *s) =20 /* Load the initial SP and PC from the vector table at address 0 */ rom =3D rom_ptr(0); + + if (!rom) { + /* Sometimes address 0x00000000 is an alias to a flash which + * actually have a ROM. + */ + MemoryRegionSection section; + hwaddr offset =3D 0; + + section =3D memory_region_find(s->as->root, 0, 8); + offset =3D memory_region_get_offset_within_address_space(secti= on.mr); + memory_region_unref(section.mr); + rom =3D rom_ptr(offset); + } + if (rom) { /* Address zero is covered by ROM which hasn't yet been * copied into physical memory. --=20 1.8.3.1 From nobody Mon May 6 10:55:00 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 1498728659276789.3790469916102; Thu, 29 Jun 2017 02:30:59 -0700 (PDT) Received: from localhost ([::1]:37968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQVmp-0003Bu-UC for importer@patchew.org; Thu, 29 Jun 2017 05:30:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQVlS-0002C8-Fx for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQVlM-0001Xc-LP for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:30 -0400 Received: from mel.act-europe.fr ([194.98.77.210]:43371 helo=smtp.eu.adacore.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQVlM-0001Ws-Fl for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:29:24 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id D0BCA81463; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wx_C5DVrTXvN; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) Received: from wifi-guest-252.act-europe.fr (wifi-guest-252.act-europe.fr [10.10.126.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id B528F8147B; Thu, 29 Jun 2017 11:29:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at eu.adacore.com From: KONRAD Frederic To: qemu-devel@nongnu.org Date: Thu, 29 Jun 2017 11:28:53 +0200 Message-Id: <1498728533-23160-4-git-send-email-frederic.konrad@adacore.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1498728533-23160-1-git-send-email-frederic.konrad@adacore.com> References: <1498728533-23160-1-git-send-email-frederic.konrad@adacore.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 194.98.77.210 Subject: [Qemu-devel] [PATCH v1 3/3] armv7m_systick: abort instead of locking on a bad rate 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: peter.maydell@linaro.org, frederic.konrad@adacore.com, alistair@alistair23.me, alex.bennee@linaro.org, pbonzini@redhat.com 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" This helps the board developer by asserting that system_clock_rate is not null. Using systick with a zero rate will lead to a deadlock so better show= ing the error. Signed-off-by: KONRAD Frederic --- hw/timer/armv7m_systick.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/timer/armv7m_systick.c b/hw/timer/armv7m_systick.c index df8d280..745efb7 100644 --- a/hw/timer/armv7m_systick.c +++ b/hw/timer/armv7m_systick.c @@ -54,6 +54,9 @@ static void systick_reload(SysTickState *s, int reset) s->tick =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); } s->tick +=3D (s->reload + 1) * systick_scale(s); + + /* system_clock_scale =3D 0 leads to a nasty deadlock, better aborting= */ + assert(systick_scale(s)); timer_mod(s->timer, s->tick); } =20 --=20 1.8.3.1