]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/x86/include/asm/kvm_page_track.h
KVM: x86: Use gpa_t for cr2/gpa to fix TDP support on 32-bit KVM
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / include / asm / kvm_page_track.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
21ebbeda
XG
2#ifndef _ASM_X86_KVM_PAGE_TRACK_H
3#define _ASM_X86_KVM_PAGE_TRACK_H
4
5enum kvm_page_track_mode {
6 KVM_PAGE_TRACK_WRITE,
7 KVM_PAGE_TRACK_MAX,
8};
9
0eb05bf2
XG
10/*
11 * The notifier represented by @kvm_page_track_notifier_node is linked into
12 * the head which will be notified when guest is triggering the track event.
13 *
14 * Write access on the head is protected by kvm->mmu_lock, read access
15 * is protected by track_srcu.
16 */
17struct kvm_page_track_notifier_head {
18 struct srcu_struct track_srcu;
19 struct hlist_head track_notifier_list;
20};
21
22struct kvm_page_track_notifier_node {
23 struct hlist_node node;
24
25 /*
26 * It is called when guest is writing the write-tracked page
27 * and write emulation is finished at that time.
28 *
29 * @vcpu: the vcpu where the write access happened.
30 * @gpa: the physical address written by guest.
31 * @new: the data was written to the address.
32 * @bytes: the written length.
d126363d 33 * @node: this node
0eb05bf2
XG
34 */
35 void (*track_write)(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
d126363d 36 int bytes, struct kvm_page_track_notifier_node *node);
ae7cd873
XC
37 /*
38 * It is called when memory slot is being moved or removed
39 * users can drop write-protection for the pages in that memory slot
40 *
41 * @kvm: the kvm where memory slot being moved or removed
42 * @slot: the memory slot being moved or removed
d126363d 43 * @node: this node
ae7cd873 44 */
d126363d
JS
45 void (*track_flush_slot)(struct kvm *kvm, struct kvm_memory_slot *slot,
46 struct kvm_page_track_notifier_node *node);
0eb05bf2
XG
47};
48
49void kvm_page_track_init(struct kvm *kvm);
2beb6dad 50void kvm_page_track_cleanup(struct kvm *kvm);
0eb05bf2 51
21ebbeda
XG
52void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
53 struct kvm_memory_slot *dont);
54int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
55 unsigned long npages);
f29d4d78
XG
56
57void kvm_slot_page_track_add_page(struct kvm *kvm,
58 struct kvm_memory_slot *slot, gfn_t gfn,
59 enum kvm_page_track_mode mode);
60void kvm_slot_page_track_remove_page(struct kvm *kvm,
61 struct kvm_memory_slot *slot, gfn_t gfn,
62 enum kvm_page_track_mode mode);
3d0c27ad
XG
63bool kvm_page_track_is_active(struct kvm_vcpu *vcpu, gfn_t gfn,
64 enum kvm_page_track_mode mode);
0eb05bf2
XG
65
66void
67kvm_page_track_register_notifier(struct kvm *kvm,
68 struct kvm_page_track_notifier_node *n);
69void
70kvm_page_track_unregister_notifier(struct kvm *kvm,
71 struct kvm_page_track_notifier_node *n);
72void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
73 int bytes);
ae7cd873 74void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot);
21ebbeda 75#endif