Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1488339imm; Mon, 3 Sep 2018 01:36:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYNI6rC2TCms216WB7dKkL9ZlMm0kRmexlsE1iNVWcW+bE6bhiGS+PEqZKdbRXbAAPeQ8Fs X-Received: by 2002:a17:902:6808:: with SMTP id h8-v6mr27547649plk.27.1535963819214; Mon, 03 Sep 2018 01:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535963819; cv=none; d=google.com; s=arc-20160816; b=EhejNBosF6l9yk+7oUmKPNLZljBKRC5GDkmjS5iH1p3cvCeW2pqNuvsKOTLZE/oS5m BgYJBb9YMDTRXDblChJr1ay5vM+MRSjssZxJ4sPWk5ysQ/xRKLwpr1aekSL/10XaPdLH Y+iddf1e8a8FUweb5bAoAmuuE4vO5VwMAY1g6v2L6qj1bQK6bZBYs9PhjTk4l7ozKX/V xK/f/v3DNnMQ0bevSRHOp6dN25YQMyX4wbv6yM8nU7g3VEaB2mfXLtSN1IRKOLcNpXUv olEFshd7i+q/f9z0jd1wsRmjm2QFWTH7ovNp+uBqpsE4CKKCuJMj2ry2vxCSHkNM26cX 9idQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=8lQVV6BgBneRbh6weoRWgGuOx3KFs5swKmFPHzGdnb4=; b=LofkEVM7XyxYXKpr9zaZsIEv7TxY0cAoWYmCpEoEBKS6Ba0GPopnhnCZfZjIF76eA2 mrHGr7BBUv99sho68o+ts4ACD2RVtirrBaZIj+TrtVWlkqIzQMK2K13mN5tBW5IRSm7+ pdEppbdVyrMJhHYtQmnwpflCBYc3BjSfzWh/7TSgsBGWNB/n223u5wZAbmtAnemLF6ys aLoxcFN1k6XC3e7rxcKHmH2GY7LCXEvVx97BMcQYnRRAPLnngXPv0noE8OKmyZ9nkrrW 31G44v+G61yS2BglDA1tosTNTKE5fSHfixDaoarMEZNrsg4kb2GvKEkjFKBtLuQEZ+fr MX2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=oHUFv0BO; 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 q197-v6si17180080pgq.526.2018.09.03.01.36.44; Mon, 03 Sep 2018 01:36:59 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=oHUFv0BO; 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 S1727250AbeICMya (ORCPT + 99 others); Mon, 3 Sep 2018 08:54:30 -0400 Received: from merlin.infradead.org ([205.233.59.134]:34678 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbeICMy3 (ORCPT ); Mon, 3 Sep 2018 08:54:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8lQVV6BgBneRbh6weoRWgGuOx3KFs5swKmFPHzGdnb4=; b=oHUFv0BOqfvz/N1h/4OTpFE2q VZvCUjsfSfTsYwqovIYX83UfXtKIuFn4o70FwEv4RjZo+LE+SJUknwlH7FLSGX8JaO/tDVq0UU3L1 L3VpFo8UAs92ChMfJagPG/6O4aHri7tpxq4ynqxca86WLRMTeT9s9dHJ47wEqTo7thgESll5Hpmni 60fVbLzOxfEphZp7FA9z4raLAjJyX+bAbIOJ34c9r3wtBeUWQsSlqODpS1fk5j2mMVSChpEQL6e0m FKrBb/LcKILFcPxGWOV+TEcJ03dB2yI60Yk8eAHqHIY7TR1gf85aAsJ5vpHiF/70Bwg6n9G69bdJG xFlwOc3Tg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwkK5-0006az-5g; Mon, 03 Sep 2018 08:35:01 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D7B22205F8650; Mon, 3 Sep 2018 10:34:59 +0200 (CEST) Date: Mon, 3 Sep 2018 10:34:59 +0200 From: Peter Zijlstra To: Sai Praneeth Prakhya Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, ricardo.neri@intel.com, matt@codeblueprint.co.uk, Lee Chun-Yi , Al Stone , Borislav Petkov , Ingo Molnar , Andy Lutomirski , Bhupesh Sharma , Ard Biesheuvel , Thomas Gleixner Subject: Re: [PATCH V2 5/6] x86/mm: If in_atomic(), allocate pages without sleeping Message-ID: <20180903083459.GT24124@hirez.programming.kicks-ass.net> References: <1535881594-25469-1-git-send-email-sai.praneeth.prakhya@intel.com> <1535881594-25469-6-git-send-email-sai.praneeth.prakhya@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1535881594-25469-6-git-send-email-sai.praneeth.prakhya@intel.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 02, 2018 at 02:46:33AM -0700, Sai Praneeth Prakhya wrote: > From: Sai Praneeth > > A page fault occurs when any EFI Runtime Service tries to reference a > memory region which it shouldn't. If the illegally accessed region > is EFI_BOOT_SERVICES_, the efi specific page fault handler > fixes it up by dynamically creating VA->PA mappings using > efi_map_region(). > > Originally, efi_map_region() and hence the functionality of creating > mappings for efi regions was intended to be used *only* during boot time > (please note __init modifier) and hence when called during runtime (i.e. > from efi page fault handler), the page allocators complain. Calling > efi_map_region() during runtime complains because "gfp_allowed_mask" > value changes from boot time to runtime (GFP_BOOT_MASK to > __GFP_BITS_MASK). During boot, even though efi_map_region() calls > alloc__page with GFP_KERNEL, the page allocator doesn't > complain because "__GFP_RECLAIM" flag is cleared by "gfp_allowed_mask", > but during runtime it isn't cleared and hence prints below stack trace. > > BUG: sleeping function called from invalid context at mm/page_alloc.c:4320 > get_zeroed_page+0x12/0x40 > alloc_pmd_page+0x13/0x50 > populate_pmd+0xc0/0x2e0 > __cpa_process_fault+0x2e1/0x5d0 > __change_page_attr_set_clr+0x7c3/0xcd0 > kernel_map_pages_in_pgd+0x8c/0x160 > __map_region+0x3c/0x60 > efi_map_region+0x83/0xd0 > efi_illegal_accesses_fixup+0x1ca/0x1e0 > no_context+0x112/0x390 > __do_page_fault+0xc7/0x4f0 > Fix the above warning by conditionally changing the allocation from > GFP_KERNEL to GFP_ATOMIC, so that efi page fault handler could use > efi_map_region() during runtime. This change shouldn't effect any other > generic page allocations because this allocation is used only by efi > functions [1]. > diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c > index 3bded76e8d5c..1b28a333c8ce 100644 > --- a/arch/x86/mm/pageattr.c > +++ b/arch/x86/mm/pageattr.c > @@ -926,7 +926,13 @@ static void unmap_pud_range(p4d_t *p4d, unsigned long start, unsigned long end) > > static int alloc_pte_page(pmd_t *pmd) > { > - pte_t *pte = (pte_t *)get_zeroed_page(GFP_KERNEL); > + pte_t *pte; > + > + if (in_atomic()) > + pte = (pte_t *)get_zeroed_page(GFP_ATOMIC); > + else > + pte = (pte_t *)get_zeroed_page(GFP_KERNEL); > + > if (!pte) > return -1; > This looks like tinkering to me..