[PATCH v9 68/84] KVM: introspection: add KVMI_EVENT_XSETBV

2020-07-21 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 | 33 arch/x86

[PATCH v9 73/84] KVM: introspection: add KVMI_EVENT_DESCRIPTOR

2020-07-21 Thread Adalbert Lazăr
of interested will be suppressed (after some appropriate guest-side handling) while the rest will be sent to the introspector via a VMCALL. Signed-off-by: Nicușor Cîțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 41

[PATCH v9 82/84] KVM: introspection: add KVMI_VCPU_TRANSLATE_GVA

2020-07-21 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.c | 5 +++ include

[PATCH v9 18/84] KVM: svm: pass struct kvm_vcpu to set_msr_interception()

2020-07-21 Thread Adalbert Lazăr
only after initialization. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/svm/svm.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index e16be80edd7e..dfa1a6e74bf7 100644

[PATCH v9 64/84] KVM: introspection: add KVMI_VCPU_CONTROL_CR and KVMI_EVENT_CR

2020-07-21 Thread Adalbert Lazăr
From: Mihai Donțu Using the KVMI_VCPU_CONTROL_CR command, the introspection tool subscribes to KVMI_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 v9 39/84] KVM: introspection: add permission access ioctls

2020-07-21 Thread Adalbert Lazăr
and almost all commands are disallowed. Some commands, those querying the introspection capabilities, are always allowed. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/api.rst| 66 ++ include/linux/kvmi_host.h | 7 ++ include/uapi/linux

[PATCH v9 30/84] KVM: x86: export kvm_vcpu_ioctl_x86_get_xsave()

2020-07-21 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/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

[PATCH v9 43/84] KVM: introspection: add KVMI_VM_GET_INFO

2020-07-21 Thread Adalbert Lazăr
From: Mihai Donțu For now, this command returns only 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

[PATCH v9 14/84] KVM: x86: add .control_desc_intercept()

2020-07-21 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_host.h | 1 + arch/x86/kvm/svm/svm.c | 26 ++ arch/x86/kvm/vmx/vmx.c | 15 +-- 3 files changed, 40 insertions

[PATCH v9 46/84] KVM: introspection: add KVMI_VM_READ_PHYSICAL/KVMI_VM_WRITE_PHYSICAL

2020-07-21 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 v9 03/84] KVM: add kvm_vcpu_kick_and_wait()

2020-07-21 Thread Adalbert Lazăr
of kvm_vcpu_kick(). And because this vCPU command (KVMI_VCPU_PAUSE) is handled by the receiving thread (instead of the vCPU thread), once a string of KVMI_VCPU_PAUSE commands with the 'wait' flag set is handled, the introspection tool can consider the VM paused, without the need to wait and check ev

[PATCH v9 48/84] KVM: introspection: add a jobs list to every introspected vCPU

2020-07-21 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 --- include/linux

[PATCH v9 59/84] KVM: introspection: add KVMI_EVENT_HYPERCALL

2020-07-21 Thread Adalbert Lazăr
a scan. Signed-off-by: Mihai Donțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/hypercalls.rst | 35 Documentation/virt/kvm/kvmi.rst | 36 +++- arch/x86/include/uapi/asm/kvmi.h | 2

[PATCH v9 61/84] KVM: introspection: add cleanup support for vCPUs

2020-07-21 Thread Adalbert Lazăr
) which will be used and freed by each of them before re-entering in guest. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 3 ++ arch/x86/include/asm/kvmi_host.h | 4 +++ arch/x86/kvm/kvmi.c | 49 +++ virt

[PATCH v9 22/84] KVM: x86: save the error code during EPT/NPF exits handling

2020-07-21 Thread Adalbert Lazăr
the instruction). Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/vmx/vmx.c | 1 + 3 files changed, 6 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm

[PATCH v9 21/84] KVM: x86: vmx: use a symbolic constant when checking the exit qualifications

