Ticket #12606: idle_pcs.diff

File idle_pcs.diff, 17.8 KB (added by jstrine@…, 17 years ago)

Patch from http://dynagui.sourceforge.net for idle_pcs variant

  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/cpu.h dynamips-0.2.7-YLT/cpu.h
    old new  
    9090   void (*mmu_raw_dump)(cpu_gen_t *cpu);
    9191   void (*add_breakpoint)(cpu_gen_t *cpu,m_uint64_t addr);
    9292   void (*remove_breakpoint)(cpu_gen_t *cpu,m_uint64_t addr);
    93    void (*set_idle_pc)(cpu_gen_t *cpu,m_uint64_t addr);
     93   void (*set_idle_pc)(cpu_gen_t *cpu,char* addr);
    9494   void (*get_idling_pc)(cpu_gen_t *cpu);   
    9595   void (*mts_rebuild)(cpu_gen_t *cpu);
    9696   void (*mts_show_stats)(cpu_gen_t *cpu);
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/dev_c2600.c dynamips-0.2.7-YLT/dev_c2600.c
    old new  
    13601360
    13611361   /* Copy some parameters from VM to CPU (idle PC, ...) */
    13621362   cpu->idle_pc = vm->idle_pc;
     1363   cpu->num_idle_pc = vm->num_idle_pc;
    13631364
    13641365   if (vm->timer_irq_check_itv)
    13651366      cpu->timer_irq_check_itv = vm->timer_irq_check_itv;
     
    15031504          vm->name,cpu->ia,vm->jit_use ? "en":"dis");
    15041505
    15051506   vm_log(vm,"C2600_BOOT",
    1506           "starting instance (CPU0 PC=0x%8.8x,idle_pc=0x%8.8x,JIT %s)\n",
    1507           cpu->ia,cpu->idle_pc,vm->jit_use ? "on":"off");
     1507          "starting instance (CPU0 PC=0x%8.8x,JIT %s)\n",
     1508          cpu->ia,vm->jit_use ? "on":"off");
    15081509
    15091510   /* Start main CPU */
    15101511   if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/dev_c2691.c dynamips-0.2.7-YLT/dev_c2691.c
    old new  
    11531153
    11541154   /* Copy some parameters from VM to CPU (idle PC, ...) */
    11551155   cpu->idle_pc = vm->idle_pc;
     1156   cpu->num_idle_pc = vm->num_idle_pc;
    11561157
    11571158   if (vm->timer_irq_check_itv)
    11581159      cpu->timer_irq_check_itv = vm->timer_irq_check_itv;
     
    12631264          vm->name,cpu->pc,vm->jit_use ? "en":"dis");
    12641265
    12651266   vm_log(vm,"C2691_BOOT",
    1266           "starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n",
    1267           cpu->pc,cpu->idle_pc,vm->jit_use ? "on":"off");
     1267          "starting instance (CPU0 PC=0x%llx,JIT %s)\n",
     1268          cpu->pc,vm->jit_use ? "on":"off");
    12681269
    12691270   /* Start main CPU */
    12701271   if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/dev_c3600.c dynamips-0.2.7-YLT/dev_c3600.c
    old new  
    13231323
    13241324   /* Copy some parameters from VM to CPU (idle PC, ...) */
    13251325   cpu->idle_pc = vm->idle_pc;
     1326   cpu->num_idle_pc = vm->num_idle_pc;
    13261327
    13271328   if (vm->timer_irq_check_itv)
    13281329      cpu->timer_irq_check_itv = vm->timer_irq_check_itv;
     
    14401441          vm->name,cpu->pc,vm->jit_use ? "en":"dis");
    14411442
    14421443   vm_log(vm,"C3600_BOOT",
    1443           "starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n",
    1444           cpu->pc,cpu->idle_pc,vm->jit_use ? "on":"off");
     1444          "starting instance (CPU0 PC=0x%llx,JIT %s)\n",
     1445          cpu->pc,vm->jit_use ? "on":"off");
    14451446
    14461447   /* Start main CPU */
    14471448   if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/dev_c3725.c dynamips-0.2.7-YLT/dev_c3725.c
    old new  
    11671167
    11681168   /* Copy some parameters from VM to CPU (idle PC, ...) */
    11691169   cpu->idle_pc = vm->idle_pc;
     1170   cpu->num_idle_pc = vm->num_idle_pc;
    11701171
    11711172   if (vm->timer_irq_check_itv)
    11721173      cpu->timer_irq_check_itv = vm->timer_irq_check_itv;
     
    12771278          vm->name,cpu->pc,vm->jit_use ? "en":"dis");
    12781279
    12791280   vm_log(vm,"C3725_BOOT",
    1280           "starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n",
    1281           cpu->pc,cpu->idle_pc,vm->jit_use ? "on":"off");
     1281          "starting instance (CPU0 PC=0x%llx,JIT %s)\n",
     1282          cpu->pc,vm->jit_use ? "on":"off");
    12821283
    12831284   /* Start main CPU */
    12841285   if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/dev_c3745.c dynamips-0.2.7-YLT/dev_c3745.c
    old new  
    12071207
    12081208   /* Copy some parameters from VM to CPU (idle PC, ...) */
    12091209   cpu->idle_pc = vm->idle_pc;
     1210   cpu->num_idle_pc = vm->num_idle_pc;
    12101211
    12111212   if (vm->timer_irq_check_itv)
    12121213      cpu->timer_irq_check_itv = vm->timer_irq_check_itv;
     
    13171318          vm->name,cpu->pc,vm->jit_use ? "en":"dis");
    13181319
    13191320   vm_log(vm,"C3745_BOOT",
    1320           "starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n",
    1321           cpu->pc,cpu->idle_pc,vm->jit_use ? "on":"off");
     1321          "starting instance (CPU0 PC=0x%llx,JIT %s)\n",
     1322          cpu->pc,vm->jit_use ? "on":"off");
    13221323
    13231324   /* Start main CPU */
    13241325   if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/dev_c7200.c dynamips-0.2.7-YLT/dev_c7200.c
    old new  
    20722072
    20732073   /* Copy some parameters from VM to CPU0 (idle PC, ...) */
    20742074   cpu0->idle_pc = vm->idle_pc;
     2075   cpu0->num_idle_pc = vm->num_idle_pc;
    20752076
    20762077   if (vm->timer_irq_check_itv)
    20772078      cpu0->timer_irq_check_itv = vm->timer_irq_check_itv;
     
    21932194
    21942195   /* Copy some parameters from VM to CPU0 (idle PC, ...) */
    21952196   cpu0->idle_pc = vm->idle_pc;
     2197   cpu0->num_idle_pc = vm->num_idle_pc;
    21962198
    21972199   if (vm->timer_irq_check_itv)
    21982200      cpu0->timer_irq_check_itv = vm->timer_irq_check_itv;
     
    23142316          vm->name,cpu->pc,vm->jit_use ? "en":"dis");
    23152317
    23162318   vm_log(vm,"C7200_BOOT",
    2317           "starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n",
    2318           cpu->pc,cpu->idle_pc,vm->jit_use ? "on":"off");
     2319          "starting instance (CPU0 PC=0x%llx,JIT %s)\n",
     2320          cpu->pc,vm->jit_use ? "on":"off");
    23192321   
    23202322   /* Start main CPU */
    23212323   if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
     
    23642366          vm->name,cpu->ia,vm->jit_use ? "en":"dis");
    23652367
    23662368   vm_log(vm,"C7200P_BOOT",
    2367           "starting instance (CPU0 IA=0x%8.8x,idle_pc=0x%8.8x,JIT %s)\n",
    2368           cpu->ia,cpu->idle_pc,vm->jit_use ? "on":"off");
     2369          "starting instance (CPU0 IA=0x%8.8x,JIT %s)\n",
     2370          cpu->ia,vm->jit_use ? "on":"off");
    23692371   
    23702372   /* Start main CPU */
    23712373   if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/dev_msfc1.c dynamips-0.2.7-YLT/dev_msfc1.c
    old new  
    12201220
    12211221   /* Copy some parameters from VM to CPU0 (idle PC, ...) */
    12221222   cpu0->idle_pc = vm->idle_pc;
     1223   cpu0->num_idle_pc = vm->num_idle_pc;
    12231224
    12241225   if (vm->timer_irq_check_itv)
    12251226      cpu0->timer_irq_check_itv = vm->timer_irq_check_itv;
     
    13261327          vm->name,cpu->pc,vm->jit_use ? "en":"dis");
    13271328
    13281329   vm_log(vm,"MSFC1_BOOT",
    1329           "starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n",
    1330           cpu->pc,cpu->idle_pc,vm->jit_use ? "on":"off");
     1330          "starting instance (CPU0 PC=0x%llx,JIT %s)\n",
     1331          cpu->pc,vm->jit_use ? "on":"off");
    13311332   
    13321333   /* Start main CPU */
    13331334   if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/dynamips.c dynamips-0.2.7-YLT/dynamips.c
    old new  
    818818   }
    819819}
    820820
     821/* slices the val values into idle_pc values, and set them to the vm */
     822static void set_idle_pc(vm_instance_t *vm, char *val) {
     823    char *tmp_val;
     824    int len = 0;
     825    /* find out how many the string length */
     826    while (val[len] != '\0')
     827        len += 1;
     828    int i = 0;
     829    int num_val = 1;
     830    /* find out how many idle_pc values we have in the string */
     831    while (i < len) {
     832        if (val[i] == ',')
     833            num_val += 1;
     834        i += 1;
     835    }
     836    vm->num_idle_pc = num_val;
     837    vm->idle_pc = (m_uint64_t*)malloc(num_val*sizeof(unsigned long long int));
     838
     839    i = 0;
     840    int current_val_idx = 0;
     841    /* slice the string, and assign each individual idle_pc values */
     842    while (i < len) {
     843        tmp_val = (char *) malloc((len+1)*sizeof(char));
     844        int j = 0;
     845        while ((i < len)&&(val[i] != ',')) {
     846            tmp_val[j] = val[i];
     847            i += 1;
     848            j += 1;
     849        }
     850        tmp_val[j] = '\0';
     851        vm->idle_pc[current_val_idx] = strtoull(tmp_val, NULL, 0);
     852        current_val_idx += 1;
     853        i += 1;
     854        free(tmp_val);
     855    }
     856}
     857
     858
    821859/* Parse the command line */
    822860static int parse_std_cmd_line(int argc,char *argv[],int *platform)
    823861{
     
    941979
    942980         /* Idle PC */
    943981         case OPT_IDLE_PC:
    944             vm->idle_pc = strtoull(optarg,NULL,0);
    945             printf("Idle PC set to 0x%llx.\n",vm->idle_pc);
     982            set_idle_pc(vm, optarg);
    946983            break;
    947984
    948985         /* Timer IRQ check interval */
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/hv_vm.c dynamips-0.2.7-YLT/hv_vm.c
    old new  
    219219   if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
    220220      return(-1);
    221221
    222    vm->idle_pc = strtoull(argv[1],NULL,0);
     222    char *tmp_val;
     223    int len = 0;
     224    /* find out how many the string length */
     225    while (argv[1][len] != '\0')
     226        len += 1;
     227    int i = 0;
     228    int num_val = 1;
     229    /* find out how many idle_pc values we have in the string */
     230    while (i < len) {
     231        if (argv[1][i] == ',')
     232            num_val += 1;
     233        i += 1;
     234    }
     235    vm->num_idle_pc = num_val;
     236    vm->idle_pc = (m_uint64_t*)malloc(num_val*sizeof(unsigned long long int));
     237
     238    i = 0;
     239    int current_val_idx = 0;
     240    while (i < len) {
     241        tmp_val = (char *) malloc((len+1)*sizeof(char));
     242        int j = 0;
     243        while ((i < len)&&(argv[1][i] != ',')) {
     244            tmp_val[j] = argv[1][i];
     245            i += 1;
     246            j += 1;
     247        }
     248        tmp_val[j] = '\0';
     249        vm->idle_pc[current_val_idx] = strtoull(tmp_val, NULL, 0);
     250        current_val_idx += 1;
     251        i += 1;
     252        free(tmp_val);
     253    }
     254
    223255
    224256   vm_release(vm);
    225257   hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
     
    239271   if (!(cpu = find_cpu(conn,vm,atoi(argv[1]))))
    240272      return(-1);
    241273
    242    cpu->set_idle_pc(cpu,strtoull(argv[2],NULL,0));
     274   cpu->set_idle_pc(cpu,argv[2]);
    243275
    244276   vm_release(vm);
    245277   hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
    246278   return(0);
    247279}
    248280
     281
    249282/* Get the idle PC proposals */
    250283static int cmd_get_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[])
    251284
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/mips64.c dynamips-0.2.7-YLT/mips64.c
    old new  
    138138}
    139139
    140140/* Set idle PC value */
    141 void mips64_set_idle_pc(cpu_gen_t *cpu,m_uint64_t addr)
     141void mips64_set_idle_pc(cpu_gen_t *cpu,char* addr)
    142142{
    143    CPU_MIPS64(cpu)->idle_pc = addr;
     143    char *tmp_val;
     144    int len = 0;
     145    /* find out how many the string length */
     146    while (addr[len] != '\0')
     147        len += 1;
     148    int i = 0;
     149    int num_val = 1;
     150    /* find out how many idle_pc values we have in the string */
     151    while (i < len) {
     152        if (addr[i] == ',')
     153            num_val += 1;
     154        i += 1;
     155    }
     156    CPU_MIPS64(cpu)->num_idle_pc = num_val;
     157    CPU_MIPS64(cpu)->idle_pc = (m_uint64_t*)malloc(num_val*sizeof(unsigned long long int));
     158
     159    i = 0;
     160    int current_val_idx = 0;
     161    /* slice the string, and assign each individual idle_pc values */
     162    while (i < len) {
     163        tmp_val = (char *) malloc((len+1)*sizeof(char));
     164        int j = 0;
     165        while ((i < len)&&(addr[i] != ',')) {
     166            tmp_val[j] = addr[i];
     167            i += 1;
     168            j += 1;
     169        }
     170        tmp_val[j] = '\0';
     171        CPU_MIPS64(cpu)->idle_pc[current_val_idx] = (m_uint32_t) strtoull(tmp_val, NULL, 0);
     172        current_val_idx += 1;
     173        i += 1;
     174        free(tmp_val);
     175    }
    144176}
    145177
    146178/* Timer IRQ */
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/mips64.h dynamips-0.2.7-YLT/mips64.h
    old new  
    389389   insn_exec_page_t *exec_page_free_list;
    390390   insn_exec_page_t *exec_page_array;
    391391
    392    /* Idle PC value */
    393    volatile m_uint64_t idle_pc;
     392   /* Idle PC value array */
     393   volatile m_uint64_t* idle_pc;
     394
     395   /* Number of Idle PC value */
     396   volatile int num_idle_pc;
    394397
    395398   /* Timer IRQs */
    396399   volatile u_int timer_irq_pending;
     
    479482void mips64_set_prid(cpu_mips_t *cpu,m_uint32_t prid);
    480483
    481484/* Set idle PC value */
    482 void mips64_set_idle_pc(cpu_gen_t *cpu,m_uint64_t addr);
     485void mips64_set_idle_pc(cpu_gen_t *cpu,char* addr);
    483486
    484487/* Timer IRQ */
    485488void *mips64_timer_irq_run(cpu_mips_t *cpu);
  • mips64_jit.c

    diff -Naur dynamips-0.2.7/mips64_jit.c dynamips-0.2.7-YLT/mips64_jit.c
    old new  
    748748      cpu->perf_counter++;
    749749#endif
    750750      /* Handle virtual idle loop */
    751       if (unlikely(cpu->pc == cpu->idle_pc)) {
    752          if (++gen->idle_count == gen->idle_max) {
    753             cpu_idle_loop(gen);
    754             gen->idle_count = 0;
    755          }
     751      int i;
     752      for (i = 0; i < cpu->num_idle_pc; i++) {
     753          if (unlikely(cpu->pc == cpu->idle_pc[i])) {
     754             if (++gen->idle_count == gen->idle_max) {
     755                cpu_idle_loop(gen);
     756                gen->idle_count = 0;
     757             }
     758          }
    756759      }
    757760
    758761      /* Handle the virtual CPU clock */
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/ppc32.c dynamips-0.2.7-YLT/ppc32.c
    old new  
    9292}
    9393
    9494/* Set idle PC value */
    95 void ppc32_set_idle_pc(cpu_gen_t *cpu,m_uint64_t addr)
     95void ppc32_set_idle_pc(cpu_gen_t *cpu, char* addr)
    9696{
    97    CPU_PPC32(cpu)->idle_pc = (m_uint32_t)addr;
     97    char *tmp_val;
     98    int len = 0;
     99    /* find out how many the string length */
     100    while (addr[len] != '\0')
     101        len += 1;
     102    int i = 0;
     103    int num_val = 1;
     104    /* find out how many idle_pc values we have in the string */
     105    while (i < len) {
     106        if (addr[i] == ',')
     107            num_val += 1;
     108        i += 1;
     109    }
     110    CPU_PPC32(cpu)->num_idle_pc = num_val;
     111    CPU_PPC32(cpu)->idle_pc = (m_uint64_t*)malloc(num_val*sizeof(unsigned long long int));
     112
     113    i = 0;
     114    int current_val_idx = 0;
     115    /* slice the string, and assign each individual idle_pc values */
     116    while (i < len) {
     117        tmp_val = (char *) malloc((len+1)*sizeof(char));
     118        int j = 0;
     119        while ((i < len)&&(addr[i] != ',')) {
     120            tmp_val[j] = addr[i];
     121            i += 1;
     122            j += 1;
     123        }
     124        tmp_val[j] = '\0';
     125        CPU_PPC32(cpu)->idle_pc[current_val_idx] = (m_uint32_t) strtoull(tmp_val, NULL, 0);
     126        current_val_idx += 1;
     127        i += 1;
     128        free(tmp_val);
     129    }
    98130}
    99131
    100132/* Timer IRQ */
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/ppc32.h dynamips-0.2.7-YLT/ppc32.h
    old new  
    336336   insn_exec_page_t *exec_page_free_list;
    337337   insn_exec_page_t *exec_page_array;
    338338
    339    /* Idle PC value */
    340    volatile m_uint32_t idle_pc;
     339   /* Array Idle PC value */
     340   volatile m_uint32_t* idle_pc;
     341
     342   /* Number of idle_pc values */
     343   volatile int num_idle_pc;
    341344
    342345   /* Timer IRQs */
    343346   volatile u_int timer_irq_pending,timer_irq_armed;
     
    489492void ppc32_set_pvr(cpu_ppc_t *cpu,m_uint32_t pvr);
    490493
    491494/* Set idle PC value */
    492 void ppc32_set_idle_pc(cpu_gen_t *cpu,m_uint64_t addr);
     495void ppc32_set_idle_pc(cpu_gen_t *cpu, char* addr);
    493496
    494497/* Timer IRQ */
    495498void *ppc32_timer_irq_run(cpu_ppc_t *cpu);
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/ppc32_jit.c dynamips-0.2.7-YLT/ppc32_jit.c
    old new  
    12391239      cpu->perf_counter++;
    12401240#endif
    12411241      /* Handle virtual idle loop */
    1242       if (unlikely(cpu->ia == cpu->idle_pc)) {
    1243          if (++gen->idle_count == gen->idle_max) {
    1244             cpu_idle_loop(gen);
    1245             gen->idle_count = 0;
    1246          }
     1242      int i;
     1243      for (i = 0; i < cpu->num_idle_pc; i++) {
     1244          if (unlikely(cpu->ia == cpu->idle_pc[i])) {
     1245             if (++gen->idle_count == gen->idle_max) {
     1246                cpu_idle_loop(gen);
     1247                gen->idle_count = 0;
     1248             }
     1249          }
    12471250      }
    12481251
    12491252      /* Handle the virtual CPU clock */
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/vm.c dynamips-0.2.7-YLT/vm.c
    old new  
    396396   vm->vtty_aux_type        = VTTY_TYPE_NONE;
    397397   vm->timer_irq_check_itv  = VM_TIMER_IRQ_CHECK_ITV;
    398398   vm->log_file_enabled     = TRUE;
     399   vm->num_idle_pc          = 0;
    399400
    400401   if (!(vm->name = strdup(name))) {
    401402      fprintf(stderr,"VM %s: unable to store instance name!\n",name);
  • dynamips-0.2.

    diff -Naur dynamips-0.2.7/vm.h dynamips-0.2.7-YLT/vm.h
    old new  
    148148   /* Timer IRQ interval check */
    149149   u_int timer_irq_check_itv;
    150150
    151    /* "idling" pointer counter */
    152    m_uint64_t idle_pc;
     151   /* "idling" pointer counter array*/
     152   m_uint64_t* idle_pc;
     153
     154   /* number of idle_pc values */
     155   int num_idle_pc;
    153156
    154157   /* JIT block direct jumps */
    155158   int exec_blk_direct_jump;
     
    180183
    181184   /* VM objects */
    182185   struct vm_obj *vm_object_list;   
     186
    183187};
    184188
    185189#define VM_C7200(vm) ((c7200_t *)vm->hw_data)