Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Functional 2 core linux guest
[palacios.releases.git] / palacios / src / devices / apic.c
index db68669..3064490 100644 (file)
@@ -118,6 +118,8 @@ typedef enum { APIC_TMR_INT, APIC_THERM_INT, APIC_PERF_INT,
 
 
 
+
+
 struct apic_msr {
     union {
        uint64_t value;
@@ -133,8 +135,6 @@ struct apic_msr {
 } __attribute__((packed));
 
 
-
-
 struct apic_state {
     addr_t base_addr;
 
@@ -188,6 +188,10 @@ struct apic_state {
     v3_lock_t  lock;
 };
 
+
+
+
+
 static int apic_read(struct guest_info * core, addr_t guest_addr, void * dst, uint_t length, void * priv_data);
 static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data);
 
@@ -888,7 +892,9 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u
            // ICC???
            PrintDebug("apic %u: core %u: sending cmd 0x%llx to apic %u\n",apic->lapic_id.val,core->cpu_id,
                       apic->int_cmd.val, apic->int_cmd.dst);
-           v3_icc_send_ipi(apic->icc_bus, apic->lapic_id.val, apic->int_cmd.val,0);
+           if (v3_icc_send_ipi(apic->icc_bus, apic->lapic_id.val, apic->int_cmd.val,apic->dst_fmt.val,0)==-1) { 
+               return -1;
+           }
            break;
        case INT_CMD_HI_OFFSET:
            apic->int_cmd.hi = op_val;
@@ -917,6 +923,8 @@ static int apic_intr_pending(struct guest_info * info, void * private_data) {
     int req_irq = get_highest_irr(apic);
     int svc_irq = get_highest_isr(apic);
 
+    //    PrintDebug("apic %u: core %u: req_irq=%d, svc_irq=%d\n",apic->lapic_id.val,info->cpu_id,req_irq,svc_irq);
+
     if ((req_irq >= 0) && 
        (req_irq > svc_irq)) {
        return 1;
@@ -956,8 +964,16 @@ static int apic_begin_irq(struct guest_info * info, void * private_data, int irq
     uchar_t * svc_location = apic->int_svc_reg + major_offset;
     uchar_t flag = 0x01 << minor_offset;
 
-    *svc_location |= flag;
-    *req_location &= ~flag;
+    if (*req_location & flag) {
+       // we will only pay attention to a begin irq if we
+       // know that we initiated it!
+       *svc_location |= flag;
+       *req_location &= ~flag;
+    } else {
+       // do nothing... 
+       PrintDebug("apic %u: core %u: begin irq for %d ignored since I don't own it\n",
+                  apic->lapic_id.val,info->cpu_id,irq);
+    }
 
 
 
@@ -1088,8 +1104,20 @@ static struct v3_device_ops dev_ops = {
 
 
 
+static int apic_should_deliver_flat(struct guest_info * core, uint8_t mda, void * private_data)
+{
+  struct apic_state * apic = (struct apic_state *)private_data;
+
+  if (mda==0xff || (apic->log_dst.dst_log_id & mda)) { 
+      return 1;
+  } else {
+      return 0;
+  }
+}
+
 static struct v3_icc_ops icc_ops = {
     .raise_intr = apic_raise_intr,
+    .should_deliver_flat = apic_should_deliver_flat,
 };