mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master 1/3] RISC-V: cpu: request stack memory region
Date: Sat, 3 Apr 2021 12:00:56 +0300	[thread overview]
Message-ID: <20210403120056.c797366f354339aca24a2b0f@gmail.com> (raw)
In-Reply-To: <2cd63d9c-903d-3670-6417-65d1fa324410@pengutronix.de>

On Sat, 3 Apr 2021 09:09:15 +0200
Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:

> Hello Antony,
> 
> On 02.04.21 10:13, Antony Pavlov wrote:
> >> This is strange. Could you print get_runtime_offset() at this location?
> >> It should be zero, because relocate_to_current_adr() had previously run,
> >> but it seems it's not for you? I don't see how compiler reordering could have
> >> occurred given that we don't do LTO and relocate_to_current_adr is thus
> >> a compiler barrier.
> 
> [ Naïve me thinking there are any guarantees from GCC for self-modifying code ]
> 
> > +    empty_slot_init(0, 0xffffffff);
> 
> That's tremendously useful. Thanks! I don't quite understand how it works
> though. It registers a "fall-back" device for all of the 32-bit address
> space?

Yes, it registers such device.

To my great surprise riscv-qemu (at least v2.12) generates no "bus error"
exception on access to unattended address.

I have just compared qemu-2.12 riscv behaviour with mips behaviour.
I have disabled empty_slot in mips_malta code:

--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -1014,7 +1014,7 @@ void mips_malta_init(MachineState *machine)
     /* The whole address space decoded by the GT-64120A doesn't generate
        exception when accessing invalid memory. Create an empty slot to
        emulate this feature. */
-    empty_slot_init(0, 0x20000000);
+    //empty_slot_init(0, 0x20000000);
 
     qdev_init_nofail(dev);
 


I have reconfigured qemu malta barebox to use only 16 MB of RAM. 

diff --git a/arch/mips/boards/qemu-malta/lowlevel.S b/arch/mips/boards/qemu-malta/lowlevel.S
index 98821e0426..6cb77b6c3e 100644
--- a/arch/mips/boards/qemu-malta/lowlevel.S
+++ b/arch/mips/boards/qemu-malta/lowlevel.S
@@ -82,4 +82,4 @@ __start:
 	li	t0, GT_LD(0x1bdfffff)
 	sw	t0, GT_PCI0M1HD_OFS(t1)
 
-ENTRY_FUNCTION_END(BOARD_PBL_START, qemu_malta, SZ_256M)
+ENTRY_FUNCTION_END(BOARD_PBL_START, qemu_malta, SZ_16M)
diff --git a/arch/mips/configs/qemu-malta_defconfig b/arch/mips/configs/qemu-malta_defconfig
index b9994f392c..3d33ae4120 100644
--- a/arch/mips/configs/qemu-malta_defconfig
+++ b/arch/mips/configs/qemu-malta_defconfig
@@ -33,7 +33,6 @@ CONFIG_CMD_SHA256SUM=y
 CONFIG_CMD_UNCOMPRESS=y
 CONFIG_CMD_SLEEP=y
 CONFIG_CMD_DHCP=y
-CONFIG_CMD_MIITOOL=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_TFTP=y
 CONFIG_CMD_ECHO_E=y
@@ -59,7 +58,6 @@ CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
-CONFIG_DRIVER_NET_RTL8139=y
 # CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_I2C_GPIO=y
@@ -71,10 +69,8 @@ CONFIG_DRIVER_CFI=y
 CONFIG_CFI_BUFFER_WRITE=y
 CONFIG_VIDEO=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
-CONFIG_DRIVER_VIDEO_BOCHS_PCI=y
+CONFIG_DRIVER_VIDEO_EDID=y
 CONFIG_GPIO_MALTA_FPGA_I2C=y
-CONFIG_PCI=y
-CONFIG_PCI_DEBUG=y
 CONFIG_FS_CRAMFS=y
 CONFIG_FS_TFTP=y
 CONFIG_FS_FAT=y
