Skip to content

Commit 0d15bf9

Browse files
committed
Merge tag 'kvm-x86-generic-6.6' of https://github.com/kvm-x86/linux into HEAD
Common KVM changes for 6.6: - Wrap kvm_{gfn,hva}_range.pte in a union to allow mmu_notifier events to pass action specific data without needing to constantly update the main handlers. - Drop unused function declarations
2 parents e0fb12c + 458933d commit 0d15bf9

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range)
17791779

17801780
bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
17811781
{
1782-
kvm_pfn_t pfn = pte_pfn(range->pte);
1782+
kvm_pfn_t pfn = pte_pfn(range->arg.pte);
17831783

17841784
if (!kvm->arch.mmu.pgt)
17851785
return false;

arch/mips/kvm/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range)
447447
bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
448448
{
449449
gpa_t gpa = range->start << PAGE_SHIFT;
450-
pte_t hva_pte = range->pte;
450+
pte_t hva_pte = range->arg.pte;
451451
pte_t *gpa_pte = kvm_mips_pte_for_gpa(kvm, NULL, gpa);
452452
pte_t old_pte;
453453

arch/riscv/kvm/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range)
553553
bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
554554
{
555555
int ret;
556-
kvm_pfn_t pfn = pte_pfn(range->pte);
556+
kvm_pfn_t pfn = pte_pfn(range->arg.pte);
557557

558558
if (!kvm->arch.pgd)
559559
return false;

arch/x86/kvm/mmu/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ static __always_inline bool kvm_handle_gfn_range(struct kvm *kvm,
15841584
for_each_slot_rmap_range(range->slot, PG_LEVEL_4K, KVM_MAX_HUGEPAGE_LEVEL,
15851585
range->start, range->end - 1, &iterator)
15861586
ret |= handler(kvm, iterator.rmap, range->slot, iterator.gfn,
1587-
iterator.level, range->pte);
1587+
iterator.level, range->arg.pte);
15881588

15891589
return ret;
15901590
}

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ static bool set_spte_gfn(struct kvm *kvm, struct tdp_iter *iter,
12411241
u64 new_spte;
12421242

12431243
/* Huge pages aren't expected to be modified without first being zapped. */
1244-
WARN_ON(pte_huge(range->pte) || range->start + 1 != range->end);
1244+
WARN_ON(pte_huge(range->arg.pte) || range->start + 1 != range->end);
12451245

12461246
if (iter->level != PG_LEVEL_4K ||
12471247
!is_shadow_present_pte(iter->old_spte))
@@ -1255,9 +1255,9 @@ static bool set_spte_gfn(struct kvm *kvm, struct tdp_iter *iter,
12551255
*/
12561256
tdp_mmu_iter_set_spte(kvm, iter, 0);
12571257

1258-
if (!pte_write(range->pte)) {
1258+
if (!pte_write(range->arg.pte)) {
12591259
new_spte = kvm_mmu_changed_pte_notifier_make_spte(iter->old_spte,
1260-
pte_pfn(range->pte));
1260+
pte_pfn(range->arg.pte));
12611261

12621262
tdp_mmu_iter_set_spte(kvm, iter, new_spte);
12631263
}

include/linux/kvm_host.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
190190
bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
191191
bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
192192
struct kvm_vcpu *except);
193-
bool kvm_make_cpus_request_mask(struct kvm *kvm, unsigned int req,
194-
unsigned long *vcpu_bitmap);
195193

196194
#define KVM_USERSPACE_IRQ_SOURCE_ID 0
197195
#define KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID 1
@@ -256,11 +254,15 @@ int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu);
256254
#endif
257255

258256
#ifdef KVM_ARCH_WANT_MMU_NOTIFIER
257+
union kvm_mmu_notifier_arg {
258+
pte_t pte;
259+
};
260+
259261
struct kvm_gfn_range {
260262
struct kvm_memory_slot *slot;
261263
gfn_t start;
262264
gfn_t end;
263-
pte_t pte;
265+
union kvm_mmu_notifier_arg arg;
264266
bool may_block;
265267
};
266268
bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range);
@@ -2160,8 +2162,6 @@ struct kvm_device_ops {
21602162
int (*mmap)(struct kvm_device *dev, struct vm_area_struct *vma);
21612163
};
21622164

2163-
void kvm_device_get(struct kvm_device *dev);
2164-
void kvm_device_put(struct kvm_device *dev);
21652165
struct kvm_device *kvm_device_from_filp(struct file *filp);
21662166
int kvm_register_device_ops(const struct kvm_device_ops *ops, u32 type);
21672167
void kvm_unregister_device_ops(u32 type);

