Re: [PATCH 0/1] x86: restore the write back cache of reserved RAM in iounmap()

2020-11-19 Thread Andrea Arcangeli
Hello Christoph, On Thu, Nov 19, 2020 at 06:02:06PM +, Christoph Hellwig wrote: > What is the callers? The whole SetPageReservered + ioremap* thing > you mention in the actual patch is completely bogus. I think we'll > need to reject that as well and fix the caller. The actual caller is not

[PATCH 1/1] x86: restore the write back cache of reserved RAM in iounmap()

2020-11-19 Thread Andrea Arcangeli
caller would need to still enforce they all have the same memtype, so it is more likely able to enforce that it doesn't do overlapping ioremaps at once than to be able to undo the changes to the direct mapping pagetables Fixes: f56d005d3034 ("x86: no CPA on iounmap") S

[PATCH 0/1] x86: restore the write back cache of reserved RAM in iounmap()

2020-11-19 Thread Andrea Arcangeli
-1); } } MODULE_LICENSE("GPL"); == Andrea Arcangeli (1): x86: restore the write back cache of reserved RAM in iounmap() arch/x86/mm/ioremap.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-)

[PATCH 0/1] x86: deduplicate the spectre_v2_user documentation

2020-11-04 Thread Andrea Arcangeli
sync, instead of keeping the dup around and applying the same update to the dup. Note: as far as I can tell spec_store_bypass_disable= documentation is not duplicated in spectre.rst, that's better in my view. The more dups we have the more one goes out of sync.. Andrea Arcangeli (1): x86: dedup

[PATCH 1/1] x86: deduplicate the spectre_v2_user documentation

2020-11-04 Thread Andrea Arcangeli
This would need updating to make prctl be the new default, but it's simpler to delete it and refer to the dup. Signed-off-by: Andrea Arcangeli --- Documentation/admin-guide/hw-vuln/spectre.rst | 51 +-- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/Document

[PATCH 1/1] x86: change default to spec_store_bypass_disable=prctl spectre_v2_user=prctl

2020-11-04 Thread Andrea Arcangeli
erified result of the new default with SMT enabled: (gdb) print spectre_v2_user_stibp $1 = SPECTRE_V2_USER_PRCTL (gdb) print spectre_v2_user_ibpb $2 = SPECTRE_V2_USER_PRCTL (gdb) print ssb_mode $3 = SPEC_STORE_BYPASS_PRCTL Acked-by: Kees Cook Signed-off-by: Andrea Arcangeli --- Documentation/admin

Re: RFC: default to spec_store_bypass_disable=prctl spectre_v2_user=prctl

