diff mbox series

[RFC,kvmtool,03/31] hw: cfi flash: Handle errors in memory transitions

Message ID 20230127113932.166089-4-suzuki.poulose@arm.com (mailing list archive)
State New, archived
Headers show
Series [RFC,kvmtool,01/31] arm64: Disable MTE when CFI flash is emulated | expand

Commit Message

Suzuki K Poulose Jan. 27, 2023, 11:39 a.m. UTC
Handle failures in creating the memory maps and back in
transitioning the CFI flash. e.g., with MTE enabled, CFI
flash emulation breaks with the map operation, silently.
And we later hit unhandled aborts in the guest.

To avoid such issues, let us make sure we catch the error
and handle it right at source.

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
 hw/cfi_flash.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series


diff --git a/hw/cfi_flash.c b/hw/cfi_flash.c
index 7faecdfb..bce546bc 100644
--- a/hw/cfi_flash.c
+++ b/hw/cfi_flash.c
@@ -455,6 +455,8 @@  static int map_flash_memory(struct kvm *kvm, struct cfi_flash_device *sfdev)
 	if (!ret)
 		sfdev->is_mapped = true;
+	else
+		die("CFI Flash: ERROR: Unable to map memory: %d\n", ret);
 	return ret;
@@ -472,6 +474,8 @@  static int unmap_flash_memory(struct kvm *kvm, struct cfi_flash_device *sfdev)
 	if (!ret)
 		sfdev->is_mapped = false;
+	else
+		die("CFI Flash: Failed to unmap Flash %d", ret);
 	return ret;