All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Zhong <yang.zhong@intel.com>
To: qemu-devel@nongnu.org
Cc: yang.zhong@intel.com, pbonzini@redhat.com, kai.huang@intel.com,
	seanjc@google.com
Subject: [PATCH 00/32] Qemu SGX virtualization
Date: Mon, 19 Apr 2021 18:01:24 +0800	[thread overview]
Message-ID: <20210419100156.53504-1-yang.zhong@intel.com> (raw)

Since Sean Christopherson has left Intel and i am responsible for Qemu SGX
upstream work. His @intel.com address will be bouncing and his new email(
seanjc@google.com) is also in CC lists.

This series is Qemu SGX virtualization implementation rebased on latest
Qemu release.

You can find Qemu repo here:

      https://github.com/intel/qemu-sgx.git upstream

If you want to try sgx, you can also get the kernel/kvm code from upstream
branch of kvm-sgx repo on github:

      https://github.com/intel/kvm-sgx.git upstream

Notice: The kvm SGX patch series has been queued by Paolo in 4/17.

To simplify, you'd better install kvm-sgx on host and guest, which can support
SGX on host and guest kernel. And to me, use below reference command to boot
SGX guest:

      #qemu-system-x86_64 \
           ...... \
           -cpu host,+sgx_provisionkey \
           -sgx-epc id=epc1,memdev=mem1 \
           -object memory-backend-epc,id=mem1,size=64M,prealloc=on

Overview
========

Intel Software Guard eXtensions (SGX) is a set of instructions and mechanisms
for memory accesses in order to provide security accesses for sensitive
applications and data. SGX allows an application to use it's pariticular
address space as an *enclave*, which is a protected area provides confidentiality
and integrity even in the presence of privileged malware. Accesses to the
enclave memory area from any software not resident in the enclave are prevented,
including those from privileged software.

SGX virtaulization
==================

The KVM SGX creates one new misc device, sgx_vepc, and Qemu will open '/dev/sgx_vepc'
device node to mmap() host EPC memory to guest. The Qemu also adds 'sgx-epc' device
to expose EPC sections to guest through CPUID and ACPI table.  The Qemu SGX also
supports multiple virtual EPC sections to guest, we just put them together physically
contiguous for the sake of simplicity. The kernel SGX NUMA has been merged into Linux
tip tree, we will support this function in the next phase.

Although the current host SGX subsystem can not support SGX2 feature, the KVM/Qemu
implementation still expose this feature to guest. Guest SGX2 support doesn't have
interaction with host kernel SGX driver, the SGX guest can normally use those new
instructions.

As for SGX virtualization detailed infomation, please reference docs/intel-sgx.txt
docuement(patch 32).


Sean Christopherson (22):
  memory: Add RAM_PROTECTED flag to skip IOMMU mappings
  hostmem: Add hostmem-epc as a backend for SGX EPC
  i386: Add 'sgx-epc' device to expose EPC sections to guest
  vl: Add "sgx-epc" option to expose SGX EPC sections to guest
  i386: Add primary SGX CPUID and MSR defines
  i386: Add SGX CPUID leaf FEAT_SGX_12_0_EAX
  i386: Add SGX CPUID leaf FEAT_SGX_12_0_EBX
  i386: Add SGX CPUID leaf FEAT_SGX_12_1_EAX
  i386: Add get/set/migrate support for SGX_LEPUBKEYHASH MSRs
  i386: Add feature control MSR dependency when SGX is enabled
  i386: Update SGX CPUID info according to hardware/KVM/user input
  linux-headers: Add placeholder for KVM_CAP_SGX_ATTRIBUTE
  i386: kvm: Add support for exposing PROVISIONKEY to guest
  i386: Propagate SGX CPUID sub-leafs to KVM
  Adjust min CPUID level to 0x12 when SGX is enabled
  hw/i386/fw_cfg: Set SGX bits in feature control fw_cfg accordingly
  hw/i386/pc: Account for SGX EPC sections when calculating device
    memory
  i386/pc: Add e820 entry for SGX EPC section(s)
  i386: acpi: Add SGX EPC entry to ACPI tables
  q35: Add support for SGX EPC
  i440fx: Add support for SGX EPC
  doc: Add the SGX doc

