xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: John Stultz <john.stultz@linaro.org>
Cc: tglx@linutronix.de, xen-devel@lists.xensource.com,
	linux-kernel@vger.kernel.org
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.
Date: Fri, 25 Mar 2011 08:21:39 -0400	[thread overview]
Message-ID: <20110325122139.GA27651@dumpdata.com> (raw)
In-Reply-To: <1300999174.848.122.camel@work-vm>

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@oracle.com>

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@linaro.org>
> 
> 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);
>  
> 

  reply	other threads:[~2011-03-25 12:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18 20:38 2.6.39 crashes BUG: unable to handle kernel NULL pointer dereference at 000000000000042 .. cmos_checkintr+0x4d/0x55 under Xen as PV guest Konrad Rzeszutek Wilk
2011-03-18 21:59 ` John Stultz
2011-03-19  2:51   ` Konrad Rzeszutek Wilk
2011-03-21 19:40     ` John Stultz
2011-03-22 14:38       ` Konrad Rzeszutek Wilk
2011-03-24 12:27         ` [Xen-devel] " Konrad Rzeszutek Wilk
2011-03-24 19:05           ` John Stultz
2011-03-24 20:39             ` John Stultz
2011-03-25 12:21               ` Konrad Rzeszutek Wilk [this message]
2011-03-19  9:28   ` Richard Cochran

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=20110325122139.GA27651@dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=xen-devel@lists.xensource.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).