Re: [RFC PATCH 1/1] virtio: write back features before verify

2021-10-06 Thread Cornelia Huck
On Mon, Oct 04 2021, "Michael S. Tsirkin" wrote: > On Mon, Oct 04, 2021 at 05:50:44PM +0200, Cornelia Huck wrote: >> On Mon, Oct 04 2021, "Michael S. Tsirkin" wrote: >> >> > On Mon, Oct 04, 2021 at 04:33:21PM +0200, Cornelia Huck wrote: >> >> On Mon, Oct 04 2021, "Michael S. Tsirkin" wrote:

[PATCH v2] virtio-mem: support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE

2021-10-06 Thread David Hildenbrand
The initial virtio-mem spec states that while unplugged memory should not be read, the device still has to allow for reading unplugged memory inside the usable region. The primary motivation for this default handling was to simplify bringup of virtio-mem, because there were corner cases where

[PATCH 1/1] virtio: write back F_VERSION_1 before validate

2021-10-06 Thread Halil Pasic
The virtio specification virtio-v1.1-cs01 states: Transitional devices MUST detect Legacy drivers by detecting that VIRTIO_F_VERSION_1 has not been acknowledged by the driver. This is exactly what QEMU as of 6.1 has done relying solely on VIRTIO_F_VERSION_1 for detecting that. However, the

Re: [virtio-dev] Fwd: [PATCH v2] Provide detailed specification of virtio-blk lifetime metrics

2021-10-06 Thread Cornelia Huck
On Fri, Aug 06 2021, Enrico Granata wrote: > Hi folks, > I am back from my leave of absence, so thank you everyone for your patience > > This proposal has been outstanding for a while and didn't seem to > receive pushback, especially compared to the initial proposal > > Would it be the right

Re: [RFC PATCH 1/1] virtio: write back features before verify

2021-10-06 Thread Michael S. Tsirkin
On Wed, Oct 06, 2021 at 12:13:14PM +0200, Cornelia Huck wrote: > On Mon, Oct 04 2021, "Michael S. Tsirkin" wrote: > > > On Mon, Oct 04, 2021 at 05:50:44PM +0200, Cornelia Huck wrote: > >> On Mon, Oct 04 2021, "Michael S. Tsirkin" wrote: > >> > >> > On Mon, Oct 04, 2021 at 04:33:21PM +0200,

Re: [PATCH RFC v1 10/11] uapi/virtio-iommu: Add a new request type to send page response

2021-10-06 Thread Jean-Philippe Brucker
On Thu, Sep 30, 2021 at 02:54:05PM +0530, Vivek Kumar Gautam wrote: > > > +struct virtio_iommu_req_page_resp { > > > + struct virtio_iommu_req_headhead; > > > + __le32 domain; > > > > I don't think we need this field, since the fault report doesn't

[PATCH v12 73/77] KVM: introspection: add KVMI_VCPU_CONTROL_SINGLESTEP

2021-10-06 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 v12 27/77] KVM: x86: wire in the preread/prewrite/preexec page trackers

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu These are needed in order to notify the introspection tool when read/write/execute access happens on one of the tracked memory pages. Also, this patch adds the case when the introspection tool requests that the vCPU re-enter in guest (and abort the emulation of the current

[PATCH v12 29/77] KVM: introduce VM introspection

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu The KVM introspection subsystem provides a facility for applications to control the execution of any running VMs (pause, resume, shutdown), query the state of the vCPUs (GPRs, MSRs etc.), alter the page access bits in the shadow page tables and receive notifications when events

[PATCH v12 60/77] KVM: introspection: add KVMI_VCPU_INJECT_EXCEPTION + KVMI_VCPU_EVENT_TRAP

2021-10-06 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 v12 20/77] KVM: x86: extend kvm_mmu_gva_to_gpa_system() with the 'access' parameter

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This is needed for kvmi_update_ad_flags() to emulate a guest page table walk on SPT violations due to A/D bit updates. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/x86.c | 6 +++--- 2 files

