All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Gowans <jgowans@amazon.com>
To: <linux-kernel@vger.kernel.org>
Cc: James Gowans <jgowans@amazon.com>,
	Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Steve Sistare <steven.sistare@oracle.com>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	"Anthony Yznaga" <anthony.yznaga@oracle.com>,
	Mike Rapoport <rppt@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>, <linux-mm@kvack.org>,
	Jason Gunthorpe <jgg@ziepe.ca>, <linux-fsdevel@vger.kernel.org>,
	Usama Arif <usama.arif@bytedance.com>, <kvm@vger.kernel.org>,
	Alexander Graf <graf@amazon.com>,
	David Woodhouse <dwmw@amazon.co.uk>,
	Paul Durrant <pdurrant@amazon.co.uk>,
	Nicolas Saenz Julienne <nsaenz@amazon.es>
Subject: [PATCH 09/10] guestmemfs: Add documentation and usage instructions
Date: Mon, 5 Aug 2024 11:32:44 +0200	[thread overview]
Message-ID: <20240805093245.889357-10-jgowans@amazon.com> (raw)
In-Reply-To: <20240805093245.889357-1-jgowans@amazon.com>

Describe the motivation for guestmemfs, the functionality it provides,
how to compile it in, how to use it as a source of guest memory, how to
persist it across kexec and save/restore a VM.

Signed-off-by: James Gowans <jgowans@amazon.com>
---
 Documentation/filesystems/guestmemfs.rst | 87 ++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/filesystems/guestmemfs.rst

diff --git a/Documentation/filesystems/guestmemfs.rst b/Documentation/filesystems/guestmemfs.rst
new file mode 100644
index 000000000000..d6ce0d194cc8
--- /dev/null
+++ b/Documentation/filesystems/guestmemfs.rst
@@ -0,0 +1,87 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+======================================================
+Guestmemfs - Persistent in-memory guest RAM filesystem
+======================================================
+
+Overview
+========
+
+Guestmemfs is an in-memory filesystem designed specifically for the purpose of
+live update of virtual machines by being a persistent across kexec source of
+guest VM memory.
+
+Live update of a hypervisor refers to act of pausing running VMs, serialising
+state, kexec-ing into a new hypervisor image, re-hydraing the KVM guests and
+resuming them. To achieve this guest memory must be preserved across kexec.
+
+Additionally, guestmemfs provides:
+- secret hiding for guest memory: the physical memory allocated for guestmemfs
+  is carved out of the direct map early in boot.
+- struct page overhead elimination: guestmemfs memory is not allocated by the
+  buddy allocator and does not have associated struct pages.
+- huge page mappings: allocations are done at PMD size and this improves TLB
+  performance (work in progress.)
+
+Compilation
+===========
+
+Guestmemfs is enabled via CONFIG_GUESTMEMFS_FS
+
+Persistence across kexec is enabled via CONFIG_KEXEC_KHO
+
+Usage
+=====
+
+On first boot (cold boot), allocate a large contiguous chunk of memory for
+guestmemfs via a kernel cmdline argument, eg:
+`guestmemfs=10G`.
+
+Mount guestmemfs:
+mount -t guestmemfs guestmemfs /mnt/guestmemfs/
+
+Create and truncate a file which will be used for guest RAM:
+
+touch /mnt/guesttmemfs/guest-ram
+truncate -s 500M /mnt/guestmemfs/guest-ram
+
+Boot a VM with this as the RAM source and the live update option enabled:
+
+qemu-system-x86_64 ... \
+  -object memory-backend-file,id=pc.ram,size=100M,mem-path=/mnt/guestmemfs/guest-ram,share=yes,prealloc=off \
+  -migrate-mode-enable cpr-reboot \
+  ...
+
+Suspect the guest and save the state via QEMU monitor:
+
+migrate_set_parameter mode cpr-reboot
+migrate file:/qemu.sav
+
+Activate KHO to serialise guestmemfs metadata and then kexec to the new
+hypervisor image:
+
+echo 1 > /sys/kernel/kho/active
+kexec -s -l --reuse-cmdline
+kexec -e
+
+After the kexec completes remount guestmemfs (or have it added to fstab)
+Re-start QEMU in live update restore mode:
+
+qemu-system-x86_64 ... \
+  -object memory-backend-file,id=pc.ram,size=100M,mem-path=/mnt/guestmemfs/guest-ram,share=yes,prealloc=off \
+  -migrate-mode-enable cpr-reboot \
+  -incoming defer
+  ...
+
+Finally restore the VM state and resume it via QEMU console:
+
+migrate_incoming file:/qemu.sav
+
+Future Work
+===========
+- NUMA awareness and multi-mount point support
+- Actually creating PMD-level mappings in page tables
+- guest_memfd style interface for confidential computing
+- supporting PUD-level allocations and mappings
+- MCE handling
+- Persisting IOMMU pgtables to allow DMA to guestmemfs during kexec
-- 
2.34.1


  parent reply	other threads:[~2024-08-05  9:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05  9:32 [PATCH 00/10] Introduce guestmemfs: persistent in-memory filesystem James Gowans
2024-08-05  9:32 ` [PATCH 01/10] guestmemfs: Introduce filesystem skeleton James Gowans
2024-08-05 10:20   ` Christian Brauner
2024-08-05  9:32 ` [PATCH 02/10] guestmemfs: add inode store, files and dirs James Gowans
2024-08-05  9:32 ` [PATCH 03/10] guestmemfs: add persistent data block allocator James Gowans
2024-08-05  9:32 ` [PATCH 04/10] guestmemfs: support file truncation James Gowans
2024-08-05  9:32 ` [PATCH 05/10] guestmemfs: add file mmap callback James Gowans
2024-10-29 23:05   ` Elliot Berman
2024-10-30 22:18     ` Frank van der Linden
2024-11-01 12:55       ` Gowans, James
2024-10-31 15:30     ` Gowans, James
2024-10-31 16:06       ` Jason Gunthorpe
2024-11-01 13:01         ` Gowans, James
2024-11-01 13:42           ` Jason Gunthorpe
2024-11-02  8:24             ` Gowans, James
2024-11-04 11:11               ` Mike Rapoport
2024-11-04 14:39               ` Jason Gunthorpe
2024-11-04 10:49             ` Mike Rapoport
2024-08-05  9:32 ` [PATCH 06/10] kexec/kho: Add addr flag to not initialise memory James Gowans
2024-08-05  9:32 ` [PATCH 07/10] guestmemfs: Persist filesystem metadata via KHO James Gowans
2024-08-05  9:32 ` [PATCH 08/10] guestmemfs: Block modifications when serialised James Gowans
2024-08-05  9:32 ` James Gowans [this message]
2024-08-05  9:32 ` [PATCH 10/10] MAINTAINERS: Add maintainers for guestmemfs James Gowans
2024-08-05 14:32 ` [PATCH 00/10] Introduce guestmemfs: persistent in-memory filesystem Theodore Ts'o
2024-08-05 14:41   ` Paolo Bonzini
2024-08-05 19:47     ` Gowans, James
2024-08-05 19:53   ` Gowans, James
2024-08-05 20:01 ` Jan Kara
2024-08-05 23:29   ` Jason Gunthorpe
2024-08-06  8:26     ` Gowans, James
2024-08-06  8:12   ` Gowans, James
2024-08-06 13:43     ` David Hildenbrand
2024-08-07 23:45 ` David Matlack
2024-10-17  4:53 ` Vishal Annapurve
2024-11-01 12:53   ` Gowans, James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240805093245.889357-10-jgowans@amazon.com \
    --to=jgowans@amazon.com \
    --cc=akpm@linux-foundation.org \
    --cc=anthony.yznaga@oracle.com \
    --cc=brauner@kernel.org \
    --cc=dwmw@amazon.co.uk \
    --cc=graf@amazon.com \
    --cc=jack@suse.cz \
    --cc=jgg@ziepe.ca \
    --cc=kvm@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nsaenz@amazon.es \
    --cc=pbonzini@redhat.com \
    --cc=pdurrant@amazon.co.uk \
    --cc=rppt@kernel.org \
    --cc=seanjc@google.com \
    --cc=steven.sistare@oracle.com \
    --cc=usama.arif@bytedance.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.