Yang Zhong (10):
  qom: Add memory-backend-epc ObjectOptions support
  hostmem: Add the reset interface for EPC backend reset
  sgx-epc: Add the reset interface for sgx-epc virt device
  qmp: Add query-sgx command
  hmp: Add 'info sgx' command
  i386: Add sgx_get_info() interface
  bitops: Support 32 and 64 bit mask macro
  qmp: Add the qmp_query_sgx_capabilities()
  Kconfig: Add CONFIG_SGX support
  sgx-epc: Add the fill_device_info() callback support

 backends/hostmem-epc.c                   | 106 ++++++
 backends/hostmem-memfd.c                 |   2 +-
 backends/meson.build                     |   1 +
 default-configs/devices/i386-softmmu.mak |   1 +
 docs/intel-sgx.txt                       | 173 +++++++++
 hmp-commands-info.hx                     |  15 +
 hw/i386/Kconfig                          |   5 +
 hw/i386/acpi-build.c                     |  22 ++
 hw/i386/fw_cfg.c                         |  10 +-
 hw/i386/meson.build                      |   1 +
 hw/i386/pc.c                             |  15 +-
 hw/i386/pc_piix.c                        |   4 +
 hw/i386/pc_q35.c                         |   3 +
 hw/i386/sgx-epc.c                        | 449 +++++++++++++++++++++++
 hw/i386/sgx-stub.c                       |  13 +
 hw/misc/ivshmem.c                        |   2 +-
 hw/remote/memory.c                       |   2 +-
 hw/vfio/common.c                         |   1 +
 include/exec/memory.h                    |  15 +
 include/hw/i386/pc.h                     |  10 +
 include/hw/i386/sgx-epc.h                |  75 ++++
 include/monitor/hmp.h                    |   1 +
 include/qemu/bitops.h                    |   7 +
 linux-headers/linux/kvm.h                |   1 +
 monitor/hmp-cmds.c                       |  32 ++
 monitor/qmp-cmds.c                       |  19 +
 qapi/machine.json                        |  26 +-
 qapi/misc.json                           |  61 +++
 qapi/qom.json                            |   2 +
 qemu-options.hx                          |   8 +
 softmmu/globals.c                        |   1 +
 softmmu/memory.c                         |  12 +-
 softmmu/physmem.c                        |   2 +-
 softmmu/vl.c                             |   9 +
 stubs/meson.build                        |   1 +
 stubs/sgx-stub.c                         |  12 +
 target/i386/cpu.c                        | 168 ++++++++-
 target/i386/cpu.h                        |  16 +
 target/i386/kvm/kvm.c                    |  75 ++++
 target/i386/kvm/kvm_i386.h               |   2 +
 target/i386/machine.c                    |  20 +
 tests/qtest/qmp-cmd-test.c               |   2 +
 42 files changed, 1390 insertions(+), 12 deletions(-)
 create mode 100644 backends/hostmem-epc.c
 create mode 100644 docs/intel-sgx.txt
 create mode 100644 hw/i386/sgx-epc.c
 create mode 100644 hw/i386/sgx-stub.c
 create mode 100644 include/hw/i386/sgx-epc.h
 create mode 100644 stubs/sgx-stub.c

