mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/irq: introduce APIC_VECTOR_VALID()
Add new macro APIC_VECTOR_VALID() to validate the interrupt vector
range as per [1]. This macro replaces hardcoded checks against the
open-coded value 16 in LAPIC and virtual LAPIC code and simplifies
the code a bit.
[1] Intel SDM volume 3A
Chapter "ADVANCED PROGRAMMABLE INTERRUPT CONTROLLER"
Section "Valid Interrupt Vectors"
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
14694975cd
commit
b7234d32e3
3 files changed
+8
-7
No files matched your search
@@ -135,8 +135,7 @@ static void intel_init_thermal(struct cpuinfo_x86 *c)
|
||||
* BIOS has programmed on AP based on BSP's info we saved (since BIOS
|
||||
* is required to set the same value for all threads/cores).
|
||||
*/
|
||||
if ( (val & APIC_DM_MASK) != APIC_DM_FIXED
|
||||
|| (val & APIC_VECTOR_MASK) > 0xf )
|
||||
if ( (val & APIC_DM_MASK) != APIC_DM_FIXED || APIC_VECTOR_VALID(val) )
|
||||
apic_write(APIC_LVTTHMR, val);
|
||||
|
||||
if ( (msr_content & (1ULL<<3))
|
||||
|
||||
@@ -123,7 +123,7 @@ static void vlapic_error(struct vlapic *vlapic, unsigned int err_bit)
|
||||
* will end up back here. Break the cycle by only injecting LVTERR
|
||||
* if it will succeed, and folding in RECVILL otherwise.
|
||||
*/
|
||||
if ( (lvterr & APIC_VECTOR_MASK) >= 16 )
|
||||
if ( APIC_VECTOR_VALID(lvterr) )
|
||||
inj = true;
|
||||
else
|
||||
set_bit(ilog2(APIC_ESR_RECVILL), &vlapic->hw.pending_esr);
|
||||
@@ -136,7 +136,7 @@ static void vlapic_error(struct vlapic *vlapic, unsigned int err_bit)
|
||||
|
||||
bool vlapic_test_irq(const struct vlapic *vlapic, uint8_t vec)
|
||||
{
|
||||
if ( unlikely(vec < 16) )
|
||||
if ( unlikely(!APIC_VECTOR_VALID(vec)) )
|
||||
return false;
|
||||
|
||||
if ( hvm_funcs.test_pir &&
|
||||
@@ -150,7 +150,7 @@ void vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig)
|
||||
{
|
||||
struct vcpu *target = vlapic_vcpu(vlapic);
|
||||
|
||||
if ( unlikely(vec < 16) )
|
||||
if ( unlikely(!APIC_VECTOR_VALID(vec)) )
|
||||
{
|
||||
vlapic_error(vlapic, ilog2(APIC_ESR_RECVILL));
|
||||
return;
|
||||
@@ -523,7 +523,7 @@ void vlapic_ipi(
|
||||
struct vlapic *target = vlapic_lowest_prio(
|
||||
vlapic_domain(vlapic), vlapic, short_hand, dest, dest_mode);
|
||||
|
||||
if ( unlikely((icr_low & APIC_VECTOR_MASK) < 16) )
|
||||
if ( unlikely(!APIC_VECTOR_VALID(icr_low)) )
|
||||
vlapic_error(vlapic, ilog2(APIC_ESR_SENDILL));
|
||||
else if ( target )
|
||||
vlapic_accept_irq(vlapic_vcpu(target), icr_low);
|
||||
@@ -531,7 +531,7 @@ void vlapic_ipi(
|
||||
}
|
||||
|
||||
case APIC_DM_FIXED:
|
||||
if ( unlikely((icr_low & APIC_VECTOR_MASK) < 16) )
|
||||
if ( unlikely(!APIC_VECTOR_VALID(icr_low)) )
|
||||
{
|
||||
vlapic_error(vlapic, ilog2(APIC_ESR_SENDILL));
|
||||
break;
|
||||
|
||||
@@ -78,6 +78,8 @@
|
||||
#define APIC_DM_STARTUP 0x00600
|
||||
#define APIC_DM_EXTINT 0x00700
|
||||
#define APIC_VECTOR_MASK 0x000FF
|
||||
#define APIC_VECTOR_VALID(x) \
|
||||
(((x) & APIC_VECTOR_MASK) >= 16)
|
||||
#define APIC_ICR2 0x310
|
||||
#define GET_xAPIC_DEST_FIELD(x) (((x)>>24)&0xFF)
|
||||
#define SET_xAPIC_DEST_FIELD(x) ((x)<<24)
|
||||
|
||||