WEBVTT
Kind: captions
Language: en

00:00:00.160 --> 00:00:01.750 align:start position:0%
 
Virtual<00:00:00.560><c> memory</c><00:00:00.880><c> management</c><00:00:01.280><c> is</c><00:00:01.520><c> a</c>

00:00:01.750 --> 00:00:01.760 align:start position:0%
Virtual memory management is a
 

00:00:01.760 --> 00:00:03.990 align:start position:0%
Virtual memory management is a
fundamental<00:00:02.320><c> part</c><00:00:02.480><c> of</c><00:00:02.639><c> any</c><00:00:02.960><c> kernel.</c><00:00:03.679><c> And</c><00:00:03.840><c> in</c>

00:00:03.990 --> 00:00:04.000 align:start position:0%
fundamental part of any kernel. And in
 

00:00:04.000 --> 00:00:05.190 align:start position:0%
fundamental part of any kernel. And in
today's<00:00:04.319><c> video,</c><00:00:04.560><c> we're</c><00:00:04.720><c> going</c><00:00:04.799><c> to</c><00:00:04.960><c> explore</c>

00:00:05.190 --> 00:00:05.200 align:start position:0%
today's video, we're going to explore
 

00:00:05.200 --> 00:00:07.510 align:start position:0%
today's video, we're going to explore
the<00:00:05.440><c> inner</c><00:00:05.759><c> workings</c><00:00:06.160><c> of</c><00:00:06.319><c> how</c><00:00:06.480><c> the</c><00:00:06.720><c> iOS</c><00:00:07.120><c> kernel</c>

00:00:07.510 --> 00:00:07.520 align:start position:0%
the inner workings of how the iOS kernel
 

00:00:07.520 --> 00:00:09.430 align:start position:0%
the inner workings of how the iOS kernel
specifically<00:00:08.320><c> handles</c><00:00:08.800><c> memory</c><00:00:09.120><c> copy</c>

00:00:09.430 --> 00:00:09.440 align:start position:0%
specifically handles memory copy
 

00:00:09.440 --> 00:00:11.830 align:start position:0%
specifically handles memory copy
operations<00:00:09.920><c> at</c><00:00:10.160><c> the</c><00:00:10.320><c> low</c><00:00:10.559><c> level.</c><00:00:11.280><c> Most</c><00:00:11.599><c> of</c><00:00:11.679><c> the</c>

00:00:11.830 --> 00:00:11.840 align:start position:0%
operations at the low level. Most of the
 

00:00:11.840 --> 00:00:13.749 align:start position:0%
operations at the low level. Most of the
concepts<00:00:12.240><c> discussed</c><00:00:12.639><c> here</c><00:00:12.880><c> will</c><00:00:13.200><c> apply</c><00:00:13.519><c> to</c>

00:00:13.749 --> 00:00:13.759 align:start position:0%
concepts discussed here will apply to
 

00:00:13.759 --> 00:00:15.990 align:start position:0%
concepts discussed here will apply to
any<00:00:14.000><c> general</c><00:00:14.320><c> OS,</c><00:00:14.799><c> but</c><00:00:15.040><c> the</c><00:00:15.280><c> examples</c><00:00:15.759><c> are</c>

00:00:15.990 --> 00:00:16.000 align:start position:0%
any general OS, but the examples are
 

00:00:16.000 --> 00:00:18.470 align:start position:0%
any general OS, but the examples are
taken<00:00:16.640><c> from</c><00:00:16.800><c> an</c><00:00:17.039><c> iPhone</c><00:00:17.440><c> running</c><00:00:17.760><c> the</c><00:00:17.840><c> XNU</c>

00:00:18.470 --> 00:00:18.480 align:start position:0%
taken from an iPhone running the XNU
 

00:00:18.480 --> 00:00:20.790 align:start position:0%
taken from an iPhone running the XNU
kernel.<00:00:19.199><c> Copying</c><00:00:19.680><c> memory</c><00:00:19.920><c> from</c><00:00:20.160><c> one</c><00:00:20.400><c> place</c><00:00:20.640><c> to</c>

00:00:20.790 --> 00:00:20.800 align:start position:0%
kernel. Copying memory from one place to
 

00:00:20.800 --> 00:00:23.189 align:start position:0%
kernel. Copying memory from one place to
another<00:00:21.199><c> is</c><00:00:21.439><c> of</c><00:00:21.600><c> course</c><00:00:21.760><c> a</c><00:00:22.000><c> very</c><00:00:22.320><c> common</c><00:00:22.640><c> task</c>

00:00:23.189 --> 00:00:23.199 align:start position:0%
another is of course a very common task
 

00:00:23.199 --> 00:00:25.750 align:start position:0%
another is of course a very common task
performed<00:00:23.680><c> by</c><00:00:24.000><c> processes.</c><00:00:24.880><c> And</c><00:00:25.039><c> for</c><00:00:25.279><c> trivial</c>

00:00:25.750 --> 00:00:25.760 align:start position:0%
performed by processes. And for trivial
 

00:00:25.760 --> 00:00:28.070 align:start position:0%
performed by processes. And for trivial
memory<00:00:26.000><c> copy</c><00:00:26.320><c> operations,</c><00:00:27.279><c> most</c><00:00:27.519><c> processes</c>

00:00:28.070 --> 00:00:28.080 align:start position:0%
memory copy operations, most processes
 

00:00:28.080 --> 00:00:30.150 align:start position:0%
memory copy operations, most processes
will<00:00:28.400><c> call</c><00:00:28.640><c> into</c><00:00:28.960><c> a</c><00:00:29.199><c> user</c><00:00:29.599><c> space</c><00:00:29.840><c> shared</c>

00:00:30.150 --> 00:00:30.160 align:start position:0%
will call into a user space shared
 

00:00:30.160 --> 00:00:32.549 align:start position:0%
will call into a user space shared
function<00:00:30.640><c> like</c><00:00:30.960><c> memcopy.</c><00:00:31.920><c> A</c><00:00:32.079><c> function</c><00:00:32.320><c> like</c>

00:00:32.549 --> 00:00:32.559 align:start position:0%
function like memcopy. A function like
 

00:00:32.559 --> 00:00:34.870 align:start position:0%
function like memcopy. A function like
memcopy<00:00:33.200><c> simply</c><00:00:33.600><c> iterates</c><00:00:34.160><c> over</c><00:00:34.320><c> the</c><00:00:34.559><c> bytes</c>

00:00:34.870 --> 00:00:34.880 align:start position:0%
memcopy simply iterates over the bytes
 

00:00:34.880 --> 00:00:37.190 align:start position:0%
memcopy simply iterates over the bytes
in<00:00:35.120><c> a</c><00:00:35.280><c> source</c><00:00:35.600><c> buffer</c><00:00:36.160><c> and</c><00:00:36.399><c> writes</c><00:00:36.800><c> them</c><00:00:37.040><c> one</c>

00:00:37.190 --> 00:00:37.200 align:start position:0%
in a source buffer and writes them one
 

00:00:37.200 --> 00:00:39.270 align:start position:0%
in a source buffer and writes them one
by<00:00:37.440><c> one</c><00:00:37.600><c> into</c><00:00:37.840><c> a</c><00:00:38.079><c> destination</c><00:00:38.559><c> buffer.</c><00:00:39.120><c> This</c>

00:00:39.270 --> 00:00:39.280 align:start position:0%
by one into a destination buffer. This
 

00:00:39.280 --> 00:00:40.790 align:start position:0%
by one into a destination buffer. This
is<00:00:39.440><c> obviously</c><00:00:39.680><c> not</c><00:00:39.920><c> very</c><00:00:40.239><c> interesting</c><00:00:40.559><c> or</c>

00:00:40.790 --> 00:00:40.800 align:start position:0%
is obviously not very interesting or
 

00:00:40.800 --> 00:00:42.470 align:start position:0%
is obviously not very interesting or
impressive.<00:00:41.520><c> What's</c><00:00:41.840><c> more</c><00:00:42.079><c> interesting,</c>

00:00:42.470 --> 00:00:42.480 align:start position:0%
impressive. What's more interesting,
 

00:00:42.480 --> 00:00:43.990 align:start position:0%
impressive. What's more interesting,
however,<00:00:42.800><c> is</c><00:00:42.960><c> a</c><00:00:43.200><c> different</c><00:00:43.520><c> method</c><00:00:43.760><c> of</c>

00:00:43.990 --> 00:00:44.000 align:start position:0%
however, is a different method of
 

00:00:44.000 --> 00:00:46.229 align:start position:0%
however, is a different method of
copying<00:00:44.480><c> memory</c><00:00:44.960><c> facilitated</c><00:00:45.680><c> directly</c><00:00:46.000><c> by</c>

00:00:46.229 --> 00:00:46.239 align:start position:0%
copying memory facilitated directly by
 

00:00:46.239 --> 00:00:48.150 align:start position:0%
copying memory facilitated directly by
the<00:00:46.399><c> kernel's</c><00:00:46.800><c> virtual</c><00:00:47.120><c> memory</c><00:00:47.360><c> subsystem.</c>

00:00:48.150 --> 00:00:48.160 align:start position:0%
the kernel's virtual memory subsystem.
 

00:00:48.160 --> 00:00:50.069 align:start position:0%
the kernel's virtual memory subsystem.
Imagine<00:00:48.480><c> we</c><00:00:48.640><c> want</c><00:00:48.719><c> to</c><00:00:48.879><c> copy</c><00:00:49.120><c> a</c><00:00:49.360><c> buffer</c><00:00:49.760><c> of</c><00:00:49.920><c> a</c>

00:00:50.069 --> 00:00:50.079 align:start position:0%
Imagine we want to copy a buffer of a
 

00:00:50.079 --> 00:00:52.229 align:start position:0%
Imagine we want to copy a buffer of a
really<00:00:50.399><c> large</c><00:00:50.800><c> size</c><00:00:51.200><c> from</c><00:00:51.440><c> one</c><00:00:51.680><c> place</c><00:00:52.000><c> to</c>

00:00:52.229 --> 00:00:52.239 align:start position:0%
really large size from one place to
 

00:00:52.239 --> 00:00:54.389 align:start position:0%
really large size from one place to
another.<00:00:52.960><c> execution</c><00:00:53.520><c> time</c><00:00:53.760><c> is</c><00:00:54.000><c> going</c><00:00:54.079><c> to</c><00:00:54.239><c> take</c>

00:00:54.389 --> 00:00:54.399 align:start position:0%
another. execution time is going to take
 

00:00:54.399 --> 00:00:56.950 align:start position:0%
another. execution time is going to take
a<00:00:54.640><c> significant</c><00:00:55.199><c> hit</c><00:00:55.440><c> if</c><00:00:55.760><c> we</c><00:00:56.079><c> utilize</c><00:00:56.640><c> a</c>

00:00:56.950 --> 00:00:56.960 align:start position:0%
a significant hit if we utilize a
 

00:00:56.960 --> 00:00:59.029 align:start position:0%
a significant hit if we utilize a
function<00:00:57.280><c> like</c><00:00:57.520><c> memcopy</c><00:00:58.320><c> because</c><00:00:58.559><c> we</c><00:00:58.800><c> have</c><00:00:58.879><c> to</c>

00:00:59.029 --> 00:00:59.039 align:start position:0%
function like memcopy because we have to
 

00:00:59.039 --> 00:01:01.189 align:start position:0%
function like memcopy because we have to
iterate<00:00:59.440><c> as</c><00:00:59.680><c> many</c><00:00:59.920><c> times</c><00:01:00.239><c> as</c><00:01:00.480><c> there</c><00:01:00.640><c> are</c><00:01:00.879><c> bytes</c>

00:01:01.189 --> 00:01:01.199 align:start position:0%
iterate as many times as there are bytes
 

00:01:01.199 --> 00:01:03.349 align:start position:0%
iterate as many times as there are bytes
in<00:01:01.359><c> the</c><00:01:01.520><c> buffer.</c><00:01:02.239><c> This</c><00:01:02.399><c> is</c><00:01:02.559><c> very</c><00:01:02.800><c> slow</c><00:01:03.120><c> when</c>

00:01:03.349 --> 00:01:03.359 align:start position:0%
in the buffer. This is very slow when
 

00:01:03.359 --> 00:01:05.590 align:start position:0%
in the buffer. This is very slow when
copying<00:01:03.840><c> large</c><00:01:04.080><c> amounts</c><00:01:04.400><c> of</c><00:01:04.640><c> data.</c><00:01:05.199><c> In</c><00:01:05.439><c> these</c>

