From: David Woodhouse <dwmw2@infradead.org>
To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Ani Sinha <anisinha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Peter Hilber <peter.hilber@opensynergy.com>,
"Mohamed Abuelfotoh, Hazem" <abuehaze@amazon.com>,
paul <paul@xen.org>
Subject: Re: [PATCH v4] hw/acpi: Add vmclock device
Date: Tue, 08 Oct 2024 12:21:52 +0100 [thread overview]
Message-ID: <686204bb375ddac471fd7c93863adc725bf4913b.camel@infradead.org> (raw)
In-Reply-To: <20241008120429.00000603@Huawei.com>
[-- Attachment #1: Type: text/plain, Size: 2954 bytes --]
On Tue, 2024-10-08 at 12:04 +0100, Jonathan Cameron wrote:
> On Mon, 07 Oct 2024 14:53:54 +0100
> David Woodhouse <dwmw2@infradead.org> wrote:
>
> >
> > + aml_append(dev, aml_name_decl("_HID",
> > aml_string("AMZNC10C")));
>
> Nice _HID :)
Can't take credit for that; it was mst's idea :)
> > + aml_append(dev, aml_name_decl("_CID", aml_string("VMCLOCK")));
> > + aml_append(dev, aml_name_decl("_DDN", aml_string("VMCLOCK")));
> > +
> > + /* Simple status method */
> > + method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> > + addr = aml_local(0);
> > + aml_append(method, aml_store(aml_int(0xf), addr));
> > + aml_append(method, aml_return(addr));
> > + aml_append(dev, method);
>
> It's static so you should be able to do:
> aml_append(dev, aml_name_decl("_STA", aml_int(0xf)));
Thanks. Tested and pushed to
https://git.infradead.org/users/dwmw2/qemu.git/shortlog/refs/heads/vmclock
>
> > +static Property vmclock_device_properties[] = {
> > + DEFINE_PROP_END_OF_LIST(),
> > +};
> > +
> > +static void vmclock_device_class_init(ObjectClass *klass, void *data)
> > +{
> > + DeviceClass *dc = DEVICE_CLASS(klass);
> > +
> > + dc->vmsd = &vmstate_vmclock;
> > + dc->realize = vmclock_realize;
> > + device_class_set_props(dc, vmclock_device_properties);
>
> Probably a silly question but why register no properties?
> Is that any different to not registering them?
> + a quick look suggests not all class_init functions
> set them.
They'll be used in the future. Phase 1 of the VMCLOCK device just
signals *disruption* to guests, so they know that their clocks are
wrong immediately after migration and they have to resync before
performing any operations that require accurate time.
Phase 2 will advertise the current time (based on the TSC of the new
host) directly to the guest. That's when it'll need a little more
setup.
So when I copied the boilerplate from vmgenid I just ripped out the
actual UUID property, not the whole setup.
For now I've just been testing the guest side with this hack, FWIW:
--- a/hw/acpi/vmclock.c
+++ b/hw/acpi/vmclock.c
@@ -151,6 +151,18 @@ static void vmclock_realize(DeviceState *dev,
Error **errp)
qemu_register_reset(vmclock_handle_reset, vms);
+ vms->clk->time_type = VMCLOCK_TIME_TAI;
+ vms->clk->flags = VMCLOCK_FLAG_TAI_OFFSET_VALID;
+ vms->clk->tai_offset_sec = -3600;
+ vms->clk->clock_status = VMCLOCK_STATUS_SYNCHRONIZED;
+ vms->clk->counter_value = 0;
+ vms->clk->counter_id = VMCLOCK_COUNTER_X86_TSC;
+ vms->clk->time_sec = 1704067200;
+ vms->clk->time_frac_sec = 0x8000000000000000ULL;
+ vms->clk->counter_period_frac_sec = 0x1a6e39b3e0ULL;
+ vms->clk->counter_period_shift = 4;
+ //vms->clk->counter_period_frac_sec = 0x1934c67f9b2ce6ULL;
+
vmclock_update_guest(vms);
}
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]
prev parent reply other threads:[~2024-10-08 11:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 13:53 [PATCH v4] hw/acpi: Add vmclock device David Woodhouse
2024-10-08 11:04 ` Jonathan Cameron via
2024-10-08 11:21 ` David Woodhouse [this message]
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=686204bb375ddac471fd7c93863adc725bf4913b.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=Jonathan.Cameron@Huawei.com \
--cc=abuehaze@amazon.com \
--cc=anisinha@redhat.com \
--cc=eduardo@habkost.net \
--cc=imammedo@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=peter.hilber@opensynergy.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 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).