linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC, PATCH 00/22] Partial MKTME enabling
@ 2018-03-05 16:25 Kirill A. Shutemov
  2018-03-05 16:25 ` [RFC, PATCH 01/22] x86/cpufeatures: Add Intel Total Memory Encryption cpufeature Kirill A. Shutemov
                   ` (22 more replies)
  0 siblings, 23 replies; 62+ messages in thread
From: Kirill A. Shutemov @ 2018-03-05 16:25 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin, Tom Lendacky
  Cc: Dave Hansen, Kai Huang, linux-kernel, linux-mm, Kirill A. Shutemov

Hi everybody,

Here's updated version of my patchset that brings support of MKTME.
It's not yet complete, but I think it worth sharing to get early feedback.

Things that are missing:

 - kmap() is not yet wired up to support tempoprary mappings of encrypted
   pages. It's requried to allow kernel to access encrypted memory.

 - Interface to manipulate encryption keys.

 - Interface to create encrypted userspace mappings.

 - IOMMU support.

What has been done:

 - PCONFIG, TME and MKTME enumeration.

 - In-kernel helper that allows to program encryption keys into CPU.

 - Allocation and freeing encrypted pages.

 - Helpers to find out if a VMA/anon_vma/page is encrypted and with what
   KeyID.

Any feedback is welcome.

------------------------------------------------------------------------------

Multikey Total Memory Encryption (MKTME)[1] is a technology that allows
transparent memory encryption in upcoming Intel platforms.

MKTME is built on top of TME. TME allows encryption of the entirety of
system memory using a single key. MKTME allows to have multiple encryption
domains, each having own key -- different memory pages can be encrypted
with different keys.

Key design points of Intel MKTME:

 - Initial HW implementation would support upto 63 keys (plus one default
   TME key). But the number of keys may be as low as 3, depending to SKU
   and BIOS settings

 - To access encrypted memory you need to use mapping with proper KeyID
   int the page table entry. KeyID is encoded in upper bits of PFN in page
   table entry.

   This means we cannot use direct map to access encrypted memory from
   kernel side. My idea is to re-use kmap() interface to get proper
   temporary mapping on kernel side.

 - CPU does not enforce coherency between mappings of the same physical
   page with different KeyIDs or encryption keys. We wound need to take
   care about flushing cache on allocation of encrypted page and on
   returning it back to free pool.

 - For managing keys, there's MKTME_KEY_PROGRAM leaf of the new PCONFIG
   (platform configuration) instruction. It allows load and clear keys
   associated with a KeyID. You can also ask CPU to generate a key for
   you or disable memory encryption when a KeyID is used.

[1] https://software.intel.com/sites/default/files/managed/a5/16/Multi-Key-Total-Memory-Encryption-Spec.pdf

Kirill A. Shutemov (22):
  x86/cpufeatures: Add Intel Total Memory Encryption cpufeature
  x86/tme: Detect if TME and MKTME is activated by BIOS
  x86/cpufeatures: Add Intel PCONFIG cpufeature
  x86/pconfig: Detect PCONFIG targets
  x86/pconfig: Provide defines and helper to run MKTME_KEY_PROG leaf
  x86/mm: Decouple dynamic __PHYSICAL_MASK from AMD SME
  x86/mm: Mask out KeyID bits from page table entry pfn
  mm: Introduce __GFP_ENCRYPT
  mm, rmap: Add arch-specific field into anon_vma
  mm/shmem: Zero out unused vma fields in shmem_pseudo_vma_init()
  mm: Use __GFP_ENCRYPT for pages in encrypted VMAs
  mm: Do no merge vma with different encryption KeyIDs
  mm, rmap: Free encrypted pages once mapcount drops to zero
  mm, khugepaged: Do not collapse pages in encrypted VMAs
  x86/mm: Introduce variables to store number, shift and mask of KeyIDs
  x86/mm: Preserve KeyID on pte_modify() and pgprot_modify()
  x86/mm: Implement vma_is_encrypted() and vma_keyid()
  x86/mm: Handle allocation of encrypted pages
  x86/mm: Implement free_encrypt_page()
  x86/mm: Implement anon_vma_encrypted() and anon_vma_keyid()
  x86/mm: Introduce page_keyid() and page_encrypted()
  x86: Introduce CONFIG_X86_INTEL_MKTME

 arch/x86/Kconfig                     |  21 +++++++
 arch/x86/boot/compressed/kaslr_64.c  |   3 +
 arch/x86/include/asm/cpufeatures.h   |   2 +
 arch/x86/include/asm/intel_pconfig.h |  65 +++++++++++++++++++
 arch/x86/include/asm/mktme.h         |  56 +++++++++++++++++
 arch/x86/include/asm/page.h          |  13 +++-
 arch/x86/include/asm/page_types.h    |   8 ++-
 arch/x86/include/asm/pgtable_types.h |   7 ++-
 arch/x86/kernel/cpu/Makefile         |   2 +-
 arch/x86/kernel/cpu/intel.c          | 119 +++++++++++++++++++++++++++++++++++
 arch/x86/kernel/cpu/intel_pconfig.c  |  82 ++++++++++++++++++++++++
 arch/x86/mm/Makefile                 |   2 +
 arch/x86/mm/mem_encrypt_identity.c   |   3 +
 arch/x86/mm/mktme.c                  | 101 +++++++++++++++++++++++++++++
 arch/x86/mm/pgtable.c                |   5 ++
 include/linux/gfp.h                  |  29 +++++++--
 include/linux/mm.h                   |  17 +++++
 include/linux/rmap.h                 |   6 ++
 include/trace/events/mmflags.h       |   1 +
 mm/Kconfig                           |   3 +
 mm/khugepaged.c                      |   2 +
 mm/mempolicy.c                       |   3 +
 mm/mmap.c                            |   3 +-
 mm/page_alloc.c                      |   3 +
 mm/rmap.c                            |  49 +++++++++++++--
 mm/shmem.c                           |   3 +-
 tools/perf/builtin-kmem.c            |   1 +
 27 files changed, 590 insertions(+), 19 deletions(-)
 create mode 100644 arch/x86/include/asm/intel_pconfig.h
 create mode 100644 arch/x86/include/asm/mktme.h
 create mode 100644 arch/x86/kernel/cpu/intel_pconfig.c
 create mode 100644 arch/x86/mm/mktme.c