00:01:05.590 --> 00:01:05.600 align:start position:0%
copying large amounts of data. In these
 

00:01:05.600 --> 00:01:07.429 align:start position:0%
copying large amounts of data. In these
cases,<00:01:06.080><c> instead</c><00:01:06.400><c> of</c><00:01:06.560><c> calling</c><00:01:06.960><c> this</c><00:01:07.119><c> user</c>

00:01:07.429 --> 00:01:07.439 align:start position:0%
cases, instead of calling this user
 

00:01:07.439 --> 00:01:09.750 align:start position:0%
cases, instead of calling this user
space<00:01:07.680><c> function,</c><00:01:08.320><c> we</c><00:01:08.560><c> can</c><00:01:08.720><c> instead</c><00:01:09.119><c> interact</c>

00:01:09.750 --> 00:01:09.760 align:start position:0%
space function, we can instead interact
 

00:01:09.760 --> 00:01:11.910 align:start position:0%
space function, we can instead interact
directly<00:01:10.159><c> with</c><00:01:10.240><c> the</c><00:01:10.400><c> kernel's</c><00:01:10.799><c> VM</c><00:01:11.200><c> subsystem</c>

00:01:11.910 --> 00:01:11.920 align:start position:0%
directly with the kernel's VM subsystem
 

00:01:11.920 --> 00:01:13.830 align:start position:0%
directly with the kernel's VM subsystem
for<00:01:12.159><c> a</c><00:01:12.400><c> much</c><00:01:12.640><c> more</c><00:01:12.799><c> timeefficient</c><00:01:13.520><c> copy</c>

00:01:13.830 --> 00:01:13.840 align:start position:0%
for a much more timeefficient copy
 

00:01:13.840 --> 00:01:15.670 align:start position:0%
for a much more timeefficient copy
mechanism.<00:01:14.720><c> Virtual</c><00:01:15.040><c> memory</c><00:01:15.360><c> is</c><00:01:15.520><c> the</c>

00:01:15.670 --> 00:01:15.680 align:start position:0%
mechanism. Virtual memory is the
 

00:01:15.680 --> 00:01:17.350 align:start position:0%
mechanism. Virtual memory is the
abstraction<00:01:16.320><c> layer</c><00:01:16.479><c> that</c><00:01:16.640><c> gives</c><00:01:16.880><c> processes</c>

00:01:17.350 --> 00:01:17.360 align:start position:0%
abstraction layer that gives processes
 

00:01:17.360 --> 00:01:19.270 align:start position:0%
abstraction layer that gives processes
the<00:01:17.759><c> illusion</c><00:01:18.080><c> of</c><00:01:18.320><c> having</c><00:01:18.640><c> a</c><00:01:18.960><c> large</c>

00:01:19.270 --> 00:01:19.280 align:start position:0%
the illusion of having a large
 

00:01:19.280 --> 00:01:21.109 align:start position:0%
the illusion of having a large
contiguous<00:01:19.840><c> block</c><00:01:20.000><c> of</c><00:01:20.159><c> memory</c><00:01:20.479><c> to</c><00:01:20.640><c> work</c><00:01:20.799><c> with.</c>

00:01:21.109 --> 00:01:21.119 align:start position:0%
contiguous block of memory to work with.
 

00:01:21.119 --> 00:01:23.030 align:start position:0%
contiguous block of memory to work with.
And<00:01:21.280><c> this</c><00:01:21.520><c> is</c><00:01:21.600><c> facilitated</c><00:01:22.320><c> partly</c><00:01:22.799><c> by</c>

00:01:23.030 --> 00:01:23.040 align:start position:0%
And this is facilitated partly by
 

00:01:23.040 --> 00:01:25.270 align:start position:0%
And this is facilitated partly by
hardware<00:01:23.680><c> in</c><00:01:23.920><c> the</c><00:01:24.080><c> MMU.</c><00:01:24.720><c> For</c><00:01:24.960><c> this</c><00:01:25.040><c> video,</c>

00:01:25.270 --> 00:01:25.280 align:start position:0%
hardware in the MMU. For this video,
 

00:01:25.280 --> 00:01:27.030 align:start position:0%
hardware in the MMU. For this video,
we're<00:01:25.520><c> mostly</c><00:01:25.840><c> interested</c><00:01:26.240><c> in</c><00:01:26.400><c> the</c><00:01:26.560><c> kernel's</c>

00:01:27.030 --> 00:01:27.040 align:start position:0%
we're mostly interested in the kernel's
 

00:01:27.040 --> 00:01:29.270 align:start position:0%
we're mostly interested in the kernel's
virtual<00:01:27.360><c> memory</c><00:01:27.600><c> management</c><00:01:28.080><c> code.</c><00:01:28.799><c> So</c><00:01:29.040><c> a</c>

00:01:29.270 --> 00:01:29.280 align:start position:0%
virtual memory management code. So a
 

00:01:29.280 --> 00:01:31.109 align:start position:0%
virtual memory management code. So a
deep<00:01:29.600><c> understanding</c><00:01:30.159><c> of</c><00:01:30.400><c> this</c><00:01:30.720><c> hardware</c>

00:01:31.109 --> 00:01:31.119 align:start position:0%
deep understanding of this hardware
 

00:01:31.119 --> 00:01:33.830 align:start position:0%
deep understanding of this hardware
translation<00:01:31.759><c> process</c><00:01:32.320><c> is</c><00:01:32.560><c> not</c><00:01:32.880><c> essential.</c>

00:01:33.830 --> 00:01:33.840 align:start position:0%
translation process is not essential.
 

00:01:33.840 --> 00:01:35.510 align:start position:0%
translation process is not essential.
However,<00:01:34.159><c> for</c><00:01:34.320><c> the</c><00:01:34.560><c> interested</c><00:01:34.960><c> viewer,</c><00:01:35.280><c> here</c>

00:01:35.510 --> 00:01:35.520 align:start position:0%
However, for the interested viewer, here
 

00:01:35.520 --> 00:01:37.670 align:start position:0%
However, for the interested viewer, here
is<00:01:35.680><c> a</c><00:01:35.920><c> brief</c><00:01:36.240><c> overview</c><00:01:36.560><c> of</c><00:01:36.720><c> how</c><00:01:36.880><c> it</c><00:01:37.040><c> works.</c>

00:01:37.670 --> 00:01:37.680 align:start position:0%
is a brief overview of how it works.
 

00:01:37.680 --> 00:01:39.270 align:start position:0%
is a brief overview of how it works.
Translation<00:01:38.240><c> tables</c><00:01:38.640><c> describing</c><00:01:39.040><c> the</c>

00:01:39.270 --> 00:01:39.280 align:start position:0%
Translation tables describing the
 

00:01:39.280 --> 00:01:40.789 align:start position:0%
Translation tables describing the
virtual<00:01:39.600><c> memory</c><00:01:40.000><c> layout</c><00:01:40.159><c> for</c><00:01:40.320><c> a</c><00:01:40.560><c> given</c>

00:01:40.789 --> 00:01:40.799 align:start position:0%
virtual memory layout for a given
 

00:01:40.799 --> 00:01:43.270 align:start position:0%
virtual memory layout for a given
process<00:01:41.520><c> can</c><00:01:41.759><c> be</c><00:01:41.920><c> set</c><00:01:42.079><c> up</c><00:01:42.320><c> ahead</c><00:01:42.560><c> of</c><00:01:42.720><c> time</c><00:01:42.960><c> in</c>

00:01:43.270 --> 00:01:43.280 align:start position:0%
process can be set up ahead of time in
 

00:01:43.280 --> 00:01:45.510 align:start position:0%
process can be set up ahead of time in
physical<00:01:43.600><c> memory.</c><00:01:44.320><c> And</c><00:01:44.479><c> then</c><00:01:44.640><c> when</c><00:01:44.799><c> the</c><00:01:44.960><c> MMU</c>

00:01:45.510 --> 00:01:45.520 align:start position:0%
physical memory. And then when the MMU
 

00:01:45.520 --> 00:01:47.510 align:start position:0%
physical memory. And then when the MMU
is<00:01:45.680><c> enabled</c><00:01:46.159><c> and</c><00:01:46.399><c> the</c><00:01:46.560><c> process</c><00:01:46.960><c> tries</c><00:01:47.280><c> to</c>

00:01:47.510 --> 00:01:47.520 align:start position:0%
is enabled and the process tries to
 

00:01:47.520 --> 00:01:50.149 align:start position:0%
is enabled and the process tries to
dreference<00:01:48.159><c> an</c><00:01:48.399><c> address,</c><00:01:49.360><c> some</c><00:01:49.680><c> hardware</c>

00:01:50.149 --> 00:01:50.159 align:start position:0%
dreference an address, some hardware
 

00:01:50.159 --> 00:01:52.710 align:start position:0%
dreference an address, some hardware
magic<00:01:50.640><c> allows</c><00:01:51.040><c> a</c><00:01:51.280><c> virtual</c><00:01:51.680><c> pointer</c><00:01:52.320><c> to</c><00:01:52.560><c> be</c>

00:01:52.710 --> 00:01:52.720 align:start position:0%
magic allows a virtual pointer to be
 

00:01:52.720 --> 00:01:54.710 align:start position:0%
magic allows a virtual pointer to be
resolved<00:01:53.200><c> to</c><00:01:53.439><c> its</c><00:01:53.759><c> corresponding</c><00:01:54.399><c> physical</c>

00:01:54.710 --> 00:01:54.720 align:start position:0%
resolved to its corresponding physical
 

00:01:54.720 --> 00:01:57.350 align:start position:0%
resolved to its corresponding physical
address<00:01:55.520><c> by</c><00:01:55.840><c> walking</c><00:01:56.240><c> down</c><00:01:56.479><c> this</c><00:01:56.720><c> page</c><00:01:57.119><c> table</c>

00:01:57.350 --> 00:01:57.360 align:start position:0%
address by walking down this page table
 

00:01:57.360 --> 00:01:59.590 align:start position:0%
address by walking down this page table
structure<00:01:58.079><c> to</c><00:01:58.320><c> locate</c><00:01:58.719><c> the</c><00:01:59.040><c> underlying</c>

00:01:59.590 --> 00:01:59.600 align:start position:0%
structure to locate the underlying
 

00:01:59.600 --> 00:02:02.069 align:start position:0%
structure to locate the underlying
physical<00:02:00.000><c> page.</c><00:02:00.640><c> For</c><00:02:00.799><c> example,</c><00:02:01.360><c> dreferencing</c>

00:02:02.069 --> 00:02:02.079 align:start position:0%
physical page. For example, dreferencing
 

00:02:02.079 --> 00:02:04.149 align:start position:0%
physical page. For example, dreferencing
a<00:02:02.320><c> user</c><00:02:02.719><c> space</c><00:02:02.960><c> address</c><00:02:03.360><c> would</c><00:02:03.600><c> go</c><00:02:03.840><c> something</c>

00:02:04.149 --> 00:02:04.159 align:start position:0%
a user space address would go something
 

00:02:04.159 --> 00:02:06.789 align:start position:0%
a user space address would go something
like<00:02:04.399><c> this.</c><00:02:05.040><c> We'd</c><00:02:05.360><c> begin</c><00:02:05.600><c> at</c><00:02:05.840><c> the</c><00:02:06.159><c> translation</c>

00:02:06.789 --> 00:02:06.799 align:start position:0%
like this. We'd begin at the translation
 

00:02:06.799 --> 00:02:08.869 align:start position:0%
like this. We'd begin at the translation
table<00:02:07.119><c> base,</c><00:02:07.680><c> which</c><00:02:07.920><c> would</c><00:02:08.080><c> be</c><00:02:08.239><c> stored</c><00:02:08.560><c> in</c><00:02:08.720><c> a</c>

00:02:08.869 --> 00:02:08.879 align:start position:0%
table base, which would be stored in a
 

00:02:08.879 --> 00:02:10.869 align:start position:0%
table base, which would be stored in a
dedicated<00:02:09.360><c> hardware</c><00:02:09.840><c> register,</c><00:02:10.640><c> the</c>

00:02:10.869 --> 00:02:10.879 align:start position:0%
dedicated hardware register, the
 

00:02:10.879 --> 00:02:13.430 align:start position:0%
dedicated hardware register, the
translation<00:02:11.440><c> table</c><00:02:11.840><c> base</c><00:02:12.080><c> register</c><00:02:12.560><c> zero.</c>

00:02:13.430 --> 00:02:13.440 align:start position:0%
translation table base register zero.
 

