From: Tom Lendacky <thomas.lendacky@amd.com>
To: Alexey Kardashevskiy <aik@amd.com>, linux-kernel@vger.kernel.org
Cc: linux-crypto@vger.kernel.org, John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Ashish Kalra <ashish.kalra@amd.com>,
Joerg Roedel <joro@8bytes.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
Kim Phillips <kim.phillips@amd.com>,
Jerry Snitselaar <jsnitsel@redhat.com>,
Vasant Hegde <vasant.hegde@amd.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
Gao Shiyuan <gaoshiyuan@baidu.com>,
Sean Christopherson <seanjc@google.com>,
Nikunj A Dadhania <nikunj@amd.com>,
Michael Roth <michael.roth@amd.com>,
Amit Shah <amit.shah@amd.com>, Peter Gonda <pgonda@google.com>,
iommu@lists.linux.dev
Subject: Re: [PATCH kernel v2 5/5] crypto/ccp: Implement SEV-TIO PCIe IDE (phase1)
Date: Tue, 2 Dec 2025 08:24:16 -0600 [thread overview]
Message-ID: <745851ab-7776-4875-a57c-978fb10239d9@amd.com> (raw)
In-Reply-To: <de801efa-61fe-4540-8749-c3483e0f793e@amd.com>
On 12/1/25 20:04, Alexey Kardashevskiy wrote:
> On 2/12/25 02:23, Tom Lendacky wrote:
>> On 11/21/25 02:06, Alexey Kardashevskiy wrote:
>>> +struct sla_addr_t {
>>> + union {
>>> + u64 sla;
>>> + struct {
>>> + u64 page_type:1;
>>> + u64 page_size:1;
>>> + u64 reserved1:10;
>>> + u64 pfn:40;
>>> + u64 reserved2:12;
>>
>> u64 page_type :1,
>> page_size :1,
>> reserved1 :10,
>> pfn :40,
>> reserved2 :12;
>
> okay for formatting but...
>
>>
>> This makes it easier to understand. Please do this everywhere you define
>> bitfields.
>
> ...I really want to keep the union here (do not care in other places
> though) for easier comparison of a whole structure.
Yes, the union is fine, I was only referring to how to represent the
bitfields.
>
>
>>> @@ -1439,8 +1446,14 @@ static int __sev_snp_init_locked(int *error,
>>> unsigned int max_snp_asid)
>>> data.init_rmp = 1;
>>> data.list_paddr_en = 1;
>>> data.list_paddr = __psp_pa(snp_range_list);
>>> +
>>> +#if defined(CONFIG_PCI_TSM)
>>> data.tio_en = sev_tio_present(sev) &&
>>> + sev_tio_enabled && psp_init_on_probe &&
>>
>> Why add the psp_init_on_probe check here? Why is it not compatible?
>> psp_init_on_probe is for SEV and SEV-ES, not SNP.
>
> If psp_init_on_probe is not set, then systemd (or modprobe?) loads
> kvm_amd and at that point SEV init is delayed but SNP init is not so
> SEV-TIO gets enabled.
>
> Then, there is some systemd service in my test Ubuntu which:
> 1) runs QEMU to discover something, with SEV enabled, that trigger
> SEV_PDH_CERT_EXPORT
> 2) the kernel ioctl handler has to initialize SEV
> 3) sev_move_to_init_state() returns shutdown_required=true (it does not
> distinguish SEV and SNP)
> 4) the SEV_PDH_CERT_EXPORT handler shuts down both SEV and SNP (which
> includes SEV-TIO).
That seems like bad behavior. It should only shutdown SEV, not SNP.
>
> The right thing to do is just not use psp_init_on_probe as it is really
> a debugging knob. But people are going to use it while DOWNLOAD_EX
It's not a debugging knob, there are customers that use it.
> (which we need this psp_init_on_probe thing for) and SEV-TIO are still
> in their infancy. It took me half a day to sort this all in my head,
> hence the check.
>
> I will remove it from the above but leave the warning below and add the
> comment:
>
> /*
> * When psp_init_on_probe is disabled, the userspace calling SEV ioctl
> * can inadvertently shut down SNP and SEV-TIO during initialization,
> * causing unexpected state loss.
> */
Maybe a follow-on patch can fix the behavior so that SNP isn't shutdown
if it was already initialized.
>
>
>> Instead of the #if, please use IS_ENABLED(CONFIG_PCI_TSM) so that the
>> #ifdefs can be eliminated from the code.
>>
>> Having all these checks in sev_tio_supported() (comment from earlier
>> patch) will simplify things.
>
> I am open coding sev_tio_supported(), and ditching 4/5, seems pointless
> as hardly anyone will want to enable just TIO in the PSP without the
> host os support for it, right?
Ok, I'll check out the new version.
Thanks,
Tom
>
next prev parent reply other threads:[~2025-12-02 14:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 8:06 [PATCH kernel v2 0/5] PCI/TSM: Enabling core infrastructure on Alexey Kardashevskiy
2025-11-21 8:06 ` [PATCH kernel v2 1/5] ccp: Make snp_reclaim_pages and __sev_do_cmd_locked public Alexey Kardashevskiy
2025-11-21 8:06 ` [PATCH kernel v2 2/5] psp-sev: Assign numbers to all status codes and add new Alexey Kardashevskiy
2025-11-21 8:06 ` [PATCH kernel v2 3/5] iommu/amd: Report SEV-TIO support Alexey Kardashevskiy
2025-11-21 8:06 ` [PATCH kernel v2 4/5] crypto: ccp: Enable SEV-TIO feature in the PSP when supported Alexey Kardashevskiy
2025-12-01 14:31 ` Tom Lendacky
2025-11-21 8:06 ` [PATCH kernel v2 5/5] crypto/ccp: Implement SEV-TIO PCIe IDE (phase1) Alexey Kardashevskiy
2025-12-01 4:56 ` Aithal, Srikanth
2025-12-01 15:23 ` Tom Lendacky
2025-12-02 2:04 ` Alexey Kardashevskiy
2025-12-02 14:24 ` Tom Lendacky [this message]
2025-11-22 3:35 ` [PATCH kernel v2 0/5] PCI/TSM: Enabling core infrastructure on Alexey Kardashevskiy
2025-11-25 14:17 ` Joerg Roedel
2025-11-25 20:38 ` dan.j.williams
2025-11-26 8:38 ` Joerg Roedel
2025-12-01 15:27 ` Tom Lendacky
2025-12-01 20:40 ` dan.j.williams
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=745851ab-7776-4875-a57c-978fb10239d9@amd.com \
--to=thomas.lendacky@amd.com \
--cc=aik@amd.com \
--cc=amit.shah@amd.com \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=davem@davemloft.net \
--cc=gaoshiyuan@baidu.com \
--cc=herbert@gondor.apana.org.au \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=john.allen@amd.com \
--cc=joro@8bytes.org \
--cc=jsnitsel@redhat.com \
--cc=kim.phillips@amd.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=nikunj@amd.com \
--cc=pgonda@google.com \
--cc=robin.murphy@arm.com \
--cc=seanjc@google.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
--cc=will@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.