Skip to content

HSM driver for ACRN hypervisor

[email protected] lkml 9 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest18 patches 7 repliesIn review
  2. v818 patches 3 repliesSuperseded
  3. v718 patches 11 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v618 patches11 repliesSuperseded
v517 patches43 repliesSuperseded
v412 of 17 patches45 repliesSuperseded
v312 of 17 patches7 repliesSuperseded
v217 patches6 repliesSuperseded
v117 patches10 repliesSuperseded

Changes in v9 from the cover letter

- Verified reserved fields of ioctls. (Greg)

Patches in v9 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18docs: acrn: Introduce ACRNDocumentation/virt/acrn/cpuid.rst Documentation/virt/acrn/index.rst Documentation/virt/acrn/introduction.rst +3 more+206 -02 replies
2/18x86/acrn: Introduce acrn_{setup, remove}_intr_handler()arch/x86/include/asm/acrn.h arch/x86/kernel/cpu/acrn.c+22 -00 replies
3/18x86/acrn: Introduce acrn_cpuid_base() and hypervisor feature bitsarch/x86/include/asm/acrn.h arch/x86/kernel/cpu/acrn.c+17 -10 replies
4/18x86/acrn: Introduce hypercall interfacesarch/x86/include/asm/acrn.h+54 -00 replies
5/18virt: acrn: Introduce ACRN HSM basic driverMAINTAINERS drivers/virt/Kconfig drivers/virt/Makefile +4 more+126 -00 replies
6/18virt: acrn: Introduce VM management interfacesDocumentation/userspace-api/ioctl/ioctl-number.rst MAINTAINERS drivers/virt/acrn/Makefile +5 more+301 -40 replies
7/18virt: acrn: Introduce an ioctl to set vCPU registers statedrivers/virt/acrn/hsm.c drivers/virt/acrn/hypercall.h include/uapi/linux/acrn.h+165 -10 replies
8/18virt: acrn: Introduce EPT mapping managementdrivers/virt/acrn/Makefile drivers/virt/acrn/acrn_drv.h drivers/virt/acrn/hsm.c +4 more+476 -100 replies
9/18virt: acrn: Introduce I/O request managementdrivers/virt/acrn/Makefile drivers/virt/acrn/acrn_drv.h drivers/virt/acrn/hsm.c +4 more+843 -100 replies
10/18virt: acrn: Introduce PCI configuration space PIO accesses combinerdrivers/virt/acrn/acrn_drv.h drivers/virt/acrn/ioreq.c include/uapi/linux/acrn.h+105 -00 replies
11/18virt: acrn: Introduce interfaces for PCI device passthroughdrivers/virt/acrn/hsm.c drivers/virt/acrn/hypercall.h include/uapi/linux/acrn.h+165 -00 replies
12/18virt: acrn: Introduce interrupt injection interfacesdrivers/virt/acrn/acrn_drv.h drivers/virt/acrn/hsm.c drivers/virt/acrn/hypercall.h +2 more+138 -00 replies
13/18virt: acrn: Introduce interfaces to query C-states and P-states allowed by hypervisordrivers/virt/acrn/hsm.c drivers/virt/acrn/hypercall.h include/uapi/linux/acrn.h+136 -00 replies
14/18virt: acrn: Introduce I/O ranges operation interfacesdrivers/virt/acrn/acrn_drv.h drivers/virt/acrn/ioreq.c+64 -00 replies
15/18virt: acrn: Introduce ioeventfddrivers/virt/acrn/Kconfig drivers/virt/acrn/Makefile drivers/virt/acrn/acrn_drv.h +4 more+327 -10 replies
16/18virt: acrn: Introduce irqfddrivers/virt/acrn/Makefile drivers/virt/acrn/acrn_drv.h drivers/virt/acrn/hsm.c +3 more+271 -10 replies
17/18virt: acrn: Introduce an interface for Service VM to control vCPUdrivers/virt/acrn/hsm.c drivers/virt/acrn/hypercall.h+62 -03 replies
18/18sample/acrn: Introduce a sample of HSM ioctl interface usagesamples/acrn/Makefile samples/acrn/guest.ld samples/acrn/payload.ld +1 more+166 -00 replies

Reviews trailers per patch

17 of 18 patches have a Reviewed-by or Acked-by.

PatchZhi WangReinette ChatreBorislav PetkovYakui ZhaoNick DesaulniersDavidlohr Bueso
1/18R-b R-b R-b
2/18R-b R-b A-b Originally-by
3/18R-b A-b
4/18R-b A-b Originally-by R-b
5/18R-b
6/18R-b R-b
7/18R-b R-b
8/18R-b R-b
9/18R-b R-b A-b
10/18R-b
11/18R-b R-b
12/18R-b R-b
13/18R-b R-b
14/18R-b
15/18R-b R-b
16/18R-b R-b
17/18R-b R-b T-b
18/18

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v9 thread

