mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/hvm: Improve error information in handle_pio()
domain_crash() should always have a message which is emitted even in release builds, so something more useful than this is presented to the user. (XEN) domain_crash called from io.c:171 (XEN) domain_crash called from io.c:171 (XEN) domain_crash called from io.c:171 ... To avoid possibly printing stack rubble, initialise data to ~0 right away. Furthermore, the maximum access size is 4, so drop data from long to int. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
9b9a83e435
commit
4609fc8eb0
1 file changed
+7
-3
@@ -132,13 +132,15 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
|
|||||||
{
|
{
|
||||||
struct vcpu *curr = current;
|
struct vcpu *curr = current;
|
||||||
struct hvm_vcpu_io *vio = &curr->arch.hvm.hvm_io;
|
struct hvm_vcpu_io *vio = &curr->arch.hvm.hvm_io;
|
||||||
unsigned long data;
|
unsigned int data;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
ASSERT((size - 1) < 4 && size != 3);
|
ASSERT((size - 1) < 4 && size != 3);
|
||||||
|
|
||||||
if ( dir == IOREQ_WRITE )
|
if ( dir == IOREQ_WRITE )
|
||||||
data = guest_cpu_user_regs()->eax;
|
data = guest_cpu_user_regs()->eax;
|
||||||
|
else
|
||||||
|
data = ~0; /* Avoid any risk of stack rubble. */
|
||||||
|
|
||||||
rc = hvmemul_do_pio_buffer(port, size, dir, &data);
|
rc = hvmemul_do_pio_buffer(port, size, dir, &data);
|
||||||
|
|
||||||
@@ -151,7 +153,7 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
|
|||||||
if ( dir == IOREQ_READ )
|
if ( dir == IOREQ_READ )
|
||||||
{
|
{
|
||||||
if ( size == 4 ) /* Needs zero extension. */
|
if ( size == 4 ) /* Needs zero extension. */
|
||||||
guest_cpu_user_regs()->rax = (uint32_t)data;
|
guest_cpu_user_regs()->rax = data;
|
||||||
else
|
else
|
||||||
memcpy(&guest_cpu_user_regs()->rax, &data, size);
|
memcpy(&guest_cpu_user_regs()->rax, &data, size);
|
||||||
}
|
}
|
||||||
@@ -167,7 +169,9 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
gdprintk(XENLOG_ERR, "Weird HVM ioemulation status %d.\n", rc);
|
gprintk(XENLOG_ERR, "Unexpected PIO status %d, port %#x %s 0x%0*x\n",
|
||||||
|
rc, port, dir == IOREQ_WRITE ? "write" : "read",
|
||||||
|
size * 2, data & ((1u << (size * 8)) - 1));
|
||||||
domain_crash(curr->domain);
|
domain_crash(curr->domain);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||