Re: [PATCH 2/2] x86/snp: Convert shared memory back to private on kexec

From: Kirill A. Shutemov
Date: Thu Feb 22 2024 - 05:50:31 EST


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?

--
Kiryl Shutsemau / Kirill A. Shutemov