00:02:13.440 --> 00:02:15.270 align:start position:0%
translation table base register zero.
There's<00:02:13.760><c> also</c><00:02:13.920><c> an</c><00:02:14.160><c> EL1</c><00:02:14.720><c> version</c><00:02:14.959><c> of</c><00:02:15.040><c> this</c>

00:02:15.270 --> 00:02:15.280 align:start position:0%
There's also an EL1 version of this
 

00:02:15.280 --> 00:02:16.869 align:start position:0%
There's also an EL1 version of this
register<00:02:15.599><c> for</c><00:02:15.760><c> the</c><00:02:15.920><c> kernel's</c><00:02:16.319><c> own</c><00:02:16.560><c> address</c>

00:02:16.869 --> 00:02:16.879 align:start position:0%
register for the kernel's own address
 

00:02:16.879 --> 00:02:18.949 align:start position:0%
register for the kernel's own address
translation.<00:02:17.840><c> This</c><00:02:18.000><c> register</c><00:02:18.480><c> holds</c><00:02:18.800><c> the</c>

00:02:18.949 --> 00:02:18.959 align:start position:0%
translation. This register holds the
 

00:02:18.959 --> 00:02:20.869 align:start position:0%
translation. This register holds the
physical<00:02:19.360><c> address</c><00:02:19.760><c> of</c><00:02:20.000><c> the</c><00:02:20.239><c> level</c><00:02:20.560><c> one</c>

00:02:20.869 --> 00:02:20.879 align:start position:0%
physical address of the level one
 

00:02:20.879 --> 00:02:22.790 align:start position:0%
physical address of the level one
translation<00:02:21.440><c> table</c><00:02:22.000><c> for</c><00:02:22.239><c> the</c><00:02:22.480><c> currently</c>

00:02:22.790 --> 00:02:22.800 align:start position:0%
translation table for the currently
 

00:02:22.800 --> 00:02:24.550 align:start position:0%
translation table for the currently
executing<00:02:23.360><c> process.</c><00:02:23.920><c> To</c><00:02:24.160><c> perform</c><00:02:24.400><c> the</c>

00:02:24.550 --> 00:02:24.560 align:start position:0%
executing process. To perform the
 

00:02:24.560 --> 00:02:26.390 align:start position:0%
executing process. To perform the
translation,<00:02:25.120><c> we</c><00:02:25.360><c> take</c><00:02:25.520><c> the</c><00:02:25.760><c> virtual</c><00:02:26.160><c> address</c>

00:02:26.390 --> 00:02:26.400 align:start position:0%
translation, we take the virtual address
 

00:02:26.400 --> 00:02:28.630 align:start position:0%
translation, we take the virtual address
that<00:02:26.560><c> we</c><00:02:26.800><c> de</c><00:02:27.040><c> referencing</c><00:02:27.760><c> and</c><00:02:28.000><c> we</c><00:02:28.239><c> split</c><00:02:28.560><c> it</c>

00:02:28.630 --> 00:02:28.640 align:start position:0%
that we de referencing and we split it
 

00:02:28.640 --> 00:02:31.110 align:start position:0%
that we de referencing and we split it
up<00:02:28.800><c> into</c><00:02:29.120><c> the</c><00:02:29.280><c> following</c><00:02:29.599><c> components.</c>

00:02:31.110 --> 00:02:31.120 align:start position:0%
up into the following components.
 

00:02:31.120 --> 00:02:33.190 align:start position:0%
up into the following components.
This<00:02:31.360><c> first</c><00:02:31.680><c> section</c><00:02:32.000><c> here</c><00:02:32.319><c> consisting</c><00:02:32.879><c> of</c>

00:02:33.190 --> 00:02:33.200 align:start position:0%
This first section here consisting of
 

00:02:33.200 --> 00:02:35.990 align:start position:0%
This first section here consisting of
nine<00:02:33.519><c> bits</c><00:02:33.920><c> is</c><00:02:34.239><c> used</c><00:02:34.400><c> as</c><00:02:34.640><c> an</c><00:02:34.800><c> index</c><00:02:35.440><c> into</c><00:02:35.760><c> this</c>

00:02:35.990 --> 00:02:36.000 align:start position:0%
nine bits is used as an index into this
 

00:02:36.000 --> 00:02:38.390 align:start position:0%
nine bits is used as an index into this
level<00:02:36.319><c> one</c><00:02:36.480><c> translation</c><00:02:37.040><c> table.</c><00:02:37.840><c> And</c><00:02:38.000><c> at</c><00:02:38.239><c> the</c>

00:02:38.390 --> 00:02:38.400 align:start position:0%
level one translation table. And at the
 

00:02:38.400 --> 00:02:40.550 align:start position:0%
level one translation table. And at the
index<00:02:38.800><c> in</c><00:02:39.040><c> that</c><00:02:39.200><c> table,</c><00:02:39.760><c> we</c><00:02:40.000><c> find</c><00:02:40.239><c> another</c>

00:02:40.550 --> 00:02:40.560 align:start position:0%
index in that table, we find another
 

00:02:40.560 --> 00:02:42.949 align:start position:0%
index in that table, we find another
physical<00:02:40.959><c> address.</c><00:02:42.000><c> This</c><00:02:42.239><c> physical</c><00:02:42.560><c> address</c>

00:02:42.949 --> 00:02:42.959 align:start position:0%
physical address. This physical address
 

00:02:42.959 --> 00:02:45.270 align:start position:0%
physical address. This physical address
points<00:02:43.200><c> to</c><00:02:43.360><c> the</c><00:02:43.599><c> level</c><00:02:43.840><c> two</c><00:02:44.080><c> page</c><00:02:44.319><c> table.</c><00:02:45.120><c> We</c>

00:02:45.270 --> 00:02:45.280 align:start position:0%
points to the level two page table. We
 

00:02:45.280 --> 00:02:47.430 align:start position:0%
points to the level two page table. We
rinse<00:02:45.599><c> and</c><00:02:45.760><c> repeat</c><00:02:46.080><c> until</c><00:02:46.480><c> we</c><00:02:46.640><c> reach</c><00:02:46.879><c> a</c><00:02:47.120><c> page</c>

00:02:47.430 --> 00:02:47.440 align:start position:0%
rinse and repeat until we reach a page
 

00:02:47.440 --> 00:02:49.589 align:start position:0%
rinse and repeat until we reach a page
table<00:02:47.760><c> entry</c><00:02:48.319><c> pointed</c><00:02:48.720><c> to</c><00:02:48.879><c> by</c><00:02:49.040><c> the</c><00:02:49.280><c> level</c>

00:02:49.589 --> 00:02:49.599 align:start position:0%
table entry pointed to by the level
 

00:02:49.599 --> 00:02:51.509 align:start position:0%
table entry pointed to by the level
three<00:02:49.760><c> page</c><00:02:50.080><c> table.</c><00:02:50.720><c> This</c><00:02:50.959><c> gives</c><00:02:51.120><c> us</c><00:02:51.280><c> the</c>

00:02:51.509 --> 00:02:51.519 align:start position:0%
three page table. This gives us the
 

00:02:51.519 --> 00:02:54.070 align:start position:0%
three page table. This gives us the
underlying<00:02:52.160><c> physical</c><00:02:52.560><c> page</c><00:02:52.800><c> address.</c><00:02:53.840><c> The</c>

00:02:54.070 --> 00:02:54.080 align:start position:0%
underlying physical page address. The
 

00:02:54.080 --> 00:02:55.589 align:start position:0%
underlying physical page address. The
least<00:02:54.319><c> significant</c><00:02:54.720><c> bits</c><00:02:55.040><c> here</c><00:02:55.360><c> don't</c>

00:02:55.589 --> 00:02:55.599 align:start position:0%
least significant bits here don't
 

00:02:55.599 --> 00:02:57.670 align:start position:0%
least significant bits here don't
actually<00:02:55.840><c> require</c><00:02:56.239><c> any</c><00:02:56.560><c> translation</c><00:02:57.200><c> because</c>

00:02:57.670 --> 00:02:57.680 align:start position:0%
actually require any translation because
 

00:02:57.680 --> 00:03:00.070 align:start position:0%
actually require any translation because
anything<00:02:58.080><c> less</c><00:02:58.319><c> than</c><00:02:58.480><c> the</c><00:02:58.640><c> page</c><00:02:58.879><c> size</c><00:02:59.360><c> of</c><00:02:59.680><c> hex</c>

00:03:00.070 --> 00:03:00.080 align:start position:0%
anything less than the page size of hex
 

00:03:00.080 --> 00:03:02.470 align:start position:0%
anything less than the page size of hex
4,000<00:03:00.640><c> in</c><00:03:00.800><c> this</c><00:03:00.959><c> case</c><00:03:01.440><c> will</c><00:03:01.680><c> be</c><00:03:01.840><c> the</c><00:03:02.080><c> same</c>

00:03:02.470 --> 00:03:02.480 align:start position:0%
4,000 in this case will be the same
 

00:03:02.480 --> 00:03:03.750 align:start position:0%
4,000 in this case will be the same
whether<00:03:02.720><c> or</c><00:03:02.959><c> not</c><00:03:03.040><c> we're</c><00:03:03.280><c> looking</c><00:03:03.440><c> at</c><00:03:03.599><c> a</c>

00:03:03.750 --> 00:03:03.760 align:start position:0%
whether or not we're looking at a
 

00:03:03.760 --> 00:03:06.149 align:start position:0%
whether or not we're looking at a
virtual<00:03:04.159><c> or</c><00:03:04.319><c> physical</c><00:03:04.720><c> page.</c><00:03:05.760><c> Process</c>

00:03:06.149 --> 00:03:06.159 align:start position:0%
virtual or physical page. Process
 

00:03:06.159 --> 00:03:08.390 align:start position:0%
virtual or physical page. Process
address<00:03:06.560><c> spaces</c><00:03:06.959><c> are</c><00:03:07.200><c> constructed</c><00:03:07.760><c> by</c><00:03:08.080><c> having</c>

00:03:08.390 --> 00:03:08.400 align:start position:0%
address spaces are constructed by having
 

00:03:08.400 --> 00:03:10.550 align:start position:0%
address spaces are constructed by having
this<00:03:08.640><c> leveled</c><00:03:09.040><c> page</c><00:03:09.360><c> table</c><00:03:09.680><c> system</c><00:03:10.080><c> set</c><00:03:10.319><c> up</c><00:03:10.400><c> in</c>

00:03:10.550 --> 00:03:10.560 align:start position:0%
this leveled page table system set up in
 

00:03:10.560 --> 00:03:12.470 align:start position:0%
this leveled page table system set up in
the<00:03:10.640><c> kernel's</c><00:03:11.120><c> memory</c><00:03:11.599><c> describing</c><00:03:12.239><c> which</c>

00:03:12.470 --> 00:03:12.480 align:start position:0%
the kernel's memory describing which
 

00:03:12.480 --> 00:03:14.309 align:start position:0%
the kernel's memory describing which
virtual<00:03:12.879><c> pages</c><00:03:13.360><c> point</c><00:03:13.599><c> to</c><00:03:13.760><c> which</c><00:03:14.000><c> physical</c>

00:03:14.309 --> 00:03:14.319 align:start position:0%
virtual pages point to which physical
 

00:03:14.319 --> 00:03:17.110 align:start position:0%
virtual pages point to which physical
pages.<00:03:15.280><c> And</c><00:03:15.440><c> the</c><00:03:15.680><c> isolation</c><00:03:16.319><c> of</c><00:03:16.720><c> process</c>

00:03:17.110 --> 00:03:17.120 align:start position:0%
pages. And the isolation of process
 

00:03:17.120 --> 00:03:18.790 align:start position:0%
pages. And the isolation of process
address<00:03:17.440><c> spaces</c><00:03:17.920><c> also</c><00:03:18.159><c> comes</c><00:03:18.480><c> from</c><00:03:18.640><c> this</c>

00:03:18.790 --> 00:03:18.800 align:start position:0%
address spaces also comes from this
 

00:03:18.800 --> 00:03:21.030 align:start position:0%
address spaces also comes from this
mechanism<00:03:19.599><c> because</c><00:03:19.840><c> in</c><00:03:20.080><c> a</c><00:03:20.319><c> context</c><00:03:20.720><c> switch</c>

00:03:21.030 --> 00:03:21.040 align:start position:0%
mechanism because in a context switch
 

00:03:21.040 --> 00:03:23.110 align:start position:0%
mechanism because in a context switch
from<00:03:21.280><c> one</c><00:03:21.440><c> process</c><00:03:21.760><c> to</c><00:03:22.000><c> another,</c><00:03:22.640><c> the</c><00:03:22.879><c> value</c>

