From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E077C433EF for ; Mon, 31 Jan 2022 19:24:43 +0000 (UTC) Received: from localhost ([::1]:34520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEcI6-0002kB-Cc for qemu-devel@archiver.kernel.org; Mon, 31 Jan 2022 14:24:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEbt4-0007Mz-CJ for qemu-devel@nongnu.org; Mon, 31 Jan 2022 13:58:50 -0500 Received: from [2607:f8b0:4864:20::62b] (port=37752 helo=mail-pl1-x62b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEbt1-0008Ng-MZ for qemu-devel@nongnu.org; Mon, 31 Jan 2022 13:58:50 -0500 Received: by mail-pl1-x62b.google.com with SMTP id j16so13287019plx.4 for ; Mon, 31 Jan 2022 10:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rTPYdCL787Y7m8xp55FStrrlxPw5OHdzRHY0ar9aWWQ=; b=B9m1XfO45DdvHOTGraGlIRCanN4CfBBpguId+CsOSICNBD1+/7jJJh1oq+JDbPgKby Idxi7B64fnwxeqvYzDyvvGOs71hCKJEi34M1lll+MoAdYBt5Maa4bGaCUJmO2FLyzf/D mn1BKtz7bM/5SZC1u4tDDZ9ei+TtPWcAq69Se3ilxY0XEKWSFYLPw6dQclO7KcRjzOao J96vjf3EXLQIIFo2UB1ThJ2zlEQhC+31u0MT523jCMPUIO1IeEsL75sJzR+y9b7skjTq 48xyyrx+s42zJnhBh/2Ic2y84H75oNTt7Qd+HARtuxTqYnVwWc0vzJogxKArp33P/ZzS ip6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rTPYdCL787Y7m8xp55FStrrlxPw5OHdzRHY0ar9aWWQ=; b=PXsgE4Pk2ABq+oG0COkb/GIEonERTB9YzJu66W5zIIw80sDQPDNbY7ys4qiROgRIrQ Jq+KnHkxF7mTgeJjim9dahjlnxxK0XRaej3SWJmhjC2e9fZ6XWUk5bRdeGvmahPSB7KH EHXWomQukd7ZkkJuW6PdFRoA93P0C4Je7EK/fVYywvOSVBDL/TtOoSafJtH522q6zGnF CQ3F3ifuHlIa2cM7orBKXEIfJn3HejJR6yRMWmTUpw0yPHZzPEUJIkNr+9O5+/3HUVRi b8yaqZpLkbiwXAyy81lrrljDJhjhG4neOTuCrcUlYk3berZ/kvRAfXn0W8UUIjKqqxJy nvKA== X-Gm-Message-State: AOAM5323/sB+bhxPMKEt2+UG/Sm9g2VrjlJ72GBcQKKf4a2yGpZ+SCuz PP9KrBbZmtPJs5VjLOS81tPEqXyeWsUjwiUUo5s= X-Google-Smtp-Source: ABdhPJzORGbl3MVmEbtyvUg0kzxgEmn6jvdfulm5FzDhzuw0hI6L6ALY8miU5nZNuwg7ccGW1gR+C2OeEuJQtfDKpMs= X-Received: by 2002:a17:90b:4ad0:: with SMTP id mh16mr34939368pjb.89.1643655525738; Mon, 31 Jan 2022 10:58:45 -0800 (PST) MIME-Version: 1.0 References: <20211102164317.45658-1-david@redhat.com> <20211102164317.45658-3-david@redhat.com> <3f971963-8424-ba36-7723-1d60251c10cd@redhat.com> In-Reply-To: <3f971963-8424-ba36-7723-1d60251c10cd@redhat.com> From: Niek Linnenbank Date: Mon, 31 Jan 2022 19:58:34 +0100 Message-ID: Subject: Re: [PATCH v3 2/3] memory: Make memory_region_is_mapped() succeed when mapped via an alias To: David Hildenbrand Content-Type: multipart/alternative; boundary="000000000000beaa0c05d6e55f43" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=nieklinnenbank@gmail.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , QEMU Developers , Peter Xu , Paolo Bonzini , Igor Mammedov , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000beaa0c05d6e55f43 Content-Type: text/plain; charset="UTF-8" Hi David, On Mon, Jan 31, 2022 at 9:11 AM David Hildenbrand wrote: > On 30.01.22 23:50, Niek Linnenbank wrote: > > Hi David, > > Hi Niek, > > thanks for the report. > > > > > While I realize my response is quite late, I wanted to report this error > > I found when running the acceptance > > tests for the orangepi-pc machine using avocado: > > > > ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado > > --show=app,console run -t machine:orangepi-pc > > tests/avocado/boot_linux_console.py > > ... > > (4/5) > > > tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08: > > -console: U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200) > > \console: DRAM: > > INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout > > reached\nOriginal status: ERROR\n{'name': > > > '4-tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08', > > 'logdir': '/home/fox/avocado/job-results/job-2022-01-30T23.09-af49e... > > (90.64 s) > > (5/5) > > > tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9: > > /console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +0000) > > console: DRAM: > > INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout > > reached\nOriginal status: ERROR\n{'name': > > > '5-tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9', > > 'logdir': '/home/fox/avocado/job-results/job-2022-01-30T23.09-af49... > > (90.64 s) > > RESULTS : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 2 | > > CANCEL 0 > > JOB TIME : 221.25 s > > > > Basically the two tests freeze during the part where the U-Boot > > bootloader needs to detect the amount of memory. We model this in the > > hw/misc/allwinner-h3-dramc.c file. > > And when running the machine manually it shows an assert on > > 'alias->mapped_via_alias >= 0'. When running manually via gdb, I was > > able to collect this backtrace: > > > > $ gdb ./build/qemu-system-arm > > ... > > gdb) run -M orangepi-pc -nographic > > ./Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img > > ... > > U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200) > > DRAM: > > qemu-system-arm: ../softmmu/memory.c:2588: memory_region_del_subregion: > > Assertion `alias->mapped_via_alias >= 0' failed. > > > > Thread 4 "qemu-system-arm" received signal SIGABRT, Aborted. > > [Switching to Thread 0x7ffff5f72700 (LWP 32866)] > > __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 > > 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. > > (gdb) bt > > #0 __GI_raise (sig=sig@entry=6) at > ../sysdeps/unix/sysv/linux/raise.c:50 > > #1 0x00007ffff7535859 in __GI_abort () at abort.c:79 > > #2 0x00007ffff7535729 in __assert_fail_base > > (fmt=0x7ffff76cb588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", > > assertion=0x55555642fd65 "alias->mapped_via_alias >= 0", > > file=0x55555642f8cd "../softmmu/memory.c", line=2588, > > function=) > > at assert.c:92 > > #3 0x00007ffff7546f36 in __GI___assert_fail > > (assertion=0x55555642fd65 "alias->mapped_via_alias >= 0", > > file=0x55555642f8cd "../softmmu/memory.c", line=2588, > > function=0x555556430690 <__PRETTY_FUNCTION__.8> > > "memory_region_del_subregion") at assert.c:101 > > #4 0x0000555555e587e0 in memory_region_del_subregion > > (mr=0x555556f0bc00, subregion=0x7ffff5fa1090) at ../softmmu/memory.c:2588 > > #5 0x0000555555e589f3 in memory_region_readd_subregion > > (mr=0x7ffff5fa1090) at ../softmmu/memory.c:2630 > > #6 0x0000555555e58a5f in memory_region_set_address (mr=0x7ffff5fa1090, > > addr=1090519040) at ../softmmu/memory.c:2642 > > #7 0x0000555555ac352b in allwinner_h3_dramc_map_rows (s=0x7ffff5fa0c50, > > row_bits=16 '\020', bank_bits=2 '\002', page_size=512) at > > ../hw/misc/allwinner-h3-dramc.c:92 > > #8 0x0000555555ac36c2 in allwinner_h3_dramcom_write > > (opaque=0x7ffff5fa0c50, offset=0, val=4396785, size=4) at > > ../hw/misc/allwinner-h3-dramc.c:131 > > #9 0x0000555555e52561 in memory_region_write_accessor > > (mr=0x7ffff5fa11a0, addr=0, value=0x7ffff5f710e8, size=4, shift=0, > > mask=4294967295, attrs=...) at ../softmmu/memory.c:492 > > #10 0x0000555555e527ad in access_with_adjusted_size (addr=0, > > value=0x7ffff5f710e8, size=4, access_size_min=4, access_size_max=4, > > access_fn= > > 0x555555e52467 , mr=0x7ffff5fa11a0, > > attrs=...) at ../softmmu/memory.c:554 > > #11 0x0000555555e55935 in memory_region_dispatch_write > > (mr=0x7ffff5fa11a0, addr=0, data=4396785, op=MO_32, attrs=...) at > > ../softmmu/memory.c:1514 > > #12 0x0000555555f891ae in io_writex (env=0x7ffff5f7ce30, > > iotlbentry=0x7fffec0275f0, mmu_idx=7, val=4396785, addr=29761536, > > retaddr=140734938367479, op=MO_32) at ../accel/tcg/cputlb.c:1420 > > #13 0x0000555555f8ba10 in store_helper (env=0x7ffff5f7ce30, > > addr=29761536, val=4396785, oi=3623, retaddr=140734938367479, op=MO_32) > > at ../accel/tcg/cputlb.c:2355 > > #14 0x0000555555f8bdda in full_le_stl_mmu (env=0x7ffff5f7ce30, > > addr=29761536, val=4396785, oi=3623, retaddr=140734938367479) at > > ../accel/tcg/cputlb.c:2443 > > #15 0x0000555555f8be16 in helper_le_stl_mmu (env=0x7ffff5f7ce30, > > addr=29761536, val=4396785, oi=3623, retaddr=140734938367479) at > > ../accel/tcg/cputlb.c:2449 > > #16 0x00007fff680245f7 in code_gen_buffer () > > #17 0x0000555555f754cb in cpu_tb_exec (cpu=0x7ffff5f730a0, > > itb=0x7fffa802b400, tb_exit=0x7ffff5f7182c) at > ../accel/tcg/cpu-exec.c:357 > > #18 0x0000555555f76366 in cpu_loop_exec_tb (cpu=0x7ffff5f730a0, > > tb=0x7fffa802b400, last_tb=0x7ffff5f71840, tb_exit=0x7ffff5f7182c) at > > ../accel/tcg/cpu-exec.c:842 > > #19 0x0000555555f76720 in cpu_exec (cpu=0x7ffff5f730a0) at > > ../accel/tcg/cpu-exec.c:1001 > > #20 0x0000555555f993dd in tcg_cpus_exec (cpu=0x7ffff5f730a0) at > > ../accel/tcg/tcg-accel-ops.c:67 > > #21 0x0000555555f9976d in mttcg_cpu_thread_fn (arg=0x7ffff5f730a0) at > > ../accel/tcg/tcg-accel-ops-mttcg.c:95 > > #22 0x000055555624bf4d in qemu_thread_start (args=0x5555572b6780) at > > ../util/qemu-thread-posix.c:556 > > #23 0x00007ffff770b609 in start_thread (arg=) at > > pthread_create.c:477 > > #24 0x00007ffff7632293 in clone () at > > ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 > > > > So it seems that the hw/misc/allwinner-h3-dramc.c file is using the call > > memory_region_set_address, where internally we are calling > > memory_region_del_subregion. > > Okay, so we're using memory_region_set_address() on an alias after > marking it as enabled. > > memory_region_readd_subregion() detect if the region is already added > via "mr->container" ... so in the old code, the > > memory_region_del_subregion() > mr->container = container; > memory_region_update_container_subregions(mr); > > I think the issue is that we want to do a "del+add" but we do a > "del+hack", not a proper add. > Okey, yeah that makes sense. > > Would something like the following do the trick (untested)?: > > > diff --git a/softmmu/memory.c b/softmmu/memory.c > index 0d39cf3da6..7a1c8158c5 100644 > --- a/softmmu/memory.c > +++ b/softmmu/memory.c > @@ -2633,8 +2633,7 @@ static void > memory_region_readd_subregion(MemoryRegion *mr) > memory_region_transaction_begin(); > memory_region_ref(mr); > memory_region_del_subregion(container, mr); > - mr->container = container; > - memory_region_update_container_subregions(mr); > + memory_region_add_subregion_common(container, mr->addr, mr); > memory_region_unref(mr); > memory_region_transaction_commit(); > } > Yes, this resolved the assertion problem indeed. I've re-run all acceptance tests for the orangepi-pc machine with this change applied to the current master at 95a6af2a00, and all tests are passing. How do we proceed from here, can this become a new patch maybe? Thanks for your help, Niek > > > -- > Thanks, > > David / dhildenb > > -- Niek Linnenbank --000000000000beaa0c05d6e55f43 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi David,

On Mon, Jan 31, 2022 at 9:11= AM David Hildenbrand <david@redhat.= com> wrote:
On 30.01.22 23:50, Niek Linnenbank wrote:
> Hi David,

Hi Niek,

thanks for the report.

>
> While I realize my response is quite late, I wanted to report this err= or
> I found when running the acceptance
> tests for the orangepi-pc machine using avocado:
>
> ARMBIAN_ARTIFACTS_CACHED=3Dyes AVOCADO_ALLOW_LARGE_STORAGE=3Dyes avoca= do
> --show=3Dapp,console run -t machine:orangepi-pc
> tests/avocado/boot_linux_console.py
> ...
> =C2=A0(4/5)
> tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi= _bionic_20_08:
> -console: U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200) > \console: DRAM:
> INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeo= ut
> reached\nOriginal status: ERROR\n{'name':
> '4-tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_o= rangepi_bionic_20_08',
> 'logdir': '/home/fox/avocado/job-results/job-2022-01-30T23= .09-af49e...
> (90.64 s)
> =C2=A0(5/5)
> tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi= _uboot_netbsd9:
> /console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +0000)
> console: DRAM:
> INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeo= ut
> reached\nOriginal status: ERROR\n{'name':
> '5-tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_o= rangepi_uboot_netbsd9',
> 'logdir': '/home/fox/avocado/job-results/job-2022-01-30T23= .09-af49...
> (90.64 s)
> RESULTS =C2=A0 =C2=A0: PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | I= NTERRUPT 2 |
> CANCEL 0
> JOB TIME =C2=A0 : 221.25 s
>
> Basically the two tests freeze during the part where the U-Boot
> bootloader needs to detect the amount of memory. We model this in the<= br> > hw/misc/allwinner-h3-dramc.c file.
> And when running the machine manually it shows an assert on
> 'alias->mapped_via_alias >=3D 0'. When running manually = via gdb, I was
> able to collect this backtrace:
>
> $ gdb ./build/qemu-system-arm
> ...
> gdb) run -M orangepi-pc -nographic
> ./Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img
> ...
> U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
> DRAM:
> qemu-system-arm: ../softmmu/memory.c:2588: memory_region_del_subregion= :
> Assertion `alias->mapped_via_alias >=3D 0' failed.
>
> Thread 4 "qemu-system-arm" received signal SIGABRT, Aborted.=
> [Switching to Thread 0x7ffff5f72700 (LWP 32866)]
> __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linux/raise.c= :50
> 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
> (gdb) bt
> #0 =C2=A0__GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linu= x/raise.c:50
> #1 =C2=A00x00007ffff7535859 in __GI_abort () at abort.c:79
> #2 =C2=A00x00007ffff7535729 in __assert_fail_base
> =C2=A0 =C2=A0 (fmt=3D0x7ffff76cb588 "%s%s%s:%u: %s%sAssertion `%s= ' failed.\n%n",
> assertion=3D0x55555642fd65 "alias->mapped_via_alias >=3D 0&= quot;,
> file=3D0x55555642f8cd "../softmmu/memory.c", line=3D2588, > function=3D<optimized out>)
> =C2=A0 =C2=A0 at assert.c:92
> #3 =C2=A00x00007ffff7546f36 in __GI___assert_fail
> =C2=A0 =C2=A0 (assertion=3D0x55555642fd65 "alias->mapped_via_a= lias >=3D 0",
> file=3D0x55555642f8cd "../softmmu/memory.c", line=3D2588, > function=3D0x555556430690 <__PRETTY_FUNCTION__.8>
> "memory_region_del_subregion") at assert.c:101
> #4 =C2=A00x0000555555e587e0 in memory_region_del_subregion
> (mr=3D0x555556f0bc00, subregion=3D0x7ffff5fa1090) at ../softmmu/memory= .c:2588
> #5 =C2=A00x0000555555e589f3 in memory_region_readd_subregion
> (mr=3D0x7ffff5fa1090) at ../softmmu/memory.c:2630
> #6 =C2=A00x0000555555e58a5f in memory_region_set_address (mr=3D0x7ffff= 5fa1090,
> addr=3D1090519040) at ../softmmu/memory.c:2642
> #7 =C2=A00x0000555555ac352b in allwinner_h3_dramc_map_rows (s=3D0x7fff= f5fa0c50,
> row_bits=3D16 '\020', bank_bits=3D2 '\002', page_size= =3D512) at
> ../hw/misc/allwinner-h3-dramc.c:92
> #8 =C2=A00x0000555555ac36c2 in allwinner_h3_dramcom_write
> (opaque=3D0x7ffff5fa0c50, offset=3D0, val=3D4396785, size=3D4) at
> ../hw/misc/allwinner-h3-dramc.c:131
> #9 =C2=A00x0000555555e52561 in memory_region_write_accessor
> (mr=3D0x7ffff5fa11a0, addr=3D0, value=3D0x7ffff5f710e8, size=3D4, shif= t=3D0,
> mask=3D4294967295, attrs=3D...) at ../softmmu/memory.c:492
> #10 0x0000555555e527ad in access_with_adjusted_size (addr=3D0,
> value=3D0x7ffff5f710e8, size=3D4, access_size_min=3D4, access_size_max= =3D4,
> access_fn=3D
> =C2=A0 =C2=A0 0x555555e52467 <memory_region_write_accessor>, mr= =3D0x7ffff5fa11a0,
> attrs=3D...) at ../softmmu/memory.c:554
> #11 0x0000555555e55935 in memory_region_dispatch_write
> (mr=3D0x7ffff5fa11a0, addr=3D0, data=3D4396785, op=3DMO_32, attrs=3D..= .) at
> ../softmmu/memory.c:1514
> #12 0x0000555555f891ae in io_writex (env=3D0x7ffff5f7ce30,
> iotlbentry=3D0x7fffec0275f0, mmu_idx=3D7, val=3D4396785, addr=3D297615= 36,
> retaddr=3D140734938367479, op=3DMO_32) at ../accel/tcg/cputlb.c:1420 > #13 0x0000555555f8ba10 in store_helper (env=3D0x7ffff5f7ce30,
> addr=3D29761536, val=3D4396785, oi=3D3623, retaddr=3D140734938367479, = op=3DMO_32)
> at ../accel/tcg/cputlb.c:2355
> #14 0x0000555555f8bdda in full_le_stl_mmu (env=3D0x7ffff5f7ce30,
> addr=3D29761536, val=3D4396785, oi=3D3623, retaddr=3D140734938367479) = at
> ../accel/tcg/cputlb.c:2443
> #15 0x0000555555f8be16 in helper_le_stl_mmu (env=3D0x7ffff5f7ce30,
> addr=3D29761536, val=3D4396785, oi=3D3623, retaddr=3D140734938367479) = at
> ../accel/tcg/cputlb.c:2449
> #16 0x00007fff680245f7 in code_gen_buffer ()
> #17 0x0000555555f754cb in cpu_tb_exec (cpu=3D0x7ffff5f730a0,
> itb=3D0x7fffa802b400, tb_exit=3D0x7ffff5f7182c) at ../accel/tcg/cpu-ex= ec.c:357
> #18 0x0000555555f76366 in cpu_loop_exec_tb (cpu=3D0x7ffff5f730a0,
> tb=3D0x7fffa802b400, last_tb=3D0x7ffff5f71840, tb_exit=3D0x7ffff5f7182= c) at
> ../accel/tcg/cpu-exec.c:842
> #19 0x0000555555f76720 in cpu_exec (cpu=3D0x7ffff5f730a0) at
> ../accel/tcg/cpu-exec.c:1001
> #20 0x0000555555f993dd in tcg_cpus_exec (cpu=3D0x7ffff5f730a0) at
> ../accel/tcg/tcg-accel-ops.c:67
> #21 0x0000555555f9976d in mttcg_cpu_thread_fn (arg=3D0x7ffff5f730a0) a= t
> ../accel/tcg/tcg-accel-ops-mttcg.c:95
> #22 0x000055555624bf4d in qemu_thread_start (args=3D0x5555572b6780) at=
> ../util/qemu-thread-posix.c:556
> #23 0x00007ffff770b609 in start_thread (arg=3D<optimized out>) a= t
> pthread_create.c:477
> #24 0x00007ffff7632293 in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
>
> So it seems that the hw/misc/allwinner-h3-dramc.c file is using the ca= ll
> memory_region_set_address, where internally we are calling
> memory_region_del_subregion.

