Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3240885imm; Fri, 20 Jul 2018 12:39:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfRrGkp8Dx2fTMuP3xYK1TjRYe4JIML2mgfUohlxV7sGh7EcEIPXVJ6nZm0zY1kMqKoghcv X-Received: by 2002:a17:902:ab95:: with SMTP id f21-v6mr3253586plr.264.1532115580635; Fri, 20 Jul 2018 12:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532115580; cv=none; d=google.com; s=arc-20160816; b=LcVo3+uvXxtpu5OhO8Lh/oRyyjMcEMQWF0CuBr4OaNAVeNg/tEeqPyHnWz9Jv6xPU8 wHTtJLjlIfg057Iesli1tOTqIXNKyza6USg5Kh0NbWvmsEEcnlzLMJQ69PZ8kUL8Zkd2 rNYjwKvIqm5ezrNZPJysbIWXPuZPh30qw+47gEWdvdZx7wAxQUtqHHXZceQ3zi5sQxLp qRMYrg8h2T6AmTZ7MGb7GvQsVQW7TPCeMIbBB2R/HqHbFUo2eetgy+5Hq60ywZ3bNxjb SpMCBeHA4sBsS21YiJRMI4WqCkNCZxgvVlcB5tZcQw9eSIO6AvGRKv0J+moHT1pQdp2b HjVw== 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=kFx1nUTQTuOA6aPW4C2WsXK86ylYkRHGy3wUGrjoUnE=; b=VCHeyDrD3ddlPSGn7DrbEPjTGtgpUFj+Y2K48r5Sa3nozMbmBUKblg5QVjENi1ryJx sLVOcehpdkaXFIJY3OStnGYMq1wDreBZm99SvrM1uIQqg7GJxxt3grzSR/fr2LV57oRW /DAUcKJcO+SQf/qwsuieWp7RBQX0ymUFdquoBqbLN+MKg+/C4E4vYviof9c7YKpPYX7z 7A+xinCam4U6A7CVRUckZ5ZaUPhsUAC2mdGNrwrtnrFmrnOYBXbTZW9Y7OXcBLGECBWy GpjXqm3sKLBhIgJmKBLijRLUqsDM3JZVHBxh5XyTgJ/d6PIuncrRt1d6ZsrzqF/jvvBg b3MQ== 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 b8-v6si2267478pls.392.2018.07.20.12.39.25; Fri, 20 Jul 2018 12:39:40 -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 S1731774AbeGTU2c (ORCPT + 99 others); Fri, 20 Jul 2018 16:28:32 -0400 Received: from terminus.zytor.com ([198.137.202.136]:42187 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731492AbeGTU2b (ORCPT ); Fri, 20 Jul 2018 16:28:31 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6KJb7EE2769209 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 20 Jul 2018 12:37:07 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6KJb7ug2769206; Fri, 20 Jul 2018 12:37:07 -0700 Date: Fri, 20 Jul 2018 12:37:07 -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: will.deacon@arm.com, acme@kernel.org, namhyung@kernel.org, jpoimboe@redhat.com, jgross@suse.com, bp@alien8.de, dhgutteridge@sympatico.ca, pavel@ucw.cz, David.Laight@aculab.com, boris.ostrovsky@oracle.com, gregkh@linuxfoundation.org, jolsa@redhat.com, brgerst@gmail.com, jkosina@suse.cz, eduval@amazon.com, aarcange@redhat.com, torvalds@linux-foundation.org, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, luto@kernel.org, peterz@infradead.org, mingo@kernel.org, tglx@linutronix.de, dvlasenk@redhat.com, jroedel@suse.de, llong@redhat.com, dave.hansen@intel.com Reply-To: luto@kernel.org, hpa@zytor.com, peterz@infradead.org, jroedel@suse.de, dvlasenk@redhat.com, tglx@linutronix.de, mingo@kernel.org, dave.hansen@intel.com, llong@redhat.com, jkosina@suse.cz, jolsa@redhat.com, brgerst@gmail.com, eduval@amazon.com, torvalds@linux-foundation.org, aarcange@redhat.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, bp@alien8.de, dhgutteridge@sympatico.ca, pavel@ucw.cz, David.Laight@aculab.com, gregkh@linuxfoundation.org, boris.ostrovsky@oracle.com, acme@kernel.org, will.deacon@arm.com, namhyung@kernel.org, jgross@suse.com, jpoimboe@redhat.com 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: cdbaf0a372db2bc3c3127e8b63fd15bd6e6757ee 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: cdbaf0a372db2bc3c3127e8b63fd15bd6e6757ee Gitweb: https://git.kernel.org/tip/cdbaf0a372db2bc3c3127e8b63fd15bd6e6757ee Author: Joerg Roedel AuthorDate: Fri, 20 Jul 2018 18:22:22 +0200 Committer: Thomas Gleixner CommitDate: Fri, 20 Jul 2018 21:32:08 +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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 5d3cf407e374..7b0e9aafafdf 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -814,6 +814,9 @@ static void rb_free_work(struct work_struct *work) vfree(base); kfree(rb); + + /* Make sure buffer is unmapped in all page-tables */ + vmalloc_sync_all(); } void rb_free(struct ring_buffer *rb) @@ -840,6 +843,13 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags) if (!all_buf) goto fail_all_buf; + /* + * 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. + */ + vmalloc_sync_all(); + rb->user_page = all_buf; rb->data_pages[0] = all_buf + PAGE_SIZE; if (nr_pages) {