2020-09-22 11:50:38

by Shuo Liu

[permalink] [raw]
Subject: [PATCH v4 00/17] 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.

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

ChangeLog:
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 (16):
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

Yin Fengwei (1):
x86/acrn: Introduce an API to check if a VM is privileged

.../userspace-api/ioctl/ioctl-number.rst | 1 +
Documentation/virt/acrn/index.rst | 11 +
Documentation/virt/acrn/introduction.rst | 40 ++
Documentation/virt/acrn/io-request.rst | 97 +++
Documentation/virt/index.rst | 1 +
MAINTAINERS | 9 +
arch/x86/include/asm/acrn.h | 74 ++
arch/x86/kernel/cpu/acrn.c | 35 +-
drivers/virt/Kconfig | 2 +
drivers/virt/Makefile | 1 +
drivers/virt/acrn/Kconfig | 15 +
drivers/virt/acrn/Makefile | 3 +
drivers/virt/acrn/acrn_drv.h | 229 +++++++
drivers/virt/acrn/hsm.c | 437 ++++++++++++
drivers/virt/acrn/hypercall.h | 254 +++++++
drivers/virt/acrn/ioeventfd.c | 273 ++++++++
drivers/virt/acrn/ioreq.c | 645 ++++++++++++++++++
drivers/virt/acrn/irqfd.c | 235 +++++++
drivers/virt/acrn/mm.c | 305 +++++++++
drivers/virt/acrn/vm.c | 126 ++++
include/uapi/linux/acrn.h | 486 +++++++++++++
21 files changed, 3278 insertions(+), 1 deletion(-)
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


base-commit: 18445bf405cb331117bc98427b1ba6f12418ad17
--
2.28.0


2020-09-22 11:50:45

by Shuo Liu

[permalink] [raw]
Subject: [PATCH v4 01/17] docs: acrn: Introduce ACRN

From: Shuo Liu <[email protected]>

Add documentation on the following aspects of ACRN:

1) A brief introduction on the architecture of ACRN.
2) I/O request handling in ACRN.

To learn more about ACRN, please go to ACRN project website
https://projectacrn.org, or the documentation page
https://projectacrn.github.io/.

Signed-off-by: Shuo Liu <[email protected]>
Reviewed-by: Zhi Wang <[email protected]>
Reviewed-by: Reinette Chatre <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Sen Christopherson <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Fengwei Yin <[email protected]>
Cc: Zhi Wang <[email protected]>
Cc: Zhenyu Wang <[email protected]>
Cc: Yu Wang <[email protected]>
Cc: Reinette Chatre <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
Documentation/virt/acrn/index.rst | 11 +++
Documentation/virt/acrn/introduction.rst | 40 ++++++++++
Documentation/virt/acrn/io-request.rst | 97 ++++++++++++++++++++++++
Documentation/virt/index.rst | 1 +
MAINTAINERS | 7 ++
5 files changed, 156 insertions(+)
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

