From nobody Fri May 17 11:05:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553010851412939.9819799571823; Tue, 19 Mar 2019 08:54:11 -0700 (PDT) Received: from localhost ([127.0.0.1]:59276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6H43-0003Iz-8i for importer@patchew.org; Tue, 19 Mar 2019 11:54:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6H0l-00013m-Qp for qemu-devel@nongnu.org; Tue, 19 Mar 2019 11:50:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6H0k-0001GN-Ot for qemu-devel@nongnu.org; Tue, 19 Mar 2019 11:50:43 -0400 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:37418) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6H0k-0001BH-Ag for qemu-devel@nongnu.org; Tue, 19 Mar 2019 11:50:42 -0400 Received: by mail-qt1-x844.google.com with SMTP id z17so22665576qtn.4 for ; Tue, 19 Mar 2019 08:50:40 -0700 (PDT) Received: from host.localdomain (104.129.187.94.16clouds.com. [104.129.187.94]) by smtp.gmail.com with ESMTPSA id m6sm6452476qkc.55.2019.03.19.08.50.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Mar 2019 08:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ceklsTcH3pgrW9jYAzbgTFSCDSlwHoAIvZNTce+zi/k=; b=JaortKx7k8SyMrd1y9koY4/xzoSlLv28mR459kUX1QqxovXZcsPWBo+yoli5JtBq1F zNepv0wRpUl9Q0Be8m/SiD475GZ6hZBr/aU+WsTrMSp9qTnc4xkI4+4no7EqeUaJeqvy cBMs12R8pU4eakoLJot2neOYHqup46vhsGZUZK9sTd1FwwRWGoAkJPawHQe02JuPlw4A TSjAu7rlVAxWfD6ELqnH7jSFGz34OcfoW09FEQ6y8p780Yby1QoXCMiJROF5ia8/QcvY T0QP+eiTTHC1bETmRRIdnUfWNiwo9V0F+nwLSwbAOl4s2684kw2O8d+U4xgQUPg46no4 mpyw== 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; bh=ceklsTcH3pgrW9jYAzbgTFSCDSlwHoAIvZNTce+zi/k=; b=OoPeQwQfyg2+LlBEAs+mldpA9l2ga2a3adHGJMDuc4cEwrg8GVJPjAcHWT2hhhwVDf aVmQjKcpmNY/ni7dcedKqzZyRUBfHxN9DgfKl66oc7bFlcieX/jhQO+ETXst1brRaxMr 5fDtn6h+MuPeICgEkw3IqOh4p4ptuAubnVdy8OpeeDB6sQSsLmoIvyHm8Yo94Oa+oC/M sYZY2jGlj7StrmI1sfOA53Lh54lwdTndtq5Jyt1YBFI039RrBfJJn3Fr970htUDhpyY8 EzXC9DlBPiiCBF3M5b76gEbnoBKnQxW0eUJlsHY61nOKbzo1aeZ6rfSYlgAGhNgwDnd7 X6XQ== X-Gm-Message-State: APjAAAXb+58Zsns8emjGRl3eRT+jTzsY5dDLn7ycWGv2JLJj51M21bct qvDhL5R/rt2gcYUr5tS5rno= X-Google-Smtp-Source: APXvYqyF1Z7ZHB/lvJVRE4f0qKqrwYNXg252MaSJxTlVpAnGWyYYWCY3i7dd6S+GaQGnD9yyi35Bug== X-Received: by 2002:aed:3c5b:: with SMTP id u27mr314078qte.6.1553010639720; Tue, 19 Mar 2019 08:50:39 -0700 (PDT) From: Catherine Ho To: Paolo Bonzini , Richard Henderson , "Dr. David Alan Gilbert" Date: Tue, 19 Mar 2019 11:49:22 -0400 Message-Id: <1553010562-13561-1-git-send-email-catherine.hecx@gmail.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::844 Subject: [Qemu-devel] [PATCH] migration: avoid copying ignore-shared ramblock when in incoming migration 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: qemu-devel@nongnu.org, Markus Armbruster , Catherine Ho , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 18269069c310 ("migration: Introduce ignore-shared capability")=20 addes a ignore-shared capability to bypass the shared ramblock (e,g, membackend + numa node). It does good to live migration. This commit expected that QEMU doesn't write to guest RAM until=20 VM starts, but it does on aarch64 qemu: Backtrace: 1 0x000055f4a296dd84 in address_space_write_rom_internal () at exec.c:3458 2 0x000055f4a296de3a in address_space_write_rom () at exec.c:3479 3 0x000055f4a2d519ff in rom_reset () at hw/core/loader.c:1101 4 0x000055f4a2d475ec in qemu_devices_reset () at hw/core/reset.c:69 5 0x000055f4a2c90a28 in qemu_system_reset () at vl.c:1675 6 0x000055f4a2c9851d in main () at vl.c:4552 In address_space_write_rom_internal, if the ramblock is RAM of=20 ramblock_is_ignored(), memcpy this ramblock will cause the memory-backend file corruption. But in normal case (!in_incoming_migration), this logic should be reserved. Fixes: commit 18269069c310 ("migration: Introduce ignore-shared capability"= )=20 Signed-off-by: Catherine Ho Suggested-by: Yury Kotov --- exec.c | 4 ++++ include/exec/cpu-common.h | 1 + include/qemu/option.h | 1 + migration/ram.c | 2 +- vl.c | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 86a38d3b3b..f08321fb7a 100644 --- a/exec.c +++ b/exec.c @@ -47,6 +47,7 @@ #include "exec/address-spaces.h" #include "sysemu/xen-mapcache.h" #include "trace-root.h" +#include "qemu/option.h" =20 #ifdef CONFIG_FALLOCATE_PUNCH_HOLE #include @@ -3455,6 +3456,9 @@ static inline MemTxResult address_space_write_rom_int= ernal(AddressSpace *as, l =3D memory_access_size(mr, l, addr1); } else { /* ROM/RAM case */ + if (in_incoming_migration && ramblock_is_ignored(mr->ram_block= )) { + break; + } ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); switch (type) { case WRITE_DATA: diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index cef8b88a2a..c80b7248a6 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -76,6 +76,7 @@ void *qemu_ram_get_host_addr(RAMBlock *rb); ram_addr_t qemu_ram_get_offset(RAMBlock *rb); ram_addr_t qemu_ram_get_used_length(RAMBlock *rb); bool qemu_ram_is_shared(RAMBlock *rb); +bool ramblock_is_ignored(RAMBlock *block); bool qemu_ram_is_uf_zeroable(RAMBlock *rb); void qemu_ram_set_uf_zeroable(RAMBlock *rb); bool qemu_ram_is_migratable(RAMBlock *rb); diff --git a/include/qemu/option.h b/include/qemu/option.h index 844587cab3..7509435164 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -139,4 +139,5 @@ QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuO= ptsList *list); QDict *keyval_parse(const char *params, const char *implied_key, Error **errp); =20 +extern bool in_incoming_migration; #endif diff --git a/migration/ram.c b/migration/ram.c index 35bd6213e9..d6de9d335d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -159,7 +159,7 @@ out: return ret; } =20 -static bool ramblock_is_ignored(RAMBlock *block) +bool ramblock_is_ignored(RAMBlock *block) { return !qemu_ram_is_migratable(block) || (migrate_ignore_shared() && qemu_ram_is_shared(block)); diff --git a/vl.c b/vl.c index c1d5484e12..b79aec9ac3 100644 --- a/vl.c +++ b/vl.c @@ -145,6 +145,7 @@ bool enable_cpu_pm =3D false; int nb_nics; NICInfo nd_table[MAX_NICS]; int autostart; +bool in_incoming_migration; static enum { RTC_BASE_UTC, RTC_BASE_LOCALTIME, @@ -3797,6 +3798,7 @@ int main(int argc, char **argv, char **envp) runstate_set(RUN_STATE_INMIGRATE); } incoming =3D optarg; + in_incoming_migration =3D true; break; case QEMU_OPTION_only_migratable: /* --=20 2.17.1