[PATCH v12 36/77] KVM: introspection: add KVM_INTROSPECTION_PREUNHOOK

2021-10-06 Thread Adalbert Lazăr
In certain situations (when the guest has to be paused, suspended, migrated, etc.), the device manager will use this new ioctl in order to trigger the KVMI_VM_EVENT_UNHOOK event. If the event is sent successfully (the VM has an active introspection channel), the device manager should delay the

[PATCH v12 38/77] KVM: introspection: add KVMI_VM_CONTROL_EVENTS

2021-10-06 Thread Adalbert Lazăr
By default, all introspection VM events are disabled. The introspection tool must explicitly enable the VM events it wants to receive. With this command it can enable/disable any VM event (e.g. KVMI_VM_EVENT_UNHOOK) if allowed by the device manager. Signed-off-by: Adalbert Lazăr ---

[PATCH v12 33/77] KVM: introspection: add KVMI_GET_VERSION

2021-10-06 Thread Adalbert Lazăr
When handling introspection commands from tools built with older or newer versions of the introspection API, the receiving thread silently accepts smaller/larger messages, but it replies with messages related to current/kernel version. Smaller introspection event replies are accepted too. However,

[PATCH v12 16/77] KVM: x86: save the error code during EPT/NPF exits handling

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This is needed for kvm_page_track_emulation_failure(). When the introspection tool {read,write,exec}-protect a guest memory page, it is notified from the read/write/fetch callbacks used by the KVM emulator. If the emulation fails it is possible that the read/write callbacks

[PATCH v12 07/77] KVM: x86: add kvm_x86_ops.control_cr3_intercept()

2021-10-06 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-x86-ops.h | 1 +

[PATCH v12 68/77] KVM: introspection: add KVMI_VCPU_CONTROL_MSR and KVMI_VCPU_EVENT_MSR

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This command is used to enable/disable introspection for a specific MSR. The KVMI_VCPU_EVENT_MSR event is sent when the tracked MSR is going to be changed. The introspection tool can respond by allowing the guest to continue with normal execution or by discarding the change.

[PATCH v12 11/77] KVM: x86: add kvm_x86_ops.control_desc_intercept()

2021-10-06 Thread Adalbert Lazăr
This function is needed to intercept descriptor-table registers access. Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h| 1 + arch/x86/kvm/svm/svm.c | 26 ++ arch/x86/kvm/vmx/vmx.c

[PATCH v12 04/77] KVM: x86: add kvm_arch_vcpu_set_regs()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This is needed for the KVMI_VCPU_SET_REGISTERS command, which allows an introspection tool to override the kvm_regs structure for a specific vCPU without clearing the pending exception. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/x86.c

[PATCH v12 51/77] KVM: introspection: add KVMI_VCPU_SET_REGISTERS

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu During an introspection event, the introspection tool might need to change the vCPU state, for example, to skip the current instruction. This command is allowed only during vCPU events and the registers will be set when the reply has been received. Signed-off-by: Mihai Donțu

