X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fapic.c;h=9e636b619d91846553f411cdd1a6548aabfe903a;hb=bd229a86fee7c3cc33a81986ac46186ad67c869e;hp=44ca08d6736207063cf8cad165c3527212dee50e;hpb=3938dc8f325981eab29bda77f43fa1be1d91c54f;p=palacios.releases.git diff --git a/palacios/src/devices/apic.c b/palacios/src/devices/apic.c index 44ca08d..9e636b6 100644 --- a/palacios/src/devices/apic.c +++ b/palacios/src/devices/apic.c @@ -505,7 +505,7 @@ static void drain_irq_entries(struct apic_state * apic) { static int get_highest_isr(struct apic_state * apic) { int i = 0, j = 0; - // We iterate backwards to find the highest priority + // We iterate backwards to find the highest priority in-service request for (i = 31; i >= 0; i--) { uint8_t * svc_major = apic->int_svc_reg + i; @@ -527,14 +527,15 @@ static int get_highest_isr(struct apic_state * apic) { static int get_highest_irr(struct apic_state * apic) { int i = 0, j = 0; - // We iterate backwards to find the highest priority + // We iterate backwards to find the highest priority enabled requested interrupt for (i = 31; i >= 0; i--) { uint8_t * req_major = apic->int_req_reg + i; - + uint8_t * en_major = apic->int_en_reg + i; + if ((*req_major) & 0xff) { for (j = 7; j >= 0; j--) { uint8_t flag = 0x1 << j; - if ((*req_major) & flag) { + if ((*req_major & *en_major) & flag) { return ((i * 8) + j); } } @@ -1877,6 +1878,12 @@ static int apic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { apic_dev = (struct apic_dev_state *)V3_Malloc(sizeof(struct apic_dev_state) + sizeof(struct apic_state) * vm->num_cores); + + if (!apic_dev) { + PrintError("Failed to allocate space for APIC\n"); + return -1; + } + apic_dev->num_apics = vm->num_cores; v3_lock_init(&(apic_dev->state_lock));