From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eduardo Habkost Subject: Re: [PATCH v8 10/28] sev/i386: add command to initialize the memory encryption context Date: Mon, 12 Feb 2018 16:57:13 -0200 Message-ID: <20180212185713.GS13981@localhost.localdomain> References: <20180212153715.87555-1-brijesh.singh@amd.com> <20180212153715.87555-11-brijesh.singh@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: qemu-devel@nongnu.org, Alistair Francis , Christian Borntraeger , Cornelia Huck , "Daniel P . Berrange" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eric Blake , kvm@vger.kernel.org, Marcel Apfelbaum , Markus Armbruster , Paolo Bonzini , Peter Crosthwaite , Peter Maydell , Richard Henderson , Stefan Hajnoczi , Thomas Lendacky , Borislav Petkov , To: Brijesh Singh Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60034 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753575AbeBLS5X (ORCPT ); Mon, 12 Feb 2018 13:57:23 -0500 Content-Disposition: inline In-Reply-To: <20180212153715.87555-11-brijesh.singh@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: 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