Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3287681imm; Fri, 20 Jul 2018 13:42:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcBGPWTzkcVjA4SIUtAaeHf7kdKrydJqYDgkNoTkG4U0WC/AiJwUKefq/B4vbKO5vijxM6l X-Received: by 2002:a17:902:900b:: with SMTP id a11-v6mr3464859plp.143.1532119322298; Fri, 20 Jul 2018 13:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532119322; cv=none; d=google.com; s=arc-20160816; b=agPtdrGBX/ic+/SwwNoOYGNETyTYKHYeojxVFh0aOpu86wKU9YqdWMZiCPze6D0xte wOBbQTY5t3lApjVm9LuR1md796iZzJVD1tn+pwE5Mt4GQ7G+ugHBxmnckbjIhHGYB4XI eF7wLVubmFvGBxcMJaQQPqiPEte16AkqYMgy37ClIPViupW2XQSR4cFx/ZGc7rN8ko0b MSFVUQmTsiPTdK9Wr+k8PB3y1OoHFg9u++L2bWeZKV8gSXHwlS8E5uciGl+dHXKaSYOU PP7qoSJr3E8sLwhBqXbFWe8ZfWAQV71MG4CmNomqgpXpTkBqsPWkpIWNdoxHJICg8+Y8 PUYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=0QvtOSlY7QZLCVtuenYqob5EzFdoiauCm/QEf1/W5H8=; b=lnLOs2HkwoOTG4Ocim4Bw4nrnNkH1Q+ulzvS+4yHI4VmRFECKImNKgoE+Ve/h51g+j 2OK0QGNkIBDvYB90BbYBWLGETxLJzFNBLs/DW7yNT5pfaEXPzzSr4ZENtM1HhHLVSftx vC9PZJhqqGtNk6+Z6NI8Fb1M3nK2009jBE9HUGNgZMkuZhIXhSeTs/K5UWCu6bT415H0 9jzkrOyDPWUnzv79NPGtsexymJZgvILflcI+aGp3zh7LR+lnOatBDoK4X1V/ksliHANj U1FVq79vBxz/7rnDjopDwstqUMUxVgBeGfdc1mE22QauWMpMVDkkxLo52JglHrYu/zBW w9KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w20-v6si2313867ply.137.2018.07.20.13.41.24; Fri, 20 Jul 2018 13:42:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728706AbeGTV1z (ORCPT + 99 others); Fri, 20 Jul 2018 17:27:55 -0400 Received: from terminus.zytor.com ([198.137.202.136]:37993 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728396AbeGTV1y (ORCPT ); Fri, 20 Jul 2018 17:27:54 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6KKasFm2784959 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 20 Jul 2018 13:36:54 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6KKaq2Q2784955; Fri, 20 Jul 2018 13:36:52 -0700 Date: Fri, 20 Jul 2018 13:36:52 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Joerg Roedel Message-ID: Cc: brgerst@gmail.com, torvalds@linux-foundation.org, jroedel@suse.de, hpa@zytor.com, jkosina@suse.cz, acme@kernel.org, tglx@linutronix.de, eduval@amazon.com, jpoimboe@redhat.com, dhgutteridge@sympatico.ca, namhyung@kernel.org, llong@redhat.com, boris.ostrovsky@oracle.com, jolsa@redhat.com, dave.hansen@intel.com, mingo@kernel.org, bp@alien8.de, jgross@suse.com, luto@kernel.org, aarcange@redhat.com, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, pavel@ucw.cz, will.deacon@arm.com, David.Laight@aculab.com, peterz@infradead.org, alexander.shishkin@linux.intel.com Reply-To: dvlasenk@redhat.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, pavel@ucw.cz, will.deacon@arm.com, David.Laight@aculab.com, peterz@infradead.org, alexander.shishkin@linux.intel.com, boris.ostrovsky@oracle.com, llong@redhat.com, jolsa@redhat.com, dave.hansen@intel.com, mingo@kernel.org, bp@alien8.de, jgross@suse.com, luto@kernel.org, aarcange@redhat.com, jpoimboe@redhat.com, dhgutteridge@sympatico.ca, namhyung@kernel.org, brgerst@gmail.com, torvalds@linux-foundation.org, jroedel@suse.de, hpa@zytor.com, jkosina@suse.cz, acme@kernel.org, eduval@amazon.com, tglx@linutronix.de In-Reply-To: <1532103744-31902-2-git-send-email-joro@8bytes.org> References: <1532103744-31902-2-git-send-email-joro@8bytes.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] perf/core: Make sure the ring-buffer is mapped in all page-tables Git-Commit-ID: 77754cfa09a6c528c38cbca9ee4cc4f7cf6ad6f2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 77754cfa09a6c528c38cbca9ee4cc4f7cf6ad6f2 Gitweb: https://git.kernel.org/tip/77754cfa09a6c528c38cbca9ee4cc4f7cf6ad6f2 Author: Joerg Roedel AuthorDate: Fri, 20 Jul 2018 18:22:22 +0200 Committer: Thomas Gleixner CommitDate: Fri, 20 Jul 2018 22:33:41 +0200 perf/core: Make sure the ring-buffer is mapped in all page-tables The ring-buffer is accessed in the NMI handler, so it's better to avoid faulting on it. Sync the vmalloc range with all page-tables in system to make sure everyone has it mapped. This fixes a WARN_ON_ONCE() that can be triggered with PTI enabled on x86-32: WARNING: CPU: 4 PID: 0 at arch/x86/mm/fault.c:320 vmalloc_fault+0x220/0x230 This triggers because with PTI enabled on an PAE kernel the PMDs are no longer shared between the page-tables, so the vmalloc changes do not propagate automatically. Note: Andy said rightfully that we should try to fix the vmalloc code for that case, but that's not a hot fix for the issue at hand. Fixes: 7757d607c6b3 ("x86/pti: Allow CONFIG_PAGE_TABLE_ISOLATION for x86_32") Signed-off-by: Joerg Roedel Signed-off-by: Thomas Gleixner Cc: "H . Peter Anvin" Cc: linux-mm@kvack.org Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Dave Hansen Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Jiri Kosina Cc: Boris Ostrovsky Cc: Brian Gerst Cc: David Laight Cc: Denys Vlasenko Cc: Eduardo Valentin Cc: Greg KH Cc: Will Deacon Cc: aliguori@amazon.com Cc: daniel.gruss@iaik.tugraz.at Cc: hughd@google.com Cc: keescook@google.com Cc: Andrea Arcangeli Cc: Waiman Long Cc: Pavel Machek Cc: "David H . Gutteridge" Cc: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: joro@8bytes.org Link: https://lkml.kernel.org/r/1532103744-31902-2-git-send-email-joro@8bytes.org --- kernel/events/ring_buffer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 5d3cf407e374..df2d8cf0072c 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -814,6 +814,13 @@ static void rb_free_work(struct work_struct *work) vfree(base); kfree(rb); + + /* + * FIXME: PAE workaround for vmalloc_fault(): Make sure buffer is + * unmapped in all page-tables. + */ + if (IS_ENABLED(CONFIG_X86_PAE)) + vmalloc_sync_all(); } void rb_free(struct ring_buffer *rb) @@ -840,6 +847,15 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags) if (!all_buf) goto fail_all_buf; + /* + * FIXME: PAE workaround for vmalloc_fault(): The buffer is + * accessed in NMI handlers, make sure it is mapped in all + * page-tables in the system so that we don't fault on the range in + * an NMI handler. + */ + if (IS_ENABLED(CONFIG_X86_PAE)) + vmalloc_sync_all(); + rb->user_page = all_buf; rb->data_pages[0] = all_buf + PAGE_SIZE; if (nr_pages) {