|
@@ -512,6 +512,23 @@ static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+static pgprot_t pgprot_clear_protnone_bits(pgprot_t prot)
|
|
|
+{
|
|
|
+ /*
|
|
|
+ * _PAGE_GLOBAL means "global page" for present PTEs.
|
|
|
+ * But, it is also used to indicate _PAGE_PROTNONE
|
|
|
+ * for non-present PTEs.
|
|
|
+ *
|
|
|
+ * This ensures that a _PAGE_GLOBAL PTE going from
|
|
|
+ * present to non-present is not confused as
|
|
|
+ * _PAGE_PROTNONE.
|
|
|
+ */
|
|
|
+ if (!(pgprot_val(prot) & _PAGE_PRESENT))
|
|
|
+ pgprot_val(prot) &= ~_PAGE_GLOBAL;
|
|
|
+
|
|
|
+ return prot;
|
|
|
+}
|
|
|
+
|
|
|
static int
|
|
|
try_preserve_large_page(pte_t *kpte, unsigned long address,
|
|
|
struct cpa_data *cpa)
|
|
@@ -577,18 +594,11 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
|
|
|
* different bit positions in the two formats.
|
|
|
*/
|
|
|
req_prot = pgprot_4k_2_large(req_prot);
|
|
|
-
|
|
|
- /*
|
|
|
- * Set the PSE and GLOBAL flags only if the PRESENT flag is
|
|
|
- * set otherwise pmd_present/pmd_huge will return true even on
|
|
|
- * a non present pmd. The canon_pgprot will clear _PAGE_GLOBAL
|
|
|
- * for the ancient hardware that doesn't support it.
|
|
|
- */
|
|
|
+ req_prot = pgprot_clear_protnone_bits(req_prot);
|
|
|
if (pgprot_val(req_prot) & _PAGE_PRESENT)
|
|
|
- pgprot_val(req_prot) |= _PAGE_PSE | _PAGE_GLOBAL;
|
|
|
+ pgprot_val(req_prot) |= _PAGE_PSE;
|
|
|
else
|
|
|
- pgprot_val(req_prot) &= ~(_PAGE_PSE | _PAGE_GLOBAL);
|
|
|
-
|
|
|
+ pgprot_val(req_prot) &= ~_PAGE_PSE;
|
|
|
req_prot = canon_pgprot(req_prot);
|
|
|
|
|
|
/*
|
|
@@ -698,16 +708,7 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address,
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * Set the GLOBAL flags only if the PRESENT flag is set
|
|
|
- * otherwise pmd/pte_present will return true even on a non
|
|
|
- * present pmd/pte. The canon_pgprot will clear _PAGE_GLOBAL
|
|
|
- * for the ancient hardware that doesn't support it.
|
|
|
- */
|
|
|
- if (pgprot_val(ref_prot) & _PAGE_PRESENT)
|
|
|
- pgprot_val(ref_prot) |= _PAGE_GLOBAL;
|
|
|
- else
|
|
|
- pgprot_val(ref_prot) &= ~_PAGE_GLOBAL;
|
|
|
+ ref_prot = pgprot_clear_protnone_bits(ref_prot);
|
|
|
|
|
|
/*
|
|
|
* Get the target pfn from the original entry:
|
|
@@ -930,18 +931,7 @@ 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 = pgprot_clear_protnone_bits(pgprot);
|
|
|
pgprot = canon_pgprot(pgprot);
|
|
|
|
|
|
while (num_pages-- && start < end) {
|
|
@@ -1234,17 +1224,7 @@ repeat:
|
|
|
|
|
|
new_prot = static_protections(new_prot, address, pfn);
|
|
|
|
|
|
- /*
|
|
|
- * 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(new_prot) & _PAGE_PRESENT)
|
|
|
- pgprot_val(new_prot) |= _PAGE_GLOBAL;
|
|
|
- else
|
|
|
- pgprot_val(new_prot) &= ~_PAGE_GLOBAL;
|
|
|
+ new_prot = pgprot_clear_protnone_bits(new_prot);
|
|
|
|
|
|
/*
|
|
|
* We need to keep the pfn from the existing PTE,
|