From 1bdf8b9d3e68127cbcee05ce44c9a721c7bc5915 Mon Sep 17 00:00:00 2001 From: Raghavendra Rao Ananta Date: Mon, 16 Mar 2020 20:35:03 -0700 Subject: [PATCH] haven: msgq: Initialize the cap-id with U64_MAX Currently, the cap-id for Tx and Rx of the message-queue are initialized with 0. However, 0 is a valid value for cap-id. A better value to initialize the cap-id is with U64_MAX. Hence, make corrections to use U64_MAX, defined as HH_CAPID_INVAL, in the message-queue driver. Change-Id: Ia501e87dc3cb8d880ea3d35ff000ca07b64aeced Signed-off-by: Raghavendra Rao Ananta --- drivers/virt/haven/hh_msgq.c | 6 ++++-- include/linux/haven/hh_common.h | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/virt/haven/hh_msgq.c b/drivers/virt/haven/hh_msgq.c index 67fb1b56579b..331602efd533 100644 --- a/drivers/virt/haven/hh_msgq.c +++ b/drivers/virt/haven/hh_msgq.c @@ -141,7 +141,7 @@ int hh_msgq_recv(void *msgq_client_desc, goto err; } - if (!cap_table_entry->rx_cap_id) { + if (cap_table_entry->rx_cap_id == HH_CAPID_INVAL) { pr_err("%s: Recv info for label %d not yet initialized\n", __func__, client_desc->label); ret = -EAGAIN; @@ -263,7 +263,7 @@ int hh_msgq_send(void *msgq_client_desc, goto err; } - if (!cap_table_entry->tx_cap_id) { + if (cap_table_entry->tx_cap_id == HH_CAPID_INVAL) { pr_err("%s: Send info for label %d not yet initialized\n", __func__, client_desc->label); ret = -EAGAIN; @@ -482,6 +482,8 @@ static int __init hh_msgq_init(void) for (i = 0; i < HH_MSGQ_LABEL_MAX; i++) { cap_table_entry = &hh_msgq_cap_table[i]; + cap_table_entry->tx_cap_id = HH_CAPID_INVAL; + cap_table_entry->rx_cap_id = HH_CAPID_INVAL; cap_table_entry->tx_full = false; cap_table_entry->rx_empty = true; init_waitqueue_head(&cap_table_entry->tx_wq); diff --git a/include/linux/haven/hh_common.h b/include/linux/haven/hh_common.h index b97334b7a5e4..f1a7ab0044e9 100644 --- a/include/linux/haven/hh_common.h +++ b/include/linux/haven/hh_common.h @@ -16,6 +16,9 @@ typedef u32 hh_memparcel_handle_t; typedef u64 hh_capid_t; typedef u64 hh_dbl_flags_t; +/* Common Haven macros */ +#define HH_CAPID_INVAL U64_MAX + enum hh_vm_names { HH_PRIMARY_VM, HH_TRUSTED_VM,