00:03:23.110 --> 00:03:23.120 align:start position:0%
from one process to another, the value
 

00:03:23.120 --> 00:03:25.430 align:start position:0%
from one process to another, the value
of<00:03:23.280><c> the</c><00:03:23.440><c> base</c><00:03:23.760><c> register</c><00:03:24.400><c> is</c><00:03:24.640><c> swapped</c><00:03:25.040><c> out</c><00:03:25.200><c> to</c>

00:03:25.430 --> 00:03:25.440 align:start position:0%
of the base register is swapped out to
 

00:03:25.440 --> 00:03:27.190 align:start position:0%
of the base register is swapped out to
point<00:03:25.680><c> to</c><00:03:25.760><c> the</c><00:03:25.920><c> root</c><00:03:26.159><c> of</c><00:03:26.239><c> the</c><00:03:26.400><c> page</c><00:03:26.720><c> table</c><00:03:26.959><c> for</c>

00:03:27.190 --> 00:03:27.200 align:start position:0%
point to the root of the page table for
 

00:03:27.200 --> 00:03:29.030 align:start position:0%
point to the root of the page table for
the<00:03:27.360><c> other</c><00:03:27.599><c> process.</c><00:03:28.400><c> This</c><00:03:28.560><c> means</c><00:03:28.800><c> that</c>

00:03:29.030 --> 00:03:29.040 align:start position:0%
the other process. This means that
 

00:03:29.040 --> 00:03:30.789 align:start position:0%
the other process. This means that
different<00:03:29.360><c> processes</c><00:03:29.920><c> can</c><00:03:30.080><c> never</c><00:03:30.400><c> read</c><00:03:30.560><c> or</c>

00:03:30.789 --> 00:03:30.799 align:start position:0%
different processes can never read or
 

00:03:30.799 --> 00:03:32.789 align:start position:0%
different processes can never read or
write<00:03:31.040><c> each</c><00:03:31.280><c> other's</c><00:03:31.519><c> memory</c><00:03:31.840><c> directly.</c><00:03:32.560><c> This</c>

00:03:32.789 --> 00:03:32.799 align:start position:0%
write each other's memory directly. This
 

00:03:32.799 --> 00:03:34.390 align:start position:0%
write each other's memory directly. This
is<00:03:32.959><c> also</c><00:03:33.200><c> cool</c><00:03:33.440><c> because</c><00:03:33.680><c> different</c><00:03:34.080><c> page</c>

00:03:34.390 --> 00:03:34.400 align:start position:0%
is also cool because different page
 

00:03:34.400 --> 00:03:36.630 align:start position:0%
is also cool because different page
tables<00:03:34.799><c> for</c><00:03:35.120><c> different</c><00:03:35.360><c> processes</c><00:03:36.319><c> can</c>

00:03:36.630 --> 00:03:36.640 align:start position:0%
tables for different processes can
 

00:03:36.640 --> 00:03:38.789 align:start position:0%
tables for different processes can
reference<00:03:37.040><c> the</c><00:03:37.280><c> same</c><00:03:37.519><c> physical</c><00:03:37.920><c> page</c><00:03:38.319><c> for</c><00:03:38.560><c> a</c>

00:03:38.789 --> 00:03:38.799 align:start position:0%
reference the same physical page for a
 

00:03:38.799 --> 00:03:41.190 align:start position:0%
reference the same physical page for a
given<00:03:39.040><c> virtual</c><00:03:39.440><c> page</c><00:03:39.760><c> if</c><00:03:40.000><c> they</c><00:03:40.159><c> so</c><00:03:40.400><c> choose.</c>

00:03:41.190 --> 00:03:41.200 align:start position:0%
given virtual page if they so choose.
 

00:03:41.200 --> 00:03:43.030 align:start position:0%
given virtual page if they so choose.
And<00:03:41.440><c> this</c><00:03:41.680><c> is</c><00:03:41.840><c> how</c><00:03:42.080><c> shared</c><00:03:42.480><c> memory</c><00:03:42.720><c> can</c><00:03:42.879><c> be</c>

00:03:43.030 --> 00:03:43.040 align:start position:0%
And this is how shared memory can be
 

00:03:43.040 --> 00:03:45.190 align:start position:0%
And this is how shared memory can be
implemented<00:03:43.920><c> which</c><00:03:44.159><c> will</c><00:03:44.319><c> be</c><00:03:44.400><c> a</c><00:03:44.560><c> key</c><00:03:44.720><c> point</c><00:03:44.959><c> of</c>

00:03:45.190 --> 00:03:45.200 align:start position:0%
implemented which will be a key point of
 

00:03:45.200 --> 00:03:47.589 align:start position:0%
implemented which will be a key point of
today's<00:03:45.599><c> topic</c><00:03:46.000><c> of</c><00:03:46.319><c> copying</c><00:03:46.879><c> large</c><00:03:47.120><c> chunks</c><00:03:47.440><c> of</c>

00:03:47.589 --> 00:03:47.599 align:start position:0%
today's topic of copying large chunks of
 

00:03:47.599 --> 00:03:49.430 align:start position:0%
today's topic of copying large chunks of
memory.<00:03:48.080><c> So</c><00:03:48.239><c> let's</c><00:03:48.560><c> focus</c><00:03:48.879><c> back</c><00:03:49.040><c> on</c><00:03:49.200><c> the</c>

00:03:49.430 --> 00:03:49.440 align:start position:0%
memory. So let's focus back on the
 

00:03:49.440 --> 00:03:52.149 align:start position:0%
memory. So let's focus back on the
kernel<00:03:49.920><c> layer.</c><00:03:50.640><c> The</c><00:03:50.879><c> kernel</c><00:03:51.200><c> manages</c><00:03:51.680><c> its</c><00:03:51.920><c> own</c>

00:03:52.149 --> 00:03:52.159 align:start position:0%
kernel layer. The kernel manages its own
 

00:03:52.159 --> 00:03:53.910 align:start position:0%
kernel layer. The kernel manages its own
higher<00:03:52.480><c> level</c><00:03:52.799><c> representation</c><00:03:53.519><c> of</c><00:03:53.760><c> the</c>

00:03:53.910 --> 00:03:53.920 align:start position:0%
higher level representation of the
 

00:03:53.920 --> 00:03:56.070 align:start position:0%
higher level representation of the
virtual<00:03:54.319><c> memory</c><00:03:54.560><c> for</c><00:03:54.799><c> each</c><00:03:55.040><c> process</c><00:03:55.599><c> in</c><00:03:55.840><c> what</c>

00:03:56.070 --> 00:03:56.080 align:start position:0%
virtual memory for each process in what
 

00:03:56.080 --> 00:03:58.550 align:start position:0%
virtual memory for each process in what
is<00:03:56.239><c> known</c><00:03:56.400><c> as</c><00:03:56.560><c> the</c><00:03:56.799><c> VM</c><00:03:57.200><c> subsystem.</c><00:03:58.319><c> This</c>

00:03:58.550 --> 00:03:58.560 align:start position:0%
is known as the VM subsystem. This
 

00:03:58.560 --> 00:04:00.630 align:start position:0%
is known as the VM subsystem. This
subsystem<00:03:59.200><c> can</c><00:03:59.439><c> be</c><00:03:59.599><c> interacted</c><00:04:00.159><c> with</c><00:04:00.319><c> via</c>

00:04:00.630 --> 00:04:00.640 align:start position:0%
subsystem can be interacted with via
 

00:04:00.640 --> 00:04:03.110 align:start position:0%
subsystem can be interacted with via
kernel<00:04:01.040><c> functions</c><00:04:01.840><c> and</c><00:04:02.080><c> it</c><00:04:02.319><c> provides</c><00:04:02.560><c> an</c><00:04:02.720><c> API</c>

00:04:03.110 --> 00:04:03.120 align:start position:0%
kernel functions and it provides an API
 

00:04:03.120 --> 00:04:05.350 align:start position:0%
kernel functions and it provides an API
to<00:04:03.360><c> manipulate</c><00:04:03.840><c> the</c><00:04:04.159><c> underlying</c><00:04:04.720><c> page</c><00:04:05.040><c> table</c>

00:04:05.350 --> 00:04:05.360 align:start position:0%
to manipulate the underlying page table
 

00:04:05.360 --> 00:04:07.830 align:start position:0%
to manipulate the underlying page table
structures<00:04:05.920><c> in</c><00:04:06.239><c> a</c><00:04:06.480><c> hardware</c><00:04:06.879><c> agnostic</c><00:04:07.360><c> way.</c>

00:04:07.830 --> 00:04:07.840 align:start position:0%
structures in a hardware agnostic way.
 

00:04:07.840 --> 00:04:10.789 align:start position:0%
structures in a hardware agnostic way.
On<00:04:08.000><c> the</c><00:04:08.080><c> XNU</c><00:04:08.720><c> kernel,</c><00:04:09.200><c> we</c><00:04:09.439><c> have</c><00:04:09.680><c> VM</c><00:04:10.159><c> map</c><00:04:10.400><c> entry</c>

00:04:10.789 --> 00:04:10.799 align:start position:0%
On the XNU kernel, we have VM map entry
 

00:04:10.799 --> 00:04:13.030 align:start position:0%
On the XNU kernel, we have VM map entry
structures<00:04:11.360><c> to</c><00:04:11.680><c> represent</c><00:04:12.159><c> slices</c><00:04:12.640><c> of</c><00:04:12.879><c> a</c>

00:04:13.030 --> 00:04:13.040 align:start position:0%
structures to represent slices of a
 

00:04:13.040 --> 00:04:14.869 align:start position:0%
structures to represent slices of a
process<00:04:13.439><c> address</c><00:04:13.760><c> space</c><00:04:14.319><c> and</c><00:04:14.480><c> these</c><00:04:14.720><c> are</c>

00:04:14.869 --> 00:04:14.879 align:start position:0%
process address space and these are
 

00:04:14.879 --> 00:04:17.509 align:start position:0%
process address space and these are
stored<00:04:15.120><c> in</c><00:04:15.280><c> a</c><00:04:15.439><c> link</c><00:04:15.760><c> list.</c><00:04:16.560><c> This</c><00:04:16.720><c> link</c><00:04:17.040><c> list</c><00:04:17.359><c> is</c>

00:04:17.509 --> 00:04:17.519 align:start position:0%
stored in a link list. This link list is
 

00:04:17.519 --> 00:04:20.710 align:start position:0%
stored in a link list. This link list is
a<00:04:17.759><c> member</c><00:04:18.000><c> of</c><00:04:18.239><c> that</c><00:04:18.560><c> process's</c><00:04:19.199><c> VM</c><00:04:19.600><c> map</c><00:04:20.479><c> which</c>

00:04:20.710 --> 00:04:20.720 align:start position:0%
a member of that process's VM map which
 

00:04:20.720 --> 00:04:22.950 align:start position:0%
a member of that process's VM map which
also<00:04:21.040><c> contains</c><00:04:21.359><c> a</c><00:04:21.600><c> reference</c><00:04:21.919><c> to</c><00:04:22.079><c> the</c><00:04:22.400><c> PMAP</c>

00:04:22.950 --> 00:04:22.960 align:start position:0%
also contains a reference to the PMAP
 

00:04:22.960 --> 00:04:24.390 align:start position:0%
also contains a reference to the PMAP
layer<00:04:23.040><c> where</c><00:04:23.199><c> the</c><00:04:23.440><c> actual</c><00:04:23.680><c> physical</c><00:04:24.080><c> page</c>

00:04:24.390 --> 00:04:24.400 align:start position:0%
layer where the actual physical page
 

00:04:24.400 --> 00:04:26.230 align:start position:0%
layer where the actual physical page
tables<00:04:24.639><c> are</c><00:04:24.800><c> held.</c><00:04:25.360><c> It's</c><00:04:25.680><c> important</c><00:04:25.919><c> that</c><00:04:26.080><c> the</c>

00:04:26.230 --> 00:04:26.240 align:start position:0%
tables are held. It's important that the
 

00:04:26.240 --> 00:04:28.070 align:start position:0%
tables are held. It's important that the
kernel's<00:04:26.720><c> own</c><00:04:26.960><c> representation</c><00:04:27.440><c> of</c><00:04:27.680><c> virtual</c>

00:04:28.070 --> 00:04:28.080 align:start position:0%
kernel's own representation of virtual
 

