[PATCH kvmtool] x86: Fix PIT2 init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Brendan Jackman <jackmanb@xxxxxxxxxx>
To: Will Deacon <will@xxxxxxxxxx>
To: Julien Thierry <julien.thierry.kdev@xxxxxxxxx>
To: kvm@xxxxxxxxxxxxxxx
---
 x86/kvm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/x86/kvm.c b/x86/kvm.c
index 328fa75..09127c2 100644
--- a/x86/kvm.c
+++ b/x86/kvm.c
@@ -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)
-- 
2.44.0.683.g7961c838ac-goog





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux