Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752902AbbKPP4V (ORCPT ); Mon, 16 Nov 2015 10:56:21 -0500 Received: from mga11.intel.com ([192.55.52.93]:15953 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751903AbbKPP4S (ORCPT ); Mon, 16 Nov 2015 10:56:18 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,303,1444719600"; d="scan'208";a="821350946" Subject: Re: [PATCH v2 1/5] x86/mm/pageattr: Ensure cpa->pfn only contains page frame numbers To: Matt Fleming , Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" References: <1447538451-5793-1-git-send-email-matt@codeblueprint.co.uk> <1447538451-5793-2-git-send-email-matt@codeblueprint.co.uk> Cc: Toshi Kani , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Sai Praneeth Prakhya , Borislav Petkov From: Dave Hansen Message-ID: <5649FCA1.1000600@intel.com> Date: Mon, 16 Nov 2015 07:56:17 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1447538451-5793-2-git-send-email-matt@codeblueprint.co.uk> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1087 Lines: 28 I'm glad you're looking at this. It obviously needed some love. :) On 11/14/2015 02:00 PM, Matt Fleming wrote: > + npages = (_end - _text) >> PAGE_SHIFT; > + text = __pa(_text); > + pfn = text >> PAGE_SHIFT; > + > + if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, 0)) { > + pr_err("Failed to map kernel text 1:1\n"); > + return 1; > + } Are _end and _text guaranteed to be aligned? If not, I think the calculation might be wrong. Just for fun, imagine that _end=0xfff and _text=0x1001. npages would be 0. Some other code like set_kernel_text_rw() does alignment on _text. One nit is that there's quite a bit going on here, like rearranging the phys_stack arithmetic ordering that is far beyond just simplifying the paddr vs. pfn issue, but that isn't called out in the changelog at all. Your fixes all look correct to me, fwiw. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/