[PATCH v10 61/81] KVM: introspection: add KVMI_VCPU_CONTROL_CR and KVMI_VCPU_EVENT_CR

2020-11-25 Thread Adalbert Lazăr
From: Mihai Donțu Using the KVMI_VCPU_CONTROL_CR command, the introspection tool subscribes to KVMI_VCPU_EVENT_CR events that will be sent when a control register (CR0, CR3 or CR4) is going to be changed. Signed-off-by: Mihai Donțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr

[PATCH v10 78/81] KVM: introspection: add KVMI_VCPU_EVENT_SINGLESTEP

2020-11-25 Thread Adalbert Lazăr
From: Nicușor Cîțu This event is sent after each instruction when the singlestep has been enabled for a vCPU. Signed-off-by: Nicușor Cîțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 31 +++ arch/x86/kvm/kvmi.c

[PATCH v10 53/81] KVM: introspection: add KVMI_VCPU_GET_REGISTERS

2020-11-25 Thread Adalbert Lazăr
From: Mihai Donțu This command is used to get kvm_regs and kvm_sregs structures, plus a list of struct kvm_msrs from a specific vCPU. While the kvm_regs and kvm_sregs structures are included with every event, this command allows reading any MSR. Signed-off-by: Mihai Donțu Co-developed-by:

[PATCH v10 77/81] KVM: introspection: add KVMI_VCPU_CONTROL_SINGLESTEP

2020-11-25 Thread Adalbert Lazăr
From: Nicușor Cîțu The next commit that adds the KVMI_VCPU_EVENT_SINGLESTEP event will make this command more useful. Signed-off-by: Nicușor Cîțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 33 +++

[PATCH v10 60/81] KVM: introspection: add KVMI_VM_CONTROL_CLEANUP

2020-11-25 Thread Adalbert Lazăr
This command will allow more control over the guest state on unhook. However, the memory restrictions (e.g. those set with KVMI_VM_SET_PAGE_ACCESS) will be removed on unhook. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 28 +++

[PATCH v10 49/81] KVM: introspection: add support for vCPU events

2020-11-25 Thread Adalbert Lazăr
This is the common code used by vCPU threads to send events and wait for replies (received and dispatched by the receiving thread). While waiting for an event reply, the vCPU thread will handle any introspection command already queued or received during this period. Signed-off-by: Adalbert Lazăr

[PATCH v10 63/81] KVM: introspection: add KVMI_VCPU_INJECT_EXCEPTION + KVMI_VCPU_EVENT_TRAP

2020-11-25 Thread Adalbert Lazăr
From: Mihai Donțu The KVMI_VCPU_INJECT_EXCEPTION command is used by the introspection tool to inject exceptions, for example, to get a page from swap. The exception is injected right before entering in guest unless there is already an exception pending. The introspection tool is notified with

[PATCH v10 81/81] KVM: x86: call the page tracking code on emulation failure

2020-11-25 Thread Adalbert Lazăr
From: Mihai Donțu The information we can provide this way is incomplete, but current users of the page tracking code can work with it. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/x86.c | 49 ++ 1 file changed, 49

[PATCH v10 09/81] KVM: x86: add kvm_x86_ops.control_cr3_intercept()

2020-11-25 Thread Adalbert Lazăr
This function is needed for the KVMI_VCPU_CONTROL_CR command, when the introspection tool has to intercept the read/write access to CR3. Co-developed-by: Nicușor Cîțu Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 6 ++

[PATCH v10 00/81] VM introspection

