Re: [Part2 PATCH v5.1 12.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command

From: Brijesh Singh
Date: Wed Oct 11 2017 - 16:53:58 EST




On 10/11/2017 03:45 PM, Brijesh Singh wrote:


On 10/11/2017 03:28 PM, Borislav Petkov wrote:
On Wed, Oct 11, 2017 at 03:10:49PM -0500, Brijesh Singh wrote:
The current 'struct sev_data_status' matches with the firmware names and the
bit fields. Only thing I did was the fields with no name is called as
"reservedX"

Ok, I see it. So what you actually wanna do is:

struct sev_data_status {
ÂÂÂÂÂÂÂÂ u8 api_major;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u8 api_minor;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u8 state;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u8 flags;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u32 config;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u32 guest_count;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
} __packed;


OK, if userspace is going to pick bits apart then how about this:

Âstruct sev_data_status {
ÂÂÂÂÂÂÂÂ u8 api_major;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u8 api_minor;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u8 state;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u32 flags;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u8 build;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
ÂÂÂÂÂÂÂÂ u32 guest_count;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Out */
Â} __packed;



BTW, I kept the build name because KVM driver prints some debug information like this:

pr_info_once("SEV: api_major %d api_minor %d build %d\n",
status->api_major, status->api_minor, status->build);

Of course, I can modify it to access bit field if we decide to go with your recommended structure - thanks