Re: [PATCH 2/7] KVM: x86: Implement Hyper-V's vCPU suspended state

2024-10-15 Thread Nicolas Saenz Julienne
Hi Sean, On Tue Oct 15, 2024 at 3:58 PM UTC, Sean Christopherson wrote: > Before we spend too much time cleaning things up, I want to first settle on > the > overall design, because it's not clear to me that punting > HvTranslateVirtualAddress > to userspace is a net positive. We agreed that VT

Re: [PATCH 16/18] KVM: x86: Take mem attributes into account when faulting memory

2024-08-22 Thread Nicolas Saenz Julienne
On Sun Jun 9, 2024 at 3:49 PM UTC, Nicolas Saenz Julienne wrote: > Take into account access restrictions memory attributes when faulting > guest memory. Prohibited memory accesses will cause an user-space fault > exit. > > Additionally, bypass a warning in the !tdp case. Access

Re: [PATCH 01/18] KVM: x86: hyper-v: Introduce XMM output support

2024-08-05 Thread Nicolas Saenz Julienne
On Mon Jul 29, 2024 at 1:53 PM UTC, Vitaly Kuznetsov wrote: > CAUTION: This email originated from outside of the organization. Do not click > links or open attachments unless you can confirm the sender and know the > content is safe. > Nicolas Saenz Julienne writes: > > >

Re: [PATCH 01/18] KVM: x86: hyper-v: Introduce XMM output support

2024-07-17 Thread Nicolas Saenz Julienne
Hi Vitaly, Thanks for having a look at this. On Mon Jul 8, 2024 at 2:59 PM UTC, Vitaly Kuznetsov wrote: > Nicolas Saenz Julienne writes: > > > Prepare infrastructure to be able to return data through the XMM > > registers when Hyper-V hypercalls are issues in fast mode. The XMM

Re: [PATCH 00/18] Introducing Core Building Blocks for Hyper-V VSM Emulation

2024-07-03 Thread Nicolas Saenz Julienne
Hi Vitaly, On Wed Jul 3, 2024 at 12:48 PM UTC, Vitaly Kuznetsov wrote: > Nicolas Saenz Julienne writes: > > > Hi Sean, > > > > On Sun Jun 9, 2024 at 3:49 PM UTC, Nicolas Saenz Julienne wrote: > >> This series introduces core KVM functionality necessary to emu

Re: [PATCH 00/18] Introducing Core Building Blocks for Hyper-V VSM Emulation

2024-07-03 Thread Nicolas Saenz Julienne
Hi Sean, On Sun Jun 9, 2024 at 3:49 PM UTC, Nicolas Saenz Julienne wrote: > This series introduces core KVM functionality necessary to emulate Hyper-V's > Virtual Secure Mode in a Virtual Machine Monitor (VMM). Just wanted to make sure the series is in your radar. Thanks, Nicolas

[PATCH 18/18] KVM: x86: hyper-v: Handle VSM hcalls in user-space

2024-06-09 Thread Nicolas Saenz Julienne
. Additionally, select KVM_GENERIC_MEMORY_ATTRIBUTES when CONFIG_KVM_HYPERV is enabled, as it's necessary in order to implement VTL memory protections. Signed-off-by: Nicolas Saenz Julienne --- Documentation/virt/kvm/api.rst| 23 +++ arch/x86/kvm/Kconfig | 1 +

[PATCH 17/18] KVM: Introduce traces to track memory attributes modification.

2024-06-09 Thread Nicolas Saenz Julienne
Introduce traces that track memory attributes modification. Signed-off-by: Nicolas Saenz Julienne --- include/trace/events/kvm.h | 20 virt/kvm/kvm_main.c| 2 ++ 2 files changed, 22 insertions(+) diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h

[PATCH 16/18] KVM: x86: Take mem attributes into account when faulting memory

2024-06-09 Thread Nicolas Saenz Julienne
emory attributes are in use. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 64 -- arch/x86/kvm/mmu/mmutrace.h| 29 +++ arch/x86/kvm/mmu/paging_tmpl.h | 2 +- include/linux/kvm_host.h | 4 +++ 4 files changed, 87 inser

