From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 3/3] DO NOT APPLY - debugging code for gpf when accessing invalid per_cpu() data Date: Thu, 26 Sep 2013 10:49:26 +0100 Message-ID: <1380188966-26665-4-git-send-email-andrew.cooper3@citrix.com> References: <1380188966-26665-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1380188966-26665-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper List-Id: xen-devel@lists.xenproject.org --- xen/common/schedule.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 1ddfb22..8b17555 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -36,6 +36,7 @@ #include #include #include +#include /* opt_sched: scheduler - default to credit */ static char __initdata opt_sched[10] = "credit"; @@ -1529,6 +1530,30 @@ void wait(void) #include "compat/schedule.c" #endif +static void percpu_gpf(unsigned char key) +{ + unsigned int cpu = NR_CPUS - 1; + printk("'%c' pressed -> Looking up schedule lock for cpu %d\n", key, cpu); + + if ( spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock) ) + printk("It is locked\n"); + else + printk("It is unlocked\n"); +} + +static struct keyhandler percpu_gpf_keyhandler = { + .diagnostic = 1, + .u.fn = percpu_gpf, + .desc = "per-cpu gpf test" +}; + +static int __init percpu_gpf_key_init(void) +{ + register_keyhandler('1', &percpu_gpf_keyhandler); + return 0; +} +__initcall(percpu_gpf_key_init); + #endif /* !COMPAT */ /* -- 1.7.10.4