Cover letter [PATCH v9 00/18] HSM driver for ACRN hypervisor

From: Shuo Liu <[email protected]>

ACRN is a Type 1 reference hypervisor stack, running directly on the bare-metal hardware, and is suitable for a variety of IoT and embedded device solutions.

ACRN implements a hybrid VMM architecture, using a privileged Service VM. The Service VM manages the system resources (CPU, memory, etc.) and I/O devices of User VMs. Multiple User VMs are supported, with each of them running Linux, Android OS or Windows. Both Service VM and User VMs are guest VM.

Below figure shows the architecture.

                Service VM                    User VM
      +----------------------------+  |  +------------------+
      |        +--------------+    |  |  |                  |
      |        |ACRN userspace|    |  |  |                  |
      |        +--------------+    |  |  |                  |
      |-----------------ioctl------|  |  |                  |   ...
      |kernel space   +----------+ |  |  |                  |
      |               |   HSM    | |  |  | Drivers          |
      |               +----------+ |  |  |                  |
      +--------------------|-------+  |  +------------------+
  +---------------------hypercall----------------------------------------+
  |                       ACRN Hypervisor                                |
  +----------------------------------------------------------------------+
  |                          Hardware                                    |
  +----------------------------------------------------------------------+

There is only one Service VM which could run Linux as OS.

In a typical case, the Service VM will be auto started when ACRN Hypervisor is booted. Then the ACRN userspace (an application running in Service VM) could be used to start/stop User VMs by communicating with ACRN Hypervisor Service Module (HSM).

ACRN Hypervisor Service Module (HSM) is a middle layer that allows the ACRN userspace and Service VM OS kernel to communicate with ACRN Hypervisor and manage different User VMs. This middle layer provides the following functionalities,
- Issues hypercalls to the hypervisor to manage User VMs:
* VM/vCPU management
* Memory management
* Device passthrough
* Interrupts injection
- I/O requests handling from User VMs.
- Exports ioctl through HSM char device.
- Exports function calls for other kernel modules

ACRN is focused on embedded system. So it doesn't support some features. E.g.,
- ACRN doesn't support VM migration.
- ACRN doesn't support vCPU migration.

This patch set adds the HSM to the Linux kernel.
I also added a simple example to launch a small guest (with several instructions as payload) on ACRN with demonstration ioctl usage.

The basic ARCN support was merged to upstream already.
https://lore.kernel.org/lkml/[email protected]/

ChangeLog:
v9:
- Verified reserved fields of ioctls. (Greg)

v8:
- Minor improved in documentation. (Randy)
- Improved public header documentation. (Greg)
- Verified more reserved fields of ioctls. (Greg)
- Change tasklet to a high prio workqueue due to tasklets are deprecated. (Davidlohr)
- Add Copyright for public header file. (Greg)

v7:
- Typo fixed in documentation. (Boris)
- Verified some reserved fields of ioctls. (Greg)
- Rebased to v5.11-rc2.

v6:
- Added the cpuid.rst documentation (Boris)
- Deleted exported acrn_is_privileged_vm(), user detects feature bits by cpuid_eax() directly (Boris)
- Used 'g' as the hcall_id constrain in hypercall definitions (Boris, Segher)
- Removed unnecessary reserved fields from structures. Sorted some fields for alignment (Greg)
- Used built-in kernel guid_t types (Greg)
- Specified the endian of some fields in user/kernel interface structures (Greg)
- Removed the alignment attribute from user/kernel interface structures (Greg)
- Set reserved fields to zero (Greg)
- Added a ioctl interface usage sample in the last patch (Greg)
- Used pin_user_pages*() instead of get_user_pages*().

v5:
- Corrected typo in documentation.
- Removed unused pr_fmt().
- Used supported constraint with a explicit MOV to R8 at beginning of ASM for hypercall interface.
- Used dev_dbg() to replace dev_err() in places which might cause a DoS.
- Introduced acrn_vm_list_lock as a mutex for friendly review.
- Changed to use default attribute group list to add attribute files.

v4:
- Used acrn_dev.this_device directly for dev_*() (Reinette)
- Removed the odd usage of {get|put}_device() on &acrn_dev->this_device (Greg)
- Removed unused log code. (Greg)
- Corrected the return error values. (Greg)
- Mentioned that HSM relies hypervisor for sanity check in acrn_dev_ioctl() comments (Greg)