[PATCH v12 76/77] KVM: introspection: emulate a guest page table walk on SPT violations due to A/D bit updates

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu On SPT page faults caused by guest page table walks, use the existing guest page table walk code to make the necessary adjustments to the A/D bits and return to guest. This effectively bypasses the x86 emulator who was making the wrong modifications leading one OS (Windows 8.1

[PATCH v12 54/77] KVM: introspection: add KVMI_VCPU_EVENT_BREAKPOINT

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This event is sent when a breakpoint was reached. The introspection tool can place breakpoints and use them as notification for when the OS or an application has reached a certain state or is trying to perform a certain operation (eg. create a process). Signed-off-by: Mihai

[PATCH v12 56/77] KVM: introspection: restore the state of #BP interception on unhook

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This commit also ensures that only the userspace or the introspection tool can control the #BP interception exclusively at one time. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvmi_host.h | 18 ++ arch/x86/kvm/kvmi.c

[PATCH v12 15/77] KVM: x86: add kvm_x86_ops.control_msr_intercept()

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This is needed for the KVMI_VCPU_EVENT_MSR event, which is used notify the introspection tool about any change made to a MSR of interest. 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 ---

[PATCH v12 18/77] KVM: x86: add kvm_x86_ops.control_singlestep()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This function is needed for KVMI_VCPU_CONTROL_SINGLESTEP. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h| 1 + arch/x86/kvm/vmx/vmx.c | 11 +++ 3 files

[PATCH v12 75/77] KVM: introspection: add KVMI_VCPU_TRANSLATE_GVA

2021-10-06 Thread Adalbert Lazăr
This helps the introspection tool with the GVA to GPA translations without the need to read or monitor the guest page tables. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 32 +++ arch/x86/kvm/kvmi_msg.c | 15 +

[PATCH v12 47/77] KVM: introspection: add KVMI_VCPU_EVENT_PAUSE

2021-10-06 Thread Adalbert Lazăr
This event is sent by the vCPU thread as a response to the KVMI_VM_PAUSE_VCPU command, but it has a lower priority, being sent after any other introspection event and when no other introspection command is queued. The number of KVMI_VCPU_EVENT_PAUSE will match the number of successful

[PATCH v12 02/77] KVM: add kvm_vcpu_kick_and_wait()

2021-10-06 Thread Adalbert Lazăr
This function is needed for the KVMI_VM_PAUSE_VCPU command, which sets the introspection request flag, kicks the vCPU out of guest and returns a success error code (0). The vCPU will send the KVMI_VCPU_EVENT_PAUSE event as soon as possible. Once the introspection tool receives the event, it knows

[PATCH v12 12/77] KVM: x86: add kvm_x86_ops.desc_intercepted()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This function will be used to test if the descriptor-table registers access is already tracked by userspace. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h| 1 +

[PATCH v12 10/77] KVM: svm: add support for descriptor-table VM-exits

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This function is needed for the KVMI_VCPU_EVENT_DESCRIPTOR event. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/svm/svm.c | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index

[PATCH v12 37/77] KVM: introspection: add KVMI_VM_EVENT_UNHOOK

2021-10-06 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 v12 28/77] KVM: x86: disable gpa_available optimization for fetch and page-walk SPT violations

2021-10-06 Thread Adalbert Lazăr
From: Mircea Cîrjaliu This change is needed because the introspection tool can write-protect guest page tables or exec-protect heap/stack pages. Signed-off-by: Mircea Cîrjaliu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 5 +

[PATCH v12 67/77] KVM: introspection: restore the state of descriptor-table register interception on unhook

2021-10-06 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 descriptor-table access VM-exit. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvmi_host.h | 4 +++ arch/x86/kvm/kvmi.c |

[PATCH v12 72/77] KVM: introspection: extend KVMI_GET_VERSION with struct kvmi_features

2021-10-06 Thread Adalbert Lazăr
This is used by the introspection tool to check the hardware support for the single step feature. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst| 15 +-- arch/x86/include/uapi/asm/kvmi.h | 5 + arch/x86/kvm/kvmi.c

[PATCH v12 09/77] KVM: x86: add kvm_x86_ops.desc_ctrl_supported()

2021-10-06 Thread Adalbert Lazăr
When the introspection tool tries to enable the KVMI_VCPU_EVENT_DESCRIPTOR event, this function is used to check if the control of VM-exits caused by descriptor-table registers access is supported. Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm-x86-ops.h | 1 +

[PATCH v12 03/77] KVM: x86: add kvm_arch_vcpu_get_regs() and kvm_arch_vcpu_get_sregs()

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu These functions are used by the VM introspection code (for the KVMI_VCPU_GET_REGISTERS command and all events sending the vCPU registers to the introspection tool). Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/x86.c | 10 ++

[PATCH v12 44/77] KVM: introspection: add KVMI_VCPU_GET_INFO

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This command returns the TSC frequency (in HZ) for the specified vCPU if available (otherwise it returns zero). Signed-off-by: Mihai Donțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 29

