Abstract
Applications in virtual machines (VMs) rely on the guest Operating System (OS), which views only virtualized hardware, creating a semantic gap between this abstraction and the real execution managed by the hypervisor and host OS. Existing paravirtualization techniques bridge this gap through service-specific solutions, but implementing and extending these solutions can require changes to guest kernel components and host-side support, such as adding new hypercalls. We present a generic framework combining one-time paravirtualization during deployment with host-injected extended Berkeley Packet Filter (eBPF) programs, allowing different services to reuse the same guest infrastructure. After this initial setup, new services can be introduced by supplying additional eBPF programs, without modifying the shared guest infrastructure. Our prototype demonstrates how the same framework supports CPU pinning, dynamic memory expansion, and firewall offloading. In the evaluated benchmarks, these services achieve approximately 3.4-fold throughput with hyperthread-aware CPU pinning compared with execution without this mechanism and approximately 2.7-fold speedup with dynamic memory expansion compared with a fixed-memory configuration that resorts to swapping. Firewall offloading preserves legitimate traffic under a denial-of-service attack that prevents communication with guest-side filtering. These results demonstrate the framework’s applicability across different services; the contribution lies in their implementation through a common, extensible infrastructure.
Keywords:
eBPF; CPU pinning; firewall; memory; paravirtualization; processing offload; virtualization 1. Introduction
Virtualization enables multiple virtual machines (VMs) to run concurrently on a single physical host, sharing hardware resources while maintaining isolation between guests and the host operating system (OS). Each VM runs its own guest OS and applications, offering benefits such as improved resource utilization, scalability, flexibility, and enhanced security.
Despite these advantages, virtualization also presents challenges. A key limitation is that guest operating systems interact only with virtual representations of hardware resources. This abstraction can lead to reduced performance and higher overhead compared to physical deployments. For example, high-performance applications may require dedicated CPUs or memory, but the guest OS can only allocate virtual equivalents, resulting in performance degradation. Similarly, a VM-based firewall can block unwanted traffic at the guest level, yet all packets still traverse the host, incurring additional processing costs.
The host can address these limitations without guest cooperation in two main ways. The first is to remove the distinction between virtual and physical resources: commonly done via static allocation or passthrough techniques. While effective in certain scenarios, these methods are costly and inflexible; for instance, if K VMs each require CPU cores, the host would need physical cores, which is rarely practical. A second approach is introspection: the ability of the host to inspect the internal state of VMs and translate virtual resource operations into actions on physical hardware [1,2]. However, the host typically sees only low-level binary data (e.g., memory pages, disk blocks) without the semantic context available to the guest OS. This disconnect, known as the semantic gap [1,3,4,5], is further amplified in confidential computing [6], where the host cannot inspect guest state at all.
A classic method to bridge the semantic gap is paravirtualization [7,8,9,10], in which the guest OS is modified to be aware of the virtual environment and to cooperate with the host, often by exposing kernel-level hints or instructions. While effective, this approach has significant drawbacks: a new paravirtual service, or enhancement of an existing one, can require guest-side kernel modifications, new modules, or host-side hypercall changes. These updates may require downtime or reboots, limiting flexibility and scalability.
Recent work continues to introduce specialized guest–host cooperation for resource management. UFO [11] coordinates CPU allocation through guest- and host-side kernel modules that exchange scheduling information using shared memory established through a hypercall. HyperAlloc [12] integrates VM memory reclamation with a hypervisor-accessible guest page-frame allocator and an allocation-time hypercall. These systems illustrate the continuing value of service-specific paravirtualization and motivate complementary infrastructure that simplifies implementing and extending services across resource-management domains.
Extending kernel functionality at the userspace/kernel interface also often requires intrusive changes. Here, the extended Berkeley Packet Filter (eBPF) offers an attractive alternative. Initially conceived as a packet-filtering mechanism in Berkeley Software Distribution (BSD) [13], eBPF in modern Linux has evolved into a powerful, safe, and highly versatile framework for in-kernel programmability [14]. It allows lightweight, sandboxed programs to run at predefined kernel hooks, supports offloading to hardware accelerators such as data processing units (DPUs) and programmable network interface cards (SmartNICs), and provides unprecedented visibility into low-level resource activity. Crucially, an in-kernel verifier statically analyzes eBPF programs before execution, checking compliance with the safety constraints imposed on the program type.
Complementary research explores how system visibility and extensibility can be reconciled with virtualization boundaries. 00SEVen [15] enables owner-controlled introspection of confidential VMs through protected in-VM agents; PageFlex [16] uses eBPF to support customizable Linux paging policies; and RosenBridge [17] enables guest-to-host offloading of storage-processing logic. These approaches address complementary aspects of inspection and resource management.
Building on eBPF’s programmability, this study investigates a generic, eBPF-based framework for implementing solutions to VM resource-management problems already addressed by service-specific paravirtualization techniques. Specifically, it aims to:
- Expose guest events and resource requirements to host services through a common mechanism.
- Support new paravirtual services through service-specific eBPF programs, reusing the same guest infrastructure.
- Demonstrate the applicability of this mechanism to CPU affinity, dynamic memory allocation, and firewall offloading.
To achieve these objectives, a guest agent receives host-provided eBPF programs, loads them into the guest kernel, and forwards their notifications to host-side services. This hybrid approach combines the flexibility of introspection with the efficiency of paravirtualization, without requiring guest kernel modifications or static resource allocations. New services can be deployed incrementally by installing additional eBPF programs, avoiding costly redeployment or downtime.
Compared to alternatives, eBPF provides direct access to selected internal kernel events. For example, ptrace supports process tracing but does not provide general hooks into kernel functions such as those involved in memory reclamation. Guest agents reading /proc or /sys are limited to the information exposed by those interfaces and may require service-specific processing or additional data transfers. Injected eBPF programs additionally undergo the kernel verifier’s checks before loading.
The approach introduced in [18] uses host-injected eBPF programs to observe guest applications’ CPU-affinity requests and enable corresponding host-side CPU pinning. Here, we extend this approach by establishing a communication channel between injected eBPF programs and external services, which can implement policies through QEMU (Quick EMUlator) or the host kernel. We demonstrate this extension through two additional use cases: dynamic memory expansion and firewall offloading. We implement a prototype for the QEMU hypervisor with Linux guests and hosts.
In summary, the main contributions of this paper are as follows:
- Extend the approach of [18] with a communication channel connecting injected eBPF programs to external services that implement policies through QEMU or the host kernel.
- Implement and evaluate two additional use cases—dynamic memory expansion and firewall offloading—alongside the CPU-pinning use case previously evaluated in [18].
- Demonstrate the effectiveness of program offloading over the Netronome SmartNIC to increase the performance of the firewall use case.
The source code for all the use cases is available at https://github.com/luigix25/eBPF-injection (accessed on 11 October 2026).
The rest of this paper is organized as follows. Section 2 provides a brief introduction to the basic principles underlying the eBPF mechanism. Next, in Section 3, we delve into the core of our proposal by presenting the details of our eBPF-based agnostic mechanism in its general form. Then, in Section 3.2, we explore three specific use cases, each of which is examined in detail. Section 4 describes the QEMU-based implementation, and Section 5 presents the experimental evaluation. In Section 6, we provide an overview of the current state of the art regarding practical countermeasures that have been proposed to address the semantic gap in virtual environments. Finally, in the Section 7, we summarize the main achievements of this paper and provide some concluding remarks.
2. Background
This section provides background on eBPF, the kernel-programming technology underlying the proposed framework.
eBPF is a powerful technology that allows user-defined code to be executed in kernel space, available for both the Linux kernel and Windows platforms [14,19]. Figure 1 provides a simplified overview of eBPF.
Figure 1.
Extended Berkeley Packet Filter simplified scheme.
Essentially, eBPF consists of an instruction set, memory objects, and helper functions. User-defined programs are written in high-level languages and compiled into bytecode, which is then verified in kernel space. Verifiability is a critical feature of eBPF because running user-space code inside the kernel introduces inherent security and stability risks. As a result, the eBPF instruction set imposes certain restrictions, such as limits on arbitrary loops. The verifier plays an important role in determining the type of eBPF program and restricting which kernel functions can be called and which data structures can be accessed by eBPF programs. This provides both security and stability.
In the Linux kernel, eBPF instructions are executed in a sandbox by a Berkeley Packet Filter (BPF) runtime, which consists of an interpreter and a Just-In-Time (JIT) compiler (to improve performance). Each eBPF program is linked to a specific code path within the kernel. Whenever this code path is traversed, the associated eBPF program is executed. Several types of code paths, called hooks, can be used, including tracepoints, kprobes, and perf events. By providing access to kernel data structures, developers can create and test new debugging code without having to recompile the entire kernel. Moreover, eBPF programs executed at their hook points can invoke helper functions. These functions are explicitly defined in a kernel whitelist and enable a wide range of tasks to be performed, greatly enhancing the overall flexibility and capabilities of the eBPF mechanism.
In addition, eBPF supports the management of stateful information that needs to persist between successive executions of the eBPF program and output results. For this purpose, special maps are used, which can be accessed both from the kernel and from userspace via appropriate application programming interfaces (APIs). These maps serve as a means of interaction and data exchange between the eBPF program and the surrounding environment.
Finally, eBPF programs can use CO-RE (Compile Once–Run Everywhere) to accommodate differences in kernel type layouts, improving portability across kernel versions. This encourages code reuse and promotes interoperability.
Kernel probes. As mentioned earlier, the execution of eBPF programs in the kernel is triggered by hooks, which encompass various functionalities defined in the kernel. These hooks include system calls, function entry and exit points, kernel probes, user probes, and network events [20].
In this paper, we focus primarily on kernel probes, which offer dynamic instrumentation capabilities within the Linux kernel. Kernel probes, also known as kprobes, allow developers to insert probe points at specific locations within the kernel code, such as function entry or exit points. When the execution reaches these probe points, the associated eBPF programs can be executed to perform custom actions, collect data, or modify the behavior of the kernel. One of the notable advantages of using kprobes with eBPF is the extremely low overhead they introduce.
By using kprobes and eBPF, developers can effectively trace and debug the execution of kernel code at runtime. They can gain valuable insight into kernel behavior and performance, diagnose problems, and dynamically monitor and analyze system operation.
3. Architecture
This section presents the architecture of the proposed extensible paravirtualization framework. We first describe how host services interact with the guest agent and injected eBPF programs then illustrate three use cases and discuss the trust assumptions governing host–guest interactions.
3.1. Our Idea
The core idea of our work is to create a generic, extensible paravirtualization framework that minimizes guest-side modifications while maximizing the host’s ability to understand and manage guest internal states. We achieve this by leveraging the introspection and programmability of eBPF to dynamically bridge the semantic gap between the host and guest operating systems.
Traditional paravirtualization can require modifying the guest kernel to add cooperative hypercalls or paravirtualized drivers for new services. This can limit flexibility, as new features or updates may require kernel recompilation or module updates, potentially causing guest downtime.
Our architecture inverts this paradigm. Instead of modifying the guest kernel for each service, we install a minimal, fixed set of components in the guest once during deployment (see Figure 2):
Figure 2.
Architecture of the extensible paravirtual infrastructure. External services send eBPF programs to the guest agent for loading into the guest kernel. The programs report guest events through ring buffers, and the agent forwards these events to the services. Thin solid lines indicate the control path, thick lines indicate the data path, and dotted lines indicate interactions through the QEMU Machine Protocol (QMP).
- A standard paravirtual device driver (e.g., ‘virtio-serial’).
- A userspace guest agent daemon.
These components establish a secure, bidirectional communication channel between the guest and the host hypervisor. This channel supports both the injection and management of eBPF programs in the guest kernel and the forwarding of their notifications to host-side services.
New paravirtual services are implemented primarily on the host side. Each service is composed of:
- A host-side service logic component (e.g., a Python script).
- One or more BPF programs designed to be injected into the guest kernel.
The service logic sends the eBPF programs through the communication channel to the guest agent. The agent loads them into the guest kernel, where they attach to predefined hooks. These programs silently monitor internal guest kernel events and states. The data they collect is written to eBPF ring buffers, which the guest agent polls and relays back to the host-side service logic.
Upon receiving this semantically rich data, the host-side service can make informed decisions and act upon the physical resources via the hypervisor’s management interface or the host kernel.
The framework exposes guest events to host-side services; application scheduling remains the responsibility of the guest OS, while the host OS schedules the virtual CPU threads. In the use cases below, external services translate guest CPU-affinity requests into host-side pinning and guest memory-pressure notifications into memory-allocation adjustments. A service can connect to multiple QEMU instances to coordinate resource allocation across co-located VMs. When concurrent demands compete for limited resources, arbitration belongs to that service’s policy; the framework provides the communication mechanism without prescribing a particular scheduling or allocation policy.
3.2. Use Cases
This section describes our approach in three use cases, corresponding to the three paravirtual services of Figure 2: an on-demand virtual CPU (vCPU) pinning service that pins host vCPU threads on demand from unmodified guest applications; an on-demand memory resizing service that automatically detects when the guest could actually benefit from additional system memory; an offloaded firewall service that transparently moves (some) guest firewall rules to where they can be most effective.
The main purpose of these use cases is to demonstrate that they can be implemented effectively and transparently using the proposed architecture, without the need for ad hoc code to be preemptively installed in the guest (other than the guest agent, of course).
On-demand vCPU pinning. CPU affinity, also known as CPU pinning, is a powerful technique for controlling the execution of a process on a specific set of CPUs. This approach offers many benefits, especially in scenarios that involve interconnected processes or threads that communicate in a non-blocking manner. By scheduling these processes on different CPUs, true concurrency can be achieved, improving overall performance. Unfortunately, the Linux scheduler does not always guarantee this behavior, making CPU affinity even more important.
Another situation where CPU affinity proves valuable is in Non-Uniform Memory Access (NUMA) architectures. In such systems, the cost of accessing resources such as RAM varies depending on the requesting CPU. By carefully selecting the CPU for each process, performance can be significantly improved.
However, when dealing with virtualized environments, the semantic gap arises between the guest and host systems. Attempting to bind a process to a specific CPU actually operates on a vCPU inside the physical machine; this action is invisible to the host, which is still free to schedule the vCPU thread—and the guest application process running on it—on any available physical CPU (pCPU). To overcome this challenge, we have devised a solution using a kprobe on the sched_setaffinity function. This internal kernel function is called whenever a process requests CPU affinity. The CPU affinity paravirtual service attaches an eBPF program to the function entry point; the program captures the CPU affinity mask and sends it back to the service. The service can then retrieve from QEMU the host thread identifiers of the vCPUs in the set and pin them to isolated pCPUs in the host. The program also writes in a map the process identifier of the guest process that has called sched_setaffinity; another program, attached to the do_exit kernel function, monitors this map to detect when all the guest processes pinned to a vCPU are terminated; it then notifies the service, which can in turn unpin the corresponding vCPU thread in the host.
At this point, it is important to note that Hyper-Threading (HT), the Intel’s implementation of Simultaneous Multi-Threading (SMT), introduces another layer of semantic gap. The CPU ordering for HT varies depending on whether the system is native or initiated using QEMU. This means that guest applications that attempted to pin two threads to two hyperthreads on the same guest core (e.g., to take advantage of cache locality) might actually end up running on separate host cores. To address this, a remapping function is required to fully enable HT. Consequently, each time an affinity mask is received and needs to be applied to the host system, it undergoes remapping to ensure seamless operation.
On-demand Memory Expansion. RAM allocation is a critical aspect of virtual machines. Ideally, VMs should request as much memory as they need to perform their tasks optimally. However, the host also wants to allocate them as little RAM as possible so that it can use the remaining memory for other purposes. Traditionally, this is achieved with memory ballooning [21]: a paravirtual device whose guest driver can allocate (inflate) and deallocate (deflate) memory within the guest by coordinating with the host; the guest memory allocated for the balloon is unavailable for other uses in the guest and can be reused by the host (e.g., allocated to other VMs).
While effective, the ballooning technique still has the limitation that it can only work with the memory originally allocated to the VM and cannot be used to give the VM more memory than anticipated at VM build time. The virtio-mem [22] technology, on the other hand, allows hotplugging and hotunplugging of memory from a running virtual machine with fine granularity. If the host needs to adjust the memory allocated to a VM, it can use the QEMU monitor to make the changes. However, due to the semantic gap, the host does not know the exact amount of free RAM available to the guest(s). As a result, the hypervisor (HV), such as QEMU in our case, does not have enough information to automatically allocate or deallocate memory to VMs. The ballooning technique solves this problem by hooking the paravirtual balloon guest driver into the memory pressure API in the guest kernel. Here, we show how we can achieve essentially the same effect for virtio-mem by using injected eBPF programs, thus gaining the usual eBPF benefits: there is no need to maintain and update an ad hoc paravirtual guest driver. This is particularly important in the context of memory management, where new heuristics are regularly developed and there is a constant need for fine-tuning.
In our prototype, we use a kprobe on the balance_pgdat internal kernel function. This function is called by the kswapd kernel thread, which is responsible for reclaiming pages when memory runs low. The underlying idea behind this use case is to provide the HV (QEMU) with information about the VM’s memory nearing full capacity. With this information, the HV can use virtio-mem to dynamically increase the amount of memory available to the guest system on demand.
Conversely, when the balance_pgdat function is not being called for a specific amount of time, the host can reclaim memory back from the VM in chunks. This dynamic memory resizing process ensures that the VMs have enough memory resources when needed, while also allowing the host to efficiently reclaim unused memory.
Transparently Offloaded Firewall. The firewall is another ideal use case for our framework. Network traffic destined for a virtual machine passes through the host machine, which is responsible for routing all the packets to the virtual network interface card (NIC) of the guest system. This operation can be computationally expensive and has a non-negligible impact on the CPU utilization, especially when dealing with high data rates, such as several Gigabits per second. During a Denial of Service (DoS) attack targeting the VM, the impact on both the host and guest machines is significant. The host machine experiences a high number of interrupt requests (IRQs) from the network card and the routing/copying operations of the packets, while the guest machine receives a large number of interrupts from the virtual NICs, which can overload the network stack.
Implementing a firewall that drops unwanted packets inside the VM may offer some benefits, as it reduces the overall CPU usage of the VM. However, in general, this dropping should be performed earlier, ideally at the host level, to save both host and guest CPU time. By filtering unwanted packets at the host level, the impact of DoS attacks can be mitigated, and only the legitimate traffic is forwarded to the VM, minimizing the computational overhead on both the host and guest machines.
Similar to the previous use cases, we used a kprobe on the nft_trans_rule_add kernel function to enable our optimization. This function is called each time a new rule is added to IPTables/NFTables. Our goal, using the kprobe, is to send this information to the host so that it can apply the same rule but with the benefit of not having to copy all the packets to the guest.
Once the rule information is received on the host side, there are several approaches that the host itself can take to handle this rule, for example:
- Recreate an equivalent rule in IPTables/nftables on the host for packets destined for the guest VM. The host can duplicate the rule configuration in its own firewall settings, allowing it to perform the filtering at the host level without forwarding all the packets to the guest.
- Create an XDP (eXpress Data Path) program that inspects all packets directed to the VM and is functionally equivalent to the rule. The host can create an XDP program running in its kernel that implements the same filtering logic as the rule.
- Offload the packet filtering to the NIC itself. Some modern network interface cards support hardware offloading of packet filtering rules. The host can configure the NIC to handle the filtering directly, further reducing the CPU overhead on both the host and guest.
3.3. Trust Model
The proposed architecture requires a certain amount of trust in the two directions of communication:
- From host to guest, when the guest accepts the eBPF programs coming from the host.
- From guest to host, when the guest sends back the output of the injected eBPF programs.
In both directions, a rogue sender may mislead and cause harm to the receiving partner.
Guest-to-host direction. The host must trust the guest to actually run the injected programs and transparently and timely send back their output. Take, for example, services that give the guest additional resources on demand, such as the ones we propose for on-demand vCPU pinning and on-demand memory expansion. A typical VM hosting service will have to manage many VMs, and a rogue guest may abuse these services by faking its demands to, e.g., pin large amounts of host resources and cause denial of service problems to other guests.
We think that the best way to handle this problem is to only design services where the guest can have no incentive in lying. For services that grant host resources (such as the vCPU pinning and memory resizing), this can be prevented if they are intended in reverse, i.e., the guests initially agree for a certain amount of resources that they need, and the paravirtual services are used to give them only when actually needed, thus reducing the costs for the guests and improving the attractiveness of the hosting service.
Other, more generic services must be designed by keeping this problem in mind. Let us consider, for example, the Offloaded Firewall service. Blindly extracting guest firewall rules and reapplying them in the host firewall can easily be abused by a rogue guest, for example, by redirecting traffic destined for other guests to itself. For this reason, the proposed service only extracts rules from the guest’s INPUT chain, i.e., from the rules that the guest firewall applies to packets that need to be received by the guest applications. Moreover, the rules are not offloaded as they are, but they are composed with an additional clause that selects only those packets that have the guest as the destination.
For example, suppose that VM A has address 192.0.2.10 and VM B has address 192.0.2.20. If A submits an INPUT rule that drops packets destined for B, the offloaded predicate becomes “destination = 192.0.2.20 AND destination = 192.0.2.10,” which cannot match any packet. A broader rule that drops all incoming packets is instead restricted to packets destined for A. The additional destination constraint must be derived from the host’s association with the requesting VM, rather than supplied by the guest. A traffic-redirection rule placed outside the INPUT chain is excluded from offloading.
Host-to-guest direction. The guest must run the host-provided guest agent with enough privileges to be able to download eBPF programs in the guest kernel (in recent kernels, the agent needs at least the CAP_BPF capability, and additional capabilities may be needed depending on context). However, the agent itself is relatively straightforward and is not subject to change after installation, so we think that it is not unreasonable to assume that the guest owners can trust it by simply inspecting the code before installing it. The dynamically injected eBPF programs require particular consideration, especially when attached to kprobes. Tracing helpers can provide broad read access to guest kernel and user-space memory, subject to kernel security restrictions. Such programs do not have unrestricted write access to guest memory: for example, bpf_probe_write_user() permits writes to the current task’s user-space memory only under specific execution conditions. Nevertheless, the ability to inspect sensitive data and, where permitted, modify user-space memory creates confidentiality and integrity risks that must be considered when authorizing a program. We can consider two scenarios: a classic one, and a “confidential computing” one. In the classic scenario, the host already has unrestricted access to the guest physical memory and can interpret it using introspection techniques: from a theoretical point of view, therefore, our proposal is not introducing any security issue that was not there before. It is true, however, that one of the points of our proposals is that eBPF makes these kind of activity easier, and this simplicity may help attackers to increase their effectiveness. Moreover, in the confidential computing scenario, the guest has its memory encrypted and inaccessible from the host context. In this case, the guest owner may want the benefits of the paravirtual services but is certainly unwilling to accept any untrusted eBPF program from the outside.
We have implemented two features to support accountability and deter abuse, assuming that the guest agent can be trusted: the agent accepts only eBPF programs signed by the host provider and logs each incoming program to a guest-chosen location. Signatures authenticate the programs as authorized by the provider’s signing key; this attribution depends on protecting that key against compromise. Retaining the signed programs allows the guest owner to inspect them and provides evidence attributable to the signing key. The intended protection is practical deterrence through auditability and non-repudiation: the prospect of detectable and attributable misuse may discourage abuse. Whether this deterrent is sufficient depends on the deployment’s trust relationships and accountability arrangements. For the classic scenario, this can actually be seen as an improvement over introspection techniques that are completely opaque to the guest owner.
The architecture can accommodate different program-acceptance policies. In conventional deployments, a tenant may authorize automatic acceptance of provider-signed programs and rely on auditability and accountability as practical deterrents to abuse. In confidential-computing deployments, the guest agent can instead refuse to load a program unless the tenant explicitly approves it. A valid provider signature would then establish provenance without constituting permission to execute.
Explicit approval makes the trust decision comparable to installing a paravirtual driver: the tenant authorizes guest-side code with the privileges needed to provide the service. The eBPF approach retains its advantages, including verifier checks and the ability to load and replace service-specific programs without modifying the guest kernel or maintaining a separate kernel driver for each service. Approval does not establish that a program is harmless; it places the decision to extend trust under the tenant’s control.
4. Implementation
This section details the practical realization of the proposed extensible paravirtualization architecture. It begins with a primer on the QEMU hypervisor, whose flexible, userspace-based design provides the ideal foundation for our implementation. We then describe our prototype solution, which leverages eBPF and a standard virtio-serial channel to enable the dynamic injection of paravirtual services from the host into a guest virtual machine. Finally, we conclude with a critical analysis of the architecture’s robustness against changes in the rapidly evolving Linux and QEMU ecosystems, a key consideration for long-term viability.
4.1. Qemu
QEMU is a versatile virtual machine monitor, originally created by Fabrice Bellard [23]. Bellard’s QEMU is an unprivileged userspace program that uses binary translation to emulate one of many different target CPU architectures on the same host CPU. Later [24], QEMU was adapted to make use of the much faster hardware-assisted virtualization introduced by AMD and Intel in their processors. In hardware-assisted virtualization, each logical CPU can run in a new “non-root” mode where it can safely execute guest code directly, provided that both guest and host share the same instruction set. While in this mode, the CPU monitors every instruction and external event and, when it detects an instruction/event that needs hypervisor intervention (e.g., an access to an I/O port or an external interrupt), it exits the non-root mode and yields back control to the hypervisor.
On Linux, QEMU uses hardware-assisted virtualization through the Kernel-based Virtual Machine (KVM) API introduced in the Linux kernel specifically to support this use case. KVM consists of a set of Linux kernel modules that implement a few ioctl() system calls on the /dev/kvm device. These ioctl()s allow sufficiently privileged Linux userspace programs to create new VMs and assign them part of their own resources.
For example, each QEMU instance runs in userspace and manages a single VM. QEMU allocates memory from the host using any of the standard APIs and then assigns it to the VM; it then spawns a new vCPU thread for each of the VM’s CPUs (see Figure 3). Each vCPU thread uses the ioctl(KVM_RUN) system call to enter the hardware non-root mode and safely execute guest code fetched from the VM’s memory. When the CPU exits non-root mode, control returns to the KVM module, which typically completes the ioctl(KVM_RUN) call, returning to userspace. The vCPU thread, now running QEMU code again, will resolve the condition that caused the non-root-mode exit (e.g., emulating the access to the virtual peripheral I/O port), and then it will issue another ioctl(KVM_RUN) to go back to non-root mode and resume guest code execution.
Figure 3.
QEMU basic architecture.
Internally, QEMU implements a complex and flexible object model that allows for the emulation of any virtual peripheral using any of a large set of compatible backends. Since QEMU is a normal program running in the host userspace, it can take full advantage of all the Linux facilities to implement its backends. For example, any emulated network device can be connected either to a TAP device on the host, or to a slirp userspace network stack, or to a TCP connection to another VM, or many other options.
Some QEMU threads, in addition to the vCPU threads, are dedicated to the emulation of peripherals and to the interaction with the host. For example, the “I/O” thread in Figure 3 runs in a select() loop, listening for read/write events on Linux file descriptors. Some of these descriptors are used by the virtual device’s backends, and others can be used to connect to external processes. External processes can interact with QEMU using messages encoded in the QEMU Machine Protocol (QMP [25]), a JavaScript Object Notation (JSON)-based protocol that can be used to extract information about the status and configuration of the VM and to send commands to dynamically update the VM configuration.
4.2. Our Solution
This section describes the proposed architecture for extensible paravirtualization. A fully functional prototype has been implemented for the QEMU hypervisor with Linux-based guests and hosts.
Figure 2 shows the main components and their interactions. The fixed infrastructure components ideally need to be installed only once per VM. They consist of the following: a paravirtual device (pv-device) emulated by the hypervisor; a driver for the above device (pv-driver) installed in the guest; a userspace daemon running in the guest userspace (guest agent). The other components may freely change whenever a new paravirtualized functionality is needed. Each one of them consists of the following: a paravirtual service where the service logic is implemented; one or more eBPF programs that collect data and events for the service; an eBPF map (of the ringbuf type) used to pass data from the eBPF programs to the guest agent.
The pv-device and its pv-driver are needed for the communication between the paravirtual services running on the host and the guest agent running inside the guest. Together, they create a simple bi-directional stream of bytes between QEMU and the guest agent. A module inside QEMU and a complementary one inside the guest agent implement a message-based connection-oriented protocol. The protocol gives each paravirtual service a private channel to talk to the guest agent.
The connection to a particular QEMU instance determines the VM with which a service communicates. The guest agent loads the supplied eBPF programs inside that VM and reports whether loading succeeded before the service begins processing notifications. This procedure attaches paravirtual functionality to an existing VM; it does not deploy or assign application tasks to VMs. Acceptance of the supplied programs is governed by the trust and authorization policies discussed in the Trust model subsection.
The paravirtual services can either run as part of QEMU or as external processes. When running as external processes, they communicate with QEMU through a socket, connected to the pv-device, to talk to the guest agent, and through a QMP port to talk to QEMU itself. This is the preferred way to implement the paravirtual services in our proposed architecture, since it brings the following benefits:
- Implementing services is much easier.
- It is easy to connect a single service to multiple QEMU instances.
- The service implementation is more robust against internal QEMU code changes.
For the first point, note that the external-service developer does not need to be an expert in QEMU internal. Perhaps more importantly, he or she can freely choose the implementation language of the service. For example, the host-side logic of the on-demand vCPU-pinning service described in Section 3.2 is entirely written in Python 3. This highlights one important use case for the proposed architecture, which is rapid prototyping of experimental paravirtual services, since both the host part and guest part of the new service can be implemented at a sufficiently high level of abstraction and can be easily replaced during experimentation.
The second point is important for services that manage global resources (like CPUs and memory), since assigning more resources of this kind to one VM may adversely affect co-located VMs. A single external service connected to all co-located QEMU instances is in the ideal position to make informed decisions about global resource allocations. Finally, for the third point, see Section 4.3 below.
The above benefits notwithstanding, the architecture also allows for services to be run as part of QEMU, using internal QEMU APIs to talk to the pv-device: services implemented in this way have access to some VM information that is not exported through QMP (e.g., the mapping between guest-physical and host-virtual addresses).
Once a channel between a service and the agent has been established, the typical interaction is as follows:
- The paravirtual service sends a messages to the guest agent; the message contains one or more eBPF program together with all the necessary information to download them into the guest kernel (e.g., in the case of kprobe programs, the hook name); at least one program is expected to define and use an eBPF ringbuf map with an agreed-upon name.
- On connection, the guest agent fork()s and the child process downloads the received programs according to the instructions, then reports the success/failure state back to the service; the parent process continues listening for new connections and commands.
- On receiving a successful reply, the service starts listening on the channel for notifications.
- After sending a successful reply, the guest agent child process starts polling the eBPF ringbuf using a timeout of 50 ms, transparently sending any new data back to the service.
- The service processes any incoming data, possibly interacting with QEMU via the QMP protocol to implement the service logic;
- Points 4 and 5 repeat for as long as the service is needed; when asked to exit, the service sends a message to the main process of the guest agent, signaling that it wants to close the channel.
- Upon receiving the close message, the agent kills the child process for this channel; since the eBPF programs for this channel had been downloaded by the terminated process, the guest kernel automatically discards them.
The fixed infrastructure supports program injection and notification forwarding, while service-specific policy logic resides on the host and acts through QEMU or the host kernel.
The interaction has been deliberately kept simple, and not much attention has been paid to the efficiency of the communication: we do not expect the paravirtual services to require frequent interaction with the guest nor to extract large amounts of data. Instead, the design was driven by other considerations, which we discuss below.
4.3. Robustness Against Infrastructure Changes
The main advantage of the proposed architecture is that new services can be added without any changes in the guest system, provided that the guest agent and pv-driver had been already installed; in most cases, the services can also be added without any changes to QEMU.
However, both QEMU and the Linux kernel are rapidly evolving projects, so it is very important to evaluate the robustness of the architecture w.r.t. upstream changes in these projects. What happens to existing paravirtual services when either the guest OS or QEMU is updated? In the case of the guest, we also face the problem of the diverse existing Linux distributions that may be installed inside the VM: can a paravirtual service be written once and then moved to other guests?
Our prototype uses a commodity-off-the-shelf virtio-serial device as the pv-device. Therefore, the pv-driver is distributed as part of the guest Linux kernel and the pv-device frontend is already implemented in QEMU. While we could have benefited from a more specialized device, the use of virtio-serial guarantees that these components are always automatically up to date and should be readily available in all Linux and QEMU installations.
The guest agent uses standard Linux system calls to inject the eBPF programs, read the ringbuf, and interact with the virtio-serial device. Since there is a strong commitment in the Linux community to always preserve binary compatibility at the syscall level, the guest agent is also relatively protected against guest kernel updates.
The paravirtual services, when implemented as external processes, depend on the following: (i) a socket interface, (ii) the QMP protocol, and (iii) the particular internal Linux kernel state that they wish to probe with eBPF programs. Items (i) and (ii) are standard, so only (iii) may cause problems. In fact, depending on the type of eBPF program, the guarantees against modification vary widely. In particular, there is no guarantee that kprobe hooks will remain the same from one version of the Linux kernel to the next. In practice, this is not a problem if the hook is at the entry point of a system call because of the strong commitment to compatibility at that level. However, most services depend on hooks on internal functions. These services may need to prepare different eBPF programs compiled for different versions of the Linux kernel or carefully choose their hooks from those that are unlikely to change. This problem can be partially mitigated by CO-RE, at least when the change only affects the layout of some structure, without changing the underlying semantics. However, the simplicity of loading and unloading eBPF programs still makes this problem an order of magnitude more tractable than the alternatives, such as maintaining a set of out-of-tree kernel patches or modules.
Paravirtual services running inside QEMU itself incur the additional risk of changes to the QEMU internal interfaces, which may render them non-functional. The best way to combat this would be to implement the necessary extensions to the QMP protocol and then move the services outside of QEMU.
5. Evaluation
This section presents an evaluation of the proposed architecture through the three distinct use cases described in Section 3.2. In all such cases, we present the experimental setup, the benchmarking methodology, and the key metrics, and we finally quantify the performance to assess the viability of our approach.
5.1. First Use Case: On-Demand vCPU Pinning
The CPU affinity service has been evaluated through benchmark tests using Lamport queues within a simplified version of the system proposed by Maffione et al. [26]. In this context, our experimental setup includes two threads: a producer and a consumer, both operating concurrently on a Single Producer Single Consumer (SPSC) queue. These threads handle the insertion and extraction of packets containing text messages from the queue. In all cases, the guest machine has two vCPUs, and the two application threads running in it attempt to pin themselves to separate vCPUs using pthread_setaffinity.
To accurately measure the performance of our approach, we used the sustained packet rate metric as the standard for measurement. In addition, to emulate real-world conditions and assess the robustness of the system, we subjected the host systems to configurable background loads executed on the cores running the benchmark tests. The amount of load was achieved by fork()ing n times a background CPU-hog task, effectively increasing the number of processes generating the computational burden. The experiments were run on an Intel i7 6700K with 32 GiB of RAM and Linux kernel v5.15.
The CPU-pinning service is intended for relatively infrequent affinity changes, rather than per-task notifications. Frequent repinning would undermine the placement stability and cache locality that affinity is intended to provide. Consequently, higher application load does not necessarily produce a higher notification rate. The experiments below examine application throughput under different background CPU loads; they do not measure sustained high-rate affinity changes. Adversarial affinity changes are a separate concern: private per-VM channels permit per-VM traffic control, but bounding host-side overhead additionally requires service-level admission or rate limits.
5.1.1. Performance Results
Two sets of experiments were conducted: the first focused on the use of virtual CPU pinning, while the second focused on virtual Hyper-Threading pinning.
Virtual CPU Pinning
Figure 4 shows the results obtained under two different scenarios. In the first setup, the host system remains unaffected by any background load, while in the second scenario, there is only a low processing load.
Figure 4.
Measured throughput w/ and w/o vCPU pinning under “No Load” and “Low Load” conditions. Mpps denotes million packets per second. Adapted from Figure 4 in [18], © 2022 Springer Nature Switzerland AG, used with permission. This figure is excluded from the CC BY 4.0 licence applying to this article.
As can be observed, in the “no load” scenario, there is no significant difference between using or not using paravirtualization. This is because there are no other processes in the idle host system that would preempt the CPU. In other words, whether the pinning is performed or not, there is no advantage in this scenario because the scheduler normally ensures that the process stays on the same pCPU, and no migrations occur.
However, as the load on the host increases, with 8 other processes running alongside the producer and consumer, the host scheduler attempts to balance the load across all available cores. As a result, processes, including the producer and consumer, are migrated from one pCPU to another, leading to cache content loss and a reduction in overall throughput.
In our system, this problem is effectively mitigated by pinning. The host scheduler is prevented from moving a process that is bound to a particular CPU, ensuring that the cache content remains intact. As a result, the negative impact on throughput caused by frequent migrations is avoided.
In the next experiment, we introduce serialization, which occurs when both the producer and consumer processes are scheduled on the same logical CPU (hardware thread). The serialization variable, which ranges from 0% to 20%, represents the percentage of time that both the producer and consumer processes are scheduled on the same logical CPU.
Figure 5 shows that in a heavily loaded system (32x), the overall throughput decreases as the value of this variable increases. This happens because the producer and consumer processes must share the same logical CPU and cannot run concurrently. However, this situation does not occur if vCPU pinning is enabled. In this case, the producer and consumer are pinned to two different cores, resulting in higher throughput.
Figure 5.
Measured throughput w/ and w/o vCPU pinning in the serialization scenarios under “High Load” conditions. Adapted from Figure 5 in [18], © 2022 Springer Nature Switzerland AG, used with permission. This figure is excluded from the CC BY 4.0 licence applying to this article.
Virtual Hyper Threading
As mentioned earlier, Hyper Threading (HT) exhibits a further semantic gap, and in Figure 6, we demonstrate its impact on throughput by comparing it against a system where the HT pinning technique is selected. For these comparisons, low and high loads were tested with and background load, respectively.
Figure 6.
Throughput on the system with and without HT pinning on "No Load", "Low Load", and "High Load" conditions. Adapted from Figure 6 in [18], © 2022 Springer Nature Switzerland AG, used with permission. This figure is excluded from the CC BY 4.0 licence applying to this article.
One interesting result that stands out is that the throughput is higher with the pinning technique for each scenario. This improvement is due to the fact that certain programs, such as the SPSC queues used in these experiments, benefit significantly from being executed on sibling hardware threads of the same physical core. This shared execution allows for efficient resource utilization, such as cache sharing, which leads to the observed performance improvement.
In Figure 7, we ran the same experiment to evaluate the impact of virtualization on overall performance. The plot reveals that there is no significant difference between executing directly on the physical machine and running in a virtual machine using hardware-assisted virtualization when vCPU pinning is enabled. This is because vCPU pinning ensures that the affinity information requested by the producer and consumer processes reaches the host machine, effectively bridging the semantic gap and allowing efficient resource allocation. However, this statement does not hold when vCPU pinning is not active. As explained earlier, this is the effect of the semantic gap, which prevents the information about affinity from reaching the host machine. In such cases, there can be a noticeable performance impact when executing in a virtual machine compared to running directly on the physical machine.
Figure 7.
Measured throughput w/ and w/o HT vCPU pinning in virtualized and physical environments under “No Load” and “Low Load” conditions. Adapted from Figure 8 in [18], © 2022 Springer Nature Switzerland AG, used with permission. This figure is excluded from the CC BY 4.0 licence applying to this article.
5.2. Second Use Case: On-Demand Memory Expansion
The experiments on dynamic RAM resizing were conducted using the h2 benchmark from the widely used DaCapo Benchmarks suite [27] version 9.12-MR1-bach. The DaCapo Benchmarks consist of a set of real-world applications with non-trivial memory loads. The h2 benchmark features an in-memory database and was chosen because it is not affected by other subsystems such as network and disk. The experiments were run on an Intel i7 6700K with 32 GiB of RAM and Linux kernel v5.15.
In Figure 8, we can observe our system in action. The cyan horizontal line represents the RAM already available to the system, while the blue line represents the total amount of RAM, which includes both the RAM added and the RAM already available. The orange line depicts the used RAM, and the green line shows the SWAP usage. The data for this plot was recorded during the execution of the benchmark.
Figure 8.
RAM and swap usage over time.
Notice that, as the RAM usage increases, the total RAM also increases due to our dynamic memory resizing mechanism in place. It dynamically provides more RAM to the VM as needed. However, at around 320 s, there is a spike in SWAP usage. This may have occurred because the program experienced a sudden increase in RAM usage, and our system was not fast enough to increase the allocated RAM before the operating system decided to use the SWAP. This can be mitigated by tuning the configuration parameters, such as the step height, to make the HV allocate more RAM each time the balance_pgdat function is called.
The main goal is to allocate as little RAM as possible to the VM without degrading its performance. As RAM usage decreases, the host begins to reclaim memory back from the VM in chunks, until it reaches the baseline RAM allocation. This dynamic adjustment ensures that the VM has sufficient resources during periods of high demand and allows the host to effectively reclaim unused memory when the VM’s workload decreases.
Figure 9 shows the time required to execute the same benchmark under three different scenarios:
Figure 9.
Time to execute the h2 benchmark in three different scenarios.
- Baseline: the system has enough RAM to perform the entire operation without resorting to swapping.
- Swapping (Dynamic Memory OFF): the system does not have enough RAM to complete the entire operation, so it must use the swap space.
- Dynamic Memory ON: the system does not have enough RAM initially, but it has the ability to increase RAM on demand using our dynamic RAM expansion mechanism.
As expected, the Baseline scenario is the fastest of the three. This is because the system has enough RAM to handle the entire operation, and there is no need for any RAM expansion techniques.
On the other hand, the Dynamic Memory OFF scenario is the slowest because it involves swapping, which is typically hosted on slower media such as hard disk drives (HDDs) or solid-state drives (SSDs), thus impacting performance.
Instead, the Dynamic Memory ON scenario is approximately faster than the swapping scenario. This improvement is achieved because our system dynamically increases the available RAM, reducing the reliance on swap usage, which can still occur occasionally, as shown in Figure 8. The small difference between the Dynamic Memory ON and Baseline setups is due to this occasional use of the swap space during the execution of the benchmark. Nevertheless, the dynamic memory approach significantly improves performance by effectively managing memory allocation according to the workload’s needs. Overall, our dynamic RAM expansion mechanism provides an efficient solution for improving performance in scenarios where the VM’s RAM requirements fluctuate, bridging the gap between having enough RAM and resorting to slower swap usage.
5.3. Third Use Case: Transparently Offloaded Firewall
The experimental setup for this use case consists of two identical servers, named whiskey and lace, both equipped with an Intel Xeon E5-1660 processor and 32 GiB of RAM. Both servers run version v5.15 of the Linux Kernel and are connected to each other through a direct 40 gigabits per second (Gbps) fiber link.
In this setup, QEMU is located on the whiskey machine, which is also equipped with a Netronome Agilio CX 2x40 Gbps NIC capable of hardware offloading of XDP programs. QEMU is connected to the external network via a TAP interface, leveraging the Linux routing capabilities for network communication. On the other side, the lace machine has a 40 Gbps Intel XL710 NIC, which is compatible with the netmap technology [28].
The purpose of these experiments is to evaluate the impact of a DoS attack on regular network traffic and to assess the effectiveness of the different countermeasures when our system is enabled/disabled. Two scenarios are considered: one when the system is under attack and one when it is not.
To simulate the attack, the lace server generates both “bad” (malicious) traffic using the netmap’s pkt-gen tool and “good” (legitimate) traffic using iperf3. On the other hand, the whiskey server hosts the virtual machine (VM) and is responsible for routing and dropping, if necessary, the incoming packets.
At this stage, three natural approaches could be considered:
- Nothing: this approach involves not using any countermeasure, serving as a baseline to measure the attack’s impact without any protection.
- IPTables on the guest: utilize IPTables, a well-known Linux firewall utility, to configure filtering rules for dropping unwanted packets on the virtual machine (VM).
- XDP on the guest: implement an XDP program and configure it to run on the guest OS kernel to filter and drop unwanted packets.
Using IPTables or XDP in the guest causes a reduction in CPU utilization, as shown in Table 1. The effect on legitimate traffic, however, is invisible: all of the above three approaches lead to the same miserable results observed in the Nothing scenario and reported in Figure 10 and Figure 11. In other words, implementing firewall rules and packet filtering in the guest OS proves to be ineffective, as the system resources are already burdened with packet handling [29]. Consequently, in all the figures, only the Nothing scenario is displayed to represent the null performance of the aforementioned approaches.
Table 1.
Number of host CPUs used at 100% during a DoS, for various mitigation strategies.
Figure 10.
Throughput in different scenarios using a TCP connection.
Figure 11.
Throughput in different scenarios using a UDP connection.
This is where our system comes into play. Indeed, our system allows the above countermeasures to be normally triggered in the guest OS but be transparently applied in the host OS in terms of IPTables rules and XDP programs.
Hence, the use of our system enables the following three scenarios:
- IPTables on the host: IPTables filtering rules are set on the host system.
- XDP on the host: an XDP program is implemented on the host system to filter and drop unwanted packets.
- XDP Offloaded to the host’s NIC: the XDP filtering logic is offloaded to the host’s NIC, leveraging its hardware capabilities to perform highly efficient packet filtering.
In practice, the user interacts with and sets IPTables rules within the guest OS as they normally would, but, behind the scenes, the enforcement of these rules takes place at the host OS level.
In Figure 10, the measured throughput (Gigabits per second) is presented when iperf3 generates traffic using TCP. As previously mentioned, in the absence of any countermeasures, the DoS attack successfully disrupts the service. Consequently, the iperf3 server is incapable of establishing a connection with the client inside the VM, resulting in an overall throughput of 0 Gigabits per second.
When using XDP on the host—specifically XDP loaded inside the NIC driver with the JIT (Just-In-Time) compiler enabled—the system effectively counteracts the DoS attack with only minor losses in terms of throughput. This approach efficiently handles the incoming traffic, providing effective defense against the DoS attack. IPTables also demonstrates effectiveness in countering the DoS attack. However, the results are less consistent if compared to XDP on the host. The best overall solution among the countermeasures tested was XDP with hardware offload. In this setup, the packets are filtered by the network card itself, dramatically reducing the impact on the CPU (see Table 1) for two reasons: first, no IRQs are raised for each unwanted packet, and second, no software filtering is necessary as the hardware itself handles the filtering burden.
One important observation is that XDP has a significant impact on the overall throughput, causing a reduction of approximately 40% even when no DoS attack is in place. To ensure that this behavior was not intrinsic to XDP itself, the same experiment was repeated using a different NIC, specifically the Intel E810-C. On the Intel E810-C card, XDP had a negligible impact on the throughput, indicating that it was not acting as a bottleneck in this case. This finding strongly suggests that the issue is likely related to the Netronome’s device driver used in conjunction with XDP.
In Figure 11, iperf3 was configured to use UDP. (In our setup, the UDP tests achieved a much lower throughput than the TCP tests. This is most likely due to the segmentation offloading optimization that is available for TCP connections passing through a VM. With segmentation offloading, the hypervisor is able to amortize the cost of interacting with the guest by building very large packets (typically 64 K) from the incoming frames.) The results indicate that, similar to the TCP scenario, when no DoS countermeasures are applied, the attack is successful, and no communication can be established. In terms of throughput, there is no significant difference between XDP with and without offload. However, as from the results of Table 1, XDP with hardware offload has a lower CPU footprint, making it a more efficient choice. Both XDP configurations effectively mitigate the DoS attack, and there is no notable difference in the throughput of “good” traffic when the attack is in progress versus when it is not. On the other hand, IPTables exhibits different behavior. When the system is not being targeted, IPTables does not act as a bottleneck. However, during the DoS attack, it is not as effective as the XDP solutions in mitigating the impact on the system.
In conclusion, our system proves highly effective in triggering responsive countermeasures to combat DoS attacks from within the guest OS. The triggering mechanism involves setting IPTables rules, which the system intercepts and seamlessly translates into either IPTables rules in the host OS or XDP programs to be executed in the host kernel or offloaded to compatible NICs. Incidentally, among the implemented solutions, XDP with hardware offload stands out as the optimal choice for mitigating DoS attacks and optimizing network performance. This approach offers several advantages, including high bandwidth and reduced CPU usage. Additionally, XDP without hardware offload remains effective against DoS attacks and does not require specialized hardware, but it may become a bottleneck in certain scenarios, particularly in TCP cases. While IPTables provides some level of protection against DoS attacks, it falls short compared to the effectiveness of XDP solutions, especially when hardware offload is employed. However, IPTables still offers significantly better protection than having no countermeasures in place at all.
6. Related Work
The widespread popularity of virtualization techniques for developing applications and services has determined an increasing (and obvious) interest towards possible approaches to address the effects of the semantic gap between host and guest machines [3]. This section highlights some notable work proposed in areas contiguous to our research, in particular concerning the three use cases of CPU affinity, dynamic memory resizing, and network security.
Recent approaches differ in where programmable logic executes and which interface they expose. PageFlex [16] connects userspace paging policies with Linux memory-management mechanisms, whereas the proposed framework connects guest events with host-side services across the VM boundary. RosenBridge [17] introduces a paravirtual device through which guests offload storage-processing programs to a userspace BPF runtime in the host. Our framework instead deploys host-provided eBPF programs inside the guest and forwards their output to external services. For confidential VMs, 00SEVen [15] provides a protected forensic agent isolated from both the cloud platform and the monitored guest OS. The tenant-approval policy discussed here governs acceptance of injected programs; it does not provide the protected-agent isolation offered by 00SEVen.
In general terms, setting the CPU affinity of an application running in a virtual machine means binding its execution threads to the virtual threads running the VM, instead of pinning a subset of the physical cores of the machines. The classic way to solve this problem is to partially remove the distinction between virtual and hardware resources, for example, by statically pinning each virtual CPU thread to an isolated hardware CPU thread. While this solution is effective, it can be unnecessarily expensive if the application workload changes.
A different, more dynamic approach is proposed in [30]. In their work, Lee and Eom propose to include appropriate hypercalls in the guest kernel to pass scheduling decisions to the hypervisor, which in turn applies them to the host system. As a matter of fact, this turns out to be an example of paravirtualization [7], as the guest system is somewhat informed of running inside a virtual machine. The same topic has also recently been explored in [31], where the authors evaluate the performance overhead of containers, virtual machines, and bare-metal execution platforms in CPU-intensive use cases and propose a set of best practices for efficiently deploying cloud-based applications. More recently, UFO [11] coordinates guest and host CPU allocation for latency-critical workloads in oversubscribed clouds. Guest- and host-side kernel modules exchange CPU utilization, scheduling frequency, and core-allocation information through shared memory established using a hypercall. This is a dedicated coordination mechanism for CPU management, whereas our framework provides a common channel for implementing services across resource-management domains. The mechanisms proposed by Lee and Eom and by UFO rely on service-specific guest–host cooperation. Our proposed solution, instead, tries to bring the advantages of eBPF in terms of ease of development and experimentation also in the domain paravirtualization.
The application of eBPF-based paravirtualization to vCPU-pinning had been previously described in [18]. However, CPUs are not the only resource that cannot be easily managed because of the semantic gap between host and guest machines. In fact, memory is another example where the hypervisor cannot recognize the amount of virtual resource available to the tasks running in the VMs. One of the pioneering approaches to overcome this problem was presented in [32], where the authors proposed predictive techniques for RAM management based on continuous monitoring of the guest machine’s swap space. The measurement activity was performed by a guest agent, which was later removed in [33]. In fact, in the latter paper, the authors do not even try to close the semantic gap and gain insight into the guest memory status (to possibly resize it) from memory access bandwidth, physical memory footprint, and page fault frequency.
Another predictive system that takes advantage of a userspace daemon running inside the VMs to collect information is proposed in [34]. All of this information is sent to the host to manage RAM allocation among all of the deployed VMs using the ballooning technique. Bielski et al. [35] introduce a technique similar to virtio-mem [22] to achieve runtime balancing of RAM among VMs.
HyperAlloc [12] integrates memory reclamation with a guest page-frame allocator accessible to the hypervisor. Its prototype replaces the guest’s buddy allocator with LLFree and uses an allocation-time hypercall to restore reclaimed memory. This specialized integration targets efficient VM memory reclamation; our memory-expansion use case instead reports guest memory-pressure events through injected eBPF programs to an external service controlling virtio-mem.
Other notable research can be classified into three main models of Virtual Machine Introspection (VMI): Out-of-band, In-band, and Derivative. Out-of-band VMI uses a separate VM to monitor the target VM and relies on external data sources such as memory snapshots or disk images. In-band VMI runs the monitoring code inside the target VM and uses system calls or hooks to access the internal state. Derivative VMI uses the hypervisor or Virtual Machine Manager to intercept events or instructions from the target VM and reconstructs the semantic state based on the execution context.
Each model has its own strengths and weaknesses in solving the semantic gap problem. Out-of-band VMI can provide strong isolation and stealth, but it can suffer from data inconsistency and incompleteness. In-band VMI can access rich semantic information, but it can introduce performance overhead and vulnerability risks. Derivative VMI can achieve high efficiency and accuracy, but it can require complex logic and knowledge of the guest operating system.
Virtuoso [1] is a derivative VMI system that uses dynamic binary analysis and symbolic execution to automatically infer the semantics of guest OS data structures and functions. LibVMI [4] provides a common API for out-of-band VMI tools and supports multiple hypervisors and guest operating systems. Nitro [36] is a derivative VMI system that uses hardware virtualization extensions to intercept system calls and extract semantic information from the guest OS kernel.
The last domain where the impact of the semantic gap will be investigated is networking (at large), with a special focus on the security aspects. In this specific case, the main issue is how to let VMs tell the hypervisor what is the data to filter out and how to trigger the appropriate mechanisms to protect the VM networks from receiving unwanted traffic. Analogous to our work, several proposals from both industry and academia have explored the use of eBPF on the Express Data Path (XDP). While paper [20] introduces the XDP technology, its potential, implementation, and possible benchmarks, Hohlfeld et al. [37] elaborate on its performance. In particular, the authors experiment with XEN and VMs over XDP and evaluate the CPU resource savings while offloading computation to either the host machine or the Netronome SmartNic [38].
Cilium [39] is an open-source project that leverages eBPF to provide networking and security capabilities for container environments. It provides fine-grained network policy enforcement, load balancing, and network visibility for containerized applications. Using eBPF, Cilium can efficiently handle large numbers of network connections and dynamically scale with the container ecosystem.
Cloudflare has used eBPF extensively to enhance its Distributed Denial of Service (DDoS) mitigation capabilities. Using eBPF, they propose Gatebot [40] and L4Drop [41] to efficiently analyze network traffic, detect and mitigate DDoS attacks in real time, and provide accurate traffic statistics to customers.
Tracee [42] from Aqua Security is a security and observability tool that uses eBPF to capture system events and analyze their behavior. It enables the detection of suspicious activity such as file system modifications, network connections, and process creation, providing valuable insight for security monitoring and incident response.
Katran [43] is a scalable software load balancer developed by Facebook. It uses eBPF to achieve high performance packet processing and distribution across multiple backend servers. By leveraging the capabilities of eBPF, Katran provides efficient load balancing while reducing the overhead and latency typically associated with traditional load balancers. Facebook also explored eBPF’s potential for DDoS protection. By deploying eBPF programs on its servers, Facebook can efficiently detect and mitigate DDoS attacks by analyzing network traffic and applying dynamic filtering rules at high speed [44].
IOVisor [45] is an open-source project from the Linux Foundation that aims to simplify the development and deployment of eBPF programs for various use cases, including networking, security, and performance analysis. It provides a framework and tools that enable developers to write and deploy eBPF programs across different kernel versions and distributions.
7. Conclusions
We presented a generic framework connecting host-injected guest eBPF programs to external services that apply policies through QEMU or the host kernel. After deployment of the shared guest infrastructure, additional services can be introduced without modifying that infrastructure. The demonstrated services operate without changes to guest applications, while acceptance of injected programs follows the tenant’s authorization policy. To validate the practicality and effectiveness of our solution, we developed a system prototype based on QEMU hypervisors and Linux hosts and guests. We described the prototype in detail and demonstrated its application in three practical use cases, showcasing its practical use and effectiveness in real-world scenarios.
Author Contributions
Conceptualization, G.L. and G.P.; methodology, G.A., G.L. and L.L.; software, L.L.; validation, G.A., G.L. and G.P.; investigation, L.L.; resources, G.P.; writing—original draft preparation, G.L., G.P. and L.L.; writing—review and editing, G.A.; visualization, G.L., G.P. and L.L.; supervision, G.L.; project administration, G.P.; funding acquisition, G.P. All authors have read and agreed to the published version of the manuscript.
Funding
This work was partially supported by the Italian Ministry of University and Research (MUR) through the FoReLab project under the Departments of Excellence programme (2023–2027), and by the Smart Networks and Services Joint Undertaking (SNS JU) under the European Union’s Horizon Europe programme, grant agreement No. 101192462 (FLECON-6G).
Data Availability Statement
The source code used in this study is publicly available at https://github.com/luigix25/eBPF-injection (accessed on 11 October 2026). The raw measurement data supporting the findings of this study is available from the corresponding author upon reasonable request.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Dolan-Gavitt, B.; Leek, T.; Zhivich, M.; Giffin, J.; Lee, W. Virtuoso: Narrowing the Semantic Gap in Virtual Machine Introspection. In Proceedings of the 2011 IEEE Symposium on Security and Privacy, Oakland, CA, USA, 22–25 May 2011; pp. 297–312. [Google Scholar] [CrossRef] [Scilit]
- Amit, N.; Wei, M. The design and implementation of hyperupcalls. In Proceedings of the 2018 USENIX Annual Technical Conference (USENIX ATC 18), Boston, MA, USA, 11–13 July 2018; pp. 97–112. [Google Scholar]
- Xu, X.; Zhao, B.; Wang, X.; Zhao, R. Research on Semantic Gap Problem of Virtual Machine. Wirel. Pers. Commun. 2017, 97, 5983–6004. [Google Scholar] [CrossRef] [Scilit]
- Xiong, H.; Liu, Z.; Xu, W.; Jiao, S. Libvmi: A Library for Bridging the Semantic Gap between Guest OS and VMM. In Proceedings of the 2012 IEEE 12th International Conference on Computer and Information Technology, Chengdu, China, 27–29 October 2012; pp. 549–556. [Google Scholar] [CrossRef] [Scilit]
- Li, H.; Liu, K.; Liang, T.; Li, Z.; Lu, T.; Chang, Y.; Yuan, H.; Xia, Y.; Bao, Y.; Chen, M.; et al. MARB: Bridge the Semantic Gap between Operating System and Application Memory Access Behavior. In Proceedings of the 2023 Design, Automation & Test in Europe Conference & Exhibition (DATE), Antwerp, Belgium, 17–19 April 2023; pp. 1–6. [Google Scholar]
- Ahmad, A.; Schultz, A.; Lee, B.; Fonseca, P. An Extensible Orchestration and Protection Framework for Confidential Cloud Computing. In Proceedings of the 17th USENIX Symposium on Operating Systems Design and Implementation (OSDI 23), Boston, MA, USA, 10–12 July 2023; pp. 173–191. [Google Scholar]
- Barham, P.; Dragovic, B.; Fraser, K.; Hand, S.; Harris, T.; Ho, A.; Neugebauer, R.; Pratt, I.; Warfield, A. Xen and the art of virtualization. ACM SIGOPS Oper. Syst. Rev. 2003, 37, 164–177. [Google Scholar] [CrossRef] [Scilit]
- Youseff, L.; Wolski, R.; Gorda, B.; Krintz, C. Paravirtualization for HPC systems. In Proceedings of the Frontiers of High Performance Computing and Networking–ISPA 2006 Workshops: ISPA 2006 International Workshops, FHPCN, XHPC, S-GRACE, GridGIS, HPC-GTP, PDCE, ParDMCom, WOMP, ISDF, and UPWN, Sorrento, Italy, 4–7 December 2006; Springer: Berlin/Heidelberg, Germany, 2006; pp. 474–486. [Google Scholar]
- Amiri Sani, A.; Boos, K.; Qin, S.; Zhong, L. I/O paravirtualization at the device file boundary. ACM SIGARCH Comput. Archit. News 2014, 42, 319–332. [Google Scholar] [CrossRef] [Scilit]
- Maffione, V.; Lettieri, G.; Rizzo, L. BPFHV: Adaptive network paravirtualization for continuous Cloud Provider evolution. In Proceedings of the 2019 ACM/IEEE Symposium on Architectures for Networking and Communications Systems (ANCS), Cambridge, UK, 24–25 September 2019; pp. 1–7. [Google Scholar]
- Peng, Y.; Chen, S.; Zhao, Y.; Yu, Z. UFO: The Ultimate QoS-Aware Core Management for Virtualized and Oversubscribed Public Clouds. In Proceedings of the 21st USENIX Symposium on Networked Systems Design and Implementation (NSDI 24), Santa Clara, CA, USA, 16–18 April 2024; pp. 1511–1530. [Google Scholar]
- Wrenger, L.; Albes, K.; Wurps, M.; Dietrich, C.; Lohmann, D. HyperAlloc: Efficient VM Memory De/Inflation via Hypervisor-Shared Page-Frame Allocators. In Proceedings of the Twentieth European Conference on Computer Systems (EuroSys’25), Rotterdam, The Netherlands, 30 March–3 April 2025; Association for Computing Machinery: New York, NY, USA, 2025; pp. 702–719. [Google Scholar] [CrossRef] [Scilit]
- McCanne, S.; Jacobson, V. The BSD Packet Filter: A New Architecture for User-level Packet Capture. In Proceedings of the USENIX Winter 1993 Conference, San Diego, CA, USA, 25–29 January 1993. [Google Scholar]
- Starovoitov, A. [PATCH Net-Next] Extended BPF. 2013. Available online: https://lkml.iu.edu/1309.3/04374.html (accessed on 11 October 2026).
- Schwarz, F.; Rossow, C. 00SEVen—Re-enabling Virtual Machine Forensics: Introspecting Confidential VMs Using Privileged in-VM Agents. In Proceedings of the 33rd USENIX Security Symposium (USENIX Security 24), Philadelphia, PA, USA, 14–16 August 2024; pp. 1651–1668. [Google Scholar]
- Yelam, A.; Wu, K.; Guo, Z.; Yang, S.; Shashidhara, R.; Xu, W.; Novaković, S.; Snoeren, A.C.; Keeton, K. PageFlex: Flexible and Efficient User-space Delegation of Linux Paging Policies with eBPF. In Proceedings of the 2025 USENIX Annual Technical Conference (USENIX ATC 25), Boston, MA, USA, 7–9 July 2025; pp. 291–306. [Google Scholar]
- Qiu, S.; Wang, L.; Yan, J.; Xiong, R.; Yang, L.; Yao, X.; Chen, R.; Zhang, G.; Li, D.; Shu, J.; et al. RosenBridge: A Framework for Enabling Express I/O Paths Across the Virtualization Boundary. In Proceedings of the 24th USENIX Conference on File and Storage Technologies (FAST 26), Santa Clara, CA, USA, 24–26 February 2026; pp. 425–441. [Google Scholar]
- Leonardi, L.; Lettieri, G.; Pellicci, G. eBPF-based Extensible Paravirtualization. In Proceedings of the High Performance Computing. ISC High Performance 2022 International Workshops; Anzt, H., Bienz, A., Luszczek, P., Baboulin, M., Eds.; Springer: Cham, Switzerland, 2022; pp. 383–393. [Google Scholar]
- Microsoft. eBPF for Windows. 2022. Available online: https://github.com/microsoft/ebpf-for-windows (accessed on 11 October 2026).
- Høiland-Jørgensen, T.; Brouer, J.D.; Borkmann, D.; Fastabend, J.; Herbert, T.; Ahern, D.; Miller, D. The EXpress Data Path: Fast Programmable Packet Processing in the Operating System Kernel. In Proceedings of the CoNEXT ’18: 14th International Conference on Emerging Networking EXperiments and Technologies, Heraklion, Greece, 4–7 December 2018; ACM: New York, NY, USA, 2018; pp. 54–66. [Google Scholar] [CrossRef] [Scilit]
- Liu, H.; Jin, H.; Liao, X.; Deng, W.; He, B.; Xu, C.z. Hotplug or Ballooning: A Comparative Study on Dynamic Memory Management Techniques for Virtual Machines. IEEE Trans. Parallel Distrib. Syst. 2015, 26, 1350–1363. [Google Scholar] [CrossRef] [Scilit]
- Hildenbrand, D.; Schulz, M. Virtio-mem: Paravirtualized memory hot (un) plug. In Proceedings of the 17th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, Virtual, 16 April 2021; pp. 1–14. [Google Scholar]
- Bellard, F. QEMU, a fast and portable dynamic translator. In Proceedings of the USENIX Annual Technical Conference, FREENIX Track, Anaheim, CA, USA, 10–15 April 2005; USENIX Association: Berkeley, CA, USA, 2005; pp. 41–46. [Google Scholar]
- Kivity, A.; Kamay, Y.; Laor, D.; Lublin, U.; Liguori, A. kvm: The Linux virtual machine monitor. In Proceedings of the Linux Symposium, Ottawa, ON, Canada, 27–30 June 2007; Volume 1, pp. 225–230. [Google Scholar]
- QEMU QMP Reference Manual. Available online: https://www.qemu.org/docs/master/interop/qemu-qmp-ref.html (accessed on 11 October 2026).
- Maffione, V.; Lettieri, G.; Rizzo, L. Cache-aware design of general-purpose Single-Producer–Single-Consumer queues. Softw. Pract. Exp. 2018, 49, 748–779. [Google Scholar] [CrossRef] [Scilit]
- Blackburn, S.M.; Garner, R.; Hoffmann, C.; Khang, A.M.; McKinley, K.S.; Bentzur, R.; Diwan, A.; Feinberg, D.; Frampton, D.; Guyer, S.Z.; et al. The DaCapo Benchmarks: Java Benchmarking Development and Analysis. SIGPLAN Not. 2006, 41, 169–190. [Google Scholar] [CrossRef] [Scilit]
- Rizzo, L. netmap: A novel framework for fast packet I/O. In Proceedings of the 2012 USENIX Annual Technical Conference (USENIX ATC 12), Boston, MA, USA, 13–15 June 2012; pp. 101–112. [Google Scholar]
- Lettieri, G.; Maffione, V.; Rizzo, L. A Study of I/O Performance of Virtual Machines. Comput. J. 2017, 61, 808–831. [Google Scholar] [CrossRef] [Scilit]
- Lee, T.; Eom, Y.I. VCPU Prioritization Interface for Improving the Performance of Latency-Critical Tasks. In Proceedings of the 2020 14th International Conference on Ubiquitous Information Management and Communication (IMCOM), Taichung, Taiwan, 3–5 January 2020; pp. 1–4. [Google Scholar] [CrossRef] [Scilit]
- Ghatrehsamani, D.; Denninnart, C.; Bacik, J.; Amini Salehi, M. The Art of CPU-Pinning: Evaluating and Improving the Performance of Virtualization and Containerization Platforms. In Proceedings of the ICPP ’20: 49th International Conference on Parallel Processing—ICPP, Virtual Event, 17–20 August 2020; Association for Computing Machinery: New York, NY, USA, 2020. [Google Scholar] [CrossRef] [Scilit]
- Zhao, W.; Wang, Z. Dynamic Memory Balancing for Virtual Machines. In Proceedings of the VEE ’09: 2009 ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, Washington, DC, USA, 11–13 March 2009; pp. 21–30. [Google Scholar] [CrossRef] [Scilit]
- Yao, L.; Li, Y.; Li, J.; Wu, W.; Xu, Y. Progressive Memory Adjustment with Performance Guarantee in Virtualized Systems. In Proceedings of the ICPP ’21: 50th International Conference on Parallel Processing, Virtual Event, 9–12 August 2021. [Google Scholar] [CrossRef] [Scilit]
- Zhang, Q.; Liu, L.; Ren, J.; Su, G.; Iyengar, A. iBalloon: Efficient VM Memory Balancing as a Service. In Proceedings of the 2016 IEEE International Conference on Web Services (ICWS), San Francisco, CA, USA, 27 June–2 July 2016; pp. 33–40. [Google Scholar] [CrossRef] [Scilit]
- Bielski, M.; Rigo, A.; Pacalet, R. Dynamic Guest Memory Resizing—Paravirtualized Approach. In Proceedings of the 2019 27th Euromicro International Conference on Parallel, Distributed and Network-Based Processing (PDP), Pavia, Italy, 13–15 February 2019; pp. 181–186. [Google Scholar] [CrossRef] [Scilit]
- Nitro—Virtual Machine Introspection Framework. Available online: https://soft.github.io/nitro/ (accessed on 11 October 2026).
- Hohlfeld, O.; Krude, J.; Reelfs, J.H.; Rüth, J.; Wehrle, K. Demystifying the Performance of XDP BPF. In Proceedings of the 2019 IEEE Conference on Network Softwarization (NetSoft), Paris, France, 24–28 June 2019; pp. 208–212. [Google Scholar] [CrossRef] [Scilit]
- Kicinski, J.; Viljoen, N. eBPF Hardware Offload to SmartNICs: cls bpf and XDP. In Proceedings of the Netdev 1.2: The Technical Conference on Linux Networking, Tokyo, Japan, 5–7 October 2016. [Google Scholar]
- Cilium. eBPF-Based Networking, Observability, Security. Available online: https://cilium.io/ (accessed on 11 October 2026).
- CloudFlare. Meet Gatebot—A Bot That Allows Us to Sleep. Available online: https://blog.cloudflare.com/meet-gatebot-a-bot-that-allows-us-to-sleep/ (accessed on 11 October 2026).
- CloudFlare. L4Drop: XDP DDoS Mitigations. Available online: https://blog.cloudflare.com/l4drop-xdp-ebpf-based-ddos-mitigations/ (accessed on 11 October 2026).
- Aqua Security. Aqua Tracee: Runtime eBPF Threat Detection Engine. Available online: https://www.aquasec.com/products/tracee/ (accessed on 11 October 2026).
- Facebook. Open-Sourcing Katran, a Scalable Network Load Balancer. Available online: https://engineering.fb.com/2018/05/22/open-source/open-sourcing-katran-a-scalable-network-load-balancer/ (accessed on 11 October 2026).
- Cilium. Deep Dive into Facebook’s BPF Edge Firewall. Available online: https://cilium.io/blog/2018/11/20/fb-bpf-firewall/ (accessed on 11 October 2026).
- The Linux Foundation Project. The IO Visor Project. Available online: https://iovisor.org/ (accessed on 11 October 2026).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.










