mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Pratik R. Sampat" <prsampat@amd.com>
To: Tom Lendacky <thomas.lendacky@amd.com>,
	mcgrof@kernel.org, russ.weight@linux.dev, dakr@kernel.org,
	ashish.kalra@amd.com, herbert@gondor.apana.org.au,
	davem@davemloft.net
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org, rafael@kernel.org,
	chao.gao@intel.com, aik@amd.com, tycho@kernel.org,
	nikunj@amd.com, michael.roth@amd.com, shansinha@google.com
Subject: Re: [Patch v3 7/7] crypto/ccp: Implement SNP Download Firmware EX
Date: Tue, 6 Oct 2026 12:55:48 -0500	[thread overview]
Message-ID: <c3384e1e-6fa4-4b3b-aaa5-a325bffcd10d@amd.com> (raw)
In-Reply-To: <66568327-9b4b-474d-bd48-667ec3bee6c8@amd.com>



On 10/6/26 12:32 PM, Tom Lendacky wrote:
> On 10/6/26 11:41, Pratik R. Sampat wrote:
>> Hi Tom,
>>
>> Thanks for the review!
>>
>> On 10/6/26 11:10 AM, Tom Lendacky wrote:
>>> On 10/5/26 11:15, Pratik R. Sampat wrote:
>>>> Implement SNP live firmware update using the DOWNLOAD_FIRMWARE_EX
>>>> command.
>>>>
>>>> DOWNLOAD_FIRMWARE_EX requires the legacy SEV platform to be UNINIT. If
>>>> it is WORKING then legacy guests are running and the update is refused
>>>> as busy. If it is INIT, shut it down, release the buffers the firmware
>>>> owns across that shutdown, run the update, and bring the platform back
>>>> up afterwards. SNP is never taken down, so SNP guests are unaffected.
>>>>
>>>> To test run the following with your sbin file in FW:
>>>>
>>>> echo 1 > /sys/class/firmware/sev/loading
>>>> cat <firmware.sbin> > /sys/class/firmware/sev/data
>>>> echo 0 > /sys/class/firmware/sev/loading
>>>>
>>>> The COMMIT bit is left clear, so the image is only loaded provisionally
>>>> and the admin decides when to make it permanent with ioctl(/dev/sev,
>>>> SNP_COMMIT). To roll back, do not commit and upload the previous image
>>>> the same way.
>>>>
>>>> Co-developed-by: Tycho Andersen (AMD) <tycho@kernel.org>
>>>> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
>>>> Signed-off-by: Pratik R. Sampat <prsampat@amd.com>
> 
>>>>  #ifdef CONFIG_FW_UPLOAD
>>>> +/* Largest image the firmware accepts, anything above is rejected */
>>>
>>> I may have missed it, but I don't see anything in the SNP ABI spec that
>>> says the limit is 512K. If that doesn't have a limit how did we arrive
>>> at 512K?
>>>
>>
>> The ABI spec doesn't mention it, but the firmware had this limit hard-coded.
>> This can potentially change without notice to the ABI. However, I did want a
>> sanity check in the OS and that's why had it in.
>>
>> I can drop it and let the firmware fail if the image is too large.
> 
> The memory holding the firmware on the call to the ASP has to be
> contiguous, so you're likely to fail on the alloc_pages() if the image
> is too large. Up to you if you want to keep it.

Sure.

>>
>>>> +#define SEV_FW_IMAGE_MAX_SIZE	SZ_512K
>>>> +
> 
>>>> +
>>>> +	__sev_release_firmware_buffers(false);
>>>
>>> Do the buffers have to be released? If so, why? I think you can keep the
>>> allocations. During platform initialization the buffers will be
>>> detected. Is there a shutdown path where they might not get freed?
>>>
>>
>> Shantanu hit this on Milan with an earlier version of the series that kept the
>> buffers across the update [1]. After DOWNLOAD_FIRMWARE_EX the new firmware
>> rejected INIT_EX with SEV_RET_INVALID_PAGE_STATE (0x1A), because sev_es_tmr and
>> sev_init_ex_buffer were still in the firmware state left over from the previous
>> image's INIT. Freeing them, and letting re-init allocate fresh ones, fixed it,
>> which is where this call came from.
>>
>> However, a fresh allocation with SNP initialized just goes through
>> rmp_mark_pages_firmware(), so my understanding of what the new firmware needs
>> is the reclaim -> make shared -> mark firmware cycle, not necessarily new
>> memory.
>>
>> Freeing seemed like the easiest option, but if you prefer, just cycling them
>> back should be able to achieve the same effect, I believe.
>>
>> [1] https://lore.kernel.org/all/20260831204757.436751-1-shansinha@google.com/
> 
> Sounds like some good info to have as a comment above the call then.
> 

Will do!

Thanks,
--Pratik

> Thanks,
> Tom
> 


  reply	other threads:[~2026-10-06 17:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 16:15 [Patch v3 0/7] Implement SNP live firmware update support Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 1/7] firmware_loader: Stop pinning modules on registration Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 2/7] firmware_loader: Stop pinning parent device per workqueue invocation Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 3/7] treewide: firmware_loader: Drop the unused @module argument Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 4/7] crypto: ccp - Factor out the release of the SEV firmware buffers Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 5/7] crypto: ccp - Allow SNP platform data to be queried after SNP INIT Pratik R. Sampat
2026-10-06 14:45   ` Tom Lendacky
2026-10-06 14:50     ` Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 6/7] crypto/ccp: Register with fw_uploader and always fail Pratik R. Sampat
2026-10-06 20:24   ` Shantanu Sinha
2026-10-07 15:36     ` Pratik R. Sampat
2026-10-07 13:55   ` Tom Lendacky
2026-10-05 16:15 ` [Patch v3 7/7] crypto/ccp: Implement SNP Download Firmware EX Pratik R. Sampat
2026-10-06 16:10   ` Tom Lendacky
2026-10-06 16:41     ` Pratik R. Sampat
2026-10-06 17:32       ` Tom Lendacky
2026-10-06 17:55         ` Pratik R. Sampat [this message]
2026-10-06 21:09           ` Shantanu Sinha
2026-10-07 15:36             ` Pratik R. Sampat

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=c3384e1e-6fa4-4b3b-aaa5-a325bffcd10d@amd.com \
    --to=prsampat@amd.com \
    --cc=aik@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=chao.gao@intel.com \
    --cc=dakr@kernel.org \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=michael.roth@amd.com \
    --cc=nikunj@amd.com \
    --cc=rafael@kernel.org \
    --cc=russ.weight@linux.dev \
    --cc=shansinha@google.com \
    --cc=thomas.lendacky@amd.com \
    --cc=tycho@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

all inboxes | Powered by JetHome®