From 71d50f3e298f459ba7cccaae4fe2b3d7697afd2f Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 8 Aug 2024 02:25:44 +0900 Subject: [PATCH] host_func_getptr/host_func_getptr2: remove offset argument there are no foreseeable users. let's simplify. --- lib/host_instance.c | 22 +++++++++++----------- lib/host_instance.h | 8 ++++---- libdyld/dyld_dlfcn.c | 4 ++-- libwasi/wasi_abi_path.c | 2 +- libwasi/wasi_abi_poll.c | 4 ++-- libwasi/wasi_abi_random.c | 2 +- libwasi/wasi_subr.c | 6 +++--- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/host_instance.c b/lib/host_instance.c index 5b5bbfa4..9f784035 100644 --- a/lib/host_instance.c +++ b/lib/host_instance.c @@ -166,7 +166,7 @@ host_func_copyin(struct exec_context *ctx, void *hostaddr, uint32_t wasmaddr, if (ret != 0) { return ret; } - ret = host_func_getptr(ctx, wasmaddr, 0, len, &p); + ret = host_func_getptr(ctx, wasmaddr, len, &p); if (ret != 0) { return ret; } @@ -184,7 +184,7 @@ host_func_copyout(struct exec_context *ctx, const void *hostaddr, if (ret != 0) { return ret; } - ret = host_func_getptr(ctx, wasmaddr, 0, len, &p); + ret = host_func_getptr(ctx, wasmaddr, len, &p); if (ret != 0) { return ret; } @@ -193,29 +193,29 @@ host_func_copyout(struct exec_context *ctx, const void *hostaddr, } int -host_func_getptr(struct exec_context *ctx, uint32_t ptr, uint32_t offset, - uint32_t size, void **pp) +host_func_getptr(struct exec_context *ctx, uint32_t ptr, uint32_t size, + void **pp) { - return host_func_getptr2(ctx, ptr, offset, size, pp, NULL); + return host_func_getptr2(ctx, ptr, size, pp, NULL); } int -host_func_getptr2(struct exec_context *ctx, uint32_t ptr, uint32_t offset, - uint32_t size, void **pp, bool *movedp) +host_func_getptr2(struct exec_context *ctx, uint32_t ptr, uint32_t size, + void **pp, bool *movedp) { struct meminst *meminst; int ret = cconv_default_memory(ctx, ctx->instance, &meminst); if (ret != 0) { return ret; } - ret = memory_instance_getptr2(meminst, ptr, offset, size, pp, movedp); + ret = memory_instance_getptr2(meminst, ptr, 0, size, pp, movedp); if (ret == ETOYWASMTRAP) { ret = trap_with_id( ctx, TRAP_OUT_OF_BOUNDS_MEMORY_ACCESS, "host function invalid memory access at %08" PRIx32 - " + %08" PRIx32 ", size %" PRIu32 - ", meminst size %" PRIu32 ", pagesize %" PRIu32, - ptr, offset, size, meminst->size_in_pages, + ", size %" PRIu32 ", meminst size %" PRIu32 + ", pagesize %" PRIu32, + ptr, size, meminst->size_in_pages, 1 << memtype_page_shift(meminst->type)); assert(ret != 0); } diff --git a/lib/host_instance.h b/lib/host_instance.h index 4ece06fb..69b0c677 100644 --- a/lib/host_instance.h +++ b/lib/host_instance.h @@ -89,10 +89,10 @@ int host_func_copyout(struct exec_context *ctx, const void *hostaddr, uint32_t wasmaddr, size_t len, size_t align); int host_func_copyin(struct exec_context *ctx, void *hostaddr, uint32_t wasmaddr, size_t len, size_t align); -int host_func_getptr(struct exec_context *ctx, uint32_t ptr, uint32_t offset, - uint32_t size, void **pp); -int host_func_getptr2(struct exec_context *ctx, uint32_t ptr, uint32_t offset, - uint32_t size, void **pp, bool *movedp); +int host_func_getptr(struct exec_context *ctx, uint32_t ptr, uint32_t size, + void **pp); +int host_func_getptr2(struct exec_context *ctx, uint32_t ptr, uint32_t size, + void **pp, bool *movedp); int host_func_trap(struct exec_context *ctx, const char *fmt, ...) __attribute__((__format__(__printf__, 2, 3))); struct restart_info; diff --git a/libdyld/dyld_dlfcn.c b/libdyld/dyld_dlfcn.c index 4388c5fc..f5a7a25d 100644 --- a/libdyld/dyld_dlfcn.c +++ b/libdyld/dyld_dlfcn.c @@ -75,7 +75,7 @@ dyld_dlfcn_load_object(struct exec_context *ctx, struct host_instance *hi, } void *vp; - ret = host_func_getptr(ctx, namep, 0, namelen, &vp); + ret = host_func_getptr(ctx, namep, namelen, &vp); if (ret != 0) { user_ret = 1; goto fail; @@ -169,7 +169,7 @@ dyld_dlfcn_resolve_symbol(struct exec_context *ctx, struct host_instance *hi, const struct dyld_dynamic_object *dobj = &VEC_ELEM(d->dynobjs, idx); void *vp; - ret = host_func_getptr(ctx, namep, 0, namelen, &vp); + ret = host_func_getptr(ctx, namep, namelen, &vp); if (ret != 0) { user_ret = 1; goto fail; diff --git a/libwasi/wasi_abi_path.c b/libwasi/wasi_abi_path.c index effbed03..08c20ef2 100644 --- a/libwasi/wasi_abi_path.c +++ b/libwasi/wasi_abi_path.c @@ -267,7 +267,7 @@ wasi_path_readlink(struct exec_context *ctx, struct host_instance *hi, * https://github.com/bytecodealliance/wasmtime/commit/24b607cf751930c51f2b6449cdfbf2e81dce1c31 */ void *p; - host_ret = host_func_getptr(ctx, buf, 0, buflen, &p); + host_ret = host_func_getptr(ctx, buf, buflen, &p); if (host_ret != 0) { goto fail; } diff --git a/libwasi/wasi_abi_poll.c b/libwasi/wasi_abi_poll.c index 5b2c8a0f..d26c7047 100644 --- a/libwasi/wasi_abi_poll.c +++ b/libwasi/wasi_abi_poll.c @@ -52,7 +52,7 @@ wasi_poll_oneoff(struct exec_context *ctx, struct host_instance *hi, if (host_ret != 0) { goto fail; } - host_ret = host_func_getptr(ctx, in, 0, insize, &p); + host_ret = host_func_getptr(ctx, in, insize, &p); if (host_ret != 0) { goto fail; } @@ -63,7 +63,7 @@ wasi_poll_oneoff(struct exec_context *ctx, struct host_instance *hi, if (host_ret != 0) { goto fail; } - host_ret = host_func_getptr2(ctx, out, 0, outsize, &p, &moved); + host_ret = host_func_getptr2(ctx, out, outsize, &p, &moved); if (host_ret != 0) { goto fail; } diff --git a/libwasi/wasi_abi_random.c b/libwasi/wasi_abi_random.c index 1c89c791..e1035434 100644 --- a/libwasi/wasi_abi_random.c +++ b/libwasi/wasi_abi_random.c @@ -29,7 +29,7 @@ wasi_random_get(struct exec_context *ctx, struct host_instance *hi, uint32_t buflen = HOST_FUNC_PARAM(ft, params, 1, i32); int ret = 0; void *p; - int host_ret = host_func_getptr(ctx, buf, 0, buflen, &p); + int host_ret = host_func_getptr(ctx, buf, buflen, &p); if (host_ret != 0) { goto fail; } diff --git a/libwasi/wasi_subr.c b/libwasi/wasi_subr.c index 3f75b03f..98413663 100644 --- a/libwasi/wasi_subr.c +++ b/libwasi/wasi_subr.c @@ -80,7 +80,7 @@ wasi_copyin_iovec(struct exec_context *ctx, uint32_t iov_uaddr, if (host_ret != 0) { goto fail; } - host_ret = host_func_getptr(ctx, iov_uaddr, 0, + host_ret = host_func_getptr(ctx, iov_uaddr, iov_count * sizeof(struct wasi_iov), &p); if (host_ret != 0) { goto fail; @@ -93,8 +93,8 @@ wasi_copyin_iovec(struct exec_context *ctx, uint32_t iov_uaddr, uint32_t iov_len = le32_decode(&iov_in_module[i].iov_len); xlog_trace("iov [%" PRIu32 "] base %" PRIx32 " len %" PRIu32, i, iov_base, iov_len); - host_ret = host_func_getptr2(ctx, iov_base, 0, iov_len, &p, - &moved); + host_ret = + host_func_getptr2(ctx, iov_base, iov_len, &p, &moved); if (host_ret != 0) { goto fail; }