Module: xenomai-2.4
Branch: master
Commit: 0f39ff9e83c72cab910a7b89cf4ce1b70183a489
URL:    
http://git.xenomai.org/?p=xenomai-2.4.git;a=commit;h=0f39ff9e83c72cab910a7b89cf4ce1b70183a489

Author: Bernhard Walle <bernh...@bwalle.de>
Date:   Sun Nov  8 10:18:26 2009 +0100

hal: check CPU frequency

In some conditions, while testing Xenomai in VirtualBox, I had the
error that xnarch_init_timeconv() is called from init_32.h with a
frequency of 0. That leads to a division by zero, followed by a system
oops.

Of course that is a bug in the virtualisation and Linux reports a CPU
frequency of 0 in /proc/cpuinfo. However, there's no harm if Xenomai
checks that instead of crashing the whole system.

Signed-off-by: Bernhard Walle <bernh...@bwalle.de>

---

 ksrc/arch/generic/hal.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ksrc/arch/generic/hal.c b/ksrc/arch/generic/hal.c
index dcb9a49..b17dcd6 100644
--- a/ksrc/arch/generic/hal.c
+++ b/ksrc/arch/generic/hal.c
@@ -788,8 +788,17 @@ int rthal_init(void)
     if (err)
         goto out;
 
-    /* The arch-dependent support must have updated the frequency args
-       as required. */
+    /*
+     * The arch-dependent support must have updated the various
+     * frequency args as required.
+     */
+
+    /* check the CPU frequency first and abort if it's invalid */
+    if (rthal_cpufreq_arg == 0) {
+        printk(KERN_ERR "Xenomai has detected a CPU frequency of 0. 
Aborting.\n");
+        return -ENODEV;
+    }
+
     rthal_tunables.cpu_freq = rthal_cpufreq_arg;
     rthal_tunables.timer_freq = rthal_timerfreq_arg;
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to