Skip to contentSkip to conversation

RISC-V KVM: Add exit logic to main.c

PATCH New XiakaiPan 3 participants 3 messages Nov 4, 2022 – Nov 27, 2022

Subsystems (2)
lore
Share & tools
lore

XiakaiPan

author
#0 lore raw

PATCH 1/1 RISC-V KVM: Add exit logic to main.c

Several lines of code are inserted to remove KVM module normally using rmmod command just like others.

---
 arch/riscv/kvm/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/kvm/main.c +6 -0
index 1549205fe..81f1a761d 100644
@@ -122,6 +122,12 @@ void kvm_arch_exit(void)
 {
 }
 
+static void riscv_kvm_exit(void)
+{
+       kvm_exit();
+}
+module_exit(riscv_kvm_exit);
+
 static int riscv_kvm_init(void)
 {
 	return kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 RISC-V KVM: Add exit logic to main.c

Quoted 27 lines · XiakaiPan

Several lines of code are inserted to remove KVM module normally using rmmod command just like others.

---
 arch/riscv/kvm/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/kvm/main.c +6 -0
index 1549205fe..81f1a761d 100644
@@ -122,6 +122,12 @@ void kvm_arch_exit(void)
 {
 }
 
+static void riscv_kvm_exit(void)
+{
+       kvm_exit();
+}
+module_exit(riscv_kvm_exit);
+
 static int riscv_kvm_init(void)
 {
 	return kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
Signature · 1 line
2.25.1

LGTM, assuming we don't need the riscv kvm module to be permanent for some reason. If we do, then I guess we need a comment here by module_init() stating that. I did test loading and unloading multiple times and running VMs in between, no fireballs appeared.

maintainer
#2 lore raw

PATCH 1/1 RISC-V KVM: Add exit logic to main.c

In reply to XiakaiPan
Quoted 13 lines · XiakaiPan

Several lines of code are inserted to remove KVM module normally using rmmod command just like others.

---
 arch/riscv/kvm/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/kvm/main.c +0 -0
index 1549205fe..81f1a761d 100644

arch/riscv/kvm/main.c void kvm_arch_exit(void) · line 125

Quoted 4 lines
arch/riscv/kvm/main.c +1 -0
@@ -122,6 +122,12 @@ void kvm_arch_exit(void)
 {
 }
 
+static void riscv_kvm_exit(void)

Add __exit attribute to riscv_kvm_exit()

arch/riscv/kvm/main.c void kvm_arch_exit(void) · line 127

Quoted 2 lines
arch/riscv/kvm/main.c +2 -0
+{
+       kvm_exit();

Use tab instead of space for indentation.

Quoted 9 lines
arch/riscv/kvm/main.c +3 -1
+}
+module_exit(riscv_kvm_exit);
+
 static int riscv_kvm_init(void)
 {
        return kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
--

2.25.1

I have taken care of the above comments at the
time of applying this patch.

Queued this patch for Linux-6.2

Thanks,
Anup