Re: [PATCH v8 10/28] sev/i386: add command to initialize the memory encryption context

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

 



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



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux