From: Jan Beulich <jbeulich@suse.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Teddy Astie <teddy.astie@vates.tech>,
Oleksii Kurochko <oleksii.kurochko@gmail.com>
Subject: Re: [PATCH for-4.22 3/5] x86/vRTC: support century field
Date: Fri, 15 May 2026 08:52:03 +0200 [thread overview]
Message-ID: <242237a9-6b9e-4580-8936-aa61be6b0636@suse.com> (raw)
In-Reply-To: <agTTtrSm1tBnBGK9@macbook.local>
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. Somebody would need to
artificially change time across century boundaries for this to become
noticeable. (Note that this aspect is different for alarm date/month: If
either of those fields was in use, backwards migration indeed needs to
fail.)
Jan
next prev parent reply other threads:[~2026-05-15 6:52 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 14:57 [PATCH 0/5] x86/time: CMOS RTC century byte Jan Beulich
2026-05-12 14:58 ` [PATCH for-4.22 1/5] x86/time: use RTC century byte when available Jan Beulich
2026-05-13 8:49 ` Roger Pau Monné
2026-05-13 10:36 ` Jan Beulich
2026-05-13 14:51 ` Roger Pau Monné
2026-05-13 15:08 ` Jan Beulich
2026-05-14 7:27 ` Oleksii Kurochko
2026-05-15 6:42 ` Jan Beulich
2026-05-12 14:59 ` [PATCH 2/5] x86/time: move BCD_TO_BIN() uses Jan Beulich
2026-05-13 8:56 ` Roger Pau Monné
2026-05-13 10:39 ` Jan Beulich
2026-05-13 14:58 ` Roger Pau Monné
2026-05-13 15:15 ` Jan Beulich
2026-05-13 19:08 ` Roger Pau Monné
2026-05-15 6:40 ` Jan Beulich
2026-05-12 14:59 ` [PATCH for-4.22 3/5] x86/vRTC: support century field Jan Beulich
2026-05-13 14:24 ` Roger Pau Monné
2026-05-13 14:58 ` Jan Beulich
2026-05-13 15:14 ` Roger Pau Monné
2026-05-13 15:24 ` Jan Beulich
2026-05-13 19:40 ` Roger Pau Monné
2026-05-15 6:52 ` Jan Beulich [this message]
2026-05-15 8:42 ` Roger Pau Monné
2026-05-15 8:48 ` Jan Beulich
2026-05-13 15:42 ` Jan Beulich
2026-05-12 15:00 ` [PATCH 4/5] x86/vRTC: use available macros for BCD <-> BIN conversion Jan Beulich
2026-05-13 14:39 ` Roger Pau Monné
2026-05-12 15:00 ` [PATCH 5/5] tools/xen-hvmctx: shorten various format strings a little Jan Beulich
2026-05-13 15:00 ` Roger Pau Monné
2026-05-15 9:32 ` Anthony PERARD
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=242237a9-6b9e-4580-8936-aa61be6b0636@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=oleksii.kurochko@gmail.com \
--cc=roger.pau@citrix.com \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.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.