Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions uefi_loader/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ extern "C" {
#include <Protocol/LoadedImage.h>
#include <Protocol/MpService.h>
}
#include "zpp/scope_guard.h"
#include "zpp/x64/asm.h"
#include <cstddef>
#include <cstdint>
#include <string>

namespace zpp
{
/**
* The boot services.
*/
Expand Down Expand Up @@ -112,6 +116,11 @@ static int call_on_cpu(std::size_t cpuid,
{
int result = -1;

// Save this GDT and restore it at function exit.
alignas(0x10) unsigned char gdt_layout[0x10]{};
x64::sgdt(gdt_layout);
scope_guard restore_gdt = [&] { x64::lgdt(gdt_layout); };

// If this is the main CPU, just call the user function.
if (0 == cpuid) {
return function(context);
Expand Down Expand Up @@ -383,3 +392,5 @@ extern "C" EFI_STATUS EFIAPI uefi_main(EFI_HANDLE image_handle,
// Return success anyway, no image was found is considered ok.
return EFI_SUCCESS;
}

} // namespace zpp
8 changes: 4 additions & 4 deletions uefi_loader/uefi_loader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,30 @@
<NMakeCleanCommandLine>C:\Windows\sysnative\bash -c "make clean"</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>C:\Windows\sysnative\bash -c "make clean &amp;&amp; make"</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>include;../loader/include;C:/Temp/edk2-UDK2018/MdePkg/Include</NMakeIncludeSearchPath>
<NMakeIncludeSearchPath>include;../hypervisor/include;C:/Temp/edk2-UDK2018/MdePkg/Include</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeBuildCommandLine>C:\Windows\sysnative\bash -c make</NMakeBuildCommandLine>
<NMakeCleanCommandLine>C:\Windows\sysnative\bash -c "make clean"</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>C:\Windows\sysnative\bash -c "make clean &amp;&amp; make"</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>include;../loader/include;C:/Temp/edk2-UDK2018/MdePkg/Include</NMakeIncludeSearchPath>
<NMakeIncludeSearchPath>include;../hypervisor/include;C:/Temp/edk2-UDK2018/MdePkg/Include</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakeBuildCommandLine>C:\Windows\sysnative\bash -c "make mode=release"</NMakeBuildCommandLine>
<NMakeOutput>hypervisor.exe</NMakeOutput>
<NMakeCleanCommandLine>C:\Windows\sysnative\bash -c "make clean"</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>C:\Windows\sysnative\bash -c "make clean &amp;&amp; make mode=release"</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>include;../loader/include;C:/Temp/edk2-UDK2018/MdePkg/Include</NMakeIncludeSearchPath>
<NMakeIncludeSearchPath>include;../hypervisor/include;C:/Temp/edk2-UDK2018/MdePkg/Include</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NMakeBuildCommandLine>C:\Windows\sysnative\bash -c "make mode=release"</NMakeBuildCommandLine>
<NMakeOutput>hypervisor.exe</NMakeOutput>
<NMakeCleanCommandLine>C:\Windows\sysnative\bash -c "make clean"</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>C:\Windows\sysnative\bash -c "make clean &amp;&amp; make mode=release"</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>include;../loader/include;C:/Temp/edk2-UDK2018/MdePkg/Include</NMakeIncludeSearchPath>
<NMakeIncludeSearchPath>include;../hypervisor/include;C:/Temp/edk2-UDK2018/MdePkg/Include</NMakeIncludeSearchPath>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
Expand Down