2020-07-21 Thread Adalbert Lazăr
From: Mihai Donțu This should make the code more readable. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/vmx/vmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index fed661eb65a7

[PATCH v9 01/84] signal: export kill_pid_info()

2020-07-21 Thread Adalbert Lazăr
-by: Adalbert Lazăr --- kernel/signal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/signal.c b/kernel/signal.c index 5ca48cc5da76..c3af81d7b62a 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1456,6 +1456,7 @@ int kill_pid_info(int sig, struct kernel_siginfo *info, struct pid *pid

[PATCH v9 65/84] KVM: introspection: restore the state of CR3 interception on unhook

2020-07-21 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 | 64

[PATCH v9 02/84] KVM: UAPI: add error codes used by the VM introspection code

2020-07-21 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 v9 63/84] KVM: introspection: add KVMI_VM_CONTROL_CLEANUP

2020-07-21 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 -- It will be more interesting if the userspace could control the cleanup behavior

[PATCH v9 84/84] KVM: x86: call the page tracking code on emulation failure

2020-07-21 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 v9 27/84] KVM: x86: export kvm_arch_vcpu_set_guest_debug()

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

[PATCH v9 09/84] KVM: x86: add .bp_intercepted() to struct kvm_x86_ops

2020-07-21 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 enabled by either side. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch

[PATCH v9 16/84] KVM: x86: export .msr_write_intercepted()

2020-07-21 Thread Adalbert Lazăr
From: Nicușor Cîțu This function will be used to check if the access for a specific MSR is already intercepted. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm/svm.c | 1 + arch/x86/kvm/vmx/vmx.c | 1 + 3

[PATCH v9 33/84] KVM: x86: page track: add track_create_slot() callback

2020-07-21 Thread Adalbert Lazăr
From: Mihai Donțu This is used to add page access notifications as soon as a slot appears. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_page_track.h | 13 - arch/x86/kvm/mmu/page_track.c | 16 +++- arch/x86/kvm/x86.c

[PATCH v9 51/84] KVM: introspection: add KVMI_VCPU_GET_INFO

2020-07-21 Thread Adalbert Lazăr
From: Mihai Donțu For now, 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 v9 76/84] KVM: introspection: restore the state of MSR interception on unhook

2020-07-21 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 | 133

[PATCH v9 24/84] KVM: x86: add .spt_fault()

2020-07-21 Thread Adalbert Lazăr
Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm/svm.c | 9 + arch/x86/kvm/vmx/vmx.c | 8 3 files changed, 18 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/as

[PATCH v9 57/84] KVM: introspection: add KVMI_VCPU_SET_REGISTERS

2020-07-21 Thread Adalbert Lazăr
Co-developed-by: Mircea Cîrjaliu Signed-off-by: Mircea Cîrjaliu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 29 include/linux/kvmi_host.h | 3 + include/uapi/linux/kvmi.h

[PATCH v9 38/84] KVM: introspection: add hook/unhook ioctls

2020-07-21 Thread Adalbert Lazăr
cea Cîrjaliu Co-developed-by: Nicușor Cîțu Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/api.rst| 55 ++ arch/x86/include/asm/kvmi_host.h | 8 + arch/x86/kvm/Makefile | 2 +- arch/x86/kvm/x8

[PATCH v9 06/84] KVM: x86: add kvm_arch_vcpu_get_regs() and kvm_arch_vcpu_get_sregs()

2020-07-21 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 v9 53/84] KVM: introspection: add KVMI_EVENT_PAUSE_VCPU

2020-07-21 Thread Adalbert Lazăr
KVMI_VCPU_PAUSE commands. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 22 ++- arch/x86/kvm/kvmi.c | 81 + include/linux/kvmi_host.h | 11 ++ include/uapi/linux/kvmi.h | 13 ++ .../testing

[PATCH v9 66/84] KVM: introspection: add KVMI_VCPU_INJECT_EXCEPTION + KVMI_EVENT_TRAP

