Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3833870ybf; Tue, 3 Mar 2020 13:49:14 -0800 (PST) X-Google-Smtp-Source: ADFU+vtkakKmZ0umLxfPuQY3nx2n+mge/aGQcX0Zt8WAQDOssUcyBgfqFq2ynvqndn4UFrBHprTV X-Received: by 2002:a05:6830:1112:: with SMTP id w18mr3357729otq.185.1583272154577; Tue, 03 Mar 2020 13:49:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583272154; cv=none; d=google.com; s=arc-20160816; b=o76On1rTBnzc8852hQNhntE+hTwNS1r5PZyXpDlIU6y6g5zxJdB+1y/7P9XkciWISf vHuNAqV8vOSPMdrz7NVYMM3RN1orW2+V4ziO1UwwfACSvd9tXUXDoKnkplf+/rIPgbMR OqAVDgkbTC2eXVfvEbjKtPWwUb3cINL/de7sfErS2l9NGdu3jCVXqJMnXjW2ZjLzCOIQ xVGg0v5BG2iT8y5GsitMd5Iznjg75t579atHsES/KmPM1wXr9oYFv4dHBBlgAkqHmgs9 XE0j4wEatmf76GYF+0rV7EKGalbfLTKonz4R2P3AvoNx+wTOqA4TAS3H0dFMJrKoRyvE r+mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LpQl3QOx5Q+iwwtomiSeHz+aE8G4tQSvo7FgTI9tPuc=; b=r8pQQmZaBnemGpl3gvq0IEU8OYhZEwyWR93naYrYvUa5HJJ8QNaCjPSw9oWhu7gZ6/ OOj0f2wkD2UIravvDfj58zH9knRpFErr3eKpaLGRo9zJYHHxquV4PPKmOWMDI2O6oKFj 6U0uMRcwM0G3K0/WN6gphFmVnZCK6ORicVGq2Wk/0Jq1Szj3JlE8a739WDh/Y32yqxXL 1W31H5Pvzjs6i/px2V2Nc1avpeW2SaBW5B4iLBZDwQbUOiQ20WSsA3ucrpccZcjeu7oR 52AVa8pGI7szGgW8PP8V9WAAcuUiR5hGvqCLDkSwa/0lOOCvTqjrqVf7mCSM9kb8qy96 fzGQ== 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 v203si24197oif.224.2020.03.03.13.49.02; Tue, 03 Mar 2020 13:49:14 -0800 (PST) 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 S1732134AbgCCUyx (ORCPT + 99 others); Tue, 3 Mar 2020 15:54:53 -0500 Received: from mail-qv1-f65.google.com ([209.85.219.65]:45477 "EHLO mail-qv1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731387AbgCCUyu (ORCPT ); Tue, 3 Mar 2020 15:54:50 -0500 Received: by mail-qv1-f65.google.com with SMTP id r8so2336654qvs.12; Tue, 03 Mar 2020 12:54:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LpQl3QOx5Q+iwwtomiSeHz+aE8G4tQSvo7FgTI9tPuc=; b=PSqdvhd2W9ItnvxRDhJ7TffR6b8U5YbwMkn+rJNsf8NU4SnVlI7b+KD5hP8EbADXuy rrGLg2bM1vUkll2IIUDRT5+ZkiXOt9nNBtLP90Y3++sJj0t7qTi5G2UHBR3MBgKnH/8S tPQ0FLGFcaK0Oa9hVquZwuYpvpugUO5zHvZOqwBsc+phzSRthRwyrqhfJ95GXPCoY0Ag u1nvy7hscs18G8OMTzXYBWnGybSu5C2t2J5Mj3BVZuoOGNK4jrzTAJpLnzMw1oX68CH0 ZXDk8xlWL3mUjCEazRLF88ByEJ8YueK9SBOH3E9jmUSP+7XPBjjhsg9kw2eAhIc7Xki+ K0JA== X-Gm-Message-State: ANhLgQ0u7ed+cMU3Se7L4UNTudW8qUYo/Wi0Pl9zjZxZezRBBqGjKP+p 3jmIRKnGKrjKFABDKNEOFl0= X-Received: by 2002:a05:6214:381:: with SMTP id l1mr5780954qvy.178.1583268889854; Tue, 03 Mar 2020 12:54:49 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id v12sm11473041qti.84.2020.03.03.12.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 12:54:49 -0800 (PST) From: Arvind Sankar To: Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Ard Biesheuvel , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] x86/mm/pat: Make num_pages consistent in populate_{pte,pud,pgd} Date: Tue, 3 Mar 2020 15:54:45 -0500 Message-Id: <20200303205445.3965393-5-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200303205445.3965393-1-nivedita@alum.mit.edu> References: <20200303205445.3965393-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The number of pages is currently all of int, unsigned int, long and unsigned long in different places. Change it to be consistently unsigned long. Remove the unnecessary min(num_pages, cur_pages), since pre_end has already been min'd with start + num_pages << PAGE_SHIFT. This gets rid of two conversions to int/unsigned int. Signed-off-by: Arvind Sankar --- arch/x86/include/asm/pgtable_types.h | 2 +- arch/x86/mm/pat/set_memory.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 0239998d8cdc..894569255a95 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -574,7 +574,7 @@ extern pmd_t *lookup_pmd_address(unsigned long address); extern phys_addr_t slow_virt_to_phys(void *__address); extern int __init kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, - unsigned numpages, + unsigned long numpages, unsigned long page_flags); extern int __init kernel_unmap_pages_in_pgd(pgd_t *pgd, unsigned long address, unsigned long numpages); diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 2f98423ef69a..51b64937cc16 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1230,7 +1230,7 @@ static int alloc_pmd_page(pud_t *pud) static void populate_pte(struct cpa_data *cpa, unsigned long start, unsigned long end, - unsigned num_pages, pmd_t *pmd, pgprot_t pgprot) + unsigned long num_pages, pmd_t *pmd, pgprot_t pgprot) { pte_t *pte; @@ -1249,9 +1249,9 @@ static void populate_pte(struct cpa_data *cpa, static int populate_pmd(struct cpa_data *cpa, unsigned long start, unsigned long end, - unsigned num_pages, pud_t *pud, pgprot_t pgprot) + unsigned long num_pages, pud_t *pud, pgprot_t pgprot) { - long cur_pages = 0; + unsigned long cur_pages = 0; pmd_t *pmd; pgprot_t pmd_pgprot; @@ -1264,7 +1264,6 @@ static int populate_pmd(struct cpa_data *cpa, pre_end = min_t(unsigned long, pre_end, next_page); cur_pages = (pre_end - start) >> PAGE_SHIFT; - cur_pages = min_t(unsigned int, num_pages, cur_pages); /* * Need a PTE page? @@ -1326,7 +1325,7 @@ static int populate_pud(struct cpa_data *cpa, unsigned long start, p4d_t *p4d, { pud_t *pud; unsigned long end; - long cur_pages = 0; + unsigned long cur_pages = 0; pgprot_t pud_pgprot; int ret; @@ -1342,7 +1341,6 @@ static int populate_pud(struct cpa_data *cpa, unsigned long start, p4d_t *p4d, pre_end = min_t(unsigned long, end, next_page); cur_pages = (pre_end - start) >> PAGE_SHIFT; - cur_pages = min_t(int, (int)cpa->numpages, cur_pages); pud = pud_offset(p4d, start); @@ -2231,7 +2229,8 @@ bool kernel_page_present(struct page *page) #endif /* CONFIG_HIBERNATION */ int __init kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, - unsigned numpages, unsigned long page_flags) + unsigned long numpages, + unsigned long page_flags) { int retval = -EINVAL; -- 2.24.1