[PATCH v12 01/77] KVM: UAPI: add error codes used by the VM introspection code

2021-10-06 Thread Adalbert Lazăr
These new error codes help the introspection tool to identify the cause of the introspection command failure and to recover from some error cases or to give more information to the user. Signed-off-by: Adalbert Lazăr --- include/uapi/linux/kvm_para.h | 4 1 file changed, 4 insertions(+)

[PATCH v12 58/77] KVM: introspection: add KVMI_VCPU_CONTROL_CR and KVMI_VCPU_EVENT_CR

2021-10-06 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 v12 74/77] KVM: introspection: add KVMI_VCPU_EVENT_SINGLESTEP

2021-10-06 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 v12 50/77] KVM: introspection: add KVMI_VCPU_GET_REGISTERS

2021-10-06 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 v12 70/77] KVM: introspection: add KVMI_VM_SET_PAGE_ACCESS

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This command sets the spte access bits (rwx) for an array of guest physical addresses (through the page tracking subsystem). These GPAs, with the requested access bits, are also kept in a radix tree in order to filter out the #PF events which are of no interest to the

[PATCH v12 24/77] KVM: x86: page track: provide all callbacks with the guest virtual address

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This is needed because the emulator calls the page tracking code irrespective of the current VM-exit reason or available information. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 2 +-

[PATCH v12 30/77] KVM: introspection: add hook/unhook ioctls

2021-10-06 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 v12 77/77] KVM: x86: call the page tracking code on emulation failure

2021-10-06 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 v12 19/77] KVM: x86: export kvm_arch_vcpu_set_guest_debug()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This function is needed in order to notify the introspection tool through KVMI_VCPU_EVENT_BP events on guest breakpoints. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/x86.c | 24 include/linux/kvm_host.h | 2 ++

[PATCH v12 39/77] KVM: introspection: add KVMI_VM_READ_PHYSICAL/KVMI_VM_WRITE_PHYSICAL

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu These commands allow the introspection tool to read/write from/to the guest memory. Signed-off-by: Mihai Donțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 68 ++ include/uapi/linux/kvmi.h

[PATCH v12 13/77] KVM: x86: add kvm_x86_ops.msr_write_intercepted()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This function will be used to check if the write access for a specific MSR is already intercepted. The information will be used to restore the interception status when the introspection tool is no longer interested in that MSR. Signed-off-by: Nicușor Cîțu Signed-off-by:

[PATCH v12 26/77] KVM: x86: page_track: add support for preread, prewrite and preexec

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu The access to a tracked memory page leads to two types of actions from the introspection tool: either the access is allowed (maybe with different data for the source operand) or the vCPU should re-enter in guest (the page is not tracked anymore, the instruction was

[PATCH v12 32/77] KVM: introspection: add the read/dispatch message function

2021-10-06 Thread Adalbert Lazăr
Based on the common header (struct kvmi_msg_hdr), the receiving thread will read/validate all messages, execute the VM introspection commands (eg. KVMI_VM_GET_INFO) and dispatch the vCPU introspection commands (eg. KVMI_VCPU_GET_REGISTERS) to the vCPU threads. The vCPU threads will reply to vCPU

[PATCH v12 14/77] KVM: x86: svm: use the vmx convention to control the MSR interception

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This is a preparatory patch in order to use a common interface to enable/disable the MSR interception. Also, it will allow to independently control the read and write interceptions. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr ---

[PATCH v12 22/77] KVM: x86: export kvm_vcpu_ioctl_x86_get_xsave()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This function is needed for the KVMI_VCPU_GET_XSAVE command. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/x86.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git

[PATCH v12 49/77] KVM: introspection: add KVMI_VCPU_CONTROL_EVENTS

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu By default, all introspection events are disabled. The introspection tool must explicitly enable the events it wants to receive. With this command (KVMI_VCPU_CONTROL_EVENTS) it can enable/disable any vCPU event allowed by the device manager. Some vCPU events doesn't have to be

[PATCH v12 05/77] KVM: x86: avoid injecting #PF when emulate the VMCALL instruction

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu It can happened to end up emulating the VMCALL instruction as a result of the handling of an EPT write fault. In this situation, the emulator will try to unconditionally patch the correct hypercall opcode bytes using emulator_write_emulated(). However, this last call uses the

[PATCH v12 06/77] KVM: x86: add kvm_x86_ops.bp_intercepted()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu Both, the introspection tool and the device manager can request #BP interception. This function will be used to check if this interception is already enabled by either side. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm-x86-ops.h |

[PATCH v12 00/77] VM introspection

2021-10-06 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 v12 40/77] KVM: introspection: add vCPU related data

