From c93998e817b2cb4e17aaaa24fda0b1f35bf6390e Mon Sep 17 00:00:00 2001 From: Steffen Schulz Date: Wed, 25 May 2022 01:06:38 +0200 Subject: [PATCH 1/2] Revert "page_cache: use file lock also for read access" This reverts commit 5c24050a645b0db69a806cb100f4e263ca191838. --- nyx/page_cache.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/nyx/page_cache.c b/nyx/page_cache.c index 1827c186a9..55689316c8 100644 --- a/nyx/page_cache.c +++ b/nyx/page_cache.c @@ -25,9 +25,6 @@ #define UNMAPPED_PAGE 0xFFFFFFFFFFFFFFFFULL -static void page_cache_unlock(page_cache_t* self); -static void page_cache_lock(page_cache_t* self); - #ifndef STANDALONE_DECODER static bool reload_addresses(page_cache_t* self){ #else @@ -43,8 +40,6 @@ bool reload_addresses(page_cache_t* self){ if(self_offset != self->num_pages*PAGE_CACHE_ADDR_LINE_SIZE){ //fprintf(stderr, "Reloading files ...\n"); - page_cache_lock(self); // don't read while someone else is writing? - lseek(self->fd_address_file, self->num_pages*PAGE_CACHE_ADDR_LINE_SIZE, SEEK_SET); offset = self->num_pages; while(read(self->fd_address_file, &value, PAGE_CACHE_ADDR_LINE_SIZE)){ @@ -84,8 +79,6 @@ bool reload_addresses(page_cache_t* self){ munmap(self->page_data, self->num_pages*PAGE_SIZE); self->num_pages = self_offset/PAGE_CACHE_ADDR_LINE_SIZE; self->page_data = mmap(NULL, (self->num_pages)*PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, self->fd_page_file, 0); - - page_cache_unlock(self); return true; } From 6a336d0d3a1e484f21a08161ddbf4c921c2a586f Mon Sep 17 00:00:00 2001 From: Steffen Schulz Date: Wed, 25 May 2022 01:06:50 +0200 Subject: [PATCH 2/2] Revert "page_cache: auto-create workdir files or resume based on existing files" This reverts commit b8995723775c5ee75355ef4e87922cec359245e5. --- nyx/interface.c | 24 ++++++++++++++++++++++++ nyx/page_cache.c | 6 +++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/nyx/interface.c b/nyx/interface.c index 09e57c0209..4294505d99 100644 --- a/nyx/interface.c +++ b/nyx/interface.c @@ -262,6 +262,30 @@ static bool verify_workdir_state(nyx_interface_state *s, Error **errp){ } free(tmp); + assert(asprintf(&tmp, "%s/page_cache.lock", workdir) != -1); + if (!file_exits(tmp)){ + fprintf(stderr, "%s does not exist...", tmp); + free(tmp); + return false; + } + free(tmp); + + assert(asprintf(&tmp, "%s/page_cache.addr", workdir) != -1); + if (!file_exits(tmp)){ + fprintf(stderr, "%s does not exist...\n", tmp); + free(tmp); + return false; + } + free(tmp); + + assert(asprintf(&tmp, "%s/page_cache.dump", workdir) != -1); + if (!file_exits(tmp)){ + fprintf(stderr, "%s does not exist...\n", tmp); + free(tmp); + return false; + } + free(tmp); + assert(asprintf(&tmp, "%s/page_cache", workdir) != -1); init_page_cache(tmp); diff --git a/nyx/page_cache.c b/nyx/page_cache.c index 55689316c8..7d40dff85e 100644 --- a/nyx/page_cache.c +++ b/nyx/page_cache.c @@ -359,12 +359,12 @@ page_cache_t* page_cache_new(const char* cache_file, uint8_t disassembler_word_w self->lookup = kh_init(PC_CACHE); - self->fd_page_file = open(tmp1, O_CLOEXEC | O_CREAT | O_RDWR, 0644); - self->fd_address_file = open(tmp2, O_CLOEXEC | O_CREAT | O_RDWR, 0644); + self->fd_page_file = open(tmp1, O_CLOEXEC | O_RDWR, S_IRWXU); + self->fd_address_file = open(tmp2, O_CLOEXEC | O_RDWR, S_IRWXU); #ifndef STANDALONE_DECODER self->cpu = cpu; - self->fd_lock = open(tmp3, O_CLOEXEC | O_CREAT, 0644); + self->fd_lock = open(tmp3, O_CLOEXEC); assert(self->fd_lock > 0); #else if(self->fd_page_file == -1 || self->fd_address_file == -1){