* KVM's PIT and PIC programming question
@ 2009-08-19 21:26 Saksena, Abhishek
2009-08-20 8:28 ` Avi Kivity
0 siblings, 1 reply; 8+ messages in thread
From: Saksena, Abhishek @ 2009-08-19 21:26 UTC (permalink / raw)
To: kvm@vger.kernel.org
Hi Guys,
I am writing very simple bios for KVM (not using Qemu but creating a simple io device models around KVM). I am having trouble in receiving regular Timer interrupts after programming PIT.
I think I have enabled PIC and PIT correctly using following code:-
PIC Programming
;; PIC
mov al, #0x00
out 0x21, AL ;master pic: all IRQs unmasked
out 0xA1, AL ;slave pic: all IRQs unmasked
PIT Programming
and also enable PIT to genrate regular timer interruput
SET_INT_VECTOR(0x08, #0xF000, #int08_handler)
mov al, #0x34 ; timer0: binary count, 16bit count, mode 2
out 0x43, al
mov al, #0x00 ; maximum count of 0000H = 18.2Hz
out 0x40, al
out 0x40, al
PIT Timer ISR code
Timer ISR code
;---------
;- INT08 -
;---------
.org 0xfea5 ; INT 08h System Timer ISR Entry Point
int08_handler:
sti
push ax
push ds
mov ax, #0x0040
mov ds, ax
mov ax, 0x006c ; increment lower word
inc ax
mov 0x006c, ax
jnz inc_done
mov ax, 0x006e ; increment upper word
inc ax
mov 0x006e, ax
For some reason I never see int08_handler ever been called. Any clues what may be wrong? I am creating only one VCPU
-Abhishek
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: KVM's PIT and PIC programming question
2009-08-19 21:26 KVM's PIT and PIC programming question Saksena, Abhishek
@ 2009-08-20 8:28 ` Avi Kivity
2009-08-20 15:05 ` Saksena, Abhishek
0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-08-20 8:28 UTC (permalink / raw)
To: Saksena, Abhishek; +Cc: kvm@vger.kernel.org
On 08/20/2009 12:26 AM, Saksena, Abhishek wrote:
> Hi Guys,
> I am writing very simple bios for KVM (not using Qemu but creating a simple io device models around KVM). I am having trouble in receiving regular Timer interrupts after programming PIT.
>
> I think I have enabled PIC and PIT correctly using following code:-
>
> PIC Programming
> ;; PIC
> mov al, #0x00
> out 0x21, AL ;master pic: all IRQs unmasked
> out 0xA1, AL ;slave pic: all IRQs unmasked
>
>
> PIT Programming
>
> and also enable PIT to genrate regular timer interruput
>
> SET_INT_VECTOR(0x08, #0xF000, #int08_handler)
> mov al, #0x34 ; timer0: binary count, 16bit count, mode 2
> out 0x43, al
> mov al, #0x00 ; maximum count of 0000H = 18.2Hz
> out 0x40, al
> out 0x40, al
>
>
> PIT Timer ISR code
>
> Timer ISR code
>
> ;---------
> ;- INT08 -
> ;---------
> .org 0xfea5 ; INT 08h System Timer ISR Entry Point
> int08_handler:
> sti
> push ax
> push ds
> mov ax, #0x0040
> mov ds, ax
> mov ax, 0x006c ; increment lower word
> inc ax
> mov 0x006c, ax
> jnz inc_done
> mov ax, 0x006e ; increment upper word
> inc ax
> mov 0x006e, ax
>
>
>
> For some reason I never see int08_handler ever been called. Any clues what may be wrong? I am creating only one VCPU
>
>
>
Things to check:
- have you initialized the kernel PIC and PIT?
- are interrupts enabled?
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: KVM's PIT and PIC programming question
2009-08-20 8:28 ` Avi Kivity
@ 2009-08-20 15:05 ` Saksena, Abhishek
2009-08-20 15:20 ` Avi Kivity
0 siblings, 1 reply; 8+ messages in thread
From: Saksena, Abhishek @ 2009-08-20 15:05 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm@vger.kernel.org
Isn't by default PIT and PIC are initialized in Kernel? Is something more needed on top of it?
I have enable PIC interuupt using following code :-
> PIC Programming
> ;; PIC
> mov al, #0x00
> out 0x21, AL ;master pic: all IRQs unmasked
> out 0xA1, AL ;slave pic: all IRQs unmasked
Also, I wonder if LAPIC need to be configured and initialized properly. I don't want to use LAPIC, can it be disabled in KVM. I am just using one VCPU.
-Thanks
Abhishek
-----Original Message-----
From: Avi Kivity [mailto:avi@redhat.com]
Sent: Thursday, August 20, 2009 1:29 AM
To: Saksena, Abhishek
Cc: kvm@vger.kernel.org
Subject: Re: KVM's PIT and PIC programming question
On 08/20/2009 12:26 AM, Saksena, Abhishek wrote:
> Hi Guys,
> I am writing very simple bios for KVM (not using Qemu but creating a simple io device models around KVM). I am having trouble in receiving regular Timer interrupts after programming PIT.
>
> I think I have enabled PIC and PIT correctly using following code:-
>
> PIC Programming
> ;; PIC
> mov al, #0x00
> out 0x21, AL ;master pic: all IRQs unmasked
> out 0xA1, AL ;slave pic: all IRQs unmasked
>
>
> PIT Programming
>
> and also enable PIT to genrate regular timer interruput
>
> SET_INT_VECTOR(0x08, #0xF000, #int08_handler)
> mov al, #0x34 ; timer0: binary count, 16bit count, mode 2
> out 0x43, al
> mov al, #0x00 ; maximum count of 0000H = 18.2Hz
> out 0x40, al
> out 0x40, al
>
>
> PIT Timer ISR code
>
> Timer ISR code
>
> ;---------
> ;- INT08 -
> ;---------
> .org 0xfea5 ; INT 08h System Timer ISR Entry Point
> int08_handler:
> sti
> push ax
> push ds
> mov ax, #0x0040
> mov ds, ax
> mov ax, 0x006c ; increment lower word
> inc ax
> mov 0x006c, ax
> jnz inc_done
> mov ax, 0x006e ; increment upper word
> inc ax
> mov 0x006e, ax
>
>
>
> For some reason I never see int08_handler ever been called. Any clues what may be wrong? I am creating only one VCPU
>
>
>
Things to check:
- have you initialized the kernel PIC and PIT?
- are interrupts enabled?
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: KVM's PIT and PIC programming question
2009-08-20 15:05 ` Saksena, Abhishek
@ 2009-08-20 15:20 ` Avi Kivity
2009-08-20 16:49 ` Saksena, Abhishek
0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-08-20 15:20 UTC (permalink / raw)
To: Saksena, Abhishek; +Cc: kvm@vger.kernel.org
On 08/20/2009 06:05 PM, Saksena, Abhishek wrote:
> Isn't by default PIT and PIC are initialized in Kernel? Is something more needed on top of it?
>
>
You need KVM_CREATE_IRQCHIP and KVM_CREATE_PIT.
> Also, I wonder if LAPIC need to be configured and initialized properly. I don't want to use LAPIC, can it be disabled in KVM. I am just using one VCPU.
>
The lapic is disabled by default.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: KVM's PIT and PIC programming question
2009-08-20 15:20 ` Avi Kivity
@ 2009-08-20 16:49 ` Saksena, Abhishek
2009-08-20 17:26 ` Avi Kivity
0 siblings, 1 reply; 8+ messages in thread
From: Saksena, Abhishek @ 2009-08-20 16:49 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm@vger.kernel.org
I am using libkvm and believe it creates PIC and PIT by default.
I see kvm_create make calls to:-
1. kvm_arch_create function which indeed calls kvm_create_pit and KVM_CREATE_PIT
2. kvm_create_irqchip function and KVM_CREATE_IRQCHIP
Is this understanding wrong?
-Thanks
Abhishek
-----Original Message-----
From: Avi Kivity [mailto:avi@redhat.com]
Sent: Thursday, August 20, 2009 8:21 AM
To: Saksena, Abhishek
Cc: kvm@vger.kernel.org
Subject: Re: KVM's PIT and PIC programming question
On 08/20/2009 06:05 PM, Saksena, Abhishek wrote:
> Isn't by default PIT and PIC are initialized in Kernel? Is something more needed on top of it?
>
>
You need KVM_CREATE_IRQCHIP and KVM_CREATE_PIT.
> Also, I wonder if LAPIC need to be configured and initialized properly. I don't want to use LAPIC, can it be disabled in KVM. I am just using one VCPU.
>
The lapic is disabled by default.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: KVM's PIT and PIC programming question
2009-08-20 16:49 ` Saksena, Abhishek
@ 2009-08-20 17:26 ` Avi Kivity
2009-08-20 17:36 ` Saksena, Abhishek
0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-08-20 17:26 UTC (permalink / raw)
To: Saksena, Abhishek; +Cc: kvm@vger.kernel.org
On 08/20/2009 07:49 PM, Saksena, Abhishek wrote:
> I am using libkvm and believe it creates PIC and PIT by default.
>
> I see kvm_create make calls to:-
>
> 1. kvm_arch_create function which indeed calls kvm_create_pit and KVM_CREATE_PIT
>
> 2. kvm_create_irqchip function and KVM_CREATE_IRQCHIP
>
It should work, but best to check using strace or adding printfs.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: KVM's PIT and PIC programming question
2009-08-20 17:26 ` Avi Kivity
@ 2009-08-20 17:36 ` Saksena, Abhishek
2009-08-20 17:41 ` Avi Kivity
0 siblings, 1 reply; 8+ messages in thread
From: Saksena, Abhishek @ 2009-08-20 17:36 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm@vger.kernel.org
Thnaks,
So just programming of PIC (8259) should do the trick. Do I have to care about IOAPIC or LAPIC programming? You mentioned lapic is disabled by default, what about IOAPIC.
I see in x86.c
case KVM_CREATE_IRQCHIP:
r = -ENOMEM;
kvm->arch.vpic = kvm_create_pic(kvm);
if (kvm->arch.vpic) {
r = kvm_ioapic_init(kvm);
if (r) {
kfree(kvm->arch.vpic);
kvm->arch.vpic = NULL;
goto out;
}
} else
goto out;
break;
so ioapic is created.
I have enabled all the interrupts in 8259s correctly
PIC Programming of master and slave 8259s
;; PIC
mov al, #0x00
out 0x21, AL ;master pic: all IRQs unmasked
out 0xA1, AL ;slave pic: all IRQs unmasked
PIT Programming
SET_INT_VECTOR(0x08, #0xF000, #int08_handler)
mov al, #0x34 ; timer0: binary count, 16bit count, mode 2
out 0x43, al
mov al, #0x00 ; maximum count of 0000H = 18.2Hz
out 0x40, al
out 0x40, al
But still not see PIT interrupts or Timer ISR being called!
-thanks
Abhishek
-----Original Message-----
From: Avi Kivity [mailto:avi@redhat.com]
Sent: Thursday, August 20, 2009 10:26 AM
To: Saksena, Abhishek
Cc: kvm@vger.kernel.org
Subject: Re: KVM's PIT and PIC programming question
On 08/20/2009 07:49 PM, Saksena, Abhishek wrote:
> I am using libkvm and believe it creates PIC and PIT by default.
>
> I see kvm_create make calls to:-
>
> 1. kvm_arch_create function which indeed calls kvm_create_pit and KVM_CREATE_PIT
>
> 2. kvm_create_irqchip function and KVM_CREATE_IRQCHIP
>
It should work, but best to check using strace or adding printfs.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: KVM's PIT and PIC programming question
2009-08-20 17:36 ` Saksena, Abhishek
@ 2009-08-20 17:41 ` Avi Kivity
0 siblings, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2009-08-20 17:41 UTC (permalink / raw)
To: Saksena, Abhishek; +Cc: kvm@vger.kernel.org
On 08/20/2009 08:36 PM, Saksena, Abhishek wrote:
> Thnaks,
>
> So just programming of PIC (8259) should do the trick. Do I have to care about IOAPIC or LAPIC programming? You mentioned lapic is disabled by default, what about IOAPIC.
>
>
The ioapic will not have any vectors programmed so it will do nothing.
> I see in x86.c
>
> case KVM_CREATE_IRQCHIP:
> r = -ENOMEM;
> kvm->arch.vpic = kvm_create_pic(kvm);
> if (kvm->arch.vpic) {
> r = kvm_ioapic_init(kvm);
> if (r) {
> kfree(kvm->arch.vpic);
> kvm->arch.vpic = NULL;
> goto out;
> }
> } else
> goto out;
> break;
>
>
> so ioapic is created.
>
>
>
> I have enabled all the interrupts in 8259s correctly
>
>
> PIC Programming of master and slave 8259s
> ;; PIC
> mov al, #0x00
> out 0x21, AL ;master pic: all IRQs unmasked
> out 0xA1, AL ;slave pic: all IRQs unmasked
>
>
> PIT Programming
>
> SET_INT_VECTOR(0x08, #0xF000, #int08_handler)
> mov al, #0x34 ; timer0: binary count, 16bit count, mode 2
> out 0x43, al
> mov al, #0x00 ; maximum count of 0000H = 18.2Hz
> out 0x40, al
> out 0x40, al
>
> But still not see PIT interrupts or Timer ISR being called!
>
>
I suggest adding printk()s (or trace_printk()s) in stragtegic places to
see what's going on. It can be either a guest programming error or host
bug.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-08-20 17:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-19 21:26 KVM's PIT and PIC programming question Saksena, Abhishek
2009-08-20 8:28 ` Avi Kivity
2009-08-20 15:05 ` Saksena, Abhishek
2009-08-20 15:20 ` Avi Kivity
2009-08-20 16:49 ` Saksena, Abhishek
2009-08-20 17:26 ` Avi Kivity
2009-08-20 17:36 ` Saksena, Abhishek
2009-08-20 17:41 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).