WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Re: 2.6.39 crashes BUG: unable to handle kernel NULL poi

To: John Stultz <john.stultz@xxxxxxxxxx>
Subject: Re: [Xen-devel] Re: 2.6.39 crashes BUG: unable to handle kernel NULL pointer dereference at 000000000000042 .. cmos_checkintr+0x4d/0x55 under Xen as PV guest.
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Fri, 25 Mar 2011 08:21:39 -0400
Cc: tglx@xxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
Delivery-date: Fri, 25 Mar 2011 05:23:03 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1300999174.848.122.camel@work-vm>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20110318203830.GA9262@xxxxxxxxxxxx> <1300485566.2731.46.camel@work-vm> <20110319025134.GA3298@xxxxxxxxxxxx> <1300736400.2731.66.camel@work-vm> <20110322143841.GA26952@xxxxxxxxxxxx> <20110324122755.GA31974@xxxxxxxxxxxx> <1300993535.848.110.camel@work-vm> <1300999174.848.122.camel@work-vm>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
On Thu, Mar 24, 2011 at 01:39:34PM -0700, John Stultz wrote:
> On Thu, 2011-03-24 at 12:05 -0700, John Stultz wrote:
> > Or... more likely, the added rtc_set_alarm is enabling interrupts,
> > allowing an irq to land before the rtc_device_register completes.
> > 
> > Oof.. ok. so that is a little gross.
> > 
> > 
> > Let me see if I can't work something out here.
> 
> Konrad: Can you give this patch a shot to see if it changes the
> behavior?

Yup. It fixes it. Tested on PV i386 and x86_64 case. And also
as the initial domain as 32-bit and 64-bit.

Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>

Thank you for fixing it!
> 
> Basically we still initialize the alarm timer from whatever the hardware
> is set to at boot time, but don't use the standard rtc_set_alarm, and
> instead initialize the aie_timer and enqueue it by hand.
> 
> That should avoid having rtc_set_alarm enabling irqs possibly too early.
> 
> thanks
> -john
> 
> 
> 
> Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx>
> 
> diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
> index 09b4437..3901386 100644
> --- a/drivers/rtc/class.c
> +++ b/drivers/rtc/class.c
> @@ -171,7 +171,7 @@ struct rtc_device *rtc_device_register(const char *name, 
> struct device *dev,
>       err = __rtc_read_alarm(rtc, &alrm);
>  
>       if (!err && !rtc_valid_tm(&alrm.time))
> -             rtc_set_alarm(rtc, &alrm);
> +             rtc_initialize_alarm(rtc, &alrm);
>  
>       strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE);
>       dev_set_name(&rtc->dev, "rtc%d", id);
> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> index 8ec6b06..b2fea80 100644
> --- a/drivers/rtc/interface.c
> +++ b/drivers/rtc/interface.c
> @@ -375,6 +375,32 @@ int rtc_set_alarm(struct rtc_device *rtc, struct 
> rtc_wkalrm *alarm)
>  }
>  EXPORT_SYMBOL_GPL(rtc_set_alarm);
>  
> +/* Called once per device from rtc_device_register */
> +int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
> +{
> +     int err;
> +
> +     err = rtc_valid_tm(&alarm->time);
> +     if (err != 0)
> +             return err;
> +
> +     err = mutex_lock_interruptible(&rtc->ops_lock);
> +     if (err)
> +             return err;
> +
> +     rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time);
> +     rtc->aie_timer.period = ktime_set(0, 0);
> +     if (alarm->enabled) {
> +             rtc->aie_timer.enabled = 1;
> +             timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node);
> +     }
> +     mutex_unlock(&rtc->ops_lock);
> +     return err;
> +}
> +EXPORT_SYMBOL_GPL(rtc_initialize_alarm);
> +
> +
> +
>  int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
>  {
>       int err = mutex_lock_interruptible(&rtc->ops_lock);
> diff --git a/include/linux/rtc.h b/include/linux/rtc.h
> index 2ca7e8a..877ece4 100644
> --- a/include/linux/rtc.h
> +++ b/include/linux/rtc.h
> @@ -228,6 +228,8 @@ extern int rtc_read_alarm(struct rtc_device *rtc,
>                       struct rtc_wkalrm *alrm);
>  extern int rtc_set_alarm(struct rtc_device *rtc,
>                               struct rtc_wkalrm *alrm);
> +extern int rtc_initialize_alarm(struct rtc_device *rtc,
> +                             struct rtc_wkalrm *alrm);
>  extern void rtc_update_irq(struct rtc_device *rtc,
>                       unsigned long num, unsigned long events);
>  
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>