* [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq
@ 2024-09-27 8:51 Chao Liu
2024-09-27 8:51 ` [PATCH v2 1/2] xilink_zynq: Add various missing unimplemented devices Chao Liu
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Chao Liu @ 2024-09-27 8:51 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, bin.meng, edgar.iglesias, alistair, Chao Liu
Hi, thank you for your prompt reply, it's a great encouragement to me!
Based on your review suggestions, I have improved the v1 patch.
By using create_unimplemented_device() during the initialization phase,
I added a "znyq.umip" device early on, which covers the 32-bit address space
of GPA. This can better serve as a replacement for the effect of the
ignore_memory_transaction_failures flag.
Since create_unimplemented_device() sets the priority of the
memory region (mr) to -100, normally created devices will override the address
segments corresponding to the unimplemented devices.
Even if our test set is not sufficiently comprehensive, we can create an
unimp_device for the maximum address space allowed by the board. This prevents
the guest system from triggering unexpected exceptions when accessing
unimplemented devices or regions.
Additionally, I still use create_unimplemented_device() for other
unimplemented devices. This makes it easier to debug when these devices
are added later.
Finally, here are my testing steps:
Step 1, Referring to the Xilinx Wiki,
I compiled a Linux kernel binary image for convenience in testing.
You can directly obtain it via:
git clone https://github.com/zevorn/QEMU_CPUFreq_Zynq.git
Step 2, Use the following command to run the QEMU:
./qemu/build/qemu-system-arm -M xilinx-zynq-a9 \
-serial /dev/null \
-serial mon:stdio \
-display none \
-kernel QEMU_CPUFreq_Zynq/Prebuilt_functional/kernel_standard_linux/uImage \
-dtb QEMU_CPUFreq_Zynq/Prebuilt_functional/my_devicetree.dtb \
--initrd QEMU_CPUFreq_Zynq/Prebuilt_functional/umy_ramdisk.image.gz
If there are no issues during execution and it boots successfully
into the terminal, for example:
...
PetaLinux 2016.4 zedboard-zynq7 /dev/ttyPS0
zedboard-zynq7 login:
root
root@zedboard-zynq7:~#
Chao Liu (2):
xilink_zynq: Add various missing unimplemented devices
xilink-zynq-devcfg: Fix up for memory address range size not set
correctly
hw/arm/xilinx_zynq.c | 46 ++++++++++++++++++++++++++++++++++++++-
hw/dma/xlnx-zynq-devcfg.c | 2 +-
2 files changed, 46 insertions(+), 2 deletions(-)
--
2.46.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] xilink_zynq: Add various missing unimplemented devices
2024-09-27 8:51 [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq Chao Liu
@ 2024-09-27 8:51 ` Chao Liu
2024-09-27 8:51 ` [PATCH v2 2/2] xilink-zynq-devcfg: Fix up for memory address range size not set correctly Chao Liu
2024-09-27 12:18 ` [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq Peter Maydell
2 siblings, 0 replies; 7+ messages in thread
From: Chao Liu @ 2024-09-27 8:51 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, bin.meng, edgar.iglesias, alistair, Chao Liu
Add PMU, CAN, GPIO, I2C, and other as unimplemented devices.
Remove a ignore_memory_transaction_failures concurrently.
This allows operating systems such as Linux to run emulations such as xilinx_zynq-7000
Signed-off-by: Chao Liu <chao.liu@yeah.net>
---
hw/arm/xilinx_zynq.c | 46 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 37c234f5ab..535e1b35a2 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -34,6 +34,7 @@
#include "hw/net/cadence_gem.h"
#include "hw/cpu/a9mpcore.h"
#include "hw/qdev-clock.h"
+#include "hw/misc/unimp.h"
#include "sysemu/reset.h"
#include "qom/object.h"
#include "exec/tswap.h"
@@ -232,6 +233,50 @@ static void zynq_init(MachineState *machine)
/* DDR remapped to address zero. */
memory_region_add_subregion(address_space_mem, 0, machine->ram);
+ /* Compatible RAZ/WI behavior for accessing memory */
+ create_unimplemented_device("znyq.unimp", 0, 4 * GiB);
+
+ /* PMU */
+ create_unimplemented_device("pmu.region0", 0xf8891000, 0x1000);
+ create_unimplemented_device("pmu.region1", 0xf8893000, 0x1000);
+
+ /* CAN */
+ create_unimplemented_device("amba.can0", 0xe0008000, 0x1000);
+ create_unimplemented_device("amba.can1", 0xe0009000, 0x1000);
+
+ /* GPIO */
+ create_unimplemented_device("amba.gpio0", 0xe000a000, 0x1000);
+
+ /* I2C */
+ create_unimplemented_device("amba.i2c0", 0xe0004000, 0x1000);
+ create_unimplemented_device("amba.i2c1", 0xe0005000, 0x1000);
+
+ /* Interrupt-Controller */
+ create_unimplemented_device("amba.intc.region0", 0xf8f00100, 0x100);
+ create_unimplemented_device("amba.intc.region1", 0xf8f01000, 0x1000);
+
+ /* Memory-Controller */
+ create_unimplemented_device("amba.mc", 0xf8006000, 0x1000);
+
+ /* SMCC */
+ create_unimplemented_device("amba.smcc", 0xe000e000, 0x1000);
+ create_unimplemented_device("amba.smcc.nand0", 0xe1000000, 0x1000000);
+
+ /* Timer */
+ create_unimplemented_device("amba.global_timer", 0xf8f00200, 0x20);
+ create_unimplemented_device("amba.scutimer", 0xf8f00600, 0x20);
+
+ /* WatchDog */
+ create_unimplemented_device("amba.watchdog0", 0xf8005000, 0x1000);
+
+ /* Other */
+ create_unimplemented_device("amba.efuse", 0xf800d000, 0x20);
+ create_unimplemented_device("amba.etb", 0xf8801000, 0x1000);
+ create_unimplemented_device("amba.tpiu", 0xf8803000, 0x1000);
+ create_unimplemented_device("amba.funnel", 0xf8804000, 0x1000);
+ create_unimplemented_device("amba.ptm.region0", 0xf889c000, 0x1000);
+ create_unimplemented_device("amba.ptm.region1", 0xf889d000, 0x1000);
+
/* 256K of on-chip memory */
memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 * KiB,
&error_fatal);
@@ -394,7 +439,6 @@ static void zynq_machine_class_init(ObjectClass *oc, void *data)
mc->init = zynq_init;
mc->max_cpus = ZYNQ_MAX_CPUS;
mc->no_sdcard = 1;
- mc->ignore_memory_transaction_failures = true;
mc->valid_cpu_types = valid_cpu_types;
mc->default_ram_id = "zynq.ext_ram";
prop = object_class_property_add_str(oc, "boot-mode", NULL,
--
2.46.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] xilink-zynq-devcfg: Fix up for memory address range size not set correctly
2024-09-27 8:51 [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq Chao Liu
2024-09-27 8:51 ` [PATCH v2 1/2] xilink_zynq: Add various missing unimplemented devices Chao Liu
@ 2024-09-27 8:51 ` Chao Liu
2024-09-27 12:18 ` [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq Peter Maydell
2 siblings, 0 replies; 7+ messages in thread
From: Chao Liu @ 2024-09-27 8:51 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, bin.meng, edgar.iglesias, alistair, Chao Liu
Signed-off-by: Chao Liu <chao.liu@yeah.net>
---
hw/dma/xlnx-zynq-devcfg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/dma/xlnx-zynq-devcfg.c b/hw/dma/xlnx-zynq-devcfg.c
index b8544d0731..7170353a62 100644
--- a/hw/dma/xlnx-zynq-devcfg.c
+++ b/hw/dma/xlnx-zynq-devcfg.c
@@ -372,7 +372,7 @@ static void xlnx_zynq_devcfg_init(Object *obj)
s->regs_info, s->regs,
&xlnx_zynq_devcfg_reg_ops,
XLNX_ZYNQ_DEVCFG_ERR_DEBUG,
- XLNX_ZYNQ_DEVCFG_R_MAX);
+ XLNX_ZYNQ_DEVCFG_R_MAX * 4);
memory_region_add_subregion(&s->iomem,
A_CTRL,
®_array->mem);
--
2.46.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq
2024-09-27 8:51 [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq Chao Liu
2024-09-27 8:51 ` [PATCH v2 1/2] xilink_zynq: Add various missing unimplemented devices Chao Liu
2024-09-27 8:51 ` [PATCH v2 2/2] xilink-zynq-devcfg: Fix up for memory address range size not set correctly Chao Liu
@ 2024-09-27 12:18 ` Peter Maydell
2024-09-27 14:03 ` Chao Liu
2 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2024-09-27 12:18 UTC (permalink / raw)
To: Chao Liu; +Cc: qemu-devel, bin.meng, edgar.iglesias, alistair
On Fri, 27 Sept 2024 at 09:52, Chao Liu <chao.liu@yeah.net> wrote:
>
> Hi, thank you for your prompt reply, it's a great encouragement to me!
>
> Based on your review suggestions, I have improved the v1 patch.
>
> By using create_unimplemented_device() during the initialization phase,
> I added a "znyq.umip" device early on, which covers the 32-bit address space
> of GPA. This can better serve as a replacement for the effect of the
> ignore_memory_transaction_failures flag.
>
> Since create_unimplemented_device() sets the priority of the
> memory region (mr) to -100, normally created devices will override the address
> segments corresponding to the unimplemented devices.
>
> Even if our test set is not sufficiently comprehensive, we can create an
> unimp_device for the maximum address space allowed by the board. This prevents
> the guest system from triggering unexpected exceptions when accessing
> unimplemented devices or regions.
What would be the benefit of doing that? If we're going to
say "we'll make accesses to regions without devices not
generate faults", the simplest way to do that is to
leave the ignore_memory_transaction_failures flag set
the way it is.
thanks
-- PMM
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq
2024-09-27 12:18 ` [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq Peter Maydell
@ 2024-09-27 14:03 ` Chao Liu
2024-09-27 14:20 ` Peter Maydell
0 siblings, 1 reply; 7+ messages in thread
From: Chao Liu @ 2024-09-27 14:03 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, bin.meng, edgar.iglesias, alistair
[-- Attachment #1: Type: text/plain, Size: 2808 bytes --]
On 2024/9/27 20:18, Peter Maydell wrote:
> On Fri, 27 Sept 2024 at 09:52, Chao Liu<chao.liu@yeah.net> wrote:
>> Hi, thank you for your prompt reply, it's a great encouragement to me!
>>
>> Based on your review suggestions, I have improved the v1 patch.
>>
>> By using create_unimplemented_device() during the initialization phase,
>> I added a "znyq.umip" device early on, which covers the 32-bit address space
>> of GPA. This can better serve as a replacement for the effect of the
>> ignore_memory_transaction_failures flag.
>>
>> Since create_unimplemented_device() sets the priority of the
>> memory region (mr) to -100, normally created devices will override the address
>> segments corresponding to the unimplemented devices.
>>
>> Even if our test set is not sufficiently comprehensive, we can create an
>> unimp_device for the maximum address space allowed by the board. This prevents
>> the guest system from triggering unexpected exceptions when accessing
>> unimplemented devices or regions.
> What would be the benefit of doing that? If we're going to
> say "we'll make accesses to regions without devices not
> generate faults", the simplest way to do that is to
> leave the ignore_memory_transaction_failures flag set
> the way it is.
>
> thanks
> -- PMM
I noticed that the `ignore_memory_transaction_failures` flag
was introduced in ed860129ac ("boards.h: Define new flag
ignore_memory_transaction_failures")
This approach was wise given the circumstances at the time.
Initially, this flag was added to ensure compatibility with the
RAZ/WI behavior in the ARM legacy board model.
Currently, only the ARM legacy board model uses this flag.
Introducing this flag provides a straightforward way to suppress
memory access exceptions by checking if the flag is enabled after
a CPU memory access failure; however,its primary purpose is to
ensure compatibility.
The purpose was to ensure that the ARM legacy board model behaves
as expected under conditions where thorough testing was not feasible.
Since we can designate unimplemented device memory ranges with
"unimplemented-device," this represents a more standard approach in QEMU
for managing RAZ/WI behavior.
However, this approach requires some effort.
Consequently, I have prioritized the removal of the
ignore_memory_transaction_failures flag on the Xilinx Zynq board
and aim to replace it with a more general solution to enhance design
simplicity and consistency.
If my approach is approved, I am very glad to systematically remove the
ignore_memory_transaction_failures flag from other ARM legacy boards and
ultimately eliminate it from the MachineClass.
This is my first attempt at contributing patches to the QEMU community,
and there is much for me to learn, and thanks for your patience and efforts!
Best regards,
Chao Liu
[-- Attachment #2: Type: text/html, Size: 3357 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq
2024-09-27 14:03 ` Chao Liu
@ 2024-09-27 14:20 ` Peter Maydell
2024-09-27 14:43 ` Chao Liu
0 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2024-09-27 14:20 UTC (permalink / raw)
To: Chao Liu; +Cc: qemu-devel, bin.meng, edgar.iglesias, alistair
On Fri, 27 Sept 2024 at 15:03, Chao Liu <chao.liu@yeah.net> wrote:
> On 2024/9/27 20:18, Peter Maydell wrote:
>> On Fri, 27 Sept 2024 at 09:52, Chao Liu <chao.liu@yeah.net> wrote:
>> Even if our test set is not sufficiently comprehensive, we can create an
>> unimp_device for the maximum address space allowed by the board. This prevents
>> the guest system from triggering unexpected exceptions when accessing
>> unimplemented devices or regions.
>
> What would be the benefit of doing that? If we're going to
> say "we'll make accesses to regions without devices not
> generate faults", the simplest way to do that is to
> leave the ignore_memory_transaction_failures flag set
> the way it is.
> Introducing this flag provides a straightforward way to suppress
> memory access exceptions by checking if the flag is enabled after
> a CPU memory access failure; however,its primary purpose is to
> ensure compatibility.
> Since we can designate unimplemented device memory ranges with
> "unimplemented-device," this represents a more standard approach in QEMU
> for managing RAZ/WI behavior.
I don't think that using a 4GB unimplemented-device is
a "more standard" way to do this. We have a standard way for
the board model to say "we don't know whether there might
be existing guest code out there that relies on being able
to make accesses to addresses where there should be a device
but we haven't modeled it". That way is to set the
ignore_memory_transaction_failures flag.
There are two things we can do:
(1) We can leave the ignore_memory_transaction_failures
flag set. This is safe (no behaviour change) but not the
right (matching the hardware) behaviour. The main reason
to do this is if we don't feel we have enough access to
a range of guest code to test the other approach.
(2) We can clear the flag. This is preferable (it matches the
hardware). But the requirement to do this is that
(a) we must make the best effort we can to be sure we've
put unimplemented-device placeholders for specific
devices we don't yet model (by checking e.g. the
hardware documentation for the SoC and board model,
the device tree, etc)
(b) we do the most wide-ranging testing of guest code that
we can. This checks that we didn't miss anything in (a).
I don't mind which of these we do. What I was asking in my
comments on version one of your patch was for how we were
doing on requirement 2b.
thanks
-- PMM
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re: [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq
2024-09-27 14:20 ` Peter Maydell
@ 2024-09-27 14:43 ` Chao Liu
0 siblings, 0 replies; 7+ messages in thread
From: Chao Liu @ 2024-09-27 14:43 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, bin.meng, edgar.iglesias, alistair
[-- Attachment #1: Type: text/plain, Size: 2704 bytes --]
On 2024/9/27 22:20, Peter Maydell wrote:
> On Fri, 27 Sept 2024 at 15:03, Chao Liu<chao.liu@yeah.net> wrote:
>> On 2024/9/27 20:18, Peter Maydell wrote:
>>> On Fri, 27 Sept 2024 at 09:52, Chao Liu<chao.liu@yeah.net> wrote:
>>> Even if our test set is not sufficiently comprehensive, we can create an
>>> unimp_device for the maximum address space allowed by the board. This prevents
>>> the guest system from triggering unexpected exceptions when accessing
>>> unimplemented devices or regions.
>> What would be the benefit of doing that? If we're going to
>> say "we'll make accesses to regions without devices not
>> generate faults", the simplest way to do that is to
>> leave the ignore_memory_transaction_failures flag set
>> the way it is.
>> Introducing this flag provides a straightforward way to suppress
>> memory access exceptions by checking if the flag is enabled after
>> a CPU memory access failure; however,its primary purpose is to
>> ensure compatibility.
>> Since we can designate unimplemented device memory ranges with
>> "unimplemented-device," this represents a more standard approach in QEMU
>> for managing RAZ/WI behavior.
> I don't think that using a 4GB unimplemented-device is
> a "more standard" way to do this. We have a standard way for
> the board model to say "we don't know whether there might
> be existing guest code out there that relies on being able
> to make accesses to addresses where there should be a device
> but we haven't modeled it". That way is to set the
> ignore_memory_transaction_failures flag.
>
> There are two things we can do:
>
> (1) We can leave the ignore_memory_transaction_failures
> flag set. This is safe (no behaviour change) but not the
> right (matching the hardware) behaviour. The main reason
> to do this is if we don't feel we have enough access to
> a range of guest code to test the other approach.
>
> (2) We can clear the flag. This is preferable (it matches the
> hardware). But the requirement to do this is that
> (a) we must make the best effort we can to be sure we've
> put unimplemented-device placeholders for specific
> devices we don't yet model (by checking e.g. the
> hardware documentation for the SoC and board model,
> the device tree, etc)
> (b) we do the most wide-ranging testing of guest code that
> we can. This checks that we didn't miss anything in (a).
>
> I don't mind which of these we do. What I was asking in my
> comments on version one of your patch was for how we were
> doing on requirement 2b.
>
> thanks
> -- PMM
I understand! I will provide more comprehensive testing methods
and results as soon as possible and will get back to you.
Best regards,
Chao Liu
[-- Attachment #2: Type: text/html, Size: 3659 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-09-27 14:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-27 8:51 [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq Chao Liu
2024-09-27 8:51 ` [PATCH v2 1/2] xilink_zynq: Add various missing unimplemented devices Chao Liu
2024-09-27 8:51 ` [PATCH v2 2/2] xilink-zynq-devcfg: Fix up for memory address range size not set correctly Chao Liu
2024-09-27 12:18 ` [PATCH v2 0/2] Drop ignore_memory_transaction_failures for xilink_zynq Peter Maydell
2024-09-27 14:03 ` Chao Liu
2024-09-27 14:20 ` Peter Maydell
2024-09-27 14:43 ` Chao Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).