diff options
author | Kirill A. Shutemov <kirill.shutemov@linux.intel.com> | 2022-02-22 21:57:40 +0300 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2022-02-23 19:14:29 +0100 |
commit | b577f542f93cbba57f8d6185ef1fb13a41ddf162 (patch) | |
tree | d64dab5aa4ad840955371fc024c3e0037929f682 /arch/x86/include/asm/coco.h | |
parent | 655a0fa34b4f7ac6e2b1406fab15e52a7b6accb1 (diff) | |
download | linux-b577f542f93cbba57f8d6185ef1fb13a41ddf162.tar.gz linux-b577f542f93cbba57f8d6185ef1fb13a41ddf162.tar.bz2 linux-b577f542f93cbba57f8d6185ef1fb13a41ddf162.zip |
x86/coco: Add API to handle encryption mask
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.
pgprot_encrypted() and pgprot_decrypted() reimplemented using new
helpers.
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().
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20220222185740.26228-5-kirill.shutemov@linux.intel.com
Diffstat (limited to 'arch/x86/include/asm/coco.h')
-rw-r--r-- | arch/x86/include/asm/coco.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/x86/include/asm/coco.h b/arch/x86/include/asm/coco.h index e49f9ddb6ae6..3d98c3a60d34 100644 --- a/arch/x86/include/asm/coco.h +++ b/arch/x86/include/asm/coco.h @@ -2,6 +2,8 @@ #ifndef _ASM_X86_COCO_H #define _ASM_X86_COCO_H +#include <asm/types.h> + enum cc_vendor { CC_VENDOR_NONE, CC_VENDOR_AMD, @@ -10,5 +12,21 @@ enum cc_vendor { }; void cc_set_vendor(enum cc_vendor v); +void cc_set_mask(u64 mask); + +#ifdef CONFIG_ARCH_HAS_CC_PLATFORM +u64 cc_mkenc(u64 val); +u64 cc_mkdec(u64 val); +#else +static inline u64 cc_mkenc(u64 val) +{ + return val; +} + +static inline u64 cc_mkdec(u64 val) +{ + return val; +} +#endif #endif /* _ASM_X86_COCO_H */ |