[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b7a719b-d7ff-495e-af3f-a419e4b46d96@amd.com>
Date: Thu, 22 Feb 2024 07:58:21 -0600
From: Tom Lendacky <thomas.lendacky@....com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Ashish Kalra <Ashish.Kalra@....com>, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com,
luto@...nel.org, x86@...nel.org, ardb@...nel.org, hpa@...or.com,
linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org, rafael@...nel.org,
peterz@...radead.org, adrian.hunter@...el.com,
sathyanarayanan.kuppuswamy@...ux.intel.com, elena.reshetova@...el.com,
jun.nakajima@...el.com, rick.p.edgecombe@...el.com, seanjc@...gle.com,
kai.huang@...el.com, bhe@...hat.com, kexec@...ts.infradead.org,
linux-coco@...ts.linux.dev, anisinha@...hat.com, michael.roth@....com,
bdas@...hat.com, vkuznets@...hat.com, dionnaglaze@...gle.com,
jroedel@...e.de, ashwin.kamat@...adcom.com
Subject: Re: [PATCH 2/2] x86/snp: Convert shared memory back to private on
kexec
On 2/22/24 04:50, Kirill A. Shutemov wrote:
> On Wed, Feb 21, 2024 at 02:35:13PM -0600, Tom Lendacky wrote:
>>> @@ -906,6 +917,206 @@ void snp_accept_memory(phys_addr_t start, phys_addr_t end)
>>> set_pages_state(vaddr, npages, SNP_PAGE_STATE_PRIVATE);
>>> }
>>> +static inline bool pte_decrypted(pte_t pte)
>>> +{
>>> + return cc_mkdec(pte_val(pte)) == pte_val(pte);
>>> +}
>>> +
>>
>> This is duplicated in TDX code, arch/x86/coco/tdx/tdx.c, looks like
>> something that can go in a header file, maybe mem_encrypt.h.
>>
>
> I think <asm/pgtable.h> is a better fit.
>
>>> +void snp_kexec_stop_conversion(bool crash)
>>> +{
>>> + /* Stop new private<->shared conversions */
>>> + conversion_allowed = false;
>>> + crash_requested = crash;
>>> +
>>> + /*
>>> + * Make sure conversion_allowed is cleared before checking
>>> + * conversions_in_progress.
>>> + */
>>> + barrier();
>>
>> This should be smp_wmb().
>>
>
> Why?
IIUC, this is because conversions_in_progress can be set on another thread
and so this needs an smp barrier. In this case, smp_wmb() just ends up
being barrier(), but to me it is clearer this way. Just my opinion, though.
Thanks,
Tom
>
Powered by blists - more mailing lists