Skip to content

Commit 2727263

Browse files
yonghuahdeb-intel
authored andcommitted
doc: hld-security memory management enhancement update
Remove some obsolete descriptions and update content that is not consistent with the design. Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
1 parent 81a7666 commit 2727263

File tree

1 file changed

+21
-43
lines changed

1 file changed

+21
-43
lines changed

doc/developer-guides/hld/hld-security.rst

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ such as Hypercall APIs, I/O emulations, and EPT violation handling.
221221
The main security goal of the ACRN hypervisor design is to prevent
222222
Privilege Escalation and enforce Isolation, for example:
223223

224-
- VMM privilege escalation (vmx non-root -> vmx root)
224+
- VMM privilege escalation (VMX non-root -> VMX root)
225225
- Non-secure OS software (running in AaaG) accessing secure world TEE
226226
assets
227227
- Unauthorized software from executing in the hypervisor
228228
- Cross-guest VM attacks
229-
- Hypervisor secret information leaks
229+
- Hypervisor secret information leakage
230230

231231
Memory Management Enhancement
232232
-----------------------------
@@ -257,9 +257,9 @@ boundary for memory space between the hypervisor and Guest VMs.
257257

258258
Hypervisor and Guest Memory Layout
259259

260-
The hypervisor must appropriately configure the EPT tables (GPA->HPA
261-
mapping) to disallow any guest to access (read/write/execution) the
262-
memory space owned by the hypervisor.
260+
The hypervisor must appropriately configure the EPT tables to disallow
261+
any guest to access (read/write/execution) the memory space owned by
262+
the hypervisor.
263263

264264
Memory Access Restrictions
265265
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -395,16 +395,13 @@ In order to activate SMEP protection, ACRN hypervisor must:
395395
#. Set CR4.SMEP bit. In the entire lifecycle of the hypervisor, this bit
396396
value always remains one.
397397

398-
As an alternative, NX feature can also be used for this purpose by
399-
setting the corresponding NX (non-execution) bit for all the guest
400-
memory mapping in host CR3 paging tables.
398+
As an alternative, NX feature is used for this purpose by setting the
399+
corresponding NX (non-execution) bit for all the guest memory mapping
400+
in host CR3 paging tables.
401401

402402
Since hypervisor code never runs in Ring 3 mode, either of these two
403-
solutions works very well. As the NX bit is also used by the hypervisor
404-
to disable execution of its own data (by policies mentioned previously),
405-
the latter solution should be easier to implement. Since enabling
406-
CR0.SMEP bit is simple and does no harm to the system, it is recommended
407-
that both solutions should be enabled in the ACRN hypervisor.
403+
solutions works very well. Both solutions are enabled in the ACRN
404+
hypervisor.
408405

409406
Guest Memory Access Prevention
410407
++++++++++++++++++++++++++++++
@@ -416,7 +413,7 @@ application program.
416413

417414
This feature is controlled by the CR4.SMAP bit. When that bit is set,
418415
any attempt to access user-accessible memory pages while running in a
419-
privileged or kernel mode will lead to a page fault.
416+
privileged or kernel mode will lead to a page fault.
420417

421418
However, there are times when the kernel legitimately needs to work with
422419
user-accessible memory pages. The Intel processor defines a separate
@@ -429,14 +426,11 @@ To manipulate that flag relatively quickly, STAC (set AC flag) and CLAC
429426
(clear AC flag) instructions are introduced for this purpose. Note that
430427
STAC and CLAC can only be executed in kernel mode (CPL=0).
431428

432-
To activate SMAP protection, ACRN hypervisor must:
429+
To activate SMAP protection in ACRN hypervisor:
433430

434431
#. Configure all the guest memory as user-writable memory (U/S bit = 1,
435432
and R/W bit = 1) in corresponding host CR3 paging table entries, as
436-
shown in :numref:`security-smap` below. Note that the R/W bit would also be clear,
437-
which means that the corresponding user-accessible pages are
438-
read-only to user mode. Then if CR0.WP = 1, even the kernel mode (in
439-
hypervisor ring 0) cannot even write to this user-accessible pages.
433+
shown in :numref:`security-smap` below.
440434
#. Set CR4.SMAP bit. In the entire lifecycle of hypervisor, this bit
441435
value always remains one.
442436
#. When needed, use STAC instruction to suppress SMAP protection, and
@@ -470,29 +464,13 @@ The attack surface can be minimized because there is only a
470464
very small window between step 1 and step 3 in which the guest memory
471465
can be accessed by hypervisor code running in ring 0.
472466

473-
The following section details the memory operation rules and
474-
functions when accessing guest memory pages.
475-
476-
Memory Operation Functions/Rules for Accessing Guest Memory
477-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
478-
479-
The Linux kernel uses copy\_[to/from]\_user() / get\_user() /
480-
put\_user() whenever the kernel legitimately attempts to access
481-
user-accessible memory pages (refer to `Linux kernel copy routines
482-
documentation
483-
<https://www.kernel.org/doc/htmldocs/kernel-hacking/routines-copy.html>`_
484-
The ACRN hypervisor, provides similar functions:
485-
486-
``put_vm()``, and ``get_vm()``
487-
used to put and get single values (such as an int, char, or long) to
488-
and from vm / guest memory area (user-accessible pages).
489-
490-
``copy\_to\_vm()``, and ``copy\_from\_vm()``
491-
used to copy an arbitrary amount of data to and from vm / guest
492-
memory area (user-accessible pages).
467+
Rules to Access Guest Memory in Hypervisor
468+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
493469

494-
Inside these functions, the internal memory read/write operations
495-
are surrounded by STAC and CLAC instructions.
470+
In ACRN hypervisor, functions ``stac()`` and ``clac()`` wrap
471+
STAC and CLAC instructions respectively, and functions
472+
``copy_to_gpa()``, and ``copy_from_gpa()`` can be used to copy
473+
an arbitrary amount of data to or from VM memory area.
496474

497475
Whenever the hypervisor needs to perform legitimate read/write access to
498476
guest memory pages, one of functions above must be used. Otherwise, the
@@ -506,8 +484,8 @@ host MMU mapping), and must not be in the range of hypervisor memory.
506484
Details of these ordinary checks are out of scope in this document.
507485

508486

509-
Memory Information Leak
510-
-----------------------
487+
Avoidance of Memory Information Leakage
488+
---------------------------------------
511489

512490
Protecting the hypervisor's memory is critical to the security of the
513491
entire platform. The hypervisor must prevent any memory content (e.g.

0 commit comments

Comments
 (0)