xen/keyhandler: Rework keyhandler infrastructure
PATCH v3 1/1 xen/keyhandler: Rework keyhandler infrastructure
struct keyhandler does not contain much information, and requires a lot of boilerplate to use. It is far more convenient to have register_keyhandler() take each piece of information a parameter, especially when introducing temporary debugging keyhandlers.
This in turn allows struct keyhandler itself to become private to keyhandler.c and for the key_table to become more efficient.
key_table doesn't need to contain 256 entries; all keys are ASCII which limits them to 7 bits of index, rather than 8. It can also become a straight array, rather than an array of pointers. The overall effect of this is the key_table grows in size by 50%, but there are no longer 24-byte keyhandler structures all over the data section.
All of the key_table entries in keyhandler.c can be initialised at compile time rather than runtime.
---
v3:
* Fix build on older GCC
* Extra whitespace
* More use of function typedefs.
v2:
* Keep {,irq_}keyhandler_t's as function typedefs
* Adjustment of initialiser macros
* Trim more trailing whitespace
* Implement register_irq_keyhandler()
* Tweak wording of some descriptions
Note: I have avoided CC'ing all maintainers as this is largely a mechanical change across the whole codebase. Most non-mechanical changes are in common code, but there is a trivial externing change xen/drivers/passthrough/vtd/extern.h as previously the struct keyhandler was in a different translation unit to the function it referenced.
--- xen/arch/x86/acpi/cpu_idle.c | 8 +- xen/arch/x86/hvm/irq.c | 8 +- xen/arch/x86/hvm/svm/vmcb.c | 8 +- xen/arch/x86/hvm/vmx/vmcs.c | 8 +- xen/arch/x86/io_apic.c | 7 +- xen/arch/x86/irq.c | 8 +- xen/arch/x86/mm/p2m-ept.c | 8 +- xen/arch/x86/mm/shadow/common.c | 14 +- xen/arch/x86/msi.c | 8 +- xen/arch/x86/nmi.c | 15 +-- xen/arch/x86/numa.c | 8 +- xen/arch/x86/time.c | 8 +- xen/common/event_channel.c | 8 +- xen/common/grant_table.c | 9 +- xen/common/kexec.c | 7 +- xen/common/keyhandler.c | 214 ++++++++++++------------------ xen/common/page_alloc.c | 16 +-- xen/common/timer.c | 8 +- xen/drivers/char/console.c | 16 +-- xen/drivers/passthrough/amd/iommu_intr.c | 9 +- xen/drivers/passthrough/iommu.c | 8 +- xen/drivers/passthrough/pci.c | 8 +- xen/drivers/passthrough/vtd/extern.h | 2 +- xen/drivers/passthrough/vtd/iommu.c | 2 +- xen/drivers/passthrough/vtd/utils.c | 8 +- xen/include/xen/keyhandler.h | 71 +++++----- 26 files changed, 152 insertions(+), 342 deletions(-)
xen/arch/x86/acpi/cpu_idle.c +1 -7
@@ -334,15 +334,9 @@ static void dump_cx(unsigned char key)print_acpi_power (cpu, processor_powers[cpu]); } -static struct keyhandler dump_cx_keyhandler = { - .diagnostic =1 , - .u.fn = dump_cx, - .desc ="dump ACPI Cx structures" -}; -static int __init cpu_idle_key_init (void ) { -register_keyhandler ('c' , &dump_cx_keyhandler); +register_keyhandler ('c' , dump_cx,"dump ACPI Cx structures" ,1 );return 0 ; }__initcall (cpu_idle_key_init);
xen/arch/x86/hvm/irq.c +1 -7
@@ -527,15 +527,9 @@ static void dump_irq_info(unsigned char key)rcu_read_unlock (&domlist_read_lock); } -static struct keyhandler dump_irq_info_keyhandler = { - .diagnostic =1 , - .u.fn = dump_irq_info, - .desc ="dump HVM irq info" -}; -static int __init dump_irq_info_key_init (void ) { -register_keyhandler ('I' , &dump_irq_info_keyhandler); +register_keyhandler ('I' , dump_irq_info,"dump HVM irq info" ,1 );return 0 ; }__initcall (dump_irq_info_key_init);
xen/arch/x86/hvm/svm/vmcb.c +1 -7
@@ -303,15 +303,9 @@ static void vmcb_dump(unsigned char ch)printk ("**************************************\n" ); } -static struct keyhandler vmcb_dump_keyhandler = { - .diagnostic =1 , - .u.fn = vmcb_dump, - .desc ="dump AMD-V VMCBs" -}; -void __init setup_vmcb_dump (void ) { -register_keyhandler ('v' , &vmcb_dump_keyhandler); +register_keyhandler ('v' , vmcb_dump,"dump AMD-V VMCBs" ,1 ); }/*
xen/arch/x86/hvm/vmx/vmcs.c +1 -7
@@ -1858,15 +1858,9 @@ static void vmcs_dump(unsigned char ch)printk ("**************************************\n" ); } -static struct keyhandler vmcs_dump_keyhandler = { - .diagnostic =1 , - .u.fn = vmcs_dump, - .desc ="dump Intel's VMCS" -}; -void __init setup_vmcs_dump (void ) { -register_keyhandler ('v' , &vmcs_dump_keyhandler); +register_keyhandler ('v' , vmcs_dump,"dump VT-x VMCSs" ,1 ); }
xen/arch/x86/io_apic.c +1 -6
@@ -1251,11 +1251,6 @@ static void _print_IO_APIC_keyhandler(unsigned char key) {__print_IO_APIC (0 ); } -static struct keyhandler print_IO_APIC_keyhandler = { - .diagnostic =1 , - .u.fn = _print_IO_APIC_keyhandler, - .desc ="print ioapic info" -};static void __init enable_IO_APIC (void ) {
@@ -2054,7 +2049,7 @@ void __init setup_IO_APIC(void)print_IO_APIC ();ioapic_pm_state_alloc (); -register_keyhandler ('z' , &print_IO_APIC_keyhandler); +register_keyhandler ('z' , _print_IO_APIC_keyhandler,"dump IOAPIC info" ,1 ); }void ioapic_suspend (void )
xen/arch/x86/irq.c +1 -7
@@ -2316,15 +2316,9 @@ static void dump_irqs(unsigned char key)dump_ioapic_irq_info (); } -static struct keyhandler dump_irqs_keyhandler = { - .diagnostic =1 , - .u.fn = dump_irqs, - .desc ="dump interrupt bindings" -}; -static int __init setup_dump_irqs (void ) { -register_keyhandler ('i' , &dump_irqs_keyhandler); +register_keyhandler ('i' , dump_irqs,"dump interrupt bindings" ,1 );return 0 ; }__initcall (setup_dump_irqs);
xen/arch/x86/mm/p2m-ept.c +1 -7
@@ -1257,15 +1257,9 @@ static void ept_dump_p2m_table(unsigned char key) } } -static struct keyhandler ept_p2m_table = { - .diagnostic =0 , - .u.fn = ept_dump_p2m_table, - .desc ="dump ept p2m table" -}; -void setup_ept_dump (void ) { -register_keyhandler ('D' , &ept_p2m_table); +register_keyhandler ('D' , ept_dump_p2m_table,"dump VT-x EPT tables" ,0 ); }/*
xen/arch/x86/mm/shadow/common.c +2 -12
@@ -97,14 +97,9 @@ static void shadow_audit_key(unsigned char key) __func__, shadow_audit_enable); } -static struct keyhandler shadow_audit_keyhandler = { - .u.fn = shadow_audit_key, - .desc ="toggle shadow audits" -}; -static int __init shadow_audit_key_init (void ) { -register_keyhandler ('O' , &shadow_audit_keyhandler); +register_keyhandler ('O' , shadow_audit_key,"toggle shadow audits" ,0 );return 0 ; }__initcall (shadow_audit_key_init);
@@ -1409,15 +1404,10 @@ static void shadow_blow_all_tables(unsigned char c)rcu_read_unlock (&domlist_read_lock); } -static struct keyhandler shadow_blow_all_tables_keyhandler = { - .u.fn = shadow_blow_all_tables, - .desc ="reset shadow pagetables" -}; -/* Register this function in the Xen console keypress table */ static __init int shadow_blow_tables_keyhandler_init (void ) { -register_keyhandler ('S' , &shadow_blow_all_tables_keyhandler); +register_keyhandler ('S' , shadow_blow_all_tables,"reset shadow pagetables" ,1 );return 0 ; }__initcall (shadow_blow_tables_keyhandler_init);
xen/arch/x86/msi.c +1 -7
@@ -1590,15 +1590,9 @@ static void dump_msi(unsigned char key) } } -static struct keyhandler dump_msi_keyhandler = { - .diagnostic =1 , - .u.fn = dump_msi, - .desc ="dump MSI state" -}; -static int __init msi_setup_keyhandler (void ) { -register_keyhandler ('M' , &dump_msi_keyhandler); +register_keyhandler ('M' , dump_msi,"dump MSI state" ,1 );return 0 ; }__initcall (msi_setup_keyhandler);
xen/arch/x86/nmi.c +2 -13
@@ -554,11 +554,6 @@ static void do_nmi_trigger(unsigned char key)self_nmi (); } -static struct keyhandler nmi_trigger_keyhandler = { - .u.fn = do_nmi_trigger, - .desc ="trigger an NMI" -}; -static void do_nmi_stats (unsigned char key) {int i;
@@ -582,16 +577,10 @@ static void do_nmi_stats(unsigned char key)printk ("dom0 vcpu0: NMI neither pending nor masked\n" ); } -static struct keyhandler nmi_stats_keyhandler = { - .diagnostic =1 , - .u.fn = do_nmi_stats, - .desc ="NMI statistics" -}; -static __init int register_nmi_trigger (void ) { -register_keyhandler ('N' , &nmi_trigger_keyhandler); -register_keyhandler ('n' , &nmi_stats_keyhandler); +register_keyhandler ('N' , do_nmi_trigger,"trigger an NMI" ,0 ); +register_keyhandler ('n' , do_nmi_stats,"NMI statistics" ,1 );return 0 ; }__initcall (register_nmi_trigger);
xen/arch/x86/numa.c +1 -7
@@ -501,15 +501,9 @@ static void dump_numa(unsigned char key)rcu_read_unlock (&domlist_read_lock); } -static struct keyhandler dump_numa_keyhandler = { - .diagnostic =1 , - .u.fn = dump_numa, - .desc ="dump numa info" -}; -static __init int register_numa_trigger (void ) { -register_keyhandler ('u' , &dump_numa_keyhandler); +register_keyhandler ('u' , dump_numa,"dump NUMA info" ,1 );return 0 ; }__initcall (register_numa_trigger);
xen/arch/x86/time.c +1 -7
@@ -2047,15 +2047,9 @@ static void dump_softtsc(unsigned char key)printk ("No domains have emulated TSC\n" ); } -static struct keyhandler dump_softtsc_keyhandler = { - .diagnostic =1 , - .u.fn = dump_softtsc, - .desc ="dump softtsc stats" -}; -static int __init setup_dump_softtsc (void ) { -register_keyhandler ('s' , &dump_softtsc_keyhandler); +register_keyhandler ('s' , dump_softtsc,"dump softtsc stats" ,1 );return 0 ; }__initcall (setup_dump_softtsc);
xen/common/event_channel.c +1 -7
@@ -1431,15 +1431,9 @@ static void dump_evtchn_info(unsigned char key)rcu_read_unlock (&domlist_read_lock); } -static struct keyhandler dump_evtchn_info_keyhandler = { - .diagnostic =1 , - .u.fn = dump_evtchn_info, - .desc ="dump evtchn info" -}; -static int __init dump_evtchn_info_key_init (void ) { -register_keyhandler ('e' , &dump_evtchn_info_keyhandler); +register_keyhandler ('e' , dump_evtchn_info,"dump evtchn info" ,1 );return 0 ; }__initcall (dump_evtchn_info_key_init);
xen/common/grant_table.c +2 -7
@@ -3492,12 +3492,6 @@ static void gnttab_usage_print_all(unsigned char key)printk ("%s ] done\n" , __FUNCTION__); } -static struct keyhandler gnttab_usage_print_all_keyhandler = { - .diagnostic =1 , - .u.fn = gnttab_usage_print_all, - .desc ="print grant table usage" -}; -static int __init gnttab_usage_init (void ) {if ( max_nr_grant_frames )
@@ -3518,7 +3512,8 @@ static int __init gnttab_usage_init(void)if ( !max_maptrack_frames ) max_maptrack_frames =DEFAULT_MAX_MAPTRACK_FRAMES ; -register_keyhandler ('g' , &gnttab_usage_print_all_keyhandler); +register_keyhandler ('g' , gnttab_usage_print_all, +"print grant table usage" ,1 );return 0 ; }__initcall (gnttab_usage_init);
xen/common/kexec.c +1 -6
@@ -374,11 +374,6 @@ static void do_crashdump_trigger(unsigned char key)printk (" * no crash kernel loaded!\n" ); } -static struct keyhandler crashdump_trigger_keyhandler = { - .u.fn = do_crashdump_trigger, - .desc ="trigger a crashdump" -}; -static void setup_note (Elf_Note *n,const char *name,int type,int descsz) {int l =strlen (name) +1 ;
@@ -571,7 +566,7 @@ static int __init kexec_init(void)if ( ! crash_notes )return -ENOMEM ; -register_keyhandler ('C' , &crashdump_trigger_keyhandler); +register_keyhandler ('C' , do_crashdump_trigger,"trigger a crashdump" ,0 );cpu_callback (&cpu_nfb,CPU_UP_PREPARE , cpu);register_cpu_notifier (&cpu_nfb);
xen/common/keyhandler.c +87 -127
344 lines not on this page · raw message
xen/common/page_alloc.c +2 -14
@@ -1849,15 +1849,9 @@ static void pagealloc_info(unsigned char key)printk (" Dom heap: %lukB free\n" , total << (PAGE_SHIFT -10 )); } -static struct keyhandler pagealloc_info_keyhandler = { - .diagnostic =1 , - .u.fn = pagealloc_info, - .desc ="memory info" -}; -static __init int pagealloc_keyhandler_init (void ) { -register_keyhandler ('m' , &pagealloc_info_keyhandler); +register_keyhandler ('m' , pagealloc_info,"memory info" ,1 );return 0 ; }__initcall (pagealloc_keyhandler_init);
@@ -1901,15 +1895,9 @@ static void dump_heap(unsigned char key) } } -static struct keyhandler dump_heap_keyhandler = { - .diagnostic =1 , - .u.fn = dump_heap, - .desc ="dump heap info" -}; -static __init int register_heap_trigger (void ) { -register_keyhandler ('H' , &dump_heap_keyhandler); +register_keyhandler ('H' , dump_heap,"dump heap info" ,1 );return 0 ; }__initcall (register_heap_trigger);
xen/common/timer.c +1 -7
@@ -540,12 +540,6 @@ static void dump_timerq(unsigned char key) } } -static struct keyhandler dump_timerq_keyhandler = { - .diagnostic =1 , - .u.fn = dump_timerq, - .desc ="dump timer queues" -}; -static void migrate_timers_from_cpu (unsigned int old_cpu) {unsigned int new_cpu =cpumask_any (&cpu_online_map);
@@ -639,7 +633,7 @@ void __init timer_init(void)cpu_callback (&cpu_nfb,CPU_UP_PREPARE , cpu);register_cpu_notifier (&cpu_nfb); -register_keyhandler ('a' , &dump_timerq_keyhandler); +register_keyhandler ('a' , dump_timerq,"dump timer queues" ,1 ); }/*
xen/drivers/char/console.c +4 -12
@@ -322,11 +322,6 @@ static void dump_console_ring_key(unsigned char key)free_xenheap_pages (buf, order); } -static struct keyhandler dump_console_ring_keyhandler = { - .u.fn = dump_console_ring_key, - .desc ="synchronously dump console ring buffer (dmesg)" -}; -/* CTRL-<switch_char> switches input direction between Xen and DOM0. */ #define switch_code (opt_conswitch[0]-'a'+1)static int __read_mostly xen_rx =1 ;/* FALSE => input passed to domain 0. */
@@ -833,7 +828,8 @@ void __init console_endboot(void)if ( opt_conswitch[1 ] =='x' ) xen_rx = !xen_rx; -register_keyhandler ('w' , &dump_console_ring_keyhandler); +register_keyhandler ('w' , dump_console_ring_key, +"synchronously dump console ring buffer (dmesg)" ,0 );/* Serial input is directed to DOM0 by default. */ switch_serial_input ();
@@ -1069,11 +1065,6 @@ static void debugtrace_key(unsigned char key)debugtrace_toggle (); } -static struct keyhandler debugtrace_keyhandler = { - .u.fn = debugtrace_key, - .desc ="toggle debugtrace to console/buffer" -}; -static int __init debugtrace_init (void ) {int order;
@@ -1095,7 +1086,8 @@ static int __init debugtrace_init(void) debugtrace_bytes = bytes; -register_keyhandler ('T' , &debugtrace_keyhandler); +register_keyhandler ('T' , debugtrace_key, +"toggle debugtrace to console/buffer" ,0 );return 0 ; }
xen/drivers/passthrough/amd/iommu_intr.c +2 -7
@@ -36,12 +36,6 @@static void dump_intremap_tables (unsigned char key); -static struct keyhandler dump_intremap = { - .diagnostic =0 , - .u.fn = dump_intremap_tables, - .desc ="dump IOMMU intremap tables" -}; -static spinlock_t *get_intremap_lock (int seg,int req_id) { return (amd_iommu_perdev_intremap ?
@@ -269,7 +263,8 @@ int __init amd_iommu_setup_ioapic_remapping(void) } } -register_keyhandler ('V' , &dump_intremap); +register_keyhandler ('V' , &dump_intremap_tables, +"dump IOMMU intremap tables" ,0 );return 0 ; }
xen/drivers/passthrough/iommu.c +1 -7
@@ -67,12 +67,6 @@PAGE_LIST_HEAD (iommu_pt_cleanup_list);static struct tasklet iommu_pt_cleanup_tasklet; -static struct keyhandler iommu_p2m_table = { - .diagnostic =0 , - .u.fn = iommu_dump_p2m_table, - .desc ="dump iommu p2m table" -}; -static void __init parse_iommu_param (char *s) {char *ss;
@@ -161,7 +155,7 @@ void __hwdom_init iommu_hwdom_init(struct domain *d)if ( !iommu_enabled )return ; -register_keyhandler ('o' , &iommu_p2m_table); +register_keyhandler ('o' , &iommu_dump_p2m_table,"dump iommu p2m table" ,0 ); d->need_iommu = !!iommu_dom0_strict;if (need_iommu (d) && !iommu_use_hap_pt (d) ) {
xen/drivers/passthrough/pci.c +1 -7
@@ -1211,15 +1211,9 @@ static void dump_pci_devices(unsigned char ch)spin_unlock (&pcidevs_lock); } -struct keyhandler dump_pci_devices_keyhandler = { - .diagnostic =1 , - .u.fn = dump_pci_devices, - .desc ="dump PCI devices" -}; -static int __init setup_dump_pcidevs (void ) { -register_keyhandler ('Q' , &dump_pci_devices_keyhandler); +register_keyhandler ('Q' , dump_pci_devices,"dump PCI devices" ,1 );return 0 ; }__initcall (setup_dump_pcidevs);
xen/drivers/passthrough/vtd/extern.h +1 -1
@@ -29,7 +29,7 @@void print_iommu_regs (struct acpi_drhd_unit *drhd);void print_vtd_entries (struct iommu *iommu,int bus,int devfn,u64 gmfn); -extern struct keyhandler dump_iommu_info_keyhandler; +keyhandler_fn_t vtd_dump_iommu_info;int enable_qinval (struct iommu *iommu);void disable_qinval (struct iommu *iommu);
xen/drivers/passthrough/vtd/iommu.c +1 -1
@@ -2210,7 +2210,7 @@ int __init intel_vtd_setup(void)if ( ret ) goto error; -register_keyhandler ('V' , &dump_iommu_info_keyhandler); +register_keyhandler ('V' , vtd_dump_iommu_info,"dump iommu info" ,1 );return 0 ;
xen/drivers/passthrough/vtd/utils.c +1 -7
@@ -177,7 +177,7 @@ void print_vtd_entries(struct iommu *iommu, int bus, int devfn, u64 gmfn) }while ( --level ); } -static void dump_iommu_info (unsigned char key) +void vtd_dump_iommu_info (unsigned char key) {struct acpi_drhd_unit *drhd;struct iommu *iommu;
@@ -291,12 +291,6 @@ static void dump_iommu_info(unsigned char key) } } -struct keyhandler dump_iommu_info_keyhandler = { - .diagnostic =1 , - .u.fn = dump_iommu_info, - .desc ="dump iommu info" -}; -/* * Local variables: * mode: C
xen/include/xen/keyhandler.h +33 -38
86 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 24.09.15 at 13:05, <[email protected]> wrote:
xen/common/keyhandler.c +6
-0+static struct keyhandler { + union { + keyhandler_fn_t *fn; + irq_keyhandler_fn_t *irq_fn; + }; +
xen/common/keyhandler.c line 49
Quoted 10 lines
xen/common/keyhandler.c +10
-0+const char *desc;/* Description for help message. */ +bool_t irq_callback,/* Call in irq context? if not, tasklet context. */ + diagnostic;/* Include in 'dump all' handler. */ +} key_table[128] __read_mostly = +{ +#define KEYHANDLER (k, f, desc, diag) \ + [k] = { .fn = (f), desc, 0, diag } + +#define IRQ_KEYHANDLER (k, f, desc, diag) \ + [k] = { .irq_fn = (f), desc, 1, diag }
I'm sorry for noticing only now, but I'm afraid these (looking as odd - but correct - as the other ones did) won't build with older gcc either.
Jan
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 24.09.15 at 13:05, <[email protected]> wrote:
xen/common/keyhandler.c +11
-0+static struct keyhandler { +union { +keyhandler_fn_t *fn; +irq_keyhandler_fn_t *irq_fn; + }; + +const char *desc;/* Description for help message. */ +bool_t irq_callback,/* Call in irq context? if not, tasklet context. */ + diagnostic;/* Include in 'dump all' handler. */ +} key_table[128 ]__read_mostly = +{
Quoted 8 lines
xen/common/keyhandler.c line 49
Quoted 5 lines
xen/common/keyhandler.c +5
-0+#define KEYHANDLER (k, f, desc, diag) \ + [k] = { .fn = (f), desc, 0, diag } + +#define IRQ_KEYHANDLER (k, f, desc, diag) \ + [k] = { .irq_fn = (f), desc, 1, diag }I'm sorry for noticing only now, but I'm afraid these (looking as odd - but correct - as the other ones did) won't build with older gcc either.
Urgh yes. I think we might have to just explicitly typecast the pointer, because .irq_fn is uninitialised in older GCC. Would that be ok?
~Andrew
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 24.09.15 at 13:47, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
xen/common/keyhandler.c
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 24.09.15 at 13:05, <[email protected]> wrote:
xen/common/keyhandler.c +7
-0+static struct keyhandler { + union { + keyhandler_fn_t *fn; + irq_keyhandler_fn_t *irq_fn; + }; + + const char *desc; /* Description for help message.*/
Quoted 1 line
Quoted 1 line
+
bool_tirq_callback, /* Call in irq context? if not, tasklet context.*/
Quoted 1 line
Quoted 1 line
+ diagnostic; /* Include in 'dump all' handler.
*/
Quoted 10 lines
xen/common/keyhandler.c line 49
Quoted 7 lines
xen/common/keyhandler.c +7
-0+} key_table[128] __read_mostly = +{ +#define KEYHANDLER (k, f, desc, diag) \ + [k] = { .fn = (f), desc, 0, diag } + +#define IRQ_KEYHANDLER (k, f, desc, diag) \ + [k] = { .irq_fn = (f), desc, 1, diag }I'm sorry for noticing only now, but I'm afraid these (looking as odd - but correct - as the other ones did) won't build with older gcc either.
Quoted 2 lines
Urgh yes. I think we might have to just explicitly typecast the pointer, because .irq_fn is uninitialised in older GCC. Would that be ok?
Yes, certainly better than re-adding the u name. Another alternative would be a void * as the first union alternative, but I suppose future gcc might become more strict about conversions between function and data pointers...
Jan
Quoted 25 lines · Jan Beulich
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 24.09.15 at 13:47, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Review
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 24.09.15 at 13:05, <[email protected]> wrote:
(quoted diff) +7
-0+static struct keyhandler { + union { + keyhandler_fn_t *fn; + irq_keyhandler_fn_t *irq_fn; + }; + + const char *desc; /* Description for help message.*/
Quoted 1 line
Quoted 1 line
+
bool_tirq_callback, /* Call in irq context? if not, tasklet context.*/
Quoted 1 line
Quoted 1 line
+ diagnostic; /* Include in 'dump all' handler.
*/
Quoted 10 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+} key_table[128] __read_mostly = +{ +#define KEYHANDLER(k, f, desc, diag) \ + [k] = { .fn = (f), desc, 0, diag } + +#define IRQ_KEYHANDLER(k, f, desc, diag) \ + [k] = { .irq_fn = (f), desc, 1, diag }I'm sorry for noticing only now, but I'm afraid these (looking as odd - but correct - as the other ones did) won't build with older gcc either.
Quoted 6 lines
Quoted 2 lines
Urgh yes. I think we might have to just explicitly typecast the pointer, because .irq_fn is uninitialised in older GCC. Would that be ok?
Yes, certainly better than re-adding the u name. Another alternative would be a void * as the first union alternative, but I suppose future gcc might become more strict about conversions between function and data pointers...
This appears to work for me.
xen/common/keyhandler.c +2 -2
@@ -43,10 +43,10 @@ } key_table[128] __read_mostly = {#define KEYHANDLER (k, f, desc, diag) \ - [k] = { .fn = (f), desc, 0, diag } + [k] = { { f }, desc, 0, diag }#define IRQ_KEYHANDLER (k, f, desc, diag) \ - [k] = { .irq_fn = (f), desc, 1, diag } + [k] = { { (keyhandler_fn_t*)f }, desc, 1, diag } IRQ_KEYHANDLER('A', do_toggle_alt_key, "toggle alternative key
handling", 0),
IRQ_KEYHANDLER('d', dump_registers, "dump registers", 1),
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 24.09.15 at 14:09, <[email protected]> wrote:
This appears to work for me.
Looks okay with ...
xen/common/keyhandler.c line 49
Quoted 12 lines
xen/common/keyhandler.c +2
-2@@ -43,10 +43,10 @@ } key_table[128] __read_mostly = {#define KEYHANDLER (k, f, desc, diag) \ - [k] = { .fn = (f), desc, 0, diag } + [k] = { { f }, desc, 0, diag }#define IRQ_KEYHANDLER (k, f, desc, diag) \ - [k] = { .irq_fn = (f), desc, 1, diag } + [k] = { { (keyhandler_fn_t*)f }, desc, 1, diag }
... parenthesizes added around f and a blank put ahead of the * here.
Jan