From 73eacbb2f3c0de52c7f79c47029960fa89443ebc Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Wed, 18 Mar 2020 16:35:19 -0700 Subject: [PATCH] haven: rm: Add HH_SELF_VM name RM accepts "VMID 0" as meaning "self." Thus, add a vm_name "HH_SELF_VM" which means the same. Haven RM console operates on vm_names and can use HH_SELF_VM to talk to RM about this VM's console. Change-Id: I7663db28497ad86a94d4a8c98f3b7068f5644915 Signed-off-by: Elliot Berman --- drivers/tty/hvc/hvc_haven.c | 2 +- drivers/virt/haven/hh_rm_iface.c | 4 ++-- include/linux/haven/hh_common.h | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/tty/hvc/hvc_haven.c b/drivers/tty/hvc/hvc_haven.c index e4dea0ae32af..8b0a2d8cfd57 100644 --- a/drivers/tty/hvc/hvc_haven.c +++ b/drivers/tty/hvc/hvc_haven.c @@ -205,7 +205,7 @@ static int __init hvc_hh_console_init(void) { int ret; - ret = hvc_instantiate(hh_vm_name_to_vtermno(HH_PRIMARY_VM), 0, + ret = hvc_instantiate(hh_vm_name_to_vtermno(HH_SELF_VM), 0, &hh_hv_ops); return ret < 0 ? -ENODEV : 0; diff --git a/drivers/virt/haven/hh_rm_iface.c b/drivers/virt/haven/hh_rm_iface.c index 619145389cac..6aedb8994d8b 100644 --- a/drivers/virt/haven/hh_rm_iface.c +++ b/drivers/virt/haven/hh_rm_iface.c @@ -48,7 +48,7 @@ int hh_rm_get_vmid(enum hh_vm_names vm_name, hh_vmid_t *vmid) { hh_vmid_t _vmid = hh_vm_table[vm_name].vmid; - if (!_vmid) { + if (!_vmid && vm_name != HH_SELF_VM) { pr_err("%s: No vmid associated with the vm\n", __func__); return -EINVAL; } @@ -346,7 +346,7 @@ int hh_rm_vm_alloc_vmid(enum hh_vm_names vm_name) /* Look up for the vm_name<->vmid pair if already present. * If so, return. */ - if (!hh_vm_table[vm_name].vmid) { + if (hh_vm_table[vm_name].vmid || vm_name == HH_SELF_VM) { pr_err("%s: VM_ALLOCATE already called for this VM\n", __func__); return -EINVAL; diff --git a/include/linux/haven/hh_common.h b/include/linux/haven/hh_common.h index a1e691166f30..543abe97e4d4 100644 --- a/include/linux/haven/hh_common.h +++ b/include/linux/haven/hh_common.h @@ -22,6 +22,11 @@ typedef u64 hh_dbl_flags_t; #define HH_CAPID_INVAL U64_MAX enum hh_vm_names { + /* + * HH_SELF_VM is an alias for VMID 0. Useful for RM APIs which allow + * operations on current VM such as console + */ + HH_SELF_VM, HH_PRIMARY_VM, HH_TRUSTED_VM, HH_VM_MAX