Message ID | 20240924162359.1390487-6-edgar.iglesias@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | xen/arm: Add Virtio-PCI for dom0less on ARM | expand |
On Tue, 24 Sep 2024, Edgar E. Iglesias wrote: > From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> > > Add a read-const writes-ignored mmio handler. This is useful > to for example register background regions that return a fixed > value instead of raising data aborts. > > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> > --- > xen/arch/arm/include/asm/mmio.h | 2 ++ > xen/arch/arm/io.c | 21 +++++++++++++++++++++ > 2 files changed, 23 insertions(+) > > diff --git a/xen/arch/arm/include/asm/mmio.h b/xen/arch/arm/include/asm/mmio.h > index 7da542cd79..605620a2f4 100644 > --- a/xen/arch/arm/include/asm/mmio.h > +++ b/xen/arch/arm/include/asm/mmio.h > @@ -82,6 +82,8 @@ struct vmmio { > struct mmio_handler *handlers; > }; > > +extern const struct mmio_handler_ops mmio_read_const_writes_ignored; > + > enum io_state try_handle_mmio(struct cpu_user_regs *regs, > mmio_info_t *info); > void register_mmio_bg_handler(struct domain *d, > diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c > index 934a2ad2b9..8ab0435afc 100644 > --- a/xen/arch/arm/io.c > +++ b/xen/arch/arm/io.c > @@ -20,6 +20,27 @@ > > #include "decode.h" > > +/* > + * Reusable mmio handler useful as background while waiting for IOREQ. > + * Register with priv as default read value. Writes ignored. > + */ > +static int bg_read(struct vcpu *v, mmio_info_t *info, register_t *r, void *priv) > +{ > + *r = (uintptr_t) priv; > + return 1; > +} > + > +static int bg_write(struct vcpu *v, mmio_info_t *info, register_t r, void *priv) > +{ > + return 1; > +} > + > +/* Read const value (from priv), writes ignored. */ > +const struct mmio_handler_ops mmio_read_const_writes_ignored = { > + .read = bg_read, > + .write = bg_write, > +}; > + > static enum io_state handle_read(const struct mmio_handler *handler, > struct vcpu *v, > mmio_info_t *info) > -- > 2.43.0 >
diff --git a/xen/arch/arm/include/asm/mmio.h b/xen/arch/arm/include/asm/mmio.h index 7da542cd79..605620a2f4 100644 --- a/xen/arch/arm/include/asm/mmio.h +++ b/xen/arch/arm/include/asm/mmio.h @@ -82,6 +82,8 @@ struct vmmio { struct mmio_handler *handlers; }; +extern const struct mmio_handler_ops mmio_read_const_writes_ignored; + enum io_state try_handle_mmio(struct cpu_user_regs *regs, mmio_info_t *info); void register_mmio_bg_handler(struct domain *d, diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c index 934a2ad2b9..8ab0435afc 100644 --- a/xen/arch/arm/io.c +++ b/xen/arch/arm/io.c @@ -20,6 +20,27 @@ #include "decode.h" +/* + * Reusable mmio handler useful as background while waiting for IOREQ. + * Register with priv as default read value. Writes ignored. + */ +static int bg_read(struct vcpu *v, mmio_info_t *info, register_t *r, void *priv) +{ + *r = (uintptr_t) priv; + return 1; +} + +static int bg_write(struct vcpu *v, mmio_info_t *info, register_t r, void *priv) +{ + return 1; +} + +/* Read const value (from priv), writes ignored. */ +const struct mmio_handler_ops mmio_read_const_writes_ignored = { + .read = bg_read, + .write = bg_write, +}; + static enum io_state handle_read(const struct mmio_handler *handler, struct vcpu *v, mmio_info_t *info)