00:04:28.080 --> 00:04:30.150 align:start position:0%
kernel's own representation of virtual
memory<00:04:28.560><c> and</c><00:04:28.720><c> the</c><00:04:28.960><c> pmap</c><00:04:29.520><c> layer</c><00:04:29.600><c> for</c><00:04:29.759><c> a</c><00:04:29.919><c> given</c>

00:04:30.150 --> 00:04:30.160 align:start position:0%
memory and the pmap layer for a given
 

00:04:30.160 --> 00:04:32.070 align:start position:0%
memory and the pmap layer for a given
process<00:04:30.800><c> both</c><00:04:31.120><c> stay</c><00:04:31.280><c> in</c><00:04:31.440><c> sync</c><00:04:31.680><c> with</c><00:04:31.919><c> one</c>

00:04:32.070 --> 00:04:32.080 align:start position:0%
process both stay in sync with one
 

00:04:32.080 --> 00:04:34.150 align:start position:0%
process both stay in sync with one
another<00:04:32.639><c> to</c><00:04:32.880><c> prevent</c><00:04:33.199><c> issues</c><00:04:33.600><c> such</c><00:04:33.840><c> as</c>

00:04:34.150 --> 00:04:34.160 align:start position:0%
another to prevent issues such as
 

00:04:34.160 --> 00:04:36.390 align:start position:0%
another to prevent issues such as
dangling<00:04:34.720><c> page</c><00:04:34.960><c> table</c><00:04:35.199><c> entries</c><00:04:35.919><c> which</c><00:04:36.160><c> I've</c>

00:04:36.390 --> 00:04:36.400 align:start position:0%
dangling page table entries which I've
 

00:04:36.400 --> 00:04:37.909 align:start position:0%
dangling page table entries which I've
covered<00:04:36.639><c> in</c><00:04:36.800><c> two</c><00:04:36.960><c> other</c><00:04:37.199><c> videos</c><00:04:37.440><c> on</c><00:04:37.759><c> this</c>

00:04:37.909 --> 00:04:37.919 align:start position:0%
covered in two other videos on this
 

00:04:37.919 --> 00:04:39.830 align:start position:0%
covered in two other videos on this
channel.<00:04:38.560><c> So</c><00:04:38.800><c> let's</c><00:04:38.960><c> imagine</c><00:04:39.280><c> we</c><00:04:39.520><c> have</c>

00:04:39.830 --> 00:04:39.840 align:start position:0%
channel. So let's imagine we have
 

00:04:39.840 --> 00:04:42.390 align:start position:0%
channel. So let's imagine we have
process<00:04:40.320><c> A</c><00:04:40.720><c> which</c><00:04:40.960><c> allocates</c><00:04:41.520><c> some</c><00:04:41.759><c> region</c><00:04:42.160><c> of</c>

00:04:42.390 --> 00:04:42.400 align:start position:0%
process A which allocates some region of
 

00:04:42.400 --> 00:04:45.670 align:start position:0%
process A which allocates some region of
virtual<00:04:42.720><c> memory</c><00:04:43.360><c> spanning</c><00:04:44.000><c> 64</c><00:04:44.560><c> pages.</c><00:04:45.360><c> Behind</c>

00:04:45.670 --> 00:04:45.680 align:start position:0%
virtual memory spanning 64 pages. Behind
 

00:04:45.680 --> 00:04:48.310 align:start position:0%
virtual memory spanning 64 pages. Behind
the<00:04:45.919><c> scenes,</c><00:04:46.240><c> a</c><00:04:46.479><c> VM</c><00:04:46.880><c> map</c><00:04:47.120><c> entry</c><00:04:47.440><c> structure</c><00:04:48.000><c> is</c>

00:04:48.310 --> 00:04:48.320 align:start position:0%
the scenes, a VM map entry structure is
 

00:04:48.320 --> 00:04:50.469 align:start position:0%
the scenes, a VM map entry structure is
added<00:04:48.639><c> to</c><00:04:48.800><c> that</c><00:04:49.040><c> process's</c><00:04:49.520><c> linked</c><00:04:49.840><c> list</c><00:04:50.240><c> in</c>

00:04:50.469 --> 00:04:50.479 align:start position:0%
added to that process's linked list in
 

00:04:50.479 --> 00:04:52.710 align:start position:0%
added to that process's linked list in
the<00:04:50.639><c> kernel</c><00:04:51.360><c> representing</c><00:04:51.919><c> that</c><00:04:52.160><c> given</c><00:04:52.479><c> range</c>

00:04:52.710 --> 00:04:52.720 align:start position:0%
the kernel representing that given range
 

00:04:52.720 --> 00:04:54.870 align:start position:0%
the kernel representing that given range
of<00:04:52.880><c> memory.</c><00:04:53.680><c> And</c><00:04:53.919><c> from</c><00:04:54.080><c> the</c><00:04:54.240><c> process's</c><00:04:54.800><c> point</c>

00:04:54.870 --> 00:04:54.880 align:start position:0%
of memory. And from the process's point
 

00:04:54.880 --> 00:04:57.350 align:start position:0%
of memory. And from the process's point
of<00:04:55.040><c> view,</c><00:04:55.680><c> this</c><00:04:56.000><c> address</c><00:04:56.400><c> range</c><00:04:56.800><c> is</c><00:04:57.040><c> now</c>

00:04:57.350 --> 00:04:57.360 align:start position:0%
of view, this address range is now
 

00:04:57.360 --> 00:04:59.189 align:start position:0%
of view, this address range is now
addressable<00:04:57.919><c> memory,</c><00:04:58.479><c> part</c><00:04:58.639><c> of</c><00:04:58.800><c> its</c><00:04:59.040><c> own</c>

00:04:59.189 --> 00:04:59.199 align:start position:0%
addressable memory, part of its own
 

00:04:59.199 --> 00:05:01.430 align:start position:0%
addressable memory, part of its own
address<00:04:59.520><c> space.</c><00:05:00.479><c> Page</c><00:05:00.800><c> tables</c><00:05:01.199><c> don't</c>

00:05:01.430 --> 00:05:01.440 align:start position:0%
address space. Page tables don't
 

00:05:01.440 --> 00:05:02.710 align:start position:0%
address space. Page tables don't
actually<00:05:01.680><c> need</c><00:05:01.840><c> to</c><00:05:01.919><c> be</c><00:05:02.080><c> involved</c><00:05:02.320><c> at</c><00:05:02.560><c> this</c>

00:05:02.710 --> 00:05:02.720 align:start position:0%
actually need to be involved at this
 

00:05:02.720 --> 00:05:04.790 align:start position:0%
actually need to be involved at this
stage<00:05:03.280><c> since</c><00:05:03.680><c> no</c><00:05:03.919><c> read</c><00:05:04.160><c> or</c><00:05:04.320><c> rights</c><00:05:04.639><c> have</c>

00:05:04.790 --> 00:05:04.800 align:start position:0%
stage since no read or rights have
 

00:05:04.800 --> 00:05:06.550 align:start position:0%
stage since no read or rights have
occurred<00:05:05.280><c> within</c><00:05:05.600><c> the</c><00:05:05.759><c> newly</c><00:05:06.000><c> allocated</c>

00:05:06.550 --> 00:05:06.560 align:start position:0%
occurred within the newly allocated
 

00:05:06.560 --> 00:05:08.629 align:start position:0%
occurred within the newly allocated
range.<00:05:07.199><c> So</c><00:05:07.360><c> it</c><00:05:07.600><c> would</c><00:05:07.680><c> be</c><00:05:07.840><c> redundant</c><00:05:08.400><c> and</c>

00:05:08.629 --> 00:05:08.639 align:start position:0%
range. So it would be redundant and
 

00:05:08.639 --> 00:05:10.950 align:start position:0%
range. So it would be redundant and
wasteful<00:05:09.120><c> to</c><00:05:09.280><c> have</c><00:05:09.520><c> physical</c><00:05:09.919><c> pages</c><00:05:10.639><c> cover</c>

00:05:10.950 --> 00:05:10.960 align:start position:0%
wasteful to have physical pages cover
 

00:05:10.960 --> 00:05:12.790 align:start position:0%
wasteful to have physical pages cover
this<00:05:11.120><c> address</c><00:05:11.440><c> range</c><00:05:11.840><c> at</c><00:05:12.000><c> this</c><00:05:12.160><c> time.</c><00:05:12.639><c> The</c>

00:05:12.790 --> 00:05:12.800 align:start position:0%
this address range at this time. The
 

00:05:12.800 --> 00:05:14.950 align:start position:0%
this address range at this time. The
kernel<00:05:13.120><c> waits</c><00:05:13.440><c> to</c><00:05:13.600><c> do</c><00:05:13.759><c> this</c><00:05:14.000><c> until</c><00:05:14.400><c> a</c><00:05:14.720><c> page</c>

00:05:14.950 --> 00:05:14.960 align:start position:0%
kernel waits to do this until a page
 

00:05:14.960 --> 00:05:17.430 align:start position:0%
kernel waits to do this until a page
fault<00:05:15.360><c> actually</c><00:05:15.680><c> occurs</c><00:05:16.240><c> within</c><00:05:16.560><c> this</c><00:05:16.800><c> range.</c>

00:05:17.430 --> 00:05:17.440 align:start position:0%
fault actually occurs within this range.
 

00:05:17.440 --> 00:05:19.510 align:start position:0%
fault actually occurs within this range.
We<00:05:17.680><c> can</c><00:05:17.759><c> trigger</c><00:05:18.000><c> a</c><00:05:18.160><c> page</c><00:05:18.400><c> fault</c><00:05:18.720><c> by</c><00:05:18.960><c> writing</c>

00:05:19.510 --> 00:05:19.520 align:start position:0%
We can trigger a page fault by writing
 

00:05:19.520 --> 00:05:21.430 align:start position:0%
We can trigger a page fault by writing
some<00:05:19.759><c> A's</c><00:05:20.240><c> to</c><00:05:20.400><c> the</c><00:05:20.560><c> first</c><00:05:20.800><c> page</c><00:05:21.039><c> in</c><00:05:21.280><c> this</c>

00:05:21.430 --> 00:05:21.440 align:start position:0%
some A's to the first page in this
 

00:05:21.440 --> 00:05:23.510 align:start position:0%
some A's to the first page in this
range.<00:05:22.080><c> And</c><00:05:22.320><c> now</c><00:05:22.479><c> we</c><00:05:22.720><c> see</c><00:05:22.800><c> that</c><00:05:22.960><c> the</c><00:05:23.120><c> kernel</c>

00:05:23.510 --> 00:05:23.520 align:start position:0%
range. And now we see that the kernel
 

00:05:23.520 --> 00:05:25.670 align:start position:0%
range. And now we see that the kernel
has<00:05:23.759><c> gone</c><00:05:24.000><c> this</c><00:05:24.240><c> extra</c><00:05:24.560><c> step</c><00:05:24.880><c> to</c><00:05:25.199><c> assign</c><00:05:25.520><c> a</c>

00:05:25.670 --> 00:05:25.680 align:start position:0%
has gone this extra step to assign a
 

00:05:25.680 --> 00:05:28.790 align:start position:0%
has gone this extra step to assign a
backend<00:05:26.160><c> VM</c><00:05:26.479><c> object</c><00:05:27.280><c> which</c><00:05:27.520><c> also</c><00:05:27.840><c> holds</c><00:05:28.160><c> a</c><00:05:28.400><c> VM</c>

00:05:28.790 --> 00:05:28.800 align:start position:0%
backend VM object which also holds a VM
 

00:05:28.800 --> 00:05:31.590 align:start position:0%
backend VM object which also holds a VM
page.<00:05:29.759><c> The</c><00:05:29.919><c> VM</c><00:05:30.240><c> page</c><00:05:30.639><c> directly</c><00:05:31.039><c> corresponds</c>

00:05:31.590 --> 00:05:31.600 align:start position:0%
page. The VM page directly corresponds
 

00:05:31.600 --> 00:05:33.990 align:start position:0%
page. The VM page directly corresponds
to<00:05:31.840><c> the</c><00:05:32.000><c> page</c><00:05:32.320><c> table</c><00:05:32.639><c> entry</c><00:05:33.360><c> which</c><00:05:33.600><c> has</c><00:05:33.759><c> also</c>

00:05:33.990 --> 00:05:34.000 align:start position:0%
to the page table entry which has also
 

00:05:34.000 --> 00:05:36.070 align:start position:0%
to the page table entry which has also
been<00:05:34.240><c> added</c><00:05:34.479><c> to</c><00:05:34.720><c> this</c><00:05:34.960><c> processes</c><00:05:35.520><c> page</c><00:05:35.759><c> table</c>

00:05:36.070 --> 00:05:36.080 align:start position:0%
been added to this processes page table
 

00:05:36.080 --> 00:05:38.790 align:start position:0%
been added to this processes page table
at<00:05:36.320><c> this</c><00:05:36.479><c> point.</c><00:05:37.039><c> So</c><00:05:37.199><c> imagine</c><00:05:37.600><c> we'veed</c><00:05:38.320><c> in</c><00:05:38.560><c> all</c>

00:05:38.790 --> 00:05:38.800 align:start position:0%
at this point. So imagine we'veed in all
 

00:05:38.800 --> 00:05:41.110 align:start position:0%
at this point. So imagine we'veed in all
64<00:05:39.280><c> pages</c><00:05:39.680><c> in</c><00:05:39.919><c> this</c><00:05:40.080><c> address</c><00:05:40.400><c> range</c><00:05:40.880><c> by</c>

00:05:41.110 --> 00:05:41.120 align:start position:0%
64 pages in this address range by
 

00:05:41.120 --> 00:05:43.510 align:start position:0%
64 pages in this address range by
writing<00:05:41.600><c> a</c><00:05:41.759><c> bunch</c><00:05:42.000><c> more</c><00:05:42.240><c> A's.</c><00:05:43.039><c> Now</c><00:05:43.280><c> the</c>

00:05:43.510 --> 00:05:43.520 align:start position:0%
writing a bunch more A's. Now the
 

00:05:43.520 --> 00:05:46.230 align:start position:0%
writing a bunch more A's. Now the
underlying<00:05:44.000><c> VM</c><00:05:44.320><c> object</c><00:05:44.880><c> holds</c><00:05:45.360><c> references</c><00:05:45.840><c> to</c>

00:05:46.230 --> 00:05:46.240 align:start position:0%
underlying VM object holds references to
 

00:05:46.240 --> 00:05:49.909 align:start position:0%
underlying VM object holds references to
64<00:05:46.880><c> VM</c><00:05:47.280><c> pages</c><00:05:47.919><c> and</c><00:05:48.160><c> there</c><00:05:48.320><c> are</c><00:05:48.479><c> also</c><00:05:48.880><c> 64</c><00:05:49.520><c> page</c>

00:05:49.909 --> 00:05:49.919 align:start position:0%
64 VM pages and there are also 64 page
 

00:05:49.919 --> 00:05:51.830 align:start position:0%
64 VM pages and there are also 64 page
table<00:05:50.160><c> entries</c><00:05:50.720><c> entered</c><00:05:51.120><c> into</c><00:05:51.360><c> the</c><00:05:51.520><c> page</c>

00:05:51.830 --> 00:05:51.840 align:start position:0%
table entries entered into the page
 

00:05:51.840 --> 00:05:54.629 align:start position:0%
table entries entered into the page
tables<00:05:52.240><c> for</c><00:05:52.400><c> this</c><00:05:52.639><c> process.</c><00:05:53.759><c> This</c><00:05:53.919><c> is</c><00:05:54.160><c> 64</c>

00:05:54.629 --> 00:05:54.639 align:start position:0%
tables for this process. This is 64
 

00:05:54.639 --> 00:05:57.430 align:start position:0%
tables for this process. This is 64
pages<00:05:55.120><c> worth</c><00:05:55.360><c> of</c><00:05:55.759><c> real</c><00:05:56.080><c> data.</c><00:05:56.960><c> So</c><00:05:57.199><c> what</c>

00:05:57.430 --> 00:05:57.440 align:start position:0%
pages worth of real data. So what
 

00:05:57.440 --> 00:05:59.110 align:start position:0%
pages worth of real data. So what
happens<00:05:57.680><c> when</c><00:05:57.919><c> we</c><00:05:58.080><c> want</c><00:05:58.160><c> to</c><00:05:58.320><c> copy</c><00:05:58.560><c> this</c><00:05:58.800><c> data</c>

00:05:59.110 --> 00:05:59.120 align:start position:0%
happens when we want to copy this data
 

00:05:59.120 --> 00:06:00.950 align:start position:0%
happens when we want to copy this data
elsewhere?<00:05:59.840><c> We</c><00:06:00.080><c> already</c><00:06:00.320><c> know</c><00:06:00.479><c> that</c><00:06:00.639><c> it</c><00:06:00.800><c> will</c>

00:06:00.950 --> 00:06:00.960 align:start position:0%
elsewhere? We already know that it will
 

00:06:00.960 --> 00:06:02.870 align:start position:0%
elsewhere? We already know that it will
be<00:06:01.039><c> very</c><00:06:01.280><c> very</c><00:06:01.520><c> slow</c><00:06:01.759><c> to</c><00:06:01.919><c> use</c><00:06:02.160><c> memcopy</c><00:06:02.720><c> for</c>

00:06:02.870 --> 00:06:02.880 align:start position:0%
be very very slow to use memcopy for
 

00:06:02.880 --> 00:06:05.110 align:start position:0%
be very very slow to use memcopy for
this.<00:06:03.440><c> So</c><00:06:03.680><c> instead</c><00:06:04.080><c> if</c><00:06:04.240><c> we</c><00:06:04.400><c> use</c><00:06:04.560><c> the</c><00:06:04.720><c> kernel</c>

00:06:05.110 --> 00:06:05.120 align:start position:0%
this. So instead if we use the kernel
 

00:06:05.120 --> 00:06:07.909 align:start position:0%
this. So instead if we use the kernel
API<00:06:05.680><c> VM</c><00:06:06.080><c> copy,</c><00:06:06.720><c> there</c><00:06:06.880><c> is</c><00:06:07.039><c> no</c><00:06:07.199><c> performance</c><00:06:07.680><c> hit</c>

00:06:07.909 --> 00:06:07.919 align:start position:0%
API VM copy, there is no performance hit
 

00:06:07.919 --> 00:06:10.070 align:start position:0%
API VM copy, there is no performance hit
taken<00:06:08.639><c> as</c><00:06:08.880><c> we</c><00:06:09.199><c> increase</c><00:06:09.440><c> the</c><00:06:09.600><c> size</c><00:06:09.759><c> of</c><00:06:09.919><c> the</c>

00:06:10.070 --> 00:06:10.080 align:start position:0%
taken as we increase the size of the
 

00:06:10.080 --> 00:06:12.230 align:start position:0%
taken as we increase the size of the
copy.<00:06:10.960><c> If</c><00:06:11.199><c> you're</c><00:06:11.360><c> a</c><00:06:11.520><c> programmer,</c><00:06:12.000><c> you</c><00:06:12.160><c> can</c>

00:06:12.230 --> 00:06:12.240 align:start position:0%
copy. If you're a programmer, you can
 

00:06:12.240 --> 00:06:13.430 align:start position:0%
copy. If you're a programmer, you can
probably<00:06:12.400><c> already</c><00:06:12.720><c> see</c><00:06:12.880><c> where</c><00:06:13.120><c> this</c><00:06:13.280><c> is</c>

00:06:13.430 --> 00:06:13.440 align:start position:0%
probably already see where this is
 

00:06:13.440 --> 00:06:15.590 align:start position:0%
probably already see where this is
going.<00:06:14.080><c> Since</c><00:06:14.319><c> the</c><00:06:14.560><c> virtual</c><00:06:14.880><c> address</c><00:06:15.199><c> space</c>

00:06:15.590 --> 00:06:15.600 align:start position:0%
going. Since the virtual address space
 

00:06:15.600 --> 00:06:17.909 align:start position:0%
going. Since the virtual address space
is<00:06:15.840><c> just</c><00:06:16.080><c> an</c><00:06:16.400><c> illusion</c><00:06:16.880><c> made</c><00:06:17.120><c> up</c><00:06:17.280><c> of</c><00:06:17.360><c> some</c><00:06:17.600><c> VM</c>

00:06:17.909 --> 00:06:17.919 align:start position:0%
is just an illusion made up of some VM
 

00:06:17.919 --> 00:06:19.749 align:start position:0%
is just an illusion made up of some VM
map<00:06:18.160><c> entry</c><00:06:18.400><c> structures</c><00:06:18.960><c> describing</c><00:06:19.520><c> the</c>

00:06:19.749 --> 00:06:19.759 align:start position:0%
map entry structures describing the
 

00:06:19.759 --> 00:06:21.749 align:start position:0%
map entry structures describing the
address<00:06:20.000><c> range,</c><00:06:20.720><c> we</c><00:06:20.880><c> can</c><00:06:21.039><c> of</c><00:06:21.199><c> course</c><00:06:21.360><c> leverage</c>

00:06:21.749 --> 00:06:21.759 align:start position:0%
address range, we can of course leverage
 

00:06:21.759 --> 00:06:24.070 align:start position:0%
address range, we can of course leverage
this<00:06:22.160><c> to</c><00:06:22.479><c> make</c><00:06:22.639><c> the</c><00:06:22.880><c> process</c><00:06:23.360><c> believe</c><00:06:23.680><c> that</c><00:06:23.919><c> we</c>

00:06:24.070 --> 00:06:24.080 align:start position:0%
this to make the process believe that we
 

00:06:24.080 --> 00:06:26.230 align:start position:0%
this to make the process believe that we
have<00:06:24.240><c> copied</c><00:06:24.639><c> all</c><00:06:24.880><c> 64</c><00:06:25.360><c> pages</c><00:06:25.680><c> to</c><00:06:25.919><c> somewhere</c>

00:06:26.230 --> 00:06:26.240 align:start position:0%
have copied all 64 pages to somewhere
 

00:06:26.240 --> 00:06:28.309 align:start position:0%
have copied all 64 pages to somewhere
else.<00:06:26.880><c> All</c><00:06:27.120><c> that</c><00:06:27.280><c> is</c><00:06:27.440><c> required</c><00:06:27.840><c> is</c><00:06:28.000><c> a</c><00:06:28.240><c> couple</c>

00:06:28.309 --> 00:06:28.319 align:start position:0%
else. All that is required is a couple
 

00:06:28.319 --> 00:06:30.390 align:start position:0%
else. All that is required is a couple
of<00:06:28.479><c> manipulations</c><00:06:29.360><c> made</c><00:06:29.600><c> to</c><00:06:29.840><c> these</c><00:06:30.080><c> VM</c>

00:06:30.390 --> 00:06:30.400 align:start position:0%
of manipulations made to these VM
 

00:06:30.400 --> 00:06:32.390 align:start position:0%
of manipulations made to these VM
structures.<00:06:30.880><c> The</c><00:06:31.120><c> kernel</c><00:06:31.440><c> first</c><00:06:31.759><c> packages</c><00:06:32.240><c> up</c>

00:06:32.390 --> 00:06:32.400 align:start position:0%
structures. The kernel first packages up
 

00:06:32.400 --> 00:06:34.469 align:start position:0%
structures. The kernel first packages up
the<00:06:32.639><c> source</c><00:06:32.960><c> range</c><00:06:33.280><c> into</c><00:06:33.680><c> what</c><00:06:33.919><c> is</c><00:06:34.000><c> known</c><00:06:34.160><c> as</c><00:06:34.319><c> a</c>

00:06:34.469 --> 00:06:34.479 align:start position:0%
the source range into what is known as a
 

00:06:34.479 --> 00:06:37.110 align:start position:0%
the source range into what is known as a
VM<00:06:34.800><c> map</c><00:06:35.120><c> copy</c><00:06:35.440><c> structure</c><00:06:36.319><c> and</c><00:06:36.479><c> then</c><00:06:36.720><c> it</c><00:06:36.880><c> calls</c>

00:06:37.110 --> 00:06:37.120 align:start position:0%
VM map copy structure and then it calls
 

00:06:37.120 --> 00:06:39.990 align:start position:0%
VM map copy structure and then it calls
VM<00:06:37.520><c> map</c><00:06:37.840><c> copy</c><00:06:38.160><c> overwrite</c><00:06:39.039><c> to</c><00:06:39.360><c> insert</c><00:06:39.759><c> this</c>

00:06:39.990 --> 00:06:40.000 align:start position:0%
VM map copy overwrite to insert this
 

00:06:40.000 --> 00:06:42.230 align:start position:0%
VM map copy overwrite to insert this
into<00:06:40.319><c> the</c><00:06:40.479><c> destination</c><00:06:41.039><c> range.</c><00:06:41.680><c> This</c><00:06:41.840><c> results</c>

00:06:42.230 --> 00:06:42.240 align:start position:0%
into the destination range. This results
 

