commit | 4335938aa6415dc9f39bed6189c7ef5dd6296c2a | [log] [tgz] |
---|---|---|
author | Sebastian Ene <sebastianene@google.com> | Wed Jul 26 11:40:03 2023 +0000 |
committer | Keir Fraser <keirf@google.com> | Tue Sep 10 07:30:40 2024 +0000 |
tree | 462eb9aeb3fb80c7793f9e1dda2d81980941946f | |
parent | 08fe78b8918220441014c33414bd5e96a6e6fb5c [diff] |
KVM: arm64: Coalesce host stage2 entries on ownership reclaim This optimization allows us to re-create higher order block mappings in the host stage2 pagetables after we teardown a guest VM. The coalescing code is triggered on host_stage2_set_owner_locked path when we annotate the entries in the host stage2 page-tables with an invalid entry that has the owner set to PKVM_ID_HOST. This can also be triggered from page_relinquish when we do page insertion in the ballooning code. This patch reintroduces the _post callback walker to be able to zap the page table entries on ownership re-assignment. When the host reclaims ownership during guest teardown, the page table walker drops the refcount of the counted entries and clears out unreferenced entries (refcount == 1). Clearing out the entry installs a zero PTE. When the host stage2 receives a data abort because there is no mapping associated, it will try to create the largest possible block mapping from the founded leaf entry. With the current patch, we increase the chances of finding a leaf entry that has level < 3 if the requested region comes from a reclaimed torned down VM memory. This has the advantage of reducing the TLB pressure at host stage2. To be able to do coalescing, we modify the way we do refcounting by not counting the following descriptor types at host stage 2: - non-zero invalid PTEs - any descriptor that has at least one of the reserved-high bits(58-55) toogled - non-default attribute mappings - page table descriptors The algorithm works as presented below: Is refcount(child(pte_table)) == 1 ? Yes -> (because we left only default mappings) Zap the table by setting 0 in the pte_table and put the page that holds the level 3 entries back into the memcache level 2 +---------+ | | | ... | | pte_table---+ level 3 -> we can now re-create a 2Mb mapping | ... | +---> +---------+ | | | | | | | | | | |def entry| +---------+ | | |def entry| | | | ... | +---------+ Change-Id: I983372a0fac876336ee6799be1f3c4a50015880c Signed-off-by: Sebastian Ene <sebastianene@google.com>
BEST: Make all of your changes to upstream Linux. If appropriate, backport to the stable releases. These patches will be merged automatically in the corresponding common kernels. If the patch is already in upstream Linux, post a backport of the patch that conforms to the patch requirements below.
EXPORT_SYMBOL_GPL()
require an in-tree modular driver that uses the symbol -- so include the new driver or changes to an existing driver in the same patchset as the export.LESS GOOD: Develop your patches out-of-tree (from an upstream Linux point-of-view). Unless these are fixing an Android-specific bug, these are very unlikely to be accepted unless they have been coordinated with kernel-team@android.com. If you want to proceed, post a patch that conforms to the patch requirements below.
scripts/checkpatch.pl
UPSTREAM:
, BACKPORT:
, FROMGIT:
, FROMLIST:
, or ANDROID:
.Change-Id:
tag (see https://gerrit-review.googlesource.com/Documentation/user-changeid.html)Bug:
tag.Signed-off-by:
tag by the author and the submitterAdditional requirements are listed below based on patch type
UPSTREAM:
, BACKPORT:
UPSTREAM:
.(cherry picked from commit ...)
lineimportant patch from upstream This is the detailed description of the important patch Signed-off-by: Fred Jones <fred.jones@foo.org>
- then Joe Smith would upload the patch for the common kernel as
UPSTREAM: important patch from upstream This is the detailed description of the important patch Signed-off-by: Fred Jones <fred.jones@foo.org> Bug: 135791357 Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 (cherry picked from commit c31e73121f4c1ec41143423ac6ce3ce6dafdcec1) Signed-off-by: Joe Smith <joe.smith@foo.org>
BACKPORT:
instead of UPSTREAM:
.UPSTREAM:
(cherry picked from commit ...)
lineBACKPORT: important patch from upstream This is the detailed description of the important patch Signed-off-by: Fred Jones <fred.jones@foo.org> Bug: 135791357 Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 (cherry picked from commit c31e73121f4c1ec41143423ac6ce3ce6dafdcec1) [joe: Resolved minor conflict in drivers/foo/bar.c ] Signed-off-by: Joe Smith <joe.smith@foo.org>
FROMGIT:
, FROMLIST:
,FROMGIT:
(cherry picked from commit <sha1> <repo> <branch>)
. This must be a stable maintainer branch (not rebased, so don't use linux-next
for example).BACKPORT: FROMGIT:
important patch from upstream This is the detailed description of the important patch Signed-off-by: Fred Jones <fred.jones@foo.org>
- then Joe Smith would upload the patch for the common kernel as
FROMGIT: important patch from upstream This is the detailed description of the important patch Signed-off-by: Fred Jones <fred.jones@foo.org> Bug: 135791357 (cherry picked from commit 878a2fd9de10b03d11d2f622250285c7e63deace https://git.kernel.org/pub/scm/linux/kernel/git/foo/bar.git test-branch) Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 Signed-off-by: Joe Smith <joe.smith@foo.org>
FROMLIST:
Link:
tag with a link to the submittal on lore.kernel.orgBug:
tag with the Android bug (required for patches not accepted into a maintainer tree)BACKPORT: FROMLIST:
FROMLIST: important patch from upstream This is the detailed description of the important patch Signed-off-by: Fred Jones <fred.jones@foo.org> Bug: 135791357 Link: https://lore.kernel.org/lkml/20190619171517.GA17557@someone.com/ Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 Signed-off-by: Joe Smith <joe.smith@foo.org>
ANDROID:
ANDROID:
Fixes:
tag that cites the patch with the bugANDROID: fix android-specific bug in foobar.c This is the detailed description of the important fix Fixes: 1234abcd2468 ("foobar: add cool feature") Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 Signed-off-by: Joe Smith <joe.smith@foo.org>
ANDROID:
Bug:
tag with the Android bug (required for android-specific features)