diff --git a/Documentation/virt/acrn/index.rst b/Documentation/virt/acrn/index.rst
new file mode 100644
index 000000000000..e3cf99033bdb
--- /dev/null
+++ b/Documentation/virt/acrn/index.rst
@@ -0,0 +1,11 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+===============
+ACRN Hypervisor
+===============
+
+.. toctree::
+ :maxdepth: 1
+
+ introduction
+ io-request
diff --git a/Documentation/virt/acrn/introduction.rst b/Documentation/virt/acrn/introduction.rst
new file mode 100644
index 000000000000..6b44924d5c0e
--- /dev/null
+++ b/Documentation/virt/acrn/introduction.rst
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+ACRN Hypervisor Introduction
+============================
+
+The ACRN Hypervisor is a Type 1 hypervisor, running directly on the bare-metal
+hardware. It has a privileged management VM, called Service VM, to manage User
+VMs and do I/O emulation.
+
+ACRN userspace is an application running in the Service VM that emulates
+devices for a User VM based on command line configurations. ACRN Hypervisor
+Service Module (HSM) is a kernel module in the Service VM which provides
+hypervisor services to the ACRN userspace.
+
+Below figure shows the architecture.
+
+::
+
+ Service VM User VM
+ +----------------------------+ | +------------------+
+ | +--------------+ | | | |
+ | |ACRN userspace| | | | |
+ | +--------------+ | | | |
+ |-----------------ioctl------| | | | ...
+ |kernel space +----------+ | | | |
+ | | HSM | | | | Drivers |
+ | +----------+ | | | |
+ +--------------------|-------+ | +------------------+
+ +---------------------hypercall----------------------------------------+
+ | ACRN Hypervisor |
+ +----------------------------------------------------------------------+
+ | Hardware |
+ +----------------------------------------------------------------------+
+
+ACRN userspace allocates memory for the User VM, configures and initializes the
+devices used by the User VM, loads the virtual bootloader, initializes the
+virtual CPU state and handles I/O request accesses from the User VM. It uses
+ioctls to communicate with the HSM. HSM implements hypervisor services by
+interacting with the ACRN Hypervisor via hypercalls. HSM exports a char device
+interface (/dev/acrn_hsm) to userspace.
diff --git a/Documentation/virt/acrn/io-request.rst b/Documentation/virt/acrn/io-request.rst
new file mode 100644
index 000000000000..019dc5978f7c
--- /dev/null
+++ b/Documentation/virt/acrn/io-request.rst
@@ -0,0 +1,97 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+I/O request handling
+====================
+
+An I/O request of a User VM, which is constructed by the hypervisor, is
+distributed by the ACRN Hypervisor Service Module to an I/O client
+corresponding to the address range of the I/O request. Details of I/O request
+handling are described in the following sections.
+
+1. I/O request
+--------------
+
+For each User VM, there is a shared 4-KByte memory region used for I/O requests
+communication between the hypervisor and Service VM. An I/O request is a
+256-byte structure buffer, which is 'struct acrn_io_request', that is filled by
+an I/O handler of the hypervisor when a trapped I/O access happens in a User
+VM. ACRN userspace in the Service VM first allocates a 4-KByte page and passes
+the GPA (Guest Physical Address) of the buffer to the hypervisor. The buffer is
+used as an array of 16 I/O request slots with each I/O request slot being 256
+bytes. This array is indexed by vCPU ID.
+
+2. I/O clients
+--------------
+
+An I/O client is responsible for handling User VM I/O requests whose accessed
+GPA falls in a certain range. Multiple I/O clients can be associated with each
+User VM. There is a special client associated with each User VM, called the
+default client, that handles all I/O requests that do not fit into the range of
+any other clients. The ACRN userspace acts as the default client for each User
+VM.
+
+Below illustration shows the relationship between I/O requests shared buffer,
+I/O requests and I/O clients.
+
+::
+
+ +------------------------------------------------------+
+ | Service VM |
+ |+--------------------------------------------------+ |
+ || +----------------------------------------+ | |
+ || | shared page ACRN userspace | | |
+ || | +-----------------+ +------------+ | | |
+ || +----+->| acrn_io_request |<-+ default | | | |
+ || | | | +-----------------+ | I/O client | | | |
+ || | | | | ... | +------------+ | | |
+ || | | | +-----------------+ | | |
+ || | +-|--------------------------------------+ | |
+ ||---|----|-----------------------------------------| |
+ || | | kernel | |
+ || | | +----------------------+ | |
+ || | | | +-------------+ HSM | | |
+ || | +--------------+ | | | |
+ || | | | I/O clients | | | |
+ || | | | | | | |
+ || | | +-------------+ | | |
+ || | +----------------------+ | |
+ |+---|----------------------------------------------+ |
+ +----|-------------------------------------------------+
+ |
+ +----|-------------------------------------------------+
+ | +-+-----------+ |
+ | | I/O handler | ACRN Hypervisor |
+ | +-------------+ |
+ +------------------------------------------------------+
+
+3. I/O request state transition
+-------------------------------
+
+The state transitions of a ACRN I/O request are as follows.
+
+::
+
+ FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE -> ...
+
+- FREE: this I/O request slot is empty
+- PENDING: a valid I/O request is pending in this slot
+- PROCESSING: the I/O request is being processed
+- COMPLETE: the I/O request has been processed
+
+An I/O request in COMPLETE or FREE state is owned by the hypervisor. HSM and
+ACRN userspace are in charge of processing the others.
+
+4. Processing flow of I/O requests
+-------------------------------
+
+a. The I/O handler of the hypervisor will fill an I/O request with PENDING
+ state when a trapped I/O access happens in a User VM.
+b. The hypervisor makes an upcall, which is a notification interrupt, to
+ the Service VM.
+c. The upcall handler schedules a tasklet to dispatch I/O requests.
+d. The tasklet looks for the PENDING I/O requests, assigns them to different
+ registered clients based on the address of the I/O accesses, updates
+ their state to PROCESSING, and notifies the corresponding client to handle.
+e. The notified client handles the assigned I/O requests.
+f. The HSM updates I/O requests states to COMPLETE and notifies the hypervisor
+ of the completion via hypercalls.
diff --git a/Documentation/virt/index.rst b/Documentation/virt/index.rst
index de1ab81df958..c10b519507f5 100644
--- a/Documentation/virt/index.rst
+++ b/Documentation/virt/index.rst
@@ -11,6 +11,7 @@ Linux Virtualization Support
uml/user_mode_linux
paravirt_ops
guest-halt-polling
+ acrn/index

