ANDROID: arm64: virt: Invalidate tlb once the balloon before reporting/inflating

Instead of invalidating the tlb of the guest every page it relinquishes,
invalidate once before the host is informed about the free pages.

Bug: 315173520
Change-Id: I8450fd552a27dfc791efa15e884982aeedaa3234
Signed-off-by: Prakruthi Deepak Heragu <quic_pheragu@quicinc.com>
This commit is contained in:
Prakruthi Deepak Heragu 2024-01-22 12:10:04 -08:00 committed by Keir Fraser
parent 4aedc102c3
commit 886c9d1fc2
7 changed files with 25 additions and 0 deletions

View File

@ -380788,6 +380788,15 @@ elf_symbol {
type_id: 0xf68b6f5e
full_name: "poll_state_synchronize_srcu"
}
elf_symbol {
id: 0x7bf7b7b1
name: "post_page_relinquish_tlb_inv"
is_defined: true
symbol_type: FUNCTION
crc: 0xcc8be82d
type_id: 0x10985193
full_name: "post_page_relinquish_tlb_inv"
}
elf_symbol {
id: 0xd612789c
name: "power_supply_am_i_supplied"
@ -407019,6 +407028,7 @@ interface {
symbol_id: 0x3020cd17
symbol_id: 0x25c6452e
symbol_id: 0x324d8228
symbol_id: 0x7bf7b7b1
symbol_id: 0xd612789c
symbol_id: 0x561323f1
symbol_id: 0x50bfe1d8

View File

@ -1143,6 +1143,7 @@
page_relinquish
page_reporting_register
page_reporting_unregister
post_page_relinquish_tlb_inv
register_oom_notifier
register_shrinker
__SetPageMovable

View File

@ -16,6 +16,7 @@ void kvm_init_ioremap_services(void);
struct hypervisor_ops {
#ifdef CONFIG_MEMORY_RELINQUISH
void (*page_relinquish)(struct page *page);
void (*post_page_relinquish_tlb_inv)(void);
#endif
};

View File

@ -11,5 +11,6 @@ struct page;
bool kvm_has_memrelinquish_services(void);
void page_relinquish(struct page *page);
void post_page_relinquish_tlb_inv(void);
#endif /* __ASM_MEM_RELINQUISH_H */

View File

@ -69,3 +69,10 @@ void page_relinquish(struct page *page)
hyp_ops.page_relinquish(page);
}
EXPORT_SYMBOL_GPL(page_relinquish);
void post_page_relinquish_tlb_inv(void)
{
if (hyp_ops.post_page_relinquish_tlb_inv)
hyp_ops.post_page_relinquish_tlb_inv();
}
EXPORT_SYMBOL_GPL(post_page_relinquish_tlb_inv);

View File

@ -149,6 +149,8 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns);
post_page_relinquish_tlb_inv();
/* We should always be able to add one buffer to an empty queue. */
virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
virtqueue_kick(vq);
@ -177,6 +179,8 @@ static int virtballoon_free_page_report(struct page_reporting_dev_info *pr_dev_i
if (WARN_ON_ONCE(err))
return err;
post_page_relinquish_tlb_inv();
virtqueue_kick(vq);
/* When host has read buffer, this completes via balloon_ack */

View File

@ -15,6 +15,7 @@
static inline bool kvm_has_memrelinquish_services(void) { return false; }
static inline void page_relinquish(struct page *page) { }
static inline void post_page_relinquish_tlb_inv(void) { }
#endif /* CONFIG_MEMORY_RELINQUISH */