Re: [PATCH V3 2/3] HYPERV/IOMMU: Add Hyper-V stub IOMMU driver

2019-02-07 Thread Vitaly Kuznetsov
lantianyu1...@gmail.com writes: > From: Lan Tianyu > > On the bare metal, enabling X2APIC mode requires interrupt remapping > function which helps to deliver irq to cpu with 32-bit APIC ID. > Hyper-V doesn't provide interrupt remapping function so far and Hyper-V > MSI protocol already supports

[PATCH] x86/kvm/nVMX: read from MSR_IA32_VMX_PROCBASED_CTLS2 only when it is available

2019-02-07 Thread Vitaly Kuznetsov
check. Reported-by: Zdenek Kaspar Tested-by: Zdenek Kaspar Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx/nested.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 653830d0f3da..4bd0902bfd8c 100644 --- a/arc

Re: [PATCH 2/3] HYPERV/IOMMU: Add Hyper-V stub IOMMU driver

2019-01-31 Thread Vitaly Kuznetsov
lantianyu1...@gmail.com writes: > From: Lan Tianyu > > On the bare metal, enabling X2APIC mode requires interrupt remapping > function which helps to deliver irq to cpu with 32-bit APIC ID. > Hyper-V doesn't provide interrupt remapping function so far and Hyper-V > MSI protocol already supports

Re: [PATCH v2 2/2] x86/kvm/hyper-v: recommend using eVMCS only when it is enabled

