[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.22 3/5] x86/vRTC: support century field


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 15 May 2026 10:42:39 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xE+sBv0E4K0Fx/gpv5zy0k/b/MMzyXvI87ZlKR8nbz0=; b=aLPCQcwDPpvvq5ynwRUlupp8NTkEBKVZgcUcBtDlB7dZX7DZJ/s78LD/Q9RTH9iR6+EiD9MUVJERh14074YOMI/yBEIcFXVzZ469O1cED7/Q4SehV6hBNMp0w7hiqrUnJJJIKHRmf2eJBkNRBVNPK48gp6G7KbAmWeSCfbLQxE3+USZqZ83POV1g76N7S9/NVi6C10NABOObkftnQnsnuNgJh14+2RO4ApL1KtwplzYnHHYm5hWcxTPBsZWWpIaDljr2ULs3PPgYhECrlQIuVlcYUAPvr6DE8IP1Bpxvaf5OEtoPd1gkRixi2zBoKDGof1G3NImzOPQH6k1Sms0aEA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iMd/0yQLB/Ccq+Yz1CzdP2bY80Kp9fJJ4auiRd8ZbjPhk5oEL/WLSAoPUaXN4IQlNPfvE7hyu6XB45zAi1utEojOrFk90rgpl4P/pZAlUWIDnFs6h5PPpnaIER/b+NONBI773n139/Ug8h94XpVavaLXLqhwNy7y3yIN4PKIz0gFL54SjZhkNXZzL+l5wMYECG8QkpLkx6wgAMmtj/clnKxBLtNXvtTbd7JZW1xDFtXK93DAMC/Pp6uRW/JbtbghHKMQwqhdxVwm44O+ojiwG78LAQvRFnXQGSg5yaTwRFEdLGQq+9HUA963FjNiPXAqEJz24NjoAwFd5LJPuMknmA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • Delivery-date: Fri, 15 May 2026 08:42:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, May 15, 2026 at 08:52:03AM +0200, Jan Beulich wrote:
> On 13.05.2026 21:40, Roger Pau Monné wrote:
> > On Wed, May 13, 2026 at 05:24:13PM +0200, Jan Beulich wrote:
> >> On 13.05.2026 17:14, Roger Pau Monné wrote:
> >>> On Wed, May 13, 2026 at 04:58:57PM +0200, Jan Beulich wrote:
> >>>> On 13.05.2026 16:24, Roger Pau Monné wrote:
> >>>>> On Tue, May 12, 2026 at 04:59:35PM +0200, Jan Beulich wrote:
> >>>>>> @@ -515,7 +538,10 @@ static int rtc_ioport_write(void *opaque
> >>>>>>              /* Fetch the current time and update just this field. */
> >>>>>>              s->current_tm = gmtime(get_localtime(d));
> >>>>>>              rtc_copy_date(s);
> >>>>>> -            s->hw.cmos_data[s->hw.cmos_index] = data;
> >>>>>> +            if ( s->hw.cmos_index != RTC_CENTURY )
> >>>>>> +                s->hw.cmos_data[s->hw.cmos_index] = data;
> >>>>>> +            else
> >>>>>> +                s->hw.century = data;
> >>>>>>              rtc_set_time(s);
> >>>>>>          }
> >>>>>>          alarm_timer_update(s);
> >>>>>
> >>>>> Don't you need to adjust the tail return of rtc_ioport_write() (below
> >>>>> the context here) to return 0 when s->hw.cmos_index == RTC_CENTURY, so
> >>>>> the set value is also propagated to the DM, and not only the index?
> >>>>
> >>>> I don't think so. The case of us not handling RTC_CENTURY is dealt with
> >>>> earlier in the function. Whereas when we handle the field, we don't want
> >>>> to forward (like for all the other RTC fields).
> >>>
> >>> Right, so then you also want to adjust the top part of
> >>> rtc_ioport_write() to not propagate the write to the 0x70 IO port when
> >>> data is RTC_CENTURY?  Otherwise you propagate the write to port 0x70,
> >>> but not the read/write to port 0x71?
> >>
> >> I can't, as whether to forward depends on the data subsequently written.
> >> Propagating the index "just in case" is the only workable model that I
> >> can think of. And as guests can do any number of successive port 70
> >> writes, the DM needs to cope with this anyway.
> > 
> > Hm, I see, the newly written value to port 0x71 is taken into account
> > to decide whether to forward to the DM or not.
> > 
> > I wonder: would it be simpler to extend the size of the hvm_hw_rtc
> > structure so that Xen can detect whether the incoming VM has support
> > for the century field, and then avoid having to play heuristics
> > with the value itself?
> 
> It would surely be possible (and we may need to do so anyway for the alarm
> date/month fields), but I wanted to get away without doing so here. And it
> seemed pretty reasonable to leverage the padding field for this.
> 
> >  We would know ahead of starting the guest
> > whether RTC_CENTURY is supposed to be handled by Xen or forwarded to
> > the DM, and we won't be limited to use 0 as the sentinel value for not
> > exposing RTC_CENTURY.
> 
> These are the positive aspects. The negative one is that "backwards"
> migration would break with the larger record size. Whereas with the padding
> field used, it won't: The guest likely won't notice that the value at 0x32
> isn't updated anymore, i.e. stays at value 20.

Sorry, maybe I'm confused, but when migrating backwards the access
won't be handled by Xen anymore, and hence we don't know what it would
return, it's up to the catch-all device model.  I don't think it's
safe to migrate backwards, as the century value won't be preserved
correctly.  IOW: we might want to actively prevent such scenario?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.