From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
Richard Henderson <rth@twiddle.net>,
patches@linaro.org
Subject: Re: [Qemu-devel] [Qemu-arm] [PATCH 4/8] boards.h: Define new flag ignore_memory_transaction_failures
Date: Sat, 5 Aug 2017 03:23:43 +0200 [thread overview]
Message-ID: <20170805012343.GC4859@toto> (raw)
In-Reply-To: <1501867249-1924-5-git-send-email-peter.maydell@linaro.org>
On Fri, Aug 04, 2017 at 06:20:45PM +0100, Peter Maydell wrote:
> Define a new MachineClass field ignore_memory_transaction_failures.
> If this is flag is true then the CPU will ignore memory transaction
> failures which should cause the CPU to take an exception due to an
> access to an unassigned physical address; the transaction will
> instead return zero (for a read) or be ignored (for a write). This
> should be set only by legacy board models which rely on the old
> RAZ/WI behaviour for handling devices that QEMU does not yet model.
> New board models should instead use "unimplemented-device" for all
> memory ranges where the guest will attempt to probe for a device that
> QEMU doesn't implement and a stub device is required.
>
> We need this for ARM boards, where we're about to implement support for
> generating external aborts on memory transaction failures. Too many
> of our legacy board models rely on the RAZ/WI behaviour and we
> would break currently working guests when their "probe for device"
> code provoked an external abort rather than a RAZ.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
> ---
> include/hw/boards.h | 11 +++++++++++
> include/qom/cpu.h | 7 ++++++-
> qom/cpu.c | 7 +++++++
> 3 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 3363dd1..7f044d1 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -131,6 +131,16 @@ typedef struct {
> * size than the target architecture's minimum. (Attempting to create
> * such a CPU will fail.) Note that changing this is a migration
> * compatibility break for the machine.
> + * @ignore_memory_transaction_failures:
> + * If this is flag is true then the CPU will ignore memory transaction
> + * failures which should cause the CPU to take an exception due to an
> + * access to an unassigned physical address; the transaction will instead
> + * return zero (for a read) or be ignored (for a write). This should be
> + * set only by legacy board models which rely on the old RAZ/WI behaviour
> + * for handling devices that QEMU does not yet model. New board models
> + * should instead use "unimplemented-device" for all memory ranges where
> + * the guest will attempt to probe for a device that QEMU doesn't
> + * implement and a stub device is required.
> */
> struct MachineClass {
> /*< private >*/
> @@ -171,6 +181,7 @@ struct MachineClass {
> bool rom_file_has_mr;
> int minimum_page_bits;
> bool has_hotpluggable_cpus;
> + bool ignore_memory_transaction_failures;
> int numa_mem_align_shift;
> void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
> int nb_nodes, ram_addr_t size);
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index fc54d55..8cff86f 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -311,6 +311,9 @@ struct qemu_work_item;
> * @trace_dstate_delayed: Delayed changes to trace_dstate (includes all changes
> * to @trace_dstate).
> * @trace_dstate: Dynamic tracing state of events for this vCPU (bitmask).
> + * @ignore_memory_transaction_failures: Cached copy of the MachineState
> + * flag of the same name: allows the board to suppress calling of the
> + * CPU do_transaction_failed hook function.
> *
> * State of one CPU core or thread.
> */
> @@ -397,6 +400,8 @@ struct CPUState {
> */
> bool throttle_thread_scheduled;
>
> + bool ignore_memory_transaction_failures;
> +
> /* Note that this is accessed at the start of every TB via a negative
> offset from AREG0. Leave this field at the end so as to make the
> (absolute value) offset as small as possible. This reduces code
> @@ -853,7 +858,7 @@ static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr,
> {
> CPUClass *cc = CPU_GET_CLASS(cpu);
>
> - if (cc->do_transaction_failed) {
> + if (!cpu->ignore_memory_transaction_failures && cc->do_transaction_failed) {
> cc->do_transaction_failed(cpu, physaddr, addr, size, access_type,
> mmu_idx, attrs, response, retaddr);
> }
> diff --git a/qom/cpu.c b/qom/cpu.c
> index 4f38db0..d8dcf64 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -29,6 +29,7 @@
> #include "exec/cpu-common.h"
> #include "qemu/error-report.h"
> #include "sysemu/sysemu.h"
> +#include "hw/boards.h"
> #include "hw/qdev-properties.h"
> #include "trace-root.h"
>
> @@ -360,6 +361,12 @@ static void cpu_common_parse_features(const char *typename, char *features,
> static void cpu_common_realizefn(DeviceState *dev, Error **errp)
> {
> CPUState *cpu = CPU(dev);
> + Object *machine = qdev_get_machine();
> + ObjectClass *oc = object_get_class(machine);
> + MachineClass *mc = MACHINE_CLASS(oc);
> +
> + cpu->ignore_memory_transaction_failures =
> + mc->ignore_memory_transaction_failures;
>
> if (dev->hotplugged) {
> cpu_synchronize_post_init(cpu);
> --
> 2.7.4
>
>
next prev parent reply other threads:[~2017-08-05 1:23 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 17:20 [Qemu-devel] [PATCH 0/8] Implement ARM external abort handling Peter Maydell
2017-08-04 17:20 ` [Qemu-devel] [PATCH 1/8] memory.h: Move MemTxResult type to memattrs.h Peter Maydell
2017-08-04 17:47 ` Richard Henderson
2017-08-05 0:59 ` [Qemu-devel] [Qemu-arm] " Edgar E. Iglesias
2017-08-07 23:11 ` Alistair Francis
2017-08-04 17:20 ` [Qemu-devel] [PATCH 2/8] cpu: Define new cpu_transaction_failed() hook Peter Maydell
2017-08-04 18:42 ` Richard Henderson
2017-08-05 1:06 ` [Qemu-devel] [Qemu-arm] " Edgar E. Iglesias
2017-08-05 16:51 ` Peter Maydell
2017-08-05 1:12 ` Edgar E. Iglesias
2017-08-05 17:18 ` Peter Maydell
2017-08-04 17:20 ` [Qemu-devel] [PATCH 3/8] cputlb: Support generating CPU exceptions on memory transaction failures Peter Maydell
2017-08-05 1:15 ` [Qemu-devel] [Qemu-arm] " Edgar E. Iglesias
2017-12-13 16:39 ` Peter Maydell
2017-12-14 9:03 ` Paolo Bonzini
2017-08-04 17:20 ` [Qemu-devel] [PATCH 4/8] boards.h: Define new flag ignore_memory_transaction_failures Peter Maydell
2017-08-04 18:09 ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-08-04 19:23 ` Richard Henderson
2017-08-05 10:13 ` Peter Maydell
2017-08-17 10:25 ` Peter Maydell
2017-08-22 3:45 ` Philippe Mathieu-Daudé
2017-08-22 8:36 ` Peter Maydell
[not found] ` <CAFEAcA_rSqsrfd_qJijtPFRe1qKEA=JiyHE+3J5atAgxAX8NBg@mail.gmail.com>
2017-08-24 20:28 ` Richard Henderson
2017-08-25 12:02 ` Peter Maydell
2017-08-05 10:29 ` Peter Maydell
2017-08-05 1:23 ` Edgar E. Iglesias [this message]
2017-08-04 17:20 ` [Qemu-devel] [PATCH 5/8] hw/arm: Set ignore_memory_transaction_failures for most ARM boards Peter Maydell
2017-08-05 1:24 ` [Qemu-devel] [Qemu-arm] " Edgar E. Iglesias
2017-08-04 17:20 ` [Qemu-devel] [PATCH 6/8] target/arm: Factor out fault delivery code Peter Maydell
2017-08-04 20:10 ` Richard Henderson
2017-08-05 1:40 ` [Qemu-devel] [Qemu-arm] " Edgar E. Iglesias
2017-08-04 17:20 ` [Qemu-devel] [PATCH 7/8] target/arm: Allow deliver_fault() caller to specify EA bit Peter Maydell
2017-08-04 20:15 ` Richard Henderson
2017-08-05 1:45 ` [Qemu-devel] [Qemu-arm] " Edgar E. Iglesias
2017-08-04 17:20 ` [Qemu-devel] [PATCH 8/8] target/arm: Implement new do_transaction_failed hook Peter Maydell
2017-08-04 20:26 ` Richard Henderson
2017-08-05 1:44 ` [Qemu-devel] [Qemu-arm] " Edgar E. Iglesias
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=20170805012343.GC4859@toto \
--to=edgar.iglesias@gmail.com \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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;
as well as URLs for NNTP newsgroup(s).