Files
ack-tegra/include/linux/virtio_balloon.h
Prakruthi Deepak Heragu d3c5649103 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>
Signed-off-by: Elliot Berman <elliot.berman@oss.qualcomm.com>
2025-03-20 23:38:59 -07:00

54 lines
1.5 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2022 Google LLC
* Author: Keir Fraser <keirf@google.com>
*/
#ifndef _LINUX_VIRTIO_BALLOON_H
#define _LINUX_VIRTIO_BALLOON_H
#include <uapi/linux/virtio_balloon.h>
struct page;
#ifdef CONFIG_VIRTIO_BALLOON_HYP_OPS
struct virtio_balloon_hyp_ops {
bool (*page_relinquish_disallowed)(void);
void (*page_relinquish)(struct page *page, unsigned int nr);
void (*post_page_relinquish_tlb_inv)(void);
};
extern struct virtio_balloon_hyp_ops *virtio_balloon_hyp_ops;
static inline bool page_relinquish_disallowed(void)
{
if (virtio_balloon_hyp_ops &&
virtio_balloon_hyp_ops->page_relinquish_disallowed)
return virtio_balloon_hyp_ops->page_relinquish_disallowed();
return false;
}
static inline void page_relinquish(struct page *page, unsigned int nr)
{
if (virtio_balloon_hyp_ops &&
virtio_balloon_hyp_ops->page_relinquish_disallowed)
return virtio_balloon_hyp_ops->page_relinquish(page, nr);
}
static inline void post_page_relinquish_tlb_inv(void)
{
if (virtio_balloon_hyp_ops &&
virtio_balloon_hyp_ops->post_page_relinquish_tlb_inv)
return virtio_balloon_hyp_ops->post_page_relinquish_tlb_inv();
}
#else /* !CONFIG_VIRTIO_BALLOON_HYP_OPS */
static inline bool page_relinquish_disallowed(void) { return false; }
static inline void page_relinquish(struct page *page, unsigned int nr) { }
static inline void post_page_relinquish_tlb_inv(void) { }
#endif /* CONFIG_VIRTIO_BALLOON_HYP_OPS */
#endif /* _LINUX_VIRTIO_BALLOON_H */