From c2c31677507345bd707472ea081e53889a59a392 Mon Sep 17 00:00:00 2001 From: hanliyang Date: Sat, 2 Mar 2024 01:47:06 +0000 Subject: [PATCH] Fix incompatibility between SEV and CSV on the GET_ID API If the length of GET_ID request is too small, Hygon CSV will return SEV_RET_INVALID_PARAM. This return code doesn't comply with SEV API Spec. Signed-off-by: hanliyang --- ...Fix-incompatibility-between-SEV-and-.patch | 36 +++++++++++++++++++ qemu.spec | 7 +++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 0046-target-i386-sev-Fix-incompatibility-between-SEV-and-.patch diff --git a/0046-target-i386-sev-Fix-incompatibility-between-SEV-and-.patch b/0046-target-i386-sev-Fix-incompatibility-between-SEV-and-.patch new file mode 100644 index 0000000..355b6cf --- /dev/null +++ b/0046-target-i386-sev-Fix-incompatibility-between-SEV-and-.patch @@ -0,0 +1,36 @@ +From 28837192da6f4591efe14b2dff548a75e5401c82 Mon Sep 17 00:00:00 2001 +From: hanliyang +Date: Fri, 1 Mar 2024 14:12:44 +0800 +Subject: [PATCH] target/i386: sev: Fix incompatibility between SEV and CSV on + the GET_ID API + +If the length of GET_ID request is too small, Hygon CSV will return +SEV_RET_INVALID_PARAM. This return code doesn't comply with SEV API +Spec. + +Hygon will consider to fix the compitibility issue of return value +of the GET_ID API, so also check whether the return value as +SEV_RET_INVALID_LEN. + +Signed-off-by: hanliyang +--- + target/i386/sev.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/target/i386/sev.c b/target/i386/sev.c +index 5123db254..eaf078e67 100644 +--- a/target/i386/sev.c ++++ b/target/i386/sev.c +@@ -621,7 +621,8 @@ static int sev_get_cpu0_id(int fd, guchar **id, size_t *id_len, Error **errp) + + /* query the ID length */ + r = sev_platform_ioctl(fd, SEV_GET_ID2, &get_id2, &err); +- if (r < 0 && err != SEV_RET_INVALID_LEN) { ++ if (r < 0 && err != SEV_RET_INVALID_LEN && ++ !(is_hygon_cpu() && err == SEV_RET_INVALID_PARAM)) { + error_setg(errp, "SEV: Failed to get ID ret=%d fw_err=%d (%s)", + r, err, fw_error_to_str(err)); + return 1; +-- +2.31.1 + diff --git a/qemu.spec b/qemu.spec index b3bdde1..5453122 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,4 +1,4 @@ -%define anolis_release 7 +%define anolis_release 8 %bcond_with check @@ -308,6 +308,7 @@ Patch0042: 0042-anolis-csv-i386-add-support-to-migrate-the-outgoing-.patch Patch0043: 0043-anolis-csv-i386-add-support-to-migrate-the-incoming-.patch Patch0044: 0044-Fix-crash-when-loading-snapshot-on-inactive-node.patch Patch0045: 0045-anolis-target-i386-sev-Add-support-for-reuse-ASID-fo.patch +Patch0046: 0046-target-i386-sev-Fix-incompatibility-between-SEV-and-.patch ExclusiveArch: x86_64 aarch64 @@ -1876,6 +1877,10 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %endif %changelog +* Sat Mar 06 2024 Liyang Han - 15:7.2.6-8 +- Patch0046: 0046-target-i386-sev-Fix-incompatibility-between-SEV-and-.patch + (Fix incompatibility between SEV and CSV on the GET_ID API) + * Wed Jan 22 2024 Liyang Han - 15:7.2.6-7 - Patch0045: 0045-anolis-target-i386-sev-Add-support-for-reuse-ASID-fo.patch (Support reuse ASID for CSV guests) -- Gitee