[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 06/17] sev: Fix error handling in sev_encrypt_flash()
From: |
Roy Hopkins |
Subject: |
[PATCH v4 06/17] sev: Fix error handling in sev_encrypt_flash() |
Date: |
Wed, 3 Jul 2024 12:05:44 +0100 |
The function sev_encrypt_flash() checks to see if the return value of
launch_update_data() < 0, but the function returns a non-zero (and not
necessarily negative) result on error. This means that some errors in
updating launch data will result in the function returning success.
In addition, the function takes an Error parameter which is not used
when an error is actually returned.
The return value is now checked for non-zero to indicate an error and
a suitable error message is logged.
Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
---
target/i386/sev.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 3ab8b3c28b..491ca5369e 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -1542,12 +1542,9 @@ sev_encrypt_flash(hwaddr gpa, uint8_t *ptr, uint64_t
len, Error **errp)
/* if SEV is in update state then encrypt the data else do nothing */
if (sev_check_state(sev_common, SEV_STATE_LAUNCH_UPDATE)) {
- int ret;
-
- ret = klass->launch_update_data(sev_common, gpa, ptr, len);
- if (ret < 0) {
- error_setg(errp, "SEV: Failed to encrypt pflash rom");
- return ret;
+ if (klass->launch_update_data(sev_common, gpa, ptr, len)) {
+ error_setg(errp, "SEV: Failed to encrypt flash");
+ return -1;
}
}
--
2.43.0
- [PATCH v4 00/17] Introduce support for IGVM files, Roy Hopkins, 2024/07/03
- [PATCH v4 04/17] hw/i386: Add igvm-cfg object and processing for IGVM files, Roy Hopkins, 2024/07/03
- [PATCH v4 03/17] backends/igvm: Add IGVM loader and configuration, Roy Hopkins, 2024/07/03
- [PATCH v4 05/17] i386/pc_sysfw: Ensure sysfw flash configuration does not conflict with IGVM, Roy Hopkins, 2024/07/03
- [PATCH v4 06/17] sev: Fix error handling in sev_encrypt_flash(),
Roy Hopkins <=
- [PATCH v4 01/17] meson: Add optional dependency on IGVM library, Roy Hopkins, 2024/07/03
- [PATCH v4 02/17] backends/confidential-guest-support: Add functions to support IGVM, Roy Hopkins, 2024/07/03
- [PATCH v4 07/17] sev: Update launch_update_data functions to use Error handling, Roy Hopkins, 2024/07/03
- [PATCH v4 11/17] docs/system: Add documentation on support for IGVM, Roy Hopkins, 2024/07/03