2020-07-21 Thread Adalbert Lazăr
with an KVMI_EVENT_TRAP event about the success of the injection. In case of failure, the introspecion tool is expected to try again later. Signed-off-by: Mihai Donțu Co-developed-by: Nicușor Cîțu Signed-off-by: Nicușor Cîțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr

[PATCH v9 49/84] KVM: introspection: handle vCPU introspection requests

2020-07-21 Thread Adalbert Lazăr
Co-developed-by: Mircea Cîrjaliu Signed-off-by: Mircea Cîrjaliu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/x86.c| 3 ++ include/linux/kvm_host.h | 1 + include/linux/kvmi_host.h | 4 +++ virt/kvm/introspection/kvmi.c | 58

[PATCH v9 60/84] KVM: introspection: add KVMI_EVENT_BREAKPOINT

2020-07-21 Thread Adalbert Lazăr
Donțu Co-developed-by: Nicușor Cîțu Signed-off-by: Nicușor Cîțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 40 arch/x86/include/uapi/asm/kvmi.h | 6 +++ arch/x86/kvm/kvmi.c

[PATCH v9 12/84] KVM: x86: add .desc_ctrl_supported()

2020-07-21 Thread Adalbert Lazăr
When the introspection tool tries to enable the KVMI_EVENT_DESCRIPTOR event, this function is used to check if it is supported. Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm/svm.c | 6 ++ arch/x86/kvm/vmx/capabilities.h | 7 ++- arch

[PATCH v9 80/84] KVM: introspection: add KVMI_VCPU_CONTROL_SINGLESTEP

2020-07-21 Thread Adalbert Lazăr
From: Nicușor Cîțu The next commit that adds the KVMI_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 | 32 ++ arch/x86/kvm/kvmi.c

[PATCH v9 28/84] KVM: x86: extend kvm_mmu_gva_to_gpa_system() with the 'access' parameter

2020-07-21 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 v9 35/84] KVM: x86: wire in the preread/prewrite/preexec page trackers

2020-07-21 Thread Adalbert Lazăr
instruction). Signed-off-by: Mihai Donțu Co-developed-by: Marian Rotariu Signed-off-by: Marian Rotariu Co-developed-by: Stefan Sicleru Signed-off-by: Stefan Sicleru Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/emulate.c | 4 +++ arch/x86/kvm/kvm_emulate.h | 1 + arch/x86/kvm/mmu/mmu.c

[PATCH v9 37/84] KVM: introduce VM introspection

2020-07-21 Thread Adalbert Lazăr
-off-by: Mihai Donțu Co-developed-by: Marian Rotariu Signed-off-by: Marian Rotariu Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 140 ++ arch/x86/kvm/Kconfig | 13 +++ arch/x86/kvm/Makefile | 2 + include/linux

[PATCH v9 41/84] KVM: introspection: add KVMI_GET_VERSION

2020-07-21 Thread Adalbert Lazăr
commands are disallowed (using id=-1) in which case KVMI_GET_VERSION is silently allowed, without error. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 37 +++ include/uapi/linux/kvmi.h | 10 + .../testing/selftests/kvm

[PATCH v9 10/84] KVM: x86: add .control_cr3_intercept() to struct kvm_x86_ops

2020-07-21 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 ++ arch/x86/kvm/svm

[PATCH v9 19/84] KVM: vmx: pass struct kvm_vcpu to the intercept msr related functions

2020-07-21 Thread Adalbert Lazăr
only after initialization. Signed-off-by: Nicușor Cîțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/vmx/vmx.c | 74 -- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index cf07db129670

[PATCH v9 78/84] KVM: introspection: add KVMI_EVENT_PF

2020-07-21 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 --- Documentation/virt

[PATCH v9 58/84] KVM: introspection: add KVMI_VCPU_GET_CPUID

