mirror of
https://github.com/reactos/reactos.git
synced 2024-09-11 05:12:43 +00:00
- Create PDE/PTE entries for KUSER_SHARED_DATA in FreeLDR, so that MmInit1 isn't needed to access it.
- This allows us to access SharedUserData much earlier in the kernel, as well as in kdcom, which means the Windows/TinyKRNL version should now work without modification. svn path=/trunk/; revision=25941
This commit is contained in:
parent
d89145a431
commit
2e20ca1f14
|
@ -40,9 +40,10 @@ ULONG_PTR KernelEntry;
|
||||||
extern PAGE_DIRECTORY_X86 startup_pagedirectory;
|
extern PAGE_DIRECTORY_X86 startup_pagedirectory;
|
||||||
extern PAGE_DIRECTORY_X86 lowmem_pagetable;
|
extern PAGE_DIRECTORY_X86 lowmem_pagetable;
|
||||||
extern PAGE_DIRECTORY_X86 kernel_pagetable;
|
extern PAGE_DIRECTORY_X86 kernel_pagetable;
|
||||||
extern ULONG_PTR hyperspace_pagetable;
|
extern PAGE_DIRECTORY_X86 hyperspace_pagetable;
|
||||||
extern PAGE_DIRECTORY_X86 apic_pagetable;
|
extern PAGE_DIRECTORY_X86 apic_pagetable;
|
||||||
extern PAGE_DIRECTORY_X86 kpcr_pagetable;
|
extern PAGE_DIRECTORY_X86 kpcr_pagetable;
|
||||||
|
extern PAGE_DIRECTORY_X86 kuser_pagetable;
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -184,6 +185,11 @@ FrLdrSetupPageDirectory(VOID)
|
||||||
PageDir->Pde[KpcrPageTableIndex].Write = 1;
|
PageDir->Pde[KpcrPageTableIndex].Write = 1;
|
||||||
PageDir->Pde[KpcrPageTableIndex].PageFrameNumber = PaPtrToPfn(kpcr_pagetable);
|
PageDir->Pde[KpcrPageTableIndex].PageFrameNumber = PaPtrToPfn(kpcr_pagetable);
|
||||||
|
|
||||||
|
/* Set up the KUSER PDE */
|
||||||
|
PageDir->Pde[KuserPageTableIndex].Valid = 1;
|
||||||
|
PageDir->Pde[KuserPageTableIndex].Write = 1;
|
||||||
|
PageDir->Pde[KuserPageTableIndex].PageFrameNumber = PaPtrToPfn(kuser_pagetable);
|
||||||
|
|
||||||
/* Set up Low Memory PTEs */
|
/* Set up Low Memory PTEs */
|
||||||
PageDir = (PPAGE_DIRECTORY_X86)&lowmem_pagetable;
|
PageDir = (PPAGE_DIRECTORY_X86)&lowmem_pagetable;
|
||||||
for (i=0; i<1024; i++)
|
for (i=0; i<1024; i++)
|
||||||
|
@ -221,6 +227,17 @@ FrLdrSetupPageDirectory(VOID)
|
||||||
PageDir->Pde[0].Valid = 1;
|
PageDir->Pde[0].Valid = 1;
|
||||||
PageDir->Pde[0].Write = 1;
|
PageDir->Pde[0].Write = 1;
|
||||||
PageDir->Pde[0].PageFrameNumber = 1;
|
PageDir->Pde[0].PageFrameNumber = 1;
|
||||||
|
|
||||||
|
/* Setup KUSER PTEs */
|
||||||
|
PageDir = (PPAGE_DIRECTORY_X86)&kuser_pagetable;
|
||||||
|
for (i = 0; i < 1024; i++)
|
||||||
|
{
|
||||||
|
/* SEetup each entry */
|
||||||
|
PageDir->Pde[i].Valid = 1;
|
||||||
|
PageDir->Pde[i].Write = 1;
|
||||||
|
PageDir->Pde[i].Owner = 1;
|
||||||
|
PageDir->Pde[i].PageFrameNumber = PaToPfn(KI_USER_SHARED_DATA + i * PAGE_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PLOADER_MODULE
|
PLOADER_MODULE
|
||||||
|
|
|
@ -37,14 +37,7 @@
|
||||||
.globl _hyperspace_pagetable
|
.globl _hyperspace_pagetable
|
||||||
.globl _apic_pagetable
|
.globl _apic_pagetable
|
||||||
.globl _kpcr_pagetable
|
.globl _kpcr_pagetable
|
||||||
|
.globl _kuser_pagetable
|
||||||
.globl _startup_pagedirectorytable_pae
|
|
||||||
.globl _startup_pagedirectory_pae
|
|
||||||
.globl _lowmem_pagetable_pae
|
|
||||||
.globl _kernel_pagetable_pae
|
|
||||||
.globl _hyperspace_pagetable_pae
|
|
||||||
.globl _apic_pagetable_pae
|
|
||||||
.globl _kpcr_pagetable_pae
|
|
||||||
|
|
||||||
.globl _PageDirectoryEnd
|
.globl _PageDirectoryEnd
|
||||||
|
|
||||||
|
@ -80,24 +73,7 @@ _apic_pagetable:
|
||||||
_kpcr_pagetable:
|
_kpcr_pagetable:
|
||||||
.fill 4096, 1, 0
|
.fill 4096, 1, 0
|
||||||
|
|
||||||
_startup_pagedirectory_pae:
|
_kuser_pagetable:
|
||||||
.fill 4 * 4096, 1, 0
|
|
||||||
|
|
||||||
_lowmem_pagetable_pae:
|
|
||||||
.fill 2 * 4096, 1, 0
|
|
||||||
|
|
||||||
_kernel_pagetable_pae:
|
|
||||||
.fill 3*4096, 1, 0
|
|
||||||
|
|
||||||
_hyperspace_pagetable_pae:
|
|
||||||
.fill 2*4096, 1, 0
|
|
||||||
|
|
||||||
_apic_pagetable_pae:
|
|
||||||
.fill 2*4096, 1, 0
|
|
||||||
|
|
||||||
_kpcr_pagetable_pae:
|
|
||||||
.fill 4*4096, 1, 0
|
|
||||||
|
|
||||||
_startup_pagedirectorytable_pae:
|
|
||||||
.fill 4096, 1, 0
|
.fill 4096, 1, 0
|
||||||
|
|
||||||
_PageDirectoryEnd:
|
_PageDirectoryEnd:
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#define HyperspacePageTableIndex (HYPERSPACE_BASE >> 22)
|
#define HyperspacePageTableIndex (HYPERSPACE_BASE >> 22)
|
||||||
#define KpcrPageTableIndex (KPCR_BASE >> 22)
|
#define KpcrPageTableIndex (KPCR_BASE >> 22)
|
||||||
#define ApicPageTableIndex (APIC_BASE >> 22)
|
#define ApicPageTableIndex (APIC_BASE >> 22)
|
||||||
|
#define KuserPageTableIndex (KI_USER_SHARED_DATA >> 22)
|
||||||
|
|
||||||
#define KernelEntryPoint (KernelEntry - KERNEL_BASE_PHYS) + KernelBase
|
#define KernelEntryPoint (KernelEntry - KERNEL_BASE_PHYS) + KernelBase
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,6 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
||||||
ULONG FeatureBits;
|
ULONG FeatureBits;
|
||||||
LARGE_INTEGER PageDirectory;
|
LARGE_INTEGER PageDirectory;
|
||||||
PVOID DpcStack;
|
PVOID DpcStack;
|
||||||
ULONG NXSupportPolicy;
|
|
||||||
ULONG Vendor[3];
|
ULONG Vendor[3];
|
||||||
|
|
||||||
/* Detect and set the CPU Type */
|
/* Detect and set the CPU Type */
|
||||||
|
@ -403,19 +402,19 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
||||||
FeatureBits = KiGetFeatureBits();
|
FeatureBits = KiGetFeatureBits();
|
||||||
|
|
||||||
/* Set the default NX policy (opt-in) */
|
/* Set the default NX policy (opt-in) */
|
||||||
NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
|
||||||
|
|
||||||
/* Check if NPX is always on */
|
/* Check if NPX is always on */
|
||||||
if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=ALWAYSON"))
|
if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=ALWAYSON"))
|
||||||
{
|
{
|
||||||
/* Set it always on */
|
/* Set it always on */
|
||||||
NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSON;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSON;
|
||||||
FeatureBits |= KF_NX_ENABLED;
|
FeatureBits |= KF_NX_ENABLED;
|
||||||
}
|
}
|
||||||
else if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTOUT"))
|
else if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTOUT"))
|
||||||
{
|
{
|
||||||
/* Set it in opt-out mode */
|
/* Set it in opt-out mode */
|
||||||
NXSupportPolicy = NX_SUPPORT_POLICY_OPTOUT;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTOUT;
|
||||||
FeatureBits |= KF_NX_ENABLED;
|
FeatureBits |= KF_NX_ENABLED;
|
||||||
}
|
}
|
||||||
else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTIN")) ||
|
else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTIN")) ||
|
||||||
|
@ -428,7 +427,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
||||||
(strstr(KeLoaderBlock->LoadOptions, "EXECUTE")))
|
(strstr(KeLoaderBlock->LoadOptions, "EXECUTE")))
|
||||||
{
|
{
|
||||||
/* Set disabled mode */
|
/* Set disabled mode */
|
||||||
NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
|
||||||
FeatureBits |= KF_NX_DISABLED;
|
FeatureBits |= KF_NX_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,9 +532,6 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
||||||
0,
|
0,
|
||||||
4096);
|
4096);
|
||||||
|
|
||||||
/* Set the NX Support policy */
|
|
||||||
SharedUserData->NXSupportPolicy = (UCHAR)NXSupportPolicy;
|
|
||||||
|
|
||||||
/* Set basic CPU Features that user mode can read */
|
/* Set basic CPU Features that user mode can read */
|
||||||
SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] =
|
SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] =
|
||||||
(KeFeatureBits & KF_MMX) ? TRUE: FALSE;
|
(KeFeatureBits & KF_MMX) ? TRUE: FALSE;
|
||||||
|
|
Loading…
Reference in a new issue