x86: Fix PIT2 init
PATCH 1/1 x86: Fix PIT2 init
KVM docs[1] for KVM_CREATE_PIT2 say:
This call is only valid after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP.
This was not enforced technically, until kernel commit 9e05d9b06757 ("KVM: x86: Check irqchip mode before create PIT"). Now I get -ENOENT.
To fix it I've just reordered the ioctls. Doing this fixes the -ENOENT when running a nested VM on VMX.
[1] https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt
To: Will Deacon <[email protected]>
To: Julien Thierry <[email protected]>
To: [email protected]
--- x86/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
x86/kvm.c +4 -4
@@ -150,6 +150,10 @@ void kvm__arch_init(struct kvm *kvm)if (ret <0 )die_perror ("KVM_SET_TSS_ADDR ioctl" ); + ret =ioctl (kvm->vm_fd,KVM_CREATE_IRQCHIP ); +if (ret <0 ) +die_perror ("KVM_CREATE_IRQCHIP ioctl" ); + ret =ioctl (kvm->vm_fd,KVM_CREATE_PIT2 , &pit_config);if (ret <0 )die_perror ("KVM_CREATE_PIT2 ioctl" );
@@ -171,10 +175,6 @@ void kvm__arch_init(struct kvm *kvm)die ("out of memory" );madvise (kvm->ram_start, kvm->ram_size,MADV_MERGEABLE ); - - ret =ioctl (kvm->vm_fd,KVM_CREATE_IRQCHIP ); -if (ret <0 ) -die_perror ("KVM_CREATE_IRQCHIP ioctl" ); }void kvm__arch_delete_ram (struct kvm *kvm)
Signature · 1 line
2.44.0.683.g7961c838ac-goog
Hi Brendan,
Quoted 13 lines · Brendan Jackman
KVM docs[1] for
KVM_CREATE_PIT2say:This call is only valid after enabling in-kernel irqchip support via
KVM_CREATE_IRQCHIP.This was not enforced technically, until kernel commit
9e05d9b06757("KVM: x86: Check irqchip mode before create PIT"). Now I get-ENOENT.To fix it I've just reordered the ioctls. Doing this fixes the
-ENOENTwhen running a nested VM on VMX.[1] https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt
Quoted 7 lines
Signed-off-by Brendan Jackman <[email protected]>To: Will Deacon <[email protected]>
To: Julien Thierry <[email protected]>
To: [email protected]--- x86/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Thanks for the patch, but I think we already fixed this in e73a6b29f1eb ("x86: Enable in-kernel irqchip before creating PIT"). Please can you check the latest kvmtool works for you?
Cheers,
Will
Quoted 3 lines · Will Deacon
Thanks for the patch, but I think we already fixed this in
e73a6b29f1eb("x86: Enable in-kernel irqchip before creating PIT"). Please can you check the latest kvmtool works for you?
Oh right, I had pulled from a bogus remote so my repo was stale. Second time I've made this mistake this year...
Anyway yep, this looks good to me. Sorry for the noise!
Brendan