Skip to content

Commit 779d287

Browse files
committed
Export two more functions needed for cleanup
When a VM gets stopped or terminated, the guest memory should be unmapped and free. This will allow mm struct to be destroyed without any problem. For that purspose we need to export 2 more functions: - insert_vm_struct - do_munmap Signed-off-by: Charalampos Mainas <[email protected]>
1 parent 131af84 commit 779d287

2 files changed

+50
-8
lines changed

v5.7/0002-Export-vma-allocation-related-functions.patch

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From d596c44ab5aa5fc4834908b24ac6f1628a023d73 Mon Sep 17 00:00:00 2001
2-
From: Charalampos Mainas <cmainas@nubificus.com>
3-
Date: Tue, 15 Jun 2021 13:31:24 +0000
1+
From ecd2fc90bb769c4f73a6f742d704217965f69f5c Mon Sep 17 00:00:00 2001
2+
From: Charalampos Mainas <charalampos.mainas@gmail.com>
3+
Date: Tue, 31 Aug 2021 00:02:50 +0300
44
Subject: [PATCH 2/2] Export vma allocation related functions
55

66
KVMM guests use kernel allocated memory, which is obtained by vmalloc.
@@ -22,8 +22,9 @@ Signed-off-by: Stratos Psomadakis <[email protected]>
2222
---
2323
arch/x86/mm/mmap.c | 1 +
2424
kernel/fork.c | 3 +++
25+
mm/mmap.c | 2 ++
2526
mm/util.c | 1 +
26-
3 files changed, 5 insertions(+)
27+
4 files changed, 7 insertions(+)
2728

2829
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
2930
index cb91eccc4..e9a285113 100644
@@ -65,6 +66,26 @@ index 48ed22774..6386b48e1 100644
6566

6667
static inline void __mmput(struct mm_struct *mm)
6768
{
69+
diff --git a/mm/mmap.c b/mm/mmap.c
70+
index f609e9ec4..ddd422fdd 100644
71+
--- a/mm/mmap.c
72+
+++ b/mm/mmap.c
73+
@@ -2843,6 +2843,7 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
74+
{
75+
return __do_munmap(mm, start, len, uf, false);
76+
}
77+
+EXPORT_SYMBOL(do_munmap);
78+
79+
static int __vm_munmap(unsigned long start, size_t len, bool downgrade)
80+
{
81+
@@ -3199,6 +3200,7 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82+
vma_link(mm, vma, prev, rb_link, rb_parent);
83+
return 0;
84+
}
85+
+EXPORT_SYMBOL(insert_vm_struct);
86+
87+
/*
88+
* Copy the vma structure to a new location in the same mm,
6889
diff --git a/mm/util.c b/mm/util.c
6990
index 988d11e6c..267ac25d7 100644
7091
--- a/mm/util.c
@@ -78,5 +99,5 @@ index 988d11e6c..267ac25d7 100644
7899
void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
79100
{
80101
--
81-
2.31.1
102+
2.32.0
82103

v5.8/0002-Export-vma-allocation-related-functions.patch

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From ba09c34ac998d7077525f95dc07d2343f2b66849 Mon Sep 17 00:00:00 2001
1+
From 2dcf0c06d4ad551618c29a73962ae16741ae9989 Mon Sep 17 00:00:00 2001
22
From: Charalampos Mainas <[email protected]>
3-
Date: Fri, 25 Jun 2021 10:53:35 +0300
3+
Date: Mon, 23 Aug 2021 00:13:45 +0300
44
Subject: [PATCH 2/2] Export vma allocation related functions
55

66
KVMM guests use kernel allocated memory, which is obtained by vmalloc.
@@ -22,8 +22,9 @@ Signed-off-by: Stratos Psomadakis <[email protected]>
2222
---
2323
arch/x86/mm/mmap.c | 1 +
2424
kernel/fork.c | 3 +++
25+
mm/mmap.c | 2 ++
2526
mm/util.c | 1 +
26-
3 files changed, 5 insertions(+)
27+
4 files changed, 7 insertions(+)
2728

2829
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
2930
index c90c20904..9775fcf10 100644
@@ -65,6 +66,26 @@ index efc549320..fc5f37e96 100644
6566

6667
static inline void __mmput(struct mm_struct *mm)
6768
{
69+
diff --git a/mm/mmap.c b/mm/mmap.c
70+
index 8c7ca737a..7bd118999 100644
71+
--- a/mm/mmap.c
72+
+++ b/mm/mmap.c
73+
@@ -2855,6 +2855,7 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
74+
{
75+
return __do_munmap(mm, start, len, uf, false);
76+
}
77+
+EXPORT_SYMBOL(do_munmap);
78+
79+
static int __vm_munmap(unsigned long start, size_t len, bool downgrade)
80+
{
81+
@@ -3211,6 +3212,7 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82+
vma_link(mm, vma, prev, rb_link, rb_parent);
83+
return 0;
84+
}
85+
+EXPORT_SYMBOL(insert_vm_struct);
86+
87+
/*
88+
* Copy the vma structure to a new location in the same mm,
6889
diff --git a/mm/util.c b/mm/util.c
6990
index c63c8e47b..adb15372c 100644
7091
--- a/mm/util.c

0 commit comments

Comments
 (0)