From patchwork Mon Aug 6 12:34:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 143511 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3236205ljj; Mon, 6 Aug 2018 05:34:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfze6yy4v6z9XH350d42rRfocT28sGlKUPB677G471Ds0MeEk2xkEUkVPVsbyFaq9+RFFs6 X-Received: by 2002:a19:4f58:: with SMTP id a24-v6mr11553378lfk.140.1533558893016; Mon, 06 Aug 2018 05:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533558893; cv=none; d=google.com; s=arc-20160816; b=u2iWd0mrl1APLoGaO7PX/Sf5MIMqi5fQt5ZRa985IcT5uCiVn/9iUKhJM4NOhG5fy/ S9a419kGSXF4y5eMiTM9bVLvCAz1+MM+O3WpwqY2kGWjLpvfrQqGNO7d6rM3f2d3F0jf WlCMZnGbg3yEKv12SRFajheSI9qTLEalj4nhqmD0GjuDVpJMytPmSTl5vufeth0p2rA5 Ai9aay2neBgkSHQKz0N4SzmZvHwDxktKyMxqKralo9xFDQHC0Q/WnW2aeFwN2wfPtd9a 1TTYDs7ZLFX/RQtiZwA2FV3y8fTg4qg4OfdoGv7kUktWTEhAMhEEgXdsR+boX7F9n6NK +fBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=IqpVq8VBOq13JI/4Xsop/gKJzlXmOGkla4RqQMGduSc=; b=YJG6IEpsvsRCWdYk48tStCMHuFWEEUMsmIwsW0IQTwMUs2oIVmBDbitHdig3SuSBET Opi3NZkx3LXP/XRwDalV0WtolEhG/lF6Lb1Vfjgl98PY5MCSbnryukO78L/wXMkrtvKv UL7WWczB8MVg0Xl4jfLUNZmx/lqzOCK9Vmoil3o3jeTb/4/kYGybMQnPslnbFTHe7G9u uVTg2gyiPFUgiO+CIsPodVz39ngvNwEJxf2CgDoLHmKw+4Nts2JjPpr1IcJWUAuPz66g pAO436X+dQ0b27/fqLVRbAwTtOfI33+cVFIKCiPVO6HBymUrUwlfmbPD+sEubmOxznEn 5oYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id k1-v6si5411000ljg.125.2018.08.06.05.34.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Aug 2018 05:34:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fmeio-0000wi-PU; Mon, 06 Aug 2018 13:34:50 +0100 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, Juan Quintela , "Dr . David Alan Gilbert" , Shannon Zhao , Shannon Zhao Subject: [PATCH for-3.0 v2 1/5] hw/intc/arm_gicv3_common: Give no-migration-shift-bug subsection a needed function Date: Mon, 6 Aug 2018 13:34:41 +0100 Message-Id: <20180806123445.1459-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806123445.1459-1-peter.maydell@linaro.org> References: <20180806123445.1459-1-peter.maydell@linaro.org> Currently the migration code incorrectly treats a subsection with no .needed function pointer as if it was the subsection list terminator -- it is ignored and so is everything after it. Work around this by giving vmstate_gicv3_gicd_no_migration_shift_bug a 'needed' function that always returns true. Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert --- This should go into 3.0 to avoid awkward migration compat problems: the no-migration-shift-bug subsection is new in 3.0. --- hw/intc/arm_gicv3_common.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.1 Reviewed-by: Juan Quintela diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index ff326b374ad..e58bc8b8105 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -203,10 +203,16 @@ static int gicv3_gicd_no_migration_shift_bug_post_load(void *opaque, return 0; } +static bool needed_always(void *opaque) +{ + return true; +} + const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = { .name = "arm_gicv3/gicd_no_migration_shift_bug", .version_id = 1, .minimum_version_id = 1, + .needed = needed_always, .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load, .post_load = gicv3_gicd_no_migration_shift_bug_post_load, .fields = (VMStateField[]) { From patchwork Mon Aug 6 12:34:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 143515 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3236257ljj; Mon, 6 Aug 2018 05:34:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeyXuNj40QJRpfQXmSxmTsvTxwigdqBCyXuRq2maTd2wn1lpgJt+VW+Kbpxg2Xyu5HwWj/8 X-Received: by 2002:a65:5a8a:: with SMTP id c10-v6mr14047705pgt.389.1533558896661; Mon, 06 Aug 2018 05:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533558896; cv=none; d=google.com; s=arc-20160816; b=T+e7w2jecmNxJ5aSjTDiq2W140svB/lqdvFZqA41a0FD4J8kifoNh54Pv+Hpc7nIPq yTCpPBuTuVpFfpNi9dJyap7hqHWbi/7sautaLfSUOhBi1L6Hw/wQP4njmmN9G0ugREvA LmQQoKptOo4Ko2syM32e8uUuKXwGe4luuz4ZizmUCH6+mLYu6WUrp3yXDRGM20lWVeBF tNuBJHfLszx9sj2FQH9Rw8mBxbGIKzm8IuLDPhvQqi7yQAtfuQ4iy8cP5CbytHHog5Yd 6/dYKNuomYMpDf91SWqN5KWx5f6ITBjXWGfConjX6rlJ3u7MqbUF6ysEq1ewORfyOLcZ VZBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1TUeGhaXZ4Xx2mfKfbBO3ST86mCdnN3fUujZpxcLomU=; b=HjUxkajl2YDelxWXCNLG4vZ2OeVrJcMkewl7SaIwN+rB88K0y5BzFe6LU/wlJnxVKq +E2WHC2fzgA0LdHX+tFpvLcS6ApPw4hcV6qPXLhW9ZvUdA//fjqZ58MuM9KvPwCp5JQ1 ZzJb7Du7RTQPPTLxxDsNNX7vjGVHDFXqLdTMb9BN1T6xCS70EbM3doCkyEr2OznRyVQ9 s1h2XD8sYSfa4NkljeE35xuSpIYG+dCusg56PTwO90/VZLlqfqNjBa9bBlK1LfiL4hHD c3JhCP+YFRtUDRrs2u7VrQE+1Ajsau89V1/+v8BPyscebtupH/O6tYLo2wRqk89rfFPp pw+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id a4-v6si13383672pgl.9.2018.08.06.05.34.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Aug 2018 05:34:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fmeip-0000wy-N6; Mon, 06 Aug 2018 13:34:51 +0100 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, Juan Quintela , "Dr . David Alan Gilbert" , Shannon Zhao , Shannon Zhao Subject: [PATCH for-3.0 v2 2/5] hw/intc/arm_gicv3_common: Combine duplicate .subsections in vmstate_gicv3_cpu Date: Mon, 6 Aug 2018 13:34:42 +0100 Message-Id: <20180806123445.1459-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806123445.1459-1-peter.maydell@linaro.org> References: <20180806123445.1459-1-peter.maydell@linaro.org> Commit 6692aac411199064 accidentally introduced a second initialization of the .subsections field of vmstate_gicv3_cpu, instead of adding the new subsection to the existing list. The effect of this was probably that migration of GICv3 with virtualization enabled was broken (or alternatively that migration of ICC_SRE_EL1 was broken, depending on which of the two initializers the compiler used). Combine the two into a single list. Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert --- Not strictly a 2.12 regression. --- hw/intc/arm_gicv3_common.c | 3 --- 1 file changed, 3 deletions(-) -- 2.17.1 Reviewed-by: Juan Quintela diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index e58bc8b8105..e1a8999cf5b 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -134,9 +134,6 @@ static const VMStateDescription vmstate_gicv3_cpu = { }, .subsections = (const VMStateDescription * []) { &vmstate_gicv3_cpu_virt, - NULL - }, - .subsections = (const VMStateDescription * []) { &vmstate_gicv3_cpu_sre_el1, NULL } From patchwork Mon Aug 6 12:34:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 143512 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3236217ljj; Mon, 6 Aug 2018 05:34:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeqXcpYk0JgRpptBH2XSr2K882OJQdwglCu7HFKLyaM5vK+MKGZ70JrPAX6MKD9YGI+qnnw X-Received: by 2002:adf:91e5:: with SMTP id 92-v6mr9697935wri.124.1533558893990; Mon, 06 Aug 2018 05:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533558893; cv=none; d=google.com; s=arc-20160816; b=ShyX3ruwlXVAq3Jkn1V6aV/YvCbGv/JZT5jWSgyuWRmFXb0Q132KmrpJA37rWaWSb+ sRA4JMo98bRkqbIbwtBXZ44fLoPgYKzvk0YCq8vCyZ9QkopzFOQGBw1/jSCnARFUEVig 22TuFGO1CeifLmUzCiVxrxC/2oLvGG+48eCYGsDES5ZV8Ua37d3C/KEtXKYlP3a8f7Ll +izh78IYxc2J0CuLo1eixqzFD/7yUs6Y8DcS1vzxxb2BNFbybHaVldmtL/IQoU3kYNCG wrBM/EjjDRybvsLawGy49mE9RNnQAAERnx+2hU35JTV+isA8wv70FIv2ujRV4D8gakiO DjOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=A9kKGbltkLTQ2D7q6RUGjYPUBSMEiavP2OLZz4kwLPc=; b=sIgm5Uk8eYCRr8mBuPg1Bsa9e9oOb0THkqnVyOuM3uATXeU4QxqhXzs792vFHKM3ew BuLl1IT9u4QthvlT8En4Ysf0D5Gz6H8ULK7TqwW3JwMr8ncO1p4pliNm07cNHyIVyjGx QTBqbb+P0l70RT9hWqLgMEOXKsC4Fak8b8YxF7EPKOCQU5gPga3CgaZjsRrahtbP9ujF zHivFqVsXn8rFpvibAa1a+EtnAjL5IHsRpY9uqljT7NQe1Z3L1yKMeczUU+ZRSI85HWd +BPpLu3V6wvs14r32ucrVjEfWNlBHog2/xZ7lUn826ztLaX5t10jF7zur25g34bPv6JA LZjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id y67-v6si5568477wme.107.2018.08.06.05.34.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Aug 2018 05:34:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fmeir-0000xP-C6; Mon, 06 Aug 2018 13:34:53 +0100 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, Juan Quintela , "Dr . David Alan Gilbert" , Shannon Zhao , Shannon Zhao Subject: [PATCH for-3.0 v2 3/5] target/arm: Add dummy needed functions to M profile vmstate subsections Date: Mon, 6 Aug 2018 13:34:43 +0100 Message-Id: <20180806123445.1459-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806123445.1459-1-peter.maydell@linaro.org> References: <20180806123445.1459-1-peter.maydell@linaro.org> Currently the migration code incorrectly treats a subsection with no .needed function pointer as if it was the subsection list terminator -- it is ignored and so is everything after it. Work around this by giving various M profile vmstate structs a 'needed' function that always returns true. We reuse m_needed() for this, since it's always true here. Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert --- Not strictly a regression as it only affects M profile CPUs with the security extensions, and migration of those was broken anyway in 2.12 due to a different bug. --- target/arm/machine.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 Reviewed-by: Juan Quintela diff --git a/target/arm/machine.c b/target/arm/machine.c index 2e28d086bdf..ff4ec22bf75 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -184,6 +184,7 @@ static const VMStateDescription vmstate_m_faultmask_primask = { .name = "cpu/m/faultmask-primask", .version_id = 1, .minimum_version_id = 1, + .needed = m_needed, .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.faultmask[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.primask[M_REG_NS], ARMCPU), @@ -230,6 +231,7 @@ static const VMStateDescription vmstate_m_scr = { .name = "cpu/m/scr", .version_id = 1, .minimum_version_id = 1, + .needed = m_needed, .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.scr[M_REG_NS], ARMCPU), VMSTATE_END_OF_LIST() @@ -240,6 +242,7 @@ static const VMStateDescription vmstate_m_other_sp = { .name = "cpu/m/other-sp", .version_id = 1, .minimum_version_id = 1, + .needed = m_needed, .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.other_sp, ARMCPU), VMSTATE_END_OF_LIST() From patchwork Mon Aug 6 12:34:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 143513 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3236228ljj; Mon, 6 Aug 2018 05:34:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdWoM2mOMpJ0z2BlMcc+XPSsPRPtno5V9N1wtZNR13njW3qPAK4cslaghyi7c/64rOL6gfO X-Received: by 2002:a1c:b80c:: with SMTP id i12-v6mr11102003wmf.30.1533558894908; Mon, 06 Aug 2018 05:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533558894; cv=none; d=google.com; s=arc-20160816; b=PbFMMeTTg7+kjbv8+n8+goH92YPZn/JZrE6oivg6UbKgpn+F+7vED+oN3i9QBzrGsk PU29TYtqKEDwBTLOlEFRd/0iRFNiB1NDjgxKlZWxLIJNkWEBI7TSUIHpAeBWSFoFTNoT 8oKCARW/AprOmGUDYDx1yiaqCU3+1jXuPemxdzdqwXDWyUTCBiZ85Uvs2I3tCaaH6Bb0 NPejwSe1j94UX8w5YaZZ/5Hci7KqSkjp3WXicxxaNGqKjMh3g8QHcVIX+gb3xbUN1tL1 C+uN/fmW7qrBm/kywAcTbwkuSYh754KZEhpf8rHfRiKjFzvJZuTnDg02zWnbJ4wi/W/J TfxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iDIgoxLx8qpv8kf4cMIhdj8rajnXr3weIf5BzV+u04I=; b=mw14eYCS53vpFMv2LAwgFo6hkOcRWqtLNFQN5FRZxLFwcNEFYY6moZN4iJZxdWuNSb hsC3g3B5+cFVF9MqDWHvSFa72t3RfFfh0CYQUxOx/qVltmpjJD1aOn4IoF6tuz+FGgQT dV1VjIlHExnKKIGZEYtFfUO5zgk6BFGaCmezJ7z5D9Yr4hz+sgPZAJTWS1WisP3SRQIT 7PF1TIbUfbFyxo5xUXzP0za58PN8kiGitpjIFnzWXXSV2zniRXtCSAQ5vFurXoHXnQAT oisd5bdfziUFlLMl6np5ivaW7lcslEnShW0f9J/KfXniR2cWtJLMQebLWTdXBUU1le2j 8brw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id a185-v6si5662621wmd.193.2018.08.06.05.34.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Aug 2018 05:34:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fmeis-0000xh-Ad; Mon, 06 Aug 2018 13:34:54 +0100 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, Juan Quintela , "Dr . David Alan Gilbert" , Shannon Zhao , Shannon Zhao Subject: [PATCH for-3.0 v2 4/5] hw/intc/arm_gicv3_common: Move post_load hooks to top-level VMSD Date: Mon, 6 Aug 2018 13:34:44 +0100 Message-Id: <20180806123445.1459-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806123445.1459-1-peter.maydell@linaro.org> References: <20180806123445.1459-1-peter.maydell@linaro.org> Contrary to the the impression given in docs/devel/migration.rst, the migration code does not run the pre_load hook for a subsection unless the subsection appears on the wire, and so this is not a place where you can set the default value for state for the "subsection not present" case. Instead this needs to be done in a pre_load hook for whatever is the parent VMSD of the subsection. We got this wrong in two of the subsection definitions in the GICv3 migration structs; fix this. Signed-off-by: Peter Maydell --- hw/intc/arm_gicv3_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index e1a8999cf5b..8175889f1e7 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -73,7 +73,7 @@ static const VMStateDescription vmstate_gicv3_cpu_virt = { } }; -static int icc_sre_el1_reg_pre_load(void *opaque) +static int vmstate_gicv3_cpu_pre_load(void *opaque) { GICv3CPUState *cs = opaque; @@ -97,7 +97,6 @@ const VMStateDescription vmstate_gicv3_cpu_sre_el1 = { .name = "arm_gicv3_cpu/sre_el1", .version_id = 1, .minimum_version_id = 1, - .pre_load = icc_sre_el1_reg_pre_load, .needed = icc_sre_el1_reg_needed, .fields = (VMStateField[]) { VMSTATE_UINT64(icc_sre_el1, GICv3CPUState), @@ -109,6 +108,7 @@ static const VMStateDescription vmstate_gicv3_cpu = { .name = "arm_gicv3_cpu", .version_id = 1, .minimum_version_id = 1, + .pre_load = vmstate_gicv3_cpu_pre_load, .fields = (VMStateField[]) { VMSTATE_UINT32(level, GICv3CPUState), VMSTATE_UINT32(gicr_ctlr, GICv3CPUState), @@ -139,7 +139,7 @@ static const VMStateDescription vmstate_gicv3_cpu = { } }; -static int gicv3_gicd_no_migration_shift_bug_pre_load(void *opaque) +static int gicv3_pre_load(void *opaque) { GICv3State *cs = opaque; @@ -210,7 +210,6 @@ const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = { .version_id = 1, .minimum_version_id = 1, .needed = needed_always, - .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load, .post_load = gicv3_gicd_no_migration_shift_bug_post_load, .fields = (VMStateField[]) { VMSTATE_BOOL(gicd_no_migration_shift_bug, GICv3State), @@ -222,6 +221,7 @@ static const VMStateDescription vmstate_gicv3 = { .name = "arm_gicv3", .version_id = 1, .minimum_version_id = 1, + .pre_load = gicv3_pre_load, .pre_save = gicv3_pre_save, .post_load = gicv3_post_load, .priority = MIG_PRI_GICV3, From patchwork Mon Aug 6 12:34:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 143514 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3236255ljj; Mon, 6 Aug 2018 05:34:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdzaZmlpztMWGIOnYJ5XtmTgn4LC3qDaRl64b9GimgSZiteD0UwFiP5m90r3Ap5oTG/9w8Q X-Received: by 2002:a5d:63c1:: with SMTP id c1-v6mr9673641wrw.106.1533558896496; Mon, 06 Aug 2018 05:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533558896; cv=none; d=google.com; s=arc-20160816; b=w1izhxfeov2z8+oD5njRJu2HWnMaaamacpZSpD/13SQmFR8+64lX6ls5TrXLGqcC1D qsVz/2COro0p293LQ12w/tiiKwGlUshkKPIyNiRgDl0uLq1fzoEww/EM9xRZ4g0gIqNY Hs2DTxd2KdIfz3z2jDbOPINvTqwonhbmJjE8oxFf6qxJfoPv10uPPnTuu4N9SufsnZjx L1SqKDzVGgvw9TrampiQK0ciQXBsvrCwmC30nv9kVU6t+l/sNGMYTfobhg9zjqrmOONd K4GxEUIDBj7cy3W0FjrLdecUvXjhKWqEKSqlnDZ8c6uMUd8WEfKS13EH6Ny+SnqllUCr gS/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=eFvTOuy8uzY6NC3VeTcO1NrZkxczQkykWxrAZrFOGU4=; b=NZazh825sl0hrRhB4+8aYD0MaUEbg+UKmJhnYUmmHHuvxp+9slTKe1eUUlHkfhY8RI NUflF7eaJkU6gJ4KpbFJagm6xBZ8YN6//t7EhUDktV3vIN8jgMQkf3botHJgomsPouCa D8dhWvb1+Ce59SIjoNNuWVmXo3yBTUE7PIMtnGDo/xe+PmbZusFbCVT5p2Aw8YfNPoUN 7OJg6g+B0AJjHNyQ1B8GEQas4RnVtJ46BmkzK8Jasa8mYeLtGyEn4tUxfB0ZJZ4a1lrx eercisuiP9kIa1hPhUgeYW+Q41c3KQ7dOheC4X63JvQzhjWl1Qbz+EEZ1/ZnReNElxhK TSWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id d73-v6si7220287wme.42.2018.08.06.05.34.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Aug 2018 05:34:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fmeiu-0000yI-0K; Mon, 06 Aug 2018 13:34:56 +0100 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, Juan Quintela , "Dr . David Alan Gilbert" , Shannon Zhao , Shannon Zhao Subject: [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 13:34:45 +0100 Message-Id: <20180806123445.1459-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806123445.1459-1-peter.maydell@linaro.org> References: <20180806123445.1459-1-peter.maydell@linaro.org> 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 --- hw/intc/arm_gicv3_common.c | 77 ++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 40 deletions(-) -- 2.17.1 Reviewed-by: Dr. David Alan Gilbert 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()