Beispiel #1
0
void
set_drmarker_hotp_policy_status_table(void *new_table)
{
    dr_marker_t *dr_marker = get_drmarker();

    ASSERT_OWN_WRITE_LOCK(true, hotp_get_lock());

    /* We don't want to write to the dr_marker_t before it is initialized;  we
     * could get an exception.
     */
    if (dr_marker == NULL)      /* Part of fix for case 5367. */
        return;
    /* Ok, dr_marker_t has been initialized. */

    /* It is ok to do this memory protection change here even though this can
     * be any arbitrary time due to the nature of nudge.  This is because
     * once initialized, the dr_marker_t isn't touched by any one except the hot
     * patch nudge.
     *
     * TODO: In future other parts of the core may need to change the dr_marker_t.
     *       It might be a good idea to introduce a lock for the dr_marker_t and
     *       generic accessor functions.
     */
    make_writable((byte*)dr_marker, INTERCEPTION_CODE_SIZE);
    dr_marker->dr_hotp_policy_status_table = new_table;
    make_unwritable((byte*)dr_marker, INTERCEPTION_CODE_SIZE);
}
Beispiel #2
0
/* Returns whether it had to change page protections */
static bool
patch_coarse_branch(cache_pc stub, cache_pc tgt, bool hot_patch,
                    coarse_info_t *info /*OPTIONAL*/)
{
	// COMPLETEDD #498 patch_coarse_branch
    bool stubs_readonly = false;
    bool stubs_restore = false;
    if (DYNAMO_OPTION(persist_protect_stubs)) {
        if (info == NULL)
            info = get_stub_coarse_info(stub);
        ASSERT(info != NULL);
        if (info->stubs_readonly) {
            stubs_readonly = true;
            stubs_restore = true;
            /* if we don't preserve mapped-in COW state the protection change
             * will fail (case 10570)
             */
            make_copy_on_writable((byte *)PAGE_START(entrance_stub_jmp(stub)),
                                  /* stub jmp can't cross page boundary (can't
                                   * cross cache line in fact) */
                                  PAGE_SIZE);
            if (DYNAMO_OPTION(persist_protect_stubs_limit) > 0) {
                info->stubs_write_count++;
                if (info->stubs_write_count >
                    DYNAMO_OPTION(persist_protect_stubs_limit)) {
                    SYSLOG_INTERNAL_WARNING_ONCE("pcache stubs over write limit");
                    STATS_INC(pcache_unprot_over_limit);
                    stubs_restore = false;
                    info->stubs_readonly = false;
                }
            }
        }
    }
    patch_branch(entrance_stub_jmp(stub), tgt, HOT_PATCHABLE);
    if (stubs_restore)
        make_unwritable((byte *)PAGE_START(entrance_stub_jmp(stub)), PAGE_SIZE);
    return stubs_readonly;
}