zephyr/include/drivers/sysapic.h

64 lines
1.4 KiB
C
Raw Normal View History

/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DRIVERS_SYSAPIC_H_
#define ZEPHYR_INCLUDE_DRIVERS_SYSAPIC_H_
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
#include <drivers/loapic.h>
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
#define _IRQ_TRIGGER_EDGE IOAPIC_EDGE
#define _IRQ_TRIGGER_LEVEL IOAPIC_LEVEL
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
#define _IRQ_POLARITY_HIGH IOAPIC_HIGH
#define _IRQ_POLARITY_LOW IOAPIC_LOW
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
#define LOAPIC_IRQ_BASE CONFIG_IOAPIC_NUM_RTES
#define LOAPIC_IRQ_COUNT 6 /* Default to LOAPIC_TIMER to LOAPIC_ERROR */
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
/* irq_controller.h interface */
void __irq_controller_irq_config(unsigned int vector, unsigned int irq,
u32_t flags);
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
int __irq_controller_isr_vector_get(void);
jailhouse: add support for x2APIC mode for all LOAPIC accesses Besides the fact that we did not have that for the current supported boards, that makes sense for this new, virtualized mode, that is meant to be run on top of full-fledged x86 64 CPUs. By having xAPIC mode access only, Jailhouse has to intercept those MMIO reads and writes, in order to examine what they do and arbitrate if it's safe or not (e.g. not all values are accepted to ICR register). This means that we can't run away from having a VM-exit event for each and every access to APIC memory region and this impacts the latency the guest OS observes over bare metal a lot. When in x2APIC mode, Jailhouse does not require VM-exits for MSR accesses other that writes to the ICR register, so the latency the guest observes is reduced to almost zero. Here are some outputs of the the command line $ sudo ./tools/jailhouse cell stats tiny-demo on a Jailhouse's root cell console, for one of the Zephyr demos using LOAPIC timers, left for a couple of seconds: Statistics for tiny-demo cell (x2APIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 7 0 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, xAPIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_xapic 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_msr 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 See that under x2APIC mode on both Jailhouse/root-cell and guest, the interruptions from the hypervisor are minimal. That is not the case when Jailhouse is on xAPIC mode, though. Note also that, as a plus, x2APIC accesses on the guest will map to xAPIC MMIO on the hypervisor just fine. Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-10-12 05:17:12 +08:00
#ifdef CONFIG_JAILHOUSE_X2APIC
void z_jailhouse_eoi(void);
jailhouse: add support for x2APIC mode for all LOAPIC accesses Besides the fact that we did not have that for the current supported boards, that makes sense for this new, virtualized mode, that is meant to be run on top of full-fledged x86 64 CPUs. By having xAPIC mode access only, Jailhouse has to intercept those MMIO reads and writes, in order to examine what they do and arbitrate if it's safe or not (e.g. not all values are accepted to ICR register). This means that we can't run away from having a VM-exit event for each and every access to APIC memory region and this impacts the latency the guest OS observes over bare metal a lot. When in x2APIC mode, Jailhouse does not require VM-exits for MSR accesses other that writes to the ICR register, so the latency the guest observes is reduced to almost zero. Here are some outputs of the the command line $ sudo ./tools/jailhouse cell stats tiny-demo on a Jailhouse's root cell console, for one of the Zephyr demos using LOAPIC timers, left for a couple of seconds: Statistics for tiny-demo cell (x2APIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 7 0 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, xAPIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_xapic 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_msr 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 See that under x2APIC mode on both Jailhouse/root-cell and guest, the interruptions from the hypervisor are minimal. That is not the case when Jailhouse is on xAPIC mode, though. Note also that, as a plus, x2APIC accesses on the guest will map to xAPIC MMIO on the hypervisor just fine. Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-10-12 05:17:12 +08:00
#endif
static inline void __irq_controller_eoi(void)
{
#if CONFIG_EOI_FORWARDING_BUG
z_lakemont_eoi();
#else
*(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_EOI) = 0;
#endif
}
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
#else /* _ASMLANGUAGE */
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
#if CONFIG_EOI_FORWARDING_BUG
.macro __irq_controller_eoi_macro
call z_lakemont_eoi
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
.endm
#else
.macro __irq_controller_eoi_macro
jailhouse: add support for x2APIC mode for all LOAPIC accesses Besides the fact that we did not have that for the current supported boards, that makes sense for this new, virtualized mode, that is meant to be run on top of full-fledged x86 64 CPUs. By having xAPIC mode access only, Jailhouse has to intercept those MMIO reads and writes, in order to examine what they do and arbitrate if it's safe or not (e.g. not all values are accepted to ICR register). This means that we can't run away from having a VM-exit event for each and every access to APIC memory region and this impacts the latency the guest OS observes over bare metal a lot. When in x2APIC mode, Jailhouse does not require VM-exits for MSR accesses other that writes to the ICR register, so the latency the guest observes is reduced to almost zero. Here are some outputs of the the command line $ sudo ./tools/jailhouse cell stats tiny-demo on a Jailhouse's root cell console, for one of the Zephyr demos using LOAPIC timers, left for a couple of seconds: Statistics for tiny-demo cell (x2APIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 7 0 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, xAPIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_xapic 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_msr 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 See that under x2APIC mode on both Jailhouse/root-cell and guest, the interruptions from the hypervisor are minimal. That is not the case when Jailhouse is on xAPIC mode, though. Note also that, as a plus, x2APIC accesses on the guest will map to xAPIC MMIO on the hypervisor just fine. Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-10-12 05:17:12 +08:00
#ifdef CONFIG_JAILHOUSE_X2APIC
call z_jailhouse_eoi
jailhouse: add support for x2APIC mode for all LOAPIC accesses Besides the fact that we did not have that for the current supported boards, that makes sense for this new, virtualized mode, that is meant to be run on top of full-fledged x86 64 CPUs. By having xAPIC mode access only, Jailhouse has to intercept those MMIO reads and writes, in order to examine what they do and arbitrate if it's safe or not (e.g. not all values are accepted to ICR register). This means that we can't run away from having a VM-exit event for each and every access to APIC memory region and this impacts the latency the guest OS observes over bare metal a lot. When in x2APIC mode, Jailhouse does not require VM-exits for MSR accesses other that writes to the ICR register, so the latency the guest observes is reduced to almost zero. Here are some outputs of the the command line $ sudo ./tools/jailhouse cell stats tiny-demo on a Jailhouse's root cell console, for one of the Zephyr demos using LOAPIC timers, left for a couple of seconds: Statistics for tiny-demo cell (x2APIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 7 0 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, xAPIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_xapic 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_msr 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 See that under x2APIC mode on both Jailhouse/root-cell and guest, the interruptions from the hypervisor are minimal. That is not the case when Jailhouse is on xAPIC mode, though. Note also that, as a plus, x2APIC accesses on the guest will map to xAPIC MMIO on the hypervisor just fine. Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-10-12 05:17:12 +08:00
#else
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
xorl %eax, %eax /* zeroes eax */
loapic_eoi_reg = (CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_EOI)
movl %eax, loapic_eoi_reg /* tell LOAPIC the IRQ is handled */
jailhouse: add support for x2APIC mode for all LOAPIC accesses Besides the fact that we did not have that for the current supported boards, that makes sense for this new, virtualized mode, that is meant to be run on top of full-fledged x86 64 CPUs. By having xAPIC mode access only, Jailhouse has to intercept those MMIO reads and writes, in order to examine what they do and arbitrate if it's safe or not (e.g. not all values are accepted to ICR register). This means that we can't run away from having a VM-exit event for each and every access to APIC memory region and this impacts the latency the guest OS observes over bare metal a lot. When in x2APIC mode, Jailhouse does not require VM-exits for MSR accesses other that writes to the ICR register, so the latency the guest observes is reduced to almost zero. Here are some outputs of the the command line $ sudo ./tools/jailhouse cell stats tiny-demo on a Jailhouse's root cell console, for one of the Zephyr demos using LOAPIC timers, left for a couple of seconds: Statistics for tiny-demo cell (x2APIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 7 0 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, xAPIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_xapic 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_msr 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xsetbv 0 0 Statistics for tiny-demo cell (xAPIC root, x2APIC inmate) COUNTER SUM PER SEC vmexits_total 4087 40 vmexits_msr 4080 40 vmexits_management 3 0 vmexits_cr 2 0 vmexits_cpuid 1 0 vmexits_exception 0 0 vmexits_hypercall 0 0 vmexits_mmio 0 0 vmexits_pio 0 0 vmexits_xapic 0 0 vmexits_xsetbv 0 0 See that under x2APIC mode on both Jailhouse/root-cell and guest, the interruptions from the hypervisor are minimal. That is not the case when Jailhouse is on xAPIC mode, though. Note also that, as a plus, x2APIC accesses on the guest will map to xAPIC MMIO on the hypervisor just fine. Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-10-12 05:17:12 +08:00
#endif
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
.endm
#endif /* CONFIG_EOI_FORWARDING_BUG */
x86: declare internal API for interrupt controllers Originally, x86 just supported APIC. Then later support for the Mint Valley Interrupt Controller was added. This controller is mostly similar to the APIC with some differences, but was integrated in a somewhat hacked-up fashion. Now we define irq_controller.h, which is a layer of abstraction between the core arch code and the interrupt controller implementation. Contents of the API: - Controllers with a fixed irq-to-vector mapping define _IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time map between the two. - _irq_controller_program() notifies the interrupt controller what vector will be used for a particular IRQ along with triggering flags - _irq_controller_isr_vector_get() reports the vector number of the IRQ currently being serviced - In assembly language domain, _irq_controller_eoi implements EOI handling. - Since triggering options can vary, some common defines for triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH, IRQ_POLARITY_LOW introduced. Specific changes made: - New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers that have a fixed relationship between IRQ lines and IDT vectors. - MVIC driver rewritten per the HAS instead of the tortuous methods used to get it to behave like LOAPIC. We are no longer writing values to reserved registers. Additional assertions added. - Some cleanup in the loapic_timer driver to make the MVIC differences clearer. - Unused APIs removed, or folded into calling code when used just once. - MVIC doesn't bother to write a -1 to the intList priority field since it gets ignored anyway Issue: ZEP-48 Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-03 03:05:08 +08:00
#endif /* _ASMLANGUAGE */
#endif /* ZEPHYR_INCLUDE_DRIVERS_SYSAPIC_H_ */