2020-07-21 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 v9 42/84] KVM: introspection: add KVMI_VM_CHECK_COMMAND and KVMI_VM_CHECK_EVENT

2020-07-21 Thread Adalbert Lazăr
commands can never be disallowed by the device manager. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 62 +++ include/uapi/linux/kvmi.h | 16 - .../testing/selftests/kvm/x86_64/kvmi_test.c | 59 ++ virt/kvm

[PATCH v9 83/84] KVM: introspection: emulate a guest page table walk on SPT violations due to A/D bit updates

2020-07-21 Thread Adalbert Lazăr
x64) to triple-fault very early in the boot process with the introspection enabled. With introspection disabled, these faults are handled by simply removing the protection from the affected guest page and returning to guest. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86

[PATCH v9 77/84] KVM: introspection: add KVMI_VM_SET_PAGE_ACCESS

2020-07-21 Thread Adalbert Lazăr
to the introspection tool. The access restrictions for pages that are not visible to the guest are silently ignored by default (the tool might set restrictions for the whole memory, based on KVMI_VM_GET_MAX_GFN). Signed-off-by: Mihai Donțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr

[PATCH v9 00/84] VM introspection

2020-07-21 Thread Adalbert Lazăr
sage validation, etc.). Adalbert Lazăr (22): KVM: UAPI: add error codes used by the VM introspection code KVM: add kvm_vcpu_kick_and_wait() KVM: doc: fix the hypercall numbering KVM: x86: add .control_cr3_intercept() to struct kvm_x86_ops KVM: x86: add .desc_ctrl_supported() KVM: x86: add .co

[PATCH v9 11/84] KVM: x86: add .cr3_write_intercepted()

2020-07-21 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 --- arch/x86

[PATCH v9 13/84] KVM: svm: add support for descriptor-table exits

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

[PATCH v9 79/84] KVM: introspection: extend KVMI_GET_VERSION with struct kvmi_features

2020-07-21 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| 13 - arch/x86/include/uapi/asm/kvmi.h | 5 + arch/x86/kvm/kvmi.c

[PATCH v9 62/84] KVM: introspection: restore the state of #BP interception on unhook

2020-07-21 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 v9 67/84] KVM: introspection: add KVMI_VM_GET_MAX_GFN

2020-07-21 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 --- Documentation/virt/kvm

[PATCH v9 55/84] KVM: introspection: add KVMI_VCPU_CONTROL_EVENTS

2020-07-21 Thread Adalbert Lazăr
Donțu Co-developed-by: Adalbert Lazăr Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 51 +- include/linux/kvmi_host.h | 2 + include/uapi/linux/kvmi.h | 12 - .../testing/selftests/kvm/x86_64

[PATCH v9 32/84] KVM: x86: page track: provide all callbacks with the guest virtual address

2020-07-21 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 +- arch/x86/include/asm

[PATCH v9 52/84] KVM: introspection: add KVMI_VCPU_PAUSE

2020-07-21 Thread Adalbert Lazăr
then checks its pause counter in order to send the pause events requested by the introspection tool. Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 66 ++- include/linux/kvmi_host.h | 2 + include/uapi/linux/kvmi.h

[RFC PATCH v1 23/34] KVM: x86: mmu: fix: update present_mask in spte_read_protect()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru shadow_present_mask is not 0ull if #VE support is enabled. If #VE support is enabled, shadow_present_mask is updated in vmx_enable_tdp() with VMX_EPT_SUPPRESS_VE_BIT. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/mmu/mmu.c | 8 +++- 1

[RFC PATCH v1 04/34] KVM: x86: mmu: reindent to avoid lines longer than 80 chars

2020-07-22 Thread Adalbert Lazăr
Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/mmu/mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 97766f34910d..f3ba4d0452c9 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2573,6 +2573,7

[RFC PATCH v1 11/34] KVM: x86: mmu: allow zapping shadow pages for specific EPT views

2020-07-22 Thread Adalbert Lazăr
-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/mmu/mmu.c | 4 +++- arch/x86/kvm/x86.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 2fbb26b54cf1

[RFC PATCH v1 10/34] KVM: x86: page track: allow page tracking for different EPT views

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru The introspection tool uses this to set distinct access rights on different EPT views. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/include/asm/kvm_page_track.h | 4 +- arch/x86/kvm/kvmi.c

[RFC PATCH v1 31/34] KVM: introspection: add #VE host capability checker

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru Add one more field to struct kvmi_features in order to publish #VE capabilities on the host as indicated by kvm_ve_supported flag. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst| 5 +++-- arch/x86/include

[RFC PATCH v1 02/34] KVM: x86: export .get_eptp_switching_status()

2020-07-22 Thread Adalbert Lazăr
-developed-by: Ștefan Șicleru Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/vmx/capabilities.h | 8 arch/x86/kvm/vmx/vmx.c | 8 arch/x86/kvm/x86.c | 3 +++ 4 files changed, 21 insertions

[RFC PATCH v1 17/34] KVM: introspection: extend the access rights database with EPT view info

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru On EPT violations, when we check if the introspection tool has shown interest in the current guest page, we will take into consideration the EPT view of the current vCPU too. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvmi_host.h

[RFC PATCH v1 29/34] KVM: vmx: make use of EPTP_INDEX in vmx_handle_exit()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru If the guest has EPTP switching capabilities with VMFUNC, read the current view from VMCS instead of walking through the EPTP list when #VE support is active. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/vmx/vmx.c | 22

[RFC PATCH v1 03/34] KVM: x86: add kvm_get_ept_view()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru This function returns the EPT view of the current vCPU or 0 if the hardware support is missing. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/vmx/vmx.c | 8 arch/x86/kvm/vmx/vmx.h

[RFC PATCH v1 24/34] KVM: vmx: trigger vm-exits for mmio sptes by default when #VE is enabled

2020-07-22 Thread Adalbert Lazăr
h provided a new mask for non-mmio sptes. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/vmx/vmx.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 3428857c6157..b65bd0d144e5 100644

[RFC PATCH v1 30/34] KVM: vmx: make use of EPTP_INDEX in vmx_set_ept_view()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/vmx/vmx.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 035f6c43a2a4..736b6cc6ca8f 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b

[RFC PATCH v1 27/34] KVM: x86: add .disable_ve()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru This function is needed for the KVMI_VCPU_DISABLE_VE command. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 10 ++ 2 files changed, 11 insertions(+) diff --git a/arch/x86

[RFC PATCH v1 14/34] KVM: introspection: add 'view' field to struct kvmi_event_arch

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru Report the view a vCPU operates on when sending events to the introspection tool. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/uapi/asm/kvmi.h | 4 +++- arch/x86/kvm/kvmi.c | 1 + 2 files changed, 4 insertions(+), 1

[RFC PATCH v1 28/34] KVM: x86: page_track: add support for suppress #VE bit

2020-07-22 Thread Adalbert Lazăr
to how access rights are configured using the page tracking mechanism. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_page_track.h | 1 + arch/x86/kvm/mmu.h| 2 ++ arch/x86/kvm/mmu/mmu.c| 38

[RFC PATCH v1 16/34] KVM: introspection: add KVMI_VCPU_CONTROL_EPT_VIEW

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru This will be used by the introspection tool to control the EPT views to which the guest is allowed to switch. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 37 ++ arch/x86/include/uapi/asm/kvmi.h

[RFC PATCH v1 19/34] KVM: introspection: clean non-default EPTs on unhook

2020-07-22 Thread Adalbert Lazăr
-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/kvmi.c | 23 ++- virt/kvm/introspection/kvmi.c | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86

