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

[xen staging] xen/keyhandler: Move key_table[] into __ro_after_init



commit 4e23c86bd809d64468407165b40f9976d7186a59
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Sep 12 11:30:44 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu Sep 12 17:28:52 2024 +0100

    xen/keyhandler: Move key_table[] into __ro_after_init
    
    All registration is done at boot.  Almost...
    
    iommu_dump_page_tables() is registered in iommu_hwdom_init(), which is 
called
    twice when LATE_HWDOM is in use.
    
    register_irq_keyhandler() has an ASSERT() guarding againt multiple
    registration attempts, and the absence of bug reports hints at how many
    configurations use LATE_HWDOM in practice.
    
    Move the registration into iommu_setup() just after printing the overall
    status of the IOMMU.  For starters, the hardware domain is specifically
    excluded by iommu_dump_page_tables().
    
    ept_dump_p2m_table is registered in setup_ept_dump() which is non-__init, 
but
    whose sole caller, start_vmx(), is __init.  Move setup_ept_dump() to match.
    
    With these two tweeks, all keyhandler reigstration is from __init functions,
    so register_{,irq_}keyhandler() can move, and key_table[] can become
    __ro_after_init.
    
    No practical change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/mm/p2m-ept.c       |  2 +-
 xen/common/keyhandler.c         | 10 +++++-----
 xen/drivers/passthrough/iommu.c |  5 +++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 2ea574ca6a..21728397f9 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -1497,7 +1497,7 @@ static void cf_check ept_dump_p2m_table(unsigned char key)
     rcu_read_unlock(&domlist_read_lock);
 }
 
-void setup_ept_dump(void)
+void __init setup_ept_dump(void)
 {
     register_keyhandler('D', ept_dump_p2m_table, "dump VT-x EPT tables", 0);
 }
diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 674e7be39e..6da291b34e 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -40,7 +40,7 @@ static struct keyhandler {
     const char *desc;    /* Description for help message.                 */
     bool irq_callback,   /* Call in irq context? if not, tasklet context. */
         diagnostic;      /* Include in 'dump all' handler.                */
-} key_table[128] __read_mostly =
+} key_table[128] __ro_after_init =
 {
 #define KEYHANDLER(k, f, desc, diag)            \
     [k] = { { .fn = (f) }, desc, 0, diag }
@@ -99,8 +99,8 @@ void handle_keypress(unsigned char key, bool need_context)
     }
 }
 
-void register_keyhandler(unsigned char key, keyhandler_fn_t *fn,
-                         const char *desc, bool diagnostic)
+void __init register_keyhandler(unsigned char key, keyhandler_fn_t *fn,
+                                const char *desc, bool diagnostic)
 {
     BUG_ON(key >= ARRAY_SIZE(key_table)); /* Key in range? */
     ASSERT(!key_table[key].fn);           /* Clobbering something else? */
@@ -111,8 +111,8 @@ void register_keyhandler(unsigned char key, keyhandler_fn_t 
*fn,
     key_table[key].diagnostic = diagnostic;
 }
 
-void register_irq_keyhandler(unsigned char key, irq_keyhandler_fn_t *fn,
-                             const char *desc, bool diagnostic)
+void __init register_irq_keyhandler(unsigned char key, irq_keyhandler_fn_t *fn,
+                                    const char *desc, bool diagnostic)
 {
     BUG_ON(key >= ARRAY_SIZE(key_table)); /* Key in range? */
     ASSERT(!key_table[key].irq_fn);       /* Clobbering something else? */
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 50bfd62553..9e74a1fc72 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -271,8 +271,6 @@ void __hwdom_init iommu_hwdom_init(struct domain *d)
     if ( !is_iommu_enabled(d) )
         return;
 
-    register_keyhandler('o', &iommu_dump_page_tables, "dump iommu page 
tables", 0);
-
     iommu_vcall(hd->platform_ops, hwdom_init, d);
 }
 
@@ -605,6 +603,9 @@ int __init iommu_setup(void)
 #ifndef iommu_intremap
         printk("Interrupt remapping %sabled\n", iommu_intremap ? "en" : "dis");
 #endif
+
+        register_keyhandler('o', &iommu_dump_page_tables,
+                            "dump iommu page tables", 0);
     }
 
     return rc;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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