v3:
- Used {get|put}_device() helpers on &acrn_dev->this_device
- Moved unused code from front patches to later ones.
- Removed self-defined pr_fmt() and dev_fmt()
- Provided comments for acrn_vm_list_lock.

v2:
- Removed API version related code. (Dave)
- Replaced pr_*() by dev_*(). (Greg)
- Used -ENOTTY as the error code of unsupported ioctl. (Greg)

Shuo Liu (17):
docs: acrn: Introduce ACRN
x86/acrn: Introduce acrn_{setup, remove}_intr_handler() x86/acrn: Introduce hypercall interfaces
virt: acrn: Introduce ACRN HSM basic driver
virt: acrn: Introduce VM management interfaces
virt: acrn: Introduce an ioctl to set vCPU registers state
virt: acrn: Introduce EPT mapping management
virt: acrn: Introduce I/O request management
virt: acrn: Introduce PCI configuration space PIO accesses combiner
virt: acrn: Introduce interfaces for PCI device passthrough
virt: acrn: Introduce interrupt injection interfaces
virt: acrn: Introduce interfaces to query C-states and P-states
allowed by hypervisor
virt: acrn: Introduce I/O ranges operation interfaces
virt: acrn: Introduce ioeventfd
virt: acrn: Introduce irqfd
virt: acrn: Introduce an interface for Service VM to control vCPU sample/acrn: Introduce a sample of HSM ioctl interface usage

Yin Fengwei (1):
x86/acrn: Introduce acrn_cpuid_base() and hypervisor feature bits

 .../userspace-api/ioctl/ioctl-number.rst      |   1 +
 Documentation/virt/acrn/cpuid.rst             |  46 ++
 Documentation/virt/acrn/index.rst             |  12 +
 Documentation/virt/acrn/introduction.rst      |  43 ++
 Documentation/virt/acrn/io-request.rst        |  97 +++
 Documentation/virt/index.rst                  |   1 +
 MAINTAINERS                                   |   9 +
 arch/x86/include/asm/acrn.h                   |  78 +++
 arch/x86/kernel/cpu/acrn.c                    |  16 +-
 drivers/virt/Kconfig                          |   2 +
 drivers/virt/Makefile                         |   1 +
 drivers/virt/acrn/Kconfig                     |  15 +
 drivers/virt/acrn/Makefile                    |   3 +
 drivers/virt/acrn/acrn_drv.h                  | 227 ++++++
 drivers/virt/acrn/hsm.c                       | 470 +++++++++++++
 drivers/virt/acrn/hypercall.h                 | 254 +++++++
 drivers/virt/acrn/ioeventfd.c                 | 273 ++++++++
 drivers/virt/acrn/ioreq.c                     | 657 ++++++++++++++++++
 drivers/virt/acrn/irqfd.c                     | 235 +++++++
 drivers/virt/acrn/mm.c                        | 306 ++++++++
 drivers/virt/acrn/vm.c                        | 126 ++++
 include/uapi/linux/acrn.h                     | 580 ++++++++++++++++
 samples/acrn/Makefile                         |  12 +
 samples/acrn/guest.ld                         |   9 +
 samples/acrn/payload.ld                       |   9 +
 samples/acrn/vm-sample.c                      | 136 ++++
 26 files changed, 3617 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/virt/acrn/cpuid.rst
 create mode 100644 Documentation/virt/acrn/index.rst
 create mode 100644 Documentation/virt/acrn/introduction.rst
 create mode 100644 Documentation/virt/acrn/io-request.rst
 create mode 100644 arch/x86/include/asm/acrn.h
 create mode 100644 drivers/virt/acrn/Kconfig
 create mode 100644 drivers/virt/acrn/Makefile
 create mode 100644 drivers/virt/acrn/acrn_drv.h
 create mode 100644 drivers/virt/acrn/hsm.c
 create mode 100644 drivers/virt/acrn/hypercall.h
 create mode 100644 drivers/virt/acrn/ioeventfd.c
 create mode 100644 drivers/virt/acrn/ioreq.c
 create mode 100644 drivers/virt/acrn/irqfd.c
 create mode 100644 drivers/virt/acrn/mm.c
 create mode 100644 drivers/virt/acrn/vm.c
 create mode 100644 include/uapi/linux/acrn.h
 create mode 100644 samples/acrn/Makefile
 create mode 100644 samples/acrn/guest.ld
 create mode 100644 samples/acrn/payload.ld
 create mode 100644 samples/acrn/vm-sample.c

base-commit: dd86e7fa07a3ec33c92c957ea7b642c4702516a0

Signature · 1 line
2.28.0