-- 
2.16.1

^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2018-03-27 14:44 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05 16:25 [RFC, PATCH 00/22] Partial MKTME enabling Kirill A. Shutemov
2018-03-05 16:25 ` [RFC, PATCH 01/22] x86/cpufeatures: Add Intel Total Memory Encryption cpufeature Kirill A. Shutemov
2018-03-12 12:20   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2018-03-05 16:25 ` [RFC, PATCH 02/22] x86/tme: Detect if TME and MKTME is activated by BIOS Kirill A. Shutemov
2018-03-12 12:21   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2018-03-13  2:12     ` Kai Huang
2018-03-13 12:49       ` Kirill A. Shutemov
2018-03-13 15:09         ` Dave Hansen
2018-03-13 22:07         ` Kai Huang
2018-03-05 16:25 ` [RFC, PATCH 03/22] x86/cpufeatures: Add Intel PCONFIG cpufeature Kirill A. Shutemov
2018-03-12 12:21   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2018-03-05 16:25 ` [RFC, PATCH 04/22] x86/pconfig: Detect PCONFIG targets Kirill A. Shutemov
2018-03-12 12:22   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2018-03-05 16:25 ` [RFC, PATCH 05/22] x86/pconfig: Provide defines and helper to run MKTME_KEY_PROG leaf Kirill A. Shutemov
2018-03-12 12:23   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2018-03-05 16:25 ` [RFC, PATCH 06/22] x86/mm: Decouple dynamic __PHYSICAL_MASK from AMD SME Kirill A. Shutemov
2018-03-05 16:25 ` [RFC, PATCH 07/22] x86/mm: Mask out KeyID bits from page table entry pfn Kirill A. Shutemov
2018-03-22 15:55   ` Punit Agrawal
2018-03-05 16:25 ` [RFC, PATCH 08/22] mm: Introduce __GFP_ENCRYPT Kirill A. Shutemov
2018-03-22 16:02   ` Punit Agrawal
2018-03-05 16:25 ` [RFC, PATCH 09/22] mm, rmap: Add arch-specific field into anon_vma Kirill A. Shutemov
2018-03-05 16:25 ` [RFC, PATCH 10/22] mm/shmem: Zero out unused vma fields in shmem_pseudo_vma_init() Kirill A. Shutemov
2018-03-05 16:25 ` [RFC, PATCH 11/22] mm: Use __GFP_ENCRYPT for pages in encrypted VMAs Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 12/22] mm: Do no merge vma with different encryption KeyIDs Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 13/22] mm, rmap: Free encrypted pages once mapcount drops to zero Kirill A. Shutemov
2018-03-05 19:12   ` Dave Hansen
2018-03-06  8:18     ` Kirill A. Shutemov
2018-03-05 19:13   ` Dave Hansen
2018-03-06  8:27     ` Kirill A. Shutemov
2018-03-06 14:59       ` Dave Hansen
2018-03-06 15:00         ` Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 14/22] mm, khugepaged: Do not collapse pages in encrypted VMAs Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 15/22] x86/mm: Introduce variables to store number, shift and mask of KeyIDs Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 16/22] x86/mm: Preserve KeyID on pte_modify() and pgprot_modify() Kirill A. Shutemov
2018-03-05 19:09   ` Dave Hansen
2018-03-06  8:30     ` Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 17/22] x86/mm: Implement vma_is_encrypted() and vma_keyid() Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 18/22] x86/mm: Handle allocation of encrypted pages Kirill A. Shutemov
2018-03-05 19:03   ` Dave Hansen
2018-03-06  8:34     ` Kirill A. Shutemov
2018-03-05 19:07   ` Dave Hansen
2018-03-06  8:36     ` Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 19/22] x86/mm: Implement free_encrypt_page() Kirill A. Shutemov
2018-03-05 19:00   ` Dave Hansen
2018-03-06  8:38     ` Kirill A. Shutemov
2018-03-05 19:07   ` Dave Hansen
2018-03-06  8:54     ` Kirill A. Shutemov
2018-03-06 13:52       ` Dave Hansen
2018-03-06 14:09         ` Kirill A. Shutemov
2018-03-20 12:50     ` Kirill A. Shutemov
2018-03-27 14:44       ` Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 20/22] x86/mm: Implement anon_vma_encrypted() and anon_vma_keyid() Kirill A. Shutemov
2018-03-05 16:26 ` [RFC, PATCH 21/22] x86/mm: Introduce page_keyid() and page_encrypted() Kirill A. Shutemov
2018-03-05 17:08   ` Dave Hansen
2018-03-06  8:57     ` Kirill A. Shutemov
2018-03-06 14:56       ` Dave Hansen
2018-03-06 14:58         ` Kirill A. Shutemov
2018-03-06 15:04           ` Dave Hansen
2018-03-05 16:26 ` [RFC, PATCH 22/22] x86: Introduce CONFIG_X86_INTEL_MKTME Kirill A. Shutemov
2018-03-05 18:30 ` [RFC, PATCH 00/22] Partial MKTME enabling Christoph Hellwig
2018-03-05 19:05   ` Matthew Wilcox
2018-03-06  8:58     ` Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).