Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4030449pxb; Mon, 30 Aug 2021 17:02:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCPtVYgSuPiDpoaMZrCuJEG3s0PfEF8jvuM9sOLD7F5iVUTiSOrqW437xSth96AOB4JEf/ X-Received: by 2002:a05:6402:28b3:: with SMTP id eg51mr26744177edb.31.1630368146833; Mon, 30 Aug 2021 17:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630368146; cv=none; d=google.com; s=arc-20160816; b=fDLbHEyubC00Mp2bxC/N1xuxjzDjmAdLnK/IeUcJmTm7n7lEtwmvUXbki16JCIfrWP +Tz7nzqH8Qq/aZSPcEGNfXkhZ87xxIuVGzT1yoEI7mzyYERw6xGqQe9CmpP/I+cReQlP 3CdtYyDGpbcnr+bEB6JYyqCVHXrDOwSEtrf2+Ha6cst9KXG60wu4NHh+iqjapOuj6bA1 tHwTiPzMCGgQTrckyWpkwu/2T2YbC8PYkvLcOcypHNlQP5fMtsdTt0nqcabsyEeU20tx R3AJC/5oAHUu6F44LreULz+Z4yyWuCAHG9o2uuZZ+UOcBLRqU98y2lW8tgM0QPlT50nd 2Hpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=C920z8kTEmUZKH+YZ2YoH5WnSgpYwlCVaBKmKmzWgPc=; b=Le241a+EEughPlEgEvIIWiZCuCS9JHhBZpU3AhV8xLw2HSBfMDnoA0z3AgoJRes3s9 xjCXXWB0UAhRADbByHtGvi+UY98bQH0EXR8S4sP7nIrRfGcgN959PpQRUWH0rTfhReMf bLkpdIzrKfNHeEAuJNf7PCX6vOrIWIf38piFGKO775pWfFN/njsYV5VD3DBH60YCAGPv ba3tAsIoHEPObv2aRmj4XVBmuYWt+AGq2ml3OOgPlUj8DJ/KYFjlYj2PIVD28PBLVdBF 7cJIyzQFRBkblDr8ggG1vchMpKNudPvlL/LGq3DjT2ZK1J0bfGQpTAvwP8nV+J/JK7vL XIEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hc31si6878410ejc.648.2021.08.30.17.02.01; Mon, 30 Aug 2021 17:02:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239366AbhHaABc (ORCPT + 99 others); Mon, 30 Aug 2021 20:01:32 -0400 Received: from mga09.intel.com ([134.134.136.24]:50155 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239206AbhHaAA6 (ORCPT ); Mon, 30 Aug 2021 20:00:58 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10092"; a="218381528" X-IronPort-AV: E=Sophos;i="5.84,364,1620716400"; d="scan'208";a="218381528" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2021 17:00:04 -0700 X-IronPort-AV: E=Sophos;i="5.84,364,1620716400"; d="scan'208";a="530712916" Received: from ajinkyak-mobl2.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.212.240.95]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2021 17:00:03 -0700 From: Rick Edgecombe To: dave.hansen@intel.com, luto@kernel.org, peterz@infradead.org, x86@kernel.org, akpm@linux-foundation.org, keescook@chromium.org, shakeelb@google.com, vbabka@suse.cz, rppt@kernel.org Cc: Rick Edgecombe , linux-mm@kvack.org, linux-hardening@vger.kernel.org, kernel-hardening@lists.openwall.com, ira.weiny@intel.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 10/19] x86/mm: Use alloc_table() for fill_pte(), etc Date: Mon, 30 Aug 2021 16:59:18 -0700 Message-Id: <20210830235927.6443-11-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210830235927.6443-1-rick.p.edgecombe@intel.com> References: <20210830235927.6443-1-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fill_pte(), set_pte_vaddr(), etc allocate page tables with spp_getpage(). Use alloc_table() for these allocations in order to get tables from the cache of protected pages when needed. Opportunistically, fix a stale comment. Signed-off-by: Rick Edgecombe --- arch/x86/mm/init_64.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 3c0323ad99da..de5a785ee89f 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -220,16 +220,19 @@ static void sync_global_pgds(unsigned long start, unsigned long end) /* * NOTE: This function is marked __ref because it calls __init function - * (alloc_bootmem_pages). It's safe to do it ONLY when after_bootmem == 0. + * (memblock_alloc). It's safe to do it ONLY when after_bootmem == 0. */ static __ref void *spp_getpage(void) { void *ptr; - if (after_bootmem) - ptr = (void *) get_zeroed_page(GFP_ATOMIC); - else + if (after_bootmem) { + struct page *page = alloc_table(GFP_ATOMIC | __GFP_ZERO); + + ptr = page ? page_address(page) : NULL; + } else { ptr = memblock_alloc(PAGE_SIZE, PAGE_SIZE); + } if (!ptr || ((unsigned long)ptr & ~PAGE_MASK)) { panic("set_pte_phys: cannot allocate page data %s\n", -- 2.17.1