static int tx4927_pcibios_read_config_dword(struct pci_dev *dev, int where, unsigned int *val) { int flags, retval; unsigned char bus, func_num; if (where & 3) return PCIBIOS_BAD_REGISTER_NUMBER; db_assert((where & 3) == 0); db_assert(where < (1 << 8)); /* check if the bus is top-level */ if (dev->bus->parent != NULL) { bus = dev->bus->number; db_assert(bus != 0); } else { bus = 0; } func_num = PCI_FUNC(dev->devfn); if (mkaddr(bus, dev->devfn, where, &flags)) return -1; *val = tx4927_pcicptr->g2pcfgdata; retval = check_abort(flags); if (retval == PCIBIOS_DEVICE_NOT_FOUND) *val = 0xffffffff; return retval; }
static int jmr3927_pcibios_read_config_dword (struct pci_dev *dev, int where, unsigned int *val) { int flags; unsigned char bus, func_num; if (where & 3) return PCIBIOS_BAD_REGISTER_NUMBER; db_assert((where & 3) == 0); db_assert(where < (1 << 8)); /* check if the bus is top-level */ if (dev->bus->parent != NULL) { bus = dev->bus->number; db_assert(bus != 0); } else { bus = 0; } func_num = PCI_FUNC(dev->devfn); if (mkaddr(bus, dev->devfn, where, &flags)) return -1; *val = le32_to_cpu(tx3927_pcicptr->icd); return check_abort(flags); }
static void read_file(struct db_main *db, char *name, int flags, void (*process_line)(struct db_main *db, char *line)) { struct stat file_stat; FILE *file; char line[LINE_BUFFER_SIZE]; if (flags & RF_ALLOW_DIR) { if (stat(name, &file_stat)) { if (flags & RF_ALLOW_MISSING) if (errno == ENOENT) return; pexit("stat: %s", path_expand(name)); } else if (S_ISDIR(file_stat.st_mode)) return; } if (!(file = fopen(path_expand(name), "r"))) { if ((flags & RF_ALLOW_MISSING) && errno == ENOENT) return; pexit("fopen: %s", path_expand(name)); } while (fgets(line, sizeof(line), file)) { process_line(db, line); check_abort(0); } if (ferror(file)) pexit("fgets"); if (fclose(file)) pexit("fclose"); }
static int tx4927_pcibios_write_config_word(struct pci_dev *dev, int where, unsigned short val) { int flags; unsigned char bus, func_num; if (where & 1) return PCIBIOS_BAD_REGISTER_NUMBER; /* check if the bus is top-level */ if (dev->bus->parent != NULL) { bus = dev->bus->number; db_assert(bus != 0); } else { bus = 0; } func_num = PCI_FUNC(dev->devfn); if (mkaddr(bus, dev->devfn, where, &flags)) return -1; #ifdef __BIG_ENDIAN *(volatile u16 *) ((ulong) & tx4927_pcicptr-> g2pcfgdata | ((where & 3) ^ 2)) = val; #else *(volatile u16 *) ((ulong) & tx4927_pcicptr-> g2pcfgdata | (where & 3)) = val; #endif return check_abort(flags); }
/* * We can't address 8 and 16 bit words directly. Instead we have to * read/write a 32bit word and mask/modify the data we actually want. */ static int tx4927_pcibios_read_config_byte(struct pci_dev *dev, int where, unsigned char *val) { int flags, retval; unsigned char bus, func_num; db_assert((where & 3) == 0); db_assert(where < (1 << 8)); /* check if the bus is top-level */ if (dev->bus->parent != NULL) { bus = dev->bus->number; db_assert(bus != 0); } else { bus = 0; } func_num = PCI_FUNC(dev->devfn); if (mkaddr(bus, dev->devfn, where, &flags)) return -1; #ifdef __BIG_ENDIAN *val = *(volatile u8 *) ((ulong) & tx4927_pcicptr-> g2pcfgdata | ((where & 3) ^ 3)); #else *val = *(volatile u8 *) ((ulong) & tx4927_pcicptr-> g2pcfgdata | (where & 3)); #endif retval = check_abort(flags); if (retval == PCIBIOS_DEVICE_NOT_FOUND) *val = 0xff; return retval; }
static int tx4927_pcibios_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val) { int flags, retval, dev, busno, func; busno = bus->number; dev = PCI_SLOT(devfn); func = PCI_FUNC(devfn); if (size == 2) { if (where & 1) return PCIBIOS_BAD_REGISTER_NUMBER; } if (size == 4) { if (where & 3) return PCIBIOS_BAD_REGISTER_NUMBER; } /* check if the bus is top-level */ if (bus->parent != NULL) { busno = bus->number; } else { busno = 0; } if (mkaddr(busno, devfn, where, &flags)) return -1; switch (size) { case 1: *val = *(volatile u8 *) ((ulong) & tx4927_pcicptr-> g2pcfgdata | #ifdef __LITTLE_ENDIAN (where & 3)); #else ((where & 0x3) ^ 0x3)); #endif break; case 2: *val = *(volatile u16 *) ((ulong) & tx4927_pcicptr-> g2pcfgdata | #ifdef __LITTLE_ENDIAN (where & 3)); #else ((where & 0x3) ^ 0x2)); #endif break; case 4: *val = tx4927_pcicptr->g2pcfgdata; break; } retval = check_abort(flags); if (retval == PCIBIOS_DEVICE_NOT_FOUND) *val = 0xffffffff; return retval; }
static void check_joined(check *chk, joined_msg *m) { chk->pending_joins--; assert(0 <= chk->pending_joins); printf("#%d ("EPID_FORMAT") has joined the network; %d pending\n", m->cn.id,EPID_ARGS(m->cn.epid),chk->pending_joins); check_abort(chk); }
static void check_chord_started(check *chk, chord_started_msg *m) { assert(chk->ncount+1 < MAX_NODES); chk->nodes[chk->ncount] = m->cn; chk->ncount++; qsort(chk->nodes,chk->ncount,sizeof(chordnode),chordnode_cmp); endpoint_link(chk->endpt,m->cn.epid); printf("chk chord_started %d: now have %d nodes\n",m->cn.id,chk->ncount); check_abort(chk); }
static void john_done(void) { path_done(); if ((options.flags & FLG_CRACKING_CHK) && !(options.flags & FLG_STDOUT)) { if (event_abort) log_event("Session aborted"); else log_event("Session completed"); } log_done(); check_abort(0); }
static void sig_handle_abort(int signum) { int saved_errno = errno; check_abort(1); event_abort = event_pending = 1; write_loop(2, "Wait...\r", 8); sig_install_abort(); errno = saved_errno; }
static int tx4938_pcibios_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val) { int retval, dev, busno, func; struct tx4938_pcic_reg *pcicptr = pci_bus_to_pcicptr(bus); void __iomem *cfgdata = (void __iomem *)(unsigned long)&pcicptr->g2pcfgdata; dev = PCI_SLOT(devfn); func = PCI_FUNC(devfn); /* check if the bus is top-level */ if (bus->parent != NULL) busno = bus->number; else { busno = 0; } if (mkaddr(busno, devfn, where, pcicptr)) return -1; switch (size) { case 1: #ifdef __BIG_ENDIAN cfgdata += (where & 3) ^ 3; #else cfgdata += where & 3; #endif *val = __raw_readb(cfgdata); break; case 2: #ifdef __BIG_ENDIAN cfgdata += (where & 2) ^ 2; #else cfgdata += where & 2; #endif *val = __raw_readw(cfgdata); break; case 4: *val = __raw_readl(cfgdata); break; } retval = check_abort(pcicptr); if (retval == PCIBIOS_DEVICE_NOT_FOUND) *val = 0xffffffff; return retval; }
static void check_id_changed(check *chk, id_changed_msg *m) { int i; for (i = 0; i < chk->ncount; i++) { if (endpointid_equals(&chk->nodes[i].epid,&m->cn.epid)) { printf(EPID_FORMAT" changed id %d -> %d\n",EPID_ARGS(m->cn.epid),m->oldid,m->cn.id); assert(chk->nodes[i].id == m->oldid); chk->nodes[i].id = m->cn.id; qsort(chk->nodes,chk->ncount,sizeof(chordnode),chordnode_cmp); check_abort(chk); return; } } fatal("received ID_CHANGED for unknown endpointid "EPID_FORMAT,EPID_ARGS(m->cn.epid)); }
static void sig_handle_abort(int signum) { int saved_errno = errno; #if OS_FORK if (john_main_process) { /* * We assume that our children are running on the same tty with us, so if we * receive a SIGINT they probably do as well without us needing to forward the * signal to them. If we forwarded the signal anyway, this could result in * them receiving the signal twice for a single Ctrl-C keypress and proceeding * with immediate abort without updating the files, which is behavior that we * reserve for (presumably intentional) repeated Ctrl-C keypress. * * We forward the signal as SIGINT even though ours was different (typically a * SIGTERM) in order not to trigger a repeated same signal for children if the * user does e.g. "killall john", which would send SIGTERM directly to children * and also have us forward a signal. */ if (signum != SIGINT) signal_children(SIGINT); } else { static int prev_signum; /* * If it's not the same signal twice in a row, don't proceed with immediate * abort since these two signals could have been triggered by the same killall * (perhaps a SIGTERM from killall directly and a SIGINT as forwarded by our * parent). event_abort would be set back to 1 just below the check_abort() * call. We only reset it to 0 temporarily to skip the immediate abort here. */ if (prev_signum && signum != prev_signum) event_abort = 0; prev_signum = signum; } #endif check_abort(1); event_abort = event_pending = 1; write_loop(2, "Wait...\r", 8); sig_install_abort(); errno = saved_errno; }
static void john_done(void) { path_done(); if ((options.flags & FLG_CRACKING_CHK) && !(options.flags & FLG_STDOUT)) { if (event_abort) log_event(timer_abort ? "Session aborted" : "Session stopped (max run-time reached)"); else log_event("Session completed"); } log_done(); check_abort(0); cleanup_tiny_memory(); }
static int tx4938_pcibios_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { int dev, busno, func; struct tx4938_pcic_reg *pcicptr = pci_bus_to_pcicptr(bus); void __iomem *cfgdata = (void __iomem *)(unsigned long)&pcicptr->g2pcfgdata; busno = bus->number; dev = PCI_SLOT(devfn); func = PCI_FUNC(devfn); /* check if the bus is top-level */ if (bus->parent != NULL) { busno = bus->number; } else { busno = 0; } if (mkaddr(busno, devfn, where, pcicptr)) return -1; switch (size) { case 1: #ifdef __BIG_ENDIAN cfgdata += (where & 3) ^ 3; #else cfgdata += where & 3; #endif __raw_writeb(val, cfgdata); break; case 2: #ifdef __BIG_ENDIAN cfgdata += (where & 2) ^ 2; #else cfgdata += where & 2; #endif __raw_writew(val, cfgdata); break; case 4: __raw_writel(val, cfgdata); break; } return check_abort(pcicptr); }
static int tx4927_pcibios_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { int flags, dev, busno, func; busno = bus->number; dev = PCI_SLOT(devfn); func = PCI_FUNC(devfn); if (size == 1) { if (where & 1) return PCIBIOS_BAD_REGISTER_NUMBER; } if (size == 4) { if (where & 3) return PCIBIOS_BAD_REGISTER_NUMBER; } /* check if the bus is top-level */ if (bus->parent != NULL) { busno = bus->number; } else { busno = 0; } if (mkaddr(busno, devfn, where, &flags)) return -1; switch (size) { case 1: *(volatile u8 *) ((ulong) & tx4927_pcicptr-> g2pcfgdata | (where & 3)) = val; break; case 2: *(volatile u16 *) ((ulong) & tx4927_pcicptr-> g2pcfgdata | (where & 3)) = val; break; case 4: tx4927_pcicptr->g2pcfgdata = val; break; } return check_abort(flags); }
static int tx4927_pcibios_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { int flags, dev, busno, func; busno = bus->number; dev = PCI_SLOT(devfn); func = PCI_FUNC(devfn); /* check if the bus is top-level */ if (bus->parent != NULL) { busno = bus->number; } else { busno = 0; } if (mkaddr(busno, devfn, where, &flags)) return -1; switch (size) { case 1: *(volatile u8 *) ((unsigned long) & tx4927_pcicptr-> g2pcfgdata | #ifdef __LITTLE_ENDIAN (where & 3)) = val; #else ((where & 0x3) ^ 0x3)) = val; #endif break; case 2: *(volatile u16 *) ((unsigned long) & tx4927_pcicptr-> g2pcfgdata | #ifdef __LITTLE_ENDIAN (where & 3)) = val; #else ((where & 0x3) ^ 0x2)) = val; #endif break; case 4: tx4927_pcicptr->g2pcfgdata = val; break; } return check_abort(flags); }
static void check_endpoint_exit(check *chk, endpoint_exit_msg *m) { endpointid exited = m->epid; int i; int nodeno = -1; for (i = 0; i < chk->ncount; i++) { if (endpointid_equals(&chk->nodes[i].epid,&exited)) nodeno = i; } printf("debug_loop: got endpoint_exit: endpoint "EPID_FORMAT", nodeno %d\n", EPID_ARGS(exited),nodeno); assert(0 <= nodeno); memmove(&chk->nodes[nodeno],&chk->nodes[nodeno+1],(chk->ncount-nodeno-1)*sizeof(chordnode)); chk->ncount--; check_abort(chk); }
static int jmr3927_pcibios_write_config_byte (struct pci_dev *dev, int where, unsigned char val) { int flags; unsigned char bus, func_num; /* check if the bus is top-level */ if (dev->bus->parent != NULL) { bus = dev->bus->number; db_assert(bus != 0); } else { bus = 0; } func_num = PCI_FUNC(dev->devfn); if (mkaddr(bus, dev->devfn, where, &flags)) return -1; *(volatile u8 *)((ulong)&tx3927_pcicptr->icd | (where&3)) = val; return check_abort(flags); }
static int tx3927_pci_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { if (mkaddr(bus, devfn, where)) return PCIBIOS_DEVICE_NOT_FOUND; switch (size) { case 1: *(volatile u8 *) ((unsigned long) & tx3927_pcicptr->icd | (where & 3)) = val; break; case 2: *(volatile u16 *) ((unsigned long) & tx3927_pcicptr->icd | (where & 2)) = cpu_to_le16(val); break; case 4: tx3927_pcicptr->icd = cpu_to_le32(val); } return check_abort(); }
static int tx4927_pcibios_write_config_dword(struct pci_dev *dev, int where, unsigned int val) { int flags; unsigned char bus, func_num; if (where & 3) return PCIBIOS_BAD_REGISTER_NUMBER; /* check if the bus is top-level */ if (dev->bus->parent != NULL) { bus = dev->bus->number; db_assert(bus != 0); } else { bus = 0; } func_num = PCI_FUNC(dev->devfn); if (mkaddr(bus, dev->devfn, where, &flags)) return -1; tx4927_pcicptr->g2pcfgdata = val; return check_abort(flags); }
static int jmr3927_pcibios_write_config_word (struct pci_dev *dev, int where, unsigned short val) { int flags; unsigned char bus, func_num; if (where & 1) return PCIBIOS_BAD_REGISTER_NUMBER; /* check if the bus is top-level */ if (dev->bus->parent != NULL) { bus = dev->bus->number; db_assert(bus != 0); } else { bus = 0; } func_num = PCI_FUNC(dev->devfn); if (mkaddr(bus, dev->devfn, where, &flags)) return -1; *(volatile u16 *)((ulong)&tx3927_pcicptr->icd | (where&3)) = cpu_to_le16(val); return check_abort(flags); }
static int tx3927_pci_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val) { if (mkaddr(bus, devfn, where)) { *val = 0xffffffff; return PCIBIOS_DEVICE_NOT_FOUND; } switch (size) { case 1: *val = *(volatile u8 *) ((unsigned long) & tx3927_pcicptr->icd | (where & 3)); break; case 2: *val = le16_to_cpu(*(volatile u16 *) ((unsigned long) & tx3927_pcicptr->icd | (where & 3))); break; case 4: *val = le32_to_cpu(tx3927_pcicptr->icd); break; } return check_abort(); }
static void check_debug_start(check *chk, endpointid *caller) { assert(!chk->indebug); chk->indebug = 1; memcpy(&chk->caller,caller,sizeof(endpointid)); chk->cur_node = 0; chk->cur_lookup = 0; chk->incorrect_nodes = 0; chk->incorrect_successor = 0; chk->incorrect_links = 0; chk->incorrect_fingers = 0; chk->incorrect_succlist = 0; chk->total_bad = 0; chk->total_hops = 0; chk->total_lookups = 0; gettimeofday(&chk->debug_start,NULL); if (0 < chk->pending_joins) { printf("skipping debug, due to %d pending joins\n",chk->pending_joins); check_abort(chk); } else if ((1 <= chk->iterations) && (0 == (chk->iterations % DISRUPT_INTERVAL))) { if (0 == (chk->iterations % (2*DISRUPT_INTERVAL))) { /* Add some new nodes */ endpointid initial = chk->nodes[rand()%chk->ncount].epid; int i; for (i = 0; i < JOIN_COUNT; i++) { add_node(chk->n,chk->endpt,chk->managerids[rand()%chk->nmanagers],initial); chk->pending_joins++; } } else { /* Kill some existing nodes */ int i; int j; int *killindices = (int*)calloc(KILL_COUNT,sizeof(int)); for (i = 0; i < KILL_COUNT; i++) { int have; int index; do { have = 0; index = rand()%chk->ncount; for (j = 0; j < i; j++) if (killindices[j] == index) have = 1; } while (have); killindices[i] = index; } for (i = 0; i < KILL_COUNT; i++) { endpoint_send(chk->endpt,chk->nodes[killindices[i]].epid,MSG_KILL,NULL,0); } free(killindices); } chk->iterations++; check_abort(chk); } else { get_table_msg gtm; gtm.sender = chk->endpt->epid; gettimeofday(&chk->node_start,NULL); endpoint_send(chk->endpt,chk->nodes[0].epid,MSG_GET_TABLE,>m,sizeof(gtm)); } }