Module: xenomai-head
Branch: master
Commit: 3b0152276752561805bf113eaa7b699d93c473c5
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=3b0152276752561805bf113eaa7b699d93c473c5

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 |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/ksrc/arch/generic/hal.c b/ksrc/arch/generic/hal.c
index 4d2fd38..8a5ec39 100644
--- a/ksrc/arch/generic/hal.c
+++ b/ksrc/arch/generic/hal.c
@@ -822,6 +822,13 @@ int rthal_init(void)
      * 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;
     rthal_tunables.clock_freq = rthal_clockfreq_arg;


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

Reply via email to