[PATCH 15/18] KVM: Introduce RWX memory attributes

2024-06-09 Thread Nicolas Saenz Julienne
ses that have short-lived access restricted regions like Hyper-V's VSM. - A non-negated version of the flags has no way of expressing non-access mapping (NR/NW/NX) without having to introduce an extra flag (since 0 isn't available). Signed-off-by: Nicolas Saenz Julienne ---

[PATCH 14/18] KVM: x86/mmu: Init memslot if memory attributes available

2024-06-09 Thread Nicolas Saenz Julienne
Systems that lack private memory support are about to start using memory attributes. So query if the memory attributes xarray is empty in order to decide whether it's necessary to init the hugepage information when installing a new memslot. Signed-off-by: Nicolas Saenz Julienne --- arch/x8

[PATCH 13/18] KVM: x86/mmu: Avoid warning when installing non-private memory attributes

2024-06-09 Thread Nicolas Saenz Julienne
In preparation to introducing RWX memory attributes, make sure user-space is attempting to install a memory attribute with KVM_MEMORY_ATTRIBUTE_PRIVATE before throwing a warning on systems with no private memory support. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 8

[PATCH 12/18] KVM: x86/mmu: Introduce infrastructure to handle non-executable mappings

2024-06-09 Thread Nicolas Saenz Julienne
g new sptes. No functional change intended. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 6 +- arch/x86/kvm/mmu/mmu_internal.h | 2 ++ arch/x86/kvm/mmu/tdp_mmu.c | 8 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu/

[PATCH 11/18] KVM: x86: Pass the instruction length on memory fault user-space exits

2024-06-09 Thread Nicolas Saenz Julienne
of this additional information is indicated by a new capability, KVM_CAP_FAULT_EXIT_INSN_LEN. Signed-off-by: Nicolas Saenz Julienne --- Documentation/virt/kvm/api.rst | 6 +- arch/x86/kvm/mmu/mmu_internal.h | 2 +- arch/x86/kvm/x86.c | 1 + include/linux/kvm_host.h| 3

[PATCH 10/18] KVM: x86: Keep track of instruction length during faults

2024-06-09 Thread Nicolas Saenz Julienne
Both VMX and SVM provide the length of the instruction being run at the time of the page fault. Save it within 'struct kvm_page_fault', as it'll become useful in the future. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 11 --- a

[PATCH 09/18] KVM: Define and communicate KVM_EXIT_MEMORY_FAULT RWX flags to userspace

2024-06-09 Thread Nicolas Saenz Julienne
ff-by: Anish Moorthy Signed-off-by: Nicolas Saenz Julienne --- Documentation/virt/kvm/api.rst | 5 + include/linux/kvm_host.h | 9 - include/uapi/linux/kvm.h | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Documentation/virt/kvm/api.rst b/Document

[PATCH 08/18] KVM: x86: hyper-v: Exit on StartVirtualProcessor and GetVpIndexFromApicId hcalls

2024-06-09 Thread Nicolas Saenz Julienne
don't enable VSM. Signed-off-by: Nicolas Saenz Julienne --- Documentation/virt/kvm/api.rst| 11 +++ arch/x86/kvm/hyperv.c | 7 +++ include/asm-generic/hyperv-tlfs.h | 1 + 3 files changed, 19 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Document

[PATCH 07/18] KVM: x86: hyper-v: Exit on TranslateVirtualAddress hcall

2024-06-09 Thread Nicolas Saenz Julienne
main VSM commit. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 3 +++ include/asm-generic/hyperv-tlfs.h | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index d0edc2bec5a4f..cbe2aca52514b 100644 --- a/arch/x8

[PATCH 06/18] KVM: x86: hyper-v: Exit on Get/SetVpRegisters hcall

