Skip to contentSkip to conversation

kvm: x86: disable the narrow guest module parameter on unload

PATCH Applied Aaron Lewis 3 participants 4 messages Jun 23, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: x86: disable the narrow guest module parameter on unload

When the kvm_intel module unloads the module parameter 'allow_smaller_maxphyaddr' is not cleared because it is also used in the kvm module. As a result, if the module parameter's state was set before kvm_intel unloads, it will also be set when it reloads. Explicitly clear the state in vmx_exit() to prevent this from happening.

---
 arch/x86/kvm/vmx/vmx.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/vmx.c +2 -0
index c2a779b688e6..fd161c9a83fd 100644
@@ -7996,6 +7996,8 @@ static void vmx_exit(void)
 	}
 #endif
 	vmx_cleanup_l1d_flush();
+
+	allow_smaller_maxphyaddr = false;
 }
 module_exit(vmx_exit);
 
Signature · 1 line
2.32.0.93.g670b81a890-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Aaron Lewis

When the kvm_intel module unloads the module parameter 'allow_smaller_maxphyaddr' is not cleared because it is also used in the

...because the backing variable is defined in the

(Or something like that.)

Quoted 14 lines

kvm module. As a result, if the module parameter's state was set before kvm_intel unloads, it will also be set when it reloads. Explicitly clear the state in vmx_exit() to prevent this from happening.

---
 arch/x86/kvm/vmx/vmx.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/vmx.c +0 -0
index c2a779b688e6..fd161c9a83fd 100644

arch/x86/kvm/vmx/vmx.c static void vmx_exit(void) · line 8002

Quoted 7 lines
arch/x86/kvm/vmx/vmx.c +2 -0
@@ -7996,6 +7996,8 @@ static void vmx_exit(void)
        }
 #endif
        vmx_cleanup_l1d_flush();
+
+       allow_smaller_maxphyaddr = false;
 }
 module_exit(vmx_exit);

This seems reasonable to me. Another option is to move the backing variable to the kvm_intel module, given the recent suggestion that it should never be enabled for AMD.

maintainer
#2 lore raw
Quoted 3 lines · Jim Mattson

This seems reasonable to me. Another option is to move the backing variable to the kvm_intel module, given the recent suggestion that it should never be enabled for AMD.

Why wouldn't it be enabled for shadow paging, since the issue with AMD is specific to the ordering of nested vs. guest page faults?

Paolo

maintainer Applied
#3 lore raw
In reply to Aaron Lewis
Quoted 17 lines · Aaron Lewis

When the kvm_intel module unloads the module parameter 'allow_smaller_maxphyaddr' is not cleared because it is also used in the kvm module. As a result, if the module parameter's state was set before kvm_intel unloads, it will also be set when it reloads. Explicitly clear the state in vmx_exit() to prevent this from happening.

---
  arch/x86/kvm/vmx/vmx.c | 2 ++
  1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/vmx.c +0 -0
index c2a779b688e6..fd161c9a83fd 100644

arch/x86/kvm/vmx/vmx.c static void vmx_exit(void) · line 8003

Quoted 8 lines
arch/x86/kvm/vmx/vmx.c +2 -0
@@ -7996,6 +7996,8 @@ static void vmx_exit(void)
  	}
  #endif
  	vmx_cleanup_l1d_flush();
+
+	allow_smaller_maxphyaddr = false;
  }
  module_exit(vmx_exit);
 

Queued, thanks.

Paolo