diff --git a/trusty/apploader/fuzz/app_fuzzer.cpp b/trusty/apploader/fuzz/app_fuzzer.cpp index aa0caca81..0a037f9e0 100644 --- a/trusty/apploader/fuzz/app_fuzzer.cpp +++ b/trusty/apploader/fuzz/app_fuzzer.cpp @@ -43,10 +43,6 @@ static struct uuid apploader_uuid = { {0xb5, 0xe8, 0xa7, 0xe9, 0xef, 0x17, 0x3a, 0x97}, }; -static inline uintptr_t RoundPageUp(uintptr_t val) { - return (val + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); -} - static bool SendLoadMsg(int chan, int dma_buf, size_t dma_buf_size) { apploader_header hdr = { .cmd = APPLOADER_CMD_LOAD_APPLICATION, @@ -107,7 +103,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { android::trusty::fuzz::Abort(); } - uint64_t shm_len = size ? RoundPageUp(size) : PAGE_SIZE; + uint64_t shm_len = size ? size : 4096; BufferAllocator alloc; unique_fd dma_buf(alloc.Alloc(kDmabufSystemHeapName, shm_len)); if (dma_buf < 0) { diff --git a/trusty/confirmationui/TrustyApp.cpp b/trusty/confirmationui/TrustyApp.cpp index cee8655e0..2356eef4e 100644 --- a/trusty/confirmationui/TrustyApp.cpp +++ b/trusty/confirmationui/TrustyApp.cpp @@ -30,10 +30,6 @@ namespace confirmationui { using ::android::base::unique_fd; -static inline uintptr_t RoundPageUp(uintptr_t val) { - return (val + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); -} - ssize_t TrustyApp::TrustyRpc(const uint8_t* obegin, const uint8_t* oend, uint8_t* ibegin, uint8_t* iend) { uint32_t olen = oend - obegin; @@ -99,7 +95,7 @@ TrustyApp::TrustyApp(const std::string& path, const std::string& appname) return; } - uint32_t shm_len = RoundPageUp(CONFIRMATIONUI_MAX_MSG_SIZE); + uint32_t shm_len = CONFIRMATIONUI_MAX_MSG_SIZE; BufferAllocator allocator; unique_fd dma_buf(allocator.Alloc("system", shm_len)); if (dma_buf < 0) { diff --git a/trusty/coverage/coverage.cpp b/trusty/coverage/coverage.cpp index 3c6b5c510..8fc2f5ca8 100644 --- a/trusty/coverage/coverage.cpp +++ b/trusty/coverage/coverage.cpp @@ -43,10 +43,6 @@ using std::string; using std::to_string; using std::unique_ptr; -static inline uintptr_t RoundPageUp(uintptr_t val) { - return (val + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); -} - CoverageRecord::CoverageRecord(string tipc_dev, struct uuid* uuid) : tipc_dev_(std::move(tipc_dev)), coverage_srv_fd_(-1), @@ -136,7 +132,7 @@ Result CoverageRecord::Open() { return Error() << "failed to open coverage client: " << ret.error(); } record_len_ = resp.open_args.record_len; - shm_len_ = RoundPageUp(record_len_); + shm_len_ = record_len_; BufferAllocator allocator; diff --git a/trusty/line-coverage/coverage.cpp b/trusty/line-coverage/coverage.cpp index 57b702510..5f7b3a3f6 100644 --- a/trusty/line-coverage/coverage.cpp +++ b/trusty/line-coverage/coverage.cpp @@ -50,10 +50,6 @@ using ::android::base::ErrnoError; using ::android::base::Error; using ::std::string; -static inline uintptr_t RoundPageUp(uintptr_t val) { - return (val + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); -} - CoverageRecord::CoverageRecord(string tipc_dev, struct uuid* uuid) : tipc_dev_(std::move(tipc_dev)), coverage_srv_fd_(-1), @@ -129,7 +125,7 @@ Result CoverageRecord::Open(int fd) { return Error() << "failed to open coverage client: " << ret.error(); } record_len_ = resp.open_args.record_len; - shm_len_ = RoundPageUp(record_len_); + shm_len_ = record_len_; BufferAllocator allocator; diff --git a/trusty/utils/acvp/trusty_modulewrapper.cpp b/trusty/utils/acvp/trusty_modulewrapper.cpp index 85b7159d3..817b60061 100644 --- a/trusty/utils/acvp/trusty_modulewrapper.cpp +++ b/trusty/utils/acvp/trusty_modulewrapper.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "acvp_ipc.h" @@ -42,9 +43,6 @@ using android::base::Result; using android::base::unique_fd; using android::base::WriteFully; -static inline size_t AlignUpToPage(size_t size) { - return (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); -} namespace { @@ -104,15 +102,12 @@ Result ModuleWrapper::SendMessage(bssl::Span shm_size_) { - shm_size_ = AlignUpToPage(total_args_size); - } + shm_size_ = std::max(ACVP_MIN_SHARED_MEMORY, total_args_size); request.buffer_size = shm_size_; struct iovec iov = {