Commit 572e6147 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: add locking to xtime accesses

do_timer must be called with xtime_lock held.  I'm not sure boot_timer_handler
needs this, however I don't think it hurts: it simply disables irq and takes a
spinlock.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6edb0862
...@@ -96,11 +96,15 @@ void time_init_kern(void) ...@@ -96,11 +96,15 @@ void time_init_kern(void)
void do_boot_timer_handler(struct sigcontext * sc) void do_boot_timer_handler(struct sigcontext * sc)
{ {
unsigned long flags;
struct pt_regs regs; struct pt_regs regs;
CHOOSE_MODE((void) (UPT_SC(&regs.regs) = sc), CHOOSE_MODE((void) (UPT_SC(&regs.regs) = sc),
(void) (regs.regs.skas.is_user = 0)); (void) (regs.regs.skas.is_user = 0));
write_seqlock_irqsave(&xtime_lock, flags);
do_timer(&regs); do_timer(&regs);
write_sequnlock_irqrestore(&xtime_lock, flags);
} }
static DEFINE_SPINLOCK(timer_spinlock); static DEFINE_SPINLOCK(timer_spinlock);
...@@ -125,15 +129,17 @@ irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs) ...@@ -125,15 +129,17 @@ irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
unsigned long long nsecs; unsigned long long nsecs;
unsigned long flags; unsigned long flags;
write_seqlock_irqsave(&xtime_lock, flags);
do_timer(regs); do_timer(regs);
write_seqlock_irqsave(&xtime_lock, flags);
nsecs = get_time() + local_offset; nsecs = get_time() + local_offset;
xtime.tv_sec = nsecs / NSEC_PER_SEC; xtime.tv_sec = nsecs / NSEC_PER_SEC;
xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC; xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC;
write_sequnlock_irqrestore(&xtime_lock, flags); write_sequnlock_irqrestore(&xtime_lock, flags);
return(IRQ_HANDLED); return IRQ_HANDLED;
} }
long um_time(int __user *tloc) long um_time(int __user *tloc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment