Commit eb79100f authored by Xavier Deguillard's avatar Xavier Deguillard Committed by Greg Kroah-Hartman

VMware balloon: Add support for balloon capabilities.

In order to extend the balloon protocol, the hypervisor and the guest
driver need to agree on a set of supported functionality to use.
Signed-off-by: default avatarXavier Deguillard <xdeguillard@vmware.com>
Acked-by: default avatarDmitry Torokhov <dtor@vmware.com>
Signed-off-by: default avatarPhilip P. Moltmann <moltmann@vmware.com>
Acked-by: default avatarAndy King <acking@vmware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ef0f8f11
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
MODULE_AUTHOR("VMware, Inc."); MODULE_AUTHOR("VMware, Inc.");
MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver"); MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
MODULE_VERSION("1.2.2.0-k"); MODULE_VERSION("1.3.0.0-k");
MODULE_ALIAS("dmi:*:svnVMware*:*"); MODULE_ALIAS("dmi:*:svnVMware*:*");
MODULE_ALIAS("vmware_vmmemctl"); MODULE_ALIAS("vmware_vmmemctl");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -110,9 +110,18 @@ MODULE_LICENSE("GPL"); ...@@ -110,9 +110,18 @@ MODULE_LICENSE("GPL");
*/ */
#define VMW_BALLOON_HV_PORT 0x5670 #define VMW_BALLOON_HV_PORT 0x5670
#define VMW_BALLOON_HV_MAGIC 0x456c6d6f #define VMW_BALLOON_HV_MAGIC 0x456c6d6f
#define VMW_BALLOON_PROTOCOL_VERSION 2
#define VMW_BALLOON_GUEST_ID 1 /* Linux */ #define VMW_BALLOON_GUEST_ID 1 /* Linux */
enum vmwballoon_capabilities {
/*
* Bit 0 is reserved and not associated to any capability.
*/
VMW_BALLOON_BASIC_CMDS = (1 << 1),
VMW_BALLOON_BATCHED_CMDS = (1 << 2)
};
#define VMW_BALLOON_CAPABILITIES (VMW_BALLOON_BASIC_CMDS)
#define VMW_BALLOON_CMD_START 0 #define VMW_BALLOON_CMD_START 0
#define VMW_BALLOON_CMD_GET_TARGET 1 #define VMW_BALLOON_CMD_GET_TARGET 1
#define VMW_BALLOON_CMD_LOCK 2 #define VMW_BALLOON_CMD_LOCK 2
...@@ -120,32 +129,36 @@ MODULE_LICENSE("GPL"); ...@@ -120,32 +129,36 @@ MODULE_LICENSE("GPL");
#define VMW_BALLOON_CMD_GUEST_ID 4 #define VMW_BALLOON_CMD_GUEST_ID 4
/* error codes */ /* error codes */
#define VMW_BALLOON_SUCCESS 0 #define VMW_BALLOON_SUCCESS 0
#define VMW_BALLOON_FAILURE -1 #define VMW_BALLOON_FAILURE -1
#define VMW_BALLOON_ERROR_CMD_INVALID 1 #define VMW_BALLOON_ERROR_CMD_INVALID 1
#define VMW_BALLOON_ERROR_PPN_INVALID 2 #define VMW_BALLOON_ERROR_PPN_INVALID 2
#define VMW_BALLOON_ERROR_PPN_LOCKED 3 #define VMW_BALLOON_ERROR_PPN_LOCKED 3
#define VMW_BALLOON_ERROR_PPN_UNLOCKED 4 #define VMW_BALLOON_ERROR_PPN_UNLOCKED 4
#define VMW_BALLOON_ERROR_PPN_PINNED 5 #define VMW_BALLOON_ERROR_PPN_PINNED 5
#define VMW_BALLOON_ERROR_PPN_NOTNEEDED 6 #define VMW_BALLOON_ERROR_PPN_NOTNEEDED 6
#define VMW_BALLOON_ERROR_RESET 7 #define VMW_BALLOON_ERROR_RESET 7
#define VMW_BALLOON_ERROR_BUSY 8 #define VMW_BALLOON_ERROR_BUSY 8
#define VMWARE_BALLOON_CMD(cmd, data, result) \ #define VMW_BALLOON_SUCCESS_WITH_CAPABILITIES (0x03000000)
({ \
unsigned long __stat, __dummy1, __dummy2; \ #define VMWARE_BALLOON_CMD(cmd, data, result) \
__asm__ __volatile__ ("inl %%dx" : \ ({ \
"=a"(__stat), \ unsigned long __status, __dummy1, __dummy2; \
"=c"(__dummy1), \ __asm__ __volatile__ ("inl %%dx" : \
"=d"(__dummy2), \ "=a"(__status), \
"=b"(result) : \ "=c"(__dummy1), \
"0"(VMW_BALLOON_HV_MAGIC), \ "=d"(__dummy2), \
"1"(VMW_BALLOON_CMD_##cmd), \ "=b"(result) : \
"2"(VMW_BALLOON_HV_PORT), \ "0"(VMW_BALLOON_HV_MAGIC), \
"3"(data) : \ "1"(VMW_BALLOON_CMD_##cmd), \
"memory"); \ "2"(VMW_BALLOON_HV_PORT), \
result &= -1UL; \ "3"(data) : \
__stat & -1UL; \ "memory"); \
if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START) \
result = __dummy1; \
result &= -1UL; \
__status & -1UL; \
}) })
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
...@@ -223,11 +236,12 @@ static struct vmballoon balloon; ...@@ -223,11 +236,12 @@ static struct vmballoon balloon;
*/ */
static bool vmballoon_send_start(struct vmballoon *b) static bool vmballoon_send_start(struct vmballoon *b)
{ {
unsigned long status, dummy; unsigned long status, capabilities;
STATS_INC(b->stats.start); STATS_INC(b->stats.start);
status = VMWARE_BALLOON_CMD(START, VMW_BALLOON_PROTOCOL_VERSION, dummy); status = VMWARE_BALLOON_CMD(START, VMW_BALLOON_CAPABILITIES,
capabilities);
if (status == VMW_BALLOON_SUCCESS) if (status == VMW_BALLOON_SUCCESS)
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment