lkml.org 
[lkml]   [2022]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCHv3.1 2.1/2] x86/coco: Add API to handle encryption mask
On Mon, Feb 21, 2022 at 10:05:20PM +0100, Borislav Petkov wrote:
> On Sat, Feb 19, 2022 at 03:13:05AM +0300, Kirill A. Shutemov wrote:
> > AMD SME/SEV uses a bit in the page table entries to indicate that the
> > page is encrypted and not accessible to the VMM.
> >
> > TDX uses a similar approach, but the polarity of the mask is opposite to
> > AMD: if the bit is set the page is accessible to VMM.
> >
> > Provide vendor-neutral API to deal with the mask:
> >
> > - cc_mkenc() and cc_mkdec() modify given address to make it
> > encrypted/decrypted. It can be applied to phys_addr_t, pgprotval_t
> > or page table entry value.
> >
> > - cc_get_mask() returns encryption or decrypthion mask. It is useful
>
> Unknown word [encrypthion] in commit message.
> Suggestions: ['encryption', 'decryption']
>
> Unknown word [decrypthion] in commit message.
> Suggestions: ['decryption', 'encryption']

Ughh. Sorry. Will fix.

> > diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c
> > index eb7fbd85b77e..fa758247ab57 100644
> > --- a/arch/x86/mm/mem_encrypt_identity.c
> > +++ b/arch/x86/mm/mem_encrypt_identity.c
> > @@ -603,5 +603,5 @@ void __init sme_enable(struct boot_params *bp)
> > out:
> > physical_mask &= ~sme_me_mask;
> > if (sme_me_mask)
> > - cc_init(CC_VENDOR_AMD);
> > + cc_init(CC_VENDOR_AMD, sme_me_mask);
>
> I'm wondering why this is looking weird... an init function with two
> arguments which get assigned. I think it would be better if you do:
>
> cc_set_vendor(CC_VENDOR_XXX);
> cc_set_mask(mask);
>
> and those helpers simply assign to __ro_after_init, local variables.
>
> IOW, simple setter functions.

I'm not sure it is a good idea. It leaves room for code between these two
calls. I believe they conceptually has to initialized in one shot. That's
the only way we get consistent state.

--
Kirill A. Shutemov

\
 
 \ /
  Last update: 2022-02-21 23:11    [W:0.124 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site