* [PATCH v1 0/2] vmw_balloon: Add arm64 support
@ 2026-12-02 21:38 Jerrin Shaji George
2026-12-02 21:38 ` [PATCH v1 1/2] arm64: Add VMware virtual I/O port definitions Jerrin Shaji George
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jerrin Shaji George @ 2026-12-02 21:38 UTC (permalink / raw)
To: gregkh, arnd
Cc: Cyprien Laplace, Keerthana K, Jerrin Shaji George, Ajay Kaher,
Alexey Makhalov, Broadcom internal kernel review list,
Catalin Marinas, Mark Rutland, Will Deacon, linux-arm-kernel,
linux-kernel, virtualization, x86
VMware's hypervisor lets arm64 guests use the same I/O port based
backdoor interfaces as x86 guests by executing HVC #0x86, which asks
the hypervisor to emulate an x86 I/O port instruction. This series uses
that mechanism to run the VMware balloon driver in arm64 guests, so that
VMware can reclaim memory from them the way it already does for x86.
Patch 1 adds arch/arm64/include/asm/vmware.h with the definitions
needed to build the w7 value that tells the hypervisor which I/O
instruction to emulate. Patch 2 adds the arm64 transport and VMware
detection to the balloon driver.
The interface is as follows. Registers x0-x6 correspond to the x86
AX, BX, CX, DX, SI, DI and BP, and w7 describes the instruction to
emulate: bits [1:0] hold the access size, bit 2 selects IN rather than
OUT, and bit 3 says the port number is in DX rather than an immediate.
The balloon uses a 32-bit IN with the port in DX.
Notes on the design:
- Only the single hypervisor call is architecture specific. The x86
"inl" sequence moves into __vmballoon_call() and an arm64 variant is
added next to it. The x86 behavior is unchanged.
- The vmware_hypercall*() helpers in arch/x86/include/asm/vmware.h do
not fit the balloon, which uses its own magic and port and needs
full-width outputs, so the driver keeps a local call.
- arm64 has no equivalent of x86_hyper_type, so the driver returns
-ENODEV unless the SMCCC conduit is HVC and the DMI system vendor is
"VMware, Inc.", which VMware's arm64 firmware reports in SMBIOS.
- The hypervisor assumes 4 KiB pages, so on arm64 the driver depends
on ARM64_4K_PAGES. Big-endian is excluded as well.
Testing:
- Built with W=1 and KCFLAGS=-Werror on v7.4-rc4 with GCC 15.2.0:
arm64 defconfig with VMWARE_BALLOON=m, and x86_64 defconfig with
HYPERVISOR_GUEST and VMWARE_BALLOON=m.
- Ran the driver in an arm64 guest with 4 KiB pages on ESX 9.1. The
guest has 8 GiB of memory, about 6 GiB of it clean page cache. With
a 5 GiB memory limit set on the VM, the balloon inflated to its
target of 777216 pages (about 3 GiB), reclaiming the page cache.
After the limit was removed it deflated back to 0 and free memory
returned.
- VMware's internal ESX balloon test group was also run against an
arm64 guest with this series, and passed.
- x86 was only build tested.
Origin: this is based on the VMware Photon OS arm64 patches by Cyprien
Laplace and Keerthana K, linked from the individual patches.
AI assistance: parts of this series were prepared with the help of LLM
coding assistants, namely porting the Photon patches to current
mainline, and reviewing the hypervisor call interface and register
usage. I have reviewed all of the code and take responsibility for it.
Jerrin Shaji George (2):
arm64: Add VMware virtual I/O port definitions
vmw_balloon: Add arm64 support
MAINTAINERS | 1 +
arch/arm64/include/asm/vmware.h | 26 +++++++++++
drivers/misc/Kconfig | 4 +-
drivers/misc/vmw_balloon.c | 82 +++++++++++++++++++++++++++------
4 files changed, 98 insertions(+), 15 deletions(-)
create mode 100644 arch/arm64/include/asm/vmware.h
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
--
2.52.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 1/2] arm64: Add VMware virtual I/O port definitions
2026-12-02 21:38 [PATCH v1 0/2] vmw_balloon: Add arm64 support Jerrin Shaji George
@ 2026-12-02 21:38 ` Jerrin Shaji George
2026-12-02 21:38 ` [PATCH v1 2/2] vmw_balloon: Add arm64 support Jerrin Shaji George
2026-12-02 21:44 ` [PATCH v1 0/2] " sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: Jerrin Shaji George @ 2026-12-02 21:38 UTC (permalink / raw)
To: gregkh, arnd
Cc: Cyprien Laplace, Keerthana K, Jerrin Shaji George, Ajay Kaher,
Alexey Makhalov, Broadcom internal kernel review list,
Catalin Marinas, Will Deacon, Mark Rutland, linux-kernel,
virtualization, x86, linux-arm-kernel
VMware's hypervisor lets arm64 guests use x86 I/O port interfaces by
executing HVC #0x86. The guest places the x86 registers AX through BP
in x0-x6 and describes the instruction to emulate in w7.
Add arch/arm64/include/asm/vmware.h with the definitions needed to
build the w7 value. This will be used by the VMware balloon driver.
Based on the VMware Photon OS arm64 patches by Cyprien Laplace and
Keerthana K.
Link: https://github.com/vmware/photon/blob/5.0/SPECS/92/linux/aarch64/0004-arm64-kmsg-dumper-for-VMware-hypervisor.patch
Co-developed-by: Keerthana K <keerthana.kalyanasundaram@broadcom.com>
Signed-off-by: Keerthana K <keerthana.kalyanasundaram@broadcom.com>
Signed-off-by: Jerrin Shaji George <jerrin.shaji-george@broadcom.com>
---
MAINTAINERS | 1 +
arch/arm64/include/asm/vmware.h | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
create mode 100644 arch/arm64/include/asm/vmware.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 44540a1eb2b8..055ac1a3229d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -29966,6 +29966,7 @@ L: virtualization@lists.linux.dev
L: x86@kernel.org
S: Supported
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/vmware
+F: arch/arm64/include/asm/vmware.h
F: arch/x86/include/asm/vmware.h
F: arch/x86/kernel/cpu/vmware.c
diff --git a/arch/arm64/include/asm/vmware.h b/arch/arm64/include/asm/vmware.h
new file mode 100644
index 000000000000..2b92a8f87011
--- /dev/null
+++ b/arch/arm64/include/asm/vmware.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+/*
+ * Copyright (C) 2021, VMware, Inc.
+ */
+#ifndef _ASM_ARM64_VMWARE_H
+#define _ASM_ARM64_VMWARE_H
+
+#include <linux/bits.h>
+
+/*
+ * VMware virtualizes x86 I/O port instructions on arm64 using HVC #0x86.
+ * Registers x0 through x6 correspond to x86 AX, BX, CX, DX, SI, DI and BP.
+ * Register w7 describes the I/O instruction to emulate.
+ */
+#define X86_IO_MAGIC 0x86
+
+/* Transfer size in w7[1:0]: 0 = byte, 1 = word, 2 = doubleword. */
+#define X86_IO_W7_SIZE_SHIFT 0
+
+/* Read from the port (IN), rather than write to it (OUT). */
+#define X86_IO_W7_DIR BIT(2)
+
+/* Use the port number in DX (w3), rather than an immediate port number. */
+#define X86_IO_W7_WITH BIT(3)
+
+#endif /* _ASM_ARM64_VMWARE_H */
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] vmw_balloon: Add arm64 support
2026-12-02 21:38 [PATCH v1 0/2] vmw_balloon: Add arm64 support Jerrin Shaji George
2026-12-02 21:38 ` [PATCH v1 1/2] arm64: Add VMware virtual I/O port definitions Jerrin Shaji George
@ 2026-12-02 21:38 ` Jerrin Shaji George
2026-12-02 21:44 ` [PATCH v1 0/2] " sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: Jerrin Shaji George @ 2026-12-02 21:38 UTC (permalink / raw)
To: gregkh, arnd
Cc: Cyprien Laplace, Keerthana K, Jerrin Shaji George,
Broadcom internal kernel review list, linux-kernel
This patch adds arm64 support for the VMware balloon driver. On
arm64 the hypervisor handles the balloon's x86 I/O port protocol
through HVC #0x86.
The hypervisor assumes 4 KiB pages, so depend on ARM64_4K_PAGES, and
keep big-endian excluded.
Return -ENODEV unless the guest is VMware. On arm64 that means the SMCCC
conduit is HVC and the DMI system vendor is "VMware, Inc.", which
VMware's arm64 firmware reports in SMBIOS.
Based on the VMware Photon OS patches by Cyprien Laplace and
Keerthana K.
Link: https://github.com/vmware/photon/blob/5.0/SPECS/92/linux/aarch64/0005-vmw_balloon-add-arm64-support.patch
Link: https://github.com/vmware/photon/blob/5.0/SPECS/92/linux/aarch64/0003-arm64-VMware-hypervisor-detection.patch
Co-developed-by: Keerthana K <keerthana.kalyanasundaram@broadcom.com>
Signed-off-by: Keerthana K <keerthana.kalyanasundaram@broadcom.com>
Signed-off-by: Jerrin Shaji George <jerrin.shaji-george@broadcom.com>
---
drivers/misc/Kconfig | 4 +-
drivers/misc/vmw_balloon.c | 82 +++++++++++++++++++++++++++++++-------
2 files changed, 71 insertions(+), 15 deletions(-)
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index c40e89cc5724..127f75d9aff5 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -346,7 +346,9 @@ config DS1682
config VMWARE_BALLOON
tristate "VMware Balloon Driver"
- depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST
+ depends on VMWARE_VMCI
+ depends on (X86 && HYPERVISOR_GUEST) || (ARM64 && ARM64_4K_PAGES)
+ depends on !CPU_BIG_ENDIAN
select BALLOON
help
This is VMware physical memory management driver which acts
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 3edb934dd7fd..6b4232b11dcb 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -32,7 +32,14 @@
#include <linux/balloon.h>
#include <linux/vmw_vmci_defs.h>
#include <linux/vmw_vmci_api.h>
+#include <linux/dmi.h>
+
+#ifdef CONFIG_X86
#include <asm/hypervisor.h>
+#elif defined(CONFIG_ARM64)
+#include <linux/arm-smccc.h>
+#include <asm/vmware.h>
+#endif
MODULE_AUTHOR("VMware, Inc.");
MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
@@ -447,26 +454,56 @@ static inline void vmballoon_stats_page_add(struct vmballoon *b,
atomic64_add(val, &b->stats->page_stat[stat][size]);
}
+#ifdef CONFIG_X86
+static inline unsigned long
+__vmballoon_call(unsigned long cmd, unsigned long arg1, unsigned long arg2,
+ unsigned long *caps, unsigned long *result)
+{
+ unsigned long status, dummy2, dummy3;
+
+ asm volatile ("inl %%dx"
+ : "=a" (status), "=c" (*caps), "=d" (dummy2),
+ "=b" (*result), "=S" (dummy3)
+ : "0" (VMW_BALLOON_HV_MAGIC), "1" (cmd),
+ "2" (VMW_BALLOON_HV_PORT), "3" (arg1), "4" (arg2)
+ : "memory");
+
+ return status;
+}
+#elif defined(CONFIG_ARM64)
+static inline unsigned long
+__vmballoon_call(unsigned long cmd, unsigned long arg1, unsigned long arg2,
+ unsigned long *caps, unsigned long *result)
+{
+ register u64 x0 asm("x0") = VMW_BALLOON_HV_MAGIC;
+ register u64 x1 asm("x1") = arg1;
+ register u32 w2 asm("w2") = cmd;
+ register u32 w3 asm("w3") = VMW_BALLOON_HV_PORT;
+ register u64 x4 asm("x4") = arg2;
+ register u32 w7 asm("w7") = X86_IO_W7_WITH | X86_IO_W7_DIR |
+ (2 << X86_IO_W7_SIZE_SHIFT);
+
+ /* x1 carries the full target when 64-bit targets are negotiated. */
+ asm volatile ("hvc %[magic]"
+ : "+r" (x0), "+r" (x1), "+r" (w2), "+r" (w3), "+r" (x4)
+ : "r" (w7), [magic] "i" (X86_IO_MAGIC)
+ : "cc", "memory");
+
+ *caps = w2;
+ *result = x1;
+ return x0;
+}
+#endif
+
static inline unsigned long
__vmballoon_cmd(struct vmballoon *b, unsigned long cmd, unsigned long arg1,
unsigned long arg2, unsigned long *result)
{
- unsigned long status, dummy1, dummy2, dummy3, local_result;
+ unsigned long status, dummy1, local_result;
vmballoon_stats_op_inc(b, cmd, VMW_BALLOON_OP_STAT);
- asm volatile ("inl %%dx" :
- "=a"(status),
- "=c"(dummy1),
- "=d"(dummy2),
- "=b"(local_result),
- "=S"(dummy3) :
- "0"(VMW_BALLOON_HV_MAGIC),
- "1"(cmd),
- "2"(VMW_BALLOON_HV_PORT),
- "3"(arg1),
- "4"(arg2) :
- "memory");
+ status = __vmballoon_call(cmd, arg1, arg2, &dummy1, &local_result);
/* update the result if needed */
if (result)
@@ -1809,6 +1846,23 @@ int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
enum migrate_mode mode);
#endif /* CONFIG_BALLOON_MIGRATION */
+static bool __init vmballoon_supported(void)
+{
+#ifdef CONFIG_X86
+ return hypervisor_is_type(X86_HYPER_VMWARE);
+#elif defined(CONFIG_ARM64)
+ /*
+ * The balloon protocol is carried by HVC. HVC is undefined where
+ * firmware does not provide it, so do not execute it unless the
+ * SMCCC conduit is HVC.
+ */
+ if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_HVC)
+ return false;
+
+ return dmi_match(DMI_SYS_VENDOR, "VMware, Inc.");
+#endif
+}
+
static int __init vmballoon_init(void)
{
int error;
@@ -1817,7 +1871,7 @@ static int __init vmballoon_init(void)
* Check if we are running on VMware's hypervisor and bail out
* if we are not.
*/
- if (x86_hyper_type != X86_HYPER_VMWARE)
+ if (!vmballoon_supported())
return -ENODEV;
INIT_DELAYED_WORK(&balloon.dwork, vmballoon_work);
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 0/2] vmw_balloon: Add arm64 support
2026-12-02 21:38 [PATCH v1 0/2] vmw_balloon: Add arm64 support Jerrin Shaji George
2026-12-02 21:38 ` [PATCH v1 1/2] arm64: Add VMware virtual I/O port definitions Jerrin Shaji George
2026-12-02 21:38 ` [PATCH v1 2/2] vmw_balloon: Add arm64 support Jerrin Shaji George
@ 2026-12-02 21:44 ` sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-02 21:44 UTC (permalink / raw)
To: Jerrin Shaji George; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
Sashiko has reviewed this 2-patch series and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202213821.22333-1-jerrin.shaji-george@broadcom.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 21:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 21:38 [PATCH v1 0/2] vmw_balloon: Add arm64 support Jerrin Shaji George
2026-12-02 21:38 ` [PATCH v1 1/2] arm64: Add VMware virtual I/O port definitions Jerrin Shaji George
2026-12-02 21:38 ` [PATCH v1 2/2] vmw_balloon: Add arm64 support Jerrin Shaji George
2026-12-02 21:44 ` [PATCH v1 0/2] " sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.