From a63f81097df55e9a15ecf1cdc4ce06d4babee8ff Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Tue, 25 Feb 2020 17:24:16 +0800 Subject: [PATCH] dm: avoid clear guest memory content if guest is RTVM If the guest is RTVM, dm process exit doesn't mean RTVM is shutdown. Only shutdown_vm in hypervisor guarantee RTVM is shutodwn. So we should avoid touch guest memory content from DM if the guest is RTVM. Tracked-On: #4428 Signed-off-by: Yin Fengwei Acked-by: Wang, Yu1 --- devicemodel/core/vmmapi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index 92bf80c4b..0db51ab3c 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -330,11 +330,17 @@ vm_unsetup_memory(struct vmctx *ctx) * allocated the new UOS, the previous UOS sensitive data * may be leaked to the new UOS if the memory is not cleared. * + * For rtvm, we can't clean VM's memory as RTVM may still + * run. But we need to return the memory to SOS here. + * Otherwise, VM can't be restart again. */ - bzero((void *)ctx->baseaddr, ctx->lowmem); - if (ctx->highmem > 0) { - bzero((void *)(ctx->baseaddr + ctx->highmem_gpa_base), - ctx->highmem); + + if (!is_rtvm) { + bzero((void *)ctx->baseaddr, ctx->lowmem); + if (ctx->highmem > 0) { + bzero((void *)(ctx->baseaddr + ctx->highmem_gpa_base), + ctx->highmem); + } } hugetlb_unsetup_memory(ctx);