From patchwork Thu Mar 9 11:34:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Pinto X-Patchwork-Id: 9613129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EAF1D602B4 for ; Thu, 9 Mar 2017 11:35:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D78ED28586 for ; Thu, 9 Mar 2017 11:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAA0F285F5; Thu, 9 Mar 2017 11:35:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 669DA28586 for ; Thu, 9 Mar 2017 11:35:59 +0000 (UTC) Received: from localhost ([::1]:33387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clwMQ-000600-Dh for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Mar 2017 06:35:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clwLu-0005wq-6L for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:35:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clwLs-0004jn-ME for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:35:26 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:32801) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clwLs-0004jf-Ft for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:35:24 -0500 Received: by mail-wm0-x241.google.com with SMTP id n11so10461883wma.0 for ; Thu, 09 Mar 2017 03:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualopensystems-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=r/wgdnyg3qUbFrWQsrLWkvfsCVEh/Dl46WgeUDJ28Rs=; b=If5sKOV9nVEUjm6jzuv0Z/c7yU6SsrtieroBqbKprJ1Jvh7MxWCJd7ZHnswSizihQa BrKerxkFjNdPHnYUr7jP8hoPJ904vt0gjAZGTaaoj0JiuPpQNJX2BptC4zlxr659zUiG m++zCpBdnOKadjtVYJ3j/7vew9C7tZxQP3UOVYuAPWBuL0zagrhJ05X3DGSwLbBvfCg2 QVtmzk2GdU10WMII4r4U9vO2/p2K4vL4Nw8MLypF5grtemkQdQ/LxxCIpUqf86cHfbkd PJPASR4D5rw6AWLycuCzX1EEuL4n9VjDLqk2bGHXjC6nVSOkDke1S4YIx/O8scZVS5Um ImLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=r/wgdnyg3qUbFrWQsrLWkvfsCVEh/Dl46WgeUDJ28Rs=; b=juU1LmHfh+bbPLCyvay/gRrOdppvBC3+aAQoaiZOQMeQSXijHozct0j6oEpdWZhH2p ZuTXemjq30ASxQcjmE/KXQcr4wpe3gadlAPBBbGAODOYbvtu/oT27EI1xfV+fws0bTNa jzkSwdTV/aIzslkSJ1G78Rc0MG9iIBRd0r0w3q/HSrPF6ta7+3Ko/YRqDzFblEHvcnY2 jXTsoWlscGncHi6URhncAV44IlExewMZXYsRj3pvWj1iMfSeKwEwj6KHZudroJ26irrj Az2tUcwqcd0qKo+/hXVmQ4H0aNA5Le0g+JWyJKhyrtl+kWis3CeQMOI39PbMcOn9F6Ml r6/w== X-Gm-Message-State: AMke39mSpnZSGaR3CQ1ySWvLzhBRUuRuAJjL1+NU+wCfbzCqmIYnVo7LoMVIO5moPa1XKw== X-Received: by 10.28.230.83 with SMTP id d80mr9964920wmh.18.1489059323414; Thu, 09 Mar 2017 03:35:23 -0800 (PST) Received: from bumma.localdomain ([151.67.127.177]) by smtp.googlemail.com with ESMTPSA id 36sm7876460wrk.57.2017.03.09.03.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 03:35:22 -0800 (PST) From: Christian Pinto To: zhang.zhanghailiang@huawei.com Date: Thu, 9 Mar 2017 12:34:34 +0100 Message-Id: <20170309113437.9667-2-c.pinto@virtualopensystems.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309113437.9667-1-c.pinto@virtualopensystems.com> References: <57B7F948.9040701@huawei.com> <20170309113437.9667-1-c.pinto@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [RFC PATCH 1/4] migration/postcopy-ram: check pagefault flags in userfaultfd thread X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aarcange@redhat.com, b.reynal@virtualopensystems.com, quintela@redhat.com, qemu-devel@nongnu.org, hanweidong@huawei.com, peter.huangpeng@huawei.com, Christian Pinto , dgilbert@redhat.com, amit.shah@redhat.com, tech@virtualopensystems.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The UFFD_PAGEFAULT_FLAG_WP should be set every time the page fault is due to a write to a write-protected page. Flag should be checked at every time to be sure the page fault is due to a write into WP area. Signed-off-by: Christian Pinto Signed-off-by: Baptiste Reynal --- migration/postcopy-ram.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index ea70bd5d16..9c45f1059f 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -534,7 +534,12 @@ static void *postcopy_ram_fault_thread(void *opaque) migrate_send_rp_req_pages(mis, NULL, rb_offset, hostpagesize); } - } else { /* UFFDIO_REGISTER_MODE_WP */ + } else if (msg.arg.pagefault.flags & + UFFD_PAGEFAULT_FLAG_WP) { /* UFFDIO_REGISTER_MODE_WP */ + /* + * msg.arg.pagefault.flags &UFFD_PAGEFAULT_FLAG_WP expected to + * be set in case of pagefault due to write protected page + * */ MigrationState *ms = container_of(us, MigrationState, userfault_state); ret = ram_save_queue_pages(ms, qemu_ram_get_idstr(rb), rb_offset,