KSM exposes a guest's virtual memory to side-channel attacks. Add a VM
configuration option to disable KSM for specific VMs that need to be
protected against such attacks. This makes it possible to still
benefit from KSM for other processes on the host rather than needing
to turn of KSM completely.

Signed-off-by: Fiona Ebner <[email protected]>
---
 src/PVE/QemuServer.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 128b8f47..af333e50 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -731,6 +731,13 @@ EODESCR
             "List of host cores used to execute guest processes, for example: 
0,5,8-11",
         optional => 1,
     },
+    'allow-ksm' => {
+        type => 'boolean',
+        description => "Allow memory pages of this guest to be merged via KSM 
(Kernel Samepage"
+            . " Merging).",
+        optional => 1,
+        default => 1,
+    },
 };
 
 my $cicustom_fmt = {
@@ -3781,6 +3788,8 @@ sub config_to_command {
         push @$machineFlags, 'kernel_irqchip=split';
     }
 
+    push @$machineFlags, 'mem-merge=off' if defined($conf->{'allow-ksm'}) && 
!$conf->{'allow-ksm'};
+
     PVE::QemuServer::Virtiofs::config($conf, $vmid, $devices);
 
     push @$cmd, @$devices;
-- 
2.47.3



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to