.. only:: html and subproject

diff --git a/MAINTAINERS b/MAINTAINERS
index deaafb617361..e0fea5e464b4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -436,6 +436,13 @@ S: Orphan
F: drivers/platform/x86/wmi.c
F: include/uapi/linux/wmi.h

+ACRN HYPERVISOR SERVICE MODULE
+M: Shuo Liu <[email protected]>
+L: [email protected]
+S: Supported
+W: https://projectacrn.org
+F: Documentation/virt/acrn/
+
AD1889 ALSA SOUND DRIVER
L: [email protected]
S: Maintained
--
2.28.0

2020-09-22 11:52:21

by Shuo Liu

[permalink] [raw]
Subject: [PATCH v4 03/17] x86/acrn: Introduce an API to check if a VM is privileged

From: Yin Fengwei <[email protected]>

ACRN Hypervisor reports hypervisor features via CPUID leaf 0x40000001
which is similar to KVM. A VM can check if it's the privileged VM using
the feature bits. The Service VM is the only privileged VM by design.

Signed-off-by: Yin Fengwei <[email protected]>
Signed-off-by: Shuo Liu <[email protected]>
Reviewed-by: Reinette Chatre <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Sean Christopherson <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Fengwei Yin <[email protected]>
Cc: Zhi Wang <[email protected]>
Cc: Zhenyu Wang <[email protected]>
Cc: Yu Wang <[email protected]>
Cc: Reinette Chatre <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
arch/x86/include/asm/acrn.h | 9 +++++++++
arch/x86/kernel/cpu/acrn.c | 19 ++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h
index ff259b69cde7..a2d4aea3a80d 100644
--- a/arch/x86/include/asm/acrn.h
+++ b/arch/x86/include/asm/acrn.h
@@ -2,7 +2,16 @@
#ifndef _ASM_X86_ACRN_H
#define _ASM_X86_ACRN_H

+/*
+ * This CPUID returns feature bitmaps in EAX.
+ * Guest VM uses this to detect the appropriate feature bit.
+ */
+#define ACRN_CPUID_FEATURES 0x40000001
+/* Bit 0 indicates whether guest VM is privileged */
+#define ACRN_FEATURE_PRIVILEGED_VM BIT(0)
+
void acrn_setup_intr_handler(void (*handler)(void));
void acrn_remove_intr_handler(void);
+bool acrn_is_privileged_vm(void);

#endif /* _ASM_X86_ACRN_H */
diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c
index 42e88d01ccf9..b04fef8bd50b 100644
--- a/arch/x86/kernel/cpu/acrn.c
+++ b/arch/x86/kernel/cpu/acrn.c
@@ -21,9 +21,26 @@
#include <asm/idtentry.h>
#include <asm/irq_regs.h>

+static u32 acrn_cpuid_base(void)
+{
+ static u32 acrn_cpuid_base;
+
+ if (!acrn_cpuid_base && boot_cpu_has(X86_FEATURE_HYPERVISOR))
+ acrn_cpuid_base = hypervisor_cpuid_base("ACRNACRNACRN", 0);
+
+ return acrn_cpuid_base;
+}
+
+bool acrn_is_privileged_vm(void)
+{
+ return cpuid_eax(acrn_cpuid_base() | ACRN_CPUID_FEATURES) &
+ ACRN_FEATURE_PRIVILEGED_VM;
+}
+EXPORT_SYMBOL_GPL(acrn_is_privileged_vm);
+
static u32 __init acrn_detect(void)
{
- return hypervisor_cpuid_base("ACRNACRNACRN", 0);
+ return acrn_cpuid_base();
}

static void __init acrn_init_platform(void)
--
2.28.0

2020-09-27 00:26:48

by Shuo Liu

[permalink] [raw]
Subject: Re: [PATCH v4 00/17] HSM driver for ACRN hypervisor

Ping...

On 9/22/2020 19:42, [email protected] wrote:
> 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.
>
> The basic ARCN support was merged to upstream already.
> https://lore.kernel.org/lkml/[email protected]/
>
> ChangeLog:
> 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 (16):
> 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
>
> Yin Fengwei (1):
> x86/acrn: Introduce an API to check if a VM is privileged
>
> .../userspace-api/ioctl/ioctl-number.rst | 1 +
> Documentation/virt/acrn/index.rst | 11 +
> Documentation/virt/acrn/introduction.rst | 40 ++
> Documentation/virt/acrn/io-request.rst | 97 +++
> Documentation/virt/index.rst | 1 +
> MAINTAINERS | 9 +
> arch/x86/include/asm/acrn.h | 74 ++
> arch/x86/kernel/cpu/acrn.c | 35 +-
> drivers/virt/Kconfig | 2 +
> drivers/virt/Makefile | 1 +
> drivers/virt/acrn/Kconfig | 15 +
> drivers/virt/acrn/Makefile | 3 +
> drivers/virt/acrn/acrn_drv.h | 229 +++++++
> drivers/virt/acrn/hsm.c | 437 ++++++++++++
> drivers/virt/acrn/hypercall.h | 254 +++++++
> drivers/virt/acrn/ioeventfd.c | 273 ++++++++
> drivers/virt/acrn/ioreq.c | 645 ++++++++++++++++++
> drivers/virt/acrn/irqfd.c | 235 +++++++
> drivers/virt/acrn/mm.c | 305 +++++++++
> drivers/virt/acrn/vm.c | 126 ++++
> include/uapi/linux/acrn.h | 486 +++++++++++++
> 21 files changed, 3278 insertions(+), 1 deletion(-)
> 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
>
>
> base-commit: 18445bf405cb331117bc98427b1ba6f12418ad17
>

2020-09-27 05:46:06

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v4 00/17] HSM driver for ACRN hypervisor

On Sun, Sep 27, 2020 at 08:24:39AM +0800, Liu, Shuo A wrote:
> Ping...

It's been less than a week since you sent this. Please relax and if you
really need reviews, get them from within Intel, where you can impose a
deadline on those developers. Otherwise, your patch is in good company:

$ mdfrm -c ~/mail/todo/
993 messages in /home/gregkh/mail/todo/

And will be handled when I get to it.

thanks,

greg "Intel still owes me lots of liquor" k-h

2020-09-30 08:11:34

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH v4 03/17] x86/acrn: Introduce an API to check if a VM is privileged

On Tue, Sep 22, 2020 at 07:42:57PM +0800, [email protected] wrote:
> +static u32 acrn_cpuid_base(void)
> +{
> + static u32 acrn_cpuid_base;
> +
> + if (!acrn_cpuid_base && boot_cpu_has(X86_FEATURE_HYPERVISOR))
> + acrn_cpuid_base = hypervisor_cpuid_base("ACRNACRNACRN", 0);
> +
> + return acrn_cpuid_base;
> +}
> +
> +bool acrn_is_privileged_vm(void)
> +{
> + return cpuid_eax(acrn_cpuid_base() | ACRN_CPUID_FEATURES) &

What's that dance and acrn_cpuid_base static thing needed for? Why not
simply:

cpuid_eax(ACRN_CPUID_FEATURES) & ...

?

> + ACRN_FEATURE_PRIVILEGED_VM;
> +}
> +EXPORT_SYMBOL_GPL(acrn_is_privileged_vm);

Also, if you're going to need more of those bit checkers acrn_is_<something>
which look at ACRN_CPUID_FEATURES, just stash CPUID_0x40000001_EAX locally and
use a

acrn_has(ACRN_FEATURE_PRIVILEGED_VM)

which does the bit testing.

--
Regards/Gruss,
Boris.

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

2020-10-09 03:53:29

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v4 01/17] docs: acrn: Introduce ACRN

On 9/22/20 4:42 AM, [email protected] wrote:
> From: Shuo Liu <[email protected]>
>
> Add documentation on the following aspects of ACRN:
>
> 1) A brief introduction on the architecture of ACRN.
> 2) I/O request handling in ACRN.
>
> To learn more about ACRN, please go to ACRN project website
> https://projectacrn.org, or the documentation page
> https://projectacrn.github.io/.
>
> Signed-off-by: Shuo Liu <[email protected]>
> Reviewed-by: Zhi Wang <[email protected]>
> Reviewed-by: Reinette Chatre <[email protected]>
> Cc: Dave Hansen <[email protected]>
> Cc: Sen Christopherson <[email protected]>
> Cc: Dan Williams <[email protected]>
> Cc: Fengwei Yin <[email protected]>
> Cc: Zhi Wang <[email protected]>
> Cc: Zhenyu Wang <[email protected]>
> Cc: Yu Wang <[email protected]>
> Cc: Reinette Chatre <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> ---
> Documentation/virt/acrn/index.rst | 11 +++
> Documentation/virt/acrn/introduction.rst | 40 ++++++++++
> Documentation/virt/acrn/io-request.rst | 97 ++++++++++++++++++++++++
> Documentation/virt/index.rst | 1 +
> MAINTAINERS | 7 ++
> 5 files changed, 156 insertions(+)
> 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
>

> diff --git a/Documentation/virt/acrn/io-request.rst b/Documentation/virt/acrn/io-request.rst
> new file mode 100644
> index 000000000000..019dc5978f7c
> --- /dev/null
> +++ b/Documentation/virt/acrn/io-request.rst
> @@ -0,0 +1,97 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +I/O request handling
> +====================
> +
> +An I/O request of a User VM, which is constructed by the hypervisor, is
> +distributed by the ACRN Hypervisor Service Module to an I/O client
> +corresponding to the address range of the I/O request. Details of I/O request
> +handling are described in the following sections.
> +
> +1. I/O request
> +--------------
> +

...

> +
> +2. I/O clients
> +--------------
> +

...

> +
> +3. I/O request state transition
> +-------------------------------
> +
> +The state transitions of a ACRN I/O request are as follows.

of an ACRN

> +
> +::
> +
> + FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE -> ...
> +
> +- FREE: this I/O request slot is empty
> +- PENDING: a valid I/O request is pending in this slot
> +- PROCESSING: the I/O request is being processed
> +- COMPLETE: the I/O request has been processed
> +
> +An I/O request in COMPLETE or FREE state is owned by the hypervisor. HSM and
> +ACRN userspace are in charge of processing the others.
> +
> +4. Processing flow of I/O requests
> +-------------------------------
> +

...



thanks.
--
~Randy

2020-10-12 08:53:28

by Shuo Liu

[permalink] [raw]
Subject: Re: [PATCH v4 01/17] docs: acrn: Introduce ACRN

On Thu 8.Oct'20 at 18:48:52 -0700, Randy Dunlap wrote:
>On 9/22/20 4:42 AM, [email protected] wrote:
>> From: Shuo Liu <[email protected]>
>>
>> Add documentation on the following aspects of ACRN:
>>
>> 1) A brief introduction on the architecture of ACRN.
>> 2) I/O request handling in ACRN.
>>
>> To learn more about ACRN, please go to ACRN project website
>> https://projectacrn.org, or the documentation page
>> https://projectacrn.github.io/.
>>
>> Signed-off-by: Shuo Liu <[email protected]>
>> Reviewed-by: Zhi Wang <[email protected]>
>> Reviewed-by: Reinette Chatre <[email protected]>
>> Cc: Dave Hansen <[email protected]>
>> Cc: Sen Christopherson <[email protected]>
>> Cc: Dan Williams <[email protected]>
>> Cc: Fengwei Yin <[email protected]>
>> Cc: Zhi Wang <[email protected]>
>> Cc: Zhenyu Wang <[email protected]>
>> Cc: Yu Wang <[email protected]>
>> Cc: Reinette Chatre <[email protected]>
>> Cc: Greg Kroah-Hartman <[email protected]>
>> ---
>> Documentation/virt/acrn/index.rst | 11 +++
>> Documentation/virt/acrn/introduction.rst | 40 ++++++++++
>> Documentation/virt/acrn/io-request.rst | 97 ++++++++++++++++++++++++
>> Documentation/virt/index.rst | 1 +
>> MAINTAINERS | 7 ++
>> 5 files changed, 156 insertions(+)
>> 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
>>
>
>> diff --git a/Documentation/virt/acrn/io-request.rst b/Documentation/virt/acrn/io-request.rst
>> new file mode 100644
>> index 000000000000..019dc5978f7c
>> --- /dev/null
>> +++ b/Documentation/virt/acrn/io-request.rst
>> @@ -0,0 +1,97 @@
>> +.. SPDX-License-Identifier: GPL-2.0
>> +
>> +I/O request handling
>> +====================
>> +
>> +An I/O request of a User VM, which is constructed by the hypervisor, is
>> +distributed by the ACRN Hypervisor Service Module to an I/O client
>> +corresponding to the address range of the I/O request. Details of I/O request
>> +handling are described in the following sections.
>> +
>> +1. I/O request
>> +--------------
>> +
>
>...
>
>> +
>> +2. I/O clients
>> +--------------
>> +
>
>...
>
>> +
>> +3. I/O request state transition
>> +-------------------------------
>> +
>> +The state transitions of a ACRN I/O request are as follows.
>
> of an ACRN

OK. Thanks for review.

Thanks
shuo

2020-10-12 12:56:53

by Shuo Liu

[permalink] [raw]
Subject: Re: [PATCH v4 03/17] x86/acrn: Introduce an API to check if a VM is privileged

Hi Boris,

On Wed 30.Sep'20 at 10:09:59 +0200, Borislav Petkov wrote:
>On Tue, Sep 22, 2020 at 07:42:57PM +0800, [email protected] wrote:
>> +static u32 acrn_cpuid_base(void)
>> +{
>> + static u32 acrn_cpuid_base;
>> +
>> + if (!acrn_cpuid_base && boot_cpu_has(X86_FEATURE_HYPERVISOR))
>> + acrn_cpuid_base = hypervisor_cpuid_base("ACRNACRNACRN", 0);
>> +
>> + return acrn_cpuid_base;
>> +}
>> +
>> +bool acrn_is_privileged_vm(void)
>> +{
>> + return cpuid_eax(acrn_cpuid_base() | ACRN_CPUID_FEATURES) &
>
>What's that dance and acrn_cpuid_base static thing needed for? Why not
>simply:
>
> cpuid_eax(ACRN_CPUID_FEATURES) & ...
>
>?

hypervisor_cpuid_base() searches reserved hypervisor cpuid region and
return the base matched the right signature, the base might vary. So i
put it here.

>
>> + ACRN_FEATURE_PRIVILEGED_VM;
>> +}
>> +EXPORT_SYMBOL_GPL(acrn_is_privileged_vm);
>
>Also, if you're going to need more of those bit checkers acrn_is_<something>
>which look at ACRN_CPUID_FEATURES, just stash CPUID_0x40000001_EAX locally and
>use a
>
> acrn_has(ACRN_FEATURE_PRIVILEGED_VM)
>
>which does the bit testing.

Thanks. Currently, there is only one feature bit. I will introduce
that you suggested with more feature bits to be tested.

Thanks
shuo