• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 71b755110581e7cab93f839c4617735fc682c679 Mon Sep 17 00:00:00 2001
2From: Keir Fraser <keirf@google.com>
3Date: Tue, 10 Dec 2024 08:28:12 +0000
4Subject: [PATCH 1/6] KVM: arm64: Define guest hypercalls
5
6---
7 include/linux/arm-smccc.h | 56 +++++++++++++++++++++++++++++++++++++++
8 1 file changed, 56 insertions(+)
9
10diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
11index 220c8c60e021..02dc0957ec2d 100644
12--- a/include/linux/arm-smccc.h
13+++ b/include/linux/arm-smccc.h
14@@ -112,6 +112,14 @@
15 /* KVM "vendor specific" services */
16 #define ARM_SMCCC_KVM_FUNC_FEATURES		0
17 #define ARM_SMCCC_KVM_FUNC_PTP			1
18+#define ARM_SMCCC_KVM_FUNC_HYP_MEMINFO		2
19+#define ARM_SMCCC_KVM_FUNC_MEM_SHARE		3
20+#define ARM_SMCCC_KVM_FUNC_MEM_UNSHARE		4
21+#define ARM_SMCCC_KVM_FUNC_MMIO_GUARD_INFO	5
22+#define ARM_SMCCC_KVM_FUNC_MMIO_GUARD_ENROLL	6
23+#define ARM_SMCCC_KVM_FUNC_MMIO_GUARD_MAP	7
24+#define ARM_SMCCC_KVM_FUNC_MMIO_GUARD_UNMAP	8
25+#define ARM_SMCCC_KVM_FUNC_MEM_RELINQUISH	9
26 #define ARM_SMCCC_KVM_FUNC_FEATURES_2		127
27 #define ARM_SMCCC_KVM_NUM_FUNCS			128
28
29@@ -134,6 +142,54 @@
30 			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
31 			   ARM_SMCCC_KVM_FUNC_PTP)
32
33+#define ARM_SMCCC_VENDOR_HYP_KVM_HYP_MEMINFO_FUNC_ID			\
34+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
35+			   ARM_SMCCC_SMC_64,				\
36+			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
37+			   ARM_SMCCC_KVM_FUNC_HYP_MEMINFO)
38+
39+#define ARM_SMCCC_VENDOR_HYP_KVM_MEM_SHARE_FUNC_ID			\
40+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
41+			   ARM_SMCCC_SMC_64,				\
42+			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
43+			   ARM_SMCCC_KVM_FUNC_MEM_SHARE)
44+
45+#define ARM_SMCCC_VENDOR_HYP_KVM_MEM_UNSHARE_FUNC_ID			\
46+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
47+			   ARM_SMCCC_SMC_64,				\
48+			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
49+			   ARM_SMCCC_KVM_FUNC_MEM_UNSHARE)
50+
51+#define ARM_SMCCC_VENDOR_HYP_KVM_MEM_RELINQUISH_FUNC_ID			\
52+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
53+			   ARM_SMCCC_SMC_64,				\
54+			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
55+			   ARM_SMCCC_KVM_FUNC_MEM_RELINQUISH)
56+
57+#define ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_INFO_FUNC_ID		\
58+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
59+			   ARM_SMCCC_SMC_64,				\
60+			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
61+			   ARM_SMCCC_KVM_FUNC_MMIO_GUARD_INFO)
62+
63+#define ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_ENROLL_FUNC_ID		\
64+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
65+			   ARM_SMCCC_SMC_64,				\
66+			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
67+			   ARM_SMCCC_KVM_FUNC_MMIO_GUARD_ENROLL)
68+
69+#define ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_MAP_FUNC_ID			\
70+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
71+			   ARM_SMCCC_SMC_64,				\
72+			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
73+			   ARM_SMCCC_KVM_FUNC_MMIO_GUARD_MAP)
74+
75+#define ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_UNMAP_FUNC_ID		\
76+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
77+			   ARM_SMCCC_SMC_64,				\
78+			   ARM_SMCCC_OWNER_VENDOR_HYP,			\
79+			   ARM_SMCCC_KVM_FUNC_MMIO_GUARD_UNMAP)
80+
81 /* ptp_kvm counter type ID */
82 #define KVM_PTP_VIRT_COUNTER			0
83 #define KVM_PTP_PHYS_COUNTER			1
84--
852.47.0.338.g60cca15819-goog
86
87
88From 14104b188b1ce2b2e227a9f5426fc8cb4d777461 Mon Sep 17 00:00:00 2001
89From: Keir Fraser <keirf@google.com>
90Date: Thu, 26 May 2022 14:22:34 +0000
91Subject: [PATCH 2/6] ANDROID: Define mem_relinquish interface for releasing
92 memory to a hypervisor.
93
94On PKVM/ARM64 this uses the ARM SMCCC relinquish hypercall when available.
95
96Bug: 240239989
97Change-Id: Ifa85b641a48f348a2364cf8c6b06b6417f1eeedb
98Signed-off-by: Keir Fraser <keirf@google.com>
99Signed-off-by: Quentin Perret <qperret@google.com>
100---
101 arch/Kconfig                            |  3 ++
102 arch/arm64/Kconfig                      |  1 +
103 arch/arm64/include/asm/hypervisor.h     |  7 +++
104 arch/arm64/include/asm/mem_relinquish.h | 12 +++++
105 arch/arm64/kernel/setup.c               |  6 +++
106 arch/arm64/mm/Makefile                  |  1 +
107 arch/arm64/mm/mem_relinquish.c          | 58 +++++++++++++++++++++++++
108 drivers/firmware/smccc/kvm_guest.c      |  2 +
109 include/linux/mem_relinquish.h          | 20 +++++++++
110 9 files changed, 110 insertions(+)
111 create mode 100644 arch/arm64/include/asm/mem_relinquish.h
112 create mode 100644 arch/arm64/mm/mem_relinquish.c
113 create mode 100644 include/linux/mem_relinquish.h
114
115diff --git a/arch/Kconfig b/arch/Kconfig
116index 8f138e580d1a..b5fb130a07e2 100644
117--- a/arch/Kconfig
118+++ b/arch/Kconfig
119@@ -1316,6 +1316,9 @@ config RELR
120 config ARCH_HAS_MEM_ENCRYPT
121 	bool
122
123+config ARCH_HAS_MEM_RELINQUISH
124+	bool
125+
126 config ARCH_HAS_CC_PLATFORM
127 	bool
128
129diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
130index 505c8a1ccbe0..935c16e89677 100644
131--- a/arch/arm64/Kconfig
132+++ b/arch/arm64/Kconfig
133@@ -31,6 +31,7 @@ config ARM64
134 	select ARCH_HAS_KCOV
135 	select ARCH_HAS_KEEPINITRD
136 	select ARCH_HAS_MEMBARRIER_SYNC_CORE
137+	select ARCH_HAS_MEM_RELINQUISH
138 	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
139 	select ARCH_HAS_PTE_DEVMAP
140 	select ARCH_HAS_PTE_SPECIAL
141diff --git a/arch/arm64/include/asm/hypervisor.h b/arch/arm64/include/asm/hypervisor.h
142index 0ae427f352c8..88f42d688eb0 100644
143--- a/arch/arm64/include/asm/hypervisor.h
144+++ b/arch/arm64/include/asm/hypervisor.h
145@@ -5,6 +5,13 @@
146 #include <asm/xen/hypervisor.h>
147
148 void kvm_init_hyp_services(void);
149+void kvm_arm_init_hyp_services(void);
150 bool kvm_arm_hyp_service_available(u32 func_id);
151
152+#ifdef CONFIG_MEMORY_BALLOON
153+void kvm_init_memrelinquish_services(void);
154+#else
155+static inline void kvm_init_memrelinquish_services(void) {}
156+#endif
157+
158 #endif
159diff --git a/arch/arm64/include/asm/mem_relinquish.h b/arch/arm64/include/asm/mem_relinquish.h
160new file mode 100644
161index 000000000000..a4ace9e6e413
162--- /dev/null
163+++ b/arch/arm64/include/asm/mem_relinquish.h
164@@ -0,0 +1,12 @@
165+/* SPDX-License-Identifier: GPL-2.0-only */
166+/*
167+ * Copyright (C) 2022 Google LLC
168+ * Author: Keir Fraser <keirf@google.com>
169+ */
170+
171+#ifndef __ASM_MEM_RELINQUISH_H
172+#define __ASM_MEM_RELINQUISH_H
173+
174+void page_relinquish(struct page *page);
175+
176+#endif	/* __ASM_MEM_RELINQUISH_H */
177diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
178index fea3223704b6..f55477b6c02e 100644
179--- a/arch/arm64/kernel/setup.c
180+++ b/arch/arm64/kernel/setup.c
181@@ -40,6 +40,7 @@
182 #include <asm/elf.h>
183 #include <asm/cpufeature.h>
184 #include <asm/cpu_ops.h>
185+#include <asm/hypervisor.h>
186 #include <asm/kasan.h>
187 #include <asm/numa.h>
188 #include <asm/sections.h>
189@@ -438,3 +439,8 @@ static int __init register_arm64_panic_block(void)
190 	return 0;
191 }
192 device_initcall(register_arm64_panic_block);
193+
194+void kvm_arm_init_hyp_services(void)
195+{
196+	kvm_init_memrelinquish_services();
197+}
198diff --git a/arch/arm64/mm/Makefile b/arch/arm64/mm/Makefile
199index ff1e800ba7a1..f6c1f3511907 100644
200--- a/arch/arm64/mm/Makefile
201+++ b/arch/arm64/mm/Makefile
202@@ -3,6 +3,7 @@ obj-y				:= dma-mapping.o extable.o fault.o init.o \
203 				   cache.o copypage.o flush.o \
204 				   ioremap.o mmap.o pgd.o mmu.o \
205 				   context.o proc.o pageattr.o
206+obj-$(CONFIG_MEMORY_BALLOON)	+= mem_relinquish.o
207 obj-$(CONFIG_HUGETLB_PAGE)	+= hugetlbpage.o
208 obj-$(CONFIG_PTDUMP_CORE)	+= ptdump.o
209 obj-$(CONFIG_PTDUMP_DEBUGFS)	+= ptdump_debugfs.o
210diff --git a/arch/arm64/mm/mem_relinquish.c b/arch/arm64/mm/mem_relinquish.c
211new file mode 100644
212index 000000000000..c95bcbb14d92
213--- /dev/null
214+++ b/arch/arm64/mm/mem_relinquish.c
215@@ -0,0 +1,58 @@
216+/* SPDX-License-Identifier: GPL-2.0-only */
217+/*
218+ * Copyright (C) 2022 Google LLC
219+ * Author: Keir Fraser <keirf@google.com>
220+ */
221+
222+#include <linux/arm-smccc.h>
223+#include <linux/memory.h>
224+#include <linux/mm.h>
225+#include <linux/types.h>
226+
227+#include <asm/hypervisor.h>
228+
229+static unsigned long memshare_granule_sz;
230+
231+void kvm_init_memrelinquish_services(void)
232+{
233+	int i;
234+	struct arm_smccc_res res;
235+	const u32 funcs[] = {
236+		ARM_SMCCC_KVM_FUNC_HYP_MEMINFO,
237+		ARM_SMCCC_KVM_FUNC_MEM_RELINQUISH,
238+	};
239+
240+	for (i = 0; i < ARRAY_SIZE(funcs); ++i) {
241+		if (!kvm_arm_hyp_service_available(funcs[i]))
242+			return;
243+	}
244+
245+	arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_HYP_MEMINFO_FUNC_ID,
246+			     0, 0, 0, &res);
247+	if (res.a0 > PAGE_SIZE) /* Includes error codes */
248+		return;
249+
250+	memshare_granule_sz = res.a0;
251+}
252+
253+void page_relinquish(struct page *page)
254+{
255+	phys_addr_t phys, end;
256+	u32 func_id = ARM_SMCCC_VENDOR_HYP_KVM_MEM_RELINQUISH_FUNC_ID;
257+
258+	if (!memshare_granule_sz)
259+		return;
260+
261+	phys = page_to_phys(page);
262+	end = phys + PAGE_SIZE;
263+
264+	while (phys < end) {
265+		struct arm_smccc_res res;
266+
267+		arm_smccc_1_1_invoke(func_id, phys, 0, 0, &res);
268+		BUG_ON(res.a0 != SMCCC_RET_SUCCESS);
269+
270+		phys += memshare_granule_sz;
271+	}
272+}
273+EXPORT_SYMBOL_GPL(page_relinquish);
274diff --git a/drivers/firmware/smccc/kvm_guest.c b/drivers/firmware/smccc/kvm_guest.c
275index 89a68e7eeaa6..0b6a1b2a0857 100644
276--- a/drivers/firmware/smccc/kvm_guest.c
277+++ b/drivers/firmware/smccc/kvm_guest.c
278@@ -39,6 +39,8 @@ void __init kvm_init_hyp_services(void)
279
280 	pr_info("hypervisor services detected (0x%08lx 0x%08lx 0x%08lx 0x%08lx)\n",
281 		 res.a3, res.a2, res.a1, res.a0);
282+
283+	kvm_arm_init_hyp_services();
284 }
285
286 bool kvm_arm_hyp_service_available(u32 func_id)
287diff --git a/include/linux/mem_relinquish.h b/include/linux/mem_relinquish.h
288new file mode 100644
289index 000000000000..6b7bf861d92d
290--- /dev/null
291+++ b/include/linux/mem_relinquish.h
292@@ -0,0 +1,20 @@
293+/* SPDX-License-Identifier: GPL-2.0-only */
294+/*
295+ * Copyright (C) 2022 Google LLC
296+ * Author: Keir Fraser <keirf@google.com>
297+ */
298+
299+#ifndef __MEM_RELINQUISH_H__
300+#define __MEM_RELINQUISH_H__
301+
302+#ifdef CONFIG_ARCH_HAS_MEM_RELINQUISH
303+
304+#include <asm/mem_relinquish.h>
305+
306+#else	/* !CONFIG_ARCH_HAS_MEM_RELINQUISH */
307+
308+static inline void page_relinquish(struct page *page) { }
309+
310+#endif	/* CONFIG_ARCH_HAS_MEM_RELINQUISH */
311+
312+#endif	/* __MEM_RELINQUISH_H__ */
313--
3142.47.0.338.g60cca15819-goog
315
316
317From 4de68c3d8410bef6a5544caf3835eba8357e08d1 Mon Sep 17 00:00:00 2001
318From: Keir Fraser <keirf@google.com>
319Date: Wed, 9 Nov 2022 13:53:28 +0000
320Subject: [PATCH 3/6] ANDROID: KVM: arm64: memory balloon: Notify hyp when
321 ballooning
322
323When running as a protected VM, the hypervisor isolates the VM's
324memory pages from the host. Returning ownership of a VM page
325therefore requires hypervisor involvement, and acknowledgement from
326the protected VM that it is voluntarily cooperating.
327
328To this end, notify pages via the new relinquish hypercall when they
329are entered into the memory balloon.
330
331Bug: 240239989
332Change-Id: Ic89b45312a7478ddff081a934d99e693eded92dc
333Signed-off-by: Keir Fraser <keirf@google.com>
334Signed-off-by: Quentin Perret <qperret@google.com>
335---
336 include/linux/balloon_compaction.h | 3 +++
337 1 file changed, 3 insertions(+)
338
339diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h
340index 5ca2d5699620..318cfe8b57a6 100644
341--- a/include/linux/balloon_compaction.h
342+++ b/include/linux/balloon_compaction.h
343@@ -43,6 +43,7 @@
344 #include <linux/err.h>
345 #include <linux/fs.h>
346 #include <linux/list.h>
347+#include <linux/mem_relinquish.h>
348
349 /*
350  * Balloon device information descriptor.
351@@ -95,6 +96,7 @@ static inline void balloon_page_insert(struct balloon_dev_info *balloon,
352 	__SetPageMovable(page, &balloon_mops);
353 	set_page_private(page, (unsigned long)balloon);
354 	list_add(&page->lru, &balloon->pages);
355+	page_relinquish(page);
356 }
357
358 /*
359@@ -139,6 +141,7 @@ static inline void balloon_page_insert(struct balloon_dev_info *balloon,
360 {
361 	__SetPageOffline(page);
362 	list_add(&page->lru, &balloon->pages);
363+	page_relinquish(page);
364 }
365
366 static inline void balloon_page_delete(struct page *page)
367--
3682.47.0.338.g60cca15819-goog
369
370
371From f34713f8af1fe2ed50297743315606f880fcbd03 Mon Sep 17 00:00:00 2001
372From: Keir Fraser <keirf@google.com>
373Date: Thu, 18 Aug 2022 10:41:35 +0000
374Subject: [PATCH 4/6] ANDROID: KVM: arm64: balloon: Notify hyp before reporting
375 free pages to host
376
377When running as a protected VM, the hypervisor isolates the VM's
378memory pages from the host. Returning ownership of a VM page therefore
379requires hypervisor involvement, and acknowledgement from the
380protected VM that it is voluntarily cooperating.
381
382To this end, notify pages via the new relinquish hypercall when they
383are being reported to the host as free and available for temporary
384reclaim.
385
386Bug: 240239989
387Change-Id: I8718e468be63c3aacb2f79ff141fbcedd6d19b56
388Signed-off-by: Keir Fraser <keirf@google.com>
389Signed-off-by: Quentin Perret <qperret@google.com>
390---
391 mm/page_reporting.c | 7 ++++++-
392 1 file changed, 6 insertions(+), 1 deletion(-)
393
394diff --git a/mm/page_reporting.c b/mm/page_reporting.c
395index 382958eef8a9..5c4b1fb73187 100644
396--- a/mm/page_reporting.c
397+++ b/mm/page_reporting.c
398@@ -7,6 +7,7 @@
399 #include <linux/module.h>
400 #include <linux/delay.h>
401 #include <linux/scatterlist.h>
402+#include <linux/mem_relinquish.h>
403
404 #include "page_reporting.h"
405 #include "internal.h"
406@@ -120,7 +121,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
407 	unsigned int page_len = PAGE_SIZE << order;
408 	struct page *page, *next;
409 	long budget;
410-	int err = 0;
411+	int i, err = 0;
412
413 	/*
414 	 * Perform early check, if free area is empty there is
415@@ -175,6 +176,10 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
416 			--(*offset);
417 			sg_set_page(&sgl[*offset], page, page_len, 0);
418
419+			/* Notify hyp that these pages are reclaimable. */
420+			for (i = 0; i < (1<<order); i++)
421+				page_relinquish(page+i);
422+
423 			continue;
424 		}
425
426--
4272.47.0.338.g60cca15819-goog
428
429
430From 429502a582c1c900681a82fb94f9078d0569c731 Mon Sep 17 00:00:00 2001
431From: Keir Fraser <keirf@google.com>
432Date: Thu, 18 Aug 2022 11:20:25 +0000
433Subject: [PATCH 5/6] ANDROID: virtio_balloon: Do not translate reported pages
434 through DMA API
435
436The free-page reporting and hinting queues do not pass arrays of page
437addresses (like the basic inflate queue) but instead pass the free page
438ranges as buffers. This does not work well with DMA API: The host wants
439to know the GPA, not an IOVA.
440
441For these two virtqueues, disable DMA API and pass through buffers untranslated.
442
443Bug: 240239989
444Change-Id: I2d13a8b7e8f6775819de7fe96f4579afa08b1300
445Signed-off-by: Keir Fraser <keirf@google.com>
446[ qperret@: Fixed minor context conflict in virtio.h ]
447Signed-off-by: Quentin Perret <qperret@google.com>
448---
449 drivers/virtio/virtio_balloon.c |  8 ++++++--
450 drivers/virtio/virtio_ring.c    | 10 ++++++++++
451 include/linux/virtio.h          |  2 ++
452 3 files changed, 18 insertions(+), 2 deletions(-)
453
454diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
455index 3f78a3a1eb75..4c85349024c1 100644
456--- a/drivers/virtio/virtio_balloon.c
457+++ b/drivers/virtio/virtio_balloon.c
458@@ -553,11 +553,15 @@ static int init_vqs(struct virtio_balloon *vb)
459 		virtqueue_kick(vb->stats_vq);
460 	}
461
462-	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT))
463+	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
464 		vb->free_page_vq = vqs[VIRTIO_BALLOON_VQ_FREE_PAGE];
465+		virtqueue_disable_dma_api_for_buffers(vb->free_page_vq);
466+	}
467
468-	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING))
469+	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING)) {
470 		vb->reporting_vq = vqs[VIRTIO_BALLOON_VQ_REPORTING];
471+		virtqueue_disable_dma_api_for_buffers(vb->reporting_vq);
472+	}
473
474 	return 0;
475 }
476diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
477index 2e7689bb933b..3eca7140bd80 100644
478--- a/drivers/virtio/virtio_ring.c
479+++ b/drivers/virtio/virtio_ring.c
480@@ -2863,4 +2863,14 @@ const struct vring *virtqueue_get_vring(struct virtqueue *vq)
481 }
482 EXPORT_SYMBOL_GPL(virtqueue_get_vring);
483
484+/*
485+ * Prevents use of DMA API for buffers passed via the specified virtqueue.
486+ * DMA API may still be used for the vrings themselves.
487+ */
488+void virtqueue_disable_dma_api_for_buffers(struct virtqueue *vq)
489+{
490+	to_vvq(vq)->use_dma_api = false;
491+}
492+EXPORT_SYMBOL_GPL(virtqueue_disable_dma_api_for_buffers);
493+
494 MODULE_LICENSE("GPL");
495diff --git a/include/linux/virtio.h b/include/linux/virtio.h
496index dcab9c7e8784..34e936343ae4 100644
497--- a/include/linux/virtio.h
498+++ b/include/linux/virtio.h
499@@ -96,6 +96,8 @@ dma_addr_t virtqueue_get_used_addr(struct virtqueue *vq);
500 int virtqueue_resize(struct virtqueue *vq, u32 num,
501 		     void (*recycle)(struct virtqueue *vq, void *buf));
502
503+void virtqueue_disable_dma_api_for_buffers(struct virtqueue *vq);
504+
505 /**
506  * struct virtio_device - representation of a device using virtio
507  * @index: unique position on the virtio bus
508--
5092.47.0.338.g60cca15819-goog
510
511
512From 49de3a1d0bb478858eb66a5b853f0d0a5b1909dc Mon Sep 17 00:00:00 2001
513From: Keir Fraser <keirf@google.com>
514Date: Thu, 17 Nov 2022 14:59:38 +0000
515Subject: [PATCH 6/6] ANDROID: virtio_balloon: Do not clear
516 VIRTIO_F_ACCESS_PLATFORM
517
518This essentially reverts commit e41b1355508debe45fda33
519"virtio_balloon: disable VIOMMU support".
520
521Although the virtio_balloon driver does not translate through a
522VIOMMU (or bounce buffer) the pages that it sends to the device,
523it *does* need to perform these translations on the virtio rings
524themselves.
525
526This fixes virtio_balloon initialisation inside a PKVM/ARM64
527protected virtual machine.
528
529Bug: 240239989
530Change-Id: I2a84eec870fd638223b231e5c4d1c27216dc40a2
531Signed-off-by: Keir Fraser <keirf@google.com>
532Signed-off-by: Quentin Perret <qperret@google.com>
533---
534 drivers/virtio/virtio_balloon.c | 1 -
535 1 file changed, 1 deletion(-)
536
537diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
538index 4c85349024c1..72fe24005bc0 100644
539--- a/drivers/virtio/virtio_balloon.c
540+++ b/drivers/virtio/virtio_balloon.c
541@@ -1097,7 +1097,6 @@ static int virtballoon_validate(struct virtio_device *vdev)
542 	else if (!virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON))
543 		__virtio_clear_bit(vdev, VIRTIO_BALLOON_F_REPORTING);
544
545-	__virtio_clear_bit(vdev, VIRTIO_F_ACCESS_PLATFORM);
546 	return 0;
547 }
548
549--
5502.47.0.338.g60cca15819-goog
551