Skip to content

[NTOS:KE/x64] Fix kernel initialization for SMP#6110

Merged
tkreuzer merged 11 commits intoreactos:masterfrom
tkreuzer:amd64/kernel-init
Dec 8, 2023
Merged

[NTOS:KE/x64] Fix kernel initialization for SMP#6110
tkreuzer merged 11 commits intoreactos:masterfrom
tkreuzer:amd64/kernel-init

Conversation

@tkreuzer
Copy link
Copy Markdown
Contributor

@tkreuzer tkreuzer commented Dec 3, 2023

Purpose

Fix the x64 kernel initialization, so that it works with SMP.
The basic initialization of the PCR and TSS must be independent of the CPU that executes them, so it can be done for the application processors before launching them.
I intentionally split the changes into small commits, so each of them is easy to review.

Proposed changes

  • Rename P0 boot stacks
  • Improve KiInitializeTss
  • Move initialization of KeLoaderBlock
  • Move initialization of PCR
  • Move Initialization of TSS
  • (Re)move initialization of IRQL and TR
  • Factor out KiInitializeP0BootStructures
  • Improve KiInitializePcr
  • Factor out KiIntializeProcessorBootStructures
  • Do not call HalInitSystem from application processors
  • Set the idle thread's IdealProcessor for application processors

Tests

https://reactos.org/testman/compare.php?ids=91633,91634,91638,91640,91641

@tkreuzer tkreuzer added refactoring For refactoring changes. kernel&hal Code changes to the ntoskrnl and HAL SMP Multiprocessor support. labels Dec 3, 2023
@tkreuzer tkreuzer added this to the SMP bringup milestone Dec 3, 2023
@tkreuzer tkreuzer self-assigned this Dec 3, 2023
Copy link
Copy Markdown
Contributor

@JoachimHenze JoachimHenze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved from a pure formal-formatting-reviews perspective. I don't have understanding of that code, but I do highly value the goal of the PR.

KiInitializePcr(&KiInitialPcr, 0, &KiInitialThread.Tcb, KiP0DoubleFaultStack);

/* Setup the TSS descriptors and entries */
KiInitializeTss(&KiInitialPcr,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the x86 equivalent code initializes the TSS descriptors before initializing the PCR. Is there a preferrable order of doing these operations?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't matter. Only thing that matters is that the CPU doesn't make use of those before they are initialized.

@tkreuzer tkreuzer merged commit e5c5efe into reactos:master Dec 8, 2023
@tkreuzer tkreuzer deleted the amd64/kernel-init branch December 8, 2023 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel&hal Code changes to the ntoskrnl and HAL refactoring For refactoring changes. SMP Multiprocessor support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants