From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1j6X3V-0006Ow-Mn for mharc-qemu-riscv@gnu.org; Tue, 25 Feb 2020 05:03:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58531) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6X3O-0006GI-Gv for qemu-riscv@nongnu.org; Tue, 25 Feb 2020 05:03:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6X3I-0003fz-9o for qemu-riscv@nongnu.org; Tue, 25 Feb 2020 05:03:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25403 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6X3I-0003fR-52 for qemu-riscv@nongnu.org; Tue, 25 Feb 2020 05:02:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582624975; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DBpD5HELVrnT83p7rH4Td+NVu0K9yUaZ4qXIwkLmVJ0=; b=Ko/PEmNEY8DbqKUKAW6nNy2F+Yv1tJrfSX/+yvcNQiQt3OnsBaOpHOPJdADwqF0v9o9ZFf c1LkMu2TLIOmvA9qBDe+V0FpQfAbsfjR6i9Utcu8UEfWBdQf9ErbiakicXPrFQa88IQs4b an1q+JT8TVlK7L/M2VC7tSfhu+kSafA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-1vMS1vDXOvC0Sjkos_Oxbw-1; Tue, 25 Feb 2020 05:02:54 -0500 X-MC-Unique: 1vMS1vDXOvC0Sjkos_Oxbw-1 Received: by mail-wr1-f70.google.com with SMTP id h4so1829349wrp.13 for ; Tue, 25 Feb 2020 02:02:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=X74lUNhApL5VU/X3sG8KsCy0ws8LJAAil4qPz+6k63c=; b=XGJRi1DlHmpSiq3tiffNgeC8LGjOcjkigV0fGch2w3/B+tkt6RyP388kMt7AlD58Dq kUKGl8ZI1M4Eyw0MWfZ/SalBkON3g9qw0phbMyQz7bNtAClcSkzvVwAf/C3+QYHvHobc ffZfbf8J3L7W7Z/5MtSBaWHR6aA8/rel0IUnXXHwGdaufxfjb/kxn6NfcV37PIeNHHUf 5TbpIpZuu1/bGo15Y91FBI0DDF4W6HBSiv4eEObtVkFMbXGHgZTfuAz0vnGMBP8iw73A W0WBCDofza95mNaW3TQc+puElmlV628gjc0JlVQu2TYdI+ZPnaxzlk9ZsCy7OuvvKHy1 PDuA== X-Gm-Message-State: APjAAAXWQV4J+CAA7sIGPHc/81RkT6tIx1YG1fGBmFO65DU2CpelwDI6 cQpUz9i6JD7DQMM7NJFMAawLh7psGxzwE6vFf89hdaQ/3oPUUYqBalsBbpMuWGk3uKJe0g9i3dk N+romEGiZpInJAIc= X-Received: by 2002:a5d:4651:: with SMTP id j17mr73329782wrs.237.1582624972826; Tue, 25 Feb 2020 02:02:52 -0800 (PST) X-Google-Smtp-Source: APXvYqy1NBJBSeZ455pTytE+aGLajrBMkKGWcjtJGJOjMO9lQdQyUHNYKx2WEFyFUVfKWFatex+6bA== X-Received: by 2002:a5d:4651:: with SMTP id j17mr73329702wrs.237.1582624972386; Tue, 25 Feb 2020 02:02:52 -0800 (PST) Received: from [192.168.1.35] (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id q12sm7900812wrg.71.2020.02.25.02.02.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Feb 2020 02:02:51 -0800 (PST) Subject: Re: [PATCH v2 05/32] hw/arm: Use memory_region_init_rom() with read-only regions To: Alistair Francis Cc: Peter Maydell , Paolo Bonzini , "qemu-devel@nongnu.org Developers" , Sagar Karandikar , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , KONRAD Frederic , Alistair Francis , "Edgar E. Iglesias" , Max Reitz , Qemu-block , Magnus Damm , =?UTF-8?Q?Herv=c3=a9_Poussineau?= , Joel Stanley , Palmer Dabbelt , Aleksandar Rikalo , Richard Henderson , Artyom Tarasenko , Eduardo Habkost , Alistair Francis , Fabien Chouteau , qemu-arm , Peter Chubb , =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , Subbaraya Sundeep , David Gibson , Kevin Wolf , "open list:RISC-V" , Igor Mitsyanko , Laurent Vivier , Jean-Christophe Dubois , Michael Walle , "open list:New World" , Aleksandar Markovic , Bastian Koppelmann , Aurelien Jarno References: <20200224204828.23167-1-philmd@redhat.com> <20200224204828.23167-6-philmd@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: <62f0a8f5-82ff-e543-964a-a8759169e01f@redhat.com> Date: Tue, 25 Feb 2020 11:02:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Feb 2020 10:03:08 -0000 On 2/24/20 10:20 PM, Alistair Francis wrote: > On Mon, Feb 24, 2020 at 12:51 PM Philippe Mathieu-Daud=C3=A9 > wrote: >> >> This commit was produced with the Coccinelle script >> scripts/coccinelle/memory-region-housekeeping.cocci. >> >> Signed-off-by: Philippe Mathieu-Daud=C3=A9 >=20 > This looks good for the ROM regions, for the flash regions this > doesn't change the current functionality but I'm not sure it's any > clearer. Less code makes easier review. These regions behave as ROM on the bus, any write to the address space=20 is illegal (they are programmable via I/O registers in another address=20 space). >=20 > Either way though: >=20 > Reviewed-by: Alistair Francis Thanks, do you want me to improve the commit description? >=20 > Alistair >=20 >> --- >> hw/arm/exynos4210.c | 3 +-- >> hw/arm/mainstone.c | 3 +-- >> hw/arm/omap_sx1.c | 6 ++---- >> hw/arm/palm.c | 3 +-- >> hw/arm/spitz.c | 3 +-- >> hw/arm/stellaris.c | 3 +-- >> hw/arm/tosa.c | 3 +-- >> 7 files changed, 8 insertions(+), 16 deletions(-) >> >> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c >> index 59a27bdd68..3af6502a5e 100644 >> --- a/hw/arm/exynos4210.c >> +++ b/hw/arm/exynos4210.c >> @@ -311,9 +311,8 @@ static void exynos4210_realize(DeviceState *socdev, = Error **errp) >> &s->chipid_mem); >> >> /* Internal ROM */ >> - memory_region_init_ram(&s->irom_mem, NULL, "exynos4210.irom", >> + memory_region_init_rom(&s->irom_mem, NULL, "exynos4210.irom", >> EXYNOS4210_IROM_SIZE, &error_fatal); >> - memory_region_set_readonly(&s->irom_mem, true); >> memory_region_add_subregion(system_mem, EXYNOS4210_IROM_BASE_ADDR, >> &s->irom_mem); >> /* mirror of iROM */ >> diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c >> index 6e64dfab50..05a806b422 100644 >> --- a/hw/arm/mainstone.c >> +++ b/hw/arm/mainstone.c >> @@ -125,9 +125,8 @@ static void mainstone_common_init(MemoryRegion *addr= ess_space_mem, >> /* Setup CPU & memory */ >> mpu =3D pxa270_init(address_space_mem, mainstone_binfo.ram_size, >> machine->cpu_type); >> - memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM, >> + memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM, >> &error_fatal); >> - memory_region_set_readonly(rom, true); >> memory_region_add_subregion(address_space_mem, 0, rom); >> >> #ifdef TARGET_WORDS_BIGENDIAN >> diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c >> index be245714db..6c3fd1b271 100644 >> --- a/hw/arm/omap_sx1.c >> +++ b/hw/arm/omap_sx1.c >> @@ -126,9 +126,8 @@ static void sx1_init(MachineState *machine, const in= t version) >> mpu =3D omap310_mpu_init(dram, machine->cpu_type); >> >> /* External Flash (EMIFS) */ >> - memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size= , >> + memory_region_init_rom(flash, NULL, "omap_sx1.flash0-0", flash_size= , >> &error_fatal); >> - memory_region_set_readonly(flash, true); >> memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash); >> >> memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, >> @@ -168,9 +167,8 @@ static void sx1_init(MachineState *machine, const in= t version) >> if ((version =3D=3D 1) && >> (dinfo =3D drive_get(IF_PFLASH, 0, fl_idx)) !=3D NULL) { >> MemoryRegion *flash_1 =3D g_new(MemoryRegion, 1); >> - memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0", >> + memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0", >> flash1_size, &error_fatal); >> - memory_region_set_readonly(flash_1, true); >> memory_region_add_subregion(address_space, OMAP_CS1_BASE, flas= h_1); >> >> memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, >> diff --git a/hw/arm/palm.c b/hw/arm/palm.c >> index 72eca8cc55..265d5891a6 100644 >> --- a/hw/arm/palm.c >> +++ b/hw/arm/palm.c >> @@ -206,9 +206,8 @@ static void palmte_init(MachineState *machine) >> mpu =3D omap310_mpu_init(dram, machine->cpu_type); >> >> /* External Flash (EMIFS) */ >> - memory_region_init_ram(flash, NULL, "palmte.flash", flash_size, >> + memory_region_init_rom(flash, NULL, "palmte.flash", flash_size, >> &error_fatal); >> - memory_region_set_readonly(flash, true); >> memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE, flas= h); >> >> memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "palmte-= cs0", >> diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c >> index e001088103..1d27399721 100644 >> --- a/hw/arm/spitz.c >> +++ b/hw/arm/spitz.c >> @@ -924,8 +924,7 @@ static void spitz_common_init(MachineState *machine, >> >> sl_flash_register(mpu, (model =3D=3D spitz) ? FLASH_128M : FLASH_1= 024M); >> >> - memory_region_init_ram(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fa= tal); >> - memory_region_set_readonly(rom, true); >> + memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fa= tal); >> memory_region_add_subregion(address_space_mem, 0, rom); >> >> /* Setup peripherals */ >> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c >> index 221a78674e..d136ba1a92 100644 >> --- a/hw/arm/stellaris.c >> +++ b/hw/arm/stellaris.c >> @@ -1300,9 +1300,8 @@ static void stellaris_init(MachineState *ms, stell= aris_board_info *board) >> sram_size =3D ((board->dc0 >> 18) + 1) * 1024; >> >> /* Flash programming is done via the SCU, so pretend it is ROM. *= / >> - memory_region_init_ram(flash, NULL, "stellaris.flash", flash_size, >> + memory_region_init_rom(flash, NULL, "stellaris.flash", flash_size, >> &error_fatal); >> - memory_region_set_readonly(flash, true); >> memory_region_add_subregion(system_memory, 0, flash); >> >> memory_region_init_ram(sram, NULL, "stellaris.sram", sram_size, >> diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c >> index 4d95a1f3e2..5dee2d76c6 100644 >> --- a/hw/arm/tosa.c >> +++ b/hw/arm/tosa.c >> @@ -226,8 +226,7 @@ static void tosa_init(MachineState *machine) >> >> mpu =3D pxa255_init(address_space_mem, tosa_binfo.ram_size); >> >> - memory_region_init_ram(rom, NULL, "tosa.rom", TOSA_ROM, &error_fata= l); >> - memory_region_set_readonly(rom, true); >> + memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fata= l); >> memory_region_add_subregion(address_space_mem, 0, rom); >> >> tmio =3D tc6393xb_init(address_space_mem, 0x10000000, >> -- >> 2.21.1 >> >> >=20