00:06:42.240 --> 00:06:44.390 align:start position:0%
into the destination range. This results
in<00:06:42.400><c> the</c><00:06:42.560><c> existing</c><00:06:43.039><c> VM</c><00:06:43.360><c> map</c><00:06:43.600><c> entries</c><00:06:44.080><c> that</c>

00:06:44.390 --> 00:06:44.400 align:start position:0%
in the existing VM map entries that
 

00:06:44.400 --> 00:06:46.550 align:start position:0%
in the existing VM map entries that
cover<00:06:44.639><c> the</c><00:06:44.880><c> destination</c><00:06:45.360><c> range</c><00:06:46.000><c> having</c><00:06:46.319><c> their</c>

00:06:46.550 --> 00:06:46.560 align:start position:0%
cover the destination range having their
 

00:06:46.560 --> 00:06:49.029 align:start position:0%
cover the destination range having their
backing<00:06:47.039><c> stores</c><00:06:47.360><c> updated</c><00:06:48.160><c> to</c><00:06:48.400><c> point</c><00:06:48.639><c> to</c><00:06:48.800><c> the</c>

00:06:49.029 --> 00:06:49.039 align:start position:0%
backing stores updated to point to the
 

00:06:49.039 --> 00:06:51.189 align:start position:0%
backing stores updated to point to the
same<00:06:49.280><c> underlying</c><00:06:49.840><c> physical</c><00:06:50.240><c> memory</c><00:06:50.560><c> pages.</c>

00:06:51.189 --> 00:06:51.199 align:start position:0%
same underlying physical memory pages.
 

00:06:51.199 --> 00:06:52.790 align:start position:0%
same underlying physical memory pages.
From<00:06:51.360><c> the</c><00:06:51.520><c> caller's</c><00:06:51.919><c> point</c><00:06:52.080><c> of</c><00:06:52.240><c> view,</c><00:06:52.560><c> this</c>

00:06:52.790 --> 00:06:52.800 align:start position:0%
From the caller's point of view, this
 

00:06:52.800 --> 00:06:55.189 align:start position:0%
From the caller's point of view, this
operation<00:06:53.440><c> happened</c><00:06:53.840><c> almost</c><00:06:54.240><c> instantly</c><00:06:55.199><c> no</c>

00:06:55.189 --> 00:06:55.199 align:start position:0%
operation happened almost instantly no
 

00:06:55.199 --> 00:06:57.430 align:start position:0%
operation happened almost instantly no
matter<00:06:55.600><c> the</c><00:06:55.759><c> size</c><00:06:55.919><c> of</c><00:06:56.080><c> the</c><00:06:56.240><c> copy.</c><00:06:56.880><c> The</c><00:06:57.039><c> process</c>

00:06:57.430 --> 00:06:57.440 align:start position:0%
matter the size of the copy. The process
 

00:06:57.440 --> 00:06:59.270 align:start position:0%
matter the size of the copy. The process
can<00:06:57.680><c> read</c><00:06:57.919><c> from</c><00:06:58.080><c> the</c><00:06:58.240><c> destination</c><00:06:58.720><c> range</c><00:06:59.039><c> and</c>

00:06:59.270 --> 00:06:59.280 align:start position:0%
can read from the destination range and
 

00:06:59.280 --> 00:07:01.189 align:start position:0%
can read from the destination range and
it<00:06:59.520><c> will</c><00:06:59.680><c> see</c><00:06:59.840><c> the</c><00:07:00.080><c> data</c><00:07:00.319><c> that</c><00:07:00.639><c> was</c><00:07:00.800><c> copied</c>

00:07:01.189 --> 00:07:01.199 align:start position:0%
it will see the data that was copied
 

00:07:01.199 --> 00:07:02.870 align:start position:0%
it will see the data that was copied
from<00:07:01.360><c> the</c><00:07:01.520><c> source</c><00:07:01.840><c> range.</c><00:07:02.400><c> The</c><00:07:02.639><c> only</c><00:07:02.720><c> thing</c>

00:07:02.870 --> 00:07:02.880 align:start position:0%
from the source range. The only thing
 

00:07:02.880 --> 00:07:04.390 align:start position:0%
from the source range. The only thing
left<00:07:03.039><c> to</c><00:07:03.199><c> handle</c><00:07:03.520><c> at</c><00:07:03.680><c> this</c><00:07:03.840><c> point</c><00:07:03.919><c> is</c><00:07:04.160><c> what</c>

00:07:04.390 --> 00:07:04.400 align:start position:0%
left to handle at this point is what
 

00:07:04.400 --> 00:07:06.230 align:start position:0%
left to handle at this point is what
actually<00:07:04.639><c> happens</c><00:07:04.960><c> if</c><00:07:05.199><c> the</c><00:07:05.360><c> caller</c><00:07:05.759><c> tries</c><00:07:06.000><c> to</c>

00:07:06.230 --> 00:07:06.240 align:start position:0%
actually happens if the caller tries to
 

00:07:06.240 --> 00:07:08.309 align:start position:0%
actually happens if the caller tries to
modify<00:07:06.720><c> one</c><00:07:06.960><c> of</c><00:07:07.039><c> the</c><00:07:07.120><c> buffers</c><00:07:07.759><c> because</c><00:07:08.080><c> at</c>

00:07:08.309 --> 00:07:08.319 align:start position:0%
modify one of the buffers because at
 

00:07:08.319 --> 00:07:10.710 align:start position:0%
modify one of the buffers because at
this<00:07:08.479><c> stage</c><00:07:09.039><c> both</c><00:07:09.360><c> address</c><00:07:09.759><c> ranges</c><00:07:10.319><c> point</c><00:07:10.560><c> to</c>

00:07:10.710 --> 00:07:10.720 align:start position:0%
this stage both address ranges point to
 

00:07:10.720 --> 00:07:12.790 align:start position:0%
this stage both address ranges point to
the<00:07:10.960><c> same</c><00:07:11.199><c> underlying</c><00:07:11.759><c> physical</c><00:07:12.160><c> memory.</c>

00:07:12.790 --> 00:07:12.800 align:start position:0%
the same underlying physical memory.
 

00:07:12.800 --> 00:07:14.870 align:start position:0%
the same underlying physical memory.
This<00:07:13.039><c> shared</c><00:07:13.360><c> memory</c><00:07:13.680><c> situation</c><00:07:14.160><c> is</c><00:07:14.479><c> fine</c><00:07:14.720><c> if</c>

00:07:14.870 --> 00:07:14.880 align:start position:0%
This shared memory situation is fine if
 

00:07:14.880 --> 00:07:17.029 align:start position:0%
This shared memory situation is fine if
the<00:07:15.120><c> application</c><00:07:15.599><c> is</c><00:07:15.919><c> only</c><00:07:16.240><c> reading</c><00:07:16.720><c> from</c><00:07:16.880><c> the</c>

00:07:17.029 --> 00:07:17.039 align:start position:0%
the application is only reading from the
 

00:07:17.039 --> 00:07:19.029 align:start position:0%
the application is only reading from the
buffers.<00:07:18.000><c> But</c><00:07:18.080><c> as</c><00:07:18.319><c> soon</c><00:07:18.400><c> as</c><00:07:18.479><c> it</c><00:07:18.720><c> tries</c><00:07:18.880><c> to</c>

00:07:19.029 --> 00:07:19.039 align:start position:0%
buffers. But as soon as it tries to
 

00:07:19.039 --> 00:07:21.110 align:start position:0%
buffers. But as soon as it tries to
write,<00:07:19.360><c> we</c><00:07:19.520><c> will</c><00:07:19.680><c> run</c><00:07:19.919><c> into</c><00:07:20.240><c> a</c><00:07:20.479><c> problem</c>

00:07:21.110 --> 00:07:21.120 align:start position:0%
write, we will run into a problem
 

00:07:21.120 --> 00:07:22.870 align:start position:0%
write, we will run into a problem
without<00:07:21.520><c> any</c><00:07:21.759><c> extra</c><00:07:22.080><c> handling.</c><00:07:22.479><c> for</c><00:07:22.720><c> this</c>

00:07:22.870 --> 00:07:22.880 align:start position:0%
without any extra handling. for this
 

00:07:22.880 --> 00:07:25.029 align:start position:0%
without any extra handling. for this
case<00:07:23.440><c> writing</c><00:07:23.919><c> to</c><00:07:24.000><c> the</c><00:07:24.160><c> destination</c><00:07:24.720><c> address</c>

00:07:25.029 --> 00:07:25.039 align:start position:0%
case writing to the destination address
 

00:07:25.039 --> 00:07:27.350 align:start position:0%
case writing to the destination address
range<00:07:25.440><c> will</c><00:07:25.680><c> also</c><00:07:25.919><c> write</c><00:07:26.160><c> to</c><00:07:26.319><c> the</c><00:07:26.479><c> source</c><00:07:27.199><c> and</c>

00:07:27.350 --> 00:07:27.360 align:start position:0%
range will also write to the source and
 

00:07:27.360 --> 00:07:29.430 align:start position:0%
range will also write to the source and
this<00:07:27.599><c> could</c><00:07:27.759><c> of</c><00:07:27.919><c> course</c><00:07:28.080><c> be</c><00:07:28.319><c> problematic.</c><00:07:29.280><c> So</c>

00:07:29.430 --> 00:07:29.440 align:start position:0%
this could of course be problematic. So
 

00:07:29.440 --> 00:07:31.670 align:start position:0%
this could of course be problematic. So
to<00:07:29.680><c> solve</c><00:07:29.840><c> this</c><00:07:30.319><c> the</c><00:07:30.560><c> shared</c><00:07:30.960><c> pages</c><00:07:31.440><c> are</c>

00:07:31.670 --> 00:07:31.680 align:start position:0%
to solve this the shared pages are
 

00:07:31.680 --> 00:07:33.430 align:start position:0%
to solve this the shared pages are
marked<00:07:32.000><c> with</c><00:07:32.160><c> a</c><00:07:32.400><c> special</c><00:07:32.720><c> flag</c><00:07:33.039><c> that</c><00:07:33.199><c> tells</c>

00:07:33.430 --> 00:07:33.440 align:start position:0%
marked with a special flag that tells
 

00:07:33.440 --> 00:07:35.350 align:start position:0%
marked with a special flag that tells
the<00:07:33.599><c> kernel</c><00:07:34.240><c> these</c><00:07:34.560><c> need</c><00:07:34.720><c> to</c><00:07:34.800><c> be</c><00:07:34.960><c> physically</c>

00:07:35.350 --> 00:07:35.360 align:start position:0%
the kernel these need to be physically
 

00:07:35.360 --> 00:07:37.589 align:start position:0%
the kernel these need to be physically
copied<00:07:36.000><c> in</c><00:07:36.160><c> the</c><00:07:36.319><c> event</c><00:07:36.479><c> of</c><00:07:36.639><c> a</c><00:07:36.880><c> write.</c><00:07:37.360><c> This</c>

00:07:37.589 --> 00:07:37.599 align:start position:0%
copied in the event of a write. This
 

00:07:37.599 --> 00:07:39.430 align:start position:0%
copied in the event of a write. This
mechanism<00:07:38.080><c> is</c><00:07:38.400><c> commonly</c><00:07:38.800><c> referred</c><00:07:39.039><c> to</c><00:07:39.199><c> as</c>

00:07:39.430 --> 00:07:39.440 align:start position:0%
mechanism is commonly referred to as
 

00:07:39.440 --> 00:07:41.670 align:start position:0%
mechanism is commonly referred to as
copy<00:07:39.759><c> on</c><00:07:40.000><c> write.</c><00:07:40.639><c> So</c><00:07:40.800><c> let's</c><00:07:40.960><c> say</c><00:07:41.120><c> the</c><00:07:41.280><c> caller</c>

00:07:41.670 --> 00:07:41.680 align:start position:0%
copy on write. So let's say the caller
 

00:07:41.680 --> 00:07:43.749 align:start position:0%
copy on write. So let's say the caller
tries<00:07:41.919><c> to</c><00:07:42.160><c> write</c><00:07:42.400><c> to</c><00:07:42.560><c> the</c><00:07:42.800><c> first</c><00:07:43.039><c> page</c><00:07:43.360><c> of</c><00:07:43.599><c> the</c>

00:07:43.749 --> 00:07:43.759 align:start position:0%
tries to write to the first page of the
 

00:07:43.759 --> 00:07:45.990 align:start position:0%
tries to write to the first page of the
destination<00:07:44.319><c> range.</c><00:07:45.280><c> The</c><00:07:45.440><c> page</c><00:07:45.759><c> fault</c>