2024-06-09 Thread Nicolas Saenz Julienne
Let user-space handle HvGetVpRegisters and HvSetVpRegisters as they are VTL aware hypercalls used solely in the context of VSM. Additionally, expose the cpuid bit. Signed-off-by: Nicolas Saenz Julienne --- Documentation/virt/kvm/api.rst| 10 ++ arch/x86/kvm/hyperv.c | 15

[PATCH 05/18] KVM: x86: hyper-v: Introduce MP_STATE_HV_INACTIVE_VTL

2024-06-09 Thread Nicolas Saenz Julienne
space. Note that by re-using the readily available halt infrastructure in KVM_RUN, MP_STATE_HV_INACTIVE_VTL correctly handles (or disables) virtualisation features like the VMX preemption timer or APICv before blocking. Suggested-by: Maxim Levitsky Signed-off-by: Nicolas Saenz Julienne -

[PATCH 04/18] KVM: x86: hyper-v: Introduce VTL awareness to Hyper-V's PV-IPIs

2024-06-09 Thread Nicolas Saenz Julienne
x27;t introduce a behaviour change otherwise. User-space is accountable for the correct processing of the PV-IPI before resuming execution. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/x8

[PATCH 03/18] hyperv-tlfs: Update struct hv_send_ipi{_ex}'s declarations

2024-06-09 Thread Nicolas Saenz Julienne
Both 'struct hv_send_ipi' and 'struct hv_send_ipi_ex' have an 'union hv_input_vtl' parameter which has been ignored until now. Expose it, as KVM will soon provide a way of dealing with VTL-aware IPIs. While doing Also fixup __send_ipi_mask_ex(). Signed-off-by: Nic

[PATCH 02/18] KVM: x86: hyper-v: Introduce helpers to check if VSM is exposed to guest

2024-06-09 Thread Nicolas Saenz Julienne
Introduce a helper function to check if the guest exposes the VSM CPUID bit. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.h | 10 ++ include/asm-generic/hyperv-tlfs.h | 1 + 2 files changed, 11 insertions(+) diff --git a/arch/x86/kvm/hyperv.h b/arch/x86

[PATCH 01/18] KVM: x86: hyper-v: Introduce XMM output support

2024-06-09 Thread Nicolas Saenz Julienne
Prepare infrastructure to be able to return data through the XMM registers when Hyper-V hypercalls are issues in fast mode. The XMM registers are exposed to user-space through KVM_EXIT_HYPERV_HCALL and restored on successful hypercall completion. Signed-off-by: Nicolas Saenz Julienne --- There

[PATCH 00/18] Introducing Core Building Blocks for Hyper-V VSM Emulation

2024-06-09 Thread Nicolas Saenz Julienne
hub.com/vianpl/linux/tree/vsm-v1 --- Anish Moorthy (1): KVM: Define and communicate KVM_EXIT_MEMORY_FAULT RWX flags to userspace Nicolas Saenz Julienne (17): KVM: x86: hyper-v: Introduce XMM output support KVM: x86: hyper-v: Introduce helpers to check if VSM is exposed to guest hyp

Re: [RFC 05/33] KVM: x86: hyper-v: Introduce VTL call/return prologues in hypercall page

2023-12-01 Thread Nicolas Saenz Julienne
On Fri Dec 1, 2023 at 5:47 PM UTC, Sean Christopherson wrote: > CAUTION: This email originated from outside of the organization. Do not click > links or open attachments unless you can confirm the sender and know the > content is safe. > > > > On Fri, Dec 01, 2023, Nicolas

Re: [RFC 05/33] KVM: x86: hyper-v: Introduce VTL call/return prologues in hypercall page

2023-12-01 Thread Nicolas Saenz Julienne
On Fri Dec 1, 2023 at 4:32 PM UTC, Sean Christopherson wrote: > On Fri, Dec 01, 2023, Nicolas Saenz Julienne wrote: > > > To support this I think that we can add a userspace msr filter on the > > > HV_X64_MSR_HYPERCALL, > > > although I am not 100% sure if a user

Re: [RFC 06/33] KVM: x86: hyper-v: Introduce VTL awareness to Hyper-V's PV-IPIs

