lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YhP+kES/UVx7RwYz@zn.tnic>
Date:   Mon, 21 Feb 2022 22:05:20 +0100
From:   Borislav Petkov <bp@...en8.de>
To:     "Kirill A. Shutemov" <kirill@...temov.name>
Cc:     aarcange@...hat.com, ak@...ux.intel.com, dan.j.williams@...el.com,
        dave.hansen@...el.com, david@...hat.com, hpa@...or.com,
        jgross@...e.com, jmattson@...gle.com, joro@...tes.org,
        jpoimboe@...hat.com, kirill.shutemov@...ux.intel.com,
        knsathya@...nel.org, linux-kernel@...r.kernel.org, luto@...nel.org,
        mingo@...hat.com, pbonzini@...hat.com, peterz@...radead.org,
        sathyanarayanan.kuppuswamy@...ux.intel.com, sdeep@...are.com,
        seanjc@...gle.com, tglx@...utronix.de, tony.luck@...el.com,
        vkuznets@...hat.com, wanpengli@...cent.com, x86@...nel.org
Subject: Re: [PATCHv3.1 2.1/2] x86/coco: Add API to handle encryption mask

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']

>     for set_memory_encrypted() and set_memory_decrypted()
>     implementation.
> 
> The implementation will be extended to cover TDX.
> 
> pgprot_decrypted() is used by drivers (i915, virtio_gpu, vfio).
> cc_mkdec() called by pgprot_decrypted(). Export cc_mkdec().
> 
> HyperV doesn't use bits in page table entries, so the mask is 0 for both
> encrypthion and decrypthion.

ditto.

> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index d77cf3a31f07..9af6be143998 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -346,7 +346,7 @@ static void __init ms_hyperv_init_platform(void)
>  		swiotlb_force = SWIOTLB_FORCE;
>  #endif
>  		if (hv_get_isolation_type() != HV_ISOLATION_TYPE_NONE)
> -			cc_init(CC_VENDOR_HYPERV);
> +			cc_init(CC_VENDOR_HYPERV, 0);
>  	}
>  
>  	if (hv_max_functions_eax >= HYPERV_CPUID_NESTED_FEATURES) {
> 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.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