2021-10-06 Thread Adalbert Lazăr
From: Mircea Cîrjaliu Add an introspection structure to all vCPUs when the VM is hooked. Signed-off-by: Mircea Cîrjaliu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvmi_host.h | 3 ++ include/linux/kvm_host.h | 2 ++ include/linux/kvmi_host.h| 6

[PATCH v12 55/77] KVM: introspection: add cleanup support for vCPUs

2021-10-06 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 v12 46/77] KVM: introspection: add support for vCPU events

2021-10-06 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 v12 31/77] KVM: introspection: add permission access ioctls

2021-10-06 Thread Adalbert Lazăr
KVM_INTROSPECTION_COMMAND and KVM_INTROSPECTION_EVENTS ioctls are used by the device manager to allow/disallow access to specific (or all) introspection commands and events. The introspection tool will get the KVM_EPERM error code on any attempt to use a disallowed command. By default, all events

[PATCH v12 08/77] KVM: x86: add kvm_x86_ops.cr3_write_intercepted()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This function will be used to allow the introspection tool to disable the CR3-write interception when it is no longer interested in these events, but only if nothing else depends on these VM-exits. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr ---

[PATCH v12 17/77] KVM: x86: add kvm_x86_ops.fault_gla()

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This function is needed for kvmi_update_ad_flags() and kvm_page_track_emulation_failure(). kvmi_update_ad_flags() uses the existing guest page table walk code to update the A/D bits and return to guest (when the introspection tool write-protects the guest page tables).

[PATCH v12 34/77] KVM: introspection: add KVMI_VM_CHECK_COMMAND and KVMI_VM_CHECK_EVENT

2021-10-06 Thread Adalbert Lazăr
These commands are used to check what introspection commands and events are supported (kernel) and allowed (device manager). These are alternative methods to KVMI_GET_VERSION in checking if the introspection supports a specific command/event. As with the KVMI_GET_VERSION command, these two

[PATCH v12 23/77] KVM: x86: export kvm_vcpu_ioctl_x86_set_xsave()

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

[PATCH v12 21/77] KVM: x86: export kvm_inject_pending_exception()

2021-10-06 Thread Adalbert Lazăr
From: Nicușor Cîțu This function is needed for the KVMI_VCPU_INJECT_EXCEPTION command. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/x86.c | 52 +++-- 2 files changed, 31

[PATCH v12 25/77] KVM: x86: page track: add track_create_slot() callback

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This is used to add page access notifications as soon as a slot appears or when a slot is moved. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_page_track.h | 11 +++ arch/x86/kvm/mmu/page_track.c | 15 +++

[PATCH v12 71/77] KVM: introspection: add KVMI_VCPU_EVENT_PF

2021-10-06 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 v12 52/77] KVM: introspection: add KVMI_VCPU_GET_CPUID

2021-10-06 Thread Adalbert Lazăr
From: Marian Rotariu This command returns a CPUID leaf (as seen by the guest OS). Signed-off-by: Marian Rotariu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 36 +++ arch/x86/include/uapi/asm/kvmi.h

[PATCH v12 61/77] KVM: introspection: add KVMI_VCPU_EVENT_XSETBV

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This event is sent when an extended control register XCR is going to be changed. 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 | 34