Okay, so we're using memory_region_set_address() on an alias after
marking it as enabled.

memory_region_readd_subregion() detect if the region is already added
via "mr->container" ... so in the old code, the

memory_region_del_subregion()
mr->container =3D container;
memory_region_update_container_subregions(mr);

I think the issue is that we want to do a "del+add" but we do a "del+hack", not a proper add.

Okey, yeah that makes sense.
=C2=A0

Would something like the following do the trick (untested)?:


diff --git a/softmmu/memory.c b/softmmu/memory.c
index 0d39cf3da6..7a1c8158c5 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2633,8 +2633,7 @@ static void
memory_region_readd_subregion(MemoryRegion *mr)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memory_region_transaction_begin();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memory_region_ref(mr);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memory_region_del_subregion(container, mr= );
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 mr->container =3D container;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 memory_region_update_container_subregions(mr);=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 memory_region_add_subregion_common(container, = mr->addr, mr);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memory_region_unref(mr);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memory_region_transaction_commit();
=C2=A0 =C2=A0 =C2=A0}

Yes, this resolve= d the assertion problem indeed. I've re-run all acceptance tests for th= e orangepi-pc machine with this change applied to
the current mas= ter at 95a6af2a00, and all tests are passing.

How = do we proceed from here, can this become a new patch maybe?
=
Thanks for your help,
Niek


--
Thanks,

David / dhildenb



--
Niek Linnenbank

--000000000000beaa0c05d6e55f43--