mbox series

[0/2] kvm/i386: Some code refactoring and cleanups for kvm_arch_init

Message ID 20240903124143.39345-1-anisinha@redhat.com (mailing list archive)
Headers show
Series kvm/i386: Some code refactoring and cleanups for kvm_arch_init | expand

Message

Ani Sinha Sept. 3, 2024, 12:41 p.m. UTC
Some cleanups. Should be no functional impact.

CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Marcelo Tosatti <mtosatti@redhat.com>
CC: kvm@vger.kernel.org
CC: qemu-devel@nongnu.org

Ani Sinha (2):
  kvm/i386: refactor kvm_arch_init and split it into smaller functions
  kvm/i386: do not initialize identity_base variable

 target/i386/kvm/kvm.c | 339 ++++++++++++++++++++++++++----------------
 1 file changed, 212 insertions(+), 127 deletions(-)

Comments

Paolo Bonzini Sept. 4, 2024, 12:31 p.m. UTC | #1
Queued patch 1 with just a small change:

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 599faf0ac6e..023af31ba3e 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -3064,10 +3064,9 @@ static int kvm_vm_set_nr_mmu_pages(KVMState *s)
     return ret;
 }

-static int kvm_vm_set_tss_addr(KVMState *s, uint64_t identity_base)
+static int kvm_vm_set_tss_addr(KVMState *s, uint64_t tss_base)
 {
-    /* Set TSS base one page after EPT identity map. */
-    return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, identity_base);
+    return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, tss_base);
 }

 static int kvm_vm_enable_disable_exits(KVMState *s)
@@ -3268,6 +3267,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
         return ret;
     }

+    /* Set TSS base one page after EPT identity map. */
     ret = kvm_vm_set_tss_addr(s, identity_base + 0x1000);
     if (ret < 0) {
         return ret;


For patch 2, it's better to remove the variable completely and make
it a constant.  I'll send a patch.

Paolo