From patchwork Fri Feb 2 10:14:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 126625 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp495837ljc; Fri, 2 Feb 2018 02:17:37 -0800 (PST) X-Google-Smtp-Source: AH8x225MOdVygnWpzL0BLokhDZGTRQSsP4NZJyl9zteiYEHFHjIhXUe8hXSE0JsV8Qa9EsZLedo3 X-Received: by 10.107.191.130 with SMTP id p124mr39579401iof.228.1517566657084; Fri, 02 Feb 2018 02:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517566657; cv=none; d=google.com; s=arc-20160816; b=dtKng0yUVWR93iHUs77FNnK1LvZ7Bitj9n1LDYYWlCzH5Fdwf+uSVH9w6vyMTB8oHs 2wosUydMCrrsjlfmKtslW3iPma7ymBf0y0oi/Z9/weKopcfjWb2PcZslqPlk5B7EYipz 2L5Cxduw6lGLAPCPgw5niOfyBBX9BRoMp+q3TBuKsDycbIHmF89vzYx2N66iLaVJjN+b l2eYF2pjDAVoJ22Wr11/1edLSZfmBXEeQbF//gpUGi755ltM2GjshwCGICzfXlyIq98v gNWRcWWJGBL08WG1dn6VDyN5Dqs+RwalGnDPi1dBHQfbJQX1zEGCRaKFppcfqoiNf39B GhQA== 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=fx8gO0NkYIsJIipHW+OVWUluFn6+eU6welLReTQpWRM=; b=fe7DpdcNGwQzFQkA3rm53X49XXHw9RxF0MjYPDp29VIawwYEcCOelfowt0nhguHMwm vDPhyLwIp6JFTiAlaAjL5ql87qVLx0j8y9RJ50kRYWdYvV1qSdTTCFcJ819RnRR4za9Z ERVjLwf3j2ZyRoUqQiL4yDuBwox83+Su27vtrESVj0LJSLoyGGZqnZD1vX/NGb/81Sk/ xDB6TK6wmlhI9KwXbxQEJ6b9c1N04Sp8pIPvefFCxjycTdVxQsdjy9BWezF0S53lnWBI R7Nhgdy9/whmWV2B3hcKZDF7Q0nMLg9XsuJ0+W78vov4t+9BKjwz75URsjxx3a6gxTtR TKow== 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 r197si1420369ior.186.2018.02.02.02.17.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 02:17:37 -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 1ehYN0-0006GF-TJ; Fri, 02 Feb 2018 10:14:58 +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 1ehYMz-0006Fd-Ta for xen-devel@lists.xen.org; Fri, 02 Feb 2018 10:14:57 +0000 X-Inumbo-ID: e11d0366-0801-11e8-ba59-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id e11d0366-0801-11e8-ba59-bc764e045a96; Fri, 02 Feb 2018 11:14:40 +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 CE4E615AD; Fri, 2 Feb 2018 02:14:56 -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 BF8B53F487; Fri, 2 Feb 2018 02:14:55 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 2 Feb 2018 10:14:44 +0000 Message-Id: <20180202101444.3510-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180202101444.3510-1-julien.grall@arm.com> References: <20180202101444.3510-1-julien.grall@arm.com> Cc: andrew.cooper3@citrix.com, Julien Grall , sstabellini@kernel.org, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH v3 4/4] 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 a 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. Changes in v2: - Add Stefano's reviewed-by --- 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 1e85f99ec1..1cba7e584d 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -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: /*