Skip to content

Commit 694b5a9

Browse files
Steve SistareFabiano Rosas
authored andcommitted
migration: Avoid SNP guest crash due to duplicate cpr blocker
With aux-ram-share=off, booting an SNP guest fails with: ../util/error.c:68: error_setv: Assertion `*errp == NULL' failed. This is because a CPR blocker for the guest_memfd ramblock is added twice, once in ram_block_add_cpr_blocker because aux-ram-share=off so rb->fd < 0, and once in ram_block_add for a specific guest_memfd blocker. To fix, add the guest_memfd blocker iff a generic one would not be added by ram_block_add_cpr_blocker. Fixes: 094a3db ("migration: ram block cpr blockers") Reported-by: Tom Lendacky <[email protected]> Reported-by: Michael Roth <[email protected]> Tested-by: Tom Lendacky <[email protected]> Signed-off-by: Steve Sistare <[email protected]> Message-ID: <[email protected]> [reword subject line] Signed-off-by: Fabiano Rosas <[email protected]>
1 parent b876e72 commit 694b5a9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

system/physmem.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static void io_mem_init(void);
158158
static void memory_map_init(void);
159159
static void tcg_log_global_after_sync(MemoryListener *listener);
160160
static void tcg_commit(MemoryListener *listener);
161+
static bool ram_is_cpr_compatible(RAMBlock *rb);
161162

162163
/**
163164
* CPUAddressSpace: all the information a CPU needs about an AddressSpace
@@ -1908,13 +1909,18 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
19081909
goto out_free;
19091910
}
19101911

1911-
error_setg(&new_block->cpr_blocker,
1912-
"Memory region %s uses guest_memfd, "
1913-
"which is not supported with CPR.",
1914-
memory_region_name(new_block->mr));
1915-
migrate_add_blocker_modes(&new_block->cpr_blocker, errp,
1916-
MIG_MODE_CPR_TRANSFER,
1917-
-1);
1912+
/*
1913+
* Add a specific guest_memfd blocker if a generic one would not be
1914+
* added by ram_block_add_cpr_blocker.
1915+
*/
1916+
if (ram_is_cpr_compatible(new_block)) {
1917+
error_setg(&new_block->cpr_blocker,
1918+
"Memory region %s uses guest_memfd, "
1919+
"which is not supported with CPR.",
1920+
memory_region_name(new_block->mr));
1921+
migrate_add_blocker_modes(&new_block->cpr_blocker, errp,
1922+
MIG_MODE_CPR_TRANSFER, -1);
1923+
}
19181924
}
19191925

19201926
ram_size = (new_block->offset + new_block->max_length) >> TARGET_PAGE_BITS;

0 commit comments

Comments
 (0)