aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuzuki K Poulose <suzuki.poulose@arm.com>2022-08-09 13:48:16 +0100
committerWill Deacon <will@kernel.org>2022-09-22 13:27:10 +0100
commit9987a37cfc574bd90df9dbb6a1e08ac6b48c7cea (patch)
treebed8cc41914d9cd37f73546498ae0aa568302805
parent336751fb10ef24e65cd2f25c450da1d52ff5b33c (diff)
downloadkvmtool-9987a37cfc574bd90df9dbb6a1e08ac6b48c7cea.tar.gz
net: Use vfork() instead of fork() for script execution
When a script is specified for a guest nic setup, we fork() and execl()s the script when it is time to execute the script. However this is not optimal, given we are running a VM. The fork() will trigger marking the entire page-table of the current process as CoW, which will trigger unmapping the entire stage2 page tables from the guest. Anyway, the child process will exec the script as soon as we fork(), making all these mm operations moot. Also, this operation could be problematic for confidential compute VMs, where it may be expensive (and sometimes destructive) to make changes to the stage2 page tables. So, instead we could use vfork() and avoid the CoW and unmap of the stage2. Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20220809124816.2880990-1-suzuki.poulose@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--virtio/net.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/virtio/net.c b/virtio/net.c
index c4e302bd..a5e0cea5 100644
--- a/virtio/net.c
+++ b/virtio/net.c
@@ -295,7 +295,7 @@ static int virtio_net_exec_script(const char* script, const char *tap_name)
pid_t pid;
int status;
- pid = fork();
+ pid = vfork();
if (pid == 0) {
execl(script, script, tap_name, NULL);
_exit(1);