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 <eberman@codeaurora.org>
This commit is contained in:
Elliot Berman 2020-03-18 16:35:19 -07:00
commit 73eacbb2f3
3 changed files with 8 additions and 3 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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