diff mbox series

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

Message ID 20221104154618.9953-1-13212017962@163.com
State Accepted
Headers show
Series RISC-V KVM: Add exit logic to main.c | expand

Commit Message

XiakaiPan Nov. 4, 2022, 3:46 p.m. UTC
Several lines of code are inserted to remove KVM module normally using rmmod command just like others.

Signed-off-by: XiakaiPan <13212017962@163.com>
---
 arch/riscv/kvm/main.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Andrew Jones Nov. 4, 2022, 5:03 p.m. UTC | #1
On Fri, Nov 04, 2022 at 11:46:18PM +0800, XiakaiPan wrote:
> Several lines of code are inserted to remove KVM module normally using rmmod command just like others.
> 
> Signed-off-by: XiakaiPan <13212017962@163.com>
> ---
>  arch/riscv/kvm/main.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c
> index 1549205fe..81f1a761d 100644
> --- a/arch/riscv/kvm/main.c
> +++ b/arch/riscv/kvm/main.c
> @@ -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);
> -- 
> 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.

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Tested-by: Andrew Jones <ajones@ventanamicro.com>
Anup Patel Nov. 27, 2022, 6:11 a.m. UTC | #2
On Fri, Nov 4, 2022 at 9:16 PM XiakaiPan <13212017962@163.com> wrote:
>
> Several lines of code are inserted to remove KVM module normally using rmmod command just like others.
>
> Signed-off-by: XiakaiPan <13212017962@163.com>
> ---
>  arch/riscv/kvm/main.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c
> index 1549205fe..81f1a761d 100644
> --- a/arch/riscv/kvm/main.c
> +++ b/arch/riscv/kvm/main.c
> @@ -122,6 +122,12 @@ void kvm_arch_exit(void)
>  {
>  }
>
> +static void riscv_kvm_exit(void)

Add __exit attribute to riscv_kvm_exit()

> +{
> +       kvm_exit();

Use tab instead of space for indentation.

> +}
> +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
diff mbox series

Patch

diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c
index 1549205fe..81f1a761d 100644
--- a/arch/riscv/kvm/main.c
+++ b/arch/riscv/kvm/main.c
@@ -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);