[RFC PATCH v1 32/34] KVM: introspection: add KVMI_VCPU_SET_VE_INFO/KVMI_VCPU_DISABLE_VE

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru The introspection tool can use #VE to reduce the number of VM-exits caused by SPT violations for some guests. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 63 +++ arch/x86/include/uapi/asm

[RFC PATCH v1 05/34] KVM: x86: mmu: add EPT view parameter to kvm_mmu_get_page()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru This will be used to create root_hpa for all the EPT views. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 7 +- arch/x86/kvm/mmu/mmu.c | 43 - arch/x86/kvm/mmu/paging_tmpl.h

[RFC PATCH v1 00/34] VM introspection - EPT Views and Virtualization Exceptions

2020-07-22 Thread Adalbert Lazăr
. Patches 31-34 extend the VM introspection API with #VE related commands. Adalbert Lazăr (2): KVM: x86: mmu: reindent to avoid lines longer than 80 chars KVM: introspection: mask out non-rwx flags when reading/writing from/to the internal database Marian Rotariu (5): KVM: x86: export

[RFC PATCH v1 20/34] KVM: x86: vmx: add support for virtualization exceptions

2020-07-22 Thread Adalbert Lazăr
From: Marian Rotariu Only the hardware support check function and the #VE info page management are introduced. Signed-off-by: Marian Rotariu Co-developed-by: Ștefan Șicleru Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86

[RFC PATCH v1 18/34] KVM: introspection: extend KVMI_VM_SET_PAGE_ACCESS with EPT view info

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru The introspection tool uses this command to set distinct access rights on different EPT views. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 8 +--- include/uapi/linux/kvmi.h | 4 ++-- virt/kvm/introspection

[RFC PATCH v1 09/34] KVM: x86: add .control_ept_view()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru This will be used by the introspection tool to control the EPT views to which the guest is allowed to switch. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 18

[RFC PATCH v1 13/34] KVM: introspection: add KVMI_VCPU_GET_EPT_VIEW

2020-07-22 Thread Adalbert Lazăr
Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 34 +++ arch/x86/include/uapi/asm/kvmi.h | 6 arch/x86/kvm/kvmi.c | 5 +++ include/uapi/linux/kvmi.h | 1 + .../testing/selftests/kvm

[RFC PATCH v1 01/34] KVM: x86: export .get_vmfunc_status()

2020-07-22 Thread Adalbert Lazăr
-by: Ștefan Șicleru Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 6 ++ 2 files changed, 7 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index d96bf0e15ea2

[RFC PATCH v1 08/34] KVM: x86: add .set_ept_view()

2020-07-22 Thread Adalbert Lazăr
-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 35 - 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 1035308940fe..300f7fc43987 100644

[RFC PATCH v1 33/34] KVM: introspection: mask out non-rwx flags when reading/writing from/to the internal database

2020-07-22 Thread Adalbert Lazăr
This is needed because the KVMI_VM_SET_PAGE_SVE command we will use the same database to keep the suppress #VE bit requested by the introspection tool. Signed-off-by: Adalbert Lazăr --- virt/kvm/introspection/kvmi.c | 36 --- 1 file changed, 25 insertions(+), 11

[RFC PATCH v1 22/34] KVM: VMX: Suppress EPT violation #VE by default (when enabled)

2020-07-22 Thread Adalbert Lazăr
tion #VEs are in use. Signed-off-by: Sean Christopherson Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/Makefile | 2 +- arch/x86/kvm/mmu.h | 1 + arch/x86/kvm/mmu/mmu.c | 22 +++--- arch/x86/kvm/vmx

[RFC PATCH v1 26/34] KVM: x86: add .set_ve_info()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru This function is needed for the KVMI_VCPU_SET_VE_INFO command. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx/vmx.c | 40

[RFC PATCH v1 34/34] KVM: introspection: add KVMI_VM_SET_PAGE_SVE

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru This command is used by the introspection tool to set/clear the suppress-VE bit for specific guest memory pages. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 42 + arch/x86/include/uapi/asm/kvmi.h

