From patchwork Tue Jan 30 16:14:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 126279 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp3499730ljd; Tue, 30 Jan 2018 08:17:12 -0800 (PST) X-Google-Smtp-Source: AH8x224e+7kzbyPECkT49K0CdGqmakDfMrFOdWLx3O0osYGzVyvG2magsuw2zBuJ3/XnzcqfWd9a X-Received: by 10.107.189.196 with SMTP id n187mr29113050iof.47.1517329032263; Tue, 30 Jan 2018 08:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517329032; cv=none; d=google.com; s=arc-20160816; b=icIal9r/KVdAEFF2i3yYJPatE0RXsYG+6wVRlJ/KAMZRjRjhUrUcRiIoi/hG6j5CXO O/+671qpJgaS+BCK38i0D87bYs/6f2vcz9GF4AlPjnx8QH+OOs4hT44o29eeGWSUFMTO NFpgTWgF/wyqpHUsG+PKO8gZkphpoQ6R4vgxgAuA65DTq7gyjXtRhTCSQxkH4lMUOy4Z KhkZBFLWYOOVCt+ak2kvA38uAR9GnXdUOkiWeNzTHXZLvSaCeCdJExfLE6w1jNHRq+uT WjYRe2+YCW6eexdQZAM69VCS4Ax6NBJ/60HCwT1hcyrxo7ntPwnKpbGJ+73RJJlPa3NL ZFnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=tOXZihsxEwYGz0wEY7Sn7NQKKLJFUvpODIvSL7Ef48s=; b=OSW4Q9V487J7F4TyH9pgoSY63hgdbQBtRK53cBHf7b/iTSbp88D1CAdaIH2vMOSUkP ctzE23WFvcKbAK8ybMKXzR0bxKWuD8EC54nCa7T6COTEikWtk6AlWRdw++8fct4sMMYb 1DVdbKE7P/TDcY6Yu6EbN1aLj0oloGDwavqsSCGNbwe3JF5zjc36Sj4xJBhc2XG2FneS zTrI4RRbgR6uKAxAc270NL+ekpV00ra8em1IWIsplFpNh4FUi0vfNOsAFAJkwo4n5nZH X4WJPi2UgXKaKeIyRTScEy7/cCjg8cT2tmDHqTxLP5NirQfNiaoKHAD/TQng/4/ZE4yh rQ9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o22si6355252iod.288.2018.01.30.08.17.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jan 2018 08:17:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egYYa-0008Ox-Nh; Tue, 30 Jan 2018 16:14:48 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egYYZ-0008OJ-88 for xen-devel@lists.xen.org; Tue, 30 Jan 2018 16:14:47 +0000 X-Inumbo-ID: bca138e9-05d8-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id bca138e9-05d8-11e8-b9b1-635ca7ef6cff; Tue, 30 Jan 2018 16:15:07 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9C59815AB; Tue, 30 Jan 2018 08:14:40 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8BCDB3F25C; Tue, 30 Jan 2018 08:14:39 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 30 Jan 2018 16:14:31 +0000 Message-Id: <20180130161433.6910-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180130161433.6910-1-julien.grall@arm.com> References: <20180130161433.6910-1-julien.grall@arm.com> Cc: andrew.cooper3@citrix.com, Julien Grall , sstabellini@kernel.org, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH 1/3] xen/arm: io: Distinguish unhandled IO from aborted one X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 avodi 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 to 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). Signed-off-by: Julien Grall --- xen/arch/arm/io.c | 24 ++++++++++++++---------- xen/arch/arm/traps.c | 34 +++++++++++++++++++++++----------- xen/include/asm-arm/mmio.h | 9 ++++++++- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c index c748d8f5bf..a74ec21b86 100644 --- a/xen/arch/arm/io.c +++ b/xen/arch/arm/io.c @@ -23,8 +23,9 @@ #include #include -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(); @@ -37,7 +38,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. @@ -57,17 +58,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 */ @@ -100,14 +104,14 @@ static const struct mmio_handler *find_mmio_handler(struct domain *d, return handler; } -int handle_mmio(mmio_info_t *info) +enum io_state handle_mmio(mmio_info_t *info) { struct vcpu *v = current; const struct mmio_handler *handler = NULL; handler = find_mmio_handler(v->domain, info->gpa); if ( !handler ) - return 0; + return IO_UNHANDLED; if ( info->dabt.write ) return handle_write(handler, v, info); diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index c8534d6cff..843adf4959 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1864,10 +1864,10 @@ static inline bool hpfar_is_valid(bool s1ptw, uint8_t fsc) return s1ptw || (fsc == FSC_FLT_TRANS && !check_workaround_834220()); } -static bool try_handle_mmio(struct cpu_user_regs *regs, - const union hsr hsr, - paddr_t gpa) -{ +static enum io_state try_handle_mmio(struct cpu_user_regs *regs, + const union hsr hsr, + paddr_t gpa) + { const struct hsr_dabt dabt = hsr.dabt; mmio_info_t info = { .gpa = gpa, @@ -1879,11 +1879,11 @@ static bool try_handle_mmio(struct cpu_user_regs *regs, /* stage-1 page table should never live in an emulated MMIO region */ if ( dabt.s1ptw ) - return false; + return IO_UNHANDLED; /* All the instructions used on emulated MMIO region should be valid */ if ( !dabt.valid ) - return false; + return IO_UNHANDLED; /* * Erratum 766422: Thumb store translation fault to Hypervisor may @@ -1896,11 +1896,11 @@ static bool try_handle_mmio(struct cpu_user_regs *regs, if ( rc ) { gprintk(XENLOG_DEBUG, "Unable to decode instruction\n"); - return false; + return IO_ABORT; } } - return !!handle_mmio(&info); + return handle_mmio(&info); } /* @@ -2005,10 +2005,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: + /* Nothing to do */ + break; + } } /* @@ -2029,6 +2040,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 ) diff --git a/xen/include/asm-arm/mmio.h b/xen/include/asm-arm/mmio.h index 37e2b7a707..baaecf6931 100644 --- a/xen/include/asm-arm/mmio.h +++ b/xen/include/asm-arm/mmio.h @@ -32,6 +32,13 @@ typedef struct paddr_t gpa; } mmio_info_t; +enum io_state +{ + IO_ABORT, /* The IO was handled by the helper and lead 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,7 +63,7 @@ struct vmmio { struct mmio_handler *handlers; }; -extern int handle_mmio(mmio_info_t *info); +extern enum io_state handle_mmio(mmio_info_t *info); void register_mmio_handler(struct domain *d, const struct mmio_handler_ops *ops, paddr_t addr, paddr_t size, void *priv); From patchwork Tue Jan 30 16:14:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 126278 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp3499687ljd; Tue, 30 Jan 2018 08:17:08 -0800 (PST) X-Google-Smtp-Source: AH8x224qkJFWpnG18eh8CI2dUCOV+e3ZmVlyTV2m1dA+MtYwXJtp5fL5MFvpsQAf9N+zONvgCFNG X-Received: by 10.107.88.4 with SMTP id m4mr30820405iob.278.1517329028638; Tue, 30 Jan 2018 08:17:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517329028; cv=none; d=google.com; s=arc-20160816; b=vRb3oIOJEUDLjGRdbrrN5kyz0IMgYlsBKMrBR8qwxi5WQYA+I5lz346xDxw2MfJB+J Vsa7/EYwNNdyZwdhmplS7o1OZNRA4FeJdyY/olS+CZk+UeWZZwRCoZtuBEKdHcIdbAwl F8G+nFmtbfyyYDRxttG7nyl2UtyIbihNvQwC4L9QjNeXcgaWt/fbtPfCAAPQ/ZcPBS8U 01J4/GUeBiVsFVvPEcA7f/UwrJW1HaSpY+XFdFRw2IY5BiAkOd+ORTf0u9iiMCMk8aKZ HNpiuwtYP/fjqNgJ8qXG52mX0KpETyhgoTmUdURIYGdoJgghf1FcaDf4uk7Gd14iZDOd p/cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=dmYdq04xRpr8/Q3Z0w6Ejmdc3mMa8vn/Z1902IQRpSk=; b=xq3SSgxvp+eACGzlA0CXsg+0chSa6ANsJtECeNsFcga9aDIt0coDqypsE18+Zzv2SS ScyV0IMHc7upVqplPx3JTU4DO2HK48YwO7DPG01dwk4qMdJk/yWX2A+rv+k3tJhgHOMH wc/2/WfgHRbjBNCiJOPnOrK9HWrRymzq/68LnsQ+jgA4dGaYIy7wmlESuvHgp0iuIK5z lqvw11kWYa3wgM75gEWehgOTDpzRU3ybYpvgA0IDixacpEh4qjSltfPwsrC7VTaiF7kw 90KxCd7y/dflPYQOjCc+NwJOpx4cguIO3A/FLJVamXvTJlox7+XE+d33qheeKfIoqwq2 TOdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id s3si35151ioi.323.2018.01.30.08.17.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jan 2018 08:17:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egYYX-0008OR-9x; Tue, 30 Jan 2018 16:14:45 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egYYV-0008OK-Pb for xen-devel@lists.xen.org; Tue, 30 Jan 2018 16:14:43 +0000 X-Inumbo-ID: a62475db-05d8-11e8-ba59-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id a62475db-05d8-11e8-ba59-bc764e045a96; Tue, 30 Jan 2018 17:14:29 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EA20D1529; Tue, 30 Jan 2018 08:14:41 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DAE593F25C; Tue, 30 Jan 2018 08:14:40 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 30 Jan 2018 16:14:32 +0000 Message-Id: <20180130161433.6910-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180130161433.6910-1-julien.grall@arm.com> References: <20180130161433.6910-1-julien.grall@arm.com> Cc: andrew.cooper3@citrix.com, Julien Grall , sstabellini@kernel.org, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH 2/3] xen/arm: Don't crash domain on bad MMIO emulation X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Now 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. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- 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(-) diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 2bdb25261a..646d1f3d12 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -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: diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index d8fa44258d..32061c6b03 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -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; } diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index af16dfd005..2ad8a6be62 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -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: diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 725b2e03ad..7788c2fc32 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -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; } From patchwork Tue Jan 30 16:14:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 126280 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp3499741ljd; Tue, 30 Jan 2018 08:17:12 -0800 (PST) X-Google-Smtp-Source: AH8x227Vi+ALbQSSixDTZOjws7HAKCSKoSz9NtKZyiP4JZ0KCJFrn6VCU30kHLEaGmip18TR/ONu X-Received: by 10.107.18.225 with SMTP id 94mr31988663ios.23.1517329032826; Tue, 30 Jan 2018 08:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517329032; cv=none; d=google.com; s=arc-20160816; b=qNRL4aHjYKFRm/WetLxkbmXolTztnWLBwRq/RpxZFyVjETt2JWJYshcUgRzfph4QbE IBTeWSnF+MxeQWzPj8c6ozzop8+Zee+fiYHNUsPx1wbdkX9/YNrrIHltaZahMoiQSnjx U5WE2SpTLRibKI4zdpi4l+KAyfsEh7txeyqV3WseB4WVVKNmPESYhiziA+NtTTYgNj9w waqlB7/2S5QC4WRR9Ox7Rutdv7kCaE2X3Z+YujNLR01hqxWOeSgqqQzH+pgI15lYVYWQ 4x9kJISQv+u1vw8aCwFYUwBjSQ7hPktxXCB1oYXQpxQ+0ZA0oWLBXkssRMBpfyUGmz8G pC9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=YZxDAyCLGw4I5HK2CKATABKmA36eJ9G8oSPQRs3ngmY=; b=o5ukwpn2XbIm26kzkJvUF3COLRsDb3fUYzA4YxBlRE1m0rvSqKtAg5Ow9JLHwcXNG3 D6IO4DSnJ7HLlx56YGRArqIBtpjPyzGOhCEg+Yofz9Yom0nT9cHHlxIaZ7SoJEQSpr9P 8tfvDqj/s+vK8Mmg9fZvef3q9HGEhAsU2rIARnqLKfpNpWAIuljSfAa70OW0RnKSP+fD CSJajWzyXfxh5HZh2673Itb84gy0SLi3vF8EDvgw0pBc0jbXQL2OUfkmFEz31S/ksO43 kqgj4x20+TocQtFoHAuDaOBYZqiHBa+ewrveRdByvONgIHmqNMNJ6IEEsnGbsAM2Mlzo Yp5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id z192si5545601iod.163.2018.01.30.08.17.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jan 2018 08:17:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egYYd-0008Pz-1e; Tue, 30 Jan 2018 16:14:51 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egYYb-0008OQ-7n for xen-devel@lists.xen.org; Tue, 30 Jan 2018 16:14:49 +0000 X-Inumbo-ID: be3111a4-05d8-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id be3111a4-05d8-11e8-b9b1-635ca7ef6cff; Tue, 30 Jan 2018 16:15:09 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43C5A15AB; Tue, 30 Jan 2018 08:14:43 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 349BF3F25C; Tue, 30 Jan 2018 08:14:42 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 30 Jan 2018 16:14:33 +0000 Message-Id: <20180130161433.6910-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180130161433.6910-1-julien.grall@arm.com> References: <20180130161433.6910-1-julien.grall@arm.com> Cc: andrew.cooper3@citrix.com, Julien Grall , sstabellini@kernel.org, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH 3/3] xen/arm: Don't crash the domain on invalid HVC immediate X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" domain_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 better position to provide helpful information (stack trace...). Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- We potentially want to return -1 instead. This would make Xen more future-proof if we decide to implement the other HVC immediate. --- xen/arch/arm/traps.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 843adf4959..18da45dff3 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1473,14 +1473,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) ) { @@ -2150,7 +2153,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; } @@ -2164,7 +2167,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: /*