From patchwork Fri May 31 01:58:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenbaodong X-Patchwork-Id: 10969449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1798B6C5 for ; Fri, 31 May 2019 02:00:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 089B828726 for ; Fri, 31 May 2019 02:00:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F138428C68; Fri, 31 May 2019 02:00:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DCA7E28726 for ; Fri, 31 May 2019 02:00:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hWWoX-0007E3-Nu; Fri, 31 May 2019 01:58:37 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hWWoW-0007Dy-9A for xen-devel@lists.xenproject.org; Fri, 31 May 2019 01:58:36 +0000 X-Inumbo-ID: 97ecdd25-8347-11e9-8980-bc764e045a96 Received: from mxnavi-mail.mxnavi.com (unknown [116.90.87.199]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 97ecdd25-8347-11e9-8980-bc764e045a96; Fri, 31 May 2019 01:58:34 +0000 (UTC) Received: from localhost.localdomain (61.161.186.150) by mxnavi-mail.mxnavi.com (116.90.87.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 31 May 2019 09:56:19 +0800 From: Baodong Chen To: Date: Fri, 31 May 2019 09:58:00 +0800 Message-ID: <1559267880-27863-1-git-send-email-chenbaodong@mxnavi.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [61.161.186.150] X-ClientProxiedBy: mxnavi-mail.mxnavi.com (116.90.87.199) To mxnavi-mail.mxnavi.com (116.90.87.199) Subject: [Xen-devel] [PATCH] xen: make keyhanler configurable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Baodong Chen , Dario Faggioli , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP keyhandler mainly used for debug usage by developers which can dump xen module(eg. timer, scheduler) status at runtime by input character from console. Signed-off-by: Baodong Chen --- xen/arch/arm/gic.c | 2 ++ xen/arch/x86/apic.c | 2 ++ xen/common/Kconfig | 9 +++++++++ xen/common/Makefile | 2 +- xen/common/cpupool.c | 2 ++ xen/common/schedule.c | 2 ++ xen/include/xen/keyhandler.h | 14 ++++++++++++++ xen/include/xen/lib.h | 2 ++ xen/include/xen/sched.h | 2 ++ 9 files changed, 36 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 6cc7dec..fff88c5 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -361,7 +361,9 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi) /* Nothing to do, will check for events on return path */ break; case GIC_SGI_DUMP_STATE: +#ifdef CONFIG_HAS_KEYHANDLER dump_execstate(regs); +#endif break; case GIC_SGI_CALL_FUNCTION: smp_call_function_interrupt(); diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index fafc0bd..e5f004a 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -1410,7 +1410,9 @@ void spurious_interrupt(struct cpu_user_regs *regs) ack_APIC_irq(); if (this_cpu(state_dump_pending)) { this_cpu(state_dump_pending) = false; +#ifdef CONFIG_HAS_KEYHANDLER dump_execstate(regs); +#endif return; } } diff --git a/xen/common/Kconfig b/xen/common/Kconfig index c838506..450541c 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -368,4 +368,13 @@ config DOM0_MEM Leave empty if you are not sure what to specify. +config HAS_KEYHANDLER + bool "Enable/Disable keyhandler" + default y + ---help--- + Enable or disable keyhandler function. + keyhandler mainly used for debug usage by developers which can dump + xen module(eg. timer, scheduler) status at runtime by input character + from console. + endmenu diff --git a/xen/common/Makefile b/xen/common/Makefile index bca48e6..c7bcd26 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -16,7 +16,7 @@ obj-y += guestcopy.o obj-bin-y += gunzip.init.o obj-y += irq.o obj-y += kernel.o -obj-y += keyhandler.o +obj-$(CONFIG_HAS_KEYHANDLER) += keyhandler.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC) += kimage.o obj-y += lib.o diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index 31ac323..721a729 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -699,6 +699,7 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) return ret; } +#ifdef CONFIG_HAS_KEYHANDLER void dump_runq(unsigned char key) { unsigned long flags; @@ -730,6 +731,7 @@ void dump_runq(unsigned char key) local_irq_restore(flags); spin_unlock(&cpupool_lock); } +#endif static int cpu_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 66f1e26..617c444 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1913,6 +1913,7 @@ void scheduler_free(struct scheduler *sched) xfree(sched); } +#ifdef CONFIG_HAS_KEYHANDLER void schedule_dump(struct cpupool *c) { unsigned int i; @@ -1941,6 +1942,7 @@ void schedule_dump(struct cpupool *c) SCHED_OP(sched, dump_cpu_state, i); } } +#endif void sched_tick_suspend(void) { diff --git a/xen/include/xen/keyhandler.h b/xen/include/xen/keyhandler.h index 5131e86..1050b80 100644 --- a/xen/include/xen/keyhandler.h +++ b/xen/include/xen/keyhandler.h @@ -28,6 +28,7 @@ struct cpu_user_regs; typedef void (irq_keyhandler_fn_t)(unsigned char key, struct cpu_user_regs *regs); +#ifdef CONFIG_HAS_KEYHANDLER /* Initialize keytable with default handlers. */ void initialize_keytable(void); @@ -48,4 +49,17 @@ void register_irq_keyhandler(unsigned char key, /* Inject a keypress into the key-handling subsystem. */ extern void handle_keypress(unsigned char key, struct cpu_user_regs *regs); +#else +static inline void initialize_keytable(void) {} +static inline void register_keyhandler(unsigned char key, keyhandler_fn_t *fn, + const char *desc, bool_t diagnostic) {} +static inline void register_irq_keyhandler(unsigned char key, + irq_keyhandler_fn_t *fn, + const char *desc, + bool_t diagnostic) {} + +static inline void handle_keypress(unsigned char key, + struct cpu_user_regs *regs) {} +#endif + #endif /* __XEN_KEYHANDLER_H__ */ diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index e0b7bcb..8710305 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -171,8 +171,10 @@ extern unsigned int tainted; extern char *print_tainted(char *str); extern void add_taint(unsigned int taint); +#ifdef CONFIG_HAS_KEYHANDLER struct cpu_user_regs; void dump_execstate(struct cpu_user_regs *); +#endif void init_constructors(void); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 748bb0f..b82cdee 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -994,8 +994,10 @@ int cpupool_add_domain(struct domain *d, int poolid); void cpupool_rm_domain(struct domain *d); int cpupool_move_domain(struct domain *d, struct cpupool *c); int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op); +#ifdef CONFIG_HAS_KEYHANDLER void schedule_dump(struct cpupool *c); extern void dump_runq(unsigned char key); +#endif void arch_do_physinfo(struct xen_sysctl_physinfo *pi);