diff --git a/docs/FAT-Pointer/FAT-Pointer.org b/docs/FAT-Pointer/FAT-Pointer.org index 6c86fd7..3c0f7af 100644 --- a/docs/FAT-Pointer/FAT-Pointer.org +++ b/docs/FAT-Pointer/FAT-Pointer.org @@ -17,7 +17,7 @@ control over memory regions. #+CAPTION: High overview architecture #+NAME: fig:HighOverviewArchitecture -[[file:diagram/HighOverviewArchitecture24.png]] +[[file:diagram/HighOverviewArchitecture.drawio.png]] Figure \ref{fig:HighOverviewArchitecture} illustrates the methodology employed to leverage the CHERI diff --git a/docs/FAT-Pointer/FAT-Pointer.pdf b/docs/FAT-Pointer/FAT-Pointer.pdf index d714051..4a1bc29 100644 Binary files a/docs/FAT-Pointer/FAT-Pointer.pdf and b/docs/FAT-Pointer/FAT-Pointer.pdf differ diff --git a/docs/FAT-Pointer/FAT-Pointer.tex b/docs/FAT-Pointer/FAT-Pointer.tex index c2bf5b3..b8dc619 100644 --- a/docs/FAT-Pointer/FAT-Pointer.tex +++ b/docs/FAT-Pointer/FAT-Pointer.tex @@ -1,4 +1,4 @@ -% Created 2025-02-04 Tue 16:04 +% Created 2025-02-05 Wed 17:11 % Intended LaTeX compiler: pdflatex \documentclass[11pt]{article} \usepackage[utf8]{inputenc} @@ -32,7 +32,7 @@ \section{Fat-pointer Address Translations} -\label{sec:orgda6e9a4} +\label{sec:org98b9cf6} Fat-pointer Address Translations, combined with the capabilities of the CHERI (Capability Hardware Enhanced RISC Instructions) architecture, introduce robust memory safety and security features by incorporating additional metadata @@ -46,8 +46,8 @@ control over memory regions. \begin{figure}[htbp] \centering -\includegraphics[width=.9\linewidth]{diagram/HighOverviewArchitecture24.png} -\caption{\label{fig:orgcc16dce}High overview architecture} +\includegraphics[width=.9\linewidth]{diagram/HighOverviewArchitecture.drawio.png} +\caption{\label{fig:orgf77b5d6}High overview architecture} \end{figure} Figure \ref{fig:HighOverviewArchitecture} illustrates @@ -73,11 +73,11 @@ The functionality of ranges encompasses several key aspects: \subsection{Encoding Ranges as Bounds to the Pointer} -\label{sec:org35c3d2b} +\label{sec:org333c91d} \begin{figure}[htbp] \centering \includegraphics[width=.9\linewidth]{diagram/AllocationOverview24.png} -\caption{\label{fig:org4c237f8}Range of memory} +\caption{\label{fig:org7770b41}Range of memory} \end{figure} Integrating range bounds directly into FAT-pointers enables the architecture @@ -95,11 +95,11 @@ management of the allocated memory regions. By using the FAT-pointer bounds, thi integrity and contiguity of the allocated blocks within the huge page. \subsection{Instrumenting Block-Based Allocators with Physically Contiguous Memory} -\label{sec:org56b5427} +\label{sec:orgc5f7075} \begin{figure}[htbp] \centering \includegraphics[width=.9\linewidth]{diagram/hugepages.drawio.png} -\caption{\label{fig:org538adae}Fat-pointer Address Translations using huge pages} +\caption{\label{fig:org0063361}Fat-pointer Address Translations using huge pages} \end{figure} hierarchical structures, to translate virtual addresses to physical addresses. This approach requires multiple entries to handle various @@ -119,7 +119,7 @@ access. This approach allows for precise and efficient memory management within \end{itemize} \subsection{Implementation} -\label{sec:orgf762315} +\label{sec:orgea27970} The software stack is based on CHERIBSD, selected because ARM officially supports Morello's performance counters on this operating system. The setup includes a C program that is linked to the prototype memory allocator or to various memory allocators being benchmarked. This linkage can occur in two ways: either as a shared object file during compile time @@ -135,7 +135,7 @@ crucial for the high-performance needs of the application. \item[{$\square$}] Requires rewrite \end{itemize} \subsubsection{kernel module} -\label{sec:org94a3383} +\label{sec:org1d0969e} The custom mmap function is tailored to ensure physically contiguous memory is allocated. This allocation is a key component of this system. The custom mmap function is interfaced to the contigmem driver, which has been modified from the DPDK library . The contigmem driver is essential for managing large contiguous diff --git a/docs/FAT-Pointer/diagram/HighOverviewArchitecture.drawio.png b/docs/FAT-Pointer/diagram/HighOverviewArchitecture.drawio.png new file mode 100644 index 0000000..9baa72d Binary files /dev/null and b/docs/FAT-Pointer/diagram/HighOverviewArchitecture.drawio.png differ diff --git a/docs/FAT-Pointer/diagram/drawio/HighOverviewArchitecture-TLB.drawio b/docs/FAT-Pointer/diagram/drawio/HighOverviewArchitecture-TLB.drawio new file mode 100644 index 0000000..85b587a --- /dev/null +++ b/docs/FAT-Pointer/diagram/drawio/HighOverviewArchitecture-TLB.drawio @@ -0,0 +1,470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/FAT-Pointer/test.aux b/docs/FAT-Pointer/test.aux new file mode 100644 index 0000000..f545d70 --- /dev/null +++ b/docs/FAT-Pointer/test.aux @@ -0,0 +1,3 @@ +\relax +\@writefile{loa}{\contentsline {algorithm}{\numberline {1}{\ignorespaces Sample Memory Allocator Implementation}}{1}{}\protected@file@percent } +\gdef \@abspage@last{1} diff --git a/docs/FAT-Pointer/test.log b/docs/FAT-Pointer/test.log new file mode 100644 index 0000000..8612672 --- /dev/null +++ b/docs/FAT-Pointer/test.log @@ -0,0 +1,167 @@ +This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex 2022.8.23) 8 FEB 2025 09:22 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**test.tex +(./test.tex +LaTeX2e <2021-11-15> patch level 1 +L3 programming layer <2022-02-24> +(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls +Document Class: article 2021/10/04 v1.4n Standard LaTeX document class +(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo +File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option) +) +\c@part=\count185 +\c@section=\count186 +\c@subsection=\count187 +\c@subsubsection=\count188 +\c@paragraph=\count189 +\c@subparagraph=\count190 +\c@figure=\count191 +\c@table=\count192 +\abovecaptionskip=\skip47 +\belowcaptionskip=\skip48 +\bibindent=\dimen138 +) +(/usr/local/texlive/2022/texmf-dist/tex/latex/algorithms/algorithm.sty +Package: algorithm 2009/08/24 v0.1 Document Style `algorithm' - floating enviro +nment + +(/usr/local/texlive/2022/texmf-dist/tex/latex/float/float.sty +Package: float 2001/11/08 v1.3d Float enhancements (AL) +\c@float@type=\count193 +\float@exts=\toks16 +\float@box=\box50 +\@float@everytoks=\toks17 +\@floatcapt=\box51 +) +(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ifthen.sty +Package: ifthen 2020/11/24 v1.1c Standard LaTeX ifthen package (DPC) +) +\@float@every@algorithm=\toks18 +\c@algorithm=\count194 +) +(/usr/local/texlive/2022/texmf-dist/tex/latex/algorithmicx/algpseudocode.sty +Package: algpseudocode + +(/usr/local/texlive/2022/texmf-dist/tex/latex/algorithmicx/algorithmicx.sty +Package: algorithmicx 2005/04/27 v1.2 Algorithmicx + +Document Style algorithmicx 1.2 - a greatly improved `algorithmic' style +\c@ALG@line=\count195 +\c@ALG@rem=\count196 +\c@ALG@nested=\count197 +\ALG@tlm=\skip49 +\ALG@thistlm=\skip50 +\c@ALG@Lnr=\count198 +\c@ALG@blocknr=\count199 +\c@ALG@storecount=\count266 +\c@ALG@tmpcounter=\count267 +\ALG@tmplength=\skip51 +) +Document Style - pseudocode environments for use with the `algorithmicx' style +) (/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsmath.sty +Package: amsmath 2021/10/15 v2.17l AMS math features +\@mathmargin=\skip52 + +For additional information on amsmath, use the `?' option. +(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amstext.sty +Package: amstext 2021/08/26 v2.01 AMS text + +(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsgen.sty +File: amsgen.sty 1999/11/30 v2.0 generic functions +\@emptytoks=\toks19 +\ex@=\dimen139 +)) +(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsbsy.sty +Package: amsbsy 1999/11/29 v1.2d Bold Symbols +\pmbraise@=\dimen140 +) +(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsopn.sty +Package: amsopn 2021/08/26 v2.02 operator names +) +\inf@bad=\count268 +LaTeX Info: Redefining \frac on input line 234. +\uproot@=\count269 +\leftroot@=\count270 +LaTeX Info: Redefining \overline on input line 399. +\classnum@=\count271 +\DOTSCASE@=\count272 +LaTeX Info: Redefining \ldots on input line 496. +LaTeX Info: Redefining \dots on input line 499. +LaTeX Info: Redefining \cdots on input line 620. +\Mathstrutbox@=\box52 +\strutbox@=\box53 +\big@size=\dimen141 +LaTeX Font Info: Redeclaring font encoding OML on input line 743. +LaTeX Font Info: Redeclaring font encoding OMS on input line 744. +\macc@depth=\count273 +\c@MaxMatrixCols=\count274 +\dotsspace@=\muskip16 +\c@parentequation=\count275 +\dspbrk@lvl=\count276 +\tag@help=\toks20 +\row@=\count277 +\column@=\count278 +\maxfields@=\count279 +\andhelp@=\toks21 +\eqnshift@=\dimen142 +\alignsep@=\dimen143 +\tagshift@=\dimen144 +\tagwidth@=\dimen145 +\totwidth@=\dimen146 +\lineht@=\dimen147 +\@envbody=\toks22 +\multlinegap=\skip53 +\multlinetaggap=\skip54 +\mathdisplay@stack=\toks23 +LaTeX Info: Redefining \[ on input line 2938. +LaTeX Info: Redefining \] on input line 2939. +) +(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def +File: l3backend-pdftex.def 2022-02-07 L3 backend support: PDF output (pdfTeX) +\l__color_backend_stack_int=\count280 +\l__pdf_internal_box=\box54 +) +(./test.aux) +\openout1 = `test.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 6. +LaTeX Font Info: ... okay on input line 6. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 6. +LaTeX Font Info: ... okay on input line 6. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 6. +LaTeX Font Info: ... okay on input line 6. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 6. +LaTeX Font Info: ... okay on input line 6. +LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 6. +LaTeX Font Info: ... okay on input line 6. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 6. +LaTeX Font Info: ... okay on input line 6. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 6. +LaTeX Font Info: ... okay on input line 6. + [1 + +{/usr/local/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./test +.aux) ) +Here is how much of TeX's memory you used: + 1792 strings out of 478268 + 28162 string characters out of 5846347 + 325647 words of memory out of 5000000 + 20044 multiletter control sequences out of 15000+600000 + 470621 words of font info for 33 fonts, out of 8000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 54i,7n,62p,270b,282s stack positions out of 10000i,1000n,20000p,200000b,200000s + + +Output written on test.pdf (1 page, 71496 bytes). +PDF statistics: + 38 PDF objects out of 1000 (max. 8388607) + 22 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 1 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/docs/FAT-Pointer/test.pdf b/docs/FAT-Pointer/test.pdf new file mode 100644 index 0000000..f7c3ac2 Binary files /dev/null and b/docs/FAT-Pointer/test.pdf differ diff --git a/docs/FAT-Pointer/test.tex b/docs/FAT-Pointer/test.tex new file mode 100644 index 0000000..43d3129 --- /dev/null +++ b/docs/FAT-Pointer/test.tex @@ -0,0 +1,41 @@ +\documentclass{article} +\usepackage{algorithm} +\usepackage{algpseudocode} +\usepackage{amsmath} + +\begin{document} + +\begin{algorithm} +\caption{Sample Memory Allocator Implementation} +\begin{algorithmic}[1] +\Function{malloc}{sz} + \State $sz \gets \text{ALIGN\_UP}(sz, \text{MAX\_ALIGNMENT})$ \Comment{Align size to max alignment} + \State $\text{MallocCounter} \gets \text{MallocCounter} - sz$ \Comment{Update remaining memory} + \State $\text{ptrLink} \gets \&\text{ptr}[\text{MallocCounter}]$ \Comment{Calculate pointer address} + \State $\text{ptrLink} \gets \text{SET\_BOUNDS}(\text{ptrLink}, sz)$ \Comment{Set bounds for memory safety and to track the length of the pointer} + \State \Return $\text{ptrLink}$ \Comment{Return allocated memory pointer} +\EndFunction +\end{algorithmic} +\end{algorithm} + +\begin{algorithm} +\begin{algorithmic}[1] +\Function{free}{ptr} + \State $\text{len} \gets \text{GET\_LENGTH}(\text{ptr})$ \Comment{Get length of memory block from the defined bounds} + \State $\text{UNMAP}(\text{ptr}, \text{len})$ \Comment{Release memory block} +\EndFunction +\end{algorithmic} +\end{algorithm} + +\begin{algorithm} +\begin{algorithmic}[1] +\Function{Init\_alloc}{} + \State $\text{sz} \gets 1\ \text{GB}$ \Comment{Define pre-allocated memory size} + \State $\text{fd} \gets \text{CREATE\_LARGE\_PAGE\_MEMORY}(\text{sz})$ \Comment{Create shared memory} + \State $\text{ptr} \gets \text{MAP\_MEMORY}(\text{sz})$ \Comment{Map memory region} + \State $\text{MallocCounter} \gets \text{sz}$ \Comment{Initialize memory counter} +\EndFunction +\end{algorithmic} +\end{algorithm} + +\end{document} \ No newline at end of file