mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nikunj A. Dadhania" <nikunj@amd.com>
To: Tom Lendacky <thomas.lendacky@amd.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org
Cc: bp@alien8.de, dionnaglaze@google.com, pgonda@google.com,
	seanjc@google.com, pbonzini@redhat.com
Subject: Re: [PATCH v3 05/14] virt: sev-guest: Add vmpck_id to snp_guest_dev struct
Date: Thu, 3 Aug 2023 10:32:50 +0530	[thread overview]
Message-ID: <0057973e-28fa-0dd2-421f-6af0fbe260a4@amd.com> (raw)
In-Reply-To: <cae0b2e9-12e6-9d2c-506e-0dc6f72988a4@amd.com>

On 8/2/2023 10:25 PM, Tom Lendacky wrote:
> On 8/1/23 23:12, Nikunj A. Dadhania wrote:
>> On 8/1/2023 10:00 PM, Tom Lendacky wrote:
>>> 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.
>>
>> Yes, will add to the  commit.
>>
>>>
>>>>    {
>>>>        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.
>>
>> Sure, will update.
> 
> Ah, although I noticed that when the various functions are moved over to the other file, the key return value can be NULL, so probably not worth changing here.

I have removed the check in this patch, but the check is retained in the later patch where key can be NULL.

Regards
Nikunj


  reply	other threads:[~2023-08-03  5:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-22 11:18 [PATCH v3 00/14] Add Secure TSC support for SNP guests Nikunj A Dadhania
2023-07-22 11:18 ` [PATCH v3 01/14] virt: sev-guest: Use AES GCM crypto library Nikunj A Dadhania
2023-08-01 15:32   ` Tom Lendacky
2023-07-22 11:18 ` [PATCH v3 02/14] virt: sev-guest: Move mutex to SNP guest device structure Nikunj A Dadhania
2023-07-22 11:18 ` [PATCH v3 03/14] virt: sev-guest: Replace pr_debug with dev_dbg Nikunj A Dadhania
2023-08-01 15:34   ` Tom Lendacky
2023-08-02  4:08     ` Nikunj A. Dadhania
2023-07-22 11:18 ` [PATCH v3 04/14] virt: sev-guest: Add SNP guest request structure Nikunj A Dadhania
2023-08-01 15:49   ` Tom Lendacky
2023-08-02  4:10     ` Nikunj A. Dadhania
2023-07-22 11:19 ` [PATCH v3 05/14] virt: sev-guest: Add vmpck_id to snp_guest_dev struct Nikunj A Dadhania
2023-08-01 16:30   ` Tom Lendacky
2023-08-02  4:12     ` Nikunj A. Dadhania
2023-08-02 16:55       ` Tom Lendacky
2023-08-03  5:02         ` Nikunj A. Dadhania [this message]
2023-07-22 11:19 ` [PATCH v3 06/14] x86/sev: Cache the secrets page address Nikunj A Dadhania
2023-08-01 16:34   ` Tom Lendacky
2023-07-22 11:19 ` [PATCH v3 07/14] x86/sev: Move and reorganize sev guest request api Nikunj A Dadhania
2023-07-22 11:19 ` [PATCH v3 08/14] x86/mm: Add generic guest initialization hook Nikunj A Dadhania
2023-07-22 11:19 ` [PATCH v3 09/14] x86/sev: Add Secure TSC support for SNP guests Nikunj A Dadhania
2023-07-22 11:19 ` [PATCH v3 10/14] x86/sev: Change TSC MSR behavior for Secure TSC enabled guests Nikunj A Dadhania
2023-07-22 11:19 ` [PATCH v3 11/14] x86/sev: Prevent RDTSC/RDTSCP interception " Nikunj A Dadhania
2023-07-22 11:19 ` [PATCH v3 12/14] x86/kvmclock: Skip kvmclock when Secure TSC is available Nikunj A Dadhania
2023-07-22 11:19 ` [PATCH v3 13/14] x86/tsc: Mark Secure TSC as reliable clocksource Nikunj A Dadhania
2023-07-22 11:19 ` [PATCH v3 14/14] x86/sev: Enable Secure TSC for SNP guests Nikunj A Dadhania
2023-08-01  4:47 ` [PATCH v3 00/14] Add Secure TSC support " Nikunj A. Dadhania

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0057973e-28fa-0dd2-421f-6af0fbe260a4@amd.com \
    --to=nikunj@amd.com \
    --cc=bp@alien8.de \
    --cc=dionnaglaze@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=seanjc@google.com \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome