LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Brijesh Singh <brijesh.singh@amd.com>
To: Mingwei Zhang <mizhang@google.com>,
	Sean Christopherson <seanjc@google.com>
Cc: brijesh.singh@amd.com, Paolo Bonzini <pbonzini@redhat.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	John Allen <john.allen@amd.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm <kvm@vger.kernel.org>,
	linux-crypto@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Alper Gun <alpergun@google.com>, Borislav Petkov <bp@alien8.de>,
	David Rienjes <rientjes@google.com>,
	Marc Orr <marcorr@google.com>, Peter Gonda <pgonda@google.com>,
	Vipin Sharma <vipinsh@google.com>
Subject: Re: [PATCH v2 3/4] KVM: SVM: move sev_bind_asid to psp
Date: Thu, 9 Sep 2021 17:25:25 -0500	[thread overview]
Message-ID: <48af420f-20e3-719a-cf5c-e651a176e7c2@amd.com> (raw)
In-Reply-To: <CAL715W+u6mt5grwoT6DBhUtzN6xx=OjWPu6M0=p0sxLZ4JTvDg@mail.gmail.com>



On 9/9/21 4:18 PM, Mingwei Zhang wrote:
>>> Most of the address field in the "struct sev_data_*" are physical
>>> addressess. The userspace will not be able to populate those fields.
>>
>> Yeah, that's my biggest hesitation to using struct sev_data_* in the API, it's
>> both confusing and gross.  But it's also why I think these helpers belong in the
>> PSP driver, KVM should not need to know the "on-the-wire" format for communicating
>> with the PSP.
>>
> 
> Did a simple checking for all struct sev_data_* fields defined in psp-sev.h:

thank you for compiling the list, let me add few more at the end of your 
list (they are part of spec but PSP/KVM does not have support for it).

I am also adding SNP specific so that we get a full picture.

> 
> The average argument is roughly 4 (103/27), detailed data appended at
> last. In addition, I believe the most used commands would be the
> following?
> 
> #data structure name: number of meaningful fields
> sev_data_launch_start: 6
> sev_data_activate: 2
> sev_data_decommission: 1
> sev_data_receive_update_data: 7
> sev_data_send_update_vmsa: 7
> sev_data_launch_measure: 3
> sev_data_launch_finish: 1
> sev_data_deactivate: 1
> 

Once the page copy, and swap in/out is implemented then it will also be 
frequently used.

sev_data_copy: 4
sev_swap_out: 12
sev_swap_in: 7

snp_data_gctx_create: 1
snp_data_activate: 2
snp_data_deactivate: 2
snp_data_decommission: 1
snp_data_launch_start: 6
snp_data_launch_update: 8
snp_data_launch_finish: 6
snp_data_page_move: 4
snp_data_page_swap_out: 8
snp_data_page_swap_in: 8
snp_data_page_reclaim: 2
snp_guest_request: 3
snp_guest_request_ext: 5


> For the above frequently-used command set, the average argument length
> is also around 3-4 (28/8) on average, 2.5 as the median.
> 

It averages around 4-5 (51/11) without snp. The good news is with snp 
the avg is still 4-5 (107/24).

Additionally, we also need to pass the sev->fd in each of these 
functions, which will increase avg to 5-6.


> So, from that perspective, I think we should just remove those
> sev_data data structures in KVM, since it is more clear to read each
> argument.
> 

I believe once we are done with it, will have 5 functions that will need 
 >=8 arguments. I don't know if its acceptable.

> In addition, having to construct each sev_data_* structure in KVM code
> is also a pain and  consumes a lot of irrelevant lines as well.
> 

Maybe I am missing something, aren't those lines will be moved from KVM 
to PSP driver?

I am in full support for restructuring, but lets look at full set of PSP 
APIs before making the final decision.

thanks

> #data structure name: number of meaningful fields
> sev_data_deactivate: 1
> sev_data_decommission: 1
> sev_data_launch_finish: 1
> sev_data_receive_finish: 1
> sev_data_send_cancel: 1
> sev_data_send_finish: 1
> sev_data_activate: 2
> sev_data_download_firmware: 2
> sev_data_get_id: 2
> sev_data_pek_csr: 2
> sev_data_init: 3
> sev_data_launch_measure: 3
> sev_data_launch_update_data: 3
> sev_data_launch_update_vmsa: 3
> sev_data_attestation_report: 4
> sev_data_dbg: 4
> sev_data_guest_status: 4
> sev_data_pdh_cert_export: 4
> sev_data_pek_cert_import: 4
> sev_data_launch_start: 6
> sev_data_receive_start: 6
> sev_data_launch_secret: 7
> sev_data_receive_update_data: 7
> sev_data_receive_update_vmsa: 7
> sev_data_send_update_data: 7
> sev_data_send_update_vmsa: 7
> sev_data_send_start: 10
> 

  reply	other threads:[~2021-09-09 22:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18  5:39 [PATCH v2 0/4] clean up interface between KVM and psp Mingwei Zhang
2021-08-18  5:39 ` [PATCH v2 1/4] KVM: SVM: fix missing sev_decommission in sev_receive_start Mingwei Zhang
2021-08-21  2:11   ` Marc Orr
2021-08-21  2:30     ` Marc Orr
2021-08-18  5:39 ` [PATCH v2 2/4] KVM: SVM: move sev_decommission to psp driver Mingwei Zhang
2021-08-18  5:39 ` [PATCH v2 3/4] KVM: SVM: move sev_bind_asid to psp Mingwei Zhang
2021-09-03 19:38   ` Sean Christopherson
2021-09-07 16:30     ` Brijesh Singh
2021-09-07 23:37       ` Sean Christopherson
2021-09-09 16:07         ` Brijesh Singh
2021-09-09 18:13           ` Sean Christopherson
2021-09-09 21:18             ` Mingwei Zhang
2021-09-09 22:25               ` Brijesh Singh [this message]
2021-09-10  1:18                 ` Mingwei Zhang
2021-09-10  1:23                   ` Marc Orr
2021-08-18  5:39 ` [PATCH v2 4/4] KVM: SVM: move sev_unbind_asid and DF_FLUSH logic into psp Mingwei Zhang

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=48af420f-20e3-719a-cf5c-e651a176e7c2@amd.com \
    --to=brijesh.singh@amd.com \
    --cc=alpergun@google.com \
    --cc=bp@alien8.de \
    --cc=jmattson@google.com \
    --cc=john.allen@amd.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=mizhang@google.com \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=rientjes@google.com \
    --cc=seanjc@google.com \
    --cc=thomas.lendacky@amd.com \
    --cc=vipinsh@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --subject='Re: [PATCH v2 3/4] KVM: SVM: move sev_bind_asid to psp' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).