Commit 09ca291e authored by Yi-De Wu's avatar Yi-De Wu Committed by Todd Kjos
Browse files

FROMLIST: virt: geniezone: Add memory pin/unpin support



Protected VM's memory cannot be swapped out because the memory pages are
protected from host access.

Once host accesses to those protected pages, the hardware exception is
triggered and may crash the host. So, we have to make those protected
pages be ineligible for swapping or merging by the host kernel to avoid
host access. To do so, we pin the page when it is assigned (donated) to
VM and unpin when VM relinquish the pages or is destroyed. Besides, the
protected VM’s memory requires hypervisor to clear the content before
returning to host, but VMM may free those memory before clearing, it
will result in those memory pages are reclaimed and reused before
totally clearing. Using pin/unpin can also avoid the above problems.

The implementation is described as follows.
- Use rb_tree to store pinned memory pages.
- Pin the page when handling page fault.

Change-Id: I1c4338e409821cf1f8df46a4951803c4f4728f94
Signed-off-by: default avatarJerry Wang <ze-yu.wang@mediatek.com>
Signed-off-by: default avatarYingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: default avatarLiju-Clr Chen <liju-clr.chen@mediatek.com>
Signed-off-by: default avatarYi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-15-yi-de.wu@mediatek.com/
parent 7cc3767c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment