Skip to contentSkip to conversation

kvm: sync registers?

Qemu-devel Gerd Hoffmann 4 participants 8 messages Nov 7, 2008 – Nov 9, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

How does kvm sync registers between kernel and qemu env? I see there are kvm_arch_{get,put}_registers() functions in target-i386/kvm.c, but grep doesn't find a single call of them?

cheers,
Gerd

#1 lore raw
Quoted 6 lines · Gerd Hoffmann

Hi,

How does kvm sync registers between kernel and qemu env? I see there are kvm_arch_{get,put}_registers() functions in target-i386/kvm.c, but grep doesn't find a single call of them?

Right now, it doesn't. We should probably sync registers in the same places that kvm-userspace does (gdbstubs, vmport, etc.).

I tried to always sync registers on every exit but this causes boot to fail. The same is true of kvm-userspace though and I've been meaning to dig into why this is.

Regards,

Anthony Liguori

Quoted 5 lines

cheers,
Gerd

#2 lore raw
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Gerd Hoffmann

Hi,

How does kvm sync registers between kernel and qemu env? I see there are kvm_arch_{get,put}_registers() functions in target-i386/kvm.c, but grep doesn't find a single call of them?

Right now, it doesn't.

Ok. No wonder xenner doesn't boot xen pv guest kernels then. kvm doesn't see the protected-mode start-of-day setup done ...

Quoted 2 lines

We should probably sync registers in the same places that kvm-userspace does (gdbstubs, vmport, etc.).

Yep.

Quoted 3 lines

I tried to always sync registers on every exit but this causes boot to fail. The same is true of kvm-userspace though and I've been meaning to dig into why this is.

Or that. And maybe have a flag indicating qemu changed register state, i.e. next vmenter must sync too.

cheers,
Gerd

#3 lore raw
Quoted 11 lines · Gerd Hoffmann
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Gerd Hoffmann

Hi,

How does kvm sync registers between kernel and qemu env? I see there are kvm_arch_{get,put}_registers() functions in target-i386/kvm.c, but grep doesn't find a single call of them?

Right now, it doesn't.

Ok. No wonder xenner doesn't boot xen pv guest kernels then. kvm doesn't see the protected-mode start-of-day setup done ...

And sprinkle in a kvm_arch_put_registers() call to the right place fixed it nicely.

cheers,
Gerd

#4 lore raw
In reply to Anthony Liguori
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Gerd Hoffmann

Hi,

How does kvm sync registers between kernel and qemu env? I see there are kvm_arch_{get,put}_registers() functions in target-i386/kvm.c, but grep doesn't find a single call of them?

Quoted 6 lines

Right now, it doesn't. We should probably sync registers in the same places that kvm-userspace does (gdbstubs, vmport, etc.).

I tried to always sync registers on every exit but this causes boot to fail. The same is true of kvm-userspace though and I've been meaning to dig into why this is.

Maybe due to do with inconsistencies between the segment register contents and the descriptor tables? I know I've written code that relies on this feature.

Paul

#5 lore raw
Quoted 13 lines · Paul Brook
Quoted 11 lines · Anthony Liguori
Quoted 6 lines · Gerd Hoffmann

Hi,

How does kvm sync registers between kernel and qemu env? I see there are kvm_arch_{get,put}_registers() functions in target-i386/kvm.c, but grep doesn't find a single call of them?

Right now, it doesn't. We should probably sync registers in the same places that kvm-userspace does (gdbstubs, vmport, etc.).

Quoted 7 lines
Quoted 4 lines

I tried to always sync registers on every exit but this causes boot to fail. The same is true of kvm-userspace though and I've been meaning to dig into why this is.

Maybe due to do with inconsistencies between the segment register contents and the descriptor tables? I know I've written code that relies on this feature.

VT/SVM actually allow you to get at the descriptor tables/cache and we save/restore them in KVM. I only see this issue if I always save/restore registers so it leads me to think it's something more subtle.

Regards,

Anthony Liguori

Quoted 2 lines

Paul

#7 lore raw
In reply to Paul Brook
Quoted 10 lines · Paul Brook
Quoted 9 lines · Anthony Liguori
Quoted 5 lines · Gerd Hoffmann

Hi,

How does kvm sync registers between kernel and qemu env? I see there are kvm_arch_{get,put}_registers() functions in target-i386/kvm.c, but grep doesn't find a single call of them?

Right now, it doesn't. We should probably sync registers in the same places that kvm-userspace does (gdbstubs, vmport, etc.).

Quoted 6 lines
Quoted 3 lines

I tried to always sync registers on every exit but this causes boot to fail. The same is true of kvm-userspace though and I've been meaning to dig into why this is.

Maybe due to do with inconsistencies between the segment register contents and the descriptor tables? I know I've written code that relies on this feature.

Unlikely. xenner depends on that too, and also on kvm supporting it. start-of-day actually sets up the segment registers only, not any descriptor tables, then starts the guest in protected mode.

#6 lore raw
In reply to Anthony Liguori
Quoted 2 lines · Anthony Liguori

VT/SVM actually allow you to get at the descriptor tables/cache and we save/restore them in KVM. I only see this issue if I always save/restore registers so it leads me to think it's something more subtle.

Perhaps it's related to the segment hacking we do on vmx in real mode.

Signature · 1 line
error compiling committee.c: too many arguments to function