From: David Gibson <david@gibson.dropbear.id.au>
To: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH 3/5] target/ppc: Implement migration support for large decrementer
Date: Tue, 13 Jun 2017 16:20:26 +0800 [thread overview]
Message-ID: <20170613082026.GF30171@umbus> (raw)
In-Reply-To: <20170608070351.1434-4-sjitindarsingh@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5489 bytes --]
On Thu, Jun 08, 2017 at 05:03:49PM +1000, Suraj Jitindar Singh wrote:
> Implement support to migrate a guest which is using the large
> decrementer.
>
> We need to save the decrementer width to the migration stream.
> On incoming migration we then need to check that the hypervisor is
> capable of letting the guest use the large decrementer and that the
> decrementer width is the same on the receiving side. Since there is no
> way to tell the guest when the width of the decrementer changes we have
> to terminate if the decrementer width is not what the guest expects.
> If we can use the large decrementer then we have to tell the hypervisor
> to enable it.
>
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> ---
> hw/ppc/spapr.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
> include/hw/ppc/spapr.h | 1 +
> 2 files changed, 64 insertions(+)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 5d10366..6ba869a 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1420,6 +1420,45 @@ static bool spapr_vga_init(PCIBus *pci_bus, Error **errp)
> }
> }
>
> +static int spapr_import_large_decr_bits(sPAPRMachineState *spapr)
> +{
> + /*
> + * If the guest uses the large decrementer then this hypervisor must also
> + * support it and have the exact same width. We must also enable the large
> + * decrementer because we have no way to tell the guest to stop using it.
> + */
> + if (spapr->large_decr_bits) {
> + uint32_t dec_bits = 32;
> + PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
> + CPUState *cs = CPU(cpu);
> + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);
> +
> + if (kvm_enabled()) {
> + if (!kvmppc_has_cap_large_decr()) {
> + error_report("Host doesn't support large decrementer and guest requires it");
> + return -EINVAL;
> + }
> + dec_bits = kvmppc_get_dec_bits();
> + } else {
> + dec_bits = pcc->large_decr_bits;
> + }
> +
> + if (spapr->large_decr_bits != dec_bits) {
> + error_report("Host large decrementer size [%u] doesn't match what guest expects [%u]",
> + dec_bits, spapr->large_decr_bits);
> + return -EINVAL;
> + }
Could you just use a VMSTATE_EQUAL() rather than explicit post_load logic?
> +
> + if (kvm_enabled()) {
> + CPU_FOREACH(cs) {
> + kvmppc_configure_large_decrementer(cs, true);
> + }
> + }
> + }
> +
> + return 0;
> +}
> +
> static int spapr_post_load(void *opaque, int version_id)
> {
> sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;
> @@ -1439,8 +1478,13 @@ static int spapr_post_load(void *opaque, int version_id)
> * value into the RTC device */
> if (version_id < 3) {
> err = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
> + if (err) {
> + return err;
> + }
> }
>
> + err = spapr_import_large_decr_bits(spapr);
> +
> return err;
> }
>
> @@ -1529,6 +1573,24 @@ static const VMStateDescription vmstate_spapr_patb_entry = {
> },
> };
>
> +static bool spapr_large_decr_entry_needed(void *opaque)
> +{
> + sPAPRMachineState *spapr = opaque;
> +
> + return !!spapr->large_decr_bits;
Hrm. We have no existing releases - upstream or down - that support
POWER9, which is the first thing with large decr. Rather than fancy
conditional logic, could we just always transfer the decr size for
POWER9?
Do we need to support qemu on POWER9 with a pre-large-decr host
kernel? Or is POWER9 support new enough that we can just say that you
require a host kernel with large decr support to run POWER9 guests.
That could simplify several things.
> +}
> +
> +static const VMStateDescription vmstate_spapr_large_decr_entry = {
> + .name = "spapr_large_decr_entry",
> + .version_id = 1,
> + .minimum_version_id = 1,
> + .needed = spapr_large_decr_entry_needed,
> + .fields = (VMStateField[]) {
> + VMSTATE_UINT32(large_decr_bits, sPAPRMachineState),
> + VMSTATE_END_OF_LIST()
> + },
> +};
> +
> static const VMStateDescription vmstate_spapr = {
> .name = "spapr",
> .version_id = 3,
> @@ -1547,6 +1609,7 @@ static const VMStateDescription vmstate_spapr = {
> .subsections = (const VMStateDescription*[]) {
> &vmstate_spapr_ov5_cas,
> &vmstate_spapr_patb_entry,
> + &vmstate_spapr_large_decr_entry,
> NULL
> }
> };
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index 98fb78b..4ba9b89 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -91,6 +91,7 @@ struct sPAPRMachineState {
> sPAPROptionVector *ov5_cas; /* negotiated (via CAS) option vectors */
> bool cas_reboot;
> bool cas_legacy_guest_workaround;
> + uint32_t large_decr_bits; /* Large decrementer width (0 -> not in use) */
Having this here as well as in the CPU class seems a bit icky.
> Notifier epow_notifier;
> QTAILQ_HEAD(, sPAPREventLogEntry) pending_events;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-06-13 8:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 7:03 [Qemu-devel] [PATCH 0/5] target/ppc: Implement support for the Large Decrementer Suraj Jitindar Singh
2017-06-08 7:03 ` [Qemu-devel] [PATCH 1/5] target/ppc: Implement large decrementer support for TCG Suraj Jitindar Singh
2017-06-13 7:50 ` David Gibson
2017-06-08 7:03 ` [Qemu-devel] [PATCH 2/5] target/ppc: Implement large decrementer support for KVM Suraj Jitindar Singh
2017-06-13 8:15 ` David Gibson
2017-06-08 7:03 ` [Qemu-devel] [PATCH 3/5] target/ppc: Implement migration support for large decrementer Suraj Jitindar Singh
2017-06-13 8:20 ` David Gibson [this message]
2017-06-08 7:03 ` [Qemu-devel] [PATCH 4/5] target/ppc: Enable the large decrementer for TCG and KVM guests Suraj Jitindar Singh
2017-06-08 7:03 ` [Qemu-devel] [PATCH 5/5] target/ppc: Add cmd line option to disable the large decrementer Suraj Jitindar Singh
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=20170613082026.GF30171@umbus \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sjitindarsingh@gmail.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).