Messages in this thread | | | Date | Tue, 1 Aug 2023 11:30:07 -0500 | Subject | Re: [PATCH v3 05/14] virt: sev-guest: Add vmpck_id to snp_guest_dev struct | From | Tom Lendacky <> |
| |
On 7/22/23 06:19, Nikunj A Dadhania wrote: > Drop vmpck and os_area_msg_seqno pointers so that secret page layout > does not need to be exposed to the sev-guest driver after the rework. > Instead, add helper APIs to access vmpck and os_area_msg_seqno when > needed. > > Signed-off-by: Nikunj A Dadhania <nikunj@amd.com> > --- > drivers/virt/coco/sev-guest/sev-guest.c | 84 +++++++++++++------------ > 1 file changed, 43 insertions(+), 41 deletions(-) > > diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c > index d4241048b397..8ad43e007d3b 100644 > --- a/drivers/virt/coco/sev-guest/sev-guest.c > +++ b/drivers/virt/coco/sev-guest/sev-guest.c > @@ -50,8 +50,7 @@ struct snp_guest_dev { > > struct snp_secrets_page_layout *layout; > struct snp_req_data input; > - u32 *os_area_msg_seqno; > - u8 *vmpck; > + unsigned int vmpck_id; > }; > > static u32 vmpck_id; > @@ -67,12 +66,23 @@ static inline unsigned int get_ctx_authsize(struct snp_guest_dev *snp_dev) > return 0; > } > > -static bool is_vmpck_empty(struct snp_guest_dev *snp_dev) > +static inline u8 *snp_get_vmpck(struct snp_guest_dev *snp_dev) > +{ > + return snp_dev->layout->vmpck0 + snp_dev->vmpck_id * VMPCK_KEY_LEN; > +} > + > +static inline u32 *snp_get_os_area_msg_seqno(struct snp_guest_dev *snp_dev) > +{ > + return &snp_dev->layout->os_area.msg_seqno_0 + snp_dev->vmpck_id; > +} > + > +static bool snp_is_vmpck_empty(struct snp_guest_dev *snp_dev)
I noticed this name change from is_vmpck_empty() to snp_is_vmpck_empty(). Is that in prep for moving, too? Is so, maybe call that out in the commit message.
> { > char zero_key[VMPCK_KEY_LEN] = {0}; > + u8 *key = snp_get_vmpck(snp_dev); > > - if (snp_dev->vmpck) > - return !memcmp(snp_dev->vmpck, zero_key, VMPCK_KEY_LEN); > + if (key) > + return !memcmp(key, zero_key, VMPCK_KEY_LEN);
I believe key can't be NULL, so this check isn't required.
Thanks, Tom
> > return true; > }
| |