All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: xenomai-core <xenomai@xenomai.org>
Subject: [Xenomai-core] [PATCH] x86: Fix race in rthal_timer_request
Date: Mon, 23 Feb 2009 16:12:51 +0100	[thread overview]
Message-ID: <49A2BCF3.40901@domain.hid> (raw)

There is a tiny race window between requesting a tick device, which
includes obtaining its frequency, and transferring that value to
rthal_tunables.timer_freq. Close it by passing a reference to the
latter to ipipe_request_tickdev. For older kernels, set the frequency
before calling into ipipe_request_tickdev.

Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---

 ksrc/arch/x86/hal-common.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ksrc/arch/x86/hal-common.c b/ksrc/arch/x86/hal-common.c
index 19637b4..5adeae3 100644
--- a/ksrc/arch/x86/hal-common.c
+++ b/ksrc/arch/x86/hal-common.c
@@ -111,7 +111,7 @@ int rthal_timer_request(
 			 struct clock_event_device *cdev),
 	int cpu)
 {
-	unsigned long tmfreq;
+	unsigned long dummy, *tmfreq = &dummy;
 	int tickval, err, res;
 
 	if (cpu_timers_requested == 0) {
@@ -124,13 +124,16 @@ int rthal_timer_request(
 
 	/* This code works both for UP+LAPIC and SMP configurations. */
 
+	if (rthal_timerfreq_arg == 0)
+		tmfreq = &rthal_tunables.timer_freq;
+
 #ifdef __IPIPE_FEATURE_REQUEST_TICKDEV
 	res = ipipe_request_tickdev("lapic", mode_emul, tick_emul, cpu,
-				    &tmfreq);
+				    tmfreq);
 #else
+	*tmfreq = RTHAL_COMPAT_TIMERFREQ;
 	res = ipipe_request_tickdev("lapic", (compat_emumode_t)mode_emul,
 				    (compat_emutick_t)tick_emul, cpu);
-	tmfreq = RTHAL_COMPAT_TIMERFREQ;
 #endif
 
 	switch (res) {
@@ -162,9 +165,6 @@ int rthal_timer_request(
 	}
 	rthal_ktimer_saved_mode = res;
 
-	if (rthal_timerfreq_arg == 0)
-		rthal_tunables.timer_freq = tmfreq;
-
 	/*
 	 * The rest of the initialization should only be performed
 	 * once by a single CPU.


                 reply	other threads:[~2009-02-23 15:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49A2BCF3.40901@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.