From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, patches@linaro.org,
Juan Quintela <quintela@redhat.com>,
Shannon Zhao <zhaoshenglong@huawei.com>,
Shannon Zhao <shannon.zhaosl@gmail.com>
Subject: Re: [Qemu-devel] [PATCH for-3.0 v2 5/5] hw/intc/arm_gicv3_common: Move gicd shift bug handling to gicv3_post_load
Date: Mon, 6 Aug 2018 16:39:25 +0100 [thread overview]
Message-ID: <20180806153925.GF2473@work-vm> (raw)
In-Reply-To: <20180806123445.1459-6-peter.maydell@linaro.org>
* Peter Maydell (peter.maydell@linaro.org) wrote:
> The code currently in gicv3_gicd_no_migration_shift_bug_post_load()
> that handles migration from older QEMU versions with a particular
> bug is misplaced. We need to run this after migration in all cases,
> not just the cases where the "arm_gicv3/gicd_no_migration_shift_bug"
> subsection is present, so it must go in a post_load hook for the
> top level VMSD, not for the subsection. Move it.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> hw/intc/arm_gicv3_common.c | 77 ++++++++++++++++++--------------------
> 1 file changed, 37 insertions(+), 40 deletions(-)
>
> diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
> index 8175889f1e7..52480c3b4cf 100644
> --- a/hw/intc/arm_gicv3_common.c
> +++ b/hw/intc/arm_gicv3_common.c
> @@ -29,6 +29,41 @@
> #include "hw/arm/linux-boot-if.h"
> #include "sysemu/kvm.h"
>
> +
> +static void gicv3_gicd_no_migration_shift_bug_post_load(GICv3State *cs)
> +{
> + if (cs->gicd_no_migration_shift_bug) {
> + return;
> + }
> +
> + /* Older versions of QEMU had a bug in the handling of state save/restore
> + * to the KVM GICv3: they got the offset in the bitmap arrays wrong,
> + * so that instead of the data for external interrupts 32 and up
> + * starting at bit position 32 in the bitmap, it started at bit
> + * position 64. If we're receiving data from a QEMU with that bug,
> + * we must move the data down into the right place.
> + */
> + memmove(cs->group, (uint8_t *)cs->group + GIC_INTERNAL / 8,
> + sizeof(cs->group) - GIC_INTERNAL / 8);
> + memmove(cs->grpmod, (uint8_t *)cs->grpmod + GIC_INTERNAL / 8,
> + sizeof(cs->grpmod) - GIC_INTERNAL / 8);
> + memmove(cs->enabled, (uint8_t *)cs->enabled + GIC_INTERNAL / 8,
> + sizeof(cs->enabled) - GIC_INTERNAL / 8);
> + memmove(cs->pending, (uint8_t *)cs->pending + GIC_INTERNAL / 8,
> + sizeof(cs->pending) - GIC_INTERNAL / 8);
> + memmove(cs->active, (uint8_t *)cs->active + GIC_INTERNAL / 8,
> + sizeof(cs->active) - GIC_INTERNAL / 8);
> + memmove(cs->edge_trigger, (uint8_t *)cs->edge_trigger + GIC_INTERNAL / 8,
> + sizeof(cs->edge_trigger) - GIC_INTERNAL / 8);
> +
> + /*
> + * While this new version QEMU doesn't have this kind of bug as we fix it,
> + * so it needs to set the flag to true to indicate that and it's necessary
> + * for next migration to work from this new version QEMU.
> + */
> + cs->gicd_no_migration_shift_bug = true;
> +}
> +
> static int gicv3_pre_save(void *opaque)
> {
> GICv3State *s = (GICv3State *)opaque;
> @@ -46,6 +81,8 @@ static int gicv3_post_load(void *opaque, int version_id)
> GICv3State *s = (GICv3State *)opaque;
> ARMGICv3CommonClass *c = ARM_GICV3_COMMON_GET_CLASS(s);
>
> + gicv3_gicd_no_migration_shift_bug_post_load(s);
> +
> if (c->post_load) {
> c->post_load(s);
> }
> @@ -161,45 +198,6 @@ static int gicv3_pre_load(void *opaque)
> return 0;
> }
>
> -static int gicv3_gicd_no_migration_shift_bug_post_load(void *opaque,
> - int version_id)
> -{
> - GICv3State *cs = opaque;
> -
> - if (cs->gicd_no_migration_shift_bug) {
> - return 0;
> - }
> -
> - /* Older versions of QEMU had a bug in the handling of state save/restore
> - * to the KVM GICv3: they got the offset in the bitmap arrays wrong,
> - * so that instead of the data for external interrupts 32 and up
> - * starting at bit position 32 in the bitmap, it started at bit
> - * position 64. If we're receiving data from a QEMU with that bug,
> - * we must move the data down into the right place.
> - */
> - memmove(cs->group, (uint8_t *)cs->group + GIC_INTERNAL / 8,
> - sizeof(cs->group) - GIC_INTERNAL / 8);
> - memmove(cs->grpmod, (uint8_t *)cs->grpmod + GIC_INTERNAL / 8,
> - sizeof(cs->grpmod) - GIC_INTERNAL / 8);
> - memmove(cs->enabled, (uint8_t *)cs->enabled + GIC_INTERNAL / 8,
> - sizeof(cs->enabled) - GIC_INTERNAL / 8);
> - memmove(cs->pending, (uint8_t *)cs->pending + GIC_INTERNAL / 8,
> - sizeof(cs->pending) - GIC_INTERNAL / 8);
> - memmove(cs->active, (uint8_t *)cs->active + GIC_INTERNAL / 8,
> - sizeof(cs->active) - GIC_INTERNAL / 8);
> - memmove(cs->edge_trigger, (uint8_t *)cs->edge_trigger + GIC_INTERNAL / 8,
> - sizeof(cs->edge_trigger) - GIC_INTERNAL / 8);
> -
> - /*
> - * While this new version QEMU doesn't have this kind of bug as we fix it,
> - * so it needs to set the flag to true to indicate that and it's necessary
> - * for next migration to work from this new version QEMU.
> - */
> - cs->gicd_no_migration_shift_bug = true;
> -
> - return 0;
> -}
> -
> static bool needed_always(void *opaque)
> {
> return true;
> @@ -210,7 +208,6 @@ const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
> .version_id = 1,
> .minimum_version_id = 1,
> .needed = needed_always,
> - .post_load = gicv3_gicd_no_migration_shift_bug_post_load,
> .fields = (VMStateField[]) {
> VMSTATE_BOOL(gicd_no_migration_shift_bug, GICv3State),
> VMSTATE_END_OF_LIST()
> --
> 2.17.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2018-08-06 15:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-06 12:34 [Qemu-devel] [PATCH for-3.0 v2 0/5] Arm migration fixes for 3.0 Peter Maydell
2018-08-06 12:34 ` [Qemu-devel] [PATCH for-3.0 v2 1/5] hw/intc/arm_gicv3_common: Give no-migration-shift-bug subsection a needed function Peter Maydell
2018-08-07 14:34 ` Juan Quintela
2018-08-06 12:34 ` [Qemu-devel] [PATCH for-3.0 v2 2/5] hw/intc/arm_gicv3_common: Combine duplicate .subsections in vmstate_gicv3_cpu Peter Maydell
2018-08-07 14:34 ` Juan Quintela
2018-08-06 12:34 ` [Qemu-devel] [PATCH for-3.0 v2 3/5] target/arm: Add dummy needed functions to M profile vmstate subsections Peter Maydell
2018-08-07 14:40 ` Juan Quintela
2018-08-07 14:45 ` Peter Maydell
2018-08-07 14:50 ` Juan Quintela
2018-08-06 12:34 ` [Qemu-devel] [PATCH for-3.0 v2 4/5] hw/intc/arm_gicv3_common: Move post_load hooks to top-level VMSD Peter Maydell
2018-08-06 15:32 ` Dr. David Alan Gilbert
2018-08-07 14:41 ` Juan Quintela
2018-08-06 12:34 ` [Qemu-devel] [PATCH for-3.0 v2 5/5] hw/intc/arm_gicv3_common: Move gicd shift bug handling to gicv3_post_load Peter Maydell
2018-08-06 15:39 ` Dr. David Alan Gilbert [this message]
2018-08-06 14:06 ` [Qemu-devel] [PATCH for-3.0 v2 0/5] Arm migration fixes for 3.0 Richard Henderson
2018-08-06 16:50 ` Peter Maydell
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=20180806153925.GF2473@work-vm \
--to=dgilbert@redhat.com \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=shannon.zhaosl@gmail.com \
--cc=zhaoshenglong@huawei.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).