2020-11-25 Thread Adalbert Lazăr
The KVM introspection subsystem provides a facility for applications running on the host or in a separate VM, to control the execution of other VMs (pause, resume, shutdown), query the state of the vCPUs (GPRs, MSRs etc.), alter the page access bits in the shadow page tables (only for the hardware

[PATCH v10 45/81] KVM: introspection: handle vCPU introspection requests

2020-11-25 Thread Adalbert Lazăr
From: Mihai Donțu The receiving thread dispatches the vCPU introspection commands by adding them to the vCPU's jobs list and kicking the vCPU. Before entering in guest, the vCPU thread checks the introspection request (KVM_REQ_INTROSPECTION) and runs its queued jobs. Signed-off-by: Mihai Donțu

[PATCH v10 70/81] KVM: introspection: add KVMI_VCPU_EVENT_DESCRIPTOR

2020-11-25 Thread Adalbert Lazăr
From: Nicușor Cîțu This event is sent when IDTR, GDTR, LDTR or TR are accessed. These could be used to implement a tiny agent which runs in the context of an introspected guest and uses virtualized exceptions (#VE) and alternate EPT views (VMFUNC #0) to filter converted VMEXITS. The events of

[PATCH v10 33/81] KVM: introspection: add hook/unhook ioctls

2020-11-25 Thread Adalbert Lazăr
On hook, a new thread is created to handle the messages coming from the introspection tool (commands or event replies). The VM related commands are handled by this thread, while the vCPU commands and events replies are dispatched to the vCPU threads. On unhook, the socket is shut down, which will

[PATCH v10 26/81] KVM: x86: export kvm_vcpu_ioctl_x86_set_xsave()

2020-11-25 Thread Adalbert Lazăr
This function is needed for the KVMI_VCPU_SET_XSAVE command. Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/x86.c | 4 ++-- include/linux/kvm_host.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index

[PATCH v10 58/81] KVM: introspection: add cleanup support for vCPUs

2020-11-25 Thread Adalbert Lazăr
From: Nicușor Cîțu On unhook the introspection channel is closed. This will signal the receiving thread to call kvmi_put() and exit. There might be vCPU threads handling introspection commands or waiting for event replies. These will also call kvmi_put() and re-enter in guest. Once the reference

[PATCH v10 73/81] KVM: introspection: restore the state of MSR interception on unhook

2020-11-25 Thread Adalbert Lazăr
From: Nicușor Cîțu This commit also ensures that the introspection tool and the userspace do not disable each other the MSR access VM-exit. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvmi_host.h | 12 +++ arch/x86/kvm/kvmi.c | 124

[PATCH v10 69/81] KVM: introspection: add KVMI_VCPU_GET_MTRR_TYPE

2020-11-25 Thread Adalbert Lazăr
From: Mihai Donțu This command returns the memory type for a guest physical address. Signed-off-by: Mihai Donțu Co-developed-by: Nicușor Cîțu Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 32 +++

[PATCH v10 64/81] KVM: introspection: add KVMI_VM_GET_MAX_GFN

2020-11-25 Thread Adalbert Lazăr
From: Ștefan Șicleru The introspection tool will use this command to get the memory address range for which it can set access restrictions. Signed-off-by: Ștefan Șicleru Co-developed-by: Nicușor Cîțu Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr ---

[PATCH v10 75/81] KVM: introspection: add KVMI_VCPU_EVENT_PF

2020-11-25 Thread Adalbert Lazăr
From: Mihai Donțu This event is sent when a #PF occurs due to a failed permission check in the shadow page tables, for a page in which the introspection tool has shown interest. Signed-off-by: Mihai Donțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr ---

[PATCH v10 40/81] KVM: introspection: add KVMI_VM_EVENT_UNHOOK

2020-11-25 Thread Adalbert Lazăr
This event is sent when the guest is about to be paused/suspended/migrated. The introspection tool has the chance to remove its hooks (e.g. breakpoints) while the guest is still running. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 31 +

[PATCH v10 46/81] KVM: introspection: handle vCPU commands

2020-11-25 Thread Adalbert Lazăr
From: Mihai Donțu Based on the common structure (kvmi_vcpu_hdr) used for all vCPU commands, the receiving thread validates and dispatches the message to the proper vCPU (adding the handling function to its jobs list). Signed-off-by: Mihai Donțu Co-developed-by: Nicușor Cîțu Signed-off-by:

<    1   2