2019-01-25 Thread Vitaly Kuznetsov
Vitaly Kuznetsov writes: > We shouldn't probably be suggesting using Enlightened VMCS when it's not > enabled (not supported from guest's point of view). Hyper-V on KVM seems > to be fine either way but let's be consistent. > Fixes: 2bc39970e932 ("x86/kvm/h

[PATCH v2 2/2] x86/kvm/hyper-v: recommend using eVMCS only when it is enabled

2019-01-25 Thread Vitaly Kuznetsov
We shouldn't probably be suggesting using Enlightened VMCS when it's not enabled (not supported from guest's point of view). Hyper-V on KVM seems to be fine either way but let's be consistent. Reviewed-by: Liran Alon Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 3 ++- 1 file

[PATCH v2 1/2] x86/kvm/hyper-v: don't recommend doing reset via synthetic MSR

2019-01-25 Thread Vitaly Kuznetsov
System reset through synthetic MSR is not recommended neither by genuine Hyper-V nor my QEMU. Fixes: 2bc39970e932 ("x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID") Signed-off-by: Vitaly Kuznetsov Reviewed-by: Liran Alon --- arch/x86/kvm/hyperv.c | 1 - 1 file changed,

[PATCH v2 0/2] tweak HYPERV_CPUID_ENLIGHTMENT_INFO

2019-01-25 Thread Vitaly Kuznetsov
Be more consistent with genuine Hyper-V: don't recommend using Enlightened VMCS when it wasn't enabled, don't advertise reset via synthetic MSR. Vitaly Kuznetsov (2): x86/kvm/hyper-v: don't recommend doing reset via synthetic MSR x86/kvm/hyper-v: recommend using eVMCS only when it is enabled

Re: [PATCH] x86/kvm/hyper-v: tweak HYPERV_CPUID_ENLIGHTMENT_INFO

2019-01-24 Thread Vitaly Kuznetsov
Liran Alon writes: >> On 24 Jan 2019, at 19:15, Vitaly Kuznetsov wrote: >> >> We shouldn't probably be suggesting using Enlightened VMCS when it's not >> enabled (not supported from guest's point of view). System reset through >> synthetic MSR is not recommended

[PATCH] x86/kvm/hyper-v: tweak HYPERV_CPUID_ENLIGHTMENT_INFO

2019-01-24 Thread Vitaly Kuznetsov
: 2bc39970e932 ("x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID") Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index ac44a681f065..4730fcaa70cf 100644 --- a/ar

[PATCH] x86/kvm/hyper-v: don't announce GUEST IDLE MSR support

2019-01-24 Thread Vitaly Kuznetsov
HV_X64_MSR_GUEST_IDLE_AVAILABLE appeared in kvm_vcpu_ioctl_get_hv_cpuid() by mistake: it announces support for HV_X64_MSR_GUEST_IDLE (0x40F0) which we don't support in KVM (yet). Fixes: 2bc39970e932 ("x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID") Signed-off-by: Vitaly

Re: [PATCH 1/2] PCI: hv: Replace hv_vp_set with hv_vpset

2019-01-24 Thread Vitaly Kuznetsov
Maya Nakamura writes: > Remove a duplicate definition of VP set (hv_vp_set) and use the common > definition (hv_vpset) that is used in other places. > > Signed-off-by: Maya Nakamura > --- > drivers/pci/controller/pci-hyperv.c | 25 - > 1 file changed, 12 insertions(+),

Re: [PATCH] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1

2019-01-21 Thread Vitaly Kuznetsov
Vitaly Kuznetsov writes: > kvm-unit-tests' eventinj "NMI failing on IDT" test results in NMI being > delivered to the host (L1) when it's running nested. The problem seems to > be: svm_complete_interrupts() raises 'nmi_injected' flag but later we > decide to reflect EX

[PATCH 2/2] KVM: selftests: check returned evmcs version range

2019-01-17 Thread Vitaly Kuznetsov
Check that KVM_CAP_HYPERV_ENLIGHTENED_VMCS returns correct version range. Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/x86_64/evmcs_test.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64/evmcs_test.c b/tools/testing/selftests/kvm

[PATCH 1/2] x86/kvm/hyper-v: nested_enable_evmcs() sets vmcs_version incorrectly

2019-01-17 Thread Vitaly Kuznetsov
ssue by re-arranging things in nested_enable_evmcs(). Fixes: e2e871ab2f02 ("x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper") Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx/evmcs.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vm

[PATCH 0/2] x86/kvm/hyper-v: fix KVM_CAP_HYPERV_ENLIGHTENED_VMCS

2019-01-17 Thread Vitaly Kuznetsov
fix could be queued before 5.0. Vitaly Kuznetsov (2): x86/kvm/hyper-v: nested_enable_evmcs() sets vmcs_version incorrectly KVM: selftests: check returned evmcs version range arch/x86/kvm/vmx/evmcs.c| 7 --- tools/testing/selftests/kvm/x86_64/evmcs_test.c | 6 +

Re: [PATCH] x86/intel_rdt: use rdmsr_safe() to workaround AWS host issue

2019-01-10 Thread Vitaly Kuznetsov
Tony Luck writes: > On Wed, Jan 9, 2019 at 5:00 AM Borislav Petkov wrote: >> >> On Wed, Jan 09, 2019 at 01:09:31PM +0100, Vitaly Kuznetsov wrote: >> > Hm, why is that? In theory, hypervisors can pass through or emulate the >> > required MSRs... >> >>

[PATCH] x86/kvm/nVMX: don't skip emulated instruction twice when vmptr address is not backed

2019-01-09 Thread Vitaly Kuznetsov
ce. Fixes: fca91f6d60b6e ("kvm: nVMX: Set VM instruction error for VMPTRLD of unbacked page") Reported-by: Cornelia Huck Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx/nested.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kv

Re: [PATCH] x86/intel_rdt: use rdmsr_safe() to workaround AWS host issue

2019-01-09 Thread Vitaly Kuznetsov
Borislav Petkov writes: > So, assuming RDT is not going to be supported in a guest Hm, why is that? In theory, hypervisors can pass through or emulate the required MSRs... -- Vitaly

Re: [PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-08 Thread Vitaly Kuznetsov
Dan Carpenter writes: > On Mon, Jan 07, 2019 at 07:38:20PM +0100, Vitaly Kuznetsov wrote: >> (I remember Greg disliked when people were tagging patches for stable@ >> themselves, he prefered maintainers deciding if the particular commit >> deserves stable@ or not - but as y

Re: [PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-08 Thread Vitaly Kuznetsov
David Hildenbrand writes: > On 07.01.19 14:44, Vitaly Kuznetsov wrote: >> David Hildenbrand writes: >> ... >>> On 04.01.19 15:19, Vitaly Kuznetsov wrote: >>>>if (start_pfn > has->start_pfn && >>>>

[PATCH] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1

2019-01-07 Thread Vitaly Kuznetsov
injection upon entry so it got delivered to L1 instead of L2. It seems that VMX code solves the same issue in prepare_vmcs12(), this was introduced with code refactoring in commit 5f3d5799974b ("KVM: nVMX: Rework event injection and recovery"). Signed-off-by: Vitaly Kuznetsov --- ar

Re: [PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-07 Thread Vitaly Kuznetsov
Sasha Levin writes: > On Mon, Jan 07, 2019 at 02:44:30PM +0100, Vitaly Kuznetsov wrote: >>P.S. I still think about bringing mem_hotplug_begin()/done() to >>hv_balloon but that's going to be a separate discussion, here I want to >>have a small fix backportable to stable. >

Re: [PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-07 Thread Vitaly Kuznetsov
David Hildenbrand writes: > On 04.01.19 15:19, Vitaly Kuznetsov wrote: >> Hyper-V memory hotplug protocol has 2M granularity and in Linux x86 we use >> 128M. To deal with it we implement partial section onlining by registering >> custom page onlining callback (hv_online_page

[PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-04 Thread Vitaly Kuznetsov
pages and checks sections instead. But in Hyper-V balloon driver we do PageReserved(pfn_to_page()) check and this is now wrong. Switch to checking online_section_nr() instead. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 10 ++ 1 file changed, 6 insertions(+), 4

Re: [PATCH] KVM: x86: svm: report MSR_IA32_MCG_EXT_CTL as unsupported

2018-12-21 Thread Vitaly Kuznetsov
Radim Krčmář writes: > 2018-12-19 12:06+0100, Vitaly Kuznetsov: >> AMD doesn't seem to implement MSR_IA32_MCG_EXT_CTL and svm code in kvm >> knows nothing about it, however, this MSR is among emulated_msrs and >> thus returned with KVM_GET_MSR_INDEX_LIST. The co

Re: [PATCH] x86/intel_rdt: use rdmsr_safe() to workaround AWS host issue

2018-12-20 Thread Vitaly Kuznetsov
Borislav Petkov writes: > On Thu, Dec 20, 2018 at 02:40:46PM +0100, Vitaly Kuznetsov wrote: >> It was found that AWS x1 instances (Xen-based) lack xen.git commit >> 1f1d183d4900 (x86/HVM: don't give the wrong impression of WRMSR succeeding) >> and because of that t

[PATCH] x86/intel_rdt: use rdmsr_safe() to workaround AWS host issue

2018-12-20 Thread Vitaly Kuznetsov
: RDMSR from 0xc90 at rIP: 0x88c5bba3 (native_read_msr+0x3/0x30) The issue should definitely get fixed on AWS side. We can, however, simply workaround this in Linux and live happily after. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kernel/cpu/intel_rdt.c | 3 ++- 1 file changed, 2

[PATCH] KVM: x86: nSVM: fix switch to guest mmu

2018-12-19 Thread Vitaly Kuznetsov
ation is needed") Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/svm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index b78c691adea2..38821b0b78da 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2923,6 +2923,8

[PATCH] selftests: kvm: report failed stage when exit reason is unexpected

2018-12-19 Thread Vitaly Kuznetsov
xit reason: 8 (SHUTDOWN), it is not obvious which particular stage failed. Add the info. Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/x86_64/evmcs_test.c | 4 ++-- tools/testing/selftests/kvm/x86_64/state_test.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --

[PATCH] KVM: x86: svm: report MSR_IA32_MCG_EXT_CTL as unsupported

2018-12-19 Thread Vitaly Kuznetsov
-by: Vitaly Kuznetsov --- arch/x86/kvm/svm.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 2acb42b74a51..dfdf7d0b7f88 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -5845,6 +5845,13 @@ static bool svm_cpu_has_accelerated_tpr

Re: [PATCH v2 0/7] x86/kvm/hyper-v: Implement KVM_GET_SUPPORTED_HV_CPUID

2018-12-18 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 17/12/18 11:30, Vitaly Kuznetsov wrote: >>> Queued, thanks. I moved this above the direct EOI series so that >>> KVM_CAP_HYPERV_STIMER_DIRECT need not exist at any point of the history. >>> >> Thanks! Just to make sure (and t

Re: [PATCH v2 0/7] x86/kvm/hyper-v: Implement KVM_GET_SUPPORTED_HV_CPUID

2018-12-17 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > > Queued, thanks. I moved this above the direct EOI series so that > KVM_CAP_HYPERV_STIMER_DIRECT need not exist at any point of the history. > Thanks! Just to make sure (and to conclude our discussion with Roman): with your Qemu maintainer hat on, do you agree with the

Re: [PATCH v6 05/13] KVM: nVMX: implement enlightened VMPTRLD and VMCLEAR

2018-12-13 Thread Vitaly Kuznetsov
Jim Mattson writes: > On Tue, Oct 16, 2018 at 9:50 AM Vitaly Kuznetsov wrote: >> >> + >> + vmx->nested.hv_evmcs = kmap(vmx->nested.hv_evmcs_page); > > Are you sure that directly mapping guest memory isn't going to lead to > time-of-check vs. t

[PATCH v4] x86/hyper-v: Mark TLFS structures packed

2018-12-12 Thread Vitaly Kuznetsov
this. 'struct hv_vp_assist_page' and 'struct hv_enlightened_vmcs' need to be properly padded to support the change. Suggested-by: Nadav Amit Signed-off-by: Vitaly Kuznetsov Acked-by: Thomas Gleixner Acked-by: Nadav Amit Reviewed-by: Michael Kelley --- - Changes since v3: - Properly pad

Re: [PATCH v3] x86/hyper-v: Mark TLFS structures packed

2018-12-12 Thread Vitaly Kuznetsov
Vitaly Kuznetsov writes: > /* Define virtual processor assist page structure. */ > struct hv_vp_assist_page { > @@ -519,7 +519,7 @@ struct hv_vp_assist_page { > __u64 nested_enlightenments_control[2]; > __u32 enlighten_vmentry; > __u64 current_nested_vmcs; &

[PATCH v2 0/2] x86/kvm/hyper-v: Direct Mode stimers fixes

2018-12-12 Thread Vitaly Kuznetsov
be merged with the original patch implementing direct mode stimers or just put on top. Vitaly Kuznetsov (2): x86/hyper-v: Stop caring about EOI for direct stimers x86/kvm/hyper-v: disallow setting illegal vectors for direct mode stimers arch/x86/kvm/hyp

[PATCH v2 1/2] x86/hyper-v: Stop caring about EOI for direct stimers

2018-12-12 Thread Vitaly Kuznetsov
()). Remove the redundant part. Suggested-by: Roman Kagan Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 36 +++- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index e6a2a085644a..0a16a77e6ac3

[PATCH v2 2/2] x86/kvm/hyper-v: disallow setting illegal vectors for direct mode stimers

2018-12-12 Thread Vitaly Kuznetsov
APIC vectors used for direct mode stimers should be valid for lAPIC and just like genuine Hyper-V we should #GP when an illegal one is specified. Add the appropriate check to stimer_set_config() Suggested-by: Roman Kagan Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 5 + 1

Re: [PATCH] x86/hyper-v: Stop caring about EOI for direct stimers

2018-12-12 Thread Vitaly Kuznetsov
Roman Kagan writes: > [ Sorry, missed this one ] > > On Wed, Dec 05, 2018 at 04:36:21PM +0100, Vitaly Kuznetsov wrote: >> Turns out we over-engineered Direct Mode for stimers a bit: unlike >> traditional stimers where we may want to try to re-inject the message upon >&g

Re: [PATCH v2 4/7] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-11 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Tue, Dec 11, 2018 at 02:28:14PM +0100, Vitaly Kuznetsov wrote: >> Roman Kagan writes: >> >> > On Mon, Dec 10, 2018 at 06:21:56PM +0100, Vitaly Kuznetsov wrote: >> >> >> + >> >> +Curr

Re: [PATCH v2 4/7] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-11 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Mon, Dec 10, 2018 at 06:21:56PM +0100, Vitaly Kuznetsov wrote: >> + >> +Currently, the following list of CPUID leaves are returned: >> + HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS >> + HYPERV_CPUID_INTERFACE >> + HYPERV_CPUID_V

Re: [PATCH 1/4] arm64: hyperv: Add core Hyper-V include files

2018-12-10 Thread Vitaly Kuznetsov
k...@linuxonhyperv.com writes: > + > +static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page > *tsc_pg, > +u64 *cur_tsc) > +{ > + u64 scale, offset; > + u32 sequence; > + > + /* > + * The protocol for reading Hyper-V

[PATCH v2 2/7] x86/hyper-v: Drop HV_X64_CONFIGURE_PROFILER definition

2018-12-10 Thread Vitaly Kuznetsov
BIT(13) in HYPERV_CPUID_FEATURES.EBX is described as "ConfigureProfiler" in TLFS v4.0 but starting 5.0 it is replaced with 'Reserved'. As we don't currently us it in kernel it can just be dropped. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Michael Kelley --- arch/x86/include/

[PATCH v2 5/7] x86/kvm/hyper-v: Drop KVM_CAP_HYPERV_STIMER_DIRECT

2018-12-10 Thread Vitaly Kuznetsov
The newly introduced KVM_GET_SUPPORTED_HV_CPUID covers Direct Mode stimers feature so we can drop KVM_CAP_HYPERV_STIMER_DIRECT and reuse its number. Signed-off-by: Vitaly Kuznetsov --- - This patch only makes sense befor 4.21 merge window, disregard if it doesn't make it in time. --- arch/x86

[PATCH v2 6/7] KVM: selftests: implement an unchecked version of vcpu_ioctl()

2018-12-10 Thread Vitaly Kuznetsov
In case we want to test failing ioctls we need an option to not fail. Following _vcpu_run() precedent implement _vcpu_ioctl(). Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/include/kvm_util.h | 2 ++ tools/testing/selftests/kvm/lib/kvm_util.c | 14 -- 2 files

[PATCH v2 7/7] KVM: selftests: Add hyperv_cpuid test

2018-12-10 Thread Vitaly Kuznetsov
Add a simple (and stupid) hyperv_cpuid test: check that we got the expected number of entries with and without Enlightened VMCS enabled and that all currently reserved fields are zeroed. Signed-off-by: Vitaly Kuznetsov --- Changes since v1: - Check for -E2BIG --- tools/testing/selftests/kvm

[PATCH v2 4/7] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-10 Thread Vitaly Kuznetsov
KVM's (e.g. 0x4000, 0x4001) and we would probably confuse userspace in case we decide to return these twice. KVM_CAP_HYPERV_CPUID's number is interim: we're intended to drop KVM_CAP_HYPERV_STIMER_DIRECT and use its number instead. Suggested-by: Paolo Bonzini Signed-off-by: Vitaly Kuznetsov -

[PATCH v2 3/7] x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper

2018-12-10 Thread Vitaly Kuznetsov
The upcoming KVM_GET_SUPPORTED_HV_CPUID ioctl will need to return Enlightened VMCS version in HYPERV_CPUID_NESTED_FEATURES.EAX when it was enabled. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 7 +++ arch/x86/kvm/vmx.c

[PATCH v2 1/7] x86/hyper-v: Do some housekeeping in hyperv-tlfs.h

2018-12-10 Thread Vitaly Kuznetsov
ed-off-by: Vitaly Kuznetsov Reviewed-by: Michael Kelley --- arch/x86/include/asm/hyperv-tlfs.h | 186 ++--- arch/x86/kvm/hyperv.c | 4 +- 2 files changed, 93 insertions(+), 97 deletions(-) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/inclu

[PATCH v2 0/7] x86/kvm/hyper-v: Implement KVM_GET_SUPPORTED_HV_CPUID

2018-12-10 Thread Vitaly Kuznetsov
KVM_CAP_HYPERV_STIMER_DIRECT before it's too late. Vitaly Kuznetsov (7): x86/hyper-v: Do some housekeeping in hyperv-tlfs.h x86/hyper-v: Drop HV_X64_CONFIGURE_PROFILER definition x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID x86/kvm/hyper-v

Re: [PATCH v2 3/4] x86/kvm/hyper-v: direct mode for synthetic timers

2018-12-10 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Mon, Dec 10, 2018 at 01:54:18PM +0100, Vitaly Kuznetsov wrote: >> Roman Kagan writes: >> > Just noticed that the patch seems to assume that "direct" timers are >> > allowed to use any vectors including 0-15. I guess this is incorrec

Re: [PATCH v2 3/4] x86/kvm/hyper-v: direct mode for synthetic timers

2018-12-10 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Mon, Nov 26, 2018 at 04:47:31PM +0100, Vitaly Kuznetsov wrote: >> Turns out Hyper-V on KVM (as of 2016) will only use synthetic timers >> if direct mode is available. With direct mode we notify the guest by >> asserting APIC irq instead of se

Re: [PATCH 3.16 047/328] xen-netfront: fix queue name setting

2018-12-09 Thread Vitaly Kuznetsov
Ben Hutchings writes: > 3.16.62-rc1 review patch. If anyone has any objections, please let me know. > > -- > > From: Vitaly Kuznetsov > > commit 2d408c0d4574b01b9ed45e02516888bf925e11a9 upstream. > > Commit f599c64fdf7d ("xen-netfront: Fix race

Re: [PATCH 4/6] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-09 Thread Vitaly Kuznetsov
Vitaly Kuznetsov writes: > With every new Hyper-V Enlightenment we implement we're forced to add a > KVM_CAP_HYPERV_* capability. While this approach works it is fairly > inconvenient: the majority of the enlightenments we do have corresponding > CPUID feature bit(s) and userspace

Re: [PATCH v4 14/14] KVM/nVMX: Use kvm_vcpu_map for accessing the enhanced VMCS

2018-12-06 Thread Vitaly Kuznetsov
KarimAllah Ahmed writes: > Use kvm_vcpu_map for accessing the enhanced VMCS since using just a nitpick: "eVMCS" stands for Enlightened VMCS, not 'enhanced' :-) > kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has > a "struct page". > > Signed-off-by: KarimAllah Ahmed >

Re: [PATCH v4 14/14] KVM/nVMX: Use kvm_vcpu_map for accessing the enhanced VMCS

2018-12-06 Thread Vitaly Kuznetsov
KarimAllah Ahmed writes: > Use kvm_vcpu_map for accessing the enhanced VMCS since using just a nitpick: "eVMCS" stands for Enlightened VMCS, not 'enhanced' :-) > kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has > a "struct page". > > Signed-off-by: KarimAllah Ahmed >

[PATCH 2/6] x86/hyper-v: Drop HV_X64_CONFIGURE_PROFILER definition

2018-12-06 Thread Vitaly Kuznetsov
BIT(13) in HYPERV_CPUID_FEATURES.EBX is described as "ConfigureProfiler" in TLFS v4.0 but starting 5.0 it is replaced with 'Reserved'. As we don't currently us it in kernel it can just be dropped. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 1 - 1 file

[PATCH 2/6] x86/hyper-v: Drop HV_X64_CONFIGURE_PROFILER definition

2018-12-06 Thread Vitaly Kuznetsov
BIT(13) in HYPERV_CPUID_FEATURES.EBX is described as "ConfigureProfiler" in TLFS v4.0 but starting 5.0 it is replaced with 'Reserved'. As we don't currently us it in kernel it can just be dropped. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 1 - 1 file

[PATCH 4/6] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-06 Thread Vitaly Kuznetsov
KVM's (e.g. 0x4000, 0x4001) and we would probably confuse userspace in case we decide to return these twice. KVM_CAP_HYPERV_CPUID's number is interim: we're intended to drop KVM_CAP_HYPERV_STIMER_DIRECT and use its number instead. Suggested-by: Paolo Bonzini Signed-off-by: Vitaly Kuznetsov ---

[PATCH 4/6] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-06 Thread Vitaly Kuznetsov
KVM's (e.g. 0x4000, 0x4001) and we would probably confuse userspace in case we decide to return these twice. KVM_CAP_HYPERV_CPUID's number is interim: we're intended to drop KVM_CAP_HYPERV_STIMER_DIRECT and use its number instead. Suggested-by: Paolo Bonzini Signed-off-by: Vitaly Kuznetsov ---

[PATCH 1/6] x86/hyper-v: Do some housekeeping in hyperv-tlfs.h

2018-12-06 Thread Vitaly Kuznetsov
ed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 186 ++--- arch/x86/kvm/hyperv.c | 4 +- 2 files changed, 93 insertions(+), 97 deletions(-) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index ebfed5

[PATCH 3/6] x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper

2018-12-06 Thread Vitaly Kuznetsov
The upcoming KVM_GET_SUPPORTED_HV_CPUID ioctl will need to return Enlightened VMCS version in HYPERV_CPUID_NESTED_FEATURES.EAX when it was enabled. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 7 +++ arch/x86/kvm/vmx.c

[PATCH 6/6] KVM: selftests: Add hyperv_cpuid test

2018-12-06 Thread Vitaly Kuznetsov
Add a simple (and stupid) hyperv_cpuid test: check that we got the expected number of entries with and without Enlightened VMCS enabled and that all currently reserved fields are zeroed. Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm

[PATCH 1/6] x86/hyper-v: Do some housekeeping in hyperv-tlfs.h

2018-12-06 Thread Vitaly Kuznetsov
ed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 186 ++--- arch/x86/kvm/hyperv.c | 4 +- 2 files changed, 93 insertions(+), 97 deletions(-) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index ebfed5

[PATCH 3/6] x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper

2018-12-06 Thread Vitaly Kuznetsov
The upcoming KVM_GET_SUPPORTED_HV_CPUID ioctl will need to return Enlightened VMCS version in HYPERV_CPUID_NESTED_FEATURES.EAX when it was enabled. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 7 +++ arch/x86/kvm/vmx.c

[PATCH 6/6] KVM: selftests: Add hyperv_cpuid test

2018-12-06 Thread Vitaly Kuznetsov
Add a simple (and stupid) hyperv_cpuid test: check that we got the expected number of entries with and without Enlightened VMCS enabled and that all currently reserved fields are zeroed. Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm

[PATCH 5/6] x86/kvm/hyper-v: Drop KVM_CAP_HYPERV_STIMER_DIRECT

2018-12-06 Thread Vitaly Kuznetsov
The newly introduced KVM_GET_SUPPORTED_HV_CPUID covers Direct Mode stimers feature so we can drop KVM_CAP_HYPERV_STIMER_DIRECT and reuse its number. Signed-off-by: Vitaly Kuznetsov --- - This patch only makes sense befor 4.21 merge window, disregard if it doesn't make it in time. --- arch/x86

[PATCH 5/6] x86/kvm/hyper-v: Drop KVM_CAP_HYPERV_STIMER_DIRECT

2018-12-06 Thread Vitaly Kuznetsov
The newly introduced KVM_GET_SUPPORTED_HV_CPUID covers Direct Mode stimers feature so we can drop KVM_CAP_HYPERV_STIMER_DIRECT and reuse its number. Signed-off-by: Vitaly Kuznetsov --- - This patch only makes sense befor 4.21 merge window, disregard if it doesn't make it in time. --- arch/x86

[PATCH 0/6] x86/kvm/hyper-v: Implement KVM_GET_SUPPORTED_HV_CPUID

2018-12-06 Thread Vitaly Kuznetsov
ioctl works) and removes recently added KVM_CAP_HYPERV_STIMER_DIRECT before it's too late. Vitaly Kuznetsov (6): x86/hyper-v: Do some housekeeping in hyperv-tlfs.h x86/hyper-v: Drop HV_X64_CONFIGURE_PROFILER definition x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper x86/kvm

[PATCH 0/6] x86/kvm/hyper-v: Implement KVM_GET_SUPPORTED_HV_CPUID

2018-12-06 Thread Vitaly Kuznetsov
ioctl works) and removes recently added KVM_CAP_HYPERV_STIMER_DIRECT before it's too late. Vitaly Kuznetsov (6): x86/hyper-v: Do some housekeeping in hyperv-tlfs.h x86/hyper-v: Drop HV_X64_CONFIGURE_PROFILER definition x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper x86/kvm

[PATCH] x86/hyper-v: Stop caring about EOI for direct stimers

2018-12-05 Thread Vitaly Kuznetsov
()). Remove the redundant part. Suggested-by: Roman Kagan Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 36 +++- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index e6a2a085644a..0a16a77e6ac3

[PATCH] x86/hyper-v: Stop caring about EOI for direct stimers

2018-12-05 Thread Vitaly Kuznetsov
()). Remove the redundant part. Suggested-by: Roman Kagan Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 36 +++- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index e6a2a085644a..0a16a77e6ac3

Re: [PATCH v2 3/4] x86/kvm/hyper-v: direct mode for synthetic timers

2018-12-04 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Mon, Nov 26, 2018 at 04:47:31PM +0100, Vitaly Kuznetsov wrote: >> @@ -379,6 +398,14 @@ void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int >> vector) >> for (i = 0; i < ARRAY_SIZE(synic->sint); i++) >> if (synic_get_

Re: [PATCH v2 3/4] x86/kvm/hyper-v: direct mode for synthetic timers

2018-12-04 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Mon, Nov 26, 2018 at 04:47:31PM +0100, Vitaly Kuznetsov wrote: >> @@ -379,6 +398,14 @@ void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int >> vector) >> for (i = 0; i < ARRAY_SIZE(synic->sint); i++) >> if (synic_get_

[PATCH v3] x86/hyper-v: Mark TLFS structures packed

2018-12-03 Thread Vitaly Kuznetsov
this. Suggested-by: Nadav Amit Signed-off-by: Vitaly Kuznetsov Acked-by: Thomas Gleixner Acked-by: Nadav Amit --- - Changes since v2: - add __packed to struct 'u' defined within union 'hv_port_id' [Michael Kelley] - This is a follow-up to my "[PATCH v2 0/4] x86/kvm/hyper-v: Impl

[PATCH v3] x86/hyper-v: Mark TLFS structures packed

2018-12-03 Thread Vitaly Kuznetsov
this. Suggested-by: Nadav Amit Signed-off-by: Vitaly Kuznetsov Acked-by: Thomas Gleixner Acked-by: Nadav Amit --- - Changes since v2: - add __packed to struct 'u' defined within union 'hv_port_id' [Michael Kelley] - This is a follow-up to my "[PATCH v2 0/4] x86/kvm/hyper-v: Impl

RE: [PATCH v2] x86/hyper-v: Mark TLFS structures packed

2018-12-03 Thread Vitaly Kuznetsov
Michael Kelley writes: > From: Vitaly Kuznetsov Sent: Friday, November 30, 2018 > 4:54 AM >> >> @@ -466,7 +466,7 @@ union hv_message_flags { >> struct { >> __u8 msg_pending:1; >> __u8 reserved:7; >> -}; >>

RE: [PATCH v2] x86/hyper-v: Mark TLFS structures packed

2018-12-03 Thread Vitaly Kuznetsov
Michael Kelley writes: > From: Vitaly Kuznetsov Sent: Friday, November 30, 2018 > 4:54 AM >> >> @@ -466,7 +466,7 @@ union hv_message_flags { >> struct { >> __u8 msg_pending:1; >> __u8 reserved:7; >> -}; >>

Re: [PATCH v2] x86/hyper-v: Mark TLFS structures packed

2018-12-02 Thread Vitaly Kuznetsov
Nadav Amit writes: [skip] > > Having said that, something else is sort of strange in the TLFS definitions, > I think (I really know little about this whole protocol). Look at the > following definitions from hyperv-tlfs.h: > >> struct hv_vpset { >> u64 format; >> u64

Re: [PATCH v2] x86/hyper-v: Mark TLFS structures packed

2018-12-02 Thread Vitaly Kuznetsov
Nadav Amit writes: [skip] > > Having said that, something else is sort of strange in the TLFS definitions, > I think (I really know little about this whole protocol). Look at the > following definitions from hyperv-tlfs.h: > >> struct hv_vpset { >> u64 format; >> u64

Re: [PATCH] x86/hyper-v: define structures from TLFS as packed

2018-11-30 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Fri, Nov 30, 2018 at 02:44:54PM +0100, Vitaly Kuznetsov wrote: > >> I also checked this patch before sending out, WS2016 guest boots without >> issues. Any particular places you're worried about? > > It's Linux guests on Hyper-V that need to be ch

Re: [PATCH] x86/hyper-v: define structures from TLFS as packed

2018-11-30 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Fri, Nov 30, 2018 at 02:44:54PM +0100, Vitaly Kuznetsov wrote: > >> I also checked this patch before sending out, WS2016 guest boots without >> issues. Any particular places you're worried about? > > It's Linux guests on Hyper-V that need to be ch

Re: [PATCH] x86/hyper-v: define structures from TLFS as packed

2018-11-30 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Fri, Nov 30, 2018 at 01:15:11PM +0100, Vitaly Kuznetsov wrote: >> Without 'packed' compiler is free to add optimization paddings and re-order >> structure fields for randomization/optimization. And structures from >> hyperv-tlfs.h are used

Re: [PATCH] x86/hyper-v: define structures from TLFS as packed

2018-11-30 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Fri, Nov 30, 2018 at 01:15:11PM +0100, Vitaly Kuznetsov wrote: >> Without 'packed' compiler is free to add optimization paddings and re-order >> structure fields for randomization/optimization. And structures from >> hyperv-tlfs.h are used

[PATCH v2] x86/hyper-v: Mark TLFS structures packed

2018-11-30 Thread Vitaly Kuznetsov
this. Suggested-by: Nadav Amit Signed-off-by: Vitaly Kuznetsov Acked-by: Thomas Gleixner --- - Changes since v1: - Re-worded commit message for clarity. [Thomas Gleixner] - This is a follow-up to my "[PATCH v2 0/4] x86/kvm/hyper-v: Implement Direct Mode for synthetic timers&qu

[PATCH v2] x86/hyper-v: Mark TLFS structures packed

2018-11-30 Thread Vitaly Kuznetsov
this. Suggested-by: Nadav Amit Signed-off-by: Vitaly Kuznetsov Acked-by: Thomas Gleixner --- - Changes since v1: - Re-worded commit message for clarity. [Thomas Gleixner] - This is a follow-up to my "[PATCH v2 0/4] x86/kvm/hyper-v: Implement Direct Mode for synthetic timers&qu

Re: [PATCH] x86/hyper-v: define structures from TLFS as packed

2018-11-30 Thread Vitaly Kuznetsov
Thomas Gleixner writes: > On Fri, 30 Nov 2018, Vitaly Kuznetsov wrote: > >> Subject: x86/hyper-v: define structures from TLFS as packed > > Please start the first word after the prefix colon with an uppercase > letter. Also structures from TLFS doesn't make sense

Re: [PATCH] x86/hyper-v: define structures from TLFS as packed

2018-11-30 Thread Vitaly Kuznetsov
Thomas Gleixner writes: > On Fri, 30 Nov 2018, Vitaly Kuznetsov wrote: > >> Subject: x86/hyper-v: define structures from TLFS as packed > > Please start the first word after the prefix colon with an uppercase > letter. Also structures from TLFS doesn't make sense

[PATCH] x86/hyper-v: define structures from TLFS as packed

2018-11-30 Thread Vitaly Kuznetsov
Without 'packed' compiler is free to add optimization paddings and re-order structure fields for randomization/optimization. And structures from hyperv-tlfs.h are used for hypervisor-guest communication, we need to ultimately forbid such practices. Suggested-by: Nadav Amit Signed-off-by: Vitaly

[PATCH] x86/hyper-v: define structures from TLFS as packed

2018-11-30 Thread Vitaly Kuznetsov
Without 'packed' compiler is free to add optimization paddings and re-order structure fields for randomization/optimization. And structures from hyperv-tlfs.h are used for hypervisor-guest communication, we need to ultimately forbid such practices. Suggested-by: Nadav Amit Signed-off-by: Vitaly

Re: [PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-29 Thread Vitaly Kuznetsov
Nadav Amit writes: >> On Nov 28, 2018, at 5:07 AM, Thomas Gleixner wrote: >> >> On Wed, 28 Nov 2018, Vitaly Kuznetsov wrote: >> >>> Nadav Amit writes: >>> >>>> On a different note: how come all of the hyper-v structs are not marked >

Re: [PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-29 Thread Vitaly Kuznetsov
Nadav Amit writes: >> On Nov 28, 2018, at 5:07 AM, Thomas Gleixner wrote: >> >> On Wed, 28 Nov 2018, Vitaly Kuznetsov wrote: >> >>> Nadav Amit writes: >>> >>>> On a different note: how come all of the hyper-v structs are not marked >

Re: [PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-28 Thread Vitaly Kuznetsov
Nadav Amit writes: > > On a different note: how come all of the hyper-v structs are not marked > with the “packed" attribute? "packed" should not be needed with proper padding; I vaguely remember someone (from x86@?) arguing _against_ "packed". -- Vitaly

Re: [PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-28 Thread Vitaly Kuznetsov
Nadav Amit writes: > > On a different note: how come all of the hyper-v structs are not marked > with the “packed" attribute? "packed" should not be needed with proper padding; I vaguely remember someone (from x86@?) arguing _against_ "packed". -- Vitaly

RE: [PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-27 Thread Vitaly Kuznetsov
Out of pure curiosity I decided to check what 'gcc -O3' produces when we use bitfields and masks. As of 'gcc version 8.2.1 20181105 (Red Hat 8.2.1-5) (GCC)' 1) bitfields: struct abc { int enabled:1; int _pad:7; int vec:8; }; int is_good(struct abc *s) { if

RE: [PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-27 Thread Vitaly Kuznetsov
Out of pure curiosity I decided to check what 'gcc -O3' produces when we use bitfields and masks. As of 'gcc version 8.2.1 20181105 (Red Hat 8.2.1-5) (GCC)' 1) bitfields: struct abc { int enabled:1; int _pad:7; int vec:8; }; int is_good(struct abc *s) { if

Re: [PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-27 Thread Vitaly Kuznetsov
Roman Kagan writes: > [ Sorry for having missed v1 ] > > On Mon, Nov 26, 2018 at 04:47:29PM +0100, Vitaly Kuznetsov wrote: >> We implement Hyper-V SynIC and synthetic timers in KVM too so there's some >> room for code sharing. >> >> Signed-off-by: Vitaly Kuzne

Re: [PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-27 Thread Vitaly Kuznetsov
Roman Kagan writes: > [ Sorry for having missed v1 ] > > On Mon, Nov 26, 2018 at 04:47:29PM +0100, Vitaly Kuznetsov wrote: >> We implement Hyper-V SynIC and synthetic timers in KVM too so there's some >> room for code sharing. >> >> Signed-off-by: Vitaly Kuzne

Re: [PATCH v2 3/4] x86/kvm/hyper-v: direct mode for synthetic timers

2018-11-26 Thread Vitaly Kuznetsov
Paolo Bonzini writes: >> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h >> index 2b7a652c9fa4..b8da14cee8e5 100644 >> --- a/include/uapi/linux/kvm.h >> +++ b/include/uapi/linux/kvm.h >> @@ -975,6 +975,7 @@ struct kvm_ppc_resize_hpt { >> #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS

Re: [PATCH v2 3/4] x86/kvm/hyper-v: direct mode for synthetic timers

2018-11-26 Thread Vitaly Kuznetsov
Paolo Bonzini writes: >> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h >> index 2b7a652c9fa4..b8da14cee8e5 100644 >> --- a/include/uapi/linux/kvm.h >> +++ b/include/uapi/linux/kvm.h >> @@ -975,6 +975,7 @@ struct kvm_ppc_resize_hpt { >> #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS

<    4   5   6   7   8   9   10   11   12   13   >