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

[PATCH v2 2/3] xen: arm: Introduce CONFIG_PARTIAL_EMULATION


  • To: <julien@xxxxxxx>, <ayan.kumar.halder@xxxxxxx>, <sstabellini@xxxxxxxxxx>, <bertrand.marquis@xxxxxxx>, <michal.orzel@xxxxxxx>, <Volodymyr_Babchuk@xxxxxxxx>, <stefano.stabellini@xxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Date: Mon, 18 Dec 2023 20:33:22 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=idvMLh7ay3HgFa0HUlYc6KaMzvjAv1vhicqtRD33Dco=; b=KyMQJl+0WIazzpnt+Z8Ac49uw2OxI6/JJ+nNdKpR/n42R7auMxGL6i4YzjUXg1an+nE8+mhYWt7dKo0a7dD8/iJre/X1deWzLvKoleq8Fm7evUPsbSjhA4vYoXbhJNe4r/9t7qwWX1QA2VBcAnEt/aCwxbkfN8pgJzX1z7IEQ7UcEw8LDpKJvuBrs+JdqXDk+qmZa+ZtGfbkSrYlO8/Xr7RjlNpDShyQGyiPFiWJhIS/yc+jPCrecLwm3cJRxXXJJ0DSrvnvLdss5SCd/Fu0Ws0k6t7sbVhLd/F5O7KAoE38FTsm8WlfNoMwTT+PEynXlDYdnitYjKlLllaYCK7Uwg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dKv8LiDJ809zUxHmJa9JVfopZvvnCKfFlFgOuhQldaTb93TpVIHwiBL+sjGdrQPwhxsQQWak5xcWXgUhvRHcoETYc7OMaLCfXIS9taaLLwlN/qSgFexrrNc3Ksxe2FYWTk7sbCjAnOTmVIRiI5IzMvuF/BzWOm632FOcBMV4L2dSehctCyRisrHWfpDt1IcBHO6921BH9IcoCd4b4vQoYcAsBNhe1V9h/guR1iPgugpjWjC7PMEgIXjYJ73TrnY8QBsQy3m09PcwUvY4tEC5DDXVy7zKs7roxXtNmA+W1DmBJutObRxsZBkJz095LdfF6Kp2HMuLOBJ9eJ47nBK/Ew==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 18 Dec 2023 20:33:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

There are can be situations when the registers cannot be emulated to its full
functionality. This can be due to the complexity involved. In such cases, we can
emulate those registers as RAZ/WI.
A suitable example of this is DBGDTRTX_EL0 (on Arm64) and DBGDTRTXINT(on Arm32).
As this register is not optional, guests may try to access this. Currently, this
would result in a crash. With this patch, Xen will emulated this as RAZ/WI and
the crash will be avoided.
Such partial emulations will be enclosed within CONFIG_PARTIAL_EMULATION.

Also "CONFIG_PARTIAL_EMULATION" is default to y, so that Xen does not need to be
rebuilt in order to prevent guest from crashing while accessing registers like
DBGDTRTX_EL0.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
Changes from v1:-

1. New patch introduced in v2.

 xen/arch/arm/Kconfig         | 8 ++++++++
 xen/arch/arm/arm64/vsysreg.c | 3 +++
 xen/arch/arm/vcpreg.c        | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 50e9bfae1a..8f25d9cba0 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -225,6 +225,14 @@ config STATIC_EVTCHN
          This option enables establishing static event channel communication
          between domains on a dom0less system (domU-domU as well as domU-dom0).
 
+config PARTIAL_EMULATION
+    bool "Enable partial emulation for registers"
+    default y
+    help
+      This option enabled partial emulation for registers to avoid guests
+      crashing when accessing registers which are not optional but has not been
+      emulated to its complete functionality.
+
 endmenu
 
 menu "ARM errata workaround via the alternative framework"
diff --git a/xen/arch/arm/arm64/vsysreg.c b/xen/arch/arm/arm64/vsysreg.c
index ebeb83dd65..0fa8716884 100644
--- a/xen/arch/arm/arm64/vsysreg.c
+++ b/xen/arch/arm/arm64/vsysreg.c
@@ -188,10 +188,13 @@ void do_sysreg(struct cpu_user_regs *regs,
         return handle_ro_read_val(regs, regidx, hsr.sysreg.read, hsr, 0,
                                   1U << 29);
     }
+#ifdef CONFIG_PARTIAL_EMULATION
     case HSR_SYSREG_DBGDTR_EL0:
     /* DBGDTR[TR]X_EL0 share the same encoding */
     case HSR_SYSREG_DBGDTRTX_EL0:
         return handle_raz_wi(regs, regidx, hsr.sysreg.read, hsr, 0);
+#endif
+
     HSR_SYSREG_DBG_CASES(DBGBVR):
     HSR_SYSREG_DBG_CASES(DBGBCR):
     HSR_SYSREG_DBG_CASES(DBGWVR):
diff --git a/xen/arch/arm/vcpreg.c b/xen/arch/arm/vcpreg.c
index 5087125111..52a8732423 100644
--- a/xen/arch/arm/vcpreg.c
+++ b/xen/arch/arm/vcpreg.c
@@ -575,6 +575,7 @@ void do_cp14_32(struct cpu_user_regs *regs, const union hsr 
hsr)
     case HSR_CPREG32(DBGOSLSR):
          return handle_ro_read_val(regs, regidx, cp32.read, hsr, 1, 1 << 3);
 
+#ifdef CONFIG_PARTIAL_EMULATION
     case HSR_CPREG32(DBGDTRTXINT):
     {
         /*
@@ -584,6 +585,7 @@ void do_cp14_32(struct cpu_user_regs *regs, const union hsr 
hsr)
          */
         return handle_raz_wi(regs, regidx, cp32.read, hsr, 0);
     }
+#endif
 
     case HSR_CPREG32(DBGVCR):
     case HSR_CPREG32(DBGBVR0):
-- 
2.25.1




 


Rackspace

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