<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/arch/arm64/kvm/hyp/nvhe/page_alloc.c, branch linux-6.2.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.2.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.2.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2022-11-11T16:40:54Z</updated>
<entry>
<title>KVM: arm64: Back the hypervisor 'struct hyp_page' array for all memory</title>
<updated>2022-11-11T16:40:54Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2022-11-10T19:02:36Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=8e6bcc3a4502a0d8d065466efd888b6b59b85789'/>
<id>urn:sha1:8e6bcc3a4502a0d8d065466efd888b6b59b85789</id>
<content type='text'>
The EL2 'vmemmap' array in nVHE Protected mode is currently very sparse:
only memory pages owned by the hypervisor itself have a matching 'struct
hyp_page'. However, as the size of this struct has been reduced
significantly since its introduction, it appears that we can now afford
to back the vmemmap for all of memory.

Having an easily accessible 'struct hyp_page' for every physical page in
memory provides the hypervisor with a simple mechanism to store metadata
(e.g. a refcount) that wouldn't otherwise fit in the very limited number
of software bits available in the host stage-2 page-table entries. This
will be used in subsequent patches when pinning host memory pages for
use by the hypervisor at EL2.

Tested-by: Vincent Donnefort &lt;vdonnefort@google.com&gt;
Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Signed-off-by: Will Deacon &lt;will@kernel.org&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20221110190259.26861-4-will@kernel.org
</content>
</entry>
<entry>
<title>KVM: arm64: Allow attaching of non-coalescable pages to a hyp pool</title>
<updated>2022-11-11T16:40:54Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2022-11-10T19:02:35Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=72a5bc0f153ce8ca80e9abbd1d9adec7d586915a'/>
<id>urn:sha1:72a5bc0f153ce8ca80e9abbd1d9adec7d586915a</id>
<content type='text'>
All the contiguous pages used to initialize a 'struct hyp_pool' are
considered coalescable, which means that the hyp page allocator will
actively try to merge them with their buddies on the hyp_put_page() path.
However, using hyp_put_page() on a page that is not part of the inital
memory range given to a hyp_pool() is currently unsupported.

In order to allow dynamically extending hyp pools at run-time, add a
check to __hyp_attach_page() to allow inserting 'external' pages into
the free-list of order 0. This will be necessary to allow lazy donation
of pages from the host to the hypervisor when allocating guest stage-2
page-table pages at EL2.

Tested-by: Vincent Donnefort &lt;vdonnefort@google.com&gt;
Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Signed-off-by: Will Deacon &lt;will@kernel.org&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20221110190259.26861-3-will@kernel.org
</content>
</entry>
<entry>
<title>KVM: arm64: Move hyp refcount manipulation helpers to common header file</title>
<updated>2022-11-11T16:40:54Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2022-11-10T19:02:34Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=0f4f7ae10ee4e6403659b2d9ddf05424eecde45b'/>
<id>urn:sha1:0f4f7ae10ee4e6403659b2d9ddf05424eecde45b</id>
<content type='text'>
We will soon need to manipulate 'struct hyp_page' refcounts from outside
page_alloc.c, so move the helpers to a common header file to allow them
to be reused easily.

Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@linaro.org&gt;
Reviewed-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
Tested-by: Vincent Donnefort &lt;vdonnefort@google.com&gt;
Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Signed-off-by: Will Deacon &lt;will@kernel.org&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20221110190259.26861-2-will@kernel.org
</content>
</entry>
<entry>
<title>KVM: arm64: fix typos in comments</title>
<updated>2022-03-18T14:04:15Z</updated>
<author>
<name>Julia Lawall</name>
<email>Julia.Lawall@inria.fr</email>
</author>
<published>2022-03-18T10:37:19Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=21ea457842759a236eefed2cfaa8cc7e5dc967a0'/>
<id>urn:sha1:21ea457842759a236eefed2cfaa8cc7e5dc967a0</id>
<content type='text'>
Various spelling mistakes in comments.
Detected with the help of Coccinelle.

Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20220318103729.157574-24-Julia.Lawall@inria.fr
</content>
</entry>
<entry>
<title>KVM: arm64: pkvm: Fix hyp_pool max order</title>
<updated>2021-12-15T14:16:28Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2021-12-08T15:22:54Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=34b43a8849229e8363c19236ecdf463b7a89d085'/>
<id>urn:sha1:34b43a8849229e8363c19236ecdf463b7a89d085</id>
<content type='text'>
The EL2 page allocator in protected mode maintains a per-pool max order
value to optimize allocations when the memory region it covers is small.
However, the max order value is currently under-estimated whenever the
number of pages in the region is a power of two. Fix the estimation.

Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Acked-by: Will Deacon &lt;will@kernel.org&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20211208152300.2478542-2-qperret@google.com
</content>
</entry>
<entry>
<title>KVM: arm64: Report corrupted refcount at EL2</title>
<updated>2021-10-05T12:02:54Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2021-10-05T09:01:42Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7615c2a514788559c6684234b8fc27f3a843c2c6'/>
<id>urn:sha1:7615c2a514788559c6684234b8fc27f3a843c2c6</id>
<content type='text'>
Some of the refcount manipulation helpers used at EL2 are instrumented
to catch a corrupted state, but not all of them are treated equally. Let's
make things more consistent by instrumenting hyp_page_ref_dec_and_test()
as well.

