-
Notifications
You must be signed in to change notification settings - Fork 25
Vm flow analysis #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arfio
merged 3 commits into
eclipse-tracecompass-incubator:master
from
beliosien:vm-flow-analysis
May 12, 2026
Merged
Vm flow analysis #265
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...ass/incubator/internal/virtual/machine/analysis/core/flow/analysis/ExecutionSequence.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 École Polytechnique de Montréal | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License 2.0 which | ||
| * accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| *******************************************************************************/ | ||
| package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Represents a complete execution sequence in a virtualized environment: | ||
| * <pre> | ||
| * VM ENTRY → GUEST → VM EXIT → Hypervisor (Host) → VM Entry | ||
| * </pre> | ||
| * <p> | ||
| * This class aggregates events occurring in both the guest and the hypervisor, | ||
| * as well as the VM exit and entry transitions that connect them. | ||
| * </p> | ||
| * | ||
| * @author Francois Belias | ||
| */ | ||
| public class ExecutionSequence { | ||
|
|
||
| /** | ||
| * List of events that occurred in the guest before the VM exit. | ||
| */ | ||
| private final List<FlowEvent> fGuestEvents = new ArrayList<>(); | ||
|
|
||
| /** | ||
| * List of events that occurred in the hypervisor (host) | ||
| * between VM exit and VM entry. | ||
| */ | ||
| private final List<FlowEvent> fHypervisorEvents = new ArrayList<>(); | ||
|
|
||
| /** | ||
| * Event representing the VM exit (transition from guest to host). | ||
| */ | ||
| private FlowEvent fVmExit; | ||
|
|
||
| /** | ||
| * Event representing the VM entry (transition from host back to guest). | ||
| */ | ||
| private FlowEvent fVmEntry; | ||
|
|
||
| /** | ||
| * Adds an event to the guest event list. | ||
| * | ||
| * @param event | ||
| * the guest event to add | ||
| */ | ||
| void addGuestEvent(FlowEvent event) { | ||
| fGuestEvents.add(event); | ||
| } | ||
|
|
||
| /** | ||
| * Adds an event to the hypervisor event list. | ||
| * | ||
| * @param event | ||
| * the hypervisor event to add | ||
| */ | ||
| void addHypervisorEvent(FlowEvent event) { | ||
| fHypervisorEvents.add(event); | ||
| } | ||
|
|
||
| /** | ||
| * Sets the VM exit event. | ||
| * | ||
| * @param event | ||
| * the VM exit event | ||
| */ | ||
| void setVmExit(FlowEvent event) { | ||
| this.fVmExit = event; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the VM entry event. | ||
| * | ||
| * @param event | ||
| * the VM entry event | ||
| */ | ||
| void setVmEntry(FlowEvent event) { | ||
| this.fVmEntry = event; | ||
| } | ||
|
|
||
| /** | ||
| * Indicates whether the execution sequence is complete. | ||
| * <p> | ||
| * A sequence is considered complete if it contains: | ||
| * <ul> | ||
| * <li>At least one guest event</li> | ||
| * <li>A VM exit event</li> | ||
| * <li>A VM entry event</li> | ||
| * </ul> | ||
| * </p> | ||
| * | ||
| * @return {@code true} if the sequence is complete, {@code false} otherwise | ||
| */ | ||
| boolean isComplete() { | ||
| return !fGuestEvents.isEmpty() && fVmExit != null && fVmEntry != null; | ||
| } | ||
| } |
104 changes: 104 additions & 0 deletions
104
...compass/incubator/internal/virtual/machine/analysis/core/flow/analysis/ExitReasonMap.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 École Polytechnique de Montréal | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License 2.0 which | ||
| * accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| *******************************************************************************/ | ||
| package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
|
|
||
| /** | ||
| * Mapping of Exit reason number to their text description | ||
| * | ||
| * @author Francois Belias | ||
| */ | ||
| public class ExitReasonMap { | ||
|
|
||
| private static final Map<Integer, String> fExitReasonMap = new HashMap<>(); | ||
|
|
||
| static { | ||
| // VMX specific reasons | ||
| fExitReasonMap.put(0x80000000, "VMX_EXIT_REASONS_FAILED_VMENTRY"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(0x08000000, "VMX_EXIT_REASONS_SGX_ENCLAVE_MODE"); //$NON-NLS-1$ | ||
|
|
||
| // General exit reasons | ||
| fExitReasonMap.put(0, "EXIT_REASON_EXCEPTION_NMI"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(1, "EXIT_REASON_EXTERNAL_INTERRUPT"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(2, "EXIT_REASON_TRIPLE_FAULT"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(3, "EXIT_REASON_INIT_SIGNAL"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(4, "EXIT_REASON_SIPI_SIGNAL"); //$NON-NLS-1$ | ||
|
|
||
| fExitReasonMap.put(7, "EXIT_REASON_INTERRUPT_WINDOW"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(8, "EXIT_REASON_NMI_WINDOW"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(9, "EXIT_REASON_TASK_SWITCH"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(10, "EXIT_REASON_CPUID"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(12, "EXIT_REASON_HLT"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(13, "EXIT_REASON_INVD"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(14, "EXIT_REASON_INVLPG"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(15, "EXIT_REASON_RDPMC"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(16, "EXIT_REASON_RDTSC"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(18, "EXIT_REASON_VMCALL"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(19, "EXIT_REASON_VMCLEAR"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(20, "EXIT_REASON_VMLAUNCH"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(21, "EXIT_REASON_VMPTRLD"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(22, "EXIT_REASON_VMPTRST"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(23, "EXIT_REASON_VMREAD"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(24, "EXIT_REASON_VMRESUME"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(25, "EXIT_REASON_VMWRITE"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(26, "EXIT_REASON_VMOFF"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(27, "EXIT_REASON_VMON"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(28, "EXIT_REASON_CR_ACCESS"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(29, "EXIT_REASON_DR_ACCESS"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(30, "EXIT_REASON_IO_INSTRUCTION"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(31, "EXIT_REASON_MSR_READ"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(32, "EXIT_REASON_MSR_WRITE"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(33, "EXIT_REASON_INVALID_STATE"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(34, "EXIT_REASON_MSR_LOAD_FAIL"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(36, "EXIT_REASON_MWAIT_INSTRUCTION"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(37, "EXIT_REASON_MONITOR_TRAP_FLAG"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(39, "EXIT_REASON_MONITOR_INSTRUCTION"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(40, "EXIT_REASON_PAUSE_INSTRUCTION"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(41, "EXIT_REASON_MCE_DURING_VMENTRY"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(43, "EXIT_REASON_TPR_BELOW_THRESHOLD"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(44, "EXIT_REASON_APIC_ACCESS"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(45, "EXIT_REASON_EOI_INDUCED"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(46, "EXIT_REASON_GDTR_IDTR"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(47, "EXIT_REASON_LDTR_TR"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(48, "EXIT_REASON_EPT_VIOLATION"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(49, "EXIT_REASON_EPT_MISCONFIG"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(50, "EXIT_REASON_INVEPT"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(51, "EXIT_REASON_RDTSCP"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(52, "EXIT_REASON_PREEMPTION_TIMER"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(53, "EXIT_REASON_INVVPID"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(54, "EXIT_REASON_WBINVD"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(55, "EXIT_REASON_XSETBV"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(56, "EXIT_REASON_APIC_WRITE"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(57, "EXIT_REASON_RDRAND"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(58, "EXIT_REASON_INVPCID"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(59, "EXIT_REASON_VMFUNC"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(60, "EXIT_REASON_ENCLS"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(61, "EXIT_REASON_RDSEED"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(62, "EXIT_REASON_PML_FULL"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(63, "EXIT_REASON_XSAVES"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(64, "EXIT_REASON_XRSTORS"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(67, "EXIT_REASON_UMWAIT"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(68, "EXIT_REASON_TPAUSE"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(74, "EXIT_REASON_BUS_LOCK"); //$NON-NLS-1$ | ||
| fExitReasonMap.put(75, "EXIT_REASON_NOTIFY"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| /** | ||
| * @param code The code of the exit type | ||
| * @return The text describing the exit type | ||
| */ | ||
| public static String getExitReasonName(int code) { | ||
| return fExitReasonMap.getOrDefault(code, "UNKNOWN_EXIT_REASON"); //$NON-NLS-1$ | ||
| } | ||
| } |
93 changes: 93 additions & 0 deletions
93
...racecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/FlowEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 École Polytechnique de Montréal | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License 2.0 which | ||
| * accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| *******************************************************************************/ | ||
| package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis; | ||
|
|
||
| /** | ||
| * Represents a single event within a unified execution flow. | ||
| * <p> | ||
| * A {@code FlowEvent} wraps a {@link KernelEventInfo} and classifies it | ||
| * according to its role in the execution sequence (guest, hypervisor, | ||
| * VM transition, etc.). | ||
| * </p> | ||
| * | ||
| * @author Francois Belias | ||
| */ | ||
| public class FlowEvent { | ||
|
|
||
| /** | ||
| * The underlying kernel event associated with this flow event. | ||
| */ | ||
| final KernelEventInfo fKernelEvent; | ||
|
|
||
| /** | ||
| * The type of this flow event within the execution flow. | ||
| */ | ||
| final FlowEventType fType; | ||
|
|
||
| /** | ||
| * Timestamp of the corresponding guest event, used for correlating | ||
| * hypervisor events back to guest execution. | ||
| * <p> | ||
| * This value is primarily used for {@link FlowEventType#HYPERVISOR_EVENT} | ||
| * and is set to {@code -1} when not applicable. | ||
| * </p> | ||
| */ | ||
| long fCorrelatedGuestTimestamp = -1; | ||
|
|
||
| /** | ||
| * Constructs a {@code FlowEvent}. | ||
| * | ||
| * @param kernelEvent | ||
| * the underlying kernel event | ||
| * @param type | ||
| * the type of the flow event | ||
| */ | ||
| FlowEvent(KernelEventInfo kernelEvent, FlowEventType type) { | ||
| this.fKernelEvent = kernelEvent; | ||
| this.fType = type; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Enumerates the different types of events in a unified execution flow. | ||
| * <p> | ||
| * These types describe the role of each event in the interaction between | ||
| * guest execution and hypervisor activity. | ||
| * </p> | ||
| */ | ||
| enum FlowEventType { | ||
|
|
||
| /** | ||
| * A regular event occurring in the guest (virtual machine). | ||
| */ | ||
| GUEST_EVENT, | ||
|
|
||
| /** | ||
| * A VM exit event, marking the transition from guest to hypervisor. | ||
| */ | ||
| VM_EXIT, | ||
|
|
||
| /** | ||
| * An event occurring in the hypervisor (host) while handling a VM exit. | ||
| */ | ||
| HYPERVISOR_EVENT, | ||
|
|
||
| /** | ||
| * A VM entry event, marking the transition from hypervisor back to guest. | ||
| */ | ||
| VM_ENTRY, | ||
|
|
||
| /** | ||
| * An event occurring in a native (non-virtualized) environment. | ||
| */ | ||
| NATIVE | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.