linux/arch/powerpc
Maciej S. Szmigiero a54d806688 KVM: Keep memslots in tree-based structures instead of array-based ones
The current memslot code uses a (reverse gfn-ordered) memslot array for
keeping track of them.

Because the memslot array that is currently in use cannot be modified
every memslot management operation (create, delete, move, change flags)
has to make a copy of the whole array so it has a scratch copy to work on.

Strictly speaking, however, it is only necessary to make copy of the
memslot that is being modified, copying all the memslots currently present
is just a limitation of the array-based memslot implementation.

Two memslot sets, however, are still needed so the VM continues to run
on the currently active set while the requested operation is being
performed on the second, currently inactive one.

In order to have two memslot sets, but only one copy of actual memslots
it is necessary to split out the memslot data from the memslot sets.

The memslots themselves should be also kept independent of each other
so they can be individually added or deleted.

These two memslot sets should normally point to the same set of
memslots. They can, however, be desynchronized when performing a
memslot management operation by replacing the memslot to be modified
by its copy.  After the operation is complete, both memslot sets once
again point to the same, common set of memslot data.

This commit implements the aforementioned idea.

For tracking of gfns an ordinary rbtree is used since memslots cannot
overlap in the guest address space and so this data structure is
sufficient for ensuring that lookups are done quickly.

The "last used slot" mini-caches (both per-slot set one and per-vCPU one),
that keep track of the last found-by-gfn memslot, are still present in the
new code.

Co-developed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Message-Id: <17c0cf3663b760a0d3753d4ac08c0753e941b811.1638817641.git.maciej.szmigiero@oracle.com>
2021-12-08 04:24:34 -05:00
..
boot powerpc updates for 5.16 2021-11-05 08:15:46 -07:00
configs Merge branch 'akpm' (patches from Andrew) 2021-11-06 14:08:17 -07:00
crypto
include KVM: PPC: Avoid referencing userspace memory region in memslot updates 2021-12-08 04:24:22 -05:00
kernel powerpc fixes for 5.16 #2 2021-11-21 10:26:35 -08:00
kexec powerpc/machdep: Remove stale functions from ppc_md structure 2021-10-22 15:22:05 +11:00
kvm KVM: Keep memslots in tree-based structures instead of array-based ones 2021-12-08 04:24:34 -05:00
lib Kbuild updates for v5.16 2021-11-08 09:15:45 -08:00
math-emu
mm powerpc/book3e: Fix TLBCAM preset at boot 2021-11-16 21:20:59 +11:00
net powerpc updates for 5.16 2021-11-05 08:15:46 -07:00
perf powerpc updates for 5.16 2021-11-05 08:15:46 -07:00
platforms powerpc/pseries/ddw: Do not try direct mapping with persistent memory and one window 2021-11-15 15:46:46 +11:00
purgatory
sysdev powerpc/xive: Change IRQ domain to a tree domain 2021-11-17 21:55:42 +11:00
tools
xmon powerpc/xmon: fix task state output 2021-10-28 22:32:03 +11:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig powerpc/64s: Default to 64K pages for 64 bit book3s 2021-10-27 22:31:22 +11:00
Kconfig.debug
Makefile Kbuild updates for v5.16 2021-11-08 09:15:45 -08:00
Makefile.postlink