Acked-by: Will Deacon &lt;will@kernel.org&gt;
Suggested-by: Will Deacon &lt;will@kernel.org&gt;
Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20211005090155.734578-6-qperret@google.com
</content>
</entry>
<entry>
<title>KVM: arm64: Fix host stage-2 PGD refcount</title>
<updated>2021-10-05T12:02:54Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2021-10-05T09:01:41Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=1d58a17ef54599506d44c45ac95be27273a4d2b1'/>
<id>urn:sha1:1d58a17ef54599506d44c45ac95be27273a4d2b1</id>
<content type='text'>
The KVM page-table library refcounts the pages of concatenated stage-2
PGDs individually. However, when running KVM in protected mode, the
host's stage-2 PGD is currently managed by EL2 as a single high-order
compound page, which can cause the refcount of the tail pages to reach 0
when they shouldn't, hence corrupting the page-table.

Fix this by introducing a new hyp_split_page() helper in the EL2 page
allocator (matching the kernel's split_page() function), and make use of
it from host_s2_zalloc_pages_exact().

Fixes: 1025c8c0c6ac ("KVM: arm64: Wrap the host with a stage 2")
Acked-by: Will Deacon &lt;will@kernel.org&gt;
Suggested-by: Will Deacon &lt;will@kernel.org&gt;
Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20211005090155.734578-5-qperret@google.com
</content>
</entry>
<entry>
<title>KVM: arm64: Use less bits for hyp_page refcount</title>
<updated>2021-06-11T12:24:12Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2021-06-08T11:45:18Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=6929586d8eddad184f43526efe7bf0a8be4f18b2'/>
<id>urn:sha1:6929586d8eddad184f43526efe7bf0a8be4f18b2</id>
<content type='text'>
The hyp_page refcount is currently encoded on 4 bytes even though we
never need to count that many objects in a page. Make it 2 bytes to save
some space in the vmemmap.

As overflows are more likely to happen as well, make sure to catch those
with a BUG in the increment function.

Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20210608114518.748712-8-qperret@google.com
</content>
</entry>
<entry>
<title>KVM: arm64: Use less bits for hyp_page order</title>
<updated>2021-06-11T12:24:11Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2021-06-08T11:45:17Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=87ec0606733e1aa9568f54ddb41f03aa6b5687f2'/>
<id>urn:sha1:87ec0606733e1aa9568f54ddb41f03aa6b5687f2</id>
<content type='text'>
The hyp_page order is currently encoded on 4 bytes even though it is
guaranteed to be smaller than this. Make it 2 bytes to reduce the hyp
vmemmap overhead.

Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20210608114518.748712-7-qperret@google.com
</content>
</entry>
<entry>
<title>KVM: arm64: Remove hyp_pool pointer from struct hyp_page</title>
<updated>2021-06-11T12:24:11Z</updated>
<author>
<name>Quentin Perret</name>
<email>qperret@google.com</email>
</author>
<published>2021-06-08T11:45:16Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d978b9cfe6fe8008467f8c5d51677f52e7815b39'/>
<id>urn:sha1:d978b9cfe6fe8008467f8c5d51677f52e7815b39</id>
<content type='text'>
Each struct hyp_page currently contains a pointer to a hyp_pool struct
where the page should be freed if its refcount reaches 0. However, this
information can always be inferred from the context in the EL2 code, so
drop the pointer to save a few bytes in the vmemmap.

Signed-off-by: Quentin Perret &lt;qperret@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20210608114518.748712-6-qperret@google.com
</content>
</entry>
</feed>