[PATCH v12 41/77] KVM: introspection: add a jobs list to every introspected vCPU

2021-10-06 Thread Adalbert Lazăr
Every vCPU has a lock-protected list in which the receiving thread places the jobs that has to be done by the vCPU thread once it is kicked out of guest (KVM_REQ_INTROSPECTION). Co-developed-by: Nicușor Cîțu Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr ---

[PATCH v12 69/77] KVM: introspection: restore the state of MSR interception on unhook

2021-10-06 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 v12 59/77] KVM: introspection: restore the state of CR3 interception on unhook

2021-10-06 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 CR3-write VM-exit. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvmi_host.h | 4 ++ arch/x86/kvm/kvmi.c | 68

[PATCH v12 65/77] KVM: introspection: add KVMI_VCPU_GET_MTRR_TYPE

2021-10-06 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 v12 57/77] KVM: introspection: add KVMI_VM_CONTROL_CLEANUP

2021-10-06 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 v12 66/77] KVM: introspection: add KVMI_VCPU_EVENT_DESCRIPTOR

2021-10-06 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 v12 45/77] KVM: introspection: add KVMI_VM_PAUSE_VCPU

2021-10-06 Thread Adalbert Lazăr
This command increments a pause requests counter for a vCPU and kicks it out of guest. The introspection tool can pause a VM by sending this command for all vCPUs. If it sets 'wait=1', it can consider that the VM is paused when it receives the reply for the last KVMI_VM_PAUSE_VCPU command.

[PATCH v12 62/77] KVM: introspection: add KVMI_VCPU_GET_XCR

2021-10-06 Thread Adalbert Lazăr
This can be used by the introspection tool to emulate SSE instructions. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 33 +++ arch/x86/include/uapi/asm/kvmi.h | 9 + arch/x86/kvm/kvmi_msg.c | 21

[PATCH v12 64/77] KVM: introspection: add KVMI_VCPU_SET_XSAVE

2021-10-06 Thread Adalbert Lazăr
This can be used by the introspection tool to emulate SSE instructions. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 28 +++ arch/x86/include/uapi/asm/kvmi.h | 4 +++ arch/x86/kvm/kvmi_msg.c | 20

[PATCH v12 53/77] KVM: introspection: add KVMI_VCPU_EVENT_HYPERCALL

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This event is sent on a specific hypercall. It is used by the code residing inside the introspected guest to call the introspection tool and to report certain details about its operation. For example, a classic antimalware remediation tool can report what it has found during a

[PATCH v12 63/77] KVM: introspection: add KVMI_VCPU_GET_XSAVE

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This vCPU command is used to get the XSAVE area. Signed-off-by: Mihai Donțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 29 +++ arch/x86/include/uapi/asm/kvmi.h | 4 +++

[PATCH v12 42/77] KVM: introspection: handle vCPU introspection requests

2021-10-06 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 v12 35/77] KVM: introspection: add KVMI_VM_GET_INFO

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This command returns the number of online vCPUs. The introspection tool uses the vCPU index to specify to which vCPU the introspection command applies to. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 18

[PATCH v12 43/77] KVM: introspection: handle vCPU commands

2021-10-06 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:

[PATCH v12 48/77] KVM: introspection: add the crash action handling on the event reply

2021-10-06 Thread Adalbert Lazăr
From: Mihai Donțu This action is used in extreme cases such as blocking the spread of malware as fast as possible. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- virt/kvm/introspection/kvmi.c | 4 1 file changed, 4 insertions(+) diff --git a/virt/kvm/introspection/kvmi.c

[PATCH] VDUSE: fix documentation underline warning

2021-10-06 Thread Randy Dunlap
Fix a VDUSE documentation build warning: Documentation/userspace-api/vduse.rst:21: WARNING: Title underline too short. Fixes: 7bc7f61897b6 ("Documentation: Add documentation for VDUSE") Signed-off-by: Randy Dunlap Cc: Xie Yongji Cc: Jason Wang Cc: Michael S. Tsirkin Cc: