Received: by 2002:a19:ee0a:0:0:0:0:0 with SMTP id g10csp171754lfb; Thu, 19 Nov 2020 00:43:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxID/NJJDZUvGsf62z2GBxuynDv/2wLrNo8CJZrH5wRZN0nKoaT4OUHVla5pLux535nWrQM X-Received: by 2002:a25:a529:: with SMTP id h38mr13573711ybi.61.1605775427547; Thu, 19 Nov 2020 00:43:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605775427; cv=none; d=google.com; s=arc-20160816; b=KuTHijSomm8sm+kABDS6IOt2N7RkQo7xbIYGe9ehwMjMUscd0J59+uzjkZmekKpXiv CQUJWlPV+GkRj2aA/MkBSWDikQfG9AV14bXKNBTmJ0vE+SlgO/Y6Elqd7otX4mvDqzTA pOu6yoEvaLDqtsvE3BlnUZCZ9mJ5QHh+HeTZRO1cpLiVocpvt8Ib0xTCJMGd4wQI1mGU U5fFgFwhoEF0X8YO5ABryuKNtJX6qoY9bxroYBBcCNbAA6WWzig+TH1ngMSkGWucI76s z4fkSvoqO4h3Qb+3tvwKD77Vl+aUz7H5ThsNF92qZMrMqYnpWA17xTYFy4gZldCUDpIR IXEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:dkim-signature :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject; bh=bVTR1qHH100S+o2AgDc4IHFQc1f0QmlYVLK5l/gh6kw=; b=nfH9PVh+0q3DGMN88KHDdcco8WUjq83KB+b59znsQYhZiIffpKPW/M3dm7D3/m5f7n pfuSlIKX6NfiY9xvEB/rKSFbcSfoQciF2s9MwREWkcrIiSqnJWr5obi13L0Z4kuELdQW X6Up3Yi3KvFxs+VYYUl5oUNX7Tm5bsnSPuiTC2kWoNG43CxAM6e2dWOUmgKLMp3DLsvf piHA+jf/eA+Tkq+JsJ9oNP2HgS94F38C0TitK899c1kvJ0B/NTCLrIMbx04JOdvpNjRL pDoGO0G7TjXJaWP/RreUUrNT6a24vHLoxps1GrwFI0AAV7xayfewiDT8Y89GFpLwzOKQ Y1Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nvidia.com header.s=n1 header.b=WVcpyLB2; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y66si26474102yby.212.2020.11.19.00.43.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Nov 2020 00:43:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@nvidia.com header.s=n1 header.b=WVcpyLB2; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: from localhost ([::1]:51218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kffXe-0004lq-Tt for alex.bennee@linaro.org; Thu, 19 Nov 2020 03:43:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kffXW-0004lf-IF; Thu, 19 Nov 2020 03:43:38 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:5155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kffXU-0001r6-6w; Thu, 19 Nov 2020 03:43:38 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 19 Nov 2020 00:43:37 -0800 Received: from [10.40.103.11] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 19 Nov 2020 08:43:28 +0000 Subject: Re: [PATCH RFC] vfio: Move the saving of the config space to the right place in VFIO migration To: Shenming Lu , Alex Williamson , Cornelia Huck References: <20201114091731.157-1-lushenming@huawei.com> X-Nvconfidentiality: public From: Kirti Wankhede Message-ID: <860bd707-8862-2584-6e12-67c86f092dba@nvidia.com> Date: Thu, 19 Nov 2020 14:13:24 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20201114091731.157-1-lushenming@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1605775417; bh=bVTR1qHH100S+o2AgDc4IHFQc1f0QmlYVLK5l/gh6kw=; h=Subject:To:CC:References:X-Nvconfidentiality:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=WVcpyLB28TuIekFV8hjq4LLavoYO1QCMEmYqHTtZu/EoIfcIBwa4zAZ1gG63U/CCI tan7Bu6X9nRyZG+wycDZmd7opLq4UAwBWNdWLE7ZfWt0lyKDwcnI3ZElKRDJYrJdz3 cmwWAL2ZGqrmXZ7IePSu//c5wN5rT3IgH80WKyB1mH4pCRiGu+7PzMpydf/SNbSQSo CG9Z1v4r5qxgZKP8iXMocb4aKIGz6pkU6rFlIqUONPwAw+IE7yd9DfXft8ZbUXlPu0 K3FZ0R33nNsST6PsYZRDG+9veYeJ3xu0HeVwzmcRiOt5w3/5qOmhM3iJN5TArhbd4O +vUOHAyopDC+A== Received-SPF: pass client-ip=216.228.121.65; envelope-from=kwankhede@nvidia.com; helo=hqnvemgate26.nvidia.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/19 03:43:34 X-ACL-Warn: Detected OS = Windows 7 or 8 [fuzzy] X-Spam_score_int: -70 X-Spam_score: -7.1 X-Spam_bar: ------- X-Spam_report: (-7.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neo Jia , Marc Zyngier , qemu-devel@nongnu.org, dgilbert@redhat.com, qemu-arm@nongnu.org, yuzenghui@huawei.com, wanghaibin.wang@huawei.com Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: TN/nwxXLHCzI On 11/14/2020 2:47 PM, Shenming Lu wrote: > When running VFIO migration, I found that the restoring of VFIO PCI devic= e=E2=80=99s > config space is before VGIC on ARM64 target. But generally, interrupt con= trollers > need to be restored before PCI devices.=20 Is there any other way by which VGIC can be restored before PCI device? > Besides, if a VFIO PCI device is > configured to have directly-injected MSIs (VLPIs), the restoring of its c= onfig > space will trigger the configuring of these VLPIs (in kernel), where it w= ould > return an error as I saw due to the dependency on kvm=E2=80=99s vgic. >=20 Can this be fixed in kernel to re-initialize the kernel state? > To avoid this, we can move the saving of the config space from the iterab= le > process to the non-iterable process, so that it will be called after VGIC > according to their priorities. >=20 With this change, at resume side, pre-copy phase data would reach=20 destination without restored config space. VFIO device on destination=20 might need it's config space setup and validated before it can accept=20 further VFIO device specific migration state. This also changes bit-stream, so it would break migration with original=20 migration patch-set. Thanks, Kirti > Signed-off-by: Shenming Lu > --- > hw/vfio/migration.c | 22 ++++++---------------- > 1 file changed, 6 insertions(+), 16 deletions(-) >=20 > diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c > index 3ce285ea39..028da35a25 100644 > --- a/hw/vfio/migration.c > +++ b/hw/vfio/migration.c > @@ -351,7 +351,7 @@ static int vfio_update_pending(VFIODevice *vbasedev) > return 0; > } > =20 > -static int vfio_save_device_config_state(QEMUFile *f, void *opaque) > +static void vfio_save_device_config_state(QEMUFile *f, void *opaque) > { > VFIODevice *vbasedev =3D opaque; > =20 > @@ -365,13 +365,14 @@ static int vfio_save_device_config_state(QEMUFile *= f, void *opaque) > =20 > trace_vfio_save_device_config_state(vbasedev->name); > =20 > - return qemu_file_get_error(f); > + if (qemu_file_get_error(f)) > + error_report("%s: Failed to save device config space", > + vbasedev->name); > } > =20 > static int vfio_load_device_config_state(QEMUFile *f, void *opaque) > { > VFIODevice *vbasedev =3D opaque; > - uint64_t data; > =20 > if (vbasedev->ops && vbasedev->ops->vfio_load_config) { > int ret; > @@ -384,15 +385,8 @@ static int vfio_load_device_config_state(QEMUFile *f= , void *opaque) > } > } > =20 > - data =3D qemu_get_be64(f); > - if (data !=3D VFIO_MIG_FLAG_END_OF_STATE) { > - error_report("%s: Failed loading device config space, " > - "end flag incorrect 0x%"PRIx64, vbasedev->name, dat= a); > - return -EINVAL; > - } > - > trace_vfio_load_device_config_state(vbasedev->name); > - return qemu_file_get_error(f); > + return 0; > } > =20 > static int vfio_set_dirty_page_tracking(VFIODevice *vbasedev, bool star= t) > @@ -575,11 +569,6 @@ static int vfio_save_complete_precopy(QEMUFile *f, v= oid *opaque) > return ret; > } > =20 > - ret =3D vfio_save_device_config_state(f, opaque); > - if (ret) { > - return ret; > - } > - > ret =3D vfio_update_pending(vbasedev); > if (ret) { > return ret; > @@ -720,6 +709,7 @@ static SaveVMHandlers savevm_vfio_handlers =3D { > .save_live_pending =3D vfio_save_pending, > .save_live_iterate =3D vfio_save_iterate, > .save_live_complete_precopy =3D vfio_save_complete_precopy, > + .save_state =3D vfio_save_device_config_state, > .load_setup =3D vfio_load_setup, > .load_cleanup =3D vfio_load_cleanup, > .load_state =3D vfio_load_state, >=20