From patchwork Fri May 5 14:30:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 98641 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp154646qge; Fri, 5 May 2017 07:32:27 -0700 (PDT) X-Received: by 10.36.10.12 with SMTP id 12mr9429590itw.74.1493994747315; Fri, 05 May 2017 07:32:27 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c81si5086880itd.99.2017.05.05.07.32.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 07:32:27 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.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 1d6eFp-0006pT-5o; Fri, 05 May 2017 14:30:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d6eFo-0006p9-JI for xen-devel@lists.xen.org; Fri, 05 May 2017 14:30:44 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 06/63-03587-49C8C095; Fri, 05 May 2017 14:30:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTXdyD0+ kwePzYhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bja1/YCv7zV2z9doa5gXE9TxcjF4eQwGZG iaaPzYwQzmlGicubDgE5nBxsApoSdz5/YgKxRQSkJa59vgwWZxZwkHjz8R4LiC0s4C2x6ORPV hCbRUBVov3IEXYQm1fAUmJR22s2EFtCQF5iV9tFsBpOASuJM//3MYPYQkA1c5Z3sU9g5F7AyL CKUb04tagstUjXXC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9C/DECwg3HmZf9 DjJIcTEqivGmiPJFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjru4FygkWp6akVaZk5wECDSUtw 8CiJ8P7uAkrzFhck5hZnpkOkTjEqSonzrgPpEwBJZJTmwbXBgvsSo6yUMC8j0CFCPAWpRbmZJ ajyrxjFORiVhHn5QKbwZOaVwE1/BbSYCWhxtCjY4pJEhJRUA2ONQsqfwnW7X8/V9cngmZlzun N79PEg58gi2Sknb96d0iVfcV/a7h3L8gcefBIck6Z3sh/m9PrruFXhn0zLae1zX9ctFDr7fN7 NDyxzWuVqn525u2z94b/Vrw59TucvaClfd2wDt2yFyofYJ806HXWVn7rvyKxg/f6kcY9mnVv6 4nNSzWx6V+uUWIozEg21mIuKEwGLG2HSaQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1493994642!66800153!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59174 invoked from network); 5 May 2017 14:30:43 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-21.messagelabs.com with SMTP; 5 May 2017 14:30:43 -0000 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 A10821516; Fri, 5 May 2017 07:30:42 -0700 (PDT) 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 0D27D3F3E1; Fri, 5 May 2017 07:30:41 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 5 May 2017 15:30:34 +0100 Message-Id: <20170505143036.27405-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170505143036.27405-1-julien.grall@arm.com> References: <20170505143036.27405-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 1/3] xen/arm: arm32: Rename the trap to the correct name X-BeenThere: xen-devel@lists.xen.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.xen.org Sender: "Xen-devel" Per Table B1-3 in ARM DDI 0406C.c, the vector 0x8 for hyp is called "Hypervisor Call". Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/arm32/entry.S | 4 ++-- xen/arch/arm/arm32/traps.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index 2b04a99664..05733089f7 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -149,7 +149,7 @@ trap_##trap: \ GLOBAL(hyp_traps_vector) .word 0 /* 0x00 - Reset */ b trap_undefined_instruction /* 0x04 - Undefined Instruction */ - b trap_supervisor_call /* 0x08 - Supervisor Call */ + b trap_hypervisor_call /* 0x08 - Hypervisor Call */ b trap_prefetch_abort /* 0x0c - Prefetch Abort */ b trap_data_abort /* 0x10 - Data Abort */ b trap_hypervisor /* 0x14 - Hypervisor */ @@ -157,7 +157,7 @@ GLOBAL(hyp_traps_vector) b trap_fiq /* 0x1c - FIQ */ DEFINE_TRAP_ENTRY(undefined_instruction) -DEFINE_TRAP_ENTRY(supervisor_call) +DEFINE_TRAP_ENTRY(hypervisor_call) DEFINE_TRAP_ENTRY(prefetch_abort) DEFINE_TRAP_ENTRY(hypervisor) DEFINE_TRAP_ENTRY_NOIRQ(irq) diff --git a/xen/arch/arm/arm32/traps.c b/xen/arch/arm/arm32/traps.c index 5bc5f64d86..e75836792a 100644 --- a/xen/arch/arm/arm32/traps.c +++ b/xen/arch/arm/arm32/traps.c @@ -50,9 +50,9 @@ die: do_unexpected_trap("Undefined Instruction", regs); } -asmlinkage void do_trap_supervisor_call(struct cpu_user_regs *regs) +asmlinkage void do_trap_hypervisor_call(struct cpu_user_regs *regs) { - do_unexpected_trap("Supervisor Call", regs); + do_unexpected_trap("Hypervisor Call", regs); } asmlinkage void do_trap_prefetch_abort(struct cpu_user_regs *regs) From patchwork Fri May 5 14:30:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 98642 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp154690qge; Fri, 5 May 2017 07:32:31 -0700 (PDT) X-Received: by 10.107.167.19 with SMTP id q19mr30709696ioe.110.1493994751640; Fri, 05 May 2017 07:32:31 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 67si26051038iou.167.2017.05.05.07.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 07:32:31 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.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 1d6eFq-0006qn-Fk; Fri, 05 May 2017 14:30:46 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d6eFp-0006pJ-Dd for xen-devel@lists.xen.org; Fri, 05 May 2017 14:30:45 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 72/74-03371-49C8C095; Fri, 05 May 2017 14:30:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTXdKD0+ kwaJ5YhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8alvnlsBdsVKw79fsPewLhUsouRi0NIYDOj xNGXl9i6GDmBnNOMEj0HVEBsNgFNiTufPzGB2CIC0hLXPl9mBLGZBRwk3ny8xwJiCwtESNzq7 mYFsVkEVCUWbDwKNodXwFLix9zXYDUSAvISu9ougtVwClhJnPm/jxlil6XEnOVd7BMYuRcwMq xi1ChOLSpLLdI1MtNLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAj0LwMQ7GA8syD wEKMkB5OSKG+aKE+kEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneV11AOcGi1PTUirTMHGCgwaQl OHiURHh/g6R5iwsSc4sz0yFSpxgVpcR5+buBEgIgiYzSPLg2WHBfYpSVEuZlBDpEiKcgtSg3s wRV/hWjOAejkjDvQZApPJl5JXDTXwEtZgJaHC0KtrgkESEl1cDoGVylPf3LSYdf07rkdL//sJ HqiJprsjDGqWcPt6TTkzrb8BkfrSx51VgPvHCZNjWt8vt5l+PFkyU4lwfpveL7+4LlccmTlvS TjP6v0hmY3d8qFm3PDfjY8jFbQFi/baG/2pZLnNs2GZ/stgyIubbj5tfFiw0v2UwS2PLyGdvM CddWnkmctV9IiaU4I9FQi7moOBEAXRnURmkCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1493994643!91147103!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28644 invoked from network); 5 May 2017 14:30:44 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-27.messagelabs.com with SMTP; 5 May 2017 14:30:44 -0000 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 7A8701610; Fri, 5 May 2017 07:30:43 -0700 (PDT) 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 DBF5E3F3E1; Fri, 5 May 2017 07:30:42 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 5 May 2017 15:30:35 +0100 Message-Id: <20170505143036.27405-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170505143036.27405-1-julien.grall@arm.com> References: <20170505143036.27405-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 2/3] xen/arm: do_trap_hypervisor: Separate hypervisor and guest traps X-BeenThere: xen-devel@lists.xen.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.xen.org Sender: "Xen-devel" The function do_trap_hypervisor is currently handling both trap coming from the hypervisor and the guest. This makes difficult to get specific behavior when a trap is coming from either the guest or the hypervisor. Split the function into two parts: - do_trap_guest_sync to handle guest traps - do_trap_hyp_sync to handle hypervisor traps On AArch32, the Hyp Trap Exception provides the standard mechanism for trapping Guest OS functions to the hypervisor (see B1.14.1 in ARM DDI 0406C.c). It cannot be generated when generated when the processor is in Hyp Mode, instead other exception will be used. So it is fine to replace the call to do_trap_hypervisor by do_trap_guest_sync. For AArch64, there are two distincts exception depending whether the exception was taken from the current level (hypervisor) or lower level (guest). Note that the unknown traps from guests will lead to panic Xen. This is already behavior and is left unchanged for simplicy. A follow-up patch will address that. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Improve warning message - Clarify in the commit message that the behavior is not yet changed. --- xen/arch/arm/arm32/entry.S | 4 ++-- xen/arch/arm/arm64/entry.S | 6 +++--- xen/arch/arm/traps.c | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index 05733089f7..120922e64e 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -152,14 +152,14 @@ GLOBAL(hyp_traps_vector) b trap_hypervisor_call /* 0x08 - Hypervisor Call */ b trap_prefetch_abort /* 0x0c - Prefetch Abort */ b trap_data_abort /* 0x10 - Data Abort */ - b trap_hypervisor /* 0x14 - Hypervisor */ + b trap_guest_sync /* 0x14 - Hypervisor */ b trap_irq /* 0x18 - IRQ */ b trap_fiq /* 0x1c - FIQ */ DEFINE_TRAP_ENTRY(undefined_instruction) DEFINE_TRAP_ENTRY(hypervisor_call) DEFINE_TRAP_ENTRY(prefetch_abort) -DEFINE_TRAP_ENTRY(hypervisor) +DEFINE_TRAP_ENTRY(guest_sync) DEFINE_TRAP_ENTRY_NOIRQ(irq) DEFINE_TRAP_ENTRY_NOIRQ(fiq) DEFINE_TRAP_ENTRY_NOABORT(data_abort) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index 137e67c674..06afc8a4e4 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -189,7 +189,7 @@ hyp_sync: entry hyp=1 msr daifclr, #6 mov x0, sp - bl do_trap_hypervisor + bl do_trap_hyp_sync exit hyp=1 hyp_irq: @@ -211,7 +211,7 @@ guest_sync: SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) msr daifclr, #6 mov x0, sp - bl do_trap_hypervisor + bl do_trap_guest_sync 1: exit hyp=0, compat=0 @@ -254,7 +254,7 @@ guest_sync_compat: SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) msr daifclr, #6 mov x0, sp - bl do_trap_hypervisor + bl do_trap_guest_sync 1: exit hyp=0, compat=1 diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 6010c96c54..645812210d 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2805,7 +2805,7 @@ static void enter_hypervisor_head(struct cpu_user_regs *regs) } } -asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) +asmlinkage void do_trap_guest_sync(struct cpu_user_regs *regs) { const union hsr hsr = { .bits = regs->hsr }; @@ -2925,6 +2925,21 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) do_trap_data_abort_guest(regs, hsr); break; + default: + printk("Unknown Guest Trap. HSR=0x%x EC=0x%x IL=%x Syndrome=0x%"PRIx32"\n", + hsr.bits, hsr.ec, hsr.len, hsr.iss); + do_unexpected_trap("Guest", regs); + } +} + +asmlinkage void do_trap_hyp_sync(struct cpu_user_regs *regs) +{ + const union hsr hsr = { .bits = regs->hsr }; + + enter_hypervisor_head(regs); + + switch ( hsr.ec ) + { #ifdef CONFIG_ARM_64 case HSR_EC_BRK: do_trap_brk(regs, hsr); From patchwork Fri May 5 14:30:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 98643 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp154775qge; Fri, 5 May 2017 07:32:39 -0700 (PDT) X-Received: by 10.107.175.78 with SMTP id y75mr51163902ioe.87.1493994750454; Fri, 05 May 2017 07:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1493994750; cv=none; d=google.com; s=arc-20160816; b=PGhywjLX5c9D4jakunnP/Ugv8xKfX0kPvf4AqnpKqOx1GQKXPrbxfpnFfFljKGlKNC M3kEmwzQdJpMX0ZUE2M3/v8Rsbxz2Jvl30F40d/fUhTCdJc4kwp6DYQwq9w1IPf7socD XUPJ1HcVC+LK81mUtAoyS3XxWFNFKlQmFNncd3iBwtTe4YXoqZE8OXqYBCa801MB2Tn1 4Xw3uVPXe0ZgAYg9/nlK7+dQlcohI0SSJYmBPLHBA4aBa4HJ+bZgbSIMDtfU+6jjwojR awebYV4nHMU5eipnrbzRtLYxr54w2x+8BG3ITyMM7Sh7NJrgvSwz+nuKREOh6s6iAJoo +ZLw== 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=l8nw0T1nCaIBODLPvfh54w8oNhd0H+Ue3r3+OfyUNwc=; b=c4XPkshC5GDTRcCFtVBUcPgVFa6VIJ4mo24GYSTl6KvGJ+XMQX7bY4xLkOQFNrlpfd wBD4OOz2APC/Fn+RSrJccqAgUGW6VNucRUxZa11jbtfoJTjHXHWvNLqnqUGacfFb1Zmq GwHgCh+d/2C6hCvG7pJC5rdfiDXOwCOpjHlILVUUxsmyi9CkQ4p5S4l9W71k3ZMRl+HT R+q3IAd5SMe0FjOJ0NsJWwt54dsxjBTzP03MjxyIQD1VaYVqWeq5lfAoHA81IAlTSCsp +ij8yDNLAD1CY9bdSxW0w2ZCQ2sPK328Hi66N5eNrj6x856fLMY7RT7rxif2Fd7bn50A J2sw== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id z16si28824465ioz.131.2017.05.05.07.32.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 07:32:30 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.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 1d6eFr-0006rz-Mg; Fri, 05 May 2017 14:30:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d6eFq-0006pl-Dc for xen-devel@lists.xen.org; Fri, 05 May 2017 14:30:46 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 5F/0A-01868-59C8C095; Fri, 05 May 2017 14:30:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTXdqD0+ kwZJTAhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bFplOsBe/5Kvb0NTA1MPbwdDFycggJbGKU uL27touRC8g+zSjR1DSJDSTBJqApcefzJyYQW0RAWuLa58uMIDazQJrEshWvwWxhASeJ6ztaw WpYBFQlVq08DWbzClhKLHk3FWyOhIC8xK62i6wgNqeAlcSZ//uYIRZbSsxZ3sU+gZF7ASPDKk b14tSistQiXWO9pKLM9IyS3MTMHF1DA2O93NTi4sT01JzEpGK95PzcTYxA7zIAwQ7G5i9Ohxg lOZiURHnTRHkihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwXusGygkWpaanVqRl5gDDDCYtwcGj JML7uwsozVtckJhbnJkOkTrFqMvxbumH90xCLHn5ealS4rzrQGYIgBRllObBjYCF/CVGWSlhX kago4R4ClKLcjNLUOVfMYpzMCoJ8waATOHJzCuB2/QK6AgmoCOiRcGOKElESEk1MIophC67Ev BI4+jVHZG5DoEv19rm3W7mTd6huITPir9EWXVf55t/LEvlFAXFJZfMj9UU2Me+SPFqmvfxIPM ablv2ny7mQlENezcerVKP65wyddNUPvb5vIuWd1vtVFh7J8fT9fCMyRVr3IzbZpzfx88t+e2L RVKivoT3hcmbfJdebi29r1dUqcRSnJFoqMVcVJwIALY8iYx0AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1493994644!99056222!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32645 invoked from network); 5 May 2017 14:30:45 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-31.messagelabs.com with SMTP; 5 May 2017 14:30:45 -0000 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 78FD4344; Fri, 5 May 2017 07:30:44 -0700 (PDT) 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 B5DC53F3E1; Fri, 5 May 2017 07:30:43 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 5 May 2017 15:30:36 +0100 Message-Id: <20170505143036.27405-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170505143036.27405-1-julien.grall@arm.com> References: <20170505143036.27405-1-julien.grall@arm.com> Cc: Mark Rutland , Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 3/3] xen/arm: Survive unknown traps from guests X-BeenThere: xen-devel@lists.xen.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.xen.org Sender: "Xen-devel" Currently we crash Xen if we see an ESR_EL2.EC value we don't recognise. As configurable disables/enables are added to the architecture (controlled by RES1/RESO bits respectively), with associated synchronous exceptions, it may be possible for a guest to trigger exceptions with classes that we don't recognise. While we can't service these exceptions in a manner useful to the guest, we can avoid bringing down the host. Per ARM DDI 0487A.k_iss10775, page D7-1937, EC values within the range 0x00 - 0x2c are reserved for future use with synchronous exceptions, and EC within the range 0x2d - 0x3f may be used for either synchronous or asynchronous exceptions. The patch makes Xen handle any unknown EC by injecting an UNDEFINED exception into the guest, with a corresponding (ratelimited) warning in the log. This patch is based on Linux commit f050fe7a9164 "arm: KVM: Survive unknown traps from the guest". Signed-off-by: Julien Grall Acked-by: Mark Rutland Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/traps.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 645812210d..6cf9ee7244 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2926,9 +2926,10 @@ asmlinkage void do_trap_guest_sync(struct cpu_user_regs *regs) break; default: - printk("Unknown Guest Trap. HSR=0x%x EC=0x%x IL=%x Syndrome=0x%"PRIx32"\n", - hsr.bits, hsr.ec, hsr.len, hsr.iss); - do_unexpected_trap("Guest", regs); + gprintk(XENLOG_WARNING, + "Unknown Guest Trap. HSR=0x%x EC=0x%x IL=%x Syndrome=0x%"PRIx32"\n", + hsr.bits, hsr.ec, hsr.len, hsr.iss); + inject_undef_exception(regs, hsr); } }