2023-12-01 Thread Nicolas Saenz Julienne
On Tue Nov 28, 2023 at 7:14 AM UTC, Maxim Levitsky wrote: > On Wed, 2023-11-08 at 11:17 +0000, Nicolas Saenz Julienne wrote: > > HVCALL_SEND_IPI and HVCALL_SEND_IPI_EX allow targeting specific a > > specific VTL. Honour the requests. > > > > Signed-off-by: Nicolas Saenz

Re: [RFC 05/33] KVM: x86: hyper-v: Introduce VTL call/return prologues in hypercall page

2023-12-01 Thread Nicolas Saenz Julienne
o EAX/RCX before calling the hypercall instruction in > > order to be able to use the Hyper-V hypercall entry function. > > > > Guests can read an emulated code page offsets register to know the > > offsets into the hypercall page for the VTL call/return entries. > >

Re: [RFC 02/33] KVM: x86: Introduce KVM_CAP_APIC_ID_GROUPS

2023-12-01 Thread Nicolas Saenz Julienne
Hi Maxim, On Tue Nov 28, 2023 at 6:56 AM UTC, Maxim Levitsky wrote: > On Wed, 2023-11-08 at 11:17 +0000, Nicolas Saenz Julienne wrote: > > From: Anel Orazgaliyeva > > > > Introduce KVM_CAP_APIC_ID_GROUPS, this capability segments the VM's APIC > > ids into two. T

Re: [RFC 0/33] KVM: x86: hyperv: Introduce VSM support

2023-11-11 Thread Nicolas Saenz Julienne
On Fri Nov 10, 2023 at 7:32 PM UTC, Sean Christopherson wrote: > On Fri, Nov 10, 2023, Nicolas Saenz Julienne wrote: > > On Wed Nov 8, 2023 at 6:33 PM UTC, Sean Christopherson wrote: > > > - What is the split between userspace and KVM? How did you arrive at > > &

Re: [RFC 0/33] KVM: x86: hyperv: Introduce VSM support

2023-11-10 Thread Nicolas Saenz Julienne
On Wed Nov 8, 2023 at 4:55 PM UTC, Sean Christopherson wrote: > > This RFC series introduces the necessary infrastructure to emulate VSM > > enabled guests. It is a snapshot of the progress we made so far, and its > > main goal is to gather design feedback. > > Heh, then please provide an overview

Re: [RFC 14/33] KVM: x86: Add VTL to the MMU role

2023-11-10 Thread Nicolas Saenz Julienne
On Wed Nov 8, 2023 at 5:26 PM UTC, Sean Christopherson wrote: > On Wed, Nov 08, 2023, Nicolas Saenz Julienne wrote: > > With the upcoming introduction of per-VTL memory protections, make MMU > > roles VTL aware. This will avoid sharing PTEs between vCPUs that belong > > to dif

Re: [RFC 02/33] KVM: x86: Introduce KVM_CAP_APIC_ID_GROUPS

2023-11-10 Thread Nicolas Saenz Julienne
On Wed Nov 8, 2023 at 5:47 PM UTC, Sean Christopherson wrote: > On Wed, Nov 08, 2023, Nicolas Saenz Julienne wrote: > > From: Anel Orazgaliyeva > > > > Introduce KVM_CAP_APIC_ID_GROUPS, this capability segments the VM's APIC > > ids into two. The lower bits, the

Re: [RFC 0/33] KVM: x86: hyperv: Introduce VSM support

2023-11-10 Thread Nicolas Saenz Julienne
08, 2023, Nicolas Saenz Julienne wrote: > > > This RFC series introduces the necessary infrastructure to emulate VSM > > > enabled guests. It is a snapshot of the progress we made so far, and its > > > main goal is to gather design feedback. > > > > Heh, th

Re: [RFC 0/33] KVM: x86: hyperv: Introduce VSM support

