aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/lib/kvm_util_internal.h
diff options
context:
space:
mode:
authorAxel Rasmussen <axelrasmussen@google.com>2021-05-19 13:03:37 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2021-05-27 07:45:56 -0400
commit94f3f2b31a8a9e8bd30bf6f4903ff84acc612e0e (patch)
tree15e044c96aecaba47ff54d4373e0846fc6be4923 /tools/testing/selftests/kvm/lib/kvm_util_internal.h
parentKVM: selftests: add shmem backing source type (diff)
downloadlinux-dev-94f3f2b31a8a9e8bd30bf6f4903ff84acc612e0e.tar.xz
linux-dev-94f3f2b31a8a9e8bd30bf6f4903ff84acc612e0e.zip
KVM: selftests: create alias mappings when using shared memory
When a memory region is added with a src_type specifying that it should use some kind of shared memory, also create an alias mapping to the same underlying physical pages. And, add an API so tests can get access to these alias addresses. Basically, for a guest physical address, let us look up the analogous host *alias* address. In a future commit, we'll modify the demand paging test to take advantage of this to exercise UFFD minor faults. The idea is, we pre-fault the underlying pages *via the alias*. When the *guest* faults, it gets a "minor" fault (PTEs don't exist yet, but a page is already in the page cache). Then, the userfaultfd theads can handle the fault: they could potentially modify the underlying memory *via the alias* if they wanted to, and then they install the PTEs and let the guest carry on via a UFFDIO_CONTINUE ioctl. Reviewed-by: Ben Gardon <bgardon@google.com> Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> Message-Id: <20210519200339.829146-9-axelrasmussen@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/kvm_util_internal.h')
-rw-r--r--tools/testing/selftests/kvm/lib/kvm_util_internal.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/kvm_util_internal.h b/tools/testing/selftests/kvm/lib/kvm_util_internal.h
index b30e8c7b119b..a03febc24ba6 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util_internal.h
+++ b/tools/testing/selftests/kvm/lib/kvm_util_internal.h
@@ -19,7 +19,9 @@ struct userspace_mem_region {
int fd;
off_t offset;
void *host_mem;
+ void *host_alias;
void *mmap_start;
+ void *mmap_alias;
size_t mmap_size;
struct rb_node gpa_node;
struct rb_node hva_node;