diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h
index 730acdd8bf1..0ccc06eb6f0 100644
--- a/ntoskrnl/mm/ARM3/miarm.h
+++ b/ntoskrnl/mm/ARM3/miarm.h
@@ -830,7 +830,10 @@ MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte,
     /* Start fresh */
     NewPte->u.Long = 0;
 
-    /* Set the protection and page */
+    /* Check that we are not setting valid a page that should not be */
+    ASSERT(ProtectionMask & MM_PROTECT_ACCESS);
+    ASSERT((ProtectionMask & MM_GUARDPAGE) == 0);
+
     NewPte->u.Hard.Valid = TRUE;
     NewPte->u.Hard.Owner = TRUE;
     NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c
index 3e5f5797218..64251ce3872 100644
--- a/ntoskrnl/mm/i386/page.c
+++ b/ntoskrnl/mm/i386/page.c
@@ -19,6 +19,66 @@
 #error "Dude, fix your stuff before using this file"
 #endif
 
+/* CORE-17587 fun */
+#define PA_BIT_PRESENT   (0)
+#define PA_BIT_READWRITE (1)
+#define PA_BIT_USER      (2)
+#define PA_BIT_WT        (3)
+#define PA_BIT_CD        (4)
+#define PA_BIT_ACCESSED  (5)
+#define PA_BIT_DIRTY     (6)
+#define PA_BIT_GLOBAL    (8)
+
+#define PA_PRESENT   (1 << PA_BIT_PRESENT)
+#define PA_READWRITE (1 << PA_BIT_READWRITE)
+#define PA_USER      (1 << PA_BIT_USER)
+#define PA_DIRTY     (1 << PA_BIT_DIRTY)
+#define PA_WT        (1 << PA_BIT_WT)
+#define PA_CD        (1 << PA_BIT_CD)
+#define PA_ACCESSED  (1 << PA_BIT_ACCESSED)
+#define PA_GLOBAL    (1 << PA_BIT_GLOBAL)
+
+static ULONG
+ProtectToPTE(ULONG flProtect)
+{
+    ULONG Attributes = 0;
+
+    if (flProtect & (PAGE_NOACCESS|PAGE_GUARD))
+    {
+        Attributes = 0;
+    }
+    else if (flProtect & PAGE_IS_WRITABLE)
+    {
+        Attributes = PA_PRESENT | PA_READWRITE;
+    }
+    else if (flProtect & (PAGE_IS_READABLE | PAGE_IS_EXECUTABLE))
+    {
+        Attributes = PA_PRESENT;
+    }
+    else
+    {
+        DPRINT1("Unknown main protection type.\n");
+        KeBugCheck(MEMORY_MANAGEMENT);
+    }
+
+    if (flProtect & PAGE_SYSTEM)
+    {
+    }
+    else
+    {
+        Attributes = Attributes | PA_USER;
+    }
+    if (flProtect & PAGE_NOCACHE)
+    {
+        Attributes = Attributes | PA_CD;
+    }
+    if (flProtect & PAGE_WRITETHROUGH)
+    {
+        Attributes = Attributes | PA_WT;
+    }
+    return(Attributes);
+}
+
 /* GLOBALS *****************************************************************/
 const
 ULONG_PTR
@@ -540,6 +600,10 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
     /* Make sure our PDE is valid, and that everything is going fine */
     if (Process == NULL)
     {
+        /* We don't support this in legacy Mm for kernel mappings */
+        ASSERT(ProtectionMask != MM_WRITECOPY);
+        ASSERT(ProtectionMask != MM_EXECUTE_WRITECOPY);
+
         if (Address < MmSystemRangeStart)
         {
             DPRINT1("NULL process given for user-mode mapping at %p\n", Address);
@@ -567,13 +631,24 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
 
     PointerPte = MiAddressToPte(Address);
 
+    MI_MAKE_HARDWARE_PTE(&TempPte, PointerPte, ProtectionMask, Page);
     if (Address >= MmSystemRangeStart)
     {
-        MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, PointerPte, ProtectionMask, Page);
+        // MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, PointerPte, ProtectionMask, Page);
+        if (TempPte.u.Long != ((Page << PAGE_SHIFT) | ProtectToPTE(flProtect | PAGE_SYSTEM) | PA_ACCESSED))
+        {
+            DPRINT1("CORE-17587: TempPte.u.Long %lx, ancient value %lx\n", TempPte.u.Long, (Page << PAGE_SHIFT) | ProtectToPTE(flProtect | PAGE_SYSTEM));
+//            ASSERT(TempPte.u.Long == ((Page << PAGE_SHIFT) | ProtectToPTE(flProtect | PAGE_SYSTEM)));
+        }
     }
     else
     {
-        MI_MAKE_HARDWARE_PTE_USER(&TempPte, PointerPte, ProtectionMask, Page);
+        // MI_MAKE_HARDWARE_PTE_USER(&TempPte, PointerPte, ProtectionMask, Page);
+        if (TempPte.u.Long != ((Page << PAGE_SHIFT) | ProtectToPTE(flProtect) | PA_ACCESSED))
+        {
+            DPRINT1("CORE-17587: TempPte.u.Long %lx, ancient value %lx\n", TempPte.u.Long, (Page << PAGE_SHIFT) | ProtectToPTE(flProtect));
+//            ASSERT(TempPte.u.Long == ((Page << PAGE_SHIFT) | ProtectToPTE(flProtect)));
+        }
     }
 
     Pte = InterlockedExchangePte(PointerPte, TempPte.u.Long);
@@ -710,11 +785,22 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
 
     PointerPte = MiAddressToPte(Address);
 
-    MI_MAKE_HARDWARE_PTE_USER(&TempPte, PointerPte, ProtectionMask, PFN_FROM_PTE(PointerPte));
+    /* Sanity check */
+    ASSERT(PointerPte->u.Hard.Owner == 1);
+
+    TempPte.u.Long = 0;
+    TempPte.u.Hard.PageFrameNumber = PointerPte->u.Hard.PageFrameNumber;
+    TempPte.u.Long |= MmProtectToPteMask[ProtectionMask];
+    TempPte.u.Hard.Owner = 1;
+
     /* Keep dirty & accessed bits */
     TempPte.u.Hard.Accessed = PointerPte->u.Hard.Accessed;
     TempPte.u.Hard.Dirty = PointerPte->u.Hard.Dirty;
 
+    /* Only set valid bit if we have to */
+    if ((ProtectionMask != MM_NOACCESS) && !FlagOn(ProtectionMask, MM_GUARDPAGE))
+        TempPte.u.Hard.Valid = 1;
+
     OldPte.u.Long = InterlockedExchangePte(PointerPte, TempPte.u.Long);
 
     // We should be able to bring a page back from PAGE_NOACCESS
