Skip to content

Commit

Permalink
ocvalidate: Explicitly restricted ResizeAppleGpuBars to 0 and -1
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Nov 4, 2021
1 parent 0701d15 commit 841eab2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 18 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ OpenCore Changelog
#### v0.7.6
- Fixed stack canary support when compiling with GCC
- Added automatic scaling factor detection
- Explicitly restricted `ResizeAppleGpuBars` to 0 and -1

#### v0.7.5
- Revised OpenLinuxBoot documentation
Expand Down
Binary file modified Docs/Configuration.pdf
Binary file not shown.
14 changes: 6 additions & 8 deletions Docs/Configuration.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1733,10 +1733,12 @@ \subsection{Quirks Properties}\label{booterpropsquirks}

This quirk reduces GPU PCI BAR sizes for Apple macOS up to the specified
value or lower if it is unsupported. The specified value follows PCI Resizable
BAR spec. Use \texttt{0} for 1 MB, \texttt{1} for 2 MB, \texttt{2}
for 4 MB, and so on up to \texttt{19} for 512 GB. Apple macOS supports
1 GB maximum, which is \texttt{10}. Use \texttt{-1} to disable this quirk.
BAR spec. While Apple macOS supports a theoretical 1 GB maximum, in practice all
non-default values may not work correctly. For this reason the only supported
value for this quirk is the minimal supported BAR size, i.e. \texttt{0}. Use
\texttt{-1} to disable this quirk.

For the development purposes one may take the risks and try other values.
Consider a GPU with 2 BARs:
\begin{itemize}
\tightlist
Expand All @@ -1753,13 +1755,9 @@ \subsection{Quirks Properties}\label{booterpropsquirks}
\emph{Example 3}: Setting \texttt{ResizeAppleGpuBars} to 16 GB will make no
changes.

\emph{Note 1}: See \texttt{ResizeGpuBars} quirk for general GPU PCI BAR
\emph{Note}: See \texttt{ResizeGpuBars} quirk for general GPU PCI BAR
size configuration and more details about the technology.

\emph{Note 2}: Certain GPU drivers do not support non-standard BAR sizes,
causing sleep wake issues, for this reason for macOS it is recommended
to use minimal supported BAR sizes, i.e. specify \texttt{0} (1 MB).

\item
\texttt{SetupVirtualMap}\\
\textbf{Type}: \texttt{plist\ boolean}\\
Expand Down
Binary file modified Docs/Differences/Differences.pdf
Binary file not shown.
32 changes: 22 additions & 10 deletions Docs/Differences/Differences.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Wed Nov 3 14:16:04 2021
%DIF ADD ../Configuration.tex Thu Nov 4 18:02:19 2021
%DIF ADD ../Configuration.tex Thu Nov 4 18:36:53 2021

\usepackage{lmodern}
\usepackage{amssymb,amsmath}
Expand Down Expand Up @@ -1793,11 +1793,19 @@ \subsection{Quirks Properties}\label{booterpropsquirks}

This quirk reduces GPU PCI BAR sizes for Apple macOS up to the specified
value or lower if it is unsupported. The specified value follows PCI Resizable
BAR spec. Use \texttt{0} for 1 MB, \texttt{1} for 2 MB, \texttt{2}
for 4 MB, and so on up to \texttt{19} for 512 GB. Apple macOS supports
1 GB maximum, which is \texttt{10}. Use \texttt{-1} to disable this quirk.

Consider a GPU with 2 BARs:
BAR spec. \DIFdelbegin \DIFdel{Use }\texttt{\DIFdel{0}} %DIFAUXCMD
\DIFdel{for 1 MB, }\texttt{\DIFdel{1}} %DIFAUXCMD
\DIFdel{for 2 MB, }\texttt{\DIFdel{2}}
%DIFAUXCMD
\DIFdel{for 4 MB, and so on up to }\texttt{\DIFdel{19}} %DIFAUXCMD
\DIFdel{for 512 GB. }\DIFdelend \DIFaddbegin \DIFadd{While }\DIFaddend Apple macOS supports \DIFaddbegin \DIFadd{a theoretical }\DIFaddend 1 GB maximum, \DIFdelbegin \DIFdel{which is }\texttt{\DIFdel{10}}%DIFAUXCMD
\DIFdel{.}\DIFdelend \DIFaddbegin \DIFadd{in practice all
non-default values may not work correctly. For this reason the only supported
value for this quirk is the minimal supported BAR size, i.e. }\texttt{\DIFadd{0}}\DIFadd{. }\DIFaddend Use
\texttt{-1} to disable this quirk.

\DIFaddbegin \DIFadd{For the development purposes one may take the risks and try other values.
}\DIFaddend Consider a GPU with 2 BARs:
\begin{itemize}
\tightlist
\item \texttt{BAR0} supports sizes from 256 MB to 8 GB. Its value is 4 GB.
Expand All @@ -1813,14 +1821,18 @@ \subsection{Quirks Properties}\label{booterpropsquirks}
\emph{Example 3}: Setting \texttt{ResizeAppleGpuBars} to 16 GB will make no
changes.

\emph{Note 1}: See \texttt{ResizeGpuBars} quirk for general GPU PCI BAR
\emph{Note\DIFdelbegin \DIFdel{1}\DIFdelend }: See \texttt{ResizeGpuBars} quirk for general GPU PCI BAR
size configuration and more details about the technology.

\emph{Note 2}: Certain GPU drivers do not support non-standard BAR sizes,
\DIFdelbegin \emph{\DIFdel{Note 2}}%DIFAUXCMD
\DIFdel{: Certain GPU drivers do not support non-standard BAR sizes,
causing sleep wake issues, for this reason for macOS it is recommended
to use minimal supported BAR sizes, i.e. specify \texttt{0} (1 MB).
to use minimal supported BAR sizes, i.e. specify }\texttt{\DIFdel{0}} %DIFAUXCMD
\DIFdel{(1 MB).
}%DIFDELCMD <

\item
%DIFDELCMD < %%%
\DIFdelend \item
\texttt{SetupVirtualMap}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
Expand Down
Binary file modified Docs/Errata/Errata.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions Utilities/ocvalidate/ValidateBooter.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ CheckBooterQuirks (
}
}

if (UserBooter->Quirks.ResizeAppleGpuBars > 10) {
DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is unsupported by macOS!\n", UserBooter->Quirks.ResizeAppleGpuBars));
++ErrorCount;
} else if (UserBooter->Quirks.ResizeAppleGpuBars > 8) {
DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is unstable with macOS sleep-wake!\n", UserBooter->Quirks.ResizeAppleGpuBars));
++ErrorCount;
} else if (UserBooter->Quirks.ResizeAppleGpuBars > 0) {
DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is not useful for macOS!\n", UserBooter->Quirks.ResizeAppleGpuBars));
++ErrorCount;
}

return ErrorCount;
}

Expand Down

0 comments on commit 841eab2

Please sign in to comment.