virt/kvm/kvm_main.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ typedef void (*on_unlock_fn_t)(struct kvm *kvm);
551551
struct kvm_hva_range {
552552
unsigned long start;
553553
unsigned long end;
554-
pte_t pte;
554+
union kvm_mmu_notifier_arg arg;
555555
hva_handler_t handler;
556556
on_lock_fn_t on_lock;
557557
on_unlock_fn_t on_unlock;
@@ -572,6 +572,8 @@ static void kvm_null_fn(void)
572572
}
573573
#define IS_KVM_NULL_FN(fn) ((fn) == (void *)kvm_null_fn)
574574

575+
static const union kvm_mmu_notifier_arg KVM_MMU_NOTIFIER_NO_ARG;
576+
575577
/* Iterate over each memslot intersecting [start, last] (inclusive) range */
576578
#define kvm_for_each_memslot_in_hva_range(node, slots, start, last) \
577579
for (node = interval_tree_iter_first(&slots->hva_tree, start, last); \
@@ -616,7 +618,7 @@ static __always_inline int __kvm_handle_hva_range(struct kvm *kvm,
616618
* bother making these conditional (to avoid writes on
617619
* the second or later invocation of the handler).
618620
*/
619-
gfn_range.pte = range->pte;
621+
gfn_range.arg = range->arg;
620622
gfn_range.may_block = range->may_block;
621623

622624
/*
@@ -657,14 +659,14 @@ static __always_inline int __kvm_handle_hva_range(struct kvm *kvm,
657659
static __always_inline int kvm_handle_hva_range(struct mmu_notifier *mn,
658660
unsigned long start,
659661
unsigned long end,
660-
pte_t pte,
662+
union kvm_mmu_notifier_arg arg,
661663
hva_handler_t handler)
662664
{
663665
struct kvm *kvm = mmu_notifier_to_kvm(mn);
664666
const struct kvm_hva_range range = {
665667
.start = start,
666668
.end = end,
667-
.pte = pte,
669+
.arg = arg,
668670
.handler = handler,
669671
.on_lock = (void *)kvm_null_fn,
670672
.on_unlock = (void *)kvm_null_fn,
@@ -684,7 +686,6 @@ static __always_inline int kvm_handle_hva_range_no_flush(struct mmu_notifier *mn
684686
const struct kvm_hva_range range = {
685687
.start = start,
686688
.end = end,
687-
.pte = __pte(0),
688689
.handler = handler,
689690
.on_lock = (void *)kvm_null_fn,
690691
.on_unlock = (void *)kvm_null_fn,
@@ -718,6 +719,7 @@ static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
718719
pte_t pte)
719720
{
720721
struct kvm *kvm = mmu_notifier_to_kvm(mn);
722+
const union kvm_mmu_notifier_arg arg = { .pte = pte };
721723

722724
trace_kvm_set_spte_hva(address);
723725

@@ -733,7 +735,7 @@ static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
733735
if (!READ_ONCE(kvm->mmu_invalidate_in_progress))
734736
return;
735737

736-
kvm_handle_hva_range(mn, address, address + 1, pte, kvm_change_spte_gfn);
738+
kvm_handle_hva_range(mn, address, address + 1, arg, kvm_change_spte_gfn);
737739
}
738740

739741
void kvm_mmu_invalidate_begin(struct kvm *kvm, unsigned long start,
@@ -772,7 +774,6 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
772774
const struct kvm_hva_range hva_range = {
773775
.start = range->start,
774776
.end = range->end,
775-
.pte = __pte(0),
776777
.handler = kvm_unmap_gfn_range,
777778
.on_lock = kvm_mmu_invalidate_begin,
778779
.on_unlock = kvm_arch_guest_memory_reclaimed,
@@ -837,7 +838,6 @@ static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
837838
const struct kvm_hva_range hva_range = {
838839
.start = range->start,
839840
.end = range->end,
840-
.pte = __pte(0),
841841
.handler = (void *)kvm_null_fn,
842842
.on_lock = kvm_mmu_invalidate_end,
843843
.on_unlock = (void *)kvm_null_fn,
@@ -870,7 +870,8 @@ static int kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn,
870870
{
871871
trace_kvm_age_hva(start, end);
872872

873-
return kvm_handle_hva_range(mn, start, end, __pte(0), kvm_age_gfn);
873+
return kvm_handle_hva_range(mn, start, end, KVM_MMU_NOTIFIER_NO_ARG,
874+
kvm_age_gfn);
874875
}
875876

876877
static int kvm_mmu_notifier_clear_young(struct mmu_notifier *mn,

0 commit comments

Comments
 (0)