[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN v9 3/4] xen/arm64: io: Handle the abort due to access to stage1 translation table


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxxxxx>
  • Date: Tue, 1 Mar 2022 12:40:21 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oHuuIqCSklM84YJbzg3sQCXYQhhgJ1Du7gvCW1yJRv4=; b=e1z1tssqiorsGvXd/sGa9IgseF+W/1oe9ZYUeQjE3gTSVIabo9w6T45rVxR5NCpcU55OgIlKPndf9M0VE6JOsmjJqQWd9DQw+/2riqhY5Bvh6pl6PtK/3pFxql9QNeQgp94iGaieVBuPk6FfyEqRfITvtk8Q9PNJ4E8E6iBu0ziWOn4STgI6oaq0MmpSczGNWwEV3Dw7oEnM0+PPokwfw35Rapg2pwXCe1zW/+3Gyt4/9JyEczer3a/5ZmeqnoGE+PpzRiuoCa5dNO8w5H//KLnns35Jul0XaMU9uYZu3T3hxcytQ2pCM1yiTQvPzR6uz7onUTmQC+zYxy1xOnyEuQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gkgVaqNI0yTxHbJyJBQyLB0Ti7GigUfaOGqaFNxbXJQqGXeDMHdUTuSnF9Rpqq1e/TpoRNnCPMW+ZdcCvBCZxS+79eSpI95Sye9HSbNKP1pSS2prZ7z6Xru3mMznaMdHv1uA/IsOB1tzhTm9fwfPHUXqKcK+tcs9ByQ8x/8GCaIDpq6vXhNl9yn5KqzGjOnFHNvakh9WDLJqMbzMqgrpC8zY8z9S8oJbxR+BPiDlXeZ2ccP0pnH6FnYPsr9gsKOURFgBz/IckbzLGK2kcb5DOgU/BfnZe+XiQ9bNlPfrQjCyMdwUzHXGwvwtu3m3gk9zBNQSOaQGtBqOfk+2TZ+moQ==
  • Cc: <sstabellini@xxxxxxxxxx>, <stefanos@xxxxxxxxxx>, <julien@xxxxxxx>, <Volodymyr_Babchuk@xxxxxxxx>, <bertrand.marquis@xxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <george.dunlap@xxxxxxxxxx>, <jbeulich@xxxxxxxx>, <wl@xxxxxxx>, <paul@xxxxxxx>, <roger.pau@xxxxxxxxxx>, Ayan Kumar Halder <ayankuma@xxxxxxxxxx>
  • Delivery-date: Tue, 01 Mar 2022 12:40:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

If the abort was caused due to access to stage1 translation table, Xen
will assume that the stage1 translation table is in the non MMIO region.
It will try to resolve the translation fault. If it succeeds, it will
return to the guest to retry the instruction. If not, then it means
that the table is in MMIO region which is not expected by Xen. Thus,
Xen will forward the abort to the guest.

Signed-off-by: Ayan Kumar Halder <ayankuma@xxxxxxxxxx>
---

Changelog :-

v1..v8 - NA

v9 - 1. Extracted this change from "[XEN v8 2/2] xen/arm64: io: Support
instructions (for which ISS is not..." into a separate patch of its own.
The reason being this is an existing bug in the codebase.

 xen/arch/arm/io.c    | 11 +++++++++++
 xen/arch/arm/traps.c | 12 +++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
index bea69ffb08..ebcb8ed548 100644
--- a/xen/arch/arm/io.c
+++ b/xen/arch/arm/io.c
@@ -128,6 +128,17 @@ void try_decode_instruction(const struct cpu_user_regs 
*regs,
         return;
     }
 
+    /*
+     * At this point, we know that the stage1 translation table is in the MMIO
+     * region. This is not expected by Xen and thus it forwards the abort to 
the
+     * guest.
+     */
+    if ( info->dabt.s1ptw )
+    {
+        info->dabt_instr.state = INSTR_ERROR;
+        return;
+    }
+
     /*
      * Armv8 processor does not provide a valid syndrome for decoding some
      * instructions. So in order to process these instructions, Xen must
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 120c971b0f..e491ca15d7 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -1923,6 +1923,7 @@ static void do_trap_stage2_abort_guest(struct 
cpu_user_regs *regs,
     bool is_data = (hsr.ec == HSR_EC_DATA_ABORT_LOWER_EL);
     mmio_info_t info;
     enum io_state state;
+    bool check_mmio_region = true;
 
     /*
      * If this bit has been set, it means that this stage-2 abort is caused
@@ -1987,7 +1988,16 @@ static void do_trap_stage2_abort_guest(struct 
cpu_user_regs *regs,
          */
         if ( !is_data || !info.dabt.valid )
         {
-            if ( check_p2m(is_data, gpa) )
+            /*
+             * If the translation fault was caused due to access to stage 1
+             * translation table, then we try to set the translation table 
entry
+             * for page1 translation table (assuming that it is in the non mmio
+             * region).
+             */
+            if ( xabt.s1ptw )
+                check_mmio_region = false;
+
+            if ( check_p2m((is_data && check_mmio_region), gpa) )
                 return;
 
             /*
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.