2023-11-08 Thread Nicolas Saenz Julienne
On Wed Nov 8, 2023 at 11:40 AM UTC, Alexander Graf wrote: > Hey Nicolas, [...] > > The series is accompanied by two repositories: > > - A PoC QEMU implementation of VSM [3]. > > - VSM kvm-unit-tests [4]. > > > > Note that this isn't a full VSM implementation. For now it only supports > > 2 VT

Re: [RFC 05/33] KVM: x86: hyper-v: Introduce VTL call/return prologues in hypercall page

2023-11-08 Thread Nicolas Saenz Julienne
On Wed Nov 8, 2023 at 11:53 AM UTC, Alexander Graf wrote: [...] > > @@ -285,6 +286,81 @@ static int patch_hypercall_page(struct kvm_vcpu *vcpu, > > u64 data) > > /* ret */ > > ((unsigned char *)instructions)[i++] = 0xc3; > > > > + /* VTL call/return entries */ > > + if (!kvm_xen_h

Re: [RFC 09/33] KVM: x86: hyper-v: Introduce per-VTL vcpu helpers

2023-11-08 Thread Nicolas Saenz Julienne
On Wed Nov 8, 2023 at 12:21 PM UTC, Alexander Graf wrote: > > On 08.11.23 12:17, Nicolas Saenz Julienne wrote: > > Introduce two helper functions. The first one queries a vCPU's VTL > > level, the second one, given a struct kvm_vcpu and VTL pair, returns the > > c

Re: [RFC 32/33] KVM: x86: hyper-v: Implement HVCALL_TRANSLATE_VIRTUAL_ADDRESS

2023-11-08 Thread Nicolas Saenz Julienne
On Wed Nov 8, 2023 at 12:49 PM UTC, Alexander Graf wrote: > > On 08.11.23 12:18, Nicolas Saenz Julienne wrote: > > Introduce HVCALL_TRANSLATE_VIRTUAL_ADDRESS, the hypercall receives a > > GVA, generally from a less privileged VTL, and returns the GPA backing > > it. The

Re: [RFC 30/33] KVM: x86: hyper-v: Introduce KVM_REQ_HV_INJECT_INTERCEPT request

2023-11-08 Thread Nicolas Saenz Julienne
On Wed Nov 8, 2023 at 12:45 PM UTC, Alexander Graf wrote: > > On 08.11.23 12:18, Nicolas Saenz Julienne wrote: > > Introduce a new request type, KVM_REQ_HV_INJECT_INTERCEPT which allows > > injecting out-of-band Hyper-V secure intercepts. For now only memory > > access

[RFC 33/33] Documentation: KVM: Introduce "Emulating Hyper-V VSM with KVM"

2023-11-08 Thread Nicolas Saenz Julienne
Introduce "Emulating Hyper-V VSM with KVM", which describes the KVM APIs made available to a VMM that wants to emulate Hyper-V's VSM. Signed-off-by: Nicolas Saenz Julienne --- .../virt/kvm/x86/emulating-hyperv-vsm.rst | 136 ++ 1 file changed, 136 insertions(

[RFC 32/33] KVM: x86: hyper-v: Implement HVCALL_TRANSLATE_VIRTUAL_ADDRESS

2023-11-08 Thread Nicolas Saenz Julienne
mpletion. Additionally we'd like to move the VTL aware parts to user-space. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 98 +++ arch/x86/kvm/trace.h | 23 include/asm-generic/hyperv-tlfs.h | 28 + 3

[RFC 31/33] KVM: x86: hyper-v: Inject intercept on VTL memory protection fault

2023-11-08 Thread Nicolas Saenz Julienne
vCPU that took the fault will exit to user-space with a memory fault. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 38ee3abdef9c..983bf8af5f64 1

[RFC 30/33] KVM: x86: hyper-v: Introduce KVM_REQ_HV_INJECT_INTERCEPT request

2023-11-08 Thread Nicolas Saenz Julienne
provided through struct kvm_vcpu_hv_intercept_info, and injected into the guest through SynIC message. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/asm/kvm_host.h | 10 +++ arch/x86/kvm/hyperv.c | 114 arch/x86/kvm/hyperv.h | 2

[RFC 29/33] KVM: VMX: Save instruction length on EPT violation

2023-11-08 Thread Nicolas Saenz Julienne
Save the length of the instruction that triggered an EPT violation in struct kvm_vcpu_arch. This will be used to populate Hyper-V VSM memory intercept messages. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/vmx/vmx.c | 1 + 2 files

[RFC 27/33] KVM: x86/mmu/hyper-v: Validate memory faults against per-VTL memprots

2023-11-08 Thread Nicolas Saenz Julienne
t->map_writable'. Non VSM users shouldn't see any behaviour change. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 66 ++ arch/x86/kvm/hyperv.h | 1 + arch/x86/kvm/mmu/mmu.c | 9 +- 3 files changed, 75 insertions(+),

[RFC 28/33] x86/hyper-v: Introduce memory intercept message structure

2023-11-08 Thread Nicolas Saenz Julienne
Introduce struct hv_memory_intercept_message, which is used when issuing memory intercepts to a Hyper-V VSM guest. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/asm/hyperv-tlfs.h | 76 ++ 1 file changed, 76 insertions(+) diff --git a/arch/x86/include

[RFC 24/33] KVM: x86: hyper-v: Introduce KVM VTL device

2023-11-08 Thread Nicolas Saenz Julienne
y registered if the VSM cap is enabled. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c| 68 arch/x86/kvm/hyperv.h| 3 ++ arch/x86/kvm/x86.c | 3 ++ include/uapi/linux/kvm.h | 5 +++ 4 files changed, 79 insertions(+) diff -

[RFC 26/33] KVM: x86: hyper-vsm: Allow setting per-VTL memory attributes

2023-11-08 Thread Nicolas Saenz Julienne
- KVM_MEMORY_ATTRIBUTE_NO_ACCESS Although only some combinations are valid, see code comment below. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 61 +++ 1 file changed, 61 insertions(+) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index

[RFC 25/33] KVM: Introduce a set of new memory attributes

2023-11-08 Thread Nicolas Saenz Julienne
memory protections of the backing memory, versus explicitly prohibiting any access to that gfn. These new memory attributes will, for now, only made be available through the VSM KVM device (which we introduce in subsequent patches). Signed-off-by: Nicolas Saenz Julienne --- include/uapi/linux

[RFC 23/33] KVM: Expose memory attribute helper functions unanimously

2023-11-08 Thread Nicolas Saenz Julienne
Expose memory attribute helper functions even when CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES is disabled. Other KVM features, like Hyper-V VSM, make use of memory attributes but don't rely on the KVM ioctl. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 2 +- include/

[RFC 22/33] KVM: Decouple kvm_ioctl_set_mem_attributes() from kvm's mem_attr_array

2023-11-08 Thread Nicolas Saenz Julienne
reuse kvm_ioctl_set_mem_attributes() by decoupling it from struct kvm's mem_attr_array. The xarray is now input as a function argument as well as the list of supported memory attributes. Signed-off-by: Nicolas Saenz Julienne --- include/linux/kvm_host.h | 3 +++ virt/kvm/kvm_main.c

[RFC 21/33] KVM: Pass memory attribute array as a MMU notifier argument

2023-11-08 Thread Nicolas Saenz Julienne
Pass the memory attribute array through struct kvm_mmu_notifier_arg and use it in kvm_arch_post_set_memory_attributes() instead of defaulting on kvm->mem_attr_array. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 8 include/linux/kvm_host.h | 5 - virt/

[RFC 19/33] KVM: x86: Decouple kvm_range_has_memory_attributes() from struct kvm's mem_attr_array

2023-11-08 Thread Nicolas Saenz Julienne
Decouple kvm_range_has_memory_attributes() from struct kvm's mem_attr_array to allow other memory attribute sources to use the function. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 3 ++- include/linux/kvm_host.h | 4 ++-- virt/kvm/kvm_main.c | 9 + 3

[RFC 20/33] KVM: x86/mmu: Decouple hugepage_has_attrs() from struct kvm's mem_attr_array

2023-11-08 Thread Nicolas Saenz Julienne
Decouple hugepage_has_attrs() from struct kvm's mem_attr_array to allow other memory attribute sources to use the function. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/x86/kv

[RFC 18/33] KVM: x86: Decouple kvm_get_memory_attributes() from struct kvm's mem_attr_array

2023-11-08 Thread Nicolas Saenz Julienne
Decouple kvm_get_memory_attributes() from struct kvm's mem_attr_array to allow other memory attribute sources to use the function. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 5 +++-- include/linux/kvm_host.h | 8 +--- 2 files changed, 8 insertions(+), 5 dele

[RFC 17/33] KVM: x86/mmu: Allow setting memory attributes if VSM enabled

2023-11-08 Thread Nicolas Saenz Julienne
VSM is also a user of memory attributes, so let it use kvm_set_mem_attributes(). Signed-off-by: Nicolas Saenz Julienne --- 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/mmu/mmu.c index feca077c0210

[RFC 16/33] KVM: x86/mmu: Expose R/W/X flags during memory fault exits

2023-11-08 Thread Nicolas Saenz Julienne
Include the fault's read, write and execute status when exiting to user-space. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/mmu/mmu.c | 4 ++-- include/linux/kvm_host.h | 9 +++-- include/uapi/linux/kvm.h | 6 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff

[RFC 15/33] KVM: x86/mmu: Introduce infrastructure to handle non-executable faults

2023-11-08 Thread Nicolas Saenz Julienne
The upcoming per-VTL memory protections support needs to fault in non-executable memory. Introduce a new attribute in struct kvm_page_fault, map_executable, to control whether the gfn range should be mapped as executable. No functional change intended. Signed-off-by: Nicolas Saenz Julienne

[RFC 13/33] KVM: Allow polling vCPUs for events

2023-11-08 Thread Nicolas Saenz Julienne
hread re-entering the guest. This hardly affects the use-cases stated above, but needs to be fixed. - This was tested alongside a WIP Hyper-V Virtual Trust Level implementation which makes ample use of the poll() interface. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/x86.c

[RFC 14/33] KVM: x86: Add VTL to the MMU role

2023-11-08 Thread Nicolas Saenz Julienne
states there is a maximum of 16 levels. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/hyperv.h | 6 ++ arch/x86/kvm/mmu.h | 1 + arch/x86/kvm/mmu/mmu.c | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff

[RFC 12/33] KVM: x86: hyper-v: Handle VSM hcalls in user-space

2023-11-08 Thread Nicolas Saenz Julienne
KVM_EXIT_HYPERV_HVCALL exit. Additionally, expose the cpuid bit. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 15 +++ include/asm-generic/hyperv-tlfs.h | 7 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm

[RFC 11/33] KVM: x86: hyper-v: Handle GET/SET_VP_REGISTER hcall in user-space

2023-11-08 Thread Nicolas Saenz Julienne
Let user-space handle HVCALL_GET_VP_REGISTERS and HVCALL_SET_VP_REGISTERS through the KVM_EXIT_HYPERV_HVCALL exit reason. Additionally, expose the cpuid bit. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 9 + include/asm-generic/hyperv-tlfs.h | 1 + 2

[RFC 10/33] KVM: x86: hyper-v: Introduce KVM_HV_GET_VSM_STATE

2023-11-08 Thread Nicolas Saenz Julienne
information through a VTL KVM device attribute (the device is introduced in subsequent patches). Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/uapi/asm/kvm.h | 5 + arch/x86/kvm/hyperv.c | 8 arch/x86/kvm/hyperv.h | 2 ++ arch/x86/kvm/x86.c

[RFC 09/33] KVM: x86: hyper-v: Introduce per-VTL vcpu helpers

2023-11-08 Thread Nicolas Saenz Julienne
ach level. VTL-vCPUs that belong to the same guest CPU share the same physical APIC id, but belong to different APIC groups where the apic group represents the vCPU's VTL. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.h | 18 ++ 1 file changed, 18 insertions(+)

[RFC 07/33] KVM: x86: hyper-v: Introduce KVM_CAP_HYPERV_VSM

2023-11-08 Thread Nicolas Saenz Julienne
Introduce a new capability to enable Hyper-V Virtual Secure Mode (VSM) emulation support. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/hyperv.h | 5 + arch/x86/kvm/x86.c | 5 + include/uapi/linux/kvm.h| 1

[RFC 08/33] KVM: x86: Don't use hv_timer if CAP_HYPERV_VSM enabled

2023-11-08 Thread Nicolas Saenz Julienne
ject interrupts regardless of their runstate. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/lapic.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index f55d216cb2a0..8cc75b24381b 100644 --- a/arch/x86/kvm/lapic.c +++

[RFC 06/33] KVM: x86: hyper-v: Introduce VTL awareness to Hyper-V's PV-IPIs

2023-11-08 Thread Nicolas Saenz Julienne
HVCALL_SEND_IPI and HVCALL_SEND_IPI_EX allow targeting specific a specific VTL. Honour the requests. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 24 +--- arch/x86/kvm/trace.h | 20 include/asm-generic/hyperv

[RFC 05/33] KVM: x86: hyper-v: Introduce VTL call/return prologues in hypercall page

2023-11-08 Thread Nicolas Saenz Julienne
le to use the Hyper-V hypercall entry function. Guests can read an emulated code page offsets register to know the offsets into the hypercall page for the VTL call/return entries. Signed-off-by: Nicolas Saenz Julienne --- My tree has the additional patch, we're still trying to understand

[RFC 04/33] KVM: x86: hyper-v: Move hypercall page handling into separate function

2023-11-08 Thread Nicolas Saenz Julienne
The hypercall page patching is about to grow considerably, move it into its own function. No functional change intended. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/hyperv.c | 69 --- 1 file changed, 39 insertions(+), 30 deletions(-) diff

[RFC 03/33] KVM: x86: hyper-v: Introduce XMM output support

2023-11-08 Thread Nicolas Saenz Julienne
Prepare infrastructure to be able to return data through the XMM registers when Hyper-V hypercalls are issues in fast mode. The XMM registers are exposed to user-space through KVM_EXIT_HYPERV_HCALL and restored on successful hypercall completion. Signed-off-by: Nicolas Saenz Julienne --- arch

[RFC 01/33] KVM: x86: Decouple lapic.h from hyperv.h

2023-11-08 Thread Nicolas Saenz Julienne
lapic.h has no dependencies with hyperv.h, so don't include it there. Additionally, cpuid.c implicitly relied on hyperv.h's inclusion through lapic.h, so include it explicitly there. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/kvm/cpuid.c | 1 + arch/x86/kvm/lapic.h | 1

[RFC 02/33] KVM: x86: Introduce KVM_CAP_APIC_ID_GROUPS

2023-11-08 Thread Nicolas Saenz Julienne
igned-off-by: Anel Orazgaliyeva Co-developed-by: Nicolas Saenz Julienne Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/asm/kvm_host.h | 3 ++ arch/x86/include/uapi/asm/kvm.h | 5 +++ arch/x86/kvm/lapic.c| 59 - arch/x86/kvm/lapic.h

[RFC 0/33] KVM: x86: hyperv: Introduce VSM support

2023-11-08 Thread Nicolas Saenz Julienne
Hyper-V's Virtual Secure Mode (VSM) is a virtualisation security feature that leverages the hypervisor to create secure execution environments within a guest. VSM is documented as part of Microsoft's Hypervisor Top Level Functional Specification [1]. Security features that build upon VSM, like Wind

[PATCH] tty: serial: meson: Add earlycon support

2016-02-07 Thread Nicolas Saenz Julienne
Signed-off-by: Nicolas Saenz Julienne --- Documentation/kernel-parameters.txt | 6 ++ drivers/tty/serial/meson_uart.c | 22 ++ 2 files changed, 28 insertions(+) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 551ecf0