diff --git a/arch/mips/dts/qemu-malta.dts b/arch/mips/dts/qemu-malta.dts
index 32e473cac0..69d78061f6 100644
--- a/arch/mips/dts/qemu-malta.dts
+++ b/arch/mips/dts/qemu-malta.dts
@@ -16,7 +16,7 @@
 
 	memory@0 {
 		device_type = "memory";
-		reg = <0x00000000 0x10000000>;
+		reg = <0x00000000 0x01000000>;
 	};
 
 	uart0: serial@180003f8 {


It is easy to see that emulated mips CPU generates bus error exception on access to unattended address
at 0xa2000000 (start RAM + 32M):

 
barebox$ qemu-system-mips-malta-no-empty-slot -nodefaults -M malta -m 16 -serial stdio -monitor null -bios barebox-flash-image


barebox 2021.03.0-00137-g8c6a139124-dirty #2 Sat Apr 3 11:38:55 MSK 2021


Board: qemu malta
malta-fpga-i2c-gpio 1f000b00.gpio@1f000b00.of: probed gpiochip-1 with base 0
cfi_flash 1e000000.flash@1e000000.of: found cfi flash at 0xbe000000, size 4 MiB
i2c-gpio i2c0.of: using pins 0 (SDA) and 1 (SCL)
netconsole: registered as netconsole-1
malloc space: 0xa0b50000 -> 0xa0f4ffff (size 4 MiB)
envfs: no envfs (magic mismatch) - envfs never written?

Hit any to stop autoboot:    2
barebox@qemu malta:/ iomem
0x00000000 - 0xffffffff (size 0x00000000) iomem
  0x180003f8 - 0x180003ff (size 0x00000008) 180003f8.serial@180003f8.of
  0x1e000000 - 0x1e3fffff (size 0x00400000) 1e000000.flash@1e000000.of
  0x1f000900 - 0x1f00093f (size 0x00000040) 1f000900.serial@1f000900.of
  0x1f000b00 - 0x1f000b1f (size 0x00000020) 1f000b00.gpio@1f000b00.of
  0xa0000000 - 0xa0ffffff (size 0x01000000) kseg1_ram0
    0xa0b49000 - 0xa0b4ffff (size 0x00007000) stack
    0xa0b50000 - 0xa0f4ffff (size 0x00400000) malloc space
    0xa0f50000 - 0xa0fa655f (size 0x00056560) barebox
    0xa0fa6560 - 0xa0ff2edf (size 0x0004c980) barebox data
    0xa0ffaee0 - 0xa0ffef33 (size 0x00004054) bss
barebox@qemu malta:/ md 0xa2000000

Ooops, bus error on load or store!

$ 0   : 00000000 00000000 00000000 00000001
$ 4   : 00000100 00000001 00000001 00000030
$ 8   : a0fa2198 00000000 ffffffff 00000010
$12   : 00000000 0000005c 0000002f 2f696e69
$16   : a2000000 00000000 a2000000 00000004
$20   : 00000000 a0b4fc30 a0b4fc80 a0b4fc39
$24   : 00000010 a0f60de4                  
$28   : 00000000 a0b4fc20 a0b4fc80 a0f50930
Hi    : 0000000a
Lo    : 00000000
epc   : a0f50930
ra    : a0f50930
Status: 00000002
Cause : 0000041c
Config: 80008482

### ERROR ### Please RESET the board ###








> > There are empty_slot read warnings on master:
> > 
> >     barebox$ qemu-system-riscv32 -nographic -M erizo -bios ./images/barebox-erizo-generic.img -serial stdio -monitor none -trace file=/dev/null 
> >     >get_runtime_offset()=0x00000000
> >     empty_slot: read from 0000000000022caf
> >     empty_slot: read from 0000000000022cae
> >     empty_slot: read from 0000000000022cb0
> >     empty_slot: read from 0000000000022cb1
> >     riscv-timer riscv-timer: running at 24000000 Hz
> >     Switch to console [cs0]
> > 
> >     barebox 2021.03.0-00134-gc4a1684da9-dirty #1 Fri Apr 2 10:33:45 MSK 2021
> > 
> >     Board: generic Erizo SoC board
> >     riscv-timer riscv-timer: running at 24000000 Hz
> >     malloc space: 0x804ffd80 -> 0x805ffd7f (size 1 MiB)
> > 
> >     Hit any to stop autoboot:    1
> >     boot: error 2
> >     barebox:/ 
> > 
> > 
> > There is no empty_slot warning with fef19e17f651^ barebox:
> > 
> >     barebox$ qemu-system-riscv32 -nographic -M erizo -bios ./images/barebox-erizo-generic.img -serial stdio -monitor none -trace file=/dev/null 
> >     >RISC-V system with no 'timebase-frequency' in DTS
> >     Switch to console [cs0]
> > 
> >     barebox 2021.03.0-00122-g6107208573 #1 Fri Apr 2 11:09:16 MSK 2021
> > 
> >     Board: generic Erizo SoC board
> >     RISC-V system with no 'timebase-frequency' in DTS
> >     malloc space: 0x802ffd80 -> 0x803ffd7f (size 1 MiB)
> > 
> >     Hit any to stop autoboot:    0
> >     boot: error 2
> >     barebox:/ 
> 
> Thanks. I identified two issues and CC'd you on a patch fixing them.
> Breaking erizo has been a blessing to sort out this kind of bugs early :D
> 
> Cheers,
> Ahmad
> 
> -- 
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-04-03  9:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24  8:23 Ahmad Fatoum
2021-03-24  8:23 ` [PATCH master 2/3] RISC-V: board-dt-2nd: ensure FDT doesn't overlap with early mem regions Ahmad Fatoum
2021-03-24  8:23 ` [PATCH master 3/3] RISC-V: boot: move stack top to very end of memory Ahmad Fatoum
2021-03-29  7:57 ` [PATCH master 1/3] RISC-V: cpu: request stack memory region Sascha Hauer
2021-04-02  5:56 ` Antony Pavlov
2021-04-02  6:34   ` Ahmad Fatoum
2021-04-02  8:13     ` Antony Pavlov
2021-04-03  7:09       ` Ahmad Fatoum
2021-04-03  9:00         ` Antony Pavlov [this message]
2021-04-04 11:26           ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210403120056.c797366f354339aca24a2b0f@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox