Skip to contentSkip to conversation

target/i386/sev: Ensure sev_fw_errlist is sync with update-linux-headers

PATCH In review Philippe Mathieu-Daudé 4 participants 8 messages Feb 19, 2021 – Jun 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/i386/sev: Ensure sev_fw_errlist is sync with update-linux-headers

Ensure sev_fw_errlist[] is updated after running
the update-linux-headers.sh script.

---
Based-on: <[email protected]>

---
 target/i386/sev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
target/i386/sev.c +4 -1
index 37690ae809c..92c69a23769 100644
@@ -87,7 +87,7 @@ typedef struct __attribute__((__packed__)) SevInfoBlock {
 static SevGuestState *sev_guest;
 static Error *sev_mig_blocker;
 
-static const char *const sev_fw_errlist[] = {
+static const char *const sev_fw_errlist[SEV_RET_MAX] = {
     [SEV_RET_SUCCESS]                = "",
     [SEV_RET_INVALID_PLATFORM_STATE] = "Platform state is invalid",
     [SEV_RET_INVALID_GUEST_STATE]    = "Guest state is invalid",
@@ -114,6 +114,8 @@ static const char *const sev_fw_errlist[] = {
     [SEV_RET_RESOURCE_LIMIT]         = "Required firmware resource depleted",
     [SEV_RET_SECURE_DATA_INVALID]    = "Part-specific integrity check failure",
 };
+/* Ensure sev_fw_errlist[] is updated after running update-linux-headers.sh */
+QEMU_BUILD_BUG_ON(SEV_RET_SECURE_DATA_INVALID + 1 != SEV_RET_MAX);
 
 #define SEV_FW_MAX_ERROR      ARRAY_SIZE(sev_fw_errlist)
 
@@ -160,6 +162,7 @@ fw_error_to_str(int code)
     if (code < 0 || code >= SEV_FW_MAX_ERROR) {
         return "unknown error";
     }
+    assert(sev_fw_errlist[code]);
 
     return sev_fw_errlist[code];
 }
Signature · 1 line
2.26.2
#2 lore raw
In reply to Philippe Mathieu-Daudé

ping?

Quoted 41 lines · Philippe Mathieu-Daudé

Ensure sev_fw_errlist[] is updated after running
the update-linux-headers.sh script.

---
Based-on: <[email protected]>

---
 target/i386/sev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
target/i386/sev.c +4 -1
index 37690ae809c..92c69a23769 100644
@@ -87,7 +87,7 @@ typedef struct __attribute__((__packed__)) SevInfoBlock {
 static SevGuestState *sev_guest;
 static Error *sev_mig_blocker;
 
-static const char *const sev_fw_errlist[] = {
+static const char *const sev_fw_errlist[SEV_RET_MAX] = {
     [SEV_RET_SUCCESS]                = "",
     [SEV_RET_INVALID_PLATFORM_STATE] = "Platform state is invalid",
     [SEV_RET_INVALID_GUEST_STATE]    = "Guest state is invalid",
@@ -114,6 +114,8 @@ static const char *const sev_fw_errlist[] = {
     [SEV_RET_RESOURCE_LIMIT]         = "Required firmware resource depleted",
     [SEV_RET_SECURE_DATA_INVALID]    = "Part-specific integrity check failure",
 };
+/* Ensure sev_fw_errlist[] is updated after running update-linux-headers.sh */
+QEMU_BUILD_BUG_ON(SEV_RET_SECURE_DATA_INVALID + 1 != SEV_RET_MAX);
 
 #define SEV_FW_MAX_ERROR      ARRAY_SIZE(sev_fw_errlist)
 
@@ -160,6 +162,7 @@ fw_error_to_str(int code)
     if (code < 0 || code >= SEV_FW_MAX_ERROR) {
         return "unknown error";
     }
+    assert(sev_fw_errlist[code]);
 
     return sev_fw_errlist[code];
 }
#3 lore raw

ping^2?

Quoted 45 lines · Philippe Mathieu-Daudé

ping?

Quoted 41 lines · Philippe Mathieu-Daudé

Ensure sev_fw_errlist[] is updated after running
the update-linux-headers.sh script.

---
Based-on: <[email protected]>

---
 target/i386/sev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
target/i386/sev.c +4 -1
index 37690ae809c..92c69a23769 100644
@@ -87,7 +87,7 @@ typedef struct __attribute__((__packed__)) SevInfoBlock {
 static SevGuestState *sev_guest;
 static Error *sev_mig_blocker;
 
-static const char *const sev_fw_errlist[] = {
+static const char *const sev_fw_errlist[SEV_RET_MAX] = {
     [SEV_RET_SUCCESS]                = "",
     [SEV_RET_INVALID_PLATFORM_STATE] = "Platform state is invalid",
     [SEV_RET_INVALID_GUEST_STATE]    = "Guest state is invalid",
@@ -114,6 +114,8 @@ static const char *const sev_fw_errlist[] = {
     [SEV_RET_RESOURCE_LIMIT]         = "Required firmware resource depleted",
     [SEV_RET_SECURE_DATA_INVALID]    = "Part-specific integrity check failure",
 };
+/* Ensure sev_fw_errlist[] is updated after running update-linux-headers.sh */
+QEMU_BUILD_BUG_ON(SEV_RET_SECURE_DATA_INVALID + 1 != SEV_RET_MAX);
 
 #define SEV_FW_MAX_ERROR      ARRAY_SIZE(sev_fw_errlist)
 
@@ -160,6 +162,7 @@ fw_error_to_str(int code)
     if (code < 0 || code >= SEV_FW_MAX_ERROR) {
         return "unknown error";
     }
+    assert(sev_fw_errlist[code]);
 
     return sev_fw_errlist[code];
 }
Acked-by
#4 lore raw
Quoted 12 lines · Philippe Mathieu-Daudé

ping^2?

Quoted 9 lines · Philippe Mathieu-Daudé

ping?

Quoted 6 lines · Philippe Mathieu-Daudé

Ensure sev_fw_errlist[] is updated after running
the update-linux-headers.sh script.

---
Based-on: <[email protected]>

I am in the favor to keep list in sync with header updates. thanks

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
---
 target/i386/sev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
target/i386/sev.c +4 -1
index 37690ae809c..92c69a23769 100644
@@ -87,7 +87,7 @@ typedef struct __attribute__((__packed__)) SevInfoBlock {
 static SevGuestState *sev_guest;
 static Error *sev_mig_blocker;
 
-static const char *const sev_fw_errlist[] = {
+static const char *const sev_fw_errlist[SEV_RET_MAX] = {
     [SEV_RET_SUCCESS]                = "",
     [SEV_RET_INVALID_PLATFORM_STATE] = "Platform state is invalid",
     [SEV_RET_INVALID_GUEST_STATE]    = "Guest state is invalid",
@@ -114,6 +114,8 @@ static const char *const sev_fw_errlist[] = {
     [SEV_RET_RESOURCE_LIMIT]         = "Required firmware resource depleted",
     [SEV_RET_SECURE_DATA_INVALID]    = "Part-specific integrity check failure",
 };
+/* Ensure sev_fw_errlist[] is updated after running update-linux-headers.sh */
+QEMU_BUILD_BUG_ON(SEV_RET_SECURE_DATA_INVALID + 1 != SEV_RET_MAX);
 
 #define SEV_FW_MAX_ERROR      ARRAY_SIZE(sev_fw_errlist)
 
@@ -160,6 +162,7 @@ fw_error_to_str(int code)
     if (code < 0 || code >= SEV_FW_MAX_ERROR) {
         return "unknown error";
     }
+    assert(sev_fw_errlist[code]);
 
     return sev_fw_errlist[code];
 }
#5 lore raw
In reply to Philippe Mathieu-Daudé

This patch was supposed to go via Eduardo's tree but he missed it, can it go via qemu-trivial instead?

Quoted 41 lines · Philippe Mathieu-Daudé

Ensure sev_fw_errlist[] is updated after running
the update-linux-headers.sh script.

---
Based-on: <[email protected]>

---
 target/i386/sev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
target/i386/sev.c +4 -1
index 37690ae809c..92c69a23769 100644
@@ -87,7 +87,7 @@ typedef struct __attribute__((__packed__)) SevInfoBlock {
 static SevGuestState *sev_guest;
 static Error *sev_mig_blocker;
 
-static const char *const sev_fw_errlist[] = {
+static const char *const sev_fw_errlist[SEV_RET_MAX] = {
     [SEV_RET_SUCCESS]                = "",
     [SEV_RET_INVALID_PLATFORM_STATE] = "Platform state is invalid",
     [SEV_RET_INVALID_GUEST_STATE]    = "Guest state is invalid",
@@ -114,6 +114,8 @@ static const char *const sev_fw_errlist[] = {
     [SEV_RET_RESOURCE_LIMIT]         = "Required firmware resource depleted",
     [SEV_RET_SECURE_DATA_INVALID]    = "Part-specific integrity check failure",
 };
+/* Ensure sev_fw_errlist[] is updated after running update-linux-headers.sh */
+QEMU_BUILD_BUG_ON(SEV_RET_SECURE_DATA_INVALID + 1 != SEV_RET_MAX);
 
 #define SEV_FW_MAX_ERROR      ARRAY_SIZE(sev_fw_errlist)
 
@@ -160,6 +162,7 @@ fw_error_to_str(int code)
     if (code < 0 || code >= SEV_FW_MAX_ERROR) {
         return "unknown error";
     }
+    assert(sev_fw_errlist[code]);
 
     return sev_fw_errlist[code];
 }
#6 lore raw
Quoted 2 lines · Philippe Mathieu-Daudé

This patch was supposed to go via Eduardo's tree but he missed it, can it go via qemu-trivial instead?

My apologies, again. I'm still behind on my qemu-devel backlog, and this was still buried in my inbox.

Quoted 20 lines · Philippe Mathieu-Daudé
Quoted 18 lines

Ensure sev_fw_errlist[] is updated after running
the update-linux-headers.sh script.

---
Based-on: <[email protected]>

---
 target/i386/sev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
target/i386/sev.c +0 -0
index 37690ae809c..92c69a23769 100644
@@ -87,7 +87,7 @@ typedef struct __attribute__((__packed__)) SevInfoBlock {
 static SevGuestState *sev_guest;
 static Error *sev_mig_blocker;
 
Quoted 11 lines

target/i386/sev.c static const char *const sev_fw_errlist[] = { · line 118

Quoted 11 lines
target/i386/sev.c +3 -1
-static const char *const sev_fw_errlist[] = {
+static const char *const sev_fw_errlist[SEV_RET_MAX] = {
     [SEV_RET_SUCCESS]                = "",
     [SEV_RET_INVALID_PLATFORM_STATE] = "Platform state is invalid",
     [SEV_RET_INVALID_GUEST_STATE]    = "Guest state is invalid",
@@ -114,6 +114,8 @@ static const char *const sev_fw_errlist[] = {
     [SEV_RET_RESOURCE_LIMIT]         = "Required firmware resource depleted",
     [SEV_RET_SECURE_DATA_INVALID]    = "Part-specific integrity check failure",
 };
+/* Ensure sev_fw_errlist[] is updated after running update-linux-headers.sh */
+QEMU_BUILD_BUG_ON(SEV_RET_SECURE_DATA_INVALID + 1 != SEV_RET_MAX);

A mechanism to notify us when sev_fw_errlist needs to be updated would be useful, but I'm not sure I agree with this change. I expect update-linux-headers patches always consist of 100% automated changes. This patch would require a manual update of target/i386/sev.c to be included in the same commit as the header update.

Quoted 13 lines
Quoted 12 lines
target/i386/sev.c +1 -0
 #define SEV_FW_MAX_ERROR      ARRAY_SIZE(sev_fw_errlist)
 
@@ -160,6 +162,7 @@ fw_error_to_str(int code)
     if (code < 0 || code >= SEV_FW_MAX_ERROR) {
         return "unknown error";
     }
+    assert(sev_fw_errlist[code]);
 
     return sev_fw_errlist[code];
 }
Signature · 1 line
Eduardo
#7 lore raw
Quoted 37 lines · Eduardo Habkost
Quoted 2 lines · Philippe Mathieu-Daudé

This patch was supposed to go via Eduardo's tree but he missed it, can it go via qemu-trivial instead?

My apologies, again. I'm still behind on my qemu-devel backlog, and this was still buried in my inbox.

Quoted 30 lines · Philippe Mathieu-Daudé
Quoted 28 lines

Ensure sev_fw_errlist[] is updated after running
the update-linux-headers.sh script.

---
Based-on: <[email protected]>

---
 target/i386/sev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
target/i386/sev.c +2 -1
index 37690ae809c..92c69a23769 100644
@@ -87,7 +87,7 @@ typedef struct __attribute__((__packed__)) SevInfoBlock {
 static SevGuestState *sev_guest;
 static Error *sev_mig_blocker;
 
-static const char *const sev_fw_errlist[] = {
+static const char *const sev_fw_errlist[SEV_RET_MAX] = {
     [SEV_RET_SUCCESS]                = "",
     [SEV_RET_INVALID_PLATFORM_STATE] = "Platform state is invalid",
     [SEV_RET_INVALID_GUEST_STATE]    = "Guest state is invalid",
@@ -114,6 +114,8 @@ static const char *const sev_fw_errlist[] = {
     [SEV_RET_RESOURCE_LIMIT]         = "Required firmware resource depleted",
     [SEV_RET_SECURE_DATA_INVALID]    = "Part-specific integrity check failure",
 };
+/* Ensure sev_fw_errlist[] is updated after running update-linux-headers.sh */
Quoted 8 lines
Quoted 1 line

target/i386/sev.c static const char *const sev_fw_errlist[] = { · line 118

Quoted 1 line
target/i386/sev.c +1 -0
+QEMU_BUILD_BUG_ON(SEV_RET_SECURE_DATA_INVALID + 1 != SEV_RET_MAX);

A mechanism to notify us when sev_fw_errlist needs to be updated would be useful, but I'm not sure I agree with this change. I expect update-linux-headers patches always consist of 100% automated changes. This patch would require a manual update of target/i386/sev.c to be included in the same commit as the header update.

OK :(