gramineproject / gramine-tdx

A library OS for Linux multi-process applications, with Intel TDX support (experimental)
GNU Lesser General Public License v3.0
19 stars 5 forks source link

[PAL/vm-common] Try to read whole buffer in `pal_common_file_read()` #37

Closed dimakuv closed 4 months ago

dimakuv commented 4 months ago

Description of the changes

Previously, common VM code read up to FILE_CHUNK_SIZE (16KB) of file contents at a time, i.e. an application issuing the read/pread system call would get the return value of max 16KB. The assumption was that applications that submit a larger buffer will notice the partial read and re-read the missing contents.

This assumption worked well for many applications. But Java (in particular, the HotSpot JVM) breaks this assumption, expecting to get the whole requested buffer in one pread syscall. This commit satisfies this assumption by wrapping FUSE read requests into a while loop. Note that this is similar to what's done for FUSE write requests (detected previously, on Python workloads).

How to test this PR?

Try Java workloads.


This change is Reviewable