00:07:45.990 --> 00:07:46.000 align:start position:0%
destination range. The page fault
 

00:07:46.000 --> 00:07:48.390 align:start position:0%
destination range. The page fault
handler<00:07:46.400><c> in</c><00:07:46.560><c> the</c><00:07:46.639><c> kernel</c><00:07:47.120><c> will</c><00:07:47.440><c> notice</c><00:07:48.000><c> this</c>

00:07:48.390 --> 00:07:48.400 align:start position:0%
handler in the kernel will notice this
 

00:07:48.400 --> 00:07:51.110 align:start position:0%
handler in the kernel will notice this
flag<00:07:49.039><c> stating</c><00:07:49.360><c> that</c><00:07:49.599><c> we</c><00:07:49.759><c> need</c><00:07:49.919><c> to</c><00:07:50.080><c> copy</c><00:07:50.720><c> and</c><00:07:50.960><c> at</c>

00:07:51.110 --> 00:07:51.120 align:start position:0%
flag stating that we need to copy and at
 

00:07:51.120 --> 00:07:52.550 align:start position:0%
flag stating that we need to copy and at
this<00:07:51.280><c> point</c><00:07:51.440><c> it</c><00:07:51.680><c> will</c><00:07:51.840><c> create</c><00:07:52.000><c> an</c><00:07:52.240><c> actual</c>

00:07:52.550 --> 00:07:52.560 align:start position:0%
this point it will create an actual
 

00:07:52.560 --> 00:07:55.110 align:start position:0%
this point it will create an actual
physical<00:07:53.039><c> copy</c><00:07:53.280><c> of</c><00:07:53.440><c> the</c><00:07:53.599><c> backing</c><00:07:54.080><c> page.</c><00:07:54.960><c> The</c>

00:07:55.110 --> 00:07:55.120 align:start position:0%
physical copy of the backing page. The
 

00:07:55.120 --> 00:07:57.270 align:start position:0%
physical copy of the backing page. The
VM<00:07:55.520><c> structures</c><00:07:55.919><c> are</c><00:07:56.080><c> updated</c><00:07:56.560><c> and</c><00:07:56.879><c> now</c><00:07:57.039><c> the</c>

00:07:57.270 --> 00:07:57.280 align:start position:0%
VM structures are updated and now the
 

00:07:57.280 --> 00:07:59.350 align:start position:0%
VM structures are updated and now the
right<00:07:57.599><c> can</c><00:07:57.759><c> proceed</c><00:07:58.240><c> without</c><00:07:58.720><c> making</c><00:07:59.039><c> any</c>

00:07:59.350 --> 00:07:59.360 align:start position:0%
right can proceed without making any
 

00:07:59.360 --> 00:08:01.510 align:start position:0%
right can proceed without making any
unwanted<00:08:00.000><c> changes</c><00:08:00.319><c> to</c><00:08:00.560><c> the</c><00:08:00.720><c> source</c><00:08:00.960><c> memory.</c>

00:08:01.510 --> 00:08:01.520 align:start position:0%
unwanted changes to the source memory.
 

00:08:01.520 --> 00:08:03.430 align:start position:0%
unwanted changes to the source memory.
The<00:08:01.759><c> concepts</c><00:08:02.160><c> explained</c><00:08:02.560><c> in</c><00:08:02.720><c> this</c><00:08:02.879><c> video</c><00:08:03.120><c> are</c>

00:08:03.430 --> 00:08:03.440 align:start position:0%
The concepts explained in this video are
 

00:08:03.440 --> 00:08:05.670 align:start position:0%
The concepts explained in this video are
fundamental<00:08:04.080><c> in</c><00:08:04.319><c> any</c><00:08:04.560><c> operating</c><00:08:04.960><c> system.</c>

00:08:05.670 --> 00:08:05.680 align:start position:0%
fundamental in any operating system.
 

00:08:05.680 --> 00:08:07.350 align:start position:0%
fundamental in any operating system.
We've<00:08:05.919><c> only</c><00:08:06.160><c> looked</c><00:08:06.319><c> at</c><00:08:06.479><c> a</c><00:08:06.639><c> use</c><00:08:06.800><c> case</c><00:08:07.039><c> when</c>

00:08:07.350 --> 00:08:07.360 align:start position:0%
We've only looked at a use case when
 

00:08:07.360 --> 00:08:08.950 align:start position:0%
We've only looked at a use case when
copying<00:08:07.840><c> memory</c><00:08:08.160><c> from</c><00:08:08.319><c> one</c><00:08:08.479><c> buffer</c><00:08:08.800><c> to</c>

00:08:08.950 --> 00:08:08.960 align:start position:0%
copying memory from one buffer to
 

00:08:08.960 --> 00:08:11.110 align:start position:0%
copying memory from one buffer to
another.<00:08:09.520><c> But</c><00:08:09.680><c> in</c><00:08:09.840><c> reality,</c><00:08:10.319><c> the</c><00:08:10.560><c> abstraction</c>

00:08:11.110 --> 00:08:11.120 align:start position:0%
another. But in reality, the abstraction
 

00:08:11.120 --> 00:08:12.710 align:start position:0%
another. But in reality, the abstraction
of<00:08:11.280><c> virtual</c><00:08:11.680><c> memory</c><00:08:12.000><c> in</c><00:08:12.160><c> this</c><00:08:12.319><c> way</c>

00:08:12.710 --> 00:08:12.720 align:start position:0%
of virtual memory in this way
 

00:08:12.720 --> 00:08:15.270 align:start position:0%
of virtual memory in this way
facilitates<00:08:13.440><c> much</c><00:08:13.680><c> more.</c><00:08:14.319><c> Process</c><00:08:14.720><c> forking</c>

00:08:15.270 --> 00:08:15.280 align:start position:0%
facilitates much more. Process forking
 

00:08:15.280 --> 00:08:17.430 align:start position:0%
facilitates much more. Process forking
into<00:08:15.599><c> process</c><00:08:15.919><c> copying</c><00:08:16.400><c> and</c><00:08:16.639><c> sharing</c><00:08:17.039><c> buffers</c>

00:08:17.430 --> 00:08:17.440 align:start position:0%
into process copying and sharing buffers
 

00:08:17.440 --> 00:08:19.749 align:start position:0%
into process copying and sharing buffers
with<00:08:17.520><c> the</c><00:08:17.680><c> kernel</c><00:08:18.000><c> itself</c><00:08:18.800><c> are</c><00:08:19.039><c> all</c><00:08:19.280><c> built</c><00:08:19.520><c> on</c>

00:08:19.749 --> 00:08:19.759 align:start position:0%
with the kernel itself are all built on
 

00:08:19.759 --> 00:08:21.749 align:start position:0%
with the kernel itself are all built on
top<00:08:19.840><c> of</c><00:08:20.000><c> this</c><00:08:20.240><c> virtual</c><00:08:20.560><c> memory</c><00:08:20.879><c> subsystem.</c>

00:08:21.749 --> 00:08:21.759 align:start position:0%
top of this virtual memory subsystem.
 

00:08:21.759 --> 00:08:23.749 align:start position:0%
top of this virtual memory subsystem.
The<00:08:22.000><c> complicated</c><00:08:22.479><c> nature</c><00:08:22.800><c> of</c><00:08:22.960><c> this</c><00:08:23.199><c> codebase</c>

00:08:23.749 --> 00:08:23.759 align:start position:0%
The complicated nature of this codebase
 

00:08:23.759 --> 00:08:26.070 align:start position:0%
The complicated nature of this codebase
within<00:08:24.160><c> X</c><00:08:24.400><c> and</c><00:08:24.800><c> specifically</c><00:08:25.680><c> means</c><00:08:25.919><c> that</c>

00:08:26.070 --> 00:08:26.080 align:start position:0%
within X and specifically means that
 

00:08:26.080 --> 00:08:27.909 align:start position:0%
within X and specifically means that
there<00:08:26.240><c> are</c><00:08:26.400><c> many</c><00:08:26.639><c> cases</c><00:08:26.960><c> of</c><00:08:27.280><c> vulnerabilities</c>

00:08:27.909 --> 00:08:27.919 align:start position:0%
there are many cases of vulnerabilities
 

00:08:27.919 --> 00:08:29.830 align:start position:0%
there are many cases of vulnerabilities
here<00:08:28.240><c> leading</c><00:08:28.560><c> to</c><00:08:28.800><c> all</c><00:08:29.039><c> kinds</c><00:08:29.280><c> of</c><00:08:29.440><c> weird</c>

00:08:29.830 --> 00:08:29.840 align:start position:0%
here leading to all kinds of weird
 

00:08:29.840 --> 00:08:31.589 align:start position:0%
here leading to all kinds of weird
undefined<00:08:30.400><c> behavior</c><00:08:30.960><c> and</c><00:08:31.280><c> memory</c>

00:08:31.589 --> 00:08:31.599 align:start position:0%
undefined behavior and memory
 

00:08:31.599 --> 00:08:33.430 align:start position:0%
undefined behavior and memory
corruption.<00:08:32.320><c> And</c><00:08:32.560><c> so,</c><00:08:32.719><c> while</c><00:08:32.959><c> we</c><00:08:33.120><c> didn't</c><00:08:33.279><c> look</c>

00:08:33.430 --> 00:08:33.440 align:start position:0%
corruption. And so, while we didn't look
 

00:08:33.440 --> 00:08:35.110 align:start position:0%
corruption. And so, while we didn't look
at<00:08:33.599><c> any</c><00:08:33.760><c> vulnerability</c><00:08:34.240><c> specifics</c><00:08:34.719><c> in</c><00:08:34.959><c> this</c>

00:08:35.110 --> 00:08:35.120 align:start position:0%
at any vulnerability specifics in this
 

00:08:35.120 --> 00:08:37.589 align:start position:0%
at any vulnerability specifics in this
video,<00:08:35.839><c> understanding</c><00:08:36.399><c> this</c><00:08:36.640><c> codebase</c><00:08:37.200><c> at</c><00:08:37.440><c> a</c>

00:08:37.589 --> 00:08:37.599 align:start position:0%
video, understanding this codebase at a
 

00:08:37.599 --> 00:08:39.430 align:start position:0%
video, understanding this codebase at a
higher<00:08:37.839><c> level</c><00:08:38.320><c> is</c><00:08:38.560><c> the</c><00:08:38.719><c> first</c><00:08:38.959><c> step</c><00:08:39.200><c> into</c>

00:08:39.430 --> 00:08:39.440 align:start position:0%
higher level is the first step into
 

00:08:39.440 --> 00:08:41.190 align:start position:0%
higher level is the first step into
diving<00:08:39.839><c> in.</c><00:08:40.240><c> Check</c><00:08:40.399><c> out</c><00:08:40.479><c> my</c><00:08:40.640><c> other</c><00:08:40.880><c> videos</c>

00:08:41.190 --> 00:08:41.200 align:start position:0%
diving in. Check out my other videos
 

00:08:41.200 --> 00:08:43.190 align:start position:0%
diving in. Check out my other videos
covering<00:08:41.599><c> the</c><00:08:41.839><c> triggering</c><00:08:42.399><c> and</c><00:08:42.640><c> exploitation</c>

00:08:43.190 --> 00:08:43.200 align:start position:0%
covering the triggering and exploitation
 

00:08:43.200 --> 00:08:45.750 align:start position:0%
covering the triggering and exploitation
of<00:08:43.360><c> a</c><00:08:43.519><c> virtual</c><00:08:43.839><c> memory</c><00:08:44.159><c> bug</c><00:08:44.320><c> in</c><00:08:44.480><c> iOS.</c><00:08:45.440><c> Links</c>

00:08:45.750 --> 00:08:45.760 align:start position:0%
of a virtual memory bug in iOS. Links
 

00:08:45.760 --> 00:08:47.750 align:start position:0%
of a virtual memory bug in iOS. Links
will<00:08:45.920><c> be</c><00:08:46.080><c> in</c><00:08:46.240><c> the</c><00:08:46.399><c> description.</c><00:08:47.279><c> Thanks</c><00:08:47.600><c> for</c>

00:08:47.750 --> 00:08:47.760 align:start position:0%
will be in the description. Thanks for
 

00:08:47.760 --> 00:08:51.279 align:start position:0%
will be in the description. Thanks for
watching<00:08:48.000><c> and</c><00:08:48.240><c> I</c><00:08:48.480><c> will</c><00:08:48.640><c> see</c><00:08:48.720><c> you</c><00:08:48.880><c> in</c><00:08:49.040><c> the</c><00:08:49.200><c> next</c>