2020-11-04 Thread Andrea Arcangeli
On Thu, Nov 05, 2020 at 12:22:29AM +0100, Thomas Gleixner wrote: > On Wed, Nov 04 2020 at 16:57, Andrea Arcangeli wrote: > > --- > > Documentation/admin-guide/kernel-parameters.txt | 5 ++--- > > Is Documentation/admin-guide/hw-vuln/* still correct? If not, please > fix

RFC: default to spec_store_bypass_disable=prctl spectre_v2_user=prctl

2020-11-04 Thread Andrea Arcangeli
upgraded his codebase to the upstream kernel with both STIBP/SSBD enabled in seccomp jails. Here's below a tentative RFC, the code is actually trivial, if you could help reviewing/improving the commit header it would be great. Thanks, Andrea >From 3f7adb783262dc7f4e71cdbf07b4ef9f6b8d3ed

Re: [PATCH v4 0/2] Control over userfaultfd kernel-fault handling

2020-10-23 Thread Andrea Arcangeli
Hello, On Thu, Oct 08, 2020 at 04:22:36PM -0700, Nick Kralevich wrote: > I haven't tried to verify this myself. I wonder if the usermode > hardening changes also impacted this exploit? See > https://lkml.org/lkml/2017/1/16/468 My plan was to: 1) reproduce with the old buggy kernel 2) forward po

Re: [PATCH v5 2/2] Add user-mode only option to unprivileged_userfaultfd sysctl knob

2020-10-23 Thread Andrea Arcangeli
ctl set to zero. So without this commit, any Linux binary using userfaultfd to manage its memory would behave differently if run within the Android userland. == Reviewed-by: Andrea Arcangeli BTW, this is still a minor nitpick, but a printk_once of the 1/2 could be added before the return -EP

Re: [PATCH v5 1/2] Add UFFD_USER_MODE_ONLY

2020-10-23 Thread Andrea Arcangeli
that these processes > will exploit userfaultfd's ability to delay kernel page faults to open > timing windows for future exploits. > > Signed-off-by: Daniel Colascione > Signed-off-by: Lokesh Gidra Reviewed-by: Andrea Arcangeli

Re: [PATCH v4 0/2] Control over userfaultfd kernel-fault handling

2020-10-07 Thread Andrea Arcangeli
Hello Lokesh, On Wed, Oct 07, 2020 at 01:26:55PM -0700, Lokesh Gidra wrote: > On Wed, Sep 23, 2020 at 11:56 PM Lokesh Gidra wrote: > > > > This patch series is split from [1]. The other series enables SELinux > > support for userfaultfd file descriptors so that its creation and > > movement can b

Re: [PATCH v1 0/6] seccomp: Implement constant action bitmaps

2020-09-24 Thread Andrea Arcangeli
Hello, I'm posting this only for the record, feel free to ignore. On Wed, Sep 23, 2020 at 04:29:17PM -0700, Kees Cook wrote: > rfc: > https://lore.kernel.org/lkml/20200616074934.1600036-1-keesc...@chromium.org/ > alternative: > https://lore.kernel.org/containers/cover.1600661418.git.yifei...@il

Re: [PATCH 2/2] Add a new sysctl knob: unprivileged_userfaultfd_user_mode_only

2020-09-03 Thread Andrea Arcangeli
Hello, On Mon, Aug 17, 2020 at 03:11:16PM -0700, Lokesh Gidra wrote: > There has been an emphasis that Android is probably the only user for > the restriction of userfaults from kernel-space and that it wouldn’t > be useful anywhere else. I humbly disagree! There are various areas > where the PROT

Re: INFO: task hung in pipe_read (2)

2020-08-10 Thread Andrea Arcangeli
Hello Tetsuo, On Sat, Aug 08, 2020 at 10:01:21AM +0900, Tetsuo Handa wrote: > use of killable waits disables ability to detect possibility of deadlock > (because > lockdep can't check possibility of deadlock which involves actions in > userspace), for > syzkaller process is SIGKILLed after 5 sec

Re: INFO: task hung in pipe_read (2)

2020-08-06 Thread Andrea Arcangeli
Hello! On Sat, Aug 01, 2020 at 10:39:00AM -0700, Linus Torvalds wrote: > On Sat, Aug 1, 2020 at 8:30 AM Tetsuo Handa > wrote: > > > > Waiting for response at > > https://lkml.kernel.org/r/45a9b2c8-d0b7-8f00-5b30-0cfe3e028...@i-love.sakura.ne.jp > > . > > I think handle_userfault() should have

Re: [RFC PATCH v2 1/5] mm: make HPAGE_PxD_{SHIFT,MASK,SIZE} always available

2020-07-10 Thread Andrea Arcangeli
On Fri, Jul 10, 2020 at 05:57:46PM +0100, Matthew Wilcox wrote: > btw, using the hpage_ prefix already caused one problem in the hugetlb > code: > > https://lore.kernel.org/linux-mm/20200629185003.97202-1-mike.krav...@oracle.com/ > > I'd suggest we rename these to THP_PMD_* and THP_PUD_* to make

Re: [RFC PATCH v2 1/5] mm: make HPAGE_PxD_{SHIFT,MASK,SIZE} always available

2020-07-10 Thread Andrea Arcangeli
Hello Hugh and Mike, On Mon, Jul 06, 2020 at 10:07:34PM -0700, Hugh Dickins wrote: > Adding Andrea to Cc, he's the one who structured it that way, > and should be consulted. > > I'm ambivalent myself. Many's the time I've been irritated by the > BUILD_BUG() in HPAGE_etc, and it's responsible for

Re: kernel BUG at mm/huge_memory.c:2613!

2020-06-22 Thread Andrea Arcangeli
Hello, On Mon, Jun 22, 2020 at 04:30:41PM +0100, Robin Murphy wrote: > On 2020-06-22 13:46, Joerg Roedel wrote: > > + Robin > > > > Robin, any idea on this? > > After a bit of archaeology, this dates back to the original review: > > https://lore.kernel.org/linux-arm-kernel/54c285d4.3070...@arm.

Re: kernel BUG at mm/huge_memory.c:2613!

2020-06-18 Thread Andrea Arcangeli
Hello, On Thu, Jun 18, 2020 at 06:14:49PM -0700, Roman Gushchin wrote: > I agree. The whole > > page = alloc_pages_node(nid, alloc_flags, order); > if (!page) > continue; > if (!order) > break; > if (!PageCompound(page)) { > split_

Re: [PATCH 2/2] Add a new sysctl knob: unprivileged_userfaultfd_user_mode_only

2020-05-20 Thread Andrea Arcangeli
On Wed, May 20, 2020 at 01:17:20PM -0700, Lokesh Gidra wrote: > Adding the Android kernel team in the discussion. Unless I'm mistaken that you can already enforce bit 1 of the second parameter of the userfaultfd syscall to be set with seccomp-bpf, this would be more a question to the Android userl

Re: [PATCH 2/2] Add a new sysctl knob: unprivileged_userfaultfd_user_mode_only

2020-05-20 Thread Andrea Arcangeli
On Wed, May 20, 2020 at 03:48:04PM -0400, Andrea Arcangeli wrote: > The sysctl /proc/sys/kernel/unprivileged_bpf_disabled is already there Oops I picked the wrong unprivileged_* :) of course I meant: /proc/sys/vm/unprivileged_userfaultfd

Re: [PATCH 2/2] Add a new sysctl knob: unprivileged_userfaultfd_user_mode_only

2020-05-20 Thread Andrea Arcangeli
Hello Kees, On Wed, May 20, 2020 at 11:03:39AM -0700, Kees Cook wrote: > Err, did I miss a separate 6-patch series? I can't find anything on lore. Daniel included the link of the previous series I referred to is the cover letter 0/2: https://lore.kernel.org/lkml/20200211225547.235083-1-dan...@go

Re: [PATCH 2/2] Add a new sysctl knob: unprivileged_userfaultfd_user_mode_only

2020-05-19 Thread Andrea Arcangeli
Hello everyone, On Fri, May 08, 2020 at 12:54:03PM -0400, Michael S. Tsirkin wrote: > On Fri, May 08, 2020 at 12:52:34PM -0400, Michael S. Tsirkin wrote: > > On Wed, Apr 22, 2020 at 05:26:32PM -0700, Daniel Colascione wrote: > > > This sysctl can be set to either zero or one. When zero (the defaul

Re: [PATCH 2/2] Add a new sysctl knob: unprivileged_userfaultfd_user_mode_only

2020-05-19 Thread Andrea Arcangeli
Hello Jonathan and everyone, On Thu, May 07, 2020 at 01:15:03PM -0600, Jonathan Corbet wrote: > On Wed, 6 May 2020 15:38:16 -0400 > Peter Xu wrote: > > > If this is going to be added... I am thinking whether it should be easier to > > add another value for unprivileged_userfaultfd, rather than a

Re: [PATCH 3/7] Add a UFFD_SECURE flag to the userfaultfd API.

2019-10-23 Thread Andrea Arcangeli
Hello, On Sat, Oct 12, 2019 at 06:14:23PM -0700, Andy Lutomirski wrote: > [adding more people because this is going to be an ABI break, sigh] That wouldn't break the ABI, no more than when if you boot a kernel built with CONFIG_USERFAULTFD=n. All non-cooperative features can be removed any time

Re: [PATCH 12/14] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-10-16 Thread Andrea Arcangeli
On Wed, Oct 16, 2019 at 09:07:39AM +0200, Paolo Bonzini wrote: > Yet you would add CPUID to the list even though it is not even there in > your benchmarks, and is *never* invoked in a hot path by *any* sane I justified CPUID as a "short term" benchmark gadget, it's one of those it shouldn't be a p

Re: [PATCH 12/14] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-10-15 Thread Andrea Arcangeli
On Wed, Oct 16, 2019 at 12:22:31AM +0200, Paolo Bonzini wrote: > Oh come on. 0.9 is not 12-years old. virtio 1.0 is 3.5 years old > (March 2016). Anything older than 2017 is going to use 0.9. Sorry if I got the date wrong, but still I don't see the point in optimizing for legacy virtio. I can't

Re: [PATCH 12/14] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-10-15 Thread Andrea Arcangeli
On Tue, Oct 15, 2019 at 09:46:58PM +0200, Paolo Bonzini wrote: > On 15/10/19 18:49, Andrea Arcangeli wrote: > > On Tue, Oct 15, 2019 at 10:28:39AM +0200, Paolo Bonzini wrote: > >> If you're including EXIT_REASON_EPT_MISCONFIG (MMIO access) then you > >> should in

Re: [PATCH 12/14] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-10-15 Thread Andrea Arcangeli
On Tue, Oct 15, 2019 at 10:28:39AM +0200, Paolo Bonzini wrote: > If you're including EXIT_REASON_EPT_MISCONFIG (MMIO access) then you > should include EXIT_REASON_IO_INSTRUCTION too. Depending on the devices > that are in the guest, the doorbell register might be MMIO or PIO. The fact outb/inb de

Re: [PATCH] fs/userfaultfd.c: simplify the calculation of new_flags

2019-10-04 Thread Andrea Arcangeli
On Sat, Oct 05, 2019 at 06:46:40AM +0800, Wei Yang wrote: > On Wed, Oct 02, 2019 at 08:45:05PM -0400, Andrea Arcangeli wrote: > >Hello, > > > >On Tue, Aug 06, 2019 at 01:38:59PM +0800, Wei Yang wrote: > >> Finally new_flags equals old vm_flags *OR* vm_flags. > >

Re: [PATCH] vfio/type1: remove hugepage checks in is_invalid_reserved_pfn()

2019-10-03 Thread Andrea Arcangeli
't allow a driver to allocate an hugepage if any > subpage is reserved in the e820 map at boot, if any driver sets the > reserved bit of head page before mapping the hugepage in userland, > it needs to set the reserved bit in all subpages to be safe. > > Signed-off-by:

Re: [PATCH] fs/userfaultfd.c: simplify the calculation of new_flags

2019-10-02 Thread Andrea Arcangeli
Hello, On Tue, Aug 06, 2019 at 01:38:59PM +0800, Wei Yang wrote: > Finally new_flags equals old vm_flags *OR* vm_flags. > > It is not necessary to mask them first. > > Signed-off-by: Wei Yang > --- > fs/userfaultfd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/

Re: [PATCH v2] vfio/type1: avoid redundant PageReserved checking

2019-09-30 Thread Andrea Arcangeli
Hello, On Fri, Sep 13, 2019 at 12:05:26PM -0600, Alex Williamson wrote: > On Mon, 2 Sep 2019 15:32:42 +0800 > Ben Luo wrote: > > > 在 2019/8/30 上午1:06, Alex Williamson 写道: > > > On Fri, 30 Aug 2019 00:58:22 +0800 > > > Ben Luo wrote: > > > > > >> 在 2019/8/28 下午11:55, Alex Williamson 写道: > >

[PATCH 05/14] KVM: monolithic: add more section prefixes in the KVM common code

2019-09-28 Thread Andrea Arcangeli
Add more section prefixes of some KVM common code function because with the monolithic KVM model the section checker can now do a more accurate static analysis at build time and this allows to build without CONFIG_SECTION_MISMATCH_WARN_ONLY=n. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm

[PATCH 01/14] KVM: monolithic: x86: remove kvm.ko

2019-09-28 Thread Andrea Arcangeli
resources than disk space. The pointer to function virtual template model cannot provide any runtime benefit because kvm-intel and kvm-amd can't be loaded at the same time. This removes kvm.ko and it links and duplicates all kvm.ko objects to both kvm-amd and kvm-intel. Signed-off-by: A

[PATCH 04/14] KVM: monolithic: x86: handle the request_immediate_exit variation

2019-09-28 Thread Andrea Arcangeli
request_immediate_exit is one of those few cases where the pointer to function of the method isn't fixed at build time and it requires special handling because hardware_setup() may override it at runtime. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/vmx/vmx.c | 5 - 1 file chang

[PATCH 07/14] KVM: monolithic: x86: remove __init section prefix from kvm_x86_cpu_has_kvm_support

2019-09-28 Thread Andrea Arcangeli
it in the __init section, but to drop it. As long as it's defined in vmx as a kvm_x86 operation, it's expectable that might eventually be called at runtime while hot plugging new CPUs. Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx/vmx.c

[PATCH 00/14] KVM monolithic v2

2019-09-28 Thread Andrea Arcangeli
mmit. After all those small commits done incrementally with this patchset, the kvm_x86_ops structure can be deleted. https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git/log/?h=kvm-mono2 Thanks, Andrea Andrea Arcangeli (14): KVM: monolithic: x86: remove kvm.ko KVM: monolithic: x86: disable linki

[PATCH 08/14] KVM: monolithic: x86: remove exports

2019-09-28 Thread Andrea Arcangeli
ster_notifier' exported twice. Previous export was in arch/x86/kvm/kvm-intel.ko WARNING: arch/x86/kvm/kvm-amd: 'kvm_page_track_unregister_notifier' exported twice. Previous export was in arch/x86/kvm/kvm-intel.ko Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/cpuid.c| 5 --

[PATCH 06/14] KVM: monolithic: x86: remove __exit section prefix from machine_unsetup

2019-09-28 Thread Andrea Arcangeli
ll is made. Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/kvm_host.h | 4 ++-- arch/x86/kvm/svm.c | 2 +- arch/x86/kvm/vmx/vmx.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h

[PATCH 11/14] KVM: x86: optimize more exit handlers in vmx.c

2019-09-28 Thread Andrea Arcangeli
Eliminate wasteful call/ret non RETPOLINE case and unnecessary fentry dynamic tracing hooking points. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/vmx/vmx.c | 30 +- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86

[PATCH 12/14] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-28 Thread Andrea Arcangeli
27;t hurt the common case and the expectation here is that if they would ever become measurable, it would be because they are increasing (and not decreasing) performance. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/vmx/vmx.c | 24 ++-- 1 file changed, 22 insertions(+), 2 dele

[PATCH 02/14] KVM: monolithic: x86: disable linking vmx and svm at the same time into the kernel

2019-09-28 Thread Andrea Arcangeli
Linking both vmx and svm into the kernel at the same time isn't possible anymore or the kvm_x86/kvm_x86_pmu external function names would collide. Reported-by: kbuild test robot Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/Kconfig | 24 ++-- 1 file change

[PATCH 09/14] KVM: monolithic: remove exports from KVM common code

2019-09-28 Thread Andrea Arcangeli
: arch/x86/kvm/kvm-amd: 'kvm_read_guest' exported twice. Previous export was in arch/x86/kvm/kvm-intel.ko WARNING: arch/x86/kvm/kvm-amd: 'kvm_write_guest' exported twice. Previous export was in arch/x86/kvm/kvm-intel.ko Signed-off-by: Andrea Arcangeli --- virt/kvm/event

[PATCH 14/14] x86: retpolines: eliminate retpoline from msr event handlers

2019-09-28 Thread Andrea Arcangeli
l+559 do_vfs_ioctl+164 ksys_ioctl+96 __x64_sys_ioctl+22 do_syscall_64+89 entry_SYSCALL_64_after_hwframe+68 ]: 2390 @[]: 33410 @total: 315707 Note the highest hit above is __delay so probably not worth optimizing even if it would be more frequent than 2k hits per sec. Signed-off-by: A

[PATCH 13/14] KVM: retpolines: x86: eliminate retpoline from svm.c exit handlers

2019-09-28 Thread Andrea Arcangeli
64+89 entry_SYSCALL_64_after_hwframe+68 ]: 499845 @total: 1780243 SVM has no TSC based programmable preemption timer so it is invoking ktime_get() frequently. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/svm.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/kvm/svm.c b

[PATCH 10/14] KVM: monolithic: x86: drop the kvm_pmu_ops structure

2019-09-28 Thread Andrea Arcangeli
Cleanup after the structure was finally left completely unused. Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/kvm_host.h | 3 --- arch/x86/kvm/pmu.h | 20 arch/x86/kvm/pmu_amd.c | 15 --- arch/x86/kvm/svm.c | 1

Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-25 Thread Andrea Arcangeli
On Wed, Sep 25, 2019 at 01:03:32PM +0200, Christophe de Dinechin wrote: > > > > On 23 Sep 2019, at 11:31, Vitaly Kuznetsov wrote: > > > > Andrea Arcangeli mailto:aarca...@redhat.com>> writes: > > > >> It's enough to check the exit value and i

Re: [PATCH 07/17] KVM: monolithic: x86: adjust the section prefixes

2019-09-25 Thread Andrea Arcangeli
Hello, On Mon, Sep 23, 2019 at 12:15:23PM +0200, Paolo Bonzini wrote: > On 20/09/19 23:24, Andrea Arcangeli wrote: > > Adjusts the section prefixes of some KVM common code function because > > with the monolithic methods the section checker can now do a more > > accurate a

Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-24 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 03:05:14PM -0400, Andrea Arcangeli wrote: > On Mon, Sep 23, 2019 at 11:57:57AM +0200, Paolo Bonzini wrote: > > On 23/09/19 11:31, Vitaly Kuznetsov wrote: > > > +#ifdef CONFIG_RETPOLINE > > > + if (exit_reason == EXIT_REASON_MSR_WRITE) >

Re: [PATCH 14/17] KVM: monolithic: x86: inline more exit handlers in vmx.c

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 09:55:27PM -0400, Andrea Arcangeli wrote: > This commit I reverted adds literally 3 inlines called by 3 functions, > in a very fast path, how many bytes of .text difference did you expect > by dropping some call/ret from a very fast path when you asked me to >

Re: [PATCH 14/17] KVM: monolithic: x86: inline more exit handlers in vmx.c

2019-09-23 Thread Andrea Arcangeli
On Tue, Sep 24, 2019 at 03:25:34AM +0200, Paolo Bonzini wrote: > On 24/09/19 03:00, Andrea Arcangeli wrote: > > Before and after this specific commit there is a difference with gcc 8.3. > > > > full patchset applied > > > > 753699 879719616 851286 cfd5

Re: [PATCH 14/17] KVM: monolithic: x86: inline more exit handlers in vmx.c

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 12:19:12PM +0200, Paolo Bonzini wrote: > On 20/09/19 23:25, Andrea Arcangeli wrote: > > They can be called directly more efficiently, so we can as well mark > > some of them inline in case gcc doesn't decide to inline them. > > What is the ou

Re: [PATCH 13/17] KVM: monolithic: x86: drop the kvm_pmu_ops structure

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 12:21:43PM +0200, Paolo Bonzini wrote: > On 20/09/19 23:25, Andrea Arcangeli wrote: > > Cleanup after this was finally left fully unused. > > > > Signed-off-by: Andrea Arcangeli > > --- > > arch/x86/include/asm/kvm_host.h

Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-23 Thread Andrea Arcangeli
Hi Paolo, On Tue, Sep 24, 2019 at 02:15:39AM +0200, Paolo Bonzini wrote: > Do you really need that? Why couldn't the handle_* functions simply be > exported from nested.c to vmx.c? I prefer the direct call too indeed. If Sean doesn't want to export those generic names to the whole kernel it wou

Re: [PATCH 03/17] KVM: monolithic: x86: handle the request_immediate_exit variation

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 04:45:00PM -0700, Sean Christopherson wrote: > With a straight rename to kvm_x86_() instead of wrappers, we > shouldn't need kvm_ops.c. kvm_ops.h might be helpful, but it'd be just > as easy to keep them in kvm_host.h and would likely yield a more > insightful diff[*]. Yes

Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 02:24:35PM -0700, Sean Christopherson wrote: > An extra CALL+RET isn't going to be noticeable, especially on modern > hardware as the high frequency VMWRITE/VMREAD fields should hit the > shadow VMCS. In your last email with regard to the inlining optimizations made possibl

Re: [PATCH 03/17] KVM: monolithic: x86: handle the request_immediate_exit variation

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 03:35:26PM -0700, Sean Christopherson wrote: > On Fri, Sep 20, 2019 at 05:24:55PM -0400, Andrea Arcangeli wrote: > > request_immediate_exit is one of those few cases where the pointer to > > function of the method isn't fixed at build time and it

Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-23 Thread Andrea Arcangeli
Hello, On Mon, Sep 23, 2019 at 01:23:49PM -0700, Sean Christopherson wrote: > The attached patch should do the trick. The two most attractive options to me remains what I already have implemented under #ifdef CONFIG_RETPOLINE with direct calls (optionally replacing the "if" with a small "switch"

Re: [PATCH 02/17] KVM: monolithic: x86: convert the kvm_x86_ops methods to external functions

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 12:19:30PM +0200, Paolo Bonzini wrote: > On 20/09/19 23:24, Andrea Arcangeli wrote: > > diff --git a/arch/x86/kvm/svm_ops.c b/arch/x86/kvm/svm_ops.c > > new file mode 100644 > > index ..2aaabda92179 > > --- /dev/null > > +++ b/a

Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 11:15:58AM -0700, Sean Christopherson wrote: > On the flip side, using a switch for the fast-path handlers gives the > compiler more flexibility to rearrange and combine checks. Of course that > doesn't mean the compiler will actually generate faster code for our > purposes

Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 11:57:57AM +0200, Paolo Bonzini wrote: > On 23/09/19 11:31, Vitaly Kuznetsov wrote: > > +#ifdef CONFIG_RETPOLINE > > + if (exit_reason == EXIT_REASON_MSR_WRITE) > > + return handle_wrmsr(vcpu); > > + else if (exit_reason == EXIT_REASON_P

Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-23 Thread Andrea Arcangeli
On Mon, Sep 23, 2019 at 06:53:10PM +0200, Paolo Bonzini wrote: > On 23/09/19 18:37, Sean Christopherson wrote: > >> Would it be too much if we get rid of > >> kvm_vmx_exit_handlers completely replacing this code with one switch()? > > Hmm, that'd require redirects for nVMX functions since they are

Re: [PATCH 01/17] x86: spec_ctrl: fix SPEC_CTRL initialization after kexec

2019-09-23 Thread Andrea Arcangeli
Hello, On Mon, Sep 23, 2019 at 08:30:57AM -0700, Sean Christopherson wrote: > On Mon, Sep 23, 2019 at 12:22:23PM +0200, Paolo Bonzini wrote: > > On 20/09/19 23:24, Andrea Arcangeli wrote: > > > We can't assume the SPEC_CTRL msr is zero at boot because it could be > >

[PATCH 03/17] KVM: monolithic: x86: handle the request_immediate_exit variation

2019-09-20 Thread Andrea Arcangeli
request_immediate_exit is one of those few cases where the pointer to function of the method isn't fixed at build time and it requires special handling because hardware_setup() may override it at runtime. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/vmx/vmx_ops.c | 5 - 1 file ch

[PATCH 00/17] KVM monolithic v1

2019-09-20 Thread Andrea Arcangeli
nclude it in the baseline measurements too. A git clonable branch for quick testing is available here: https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git/log/?h=kvm-mono1 Thanks, Andrea Andrea Arcangeli (17): x86: spec_ctrl: fix SPEC_CTRL initialization after kexec KVM: monolithic: x86

[PATCH 13/17] KVM: monolithic: x86: drop the kvm_pmu_ops structure

2019-09-20 Thread Andrea Arcangeli
Cleanup after this was finally left fully unused. Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/kvm_host.h | 3 --- arch/x86/kvm/pmu.h | 19 --- arch/x86/kvm/pmu_amd.c | 15 --- arch/x86/kvm/svm.c | 1 - arch/x86/kvm

[PATCH 11/17] KVM: monolithic: x86: remove exports

2019-09-20 Thread Andrea Arcangeli
The exports would be duplicated across kvm-amd and kvm-intel if they're kept, this cleanup various harmless warnings about it. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/cpuid.c| 5 -- arch/x86/kvm/hyperv.c | 2 - arch/x86/kvm/irq.c | 4 -- arch/x86/kvm/irq_comm.c

[PATCH 02/17] KVM: monolithic: x86: convert the kvm_x86_ops methods to external functions

2019-09-20 Thread Andrea Arcangeli
kvm_vcpu_ioctl+559 do_vfs_ioctl+164 ksys_ioctl+96 __x64_sys_ioctl+22 do_syscall_64+89 entry_SYSCALL_64_after_hwframe+68 ]: 227076 @total: 3829460 Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/kvm_ops.h | 166 arch/x86/kvm/svm

[PATCH 14/17] KVM: monolithic: x86: inline more exit handlers in vmx.c

2019-09-20 Thread Andrea Arcangeli
They can be called directly more efficiently, so we can as well mark some of them inline in case gcc doesn't decide to inline them. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/vmx/vmx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b

[PATCH 17/17] x86: retpolines: eliminate retpoline from msr event handlers

2019-09-20 Thread Andrea Arcangeli
l+559 do_vfs_ioctl+164 ksys_ioctl+96 __x64_sys_ioctl+22 do_syscall_64+89 entry_SYSCALL_64_after_hwframe+68 ]: 2390 @[]: 33410 @total: 315707 Note the highest hit above is __delay so probably not worth optimizing even if it would be more frequent than 2k hits per sec. Signed-off-by: A

[PATCH 09/17] KVM: monolithic: x86: remove kvm.ko

2019-09-20 Thread Andrea Arcangeli
This removes kvm.ko and it links and duplicates all kvm.ko objects to both kvm-amd and kvm-intel. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 31ecf7a76d5a

[PATCH 08/17] KVM: monolithic: adjust the section prefixes in the KVM common code

2019-09-20 Thread Andrea Arcangeli
Adjusts the section prefixes of some KVM common code function because with the monolithic methods the section checker can now do a more accurate analysis at build time and this allows to build without CONFIG_SECTION_MISMATCH_WARN_ONLY=n. Signed-off-by: Andrea Arcangeli --- virt/kvm/kvm_main.c

[PATCH 05/17] KVM: monolithic: x86: enable the kvm_x86_ops external functions

2019-09-20 Thread Andrea Arcangeli
Plug in the new external functions and their extern declarations in the respective kernel modules (kvm-intel and kvm-amd). Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/svm.c | 2 ++ arch/x86/kvm/vmx/vmx.c | 2 ++ 3 files changed

[PATCH 10/17] KVM: monolithic: x86: use the external functions instead of kvm_x86_ops

2019-09-20 Thread Andrea Arcangeli
Now that the new methods are plugged in and they are functional use them instead of invoking the pointer to functions through kvm_x86_ops. Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/kvm_host.h | 10 +- arch/x86/kvm/cpuid.c| 22 +-- arch/x86/kvm/hyperv.c

[PATCH 01/17] x86: spec_ctrl: fix SPEC_CTRL initialization after kexec

2019-09-20 Thread Andrea Arcangeli
y and unexpectedly leave bit 2 set in SPEC_CTRL. Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kernel/cpu/bugs.c | 20 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/as

[PATCH 12/17] KVM: monolithic: remove exports from KVM common code

2019-09-20 Thread Andrea Arcangeli
e. Previous export was in arch/x86/kvm/kvm-intel.ko WARNING: arch/x86/kvm/kvm-amd: 'kvm_page_track_unregister_notifier' exported twice. Previous export was in arch/x86/kvm/kvm-intel.ko a Signed-off-by: Andrea Arcangeli --- virt/kvm/eventfd.c | 1 - virt/kvm/kvm_main.c | 65 ---

[PATCH 06/17] KVM: monolithic: x86: enable the kvm_pmu_ops external functions

2019-09-20 Thread Andrea Arcangeli
Plug in the new external functions and their extern declarations in the respective kernel modules (kvm-intel and kvm-amd). Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/pmu.h | 2 ++ arch/x86/kvm/pmu_amd.c | 2 ++ arch/x86/kvm/vmx/pmu_intel.c | 2 ++ 3 files changed, 6

[PATCH 04/17] KVM: monolithic: x86: convert the kvm_pmu_ops methods to external functions

2019-09-20 Thread Andrea Arcangeli
This replaces all kvm_pmu_ops pointer to functions with regular external functions that don't require indirect calls. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/pmu_amd_ops.c | 68 arch/x86/kvm/pmu_ops.h | 22 +++ arch/x86/kv

[PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-20 Thread Andrea Arcangeli
It's enough to check the exit value and issue a direct call to avoid the retpoline for all the common vmexit reasons. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/vmx/vmx.c | 24 ++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vm

[PATCH 16/17] KVM: retpolines: x86: eliminate retpoline from svm.c exit handlers

2019-09-20 Thread Andrea Arcangeli
64+89 entry_SYSCALL_64_after_hwframe+68 ]: 499845 @total: 1780243 SVM has no TSC based programmable preemption timer so it is invoking ktime_get() frequently. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/svm.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/kvm/svm.c b

[PATCH 07/17] KVM: monolithic: x86: adjust the section prefixes

2019-09-20 Thread Andrea Arcangeli
Adjusts the section prefixes of some KVM common code function because with the monolithic methods the section checker can now do a more accurate analysis at build time and this allows to build without CONFIG_SECTION_MISMATCH_WARN_ONLY=n. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/svm.c

Re: [patch for-5.3 0/4] revert immediate fallback to remote hugepages

2019-09-04 Thread Andrea Arcangeli
On Wed, Sep 04, 2019 at 12:54:15PM -0700, David Rientjes wrote: > Two commits: > > commit a8282608c88e08b1782141026eab61204c1e533f > Author: Andrea Arcangeli > Date: Tue Aug 13 15:37:53 2019 -0700 > > Revert "mm, thp: restore node-local hugepag

Re: [PATCH] userfaultfd_release: always remove uffd flags and clear vm_userfaultfd_ctx

2019-08-20 Thread Andrea Arcangeli
changed, 13 insertions(+), 12 deletions(-) Reviewed-by: Andrea Arcangeli Thanks, Andrea

Re: [PATCH] mm/gup: continue VM_FAULT_RETRY processing event for pre-faults

2019-06-22 Thread Andrea Arcangeli
Hello everyone, On Wed, May 22, 2019 at 02:18:03PM -0700, Andrew Morton wrote: > > arch/x86/kernel/fpu/signal.c:198:8-31: -> gup with !pages This simply had not to return -EFAULT if ret < nr_pages.. but ret >= 0. Instead it did: if (ret == nr_pages) goto r

[PATCH 1/1] coredump: fix race condition between collapse_huge_page() and core dumping

2019-06-07 Thread Andrea Arcangeli
tate backporting, but in my view it's more a bug in the coredump code that will eventually have to be rewritten to stop invoking page faults without the mmap_sem for reading. So the long term plan is still to drop all mmget_still_valid(). Cc: Fixes: ba76149f47d8 ("thp: khugepaged") Re

Re: [PATCH 2/2] Revert "mm, thp: restore node-local hugepage allocations"

2019-05-24 Thread Andrea Arcangeli
Hello everyone, On Thu, May 23, 2019 at 05:57:37PM -0700, Andrew Morton wrote: > On Mon, 20 May 2019 10:54:16 -0700 (PDT) David Rientjes > wrote: > > > We are going in circles, *yes* there is a problem for potential swap > > storms today because of the poor interaction between memory compactio

[PATCH 2/2] Revert "mm, thp: restore node-local hugepage allocations"

2019-05-03 Thread Andrea Arcangeli
in feature for guest mode is worth it, to swap "DN 4k | DN+1 THP" with "DN+1 THP | DN 4k" at every NUMA distance crossing. Signed-off-by: Andrea Arcangeli --- include/linux/mempolicy.h | 2 ++ mm/huge_memory.c | 42 --- mm/mempol

[PATCH 0/2] reapply: relax __GFP_THISNODE for MADV_HUGEPAGE mappings

2019-05-03 Thread Andrea Arcangeli
rther. The silver lining is that this extra time allowed to think more at this issue and also plan for a future direction to improve things further in terms of THP NUMA locality. Thank you, Andrea Andrea Arcangeli (2): Revert "Revert "mm, thp: consolidate THP gfp handling into alloc_hug

[PATCH 1/2] Revert "Revert "mm, thp: consolidate THP gfp handling into alloc_hugepage_direct_gfpmask""

2019-05-03 Thread Andrea Arcangeli
This reverts commit 356ff8a9a78fb35d6482584d260c3754dcbdf669. Signed-off-by: Andrea Arcangeli --- include/linux/gfp.h | 12 mm/huge_memory.c| 27 ++- mm/mempolicy.c | 32 +++- mm/shmem.c | 2 +- 4 files changed

Re: [PATCH v2 1/1] userfaultfd/sysctl: add vm.unprivileged_userfaultfd

2019-03-21 Thread Andrea Arcangeli
Hello, On Thu, Mar 21, 2019 at 01:43:35PM +, Luis Chamberlain wrote: > On Wed, Mar 20, 2019 at 03:01:12PM -0400, Andrea Arcangeli wrote: > > but > > that would be better be achieved through SECCOMP and not globally.'. > > That begs the question why not use seccomp

Re: [PATCH v2 1/1] userfaultfd/sysctl: add vm.unprivileged_userfaultfd

2019-03-20 Thread Andrea Arcangeli
Hello, On Tue, Mar 19, 2019 at 06:28:23PM +, Dr. David Alan Gilbert wrote: > --- > Userfaultfd can be misued to make it easier to exploit existing use-after-free > (and similar) bugs that might otherwise only make a short window > or race condition available. By using userfaultfd to stall a k

Re: [PATCH v2 1/1] userfaultfd/sysctl: add vm.unprivileged_userfaultfd

2019-03-19 Thread Andrea Arcangeli
users. When this is > > set to zero, only privileged users (root user, or users with the > > CAP_SYS_PTRACE capability) will be able to use the userfaultfd > > syscalls. > > > > Suggested-by: Andrea Arcangeli > > Suggested-by: Mike Rapoport > > Signed-of

Re: KASAN: use-after-free Read in get_mem_cgroup_from_mm

2019-03-16 Thread Andrea Arcangeli
On Sat, Mar 16, 2019 at 05:38:54PM +0800, zhong jiang wrote: > On 2019/3/16 5:39, Andrea Arcangeli wrote: > > On Fri, Mar 08, 2019 at 03:10:08PM +0800, zhong jiang wrote: > >> I can reproduce the issue in arm64 qemu machine. The issue will leave > >> af

Re: KASAN: use-after-free Read in get_mem_cgroup_from_mm

2019-03-15 Thread Andrea Arcangeli
On Fri, Mar 08, 2019 at 03:10:08PM +0800, zhong jiang wrote: > I can reproduce the issue in arm64 qemu machine. The issue will leave after > applying the > patch. > > Tested-by: zhong jiang Thanks a lot for the quick testing! > Meanwhile, I just has a little doubt whether it is necessary to

Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users

2019-03-14 Thread Andrea Arcangeli
On Thu, Mar 14, 2019 at 11:58:15AM +0100, Paolo Bonzini wrote: > On 14/03/19 00:44, Andrea Arcangeli wrote: > > Then I thought we can add a tristate so an open of /dev/kvm would also > > allow the syscall to make things more user friendly because > > unprivileged container

Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users

2019-03-13 Thread Andrea Arcangeli
On Wed, Mar 13, 2019 at 01:01:40PM -0700, Mike Kravetz wrote: > On 3/13/19 11:52 AM, Andrea Arcangeli wrote: > > > > hugetlbfs is more complicated to detect, because even if you inherit > > it from fork(), the services that mounts the fs may be in a different > >

Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users

2019-03-13 Thread Andrea Arcangeli
Hi Paolo, On Wed, Mar 13, 2019 at 03:12:28PM -0400, Paolo Bonzini wrote: > > > On Wed, Mar 13, 2019 at 09:22:31AM +0100, Paolo Bonzini wrote: > > Unless somebody suggests a consistent way to make hugetlbfs "just > > work" (like we could achieve clean with CRIU and KVM), I think Oracle > > will ne

Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users

2019-03-13 Thread Andrea Arcangeli
Hello, On Wed, Mar 13, 2019 at 09:22:31AM +0100, Paolo Bonzini wrote: > On 13/03/19 07:00, Peter Xu wrote: > >> However, I can imagine more special cases being added for other users. > >> And, > >> once you have more than one special case then you may want to combine them. > >> For example, kvm

<    1   2   3   4   5   6   7   8   9   10   >