diff options
| -rw-r--r-- | libcacard/vcard_emul_nss.c | 36 | ||||
| -rw-r--r-- | target-sparc/mmu_helper.c | 19 |
2 files changed, 34 insertions, 21 deletions
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index bdc3c79462..802cae3a29 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -682,8 +682,19 @@ vcard_emul_event_thread(void *arg) SECMODModule *module = (SECMODModule *)arg; do { + /* + * XXX - the latency value doesn't matter one bit. you only get no + * blocking (flags |= CKF_DONT_BLOCK) or PKCS11_WAIT_LATENCY (==500), + * hard coded in coolkey. And it isn't coolkey's fault - the timeout + * value we pass get's dropped on the floor before C_WaitForSlotEvent + * is called. + */ slot = SECMOD_WaitForAnyTokenEvent(module, 0, 500); if (slot == NULL) { + /* this could be just a no event indication */ + if (PORT_GetError() == SEC_ERROR_NO_EVENT) { + continue; + } break; } vreader = vcard_emul_find_vreader_from_slot(slot); @@ -994,10 +1005,10 @@ vcard_emul_init(const VCardEmulOptions *options) SECMOD_GetReadLock(module_lock); for (mlp = module_list; mlp; mlp = mlp->next) { SECMODModule *module = mlp->module; - PRBool has_emul_slots = PR_FALSE; - if (module == NULL) { - continue; + /* Ignore the internal module */ + if (module == NULL || module == SECMOD_GetInternalModule()) { + continue; } for (i = 0; i < module->slotCount; i++) { @@ -1007,15 +1018,22 @@ vcard_emul_init(const VCardEmulOptions *options) if (slot == NULL || !PK11_IsRemovable(slot) || !PK11_IsHW(slot)) { continue; } + if (strcmp("E-Gate 0 0", PK11_GetSlotName(slot)) == 0) { + /* + * coolkey <= 1.1.0-20 emulates this reader if it can't find + * any hardware readers. This causes problems, warn user of + * problems. + */ + fprintf(stderr, "known bad coolkey version - see " + "https://bugzilla.redhat.com/show_bug.cgi?id=802435\n"); + continue; + } vreader_emul = vreader_emul_new(slot, options->hw_card_type, options->hw_type_params); vreader = vreader_new(PK11_GetSlotName(slot), vreader_emul, vreader_emul_delete); vreader_add_reader(vreader); - has_readers = PR_TRUE; - has_emul_slots = PR_TRUE; - if (PK11_IsPresent(slot)) { VCard *vcard; vcard = vcard_emul_mirror_card(vreader); @@ -1024,12 +1042,10 @@ vcard_emul_init(const VCardEmulOptions *options) vcard_free(vcard); } } - if (has_emul_slots) { - vcard_emul_new_event_thread(module); - } + vcard_emul_new_event_thread(module); } SECMOD_ReleaseReadLock(module_lock); - nss_emul_init = has_readers; + nss_emul_init = PR_TRUE; return VCARD_EMUL_OK; } diff --git a/target-sparc/mmu_helper.c b/target-sparc/mmu_helper.c index 11fb9f5de6..cb73c449f0 100644 --- a/target-sparc/mmu_helper.c +++ b/target-sparc/mmu_helper.c @@ -150,18 +150,17 @@ static int get_physical_address(CPUSPARCState *env, target_phys_addr_t *physical case 3: /* Reserved */ return (3 << 8) | (4 << 2); case 2: /* L3 PTE */ - page_offset = (address & TARGET_PAGE_MASK) & - (TARGET_PAGE_SIZE - 1); + page_offset = 0; } *page_size = TARGET_PAGE_SIZE; break; case 2: /* L2 PTE */ - page_offset = address & 0x3ffff; + page_offset = address & 0x3f000; *page_size = 0x40000; } break; case 2: /* L1 PTE */ - page_offset = address & 0xffffff; + page_offset = address & 0xfff000; *page_size = 0x1000000; } } @@ -206,11 +205,11 @@ int cpu_sparc_handle_mmu_fault(CPUSPARCState *env, target_ulong address, int rw, target_ulong page_size; int error_code = 0, prot, access_index; + address &= TARGET_PAGE_MASK; error_code = get_physical_address(env, &paddr, &prot, &access_index, address, rw, mmu_idx, &page_size); + vaddr = address; if (error_code == 0) { - vaddr = address & TARGET_PAGE_MASK; - paddr &= TARGET_PAGE_MASK; #ifdef DEBUG_MMU printf("Translate at " TARGET_FMT_lx " -> " TARGET_FMT_plx ", vaddr " TARGET_FMT_lx "\n", address, paddr, vaddr); @@ -230,7 +229,6 @@ int cpu_sparc_handle_mmu_fault(CPUSPARCState *env, target_ulong address, int rw, permissions. If no mapping is available, redirect accesses to neverland. Fake/overridden mappings will be flushed when switching to normal mode. */ - vaddr = address & TARGET_PAGE_MASK; prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; tlb_set_page(env, vaddr, paddr, prot, mmu_idx, TARGET_PAGE_SIZE); return 0; @@ -704,17 +702,16 @@ static int get_physical_address(CPUSPARCState *env, target_phys_addr_t *physical int cpu_sparc_handle_mmu_fault(CPUSPARCState *env, target_ulong address, int rw, int mmu_idx) { - target_ulong virt_addr, vaddr; + target_ulong vaddr; target_phys_addr_t paddr; target_ulong page_size; int error_code = 0, prot, access_index; + address &= TARGET_PAGE_MASK; error_code = get_physical_address(env, &paddr, &prot, &access_index, address, rw, mmu_idx, &page_size); if (error_code == 0) { - virt_addr = address & TARGET_PAGE_MASK; - vaddr = virt_addr + ((address & TARGET_PAGE_MASK) & - (TARGET_PAGE_SIZE - 1)); + vaddr = address; trace_mmu_helper_mmu_fault(address, paddr, mmu_idx, env->tl, env->dmmu.mmu_primary_context, |