From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935115AbcA0Sgf (ORCPT ); Wed, 27 Jan 2016 13:36:35 -0500 Received: from mga11.intel.com ([192.55.52.93]:30000 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965081AbcA0Sen (ORCPT ); Wed, 27 Jan 2016 13:34:43 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,356,1449561600"; d="scan'208";a="642331781" From: Sai Praneeth Prakhya To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sai Praneeth , Ricardo Neri , Ravi Shankar , Borislav Petkov , Matt Fleming Subject: [PATCH] x86/mm/pageattr: Use _PAGE_GLOBAL bit for EFI page table mappings Date: Wed, 27 Jan 2016 10:34:56 -0800 Message-Id: <1453919696-13096-1-git-send-email-sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sai Praneeth Since EFI page tables can be treated as kernel page tables they should be global. All the other page mapping functions in pageattr.c set the _PAGE_GLOBAL bit and we want to avoid inconsistencies when we map a page in the EFI code paths, for example when that page is split in __split_large_page(), etc. It also makes it easier to validate that the EFI region mappings have the correct attributes because there are fewer differences compared with regular kernel mappings. Cc: Ricardo Neri Cc: Ravi Shankar Cc: Borislav Petkov Cc: Matt Fleming Signed-off-by: Sai Praneeth Prakhya --- arch/x86/mm/pageattr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 3052e72fa9f5..9256f6406a3c 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -904,6 +904,20 @@ static void populate_pte(struct cpa_data *cpa, pte = pte_offset_kernel(pmd, start); + /* + * Set the GLOBAL flags only if the PRESENT flag is + * set otherwise pte_present will return true even on + * a non present pte. The canon_pgprot will clear + * _PAGE_GLOBAL for the ancient hardware that doesn't + * support it. + */ + if (pgprot_val(pgprot) & _PAGE_PRESENT) + pgprot_val(pgprot) |= _PAGE_GLOBAL; + else + pgprot_val(pgprot) &= ~_PAGE_GLOBAL; + + pgprot = canon_pgprot(pgprot); + while (num_pages-- && start < end) { set_pte(pte, pfn_pte(cpa->pfn, pgprot)); -- 2.1.4