From patchwork Wed Jul 25 15:48:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10544235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EF381822 for ; Wed, 25 Jul 2018 15:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C70C2A562 for ; Wed, 25 Jul 2018 15:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 603492A572; Wed, 25 Jul 2018 15:48:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED92C2A562 for ; Wed, 25 Jul 2018 15:48:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C2B36B026D; Wed, 25 Jul 2018 11:48:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 848FC6B0273; Wed, 25 Jul 2018 11:48:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69CF66B0276; Wed, 25 Jul 2018 11:48:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 087D26B026D for ; Wed, 25 Jul 2018 11:48:26 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id s18-v6so3271954edr.15 for ; Wed, 25 Jul 2018 08:48:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=aLVLspOd7Qbtq2EYgt1XnlykT9TipxaQrzABixC1uTc=; b=Qs7u6nGhiPpcW78f82AfWClEitckcsgYnuRVJjYOrOV+bYguaTjTVtZjoIubKr83cx Q0b+uW0aYFx1DUWWtRXgstbeJKxE0Owz6bTlGX1Ekr8Pjno/USCxmrsMOj9lYN+Ll7d0 KCi2Z4dqKZC6JGO67ZyqS8Et180eXW4eWR/mJelgvpR7hLR4oMLxdEAfKaw1t48apVNL 5RYEYkH1Oisy/uumAcSUEoODTf7iYlDrYzaUxzM0GKIP/OmPgtwXCvP8hS+7O/nkWFd6 Ol/UytW1a+jPlriS7dd7OCod2poQ5OsSCivD/ygAgcC/KFeKeup2zlx1UoGc36ffev3l Ad3A== X-Gm-Message-State: AOUpUlExZX1J4ot/Yznh5x/Py7NflBad14FQEK5TvmnJziRdoxRWXCIN l8XSNCeKKRoSfA6twvk+Yh5FAOVLttmSk3VL59dCigTCUtfUDRbKaEWkEDRWN7SYsRM4AK4hdzF K/00gJDtLLZarvl95AVrx5TeUDQ5XA8ynkAGnC+mDFQ3uegZ0s71ZJV5pxSuY/STJ3A== X-Received: by 2002:a50:b410:: with SMTP id b16-v6mr8290477edh.190.1532533705604; Wed, 25 Jul 2018 08:48:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd2DHbAcW4N711JPF8d3YjLJnkkF4S3ycvF/fDWAdeSF16CVrpWLiCNI+akyteyIYm2PI9o X-Received: by 2002:a50:b410:: with SMTP id b16-v6mr8290444edh.190.1532533705015; Wed, 25 Jul 2018 08:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532533704; cv=none; d=google.com; s=arc-20160816; b=jGTGYhvXFchApSwm7QMgEOXxIxgIQhh5RsDAaUgdhhQIVhATzxVV6zmpLSFM0G1irl h9BksDHVhK+AbpOTCoORLwqPTo2kiuOOdLxOMmOMAnO8sJXmBa98FBmnaA1IoXA62TFx excMcSVwne8jeEUXNfPLWPria+IHM1M4n7H30lVTQLT+nP7iCu8JJ7w32wUMNwHgYLII BSw/oa1U0zNwpADLlAO1mRrvQrbxnLct0vtviA6vmSsLRtZLs22aye54bfowREsrd/RI auETGWUpi1VaJMnxh1sIVFVZCmGKOiunXx+ZdDUlno35V06he5LiMJibXXEY7r8OU0Rs oBBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=aLVLspOd7Qbtq2EYgt1XnlykT9TipxaQrzABixC1uTc=; b=OwKZ+r32ShsszucEHss65kMup827eW9jflKNZkJShVBeFHEPq2+pj7LX7S9YlotKqX 5ysw3g23dSZsEnPOvBHN5JBPCNZjrr84QfuZJQSVtztm/+Q7GKjEz8RcCpSYS0bwlEdD +yUXpnh/6/tcXGplQ9dBsFIKmoElMjPCz2qDS12LgGKuJh+H4bpqA8Z7kaM+m/f/WObH dII2pP2GJQhuvfWht9CQ24V9C2B/YJ+qF42Lqu8xMnfpZtb7khp5/ssJlPRWrPgAlWU9 w7hVb5etMi71nMskgEsoxFfg3Zq8iCYCeLsGWFp8jdeVrU9oTgB7UZaA0ec5Yjzq3GGb yuqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=bhTQVlM7; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [2a01:238:4383:600:38bc:a715:4b6d:a889]) by mx.google.com with ESMTPS id 38-v6si4319735edq.417.2018.07.25.08.48.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 08:48:24 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) client-ip=2a01:238:4383:600:38bc:a715:4b6d:a889; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=bhTQVlM7; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id 714D92DC; Wed, 25 Jul 2018 17:48:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1532533699; bh=L9/OWQWqSPUqG2lLweD54IOtxRyq7LaGRIrwnwmSXjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bhTQVlM7n5PlqM8ICWuJsAX/iarutHZxGEb6ajynyNliPRZM546gp8odEVXF76p5E iQmtbc/KAP4ldPX0SDik8KeBdDEX8JyMLI4zlvpiRVzsm8dmnIUFf2lD9rSAjZ1gva yBJKUg87BBP4inpcs3z7DwXxkaaKxTxQ3TuSCqssthzeAve1I5DR6VlLFSXxHLEXJr X1hSrG9oP863uGSYgGg4MGM9IyWNK/8zhYdCFmhKjh6Ea/I/IZeCshQC/8i0vofpfp M7QoNdCUb4hy6v5pSvnaTVFBIkIQa4HI6WHvFIPZrqX/JVZsv1+tit6sRHoC4KI8SG k05f+OsPHAjig== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , "David H . Gutteridge" , jroedel@suse.de, Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , joro@8bytes.org Subject: [PATCH 1/3] x86/mm: Remove in_nmi() warning from vmalloc_fault() Date: Wed, 25 Jul 2018 17:48:01 +0200 Message-Id: <1532533683-5988-2-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532533683-5988-1-git-send-email-joro@8bytes.org> References: <1532533683-5988-1-git-send-email-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel It is perfectly okay to take page-faults, especially on the vmalloc area while executing an NMI handler. Remove the warning. Signed-off-by: Joerg Roedel --- arch/x86/mm/fault.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 2aafa6a..db1c042 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -317,8 +317,6 @@ static noinline int vmalloc_fault(unsigned long address) if (!(address >= VMALLOC_START && address < VMALLOC_END)) return -1; - WARN_ON_ONCE(in_nmi()); - /* * Synchronize this task's top level page-table * with the 'reference' page table. From patchwork Wed Jul 25 15:48:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10544231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4227139A for ; Wed, 25 Jul 2018 15:48:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1F4E2A562 for ; Wed, 25 Jul 2018 15:48:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5B3D2A577; Wed, 25 Jul 2018 15:48:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34CCB2A56B for ; Wed, 25 Jul 2018 15:48:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EB526B0008; Wed, 25 Jul 2018 11:48:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 899416B000A; Wed, 25 Jul 2018 11:48:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7383D6B026A; Wed, 25 Jul 2018 11:48:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 127766B0008 for ; Wed, 25 Jul 2018 11:48:22 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id t10-v6so3253612eds.7 for ; Wed, 25 Jul 2018 08:48:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=e7JIXeIE5y6qltsPiO3RKWlFtD+ateGuDZYAyHjxLWg=; b=Vt0L60z5otAveCfHtNSjfEoRmfMozWEEjyDIwrh2HHlwx9mBVw/pO+pO6MTnRCYAea gzbG5iBLQX8ByVWGn6oJo7OXDHaLOYw3IiOajn8nH5SFSLD0R41pKsxNvBtJ9iIqXESD SDipuicaeaZC8ZSemgo8SErTO1XENu1UoVUDNtF45I3Aw4qL9qdBhi3vNw9MppFrWfz0 wX9KNkI5yqjgaYrTHdpjlNuphELM5I0OyynRbU7U0rlnADeIGx/YW9KC55owifrudRC6 EjmzhoyJacBqS866LxPB3E621taK8fxu23zSnx3Dt1iR7PPIiHO/YVFBgi24+IGQPcs9 G76A== X-Gm-Message-State: AOUpUlEAS5iSa0pTUvSuRDoowkJt4yVb1u2GzOndVq0hh6uAns3Y0QJ6 0txW87OgkEYVxOadOfM/NpqbMR/+0h0NRkkYIXeAxYtTASAkbwjCo7Wldmb4+GmUZW9CgD6OEUX irP9ofHonkme28Q42VcooDdZOEypp6bO45itXSlQQNH7zuN5fjgqxAmPZ2CxeikC/Gw== X-Received: by 2002:a50:8327:: with SMTP id 36-v6mr22778829edh.305.1532533701632; Wed, 25 Jul 2018 08:48:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdGVmpO501+cj9mCojbVX/XlP9oO54h42EwNlPSgpt2kaTi6SyHchHsrqmSNnO5VRl7wo31 X-Received: by 2002:a50:8327:: with SMTP id 36-v6mr22778800edh.305.1532533701019; Wed, 25 Jul 2018 08:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532533701; cv=none; d=google.com; s=arc-20160816; b=BtKj296uH6TL84UiHpaOsE0piZDHrViMVtSlgumlpXfcr2QjzsMaAXh7/ejmc5kfcS etMZWUO8MePjQnkKSKORsOMlbqe7URwJ+b8CA3LRbQjX+M7saHDg0qayCKdtYN2ItjZM Y0ImVpafMi+H8DgtmPGTKfmun5rdE2t4wqeXnPoVlXGd0B2Br0orJf+vO8rCFKGbuIX+ psmeRJsg8LGqCOV/HhtqluAxgjP98cMVt9sv9ueT2+4iAJ5ys1k4SsTEwLitOBMOYi9U NgiBTcrqCN1sSi5x0EEEGZLtIadfq57vNvnKxdYDJqEtb2mAZVtkSUThIZ+MpDrTpyhc 0PwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=e7JIXeIE5y6qltsPiO3RKWlFtD+ateGuDZYAyHjxLWg=; b=hl9wdUA2c2MlwZKxNAXHGiMHhtrowUxWaiUytg0fnVhDJBMYS8jKg5qTwQP7YZY5mZ O6tsMFzZ9gOTqzcfzEFf2Nr67U2nNVtvplgJZd5tmNSFkHAufYOcI4EWL8Nxu/V/Uac8 yzB4Rk7Gzv8g/TdYKvFBXaTuDblk/Q0XbHE9Pg5P/HQ+SgmtHv2x0uv2mgRuTsVdjj0X 6gfVfJUkdl8Fmk3wb9P4ym7by64j4YaA5uwTKAOpOibsRpQcWZnUCIuv20fA8aDRIHIj xncex45IknEQ2bS8xoi9lOJ2RNrv5AIMFdRA4UWBt5FqPxy0qw5jCsza7qnyrvRCfpL8 vJZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=pQwHZjV+; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [81.169.241.247]) by mx.google.com with ESMTPS id j18-v6si8553819edf.210.2018.07.25.08.48.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 08:48:20 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) client-ip=81.169.241.247; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=pQwHZjV+; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id A25381EB; Wed, 25 Jul 2018 17:48:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1532533699; bh=ykRHdAWzkL9irMORgQ3yCGBj8VygOYQR3zKjFy1te0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pQwHZjV+Hsuy/UbgSaVcSi+/79PBz/0jUAGxon4xT3VYFfAELiMBFwtdhiEFS3k1I SaCSLOQLHLrxHDMlUeepWNNwDcka98DxxWd6GSKwnHJDTz8DMnYK1AoY5op7DdlSTT cZ9Utz6IpkmJIbUo2jerBINddG4/P489XP228bM3tPjkPs5KZ7ZBwj7ybO/DwwIc6Q IBS/g3pxjlfkCDp9HXcX9udwzhbODpSQ03oqGyEwDpOPkaZVS0f979VnKR9JrjSo/X o/NJcYMrEIJJsMJo23ZVTsVHhYvMPTUQT5btkkVSJjUVLTDW7u0yarxS2d4fT0a0MX Ml+mp/m7n1wmw== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , "David H . Gutteridge" , jroedel@suse.de, Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , joro@8bytes.org Subject: [PATCH 2/3] Revert "perf/core: Make sure the ring-buffer is mapped in all page-tables" Date: Wed, 25 Jul 2018 17:48:02 +0200 Message-Id: <1532533683-5988-3-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532533683-5988-1-git-send-email-joro@8bytes.org> References: <1532533683-5988-1-git-send-email-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel This reverts commit 77754cfa09a6c528c38cbca9ee4cc4f7cf6ad6f2. The patch was necessary to silence a WARN_ON_ONCE(in_nmi()) that triggered in the vmalloc_fault() function when PTI was enabled on x86-32. Faulting in an NMI handler turned out to be safe and the warning in vmalloc_fault() is gone now. So the above patch can be reverted. Signed-off-by: Joerg Roedel --- kernel/events/ring_buffer.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index df2d8cf..5d3cf40 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -814,13 +814,6 @@ 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) @@ -847,15 +840,6 @@ 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) { From patchwork Wed Jul 25 15:48:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10544233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A72E01822 for ; Wed, 25 Jul 2018 15:48:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 938182A562 for ; Wed, 25 Jul 2018 15:48:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84DEC2A572; Wed, 25 Jul 2018 15:48:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1789D2A570 for ; Wed, 25 Jul 2018 15:48:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7A0E6B000A; Wed, 25 Jul 2018 11:48:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B31216B026A; Wed, 25 Jul 2018 11:48:23 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FA336B026D; Wed, 25 Jul 2018 11:48:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 3F6EF6B000A for ; Wed, 25 Jul 2018 11:48:23 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id r9-v6so3276194edh.14 for ; Wed, 25 Jul 2018 08:48:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=TajgHOneCvhrI3d9Y/ncht+jMZd+KF8cRr7CIcYW0zo=; b=UJHydq4/r3TCwpAlzy9O/PkJQPNBFbxYMybwp1Lk6oxeD6DLJCf2mQfPeduqu6kFqI 0LC0UCImLEVdKtDC21vMIuOB/Bw16CQTXsXIM8c5aZaYIA4m4Q4URmKITqZLjEccAvjq 9KpSOESAH5Kfh2N15PBeQcCEP/Iind4hTHES3IK/wnDsP+GcnChjd4Lh4foqav972aG2 M4xxiCuIUUCZXqYjYuyMfD5uAEO+GSUpsVqnKBnT3Wd7R/i/xM0mBGdroLflZPJH4M6O 6stUxgYU0YJnsGnpqGnSyHfR9RU9uAwVX/aGluKNu5MJEKRmpthY+1M6NQUhvTQcS/Yo IRow== X-Gm-Message-State: AOUpUlFhwysFYIlhKqCXQ1Ox2vrFHV7K5T+nUK8SKZ9nHiRhIhoHefya 0w04oLxsS0XIITY4EgPqnKa6Go+HC+0efWDKVNvvd+01KbqgTvdM6BI4G1eMfOoJAm/vULe1Afa GoEXTCfjg065zXubCV7FEXPQjofthBMrPKnXiZpFdkHsa2WzIHe9lbo/RTAFTm8XYlQ== X-Received: by 2002:a50:f18c:: with SMTP id x12-v6mr24076961edl.59.1532533702817; Wed, 25 Jul 2018 08:48:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcz3UhH9Ofy0FmmmifLWftKhFXVWHENl+SZmh6h/N74gkW0+JHE2bMTykbUxPkrKesK8nBA X-Received: by 2002:a50:f18c:: with SMTP id x12-v6mr24076922edl.59.1532533702118; Wed, 25 Jul 2018 08:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532533702; cv=none; d=google.com; s=arc-20160816; b=otHgXV3/e7jFqovJfC3uzPGVjQCrFdU6JbFqqJ+ldB9Vut92LSE0IBEESOat4oLS38 GHfRGu1XaNwRWT2MPAQRnpRR2YOt3giisP5F5eJdv1N93Cc6zqSEXsUenlAJFDkb4QlD H0N+vd6ivtoBt0P38H6sEYtatKcdxk/MT4E7fTBTTsSDn+FtfUALMaFcktEOLdKBP7ja 7sUs5bGkA0rTuxTnH66cSaaI/g+nQGAsT32AVB/ZKE8c+8O8oOjbl6VqwgGva1E0gp8d IKQ0dxcTW3jaaD+POY/RikogMVRS1jqe6uYFQLIewrzyeFhk+qB83sOaL0GWaRCCxaXE 0dkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=TajgHOneCvhrI3d9Y/ncht+jMZd+KF8cRr7CIcYW0zo=; b=eti+bQt7jXhaaIQ1yznofERvVNnmZSGhcUyDQdbxllgGy/PKOAA+mFY+4oSODJGZRp 9jknO2sGAnrj3Ahld0u/fNYoUTKaiPRIqPLCejcUwNeeJIDKu/CDenT1RSE2ZJ2JZnvo a4Rt1lI7CazZsWxpuPBqPDdcfByYW6y/ug1G9fhfUEC3iWnrKxxv0Km4t4jwlZsYyz3q fynUkvvjFtA1aegF+ZGzGKyAhYeUtZITUiTVyj5Bgouh1zrg3x2uN3IvhsShuj3GViiW iX7dw8BU/dCIvx19Ft5SdLz/hxrxShOClKOdKmRLcH3otYIUdjFGwtV4POrPZP7v/ao/ nbYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=jWvJ76oN; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [81.169.241.247]) by mx.google.com with ESMTPS id f20-v6si4976447eda.234.2018.07.25.08.48.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 08:48:22 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) client-ip=81.169.241.247; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=jWvJ76oN; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id D9F372DF; Wed, 25 Jul 2018 17:48:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1532533699; bh=7uyJQGX9MH9cxdB/eSz9dqZtNfQZQYIzfaEbxYSk570=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWvJ76oNSjsoIEonhak0wCu79+mD3+lH8iEegZ2evNmKO+cqf2NAIgHNfcKAMaf/a MwEA8Nmk4a36mKs1n/PTDVMNm2lbnbqUzO8yVgmf5QPOFm/saH6ykWhxrPA1/ua4rQ jcfBBfX4noPHzUHxiqVdpkXt3zjYVsmYMFnvcPNkVJbkqpPIDyC98hRITyAH2mvxhX Dz8rmMkMDrQGy2YlBi05whtLt7MmvrCzvXCkNig/FKr5J0XFZ6B8xWjhcAFraBcj9l 9QaqO1QXQT/Ghrq9msDwWKdx4gjaCnXVe+LKKXJ3G2xG+JjaZmiVNAdnEC2ReocCF4 0xZCnx2vRRXpw== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , "David H . Gutteridge" , jroedel@suse.de, Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , joro@8bytes.org Subject: [PATCH 3/3] x86/kexec: Allocate 8k PGDs for PTI Date: Wed, 25 Jul 2018 17:48:03 +0200 Message-Id: <1532533683-5988-4-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532533683-5988-1-git-send-email-joro@8bytes.org> References: <1532533683-5988-1-git-send-email-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel Fuzzing the PTI-x86-32 code with trinity showed unhandled kernel paging request oops-messages that looked a lot like silent data corruption. Lot's of debugging and testing lead to the kexec-32bit code, which is still allocating 4k PGDs when PTI is enabled. But since it uses native_set_pud() to build the page-table, it will unevitably call into __pti_set_user_pgtbl(), which writes beyond the allocated 4k page. Use PGD_ALLOCATION_ORDER to allocate PGDs in the kexec code to fix the issue. Signed-off-by: Joerg Roedel --- arch/x86/kernel/machine_kexec_32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c index d1ab07e..5409c28 100644 --- a/arch/x86/kernel/machine_kexec_32.c +++ b/arch/x86/kernel/machine_kexec_32.c @@ -56,7 +56,7 @@ static void load_segments(void) static void machine_kexec_free_page_tables(struct kimage *image) { - free_page((unsigned long)image->arch.pgd); + free_pages((unsigned long)image->arch.pgd, PGD_ALLOCATION_ORDER); image->arch.pgd = NULL; #ifdef CONFIG_X86_PAE free_page((unsigned long)image->arch.pmd0); @@ -72,7 +72,8 @@ static void machine_kexec_free_page_tables(struct kimage *image) static int machine_kexec_alloc_page_tables(struct kimage *image) { - image->arch.pgd = (pgd_t *)get_zeroed_page(GFP_KERNEL); + image->arch.pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, + PGD_ALLOCATION_ORDER); #ifdef CONFIG_X86_PAE image->arch.pmd0 = (pmd_t *)get_zeroed_page(GFP_KERNEL); image->arch.pmd1 = (pmd_t *)get_zeroed_page(GFP_KERNEL);