-- 
2.29.2.334.gfaefdd61ec



             reply	other threads:[~2021-04-19 10:24 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 10:01 Yang Zhong [this message]
2021-04-19 10:01 ` [PATCH 01/32] memory: Add RAM_PROTECTED flag to skip IOMMU mappings Yang Zhong
2021-04-19 10:01 ` [PATCH 02/32] hostmem: Add hostmem-epc as a backend for SGX EPC Yang Zhong
2021-04-19 10:01 ` [PATCH 03/32] qom: Add memory-backend-epc ObjectOptions support Yang Zhong
2021-04-19 10:01 ` [PATCH 04/32] i386: Add 'sgx-epc' device to expose EPC sections to guest Yang Zhong
2021-04-19 10:01 ` [PATCH 05/32] vl: Add "sgx-epc" option to expose SGX " Yang Zhong
2021-04-19 10:01 ` [PATCH 06/32] i386: Add primary SGX CPUID and MSR defines Yang Zhong
2021-04-19 10:01 ` [PATCH 07/32] i386: Add SGX CPUID leaf FEAT_SGX_12_0_EAX Yang Zhong
2021-04-19 10:01 ` [PATCH 08/32] i386: Add SGX CPUID leaf FEAT_SGX_12_0_EBX Yang Zhong
2021-04-19 10:01 ` [PATCH 09/32] i386: Add SGX CPUID leaf FEAT_SGX_12_1_EAX Yang Zhong
2021-04-19 10:01 ` [PATCH 10/32] i386: Add get/set/migrate support for SGX_LEPUBKEYHASH MSRs Yang Zhong
2021-04-19 10:01 ` [PATCH 11/32] i386: Add feature control MSR dependency when SGX is enabled Yang Zhong
2021-04-19 10:01 ` [PATCH 12/32] i386: Update SGX CPUID info according to hardware/KVM/user input Yang Zhong
2021-04-19 10:01 ` [PATCH 13/32] linux-headers: Add placeholder for KVM_CAP_SGX_ATTRIBUTE Yang Zhong
2021-04-20  2:08   ` Kai Huang
2021-04-20  2:58     ` Yang Zhong
2021-04-19 10:01 ` [PATCH 14/32] i386: kvm: Add support for exposing PROVISIONKEY to guest Yang Zhong
2021-04-19 10:01 ` [PATCH 15/32] i386: Propagate SGX CPUID sub-leafs to KVM Yang Zhong
2021-04-19 10:01 ` [PATCH 16/32] Adjust min CPUID level to 0x12 when SGX is enabled Yang Zhong
2021-04-19 10:01 ` [PATCH 17/32] hw/i386/fw_cfg: Set SGX bits in feature control fw_cfg accordingly Yang Zhong
2021-04-19 10:01 ` [PATCH 18/32] hw/i386/pc: Account for SGX EPC sections when calculating device memory Yang Zhong
2021-04-19 10:01 ` [PATCH 19/32] i386/pc: Add e820 entry for SGX EPC section(s) Yang Zhong
2021-04-19 10:01 ` [PATCH 20/32] i386: acpi: Add SGX EPC entry to ACPI tables Yang Zhong
2021-04-19 10:01 ` [PATCH 21/32] q35: Add support for SGX EPC Yang Zhong
2021-04-19 10:01 ` [PATCH 22/32] i440fx: " Yang Zhong
2021-04-19 10:01 ` [PATCH 23/32] hostmem: Add the reset interface for EPC backend reset Yang Zhong
2021-04-19 10:01 ` [PATCH 24/32] sgx-epc: Add the reset interface for sgx-epc virt device Yang Zhong
2021-04-19 10:01 ` [PATCH 25/32] qmp: Add query-sgx command Yang Zhong
2021-04-19 10:01 ` [PATCH 26/32] hmp: Add 'info sgx' command Yang Zhong
2021-04-19 10:01 ` [PATCH 27/32] i386: Add sgx_get_info() interface Yang Zhong
2021-04-19 10:01 ` [PATCH 28/32] bitops: Support 32 and 64 bit mask macro Yang Zhong
2021-04-19 10:01 ` [PATCH 29/32] qmp: Add the qmp_query_sgx_capabilities() Yang Zhong
2021-04-19 10:01 ` [PATCH 30/32] Kconfig: Add CONFIG_SGX support Yang Zhong
2021-04-19 10:01 ` [PATCH 31/32] sgx-epc: Add the fill_device_info() callback support Yang Zhong
2021-04-19 10:01 ` [PATCH 32/32] doc: Add the SGX doc Yang Zhong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210419100156.53504-1-yang.zhong@intel.com \
    --to=yang.zhong@intel.com \
    --cc=kai.huang@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.