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 X-Spam-Level: X-Spam-Status: No, score=0.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A533C433F5 for ; Fri, 10 Sep 2021 13:23:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5452F60462 for ; Fri, 10 Sep 2021 13:23:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5452F60462 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:39432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOgV7-0008SY-GH for qemu-devel@archiver.kernel.org; Fri, 10 Sep 2021 09:23:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOgTX-0005j3-Ku for qemu-devel@nongnu.org; Fri, 10 Sep 2021 09:21:51 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:39591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOgTV-0007vn-Q6 for qemu-devel@nongnu.org; Fri, 10 Sep 2021 09:21:51 -0400 Received: by mail-qk1-x72d.google.com with SMTP id y144so1869049qkb.6 for ; Fri, 10 Sep 2021 06:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=lH9PA6PRW7H6tMvhGEY2MuydTGodjOlWAKHaJkoqv2g=; b=g2moUGczaFZJTrSHLf4gvi1Qnv7j3jdmgxx1OBwarHRhnDISowLoEVUoHvCpqtt2zP gGB9/nt/KVaiPqvF9BFZ/F8WbSvjEczL8UQ/2jGRl3i9GJqAHxpIWHUT+gfvIRzGOZR6 D2pmYbKrkEw5+KLA0ezm3KlYtd8GQ2Rz54nuv1bNIvqvsv0Vptxuiz9dbAftAC6Wtaf6 L6VPkq3merKwKv7V+bZXSZhno1JJGR6K9w43RO7jmZCEyakrkIeXs17wbKUzdGOgJ4R3 huwpTYmbtnvVcFLUEDhp0WRjHH3sohSwb3r23HewQVRx1MB9ysQtb4WseDAqZ0LEJU6G qNKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=lH9PA6PRW7H6tMvhGEY2MuydTGodjOlWAKHaJkoqv2g=; b=vwHr9b0yItHbWWLUXQF/OxYD6G82WK94uTONWXkbl72dsN7cb8BSdNLd4EpccORi+z bJ9Y8DaofEk1vDmWL54kyUSV+5nRs7c/5kU9NRojCgyH+Ixv1bTRg6GD7UvkWQtMzFNa a9YGcWhgt7rEqOFYg5dO66/WW35LVrEz2pYCjYtj/W2zDODRXU5SpKyqtpUKNQZoTPwh d9dSYN7WgziAyyRQ7D7VXpw6PkTbfVumRwtbd75rFCzJw2fa4ZyZiCOMSvmzh+oYv1m5 LZArDTZ45LWF7DYgIvY6omJ82tRKYGf7oMtJ9wGntN3qlaqzXKMAOXn8qxulSK4FypEC 1UCw== X-Gm-Message-State: AOAM5314d2IykewTGR6wYUSLvh+wDu5dKNuQjtWV6+rfUmLx9uebpJlK 5uxBfzTMAQA0I6VTonN4mDbg0vZS1IPEIinxhah25XzkywsQ6Q== X-Google-Smtp-Source: ABdhPJyvTcSLnC3DAViEut58VHAj6hSS6Fo+vigd7xHtsZvwTE8zZaVVlyhTd1CVCgjpFwtof8nd1QF+/9TPy3fNPjg= X-Received: by 2002:a37:9e55:: with SMTP id h82mr7444784qke.42.1631280108625; Fri, 10 Sep 2021 06:21:48 -0700 (PDT) MIME-Version: 1.0 From: Hinko Kocevar Date: Fri, 10 Sep 2021 15:21:37 +0200 Message-ID: Subject: Adding IO memory region to mipssim To: qemu-devel@nongnu.org Content-Type: multipart/alternative; boundary="00000000000067612805cba3ff17" Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=hinkocevar@gmail.com; helo=mail-qk1-x72d.google.com 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000067612805cba3ff17 Content-Type: text/plain; charset="UTF-8" I'm trying to add an I/O memory region to mipssim machine to emulate a MMIO region used by the u-boot loaded as BIOS image. I can confirm that the machine starts and loads the BIOS, starts execution but hangs due to unhandled IO access as described below. The region should be at 0xB8810000, of size 0x10000. I've added these lines of code to mispsim.c mips_mipssim_init(): my_state *s = g_malloc0(sizeof(my_state)); memory_region_init_io(&s->mmio, NULL, &my_ops, s, "mips_mipssim.foo", 0x10000); memory_region_add_subregion(address_space_mem, 0xB8810000LL, &s->mmio); All goes well, the machine starts, and I can see the newly added region in qemu monitor info mtree output like so: 00000000b8810000-00000000b881ffff (prio 0, i/o): mips_mipssim.foo With some tracing enabled I see this error: Invalid access at addr 0x18810104, size 4, region '(null)', reason: rejected I know the u-boot is making request to 0xB8810104 and not 0x18810104. I also can see 0xB8810104 address being handed to io_writex(), but mr_offset becomes 0x18810104 here: mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; What is going on? FWIW, I can place my emulated memory region at 0x18810104, but would like to understand the behavior above. Thanks! //hinko --00000000000067612805cba3ff17 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'm trying to add an I/O memory region to mipssim mach= ine to emulate a MMIO region used by the u-boot loaded as BIOS image. I can= confirm that the machine starts and loads the BIOS, starts execution but h= angs due to unhandled IO access as described below.

The region= should be at=C2=A00xB8810000, of size 0x10000.

I&= #39;ve added these lines of code to mispsim.c=C2=A0mips_mipssim_init():

=C2=A0 =C2=A0 my_state *s =3D g_malloc0(sizeof(my_sta= te));
=C2=A0 =C2=A0 memory_region_init_io(&s->mmio, NULL, &my= _ops, s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0"mips_mipssim.foo", 0x10000);
=C2= =A0 =C2=A0 memory_region_add_subregion(address_space_mem, 0xB8810000LL, &am= p;s->mmio);

All goes well, the machine starts, an= d I can see the newly added region in qemu monitor info mtree output like s= o:

=C2=A0 =C2=A0 00000000b8810000-00000000b881ffff= (prio 0, i/o): mips_mipssim.foo

With some tra= cing enabled I see this error:

=C2=A0I= nvalid access at addr 0x18810104, size 4, region '(null)', reason: = rejected

I know the u-boot is making request t= o 0xB8810104 and not 0x18810104. I also can see 0xB8810104 address being ha= nded to=C2=A0io_writex(), but mr_offset becomes 0x18810104 here:
=
=C2=A0=C2=A0mr_offset =3D (iotlbentry->addr & TARGET_= PAGE_MASK) + addr;

What is going on?
FWIW, I can place my emulated memory region at 0x18810104, but = would like to understand the behavior above.

Thank= s!
//hinko

--00000000000067612805cba3ff17--