[RFC PATCH v1 15/34] KVM: introspection: add KVMI_VCPU_SET_EPT_VIEW

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru The introspection tool uses this function to check the hardware support for EPT switching, which can be used to singlestep vCPUs on a unprotected EPT view. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 36

[RFC PATCH v1 21/34] KVM: VMX: Define EPT suppress #VE bit (bit 63 in EPT leaf entries)

2020-07-22 Thread Adalbert Lazăr
"Suppress #VE" bit is ignored: - By hardware that does not support EPT violation #VEs - When the EPT violation #VE VMCS control is disabled - On non-leaf EPT entries Signed-off-by: Sean Christopherson Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/vmx.h | 1 + 1 fi

[RFC PATCH v1 12/34] KVM: introspection: extend struct kvmi_features with the EPT views status support

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru The introspection tool will use these new fields to check the hardware support before using the related introspection commands. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst| 6 -- arch/x86/include

[RFC PATCH v1 06/34] KVM: x86: mmu: add support for EPT switching

2020-07-22 Thread Adalbert Lazăr
-developed-by: Ștefan Șicleru Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu/mmu.c | 12 ++-- arch/x86/kvm/vmx/vmx.c | 98 + arch/x86/kvm/vmx/vmx.h | 1 + 4 files

[RFC PATCH v1 07/34] KVM: x86: mmu: increase mmu_memory_cache size

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru We use/allocate more root_hpa's every time mmu_alloc_roots() is called. Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/mmu/mmu.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm

[RFC PATCH v1 25/34] KVM: x86: svm: set .clear_page()

2020-07-22 Thread Adalbert Lazăr
From: Ștefan Șicleru Signed-off-by: Ștefan Șicleru Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/svm/svm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 5c2d4a0c3d31..1c78b913eb5d 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86

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

2020-12-07 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 ++ arch/x86/kvm/svm

[PATCH v11 13/81] KVM: x86: add kvm_x86_ops.control_desc_intercept()

2020-12-07 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_host.h | 1 + arch/x86/kvm/svm/svm.c | 26 ++ arch/x86/kvm/vmx/vmx.c | 15 +-- 3 files changed, 40 insertions

[PATCH v11 20/81] KVM: x86: add kvm_x86_ops.fault_gla()

2020-12-07 Thread Adalbert Lazăr
). kvm_page_track_emulation_failure() calls the page tracking code, that can trigger an event for the introspection tool (which might need the GVA in addition to the GPA). 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 --- arch/x86

[PATCH v11 23/81] KVM: x86: extend kvm_mmu_gva_to_gpa_system() with the 'access' parameter

2020-12-07 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 v11 27/81] KVM: x86: page track: provide all callbacks with the guest virtual address

2020-12-07 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 +- arch/x86/include/asm

[PATCH v11 21/81] KVM: x86: add kvm_x86_ops.control_singlestep()

2020-12-07 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_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 11 +++ 2 files changed, 12 insertions(+) diff --git a/arch/x86

[PATCH v11 32/81] KVM: introduce VM introspection

2020-12-07 Thread Adalbert Lazăr
-off-by: Mihai Donțu Co-developed-by: Marian Rotariu Signed-off-by: Marian Rotariu Signed-off-by: Adalbert Lazăr --- Documentation/virt/kvm/kvmi.rst | 139 ++ arch/x86/include/asm/kvm_host.h | 2 + arch/x86/kvm/Kconfig | 9 ++ arch/x86/kvm/Makefile

[PATCH v11 07/81] KVM: x86: avoid injecting #PF when emulate the VMCALL instruction

2020-12-07 Thread Adalbert Lazăr
and as such emulator_write_emulated() fails and we inject a write #PF, leading to a guest crash. Signed-off-by: Mihai Donțu Signed-off-by: Adalbert Lazăr --- arch/x86/kvm/x86.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5951458408fb

<    1   2   3   4   5   6   7   >