This invention discloses a virtualized log export method, apparatus, terminal, and storage medium, belonging to the field of
logging. The method includes: allocating contiguous memory at the EL2 layer as a buffer and initializing a start
timestamp; collecting data when an event occurs, determining the
mask position, writing the
event type and description to a
bitmap, writing the relative duration to a preset position, and writing process and CPU information at a
fixed length to generate a fixed-length binary event
record; when aggregation conditions are met, aggregating the valid data in the buffer into a
composite event information structure via
memory copy to form a
package to be exported; writing the structure to a memory-mapped window area accessible only by EL1, allowing EL1 to read without
trapping into EL2; when the window changes from empty to non-empty, EL2 sends only one notification, allowing EL1 to continue reading without additional overhead. This reduces the overhead of cross-exception level notifications and traps, achieving efficient and secure structured log transmission.