xen/arm: Inject an exception to the guest rather than crashing it
v2 cover xen/arm: Inject an exception to the guest rather than crashing it
Hi all,
This small series replaces all call to domain_crash_synchronous by injecting an exception to the guest.
This will result to a nicer trace from the guest (no need to manually walk the stack) and give a chance to the guest to give a bit more information on what it was doing.
Cheers,
Julien Grall (3):
xen/arm: io: Distinguish unhandled IO from aborted one xen/arm: Don't crash domain on bad MMIO emulation xen/arm: Don't crash the domain on invalid HVC immediate
xen/arch/arm/io.c | 32 ++++++++++++++++++-------------- xen/arch/arm/traps.c | 31 +++++++++++++++++++++++-------- xen/arch/arm/vgic-v2.c | 2 -- xen/arch/arm/vgic-v3-its.c | 3 --- xen/arch/arm/vgic-v3.c | 8 -------- xen/arch/arm/vpl011.c | 2 -- xen/include/asm-arm/mmio.h | 13 ++++++++++--- 7 files changed, 51 insertions(+), 40 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/3 xen/arm: io: Distinguish unhandled IO from aborted one
Currently, Xen is considering that an IO could either be handled or unhandled. When unhandled, the stage-2 abort function will try another way to resolve the abort.
However, the MMIO emulation may return unhandled when the address belongs to an emulated range but was not correct. In that case, Xen should avoid to try another way and directly inject a guest data abort.
Introduce a tri-state return to distinguish the following state:
* IO_ABORT: The IO was handled but resulted in an abort
* IO_HANDLED: The IO was handled
* IO_UNHANDLED: The IO was unhandled
For now, it is considered that an IO belonging to an emulated range could either be handled or inject an abort. This could be revisit in the future if overlapped region exist (or we want to try another way to resolve the abort).
---
Changes in v2:
- Always return IO_ABORT when the check failed because we know it was targeted emulated IO.
- Fix typoes
--- xen/arch/arm/io.c | 32 ++++++++++++++++++-------------- xen/arch/arm/traps.c | 18 +++++++++++++++--- xen/include/asm-arm/mmio.h | 13 ++++++++++--- 3 files changed, 43 insertions(+), 20 deletions(-)
xen/arch/arm/io.c +18 -14
@@ -26,8 +26,9 @@#include "decode.h" -static int handle_read (const struct mmio_handler *handler,struct vcpu *v, -mmio_info_t *info) +static enum io_state handle_read (const struct mmio_handler *handler, +struct vcpu *v, +mmio_info_t *info) {const struct hsr_dabt dabt = info->dabt;struct cpu_user_regs *regs =guest_cpu_user_regs ();
@@ -40,7 +41,7 @@ static int handle_read(const struct mmio_handler *handler, struct vcpu *v,uint8_t size = (1 << dabt.size) *8 ;if ( !handler->ops->read (v, info, &r, handler->priv) ) -return 0 ; +return IO_ABORT ;/* * Sign extend if required.
@@ -60,17 +61,20 @@ static int handle_read(const struct mmio_handler *handler, struct vcpu *v,set_user_reg (regs, dabt.reg, r); -return 1 ; +return IO_HANDLED ; } -static int handle_write (const struct mmio_handler *handler,struct vcpu *v, -mmio_info_t *info) +static enum io_state handle_write (const struct mmio_handler *handler, +struct vcpu *v, +mmio_info_t *info) {const struct hsr_dabt dabt = info->dabt;struct cpu_user_regs *regs =guest_cpu_user_regs (); +int ret; -return handler->ops->write (v, info,get_user_reg (regs, dabt.reg), - handler->priv); + ret = handler->ops->write (v, info,get_user_reg (regs, dabt.reg), + handler->priv); +return ( ret ) ?IO_HANDLED :IO_ABORT ; }/* This function assumes that mmio regions are not overlapped */
@@ -103,9 +107,9 @@ static const struct mmio_handler *find_mmio_handler(struct domain *d,return handler; } -int try_handle_mmio (struct cpu_user_regs *regs, -const union hsr hsr, -paddr_t gpa) +enum io_state try_handle_mmio (struct cpu_user_regs *regs, +const union hsr hsr, +paddr_t gpa) {struct vcpu *v = current;const struct mmio_handler *handler =NULL ;
@@ -119,11 +123,11 @@ int try_handle_mmio(struct cpu_user_regs *regs, handler =find_mmio_handler (v->domain, info.gpa);if ( !handler ) -return 0 ; +return IO_UNHANDLED ;/* All the instructions used on emulated MMIO region should be valid */ if ( !dabt.valid ) -return 0 ; +return IO_ABORT ;/* * Erratum 766422: Thumb store translation fault to Hypervisor may
@@ -138,7 +142,7 @@ int try_handle_mmio(struct cpu_user_regs *regs,if ( rc ) {gprintk (XENLOG_DEBUG ,"Unable to decode instruction\n" ); -return 0 ; +return IO_ABORT ; } }
xen/arch/arm/traps.c +15 -3
@@ -1964,10 +1964,21 @@ static void do_trap_stage2_abort_guest(struct cpu_user_regs *regs,* * Note that emulated region cannot be executed */ -if ( is_data &&try_handle_mmio (regs, hsr, gpa) ) +if ( is_data ) { -advance_pc (regs, hsr); -return ; +enum io_state state =try_handle_mmio (regs, hsr, gpa); + +switch ( state ) + { +case IO_ABORT : + goto inject_abt; +case IO_HANDLED : +advance_pc (regs, hsr); +return ; +case IO_UNHANDLED : +/* IO unhandled, try another way to handle it. */ +break ; + } }/*
@@ -1988,6 +1999,7 @@ static void do_trap_stage2_abort_guest(struct cpu_user_regs *regs, hsr.bits, xabt.fsc); } +inject_abt:gdprintk (XENLOG_DEBUG ,"HSR=0x%x pc=%#" PRIregister" gva=%#" PRIvaddr" gpa=%#" PRIpaddr"\n" , hsr.bits, regs->pc, gva, gpa);if ( is_data )
xen/include/asm-arm/mmio.h +10 -3
@@ -32,6 +32,13 @@ typedef structpaddr_t gpa; } mmio_info_t; +enum io_state +{ +IO_ABORT ,/* The IO was handled by the helper and led to an abort. */ +IO_HANDLED ,/* The IO was successfully handled by the helper. */ +IO_UNHANDLED ,/* The IO was not handled by the helper. */ +}; +typedef int (*mmio_read_t )(struct vcpu *v,mmio_info_t *info,register_t *r,void *priv); typedef int (*mmio_write_t)(struct vcpu *v, mmio_info_t *info,
@@ -56,9 +63,9 @@ struct vmmio {struct mmio_handler *handlers; }; -int try_handle_mmio (struct cpu_user_regs *regs, -const union hsr hsr, -paddr_t gpa); +enum io_state try_handle_mmio (struct cpu_user_regs *regs, +const union hsr hsr, +paddr_t gpa);void register_mmio_handler (struct domain *d,const struct mmio_handler_ops *ops,paddr_t addr,paddr_t size,void *priv);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/3] xen/arm: io: Distinguish unhandled IO from aborted one
Quoted 96 lines · Julien Grall
Currently, Xen is considering that an IO could either be handled or unhandled. When unhandled, the stage-2 abort function will try another way to resolve the abort.
However, the MMIO emulation may return unhandled when the address belongs to an emulated range but was not correct. In that case, Xen should avoid to try another way and directly inject a guest data abort.
Introduce a tri-state return to distinguish the following state:
*IO_ABORT: The IO was handled but resulted in an abort
*IO_HANDLED: The IO was handled
*IO_UNHANDLED: The IO was unhandledFor now, it is considered that an IO belonging to an emulated range could either be handled or inject an abort. This could be revisit in the future if overlapped region exist (or we want to try another way to resolve the abort).
Signed-off-by Julien Grall <[email protected]>---
Changes in v2:
- Always returnIO_ABORTwhen the check failed because we know it was targeted emulated IO.
- Fix typoes--- xen/arch/arm/io.c | 32 ++++++++++++++++++-------------- xen/arch/arm/traps.c | 18 +++++++++++++++--- xen/include/asm-arm/mmio.h | 13 ++++++++++--- 3 files changed, 43 insertions(+), 20 deletions(-)xen/arch/arm/io.c +15
-11@@ -26,8 +26,9 @@#include "decode.h" -static int handle_read (const struct mmio_handler *handler,struct vcpu *v, -mmio_info_t *info) +static enum io_state handle_read (const struct mmio_handler *handler, +struct vcpu *v, +mmio_info_t *info) {const struct hsr_dabt dabt = info->dabt;struct cpu_user_regs *regs =guest_cpu_user_regs ();@@ -40,7 +41,7 @@ static int handle_read(const struct mmio_handler *handler, struct vcpu *v,uint8_t size = (1 << dabt.size) *8 ;if ( !handler->ops->read (v, info, &r, handler->priv) ) -return 0 ; +return IO_ABORT ;/* * Sign extend if required. @@ -60,17 +61,20 @@ static int handle_read(const struct mmio_handler *handler, struct vcpu *v,set_user_reg (regs, dabt.reg, r); -return 1 ; +return IO_HANDLED ; } -static int handle_write (const struct mmio_handler *handler,struct vcpu *v, -mmio_info_t *info) +static enum io_state handle_write (const struct mmio_handler *handler, +struct vcpu *v, +mmio_info_t *info) {const struct hsr_dabt dabt = info->dabt;struct cpu_user_regs *regs =guest_cpu_user_regs (); +int ret; -return handler->ops->write (v, info,get_user_reg (regs, dabt.reg), - handler->priv); + ret = handler->ops->write (v, info,get_user_reg (regs, dabt.reg), + handler->priv); +return ( ret ) ?IO_HANDLED :IO_ABORT ; }/* This function assumes that mmio regions are not overlapped */ @@ -103,9 +107,9 @@ static const struct mmio_handler *find_mmio_handler(struct domain *d,return handler; } -int try_handle_mmio (struct cpu_user_regs *regs, -const union hsr hsr, -paddr_t gpa) +enum io_state try_handle_mmio (struct cpu_user_regs *regs, +const union hsr hsr, +paddr_t gpa) {struct vcpu *v = current;const struct mmio_handler *handler =NULL ;
xen/arch/arm/io.c int try_handle_mmio(struct cpu_user_regs *regs, · line 126
Quoted 5 lines
xen/arch/arm/io.c +1
-1@@ -119,11 +123,11 @@ int try_handle_mmio(struct cpu_user_regs *regs, handler =find_mmio_handler (v->domain, info.gpa);if ( !handler ) -return 0 ; +return IO_UNHANDLED ;
Did you forget to send a patch? Or is there a prerequisite for this series? This patch doesn't apply.
Quoted 87 lines
xen/arch/arm/io.c +2
-2/* All the instructions used on emulated MMIO region should be valid */ if ( !dabt.valid ) -return 0 ; +return IO_ABORT ;/* * Erratum 766422: Thumb store translation fault to Hypervisor may @@ -138,7 +142,7 @@ int try_handle_mmio(struct cpu_user_regs *regs,if ( rc ) {gprintk (XENLOG_DEBUG ,"Unable to decode instruction\n" ); -return 0 ; +return IO_ABORT ; } }xen/arch/arm/traps.c +15
-3@@ -1964,10 +1964,21 @@ static void do_trap_stage2_abort_guest(struct cpu_user_regs *regs,* * Note that emulated region cannot be executed */ -if ( is_data &&try_handle_mmio (regs, hsr, gpa) ) +if ( is_data ) { -advance_pc (regs, hsr); -return ; +enum io_state state =try_handle_mmio (regs, hsr, gpa); + +switch ( state ) + { +case IO_ABORT : + goto inject_abt; +case IO_HANDLED : +advance_pc (regs, hsr); +return ; +case IO_UNHANDLED : +/* IO unhandled, try another way to handle it. */ +break ; + } }/* @@ -1988,6 +1999,7 @@ static void do_trap_stage2_abort_guest(struct cpu_user_regs *regs, hsr.bits, xabt.fsc); } +inject_abt:gdprintk (XENLOG_DEBUG ,"HSR=0x%x pc=%#" PRIregister" gva=%#" PRIvaddr" gpa=%#" PRIpaddr"\n" , hsr.bits, regs->pc, gva, gpa);if ( is_data )xen/include/asm-arm/mmio.h +10
-3@@ -32,6 +32,13 @@ typedef structpaddr_t gpa; } mmio_info_t; +enum io_state +{ +IO_ABORT ,/* The IO was handled by the helper and led to an abort. */ +IO_HANDLED ,/* The IO was successfully handled by the helper. */ +IO_UNHANDLED ,/* The IO was not handled by the helper. */ +}; +typedef int (*mmio_read_t )(struct vcpu *v,mmio_info_t *info,register_t *r,void *priv); typedef int (*mmio_write_t)(struct vcpu *v, mmio_info_t *info,@@ -56,9 +63,9 @@ struct vmmio {struct mmio_handler *handlers; }; -int try_handle_mmio (struct cpu_user_regs *regs, -const union hsr hsr, -paddr_t gpa); +enum io_state try_handle_mmio (struct cpu_user_regs *regs, +const union hsr hsr, +paddr_t gpa);void register_mmio_handler (struct domain *d,const struct mmio_handler_ops *ops,paddr_t addr,paddr_t size,void *priv);Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/3] xen/arm: io: Distinguish unhandled IO from aborted one
(sorry for the formatting)
On 1 Feb 2018 19:05, "Stefano Stabellini" <[email protected]> wrote:
Quoted 36 lines · Julien Grall
Currently, Xen is considering that an IO could either be handled or unhandled. When unhandled, the stage-2 abort function will try another way to resolve the abort.
However, the MMIO emulation may return unhandled when the address belongs to an emulated range but was not correct. In that case, Xen should avoid to try another way and directly inject a guest data abort.
Introduce a tri-state return to distinguish the following state:
*IO_ABORT: The IO was handled but resulted in an abort
*IO_HANDLED: The IO was handled
*IO_UNHANDLED: The IO was unhandledFor now, it is considered that an IO belonging to an emulated range could either be handled or inject an abort. This could be revisit in the future if overlapped region exist (or we want to try another way to resolve the abort).
Signed-off-by Julien Grall <[email protected]>---
Changes in v2:
- Always returnIO_ABORTwhen the check failed because we know it was targeted emulated IO.
- Fix typoes--- xen/arch/arm/io.c | 32 ++++++++++++++++++-------------- xen/arch/arm/traps.c | 18 +++++++++++++++--- xen/include/asm-arm/mmio.h | 13 ++++++++++--- 3 files changed, 43 insertions(+), 20 deletions(-)xen/arch/arm/io.c +0
-0
xen/arch/arm/io.c line 29
Quoted 4 lines
xen/arch/arm/io.c +0
-1@@ -26,8 +26,9 @@#include "decode.h" -static int handle_read(const struct mmio_handler *handler, struct vcpu
*v,
xen/arch/arm/io.c static int handle_read(const struct mmio_handler
Quoted 8 lines
xen/arch/arm/io.c +3
-1- mmio_info_t *info) +static enum io_state handle_read (const struct mmio_handler *handler, +struct vcpu *v, +mmio_info_t *info) {const struct hsr_dabt dabt = info->dabt;struct cpu_user_regs *regs =guest_cpu_user_regs ();@@ -40,7 +41,7 @@ static int handle_read(const struct mmio_handler
*handler, struct vcpu *v,
xen/arch/arm/io.c static int handle_read(const struct mmio_handler
Quoted 9 lines
xen/arch/arm/io.c +1
-1uint8_t size = (1 << dabt.size) *8 ;if ( !handler->ops->read (v, info, &r, handler->priv) ) -return 0 ; +return IO_ABORT ;/* * Sign extend if required. @@ -60,17 +61,20 @@ static int handle_read(const struct mmio_handler
*handler, struct vcpu *v,
xen/arch/arm/io.c static int handle_read(const struct mmio_handler *handler, struct vcpu *v,
Quoted 8 lines
xen/arch/arm/io.c +1
-2set_user_reg (regs, dabt.reg, r); -return 1 ; +return IO_HANDLED ; } -static int handle_write(const struct mmio_handler *handler, struct vcpu
*v,
xen/arch/arm/io.c static const struct mmio_handler
Quoted 18 lines
xen/arch/arm/io.c +7
-3- mmio_info_t *info) +static enum io_state handle_write (const struct mmio_handler *handler, +struct vcpu *v, +mmio_info_t *info) {const struct hsr_dabt dabt = info->dabt;struct cpu_user_regs *regs =guest_cpu_user_regs (); +int ret; -return handler->ops->write (v, info,get_user_reg (regs, dabt.reg), - handler->priv); + ret = handler->ops->write (v, info,get_user_reg (regs, dabt.reg), + handler->priv); +return ( ret ) ?IO_HANDLED :IO_ABORT ; }/* This function assumes that mmio regions are not overlapped */ @@ -103,9 +107,9 @@ static const struct mmio_handler
*find_mmio_handler(struct domain *d,
Quoted 13 lines
xen/arch/arm/io.c +3
-3return handler; } -int try_handle_mmio (struct cpu_user_regs *regs, -const union hsr hsr, -paddr_t gpa) +enum io_state try_handle_mmio (struct cpu_user_regs *regs, +const union hsr hsr, +paddr_t gpa) {struct vcpu *v = current;const struct mmio_handler *handler =NULL ;
xen/arch/arm/io.c int try_handle_mmio(struct cpu_user_regs *regs, · line 126
Quoted 5 lines
xen/arch/arm/io.c +1
-1@@ -119,11 +123,11 @@ int try_handle_mmio(struct cpu_user_regs *regs, handler =find_mmio_handler (v->domain, info.gpa);if ( !handler ) -return 0 ; +return IO_UNHANDLED ;
Did you forget to send a patch? Or is there a prerequisite for this series? This patch doesn't apply.
Yes, I messed up my git format-patch command line. The series is meant to have 4 patches.
Sorry for that. I will resend it tomorrow.
Cheers,
xen/arch/arm/io.c int try_handle_mmio(struct cpu_user_regs *regs, · line 127
Quoted 1 line
xen/arch/arm/io.c +0
-0/* All the instructions used on emulated MMIO region should be valid
*/
xen/arch/arm/traps.c static void do_trap_stage2_abort_guest(struct
Quoted 20 lines
xen/arch/arm/io.c +2
-2if ( !dabt.valid ) -return 0 ; +return IO_ABORT ;/* * Erratum 766422: Thumb store translation fault to Hypervisor may @@ -138,7 +142,7 @@ int try_handle_mmio(struct cpu_user_regs *regs,if ( rc ) {gprintk (XENLOG_DEBUG ,"Unable to decode instruction\n" ); -return 0 ; +return IO_ABORT ; } }xen/arch/arm/traps.c +0
-0@@ -1964,10 +1964,21 @@ static void do_trap_stage2_abort_guest(struct
cpu_user_regs *regs,
xen/arch/arm/traps.c static void do_trap_stage2_abort_guest(struct
Quoted 25 lines
xen/arch/arm/traps.c +14
-3* * Note that emulated region cannot be executed */ -if ( is_data &&try_handle_mmio (regs, hsr, gpa) ) +if ( is_data ) { -advance_pc (regs, hsr); -return ; +enum io_state state =try_handle_mmio (regs, hsr, gpa); + +switch ( state ) + { +case IO_ABORT : + goto inject_abt; +case IO_HANDLED : +advance_pc (regs, hsr); +return ; +case IO_UNHANDLED : +/* IO unhandled, try another way to handle it. */ +break ; + } }/* @@ -1988,6 +1999,7 @@ static void do_trap_stage2_abort_guest(struct
cpu_user_regs *regs,
Quoted 12 lines
xen/arch/arm/traps.c +1
-0hsr.bits, xabt.fsc); } +inject_abt:gdprintk (XENLOG_DEBUG ,"HSR=0x%x pc=%#" PRIregister" gva=%#" PRIvaddr" gpa=%#" PRIpaddr"\n" , hsr.bits, regs->pc, gva, gpa);if ( is_data )xen/include/asm-arm/mmio.h +0
-0
xen/include/asm-arm/mmio.h typedef struct · line 37
Quoted 6 lines
xen/include/asm-arm/mmio.h +3
-0@@ -32,6 +32,13 @@ typedef structpaddr_t gpa; } mmio_info_t; +enum io_state +{ +IO_ABORT ,/* The IO was handled by the helper and led to an
abort. */
Quoted 21 lines
xen/include/asm-arm/mmio.h +7
-4+IO_HANDLED ,/* The IO was successfully handled by the helper. */ + IO_UNHANDLED, /* The IO was not handled by the helper. */ +}; +typedef int (*mmio_read_t )(struct vcpu *v,mmio_info_t *info,register_t *r,void *priv); typedef int (*mmio_write_t)(struct vcpu *v, mmio_info_t *info,@@ -56,9 +63,9 @@ struct vmmio {struct mmio_handler *handlers; }; -int try_handle_mmio (struct cpu_user_regs *regs, -const union hsr hsr, -paddr_t gpa); +enum io_state try_handle_mmio (struct cpu_user_regs *regs, +const union hsr hsr, +paddr_t gpa);void register_mmio_handler (struct domain *d,const struct mmio_handler_ops *ops,paddr_t addr,paddr_t size,void *priv); --
Quoted 2 lines
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/3 xen/arm: Don't crash domain on bad MMIO emulation
In reply to Julien GrallNow the MMIO emulation is able to distinguish unhandled IO from aborted one, there are no need to crash the domain when the region is access with a bad width.
Instead let Xen inject a data abort to the guest and decide what to do.
---
Changes in v2
- Add Stefano's reviewed-by
--- xen/arch/arm/vgic-v2.c | 2 -- xen/arch/arm/vgic-v3-its.c | 3 --- xen/arch/arm/vgic-v3.c | 8 -------- xen/arch/arm/vpl011.c | 2 -- 4 files changed, 15 deletions(-)
xen/arch/arm/vgic-v2.c +0 -2
@@ -348,7 +348,6 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, bad_width:printk (XENLOG_G_ERR "%pv: vGICD: bad read width %d r%d offset %#08x\n" , v, dabt.size, dabt.reg, gicd_reg); -domain_crash_synchronous ();return 0 ; read_as_zero_32:
@@ -613,7 +612,6 @@ bad_width:printk (XENLOG_G_ERR "%pv: vGICD: bad write width %d r%d=%" PRIregister" offset %#08x\n" , v, dabt.size, dabt.reg, r, gicd_reg); -domain_crash_synchronous ();return 0 ; write_ignore_32:
xen/arch/arm/vgic-v3-its.c +0 -3
@@ -1136,7 +1136,6 @@ read_reserved: bad_width:printk (XENLOG_G_ERR "vGITS: bad read width %d r%d offset %#04lx\n" , info->dabt.size, info->dabt.reg, (unsigned long )info->gpa &0xffff ); -domain_crash_synchronous ();return 0 ; }
@@ -1446,8 +1445,6 @@ bad_width:printk (XENLOG_G_ERR "vGITS: bad write width %d r%d offset %#08lx\n" , info->dabt.size, info->dabt.reg, (unsigned long )info->gpa &0xffff ); -domain_crash_synchronous (); -return 0 ; }
xen/arch/arm/vgic-v3.c +0 -8
@@ -328,7 +328,6 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, bad_width:printk (XENLOG_G_ERR "%pv vGICR: bad read width %d r%d offset %#08x\n" , v, dabt.size, dabt.reg, gicr_reg); -domain_crash_synchronous ();return 0 ; read_as_zero_64:
@@ -648,7 +647,6 @@ bad_width:printk (XENLOG_G_ERR "%pv: vGICR: bad write width %d r%d=%" PRIregister" offset %#08x\n" , v, dabt.size, dabt.reg, r, gicr_reg); -domain_crash_synchronous ();return 0 ; write_ignore_64:
@@ -760,7 +758,6 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v, bad_width:printk (XENLOG_G_ERR "%pv: %s: bad read width %d r%d offset %#08x\n" , v, name, dabt.size, dabt.reg, reg); -domain_crash_synchronous ();return 0 ; read_as_zero:
@@ -876,7 +873,6 @@ bad_width:printk (XENLOG_G_ERR "%pv: %s: bad write width %d r%d=%" PRIregister" offset %#08x\n" , v, name, dabt.size, dabt.reg, r, reg); -domain_crash_synchronous ();return 0 ; write_ignore_32:
@@ -937,7 +933,6 @@ static int vgic_v3_rdistr_sgi_mmio_read(struct vcpu *v, mmio_info_t *info, bad_width:printk (XENLOG_G_ERR "%pv: vGICR: SGI: bad read width %d r%d offset %#08x\n" , v, dabt.size, dabt.reg, gicr_reg); -domain_crash_synchronous ();return 0 ; read_as_zero_32:
@@ -1017,7 +1012,6 @@ bad_width:printk (XENLOG_G_ERR "%pv: vGICR: SGI: bad write width %d r%d=%" PRIregister" offset %#08x\n" , v, dabt.size, dabt.reg, r, gicr_reg); -domain_crash_synchronous ();return 0 ; write_ignore_32:
@@ -1268,7 +1262,6 @@ static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info, bad_width:printk (XENLOG_G_ERR "%pv: vGICD: bad read width %d r%d offset %#08x\n" , v, dabt.size, dabt.reg, gicd_reg); -domain_crash_synchronous ();return 0 ; read_as_zero_32:
@@ -1456,7 +1449,6 @@ bad_width:printk (XENLOG_G_ERR "%pv: vGICD: bad write width %d r%d=%" PRIregister" offset %#08x\n" , v, dabt.size, dabt.reg, r, gicd_reg); -domain_crash_synchronous ();return 0 ; write_ignore_32:
xen/arch/arm/vpl011.c +0 -2
@@ -296,7 +296,6 @@ static int vpl011_mmio_read(struct vcpu *v, bad_width:gprintk (XENLOG_ERR ,"vpl011: bad read width %d r%d offset %#08x\n" , dabt.size, dabt.reg, vpl011_reg); -domain_crash_synchronous ();return 0 ; }
@@ -366,7 +365,6 @@ write_ignore: bad_width:gprintk (XENLOG_ERR ,"vpl011: bad write width %d r%d offset %#08x\n" , dabt.size, dabt.reg, vpl011_reg); -domain_crash_synchronous ();return 0 ; }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 3/3 xen/arm: Don't crash the domain on invalid HVC immediate
In reply to Julien Gralldomain_crash_synchronous() should only be used when something went wrong in Xen. It is better to inject to the guest as it will be in a better position to provide helpful information (stack trace...).
---
We potentially want to return -1 instead. This would make Xen more future-proof if we decide to implement the other HVC immediate.
Changes in v2:
- Add Stefano's reviewed-by
--- xen/arch/arm/traps.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
xen/arch/arm/traps.c +8 -5
@@ -1471,14 +1471,17 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)#endif static void do_trap_hypercall (struct cpu_user_regs *regs,register_t *nr, -unsigned long iss) +const union hsr hsr) {arm_hypercall_fn_t call =NULL ;BUILD_BUG_ON (NR_hypercalls <ARRAY_SIZE (arm_hypercall_table) ); -if ( iss !=XEN_HYPERCALL_TAG ) -domain_crash_synchronous (); +if ( hsr.iss !=XEN_HYPERCALL_TAG ) + { +gprintk (XENLOG_WARNING ,"Invalid HVC imm 0x%x\n" , hsr.iss); +return inject_undef_exception (regs, hsr); + }if ( *nr >=ARRAY_SIZE (arm_hypercall_table) ) {
@@ -2109,7 +2112,7 @@ void do_trap_guest_sync(struct cpu_user_regs *regs)if ( hsr.iss ==0 )return do_trap_hvc_smccc (regs); nr = regs->r12; -do_trap_hypercall (regs, &nr, hsr.iss); +do_trap_hypercall (regs, &nr, hsr); regs->r12 = (uint32_t )nr;break ; }
@@ -2123,7 +2126,7 @@ void do_trap_guest_sync(struct cpu_user_regs *regs)#endif if ( hsr.iss ==0 )return do_trap_hvc_smccc (regs); -do_trap_hypercall (regs, ®s->x16, hsr.iss); +do_trap_hypercall (regs, ®s->x16, hsr);break ;case HSR_EC_SMC64 :/*
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel