acrn-hypervisor/doc
Junjie Mao ea4eadf0a5 hv: hypercalls: refactor permission-checking and dispatching logic
The current permission-checking and dispatching mechanism of hypercalls is
not unified because:

  1. Some hypercalls require the exact vCPU initiating the call, while the
     others only need to know the VM.
  2. Different hypercalls have different permission requirements: the
     trusty-related ones are enabled by a guest flag, while the others
     require the initiating VM to be the Service OS.

Without a unified logic it could be hard to scale when more kinds of
hypercalls are added later.

The objectives of this patch are as follows.

  1. All hypercalls have the same prototype and are dispatched by a unified
     logic.
  2. Permissions are checked by a unified logic without consulting the
     hypercall ID.

To achieve the first objective, this patch modifies the type of the first
parameter of hcall_* functions (which are the callbacks implementing the
hypercalls) from `struct acrn_vm *` to `struct acrn_vcpu *`. The
doxygen-style documentations are updated accordingly.

To achieve the second objective, this patch adds to `struct hc_dispatch` a
`permission_flags` field which specifies the guest flags that must ALL be
set for a VM to be able to invoke the hypercall. The default value (which
is 0UL) indicates that this hypercall is for SOS only. Currently only the
`permission_flag` of trusty-related hypercalls have the non-zero value
GUEST_FLAG_SECURE_WORLD_ENABLED.

With `permission_flag`, the permission checking logic of hypercalls is
unified as follows.

  1. General checks
     i. If the VM is neither SOS nor having any guest flag that allows
        certain hypercalls, it gets #UD upon executing the `vmcall`
        instruction.
    ii. If the VM is allowed to execute the `vmcall` instruction, but
        attempts to execute it in ring 1, 2 or 3, the VM gets #GP(0).
  2. Hypercall-specific checks
     i. If the hypercall is for SOS (i.e. `permission_flag` is 0), the
        initiating VM must be SOS and the specified target VM cannot be a
        pre-launched VM. Otherwise the hypercall returns -EINVAL without
        further actions.
    ii. If the hypercall requires certain guest flags, the initiating VM
        must have all the required flags. Otherwise the hypercall returns
        -EINVAL without further actions.
   iii. A hypercall with an unknown hypercall ID makes the hypercall
        returns -EINVAL without further actions.

The logic above is different from the current implementation in the
following aspects.

  1. A pre-launched VM now gets #UD (rather than #GP(0)) when it attempts
     to execute `vmcall` in ring 1, 2 or 3.
  2. A pre-launched VM now gets #UD (rather than the return value -EPERM)
     when it attempts to execute a trusty hypercall in ring 0.
  3. The SOS now gets the return value -EINVAL (rather than -EPERM) when it
     attempts to invoke a trusty hypercall.
  4. A post-launched VM with trusty support now gets the return value
     -EINVAL (rather than #UD) when it attempts to invoke a non-trusty
     hypercall or an invalid hypercall.

v1 -> v2:
 - Update documentation that describe hypercall behavior.
 - Fix Doxygen warnings

Tracked-On: #5924
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-05-12 13:43:41 +08:00
..
.known-issues doc: tweak known-issues for PDF processing 2021-04-27 17:07:00 -07:00
_templates doc: update breadcrumb to include release version 2020-10-01 14:53:29 -07:00
api doc: update another few mis-handled titles 2021-02-24 15:14:53 -08:00
custom-doxygen
developer-guides hv: hypercalls: refactor permission-checking and dispatching logic 2021-05-12 13:43:41 +08:00
extensions doc: add extension to create files and raw links 2020-11-05 09:17:05 -08:00
getting-started doc: add clang-format to setup package list 2021-05-06 16:14:11 -07:00
images doc: add ACRN lockup logo to README 2020-12-15 10:36:42 -08:00
introduction doc: make the "logical partitioning" description more generic 2021-04-20 13:28:30 -07:00
reference doc: fix incorrect info about serial port availability 2021-03-08 13:40:26 -08:00
release_notes doc: update release notes 2021-04-06 08:01:01 -07:00
scripts doc: clean up PDF generation for ACRN docs 2021-04-26 19:50:44 -07:00
static doc: update v2.4 release notes 2021-03-29 19:32:07 -07:00
tutorials doc: update ACRN qemu HV tag to v2.0 2021-05-10 15:36:01 -07:00
user-guides doc: add note to emphasize the need to use --windows for WaaG 2021-05-05 18:50:50 -07:00
404.rst doc: fix columns issue with 404 page display 2020-06-05 16:44:15 -07:00
LICENSE
Makefile doc: clean up PDF generation for ACRN docs 2021-04-26 19:50:44 -07:00
README.md doc: post-merge changes to docs 2018-05-15 18:03:33 +08:00
acrn.doxyfile hv: mod: do not use explicit arch name when including headers 2021-05-08 11:15:46 +08:00
asa.rst doc: update a few mis-handled titles 2021-02-17 16:42:56 -08:00
conf.py doc: clean up PDF generation for ACRN docs 2021-04-26 19:50:44 -07:00
contribute.rst doc: fix rst-columns display 2020-05-21 15:08:15 -07:00
develop.rst doc: remove Kconfig reference documentation 2021-02-03 09:01:40 -08:00
faq.rst config_tools: remove UOS_RAM_SIZE and SOS_RAM_SIZE in scenario config 2021-04-19 14:45:10 +08:00
genindex.rst doc: add sphinx-generated index to leftnav 2020-11-05 09:16:45 -08:00
glossary.rst doc: more prep for upgrading doc build tools 2020-11-01 10:12:17 -08:00
index.rst doc: fix all headings to use title case 2021-02-13 12:37:49 -08:00
learn.rst doc: fix all headings to use title case 2021-02-13 12:37:49 -08:00
nocl.rst doc: fix all headings to use title case 2021-02-13 12:37:49 -08:00
scorer.js doc: adjust search results to bias certain docs 2020-06-15 12:30:36 -07:00
substitutions.txt doc: fix rendering of rightwards arrows 2021-02-25 14:55:51 -08:00
try.rst doc: add ROScube GSG 2020-12-08 11:08:58 -08:00

README.md

Project ACRN Documentation

This folder hold the source and configuration files used to generate the Project ACRN documentation web site published to https://projectacrn.github.io