ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
December 2023
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
20 participants
274 discussions
Start a n
N
ew thread
[reactos] 06/11: [NTOS:KE/x64] (Re)move initialization of IRQL and TR
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e65559460913f1dc41f5d…
commit e65559460913f1dc41f5d33f671aa6353bb3e7b0 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Dec 2 16:37:44 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 20:16:51 2023 +0200 [NTOS:KE/x64] (Re)move initialization of IRQL and TR --- ntoskrnl/ke/amd64/kiinit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c index c6810ef1253..999b09b4fbe 100644 --- a/ntoskrnl/ke/amd64/kiinit.c +++ b/ntoskrnl/ke/amd64/kiinit.c @@ -162,7 +162,6 @@ KiInitializePcr(IN PKIPCR Pcr, /* Start us out at PASSIVE_LEVEL */ Pcr->Irql = PASSIVE_LEVEL; - KeSetCurrentIrql(PASSIVE_LEVEL); } VOID @@ -240,6 +239,8 @@ KiInitializeCpu(PKIPCR Pcr) /* Initialize MXCSR */ _mm_setcsr(INITIAL_MXCSR); + + KeSetCurrentIrql(PASSIVE_LEVEL); } static @@ -276,9 +277,6 @@ KiInitializeTss( /* Setup a stack for NMI Traps */ Tss->Ist[3] = (ULONG64)NmiStack; - - /* Load the task register */ - __ltr(KGDT64_SYS_TSS); } CODE_SEG("INIT")
1 year
1
0
0
0
[reactos] 05/11: [NTOS:KE/x64] Move Initialization of TSS
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0a7255e4bf999b9d1e80f…
commit 0a7255e4bf999b9d1e80fb79bddc2acebc607e4a Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Dec 2 16:35:16 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 20:16:51 2023 +0200 [NTOS:KE/x64] Move Initialization of TSS --- ntoskrnl/ke/amd64/kiinit.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c index 441f5cf9433..c6810ef1253 100644 --- a/ntoskrnl/ke/amd64/kiinit.c +++ b/ntoskrnl/ke/amd64/kiinit.c @@ -446,6 +446,13 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Initialize the PCR */ KiInitializePcr(&KiInitialPcr, 0, &KiInitialThread.Tcb, KiP0DoubleFaultStack); + + /* Setup the TSS descriptors and entries */ + KiInitializeTss(&KiInitialPcr, + KiInitialPcr.TssBase, + KiP0BootStack, + KiP0DoubleFaultStack, + KiP0DoubleFaultStack); } /* Get Pcr from loader block */ @@ -473,13 +480,6 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Initialize the module list (ntos, hal, kdcom) */ KiInitModuleList(LoaderBlock); - /* Setup the TSS descriptors and entries */ - KiInitializeTss(Pcr, - Pcr->TssBase, - (PVOID)InitialStack, - KiP0DoubleFaultStack, - KiP0DoubleFaultStack); - /* Setup the IDT */ KeInitExceptions();
1 year
1
0
0
0
[reactos] 04/11: [NTOS:KE/x64] Move initialization of PCR
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=160980aba1abc89545889…
commit 160980aba1abc89545889e49206454dd55fe7e86 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Dec 2 16:32:20 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 20:16:51 2023 +0200 [NTOS:KE/x64] Move initialization of PCR --- ntoskrnl/ke/amd64/kiinit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c index 3eb576178ac..441f5cf9433 100644 --- a/ntoskrnl/ke/amd64/kiinit.c +++ b/ntoskrnl/ke/amd64/kiinit.c @@ -443,6 +443,9 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) LoaderBlock->Thread = (ULONG_PTR)&KiInitialThread; LoaderBlock->Process = (ULONG_PTR)&KiInitialProcess.Pcb; LoaderBlock->Prcb = (ULONG_PTR)&KiInitialPcr.Prcb; + + /* Initialize the PCR */ + KiInitializePcr(&KiInitialPcr, 0, &KiInitialThread.Tcb, KiP0DoubleFaultStack); } /* Get Pcr from loader block */ @@ -461,9 +464,6 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Set us as the current process */ InitialThread->ApcState.Process = (PVOID)LoaderBlock->Process; - /* Initialize the PCR */ - KiInitializePcr(Pcr, Cpu, InitialThread, KiP0DoubleFaultStack); - /* Initialize the CPU features */ KiInitializeCpu(Pcr);
1 year
1
0
0
0
[reactos] 03/11: [NTOS:KE/x64] Move initialization of KeLoaderBlock
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba62dd0aaa24ebf4715e8…
commit ba62dd0aaa24ebf4715e85a608d96f9bbd488992 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Dec 2 16:29:59 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 20:16:51 2023 +0200 [NTOS:KE/x64] Move initialization of KeLoaderBlock --- ntoskrnl/ke/amd64/kiinit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c index 3f7703c8680..3eb576178ac 100644 --- a/ntoskrnl/ke/amd64/kiinit.c +++ b/ntoskrnl/ke/amd64/kiinit.c @@ -429,15 +429,15 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) FrLdrDbgPrint = LoaderBlock->u.I386.CommonDataArea; //FrLdrDbgPrint("Hello from KiSystemStartup!!!\n"); - /* Save the loader block */ - KeLoaderBlock = LoaderBlock; - /* Get the current CPU number */ Cpu = KeNumberProcessors++; // FIXME /* LoaderBlock initialization for Cpu 0 */ if (Cpu == 0) { + /* Save the loader block */ + KeLoaderBlock = LoaderBlock; + /* Set the initial stack, idle thread and process */ LoaderBlock->KernelStack = (ULONG_PTR)KiP0BootStack; LoaderBlock->Thread = (ULONG_PTR)&KiInitialThread;
1 year
1
0
0
0
[reactos] 02/11: [NTOS:KE/x64] Improve KiInitializeTss
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e1497d43d7dd0e363fe28…
commit e1497d43d7dd0e363fe280ed92b4823e4c318323 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Dec 2 13:24:28 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 20:16:51 2023 +0200 [NTOS:KE/x64] Improve KiInitializeTss --- ntoskrnl/include/internal/amd64/ke.h | 2 -- ntoskrnl/ke/amd64/kiinit.c | 26 +++++++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ntoskrnl/include/internal/amd64/ke.h b/ntoskrnl/include/internal/amd64/ke.h index b44cffbfd94..f54f33037d9 100644 --- a/ntoskrnl/include/internal/amd64/ke.h +++ b/ntoskrnl/include/internal/amd64/ke.h @@ -385,8 +385,6 @@ Ki386PerfEnd(VOID) struct _KPCR; -//VOID KiInitializeTss(IN PKTSS Tss, IN UINT64 Stack); - DECLSPEC_NORETURN VOID KiSwitchToBootStack(IN ULONG_PTR InitialStack); VOID KiDivideErrorFault(VOID); VOID KiDebugTrapOrFault(VOID); diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c index be33e65b4ec..3f7703c8680 100644 --- a/ntoskrnl/ke/amd64/kiinit.c +++ b/ntoskrnl/ke/amd64/kiinit.c @@ -242,15 +242,19 @@ KiInitializeCpu(PKIPCR Pcr) _mm_setcsr(INITIAL_MXCSR); } +static VOID -FASTCALL -KiInitializeTss(IN PKTSS64 Tss, - IN UINT64 Stack) +KiInitializeTss( + _In_ PKIPCR Pcr, + _Out_ PKTSS64 Tss, + _In_ PVOID InitialStack, + _In_ PVOID DoubleFaultStack, + _In_ PVOID NmiStack) { PKGDTENTRY64 TssEntry; /* Get pointer to the GDT entry */ - TssEntry = KiGetGdtEntry(KeGetPcr()->GdtBase, KGDT64_SYS_TSS); + TssEntry = KiGetGdtEntry(Pcr->GdtBase, KGDT64_SYS_TSS); /* Initialize the GDT entry */ KiInitGdtEntry(TssEntry, (ULONG64)Tss, sizeof(KTSS64), AMD64_TSS, 0); @@ -262,16 +266,16 @@ KiInitializeTss(IN PKTSS64 Tss, Tss->IoMapBase = 0x68; /* Setup ring 0 stack pointer */ - Tss->Rsp0 = Stack; + Tss->Rsp0 = (ULONG64)InitialStack; /* Setup a stack for Double Fault Traps */ - Tss->Ist[1] = (ULONG64)KiP0DoubleFaultStack; + Tss->Ist[1] = (ULONG64)DoubleFaultStack; /* Setup a stack for CheckAbort Traps */ - Tss->Ist[2] = (ULONG64)KiP0DoubleFaultStack; + Tss->Ist[2] = (ULONG64)DoubleFaultStack; /* Setup a stack for NMI Traps */ - Tss->Ist[3] = (ULONG64)KiP0DoubleFaultStack; + Tss->Ist[3] = (ULONG64)NmiStack; /* Load the task register */ __ltr(KGDT64_SYS_TSS); @@ -470,7 +474,11 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) KiInitModuleList(LoaderBlock); /* Setup the TSS descriptors and entries */ - KiInitializeTss(Pcr->TssBase, InitialStack); + KiInitializeTss(Pcr, + Pcr->TssBase, + (PVOID)InitialStack, + KiP0DoubleFaultStack, + KiP0DoubleFaultStack); /* Setup the IDT */ KeInitExceptions();
1 year
1
0
0
0
[reactos] 01/11: [NTOS:KE/x64] Rename P0 boot stacks
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bbe16859b58c882d821ae…
commit bbe16859b58c882d821aea6f17970091bcb28d3b Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Dec 2 13:24:28 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 20:16:51 2023 +0200 [NTOS:KE/x64] Rename P0 boot stacks --- ntoskrnl/ke/amd64/kiinit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c index 6d6ffbd3f2a..be33e65b4ec 100644 --- a/ntoskrnl/ke/amd64/kiinit.c +++ b/ntoskrnl/ke/amd64/kiinit.c @@ -29,10 +29,10 @@ KSPIN_LOCK KiFreezeExecutionLock; KIPCR KiInitialPcr; /* Boot and double-fault/NMI/DPC stack */ -UCHAR DECLSPEC_ALIGN(16) P0BootStackData[KERNEL_STACK_SIZE] = {0}; -UCHAR DECLSPEC_ALIGN(16) KiDoubleFaultStackData[KERNEL_STACK_SIZE] = {0}; -ULONG_PTR P0BootStack = (ULONG_PTR)&P0BootStackData[KERNEL_STACK_SIZE]; -ULONG_PTR KiDoubleFaultStack = (ULONG_PTR)&KiDoubleFaultStackData[KERNEL_STACK_SIZE]; +UCHAR DECLSPEC_ALIGN(16) KiP0BootStackData[KERNEL_STACK_SIZE] = {0}; +UCHAR DECLSPEC_ALIGN(16) KiP0DoubleFaultStackData[KERNEL_STACK_SIZE] = {0}; +PVOID KiP0BootStack = &KiP0BootStackData[KERNEL_STACK_SIZE]; +PVOID KiP0DoubleFaultStack = &KiP0DoubleFaultStackData[KERNEL_STACK_SIZE]; ULONGLONG BootCycles, BootCyclesEnd; @@ -265,13 +265,13 @@ KiInitializeTss(IN PKTSS64 Tss, Tss->Rsp0 = Stack; /* Setup a stack for Double Fault Traps */ - Tss->Ist[1] = (ULONG64)KiDoubleFaultStack; + Tss->Ist[1] = (ULONG64)KiP0DoubleFaultStack; /* Setup a stack for CheckAbort Traps */ - Tss->Ist[2] = (ULONG64)KiDoubleFaultStack; + Tss->Ist[2] = (ULONG64)KiP0DoubleFaultStack; /* Setup a stack for NMI Traps */ - Tss->Ist[3] = (ULONG64)KiDoubleFaultStack; + Tss->Ist[3] = (ULONG64)KiP0DoubleFaultStack; /* Load the task register */ __ltr(KGDT64_SYS_TSS); @@ -435,7 +435,7 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) if (Cpu == 0) { /* Set the initial stack, idle thread and process */ - LoaderBlock->KernelStack = (ULONG_PTR)P0BootStack; + LoaderBlock->KernelStack = (ULONG_PTR)KiP0BootStack; LoaderBlock->Thread = (ULONG_PTR)&KiInitialThread; LoaderBlock->Process = (ULONG_PTR)&KiInitialProcess.Pcb; LoaderBlock->Prcb = (ULONG_PTR)&KiInitialPcr.Prcb; @@ -458,7 +458,7 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) InitialThread->ApcState.Process = (PVOID)LoaderBlock->Process; /* Initialize the PCR */ - KiInitializePcr(Pcr, Cpu, InitialThread, (PVOID)KiDoubleFaultStack); + KiInitializePcr(Pcr, Cpu, InitialThread, KiP0DoubleFaultStack); /* Initialize the CPU features */ KiInitializeCpu(Pcr);
1 year
1
0
0
0
[reactos] 02/02: [NTOS:KE/x64] Add back a stubs.c file
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6c5b3f203d3a1e6687d92…
commit 6c5b3f203d3a1e6687d92653ba630a1c73556f3c Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Wed Dec 6 10:49:06 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 19:38:59 2023 +0200 [NTOS:KE/x64] Add back a stubs.c file --- ntoskrnl/ke/amd64/stubs.c | 195 ++++++++++++++++++++++++++++++++++++++++ ntoskrnl/ke/amd64/traphandler.c | 185 +------------------------------------- ntoskrnl/ntos.cmake | 1 + 3 files changed, 197 insertions(+), 184 deletions(-) diff --git a/ntoskrnl/ke/amd64/stubs.c b/ntoskrnl/ke/amd64/stubs.c new file mode 100644 index 00000000000..cb2d4a37248 --- /dev/null +++ b/ntoskrnl/ke/amd64/stubs.c @@ -0,0 +1,195 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: stubs + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include <ntoskrnl.h> + +#define NDEBUG +#include <debug.h> + +/* GLOBALS *******************************************************************/ + +ULONG ProcessCount; +SIZE_T KeXStateLength = sizeof(XSAVE_FORMAT); + +PVOID +KiSwitchKernelStackHelper( + LONG_PTR StackOffset, + PVOID OldStackBase); + +/* + * Kernel stack layout (example pointers): + * 0xFFFFFC0F'2D008000 KTHREAD::StackBase + * [XSAVE_AREA size == KeXStateLength = 0x440] + * 0xFFFFFC0F'2D007BC0 KTHREAD::StateSaveArea _XSAVE_FORMAT + * 0xFFFFFC0F'2D007B90 KTHREAD::InitialStack + * [0x190 bytes KTRAP_FRAME] + * 0xFFFFFC0F'2D007A00 KTHREAD::TrapFrame + * [KSTART_FRAME] or ... + * [KSWITCH_FRAME] + * 0xFFFFFC0F'2D007230 KTHREAD::KernelStack + */ + +PVOID +NTAPI +KiSwitchKernelStack(PVOID StackBase, PVOID StackLimit) +{ + PKTHREAD CurrentThread; + PVOID OldStackBase; + LONG_PTR StackOffset; + SIZE_T StackSize; + PKIPCR Pcr; + ULONG Eflags; + + /* Get the current thread */ + CurrentThread = KeGetCurrentThread(); + + /* Save the old stack base */ + OldStackBase = CurrentThread->StackBase; + + /* Get the size of the current stack */ + StackSize = (ULONG_PTR)CurrentThread->StackBase - CurrentThread->StackLimit; + ASSERT(StackSize <= (ULONG_PTR)StackBase - (ULONG_PTR)StackLimit); + + /* Copy the current stack contents to the new stack */ + RtlCopyMemory((PUCHAR)StackBase - StackSize, + (PVOID)CurrentThread->StackLimit, + StackSize); + + /* Calculate the offset between the old and the new stack */ + StackOffset = (PUCHAR)StackBase - (PUCHAR)CurrentThread->StackBase; + + /* Disable interrupts while messing with the stack */ + Eflags = __readeflags(); + _disable(); + + /* Set the new trap frame */ + CurrentThread->TrapFrame = (PKTRAP_FRAME)Add2Ptr(CurrentThread->TrapFrame, + StackOffset); + + /* Set the new initial stack */ + CurrentThread->InitialStack = Add2Ptr(CurrentThread->InitialStack, + StackOffset); + + /* Set the new stack limits */ + CurrentThread->StackBase = StackBase; + CurrentThread->StackLimit = (ULONG_PTR)StackLimit; + CurrentThread->LargeStack = TRUE; + + /* Adjust RspBase in the PCR */ + Pcr = (PKIPCR)KeGetPcr(); + Pcr->Prcb.RspBase += StackOffset; + + /* Adjust Rsp0 in the TSS */ + Pcr->TssBase->Rsp0 += StackOffset; + + /* Restore interrupts */ + __writeeflags(Eflags); + + return OldStackBase; +} + +DECLSPEC_NORETURN +VOID +KiIdleLoop(VOID) +{ + PKPRCB Prcb = KeGetCurrentPrcb(); + PKTHREAD OldThread, NewThread; + + /* Now loop forever */ + while (TRUE) + { + /* Start of the idle loop: disable interrupts */ + _enable(); + YieldProcessor(); + YieldProcessor(); + _disable(); + + /* Check for pending timers, pending DPCs, or pending ready threads */ + if ((Prcb->DpcData[0].DpcQueueDepth) || + (Prcb->TimerRequest) || + (Prcb->DeferredReadyListHead.Next)) + { + /* Quiesce the DPC software interrupt */ + HalClearSoftwareInterrupt(DISPATCH_LEVEL); + + /* Handle it */ + KiRetireDpcList(Prcb); + } + + /* Check if a new thread is scheduled for execution */ + if (Prcb->NextThread) + { + /* Enable interrupts */ + _enable(); + + /* Capture current thread data */ + OldThread = Prcb->CurrentThread; + NewThread = Prcb->NextThread; + + /* Set new thread data */ + Prcb->NextThread = NULL; + Prcb->CurrentThread = NewThread; + + /* The thread is now running */ + NewThread->State = Running; + + /* Do the swap at SYNCH_LEVEL */ + KfRaiseIrql(SYNCH_LEVEL); + + /* Switch away from the idle thread */ + KiSwapContext(APC_LEVEL, OldThread); + + /* Go back to DISPATCH_LEVEL */ + KeLowerIrql(DISPATCH_LEVEL); + } + else + { + /* Continue staying idle. Note the HAL returns with interrupts on */ + Prcb->PowerState.IdleFunction(&Prcb->PowerState); + } + } +} + +VOID +NTAPI +KiSwapProcess(IN PKPROCESS NewProcess, + IN PKPROCESS OldProcess) +{ + PKIPCR Pcr = (PKIPCR)KeGetPcr(); + +#ifdef CONFIG_SMP + /* Update active processor mask */ + InterlockedXor64((PLONG64)&NewProcess->ActiveProcessors, Pcr->Prcb.SetMember); + InterlockedXor64((PLONG64)&OldProcess->ActiveProcessors, Pcr->Prcb.SetMember); +#endif + + /* Update CR3 */ + __writecr3(NewProcess->DirectoryTableBase[0]); + + /* Update IOPM offset */ + Pcr->TssBase->IoMapBase = NewProcess->IopmOffset; +} + +NTSTATUS +NTAPI +NtSetLdtEntries(ULONG Selector1, LDT_ENTRY LdtEntry1, ULONG Selector2, LDT_ENTRY LdtEntry2) +{ + UNIMPLEMENTED; + __debugbreak(); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +NtVdmControl(IN ULONG ControlCode, + IN PVOID ControlData) +{ + /* Not supported */ + return STATUS_NOT_IMPLEMENTED; +} diff --git a/ntoskrnl/ke/amd64/traphandler.c b/ntoskrnl/ke/amd64/traphandler.c index 7933d2c1cf9..2b67b07d7b8 100644 --- a/ntoskrnl/ke/amd64/traphandler.c +++ b/ntoskrnl/ke/amd64/traphandler.c @@ -1,21 +1,17 @@ /* * PROJECT: ReactOS Kernel * LICENSE: GPL - See COPYING in the top level directory - * PURPOSE: stubs + * PURPOSE: x64 trap handlers * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org) */ /* INCLUDES ******************************************************************/ #include <ntoskrnl.h> -#include <fltkernel.h> #define NDEBUG #include <debug.h> -ULONG ProcessCount; -SIZE_T KeXStateLength = sizeof(XSAVE_FORMAT); - VOID KiRetireDpcListInDpcStack( PKPRCB Prcb, @@ -88,165 +84,6 @@ KiDpcInterruptHandler(VOID) KeLowerIrql(OldIrql); } -PVOID -KiSwitchKernelStackHelper( - LONG_PTR StackOffset, - PVOID OldStackBase); - -/* - * Kernel stack layout (example pointers): - * 0xFFFFFC0F'2D008000 KTHREAD::StackBase - * [XSAVE_AREA size == KeXStateLength = 0x440] - * 0xFFFFFC0F'2D007BC0 KTHREAD::StateSaveArea _XSAVE_FORMAT - * 0xFFFFFC0F'2D007B90 KTHREAD::InitialStack - * [0x190 bytes KTRAP_FRAME] - * 0xFFFFFC0F'2D007A00 KTHREAD::TrapFrame - * [KSTART_FRAME] or ... - * [KSWITCH_FRAME] - * 0xFFFFFC0F'2D007230 KTHREAD::KernelStack - */ - -PVOID -NTAPI -KiSwitchKernelStack(PVOID StackBase, PVOID StackLimit) -{ - PKTHREAD CurrentThread; - PVOID OldStackBase; - LONG_PTR StackOffset; - SIZE_T StackSize; - PKIPCR Pcr; - ULONG Eflags; - - /* Get the current thread */ - CurrentThread = KeGetCurrentThread(); - - /* Save the old stack base */ - OldStackBase = CurrentThread->StackBase; - - /* Get the size of the current stack */ - StackSize = (ULONG_PTR)CurrentThread->StackBase - CurrentThread->StackLimit; - ASSERT(StackSize <= (ULONG_PTR)StackBase - (ULONG_PTR)StackLimit); - - /* Copy the current stack contents to the new stack */ - RtlCopyMemory((PUCHAR)StackBase - StackSize, - (PVOID)CurrentThread->StackLimit, - StackSize); - - /* Calculate the offset between the old and the new stack */ - StackOffset = (PUCHAR)StackBase - (PUCHAR)CurrentThread->StackBase; - - /* Disable interrupts while messing with the stack */ - Eflags = __readeflags(); - _disable(); - - /* Set the new trap frame */ - CurrentThread->TrapFrame = (PKTRAP_FRAME)Add2Ptr(CurrentThread->TrapFrame, - StackOffset); - - /* Set the new initial stack */ - CurrentThread->InitialStack = Add2Ptr(CurrentThread->InitialStack, - StackOffset); - - /* Set the new stack limits */ - CurrentThread->StackBase = StackBase; - CurrentThread->StackLimit = (ULONG_PTR)StackLimit; - CurrentThread->LargeStack = TRUE; - - /* Adjust RspBase in the PCR */ - Pcr = (PKIPCR)KeGetPcr(); - Pcr->Prcb.RspBase += StackOffset; - - /* Adjust Rsp0 in the TSS */ - Pcr->TssBase->Rsp0 += StackOffset; - - /* Restore interrupts */ - __writeeflags(Eflags); - - return OldStackBase; -} - -DECLSPEC_NORETURN -VOID -KiIdleLoop(VOID) -{ - PKPRCB Prcb = KeGetCurrentPrcb(); - PKTHREAD OldThread, NewThread; - - /* Now loop forever */ - while (TRUE) - { - /* Start of the idle loop: disable interrupts */ - _enable(); - YieldProcessor(); - YieldProcessor(); - _disable(); - - /* Check for pending timers, pending DPCs, or pending ready threads */ - if ((Prcb->DpcData[0].DpcQueueDepth) || - (Prcb->TimerRequest) || - (Prcb->DeferredReadyListHead.Next)) - { - /* Quiesce the DPC software interrupt */ - HalClearSoftwareInterrupt(DISPATCH_LEVEL); - - /* Handle it */ - KiRetireDpcList(Prcb); - } - - /* Check if a new thread is scheduled for execution */ - if (Prcb->NextThread) - { - /* Enable interrupts */ - _enable(); - - /* Capture current thread data */ - OldThread = Prcb->CurrentThread; - NewThread = Prcb->NextThread; - - /* Set new thread data */ - Prcb->NextThread = NULL; - Prcb->CurrentThread = NewThread; - - /* The thread is now running */ - NewThread->State = Running; - - /* Do the swap at SYNCH_LEVEL */ - KfRaiseIrql(SYNCH_LEVEL); - - /* Switch away from the idle thread */ - KiSwapContext(APC_LEVEL, OldThread); - - /* Go back to DISPATCH_LEVEL */ - KeLowerIrql(DISPATCH_LEVEL); - } - else - { - /* Continue staying idle. Note the HAL returns with interrupts on */ - Prcb->PowerState.IdleFunction(&Prcb->PowerState); - } - } -} - -VOID -NTAPI -KiSwapProcess(IN PKPROCESS NewProcess, - IN PKPROCESS OldProcess) -{ - PKIPCR Pcr = (PKIPCR)KeGetPcr(); - -#ifdef CONFIG_SMP - /* Update active processor mask */ - InterlockedXor64((PLONG64)&NewProcess->ActiveProcessors, Pcr->Prcb.SetMember); - InterlockedXor64((PLONG64)&OldProcess->ActiveProcessors, Pcr->Prcb.SetMember); -#endif - - /* Update CR3 */ - __writecr3(NewProcess->DirectoryTableBase[0]); - - /* Update IOPM offset */ - Pcr->TssBase->IoMapBase = NewProcess->IopmOffset; -} - #define MAX_SYSCALL_PARAMS 16 NTSTATUS @@ -402,23 +239,3 @@ KiSystemService(IN PKTHREAD Thread, __debugbreak(); } -NTSTATUS -NTAPI -NtSetLdtEntries -(ULONG Selector1, LDT_ENTRY LdtEntry1, ULONG Selector2, LDT_ENTRY LdtEntry2) -{ - UNIMPLEMENTED; - __debugbreak(); - return STATUS_UNSUCCESSFUL; -} - -NTSTATUS -NTAPI -NtVdmControl(IN ULONG ControlCode, - IN PVOID ControlData) -{ - /* Not supported */ - return STATUS_NOT_IMPLEMENTED; -} - - diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake index 1fc4307573f..26a1e07b17e 100644 --- a/ntoskrnl/ntos.cmake +++ b/ntoskrnl/ntos.cmake @@ -359,6 +359,7 @@ elseif(ARCH STREQUAL "amd64") ${REACTOS_SOURCE_DIR}/ntoskrnl/mm/amd64/init.c ${REACTOS_SOURCE_DIR}/ntoskrnl/mm/amd64/procsup.c ${REACTOS_SOURCE_DIR}/ntoskrnl/ps/amd64/psctx.c + ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/stubs.c ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/traphandler.c ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/usercall.c) if(BUILD_MP)
1 year
1
0
0
0
[reactos] 01/02: [NTOS:KE/x64] Rename stubs.c to traphandler.c
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=57c7f06004f432741478c…
commit 57c7f06004f432741478c8e800b562822ffaf260 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Wed Dec 6 10:38:31 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 19:38:59 2023 +0200 [NTOS:KE/x64] Rename stubs.c to traphandler.c --- ntoskrnl/ke/amd64/{stubs.c => traphandler.c} | 0 ntoskrnl/ntos.cmake | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/ke/amd64/stubs.c b/ntoskrnl/ke/amd64/traphandler.c similarity index 100% rename from ntoskrnl/ke/amd64/stubs.c rename to ntoskrnl/ke/amd64/traphandler.c diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake index e1adedf9892..1fc4307573f 100644 --- a/ntoskrnl/ntos.cmake +++ b/ntoskrnl/ntos.cmake @@ -359,7 +359,7 @@ elseif(ARCH STREQUAL "amd64") ${REACTOS_SOURCE_DIR}/ntoskrnl/mm/amd64/init.c ${REACTOS_SOURCE_DIR}/ntoskrnl/mm/amd64/procsup.c ${REACTOS_SOURCE_DIR}/ntoskrnl/ps/amd64/psctx.c - ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/stubs.c + ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/traphandler.c ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/usercall.c) if(BUILD_MP) list(APPEND SOURCE
1 year
1
0
0
0
[reactos] 03/03: [HALX86] Some improvements / bugfixes for IPI support functions
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=230f7c7f3c34a91c921bd…
commit 230f7c7f3c34a91c921bd0db826d01631c55bf03 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Thu Nov 30 14:08:12 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 19:28:57 2023 +0200 [HALX86] Some improvements / bugfixes for IPI support functions --- hal/halx86/apic/apicsmp.c | 6 +++--- hal/halx86/generic/up.c | 2 ++ hal/halx86/smp/ipi.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hal/halx86/apic/apicsmp.c b/hal/halx86/apic/apicsmp.c index 47415bc84b6..5165a367156 100644 --- a/hal/halx86/apic/apicsmp.c +++ b/hal/halx86/apic/apicsmp.c @@ -51,7 +51,7 @@ extern PPROCESSOR_IDENTITY HalpProcessorIdentity; APIC_DSH_Destination APIC_DSH_Self APIC_DSH_AllIncludingSelf - APIC_DSH_AllExclusingSelf + APIC_DSH_AllExcludingSelf \see "AMD64 Architecture Programmer's Manual Volume 2 System Programming" Chapter 16 "Advanced Programmable Interrupt Controller (APIC)" @@ -170,7 +170,7 @@ HalRequestIpiSpecifyVector( _In_ KAFFINITY TargetSet, _In_ UCHAR Vector) { - KAFFINITY ActiveProcessors = KeQueryActiveProcessors(); + KAFFINITY ActiveProcessors = HalpActiveProcessors; KAFFINITY RemainingSet, SetMember; ULONG ProcessorIndex; ULONG LApicId; @@ -277,7 +277,7 @@ HalpSendNMI( ULONG LApicId; /* Make sure we do not send an NMI to ourselves */ - ASSERT((TargetSet & ~KeGetCurrentPrcb()->SetMember) == 0); + ASSERT((TargetSet & KeGetCurrentPrcb()->SetMember) == 0); /* Loop while we have more processors */ RemainingSet = TargetSet; diff --git a/hal/halx86/generic/up.c b/hal/halx86/generic/up.c index dd60cc1cffb..377c7e1aaf5 100644 --- a/hal/halx86/generic/up.c +++ b/hal/halx86/generic/up.c @@ -40,6 +40,7 @@ NTAPI HalSendNMI( _In_ KAFFINITY TargetSet) { + NOTHING; } VOID @@ -48,6 +49,7 @@ HalSendSoftwareInterrupt( _In_ KAFFINITY TargetSet, _In_ KIRQL Irql) { + NOTHING; } #endif // _M_AMD64 diff --git a/hal/halx86/smp/ipi.c b/hal/halx86/smp/ipi.c index a2411961dae..48747026cc9 100644 --- a/hal/halx86/smp/ipi.c +++ b/hal/halx86/smp/ipi.c @@ -35,7 +35,7 @@ HalSendNMI( // See: // -
https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Runtime/r0drv/nt/int…
-//
https://github.com/mirror/vbox/blob/b9657cd5351cf17432b664009cc25bb480dc64c…
+// -
https://github.com/mirror/vbox/blob/b9657cd5351cf17432b664009cc25bb480dc64c…
VOID NTAPI HalSendSoftwareInterrupt(
1 year
1
0
0
0
[reactos] 02/03: [HALX86] Use InterlockedBitTestAndSetAffinity instead of InterlockedBitTestAndSet
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d8d46a00c37b7d46484e7…
commit d8d46a00c37b7d46484e7947f67e0d9a7f984c4b Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Thu Nov 30 14:04:21 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Fri Dec 8 19:28:57 2023 +0200 [HALX86] Use InterlockedBitTestAndSetAffinity instead of InterlockedBitTestAndSet --- hal/halx86/generic/halinit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hal/halx86/generic/halinit.c b/hal/halx86/generic/halinit.c index bbd3c49204e..70822fd5cc5 100644 --- a/hal/halx86/generic/halinit.c +++ b/hal/halx86/generic/halinit.c @@ -54,9 +54,8 @@ HalInitializeProcessor( KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT; /* Update the interrupt affinity and processor mask */ - InterlockedBitTestAndSet((PLONG)&HalpActiveProcessors, ProcessorNumber); - InterlockedBitTestAndSet((PLONG)&HalpDefaultInterruptAffinity, - ProcessorNumber); + InterlockedBitTestAndSetAffinity(&HalpActiveProcessors, ProcessorNumber); + InterlockedBitTestAndSetAffinity(&HalpDefaultInterruptAffinity, ProcessorNumber); /* Register routines for KDCOM */ HalpRegisterKdSupportFunctions();
1 year
1
0
0
0
← Newer
1
...
20
21
22
23
24
25
26
27
28
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Results per page:
10
25
50
100
200