qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v8 10/28] sev/i386: add command to initialize th


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH v8 10/28] sev/i386: add command to initialize the memory encryption context
Date: Mon, 12 Feb 2018 16:57:13 -0200
User-agent: Mutt/1.9.1 (2017-09-22)

On Mon, Feb 12, 2018 at 09:36:57AM -0600, Brijesh Singh wrote:
[...]
> +#define SEV_FW_MAX_ERROR      0x17
> +
> +static const char *const sev_fw_errlist[] = {

This requires anybody reading the code to manually count the
number of items on the array to be sure fw_error_to_str() is
safe.

What about:
  #define SEV_FW_MAX_ERROR ARRAY_SIZE(sev_fw_errlist)


> +    "",
> +    "Platform state is invalid",
> +    "Guest state is invalid",
> +    "Platform configuration is invalid",
> +    "Buffer too small",
> +    "Platform is already owned",
> +    "Certificate is invalid",
> +    "Policy is not allowed",
> +    "Guest is not active",
> +    "Invalid address",
> +    "Bad signature",
> +    "Bad measurement",
> +    "Asid is already owned",
> +    "Invalid ASID",
> +    "WBINVD is required",
> +    "DF_FLUSH is required",
> +    "Guest handle is invalid",
> +    "Invalid command",
> +    "Guest is active",
> +    "Hardware error",
> +    "Hardware unsafe",
> +    "Feature not supported",
> +    "Invalid parameter"
> +};
[...]
> +fw_error_to_str(int code)
> +{
> +    if (code >= SEV_FW_MAX_ERROR) {
> +        return "unknown error";
> +    }
> +
> +    return sev_fw_errlist[code];
> +}
> +

-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]