Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp544417rdd; Tue, 9 Jan 2024 11:43:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNo2HCjX9Bb6PsLQbo6Vd2EekLTHfN+EgFun6ZmF8Dl0FGrOYuzDyyHCJHEhllTAFluDoI X-Received: by 2002:a62:b514:0:b0:6db:f61:6a41 with SMTP id y20-20020a62b514000000b006db0f616a41mr1175377pfe.22.1704829429735; Tue, 09 Jan 2024 11:43:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704829429; cv=none; d=google.com; s=arc-20160816; b=kbSUFK8nRxVmvoUeaWGDGm5EA601t2BhFyPppSQE2Lti5ZF+8yrrEm/zDLPB7aZawf J12F8QeVxDGORvo4GG6JKSoFae+1nL8gqfxbgFPjxmooej5iWx07P3UQOadnRCmvLb15 CZlutH6m6iaYjEFrDipbtlgRxfgLdfvxIYXhRVi8pNw5J+QnzWZ3try7dPqRONDDTYB5 v38Q/BAt8iWMa0p9xDV5xGtP5d5rafeZyND+XILGGOvbVk+LVMO0yqGYWhQsMaVLDkss pHBaOEcMJmp87pOFF7AhB/nvCfFckiTEvbtvIQK/fvg5ZPwWOqD4JON7S02YupEMY4VE Vonw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=mISjbqlRqJVm6RisqWAuRaAGWyV18zAgZkFAhzyIWvs=; fh=j53ffieBeHmuArQHAkiXDczYOIriM+Jf92hqYE3BW8U=; b=M/dziq7Cgz/0+OCm0Ve7k8MGM0Vy8knCjwNx3JUg4oqh4SOEtW7Ma0x840NBcXSNDk l6mYYMfolL04MgtEpZxbjihnDu+ktiOm+Xtp0AMZwpIPzAIu6QeSKgukzHMXpUMbHbQy J6tabHTk3NRE6aHtmIN2EcJdZylmp6CvPBnlJo3SbFuwEXI4kqjTm91dTI7PvxztLUWP bGAee569XS0B87xqkMMiUOCb6O/6Q2WCqBRLv7c6e5q3Snb1+goBk29zJO0EN23mYfYN bYH+xlYBQcWZy2JmlS6dHE/EcwSlgF/yeVm8B/w4QyOJQIfVFW5bmWWgckmajCCaXwCs m9Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=V6m8c9Mx; spf=pass (google.com: domain of linux-kernel+bounces-21343-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21343-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b64-20020a62cf43000000b006d9d6e6cf73si1963855pfg.289.2024.01.09.11.43.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 11:43:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21343-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=V6m8c9Mx; spf=pass (google.com: domain of linux-kernel+bounces-21343-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21343-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 603C128896A for ; Tue, 9 Jan 2024 19:43:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 865D847A55; Tue, 9 Jan 2024 19:38:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="V6m8c9Mx" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 673F34437F; Tue, 9 Jan 2024 19:38:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 409GCAMK032177; Tue, 9 Jan 2024 19:38:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:date:subject:mime-version:content-type :content-transfer-encoding:message-id:references:in-reply-to:to :cc; s=qcppdkim1; bh=mISjbqlRqJVm6RisqWAuRaAGWyV18zAgZkFAhzyIWvs =; b=V6m8c9Mx2eyhux4dK8665TNsA6fyLrEUnpaGhJjGuHQgzO7Lm3gMbmtsEvB p1+f/99M2SM60MlmAYF2aIwBieGY9fCV4fq8/7k1qFfgMHti6yXBaQ4i11l1jbqf /11POm1l8TiBS18saLUGLiLpx4HfPlfA00X6tjJ+BeeOtSvOwbTxfaUAHd9KDj+j n2sn/MhCcsMTHrnwmRhNxP4V74e56MMiud81kqYLVqnqPAmjuruwEC5WRVdTjPpy 5JIpj9TCPATFZQdrclnLzGsyRbbvtv3mRO60GNmLZ3U2UHZLYngVlpeC6M2ZeFjy TuRx2FGqJIBSRny8G6ObJLaUlgA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vh9evrfhy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jan 2024 19:38:08 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 409Jc72b012055 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 9 Jan 2024 19:38:07 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 9 Jan 2024 11:38:06 -0800 From: Elliot Berman Date: Tue, 9 Jan 2024 11:38:06 -0800 Subject: [PATCH v16 28/34] gunyah: rsc_mgr: Add RPC to set VM boot context Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20240109-gunyah-v16-28-634904bf4ce9@quicinc.com> References: <20240109-gunyah-v16-0-634904bf4ce9@quicinc.com> In-Reply-To: <20240109-gunyah-v16-0-634904bf4ce9@quicinc.com> To: Alex Elder , Srinivas Kandagatla , Murali Nalajal , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Philip Derrin , Prakruthi Deepak Heragu , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Catalin Marinas , Will Deacon , Konrad Dybcio , Bjorn Andersson , Dmitry Baryshkov , "Fuad Tabba" , Sean Christopherson , "Andrew Morton" CC: , , , , , , Elliot Berman X-Mailer: b4 0.13-dev X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: eLF8qTS-lSW6WCS6nT_JzEqTWuhHD0yL X-Proofpoint-ORIG-GUID: eLF8qTS-lSW6WCS6nT_JzEqTWuhHD0yL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 priorityscore=1501 adultscore=0 suspectscore=0 clxscore=1015 spamscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401090158 The initial context of a the primary vCPU can be initialized by performing RM RPC calls. Signed-off-by: Elliot Berman --- drivers/virt/gunyah/rsc_mgr.h | 2 ++ drivers/virt/gunyah/rsc_mgr_rpc.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/virt/gunyah/rsc_mgr.h b/drivers/virt/gunyah/rsc_mgr.h index 99c2db18579c..2acaf8dff365 100644 --- a/drivers/virt/gunyah/rsc_mgr.h +++ b/drivers/virt/gunyah/rsc_mgr.h @@ -84,6 +84,8 @@ int gunyah_rm_vm_configure(struct gunyah_rm *rm, u16 vmid, u32 mem_handle, u64 image_offset, u64 image_size, u64 dtb_offset, u64 dtb_size); int gunyah_rm_vm_init(struct gunyah_rm *rm, u16 vmid); +int gunyah_rm_vm_set_boot_context(struct gunyah_rm *rm, u16 vmid, u8 reg_set, + u8 reg_index, u64 value); struct gunyah_rm_hyp_resource { u8 type; diff --git a/drivers/virt/gunyah/rsc_mgr_rpc.c b/drivers/virt/gunyah/rsc_mgr_rpc.c index f4e396fd0d47..bbdae0b05cd4 100644 --- a/drivers/virt/gunyah/rsc_mgr_rpc.c +++ b/drivers/virt/gunyah/rsc_mgr_rpc.c @@ -20,6 +20,7 @@ #define GUNYAH_RM_RPC_VM_RESET 0x56000006 #define GUNYAH_RM_RPC_VM_CONFIG_IMAGE 0x56000009 #define GUNYAH_RM_RPC_VM_INIT 0x5600000B +#define GUNYAH_RM_RPC_VM_SET_BOOT_CONTEXT 0x5600000C #define GUNYAH_RM_RPC_VM_GET_HYP_RESOURCES 0x56000020 #define GUNYAH_RM_RPC_VM_GET_VMID 0x56000024 #define GUNYAH_RM_RPC_VM_SET_DEMAND_PAGING 0x56000033 @@ -102,6 +103,15 @@ struct gunyah_rm_vm_config_image_req { __le64 dtb_size; } __packed; +/* Call: VM_SET_BOOT_CONTEXT */ +struct gunyah_rm_vm_set_boot_context_req { + __le16 vmid; + u8 reg_set; + u8 reg_index; + __le32 _padding; + __le64 value; +} __packed; + /* Call: VM_SET_DEMAND_PAGING */ struct gunyah_rm_vm_set_demand_paging_req { __le16 vmid; @@ -435,6 +445,28 @@ int gunyah_rm_vm_init(struct gunyah_rm *rm, u16 vmid) return gunyah_rm_common_vmid_call(rm, GUNYAH_RM_RPC_VM_INIT, vmid); } +/** + * gunyah_rm_vm_set_boot_context() - set the initial boot context of the primary vCPU + * @rm: Handle to a Gunyah resource manager + * @vmid: VM identifier + * @reg_set: See &enum gunyah_vm_boot_context_reg + * @reg_index: Which register to set; must be 0 for REG_SET_PC + * @value: Value to set in the register + */ +int gunyah_rm_vm_set_boot_context(struct gunyah_rm *rm, u16 vmid, u8 reg_set, + u8 reg_index, u64 value) +{ + struct gunyah_rm_vm_set_boot_context_req req_payload = { + .vmid = cpu_to_le16(vmid), + .reg_set = reg_set, + .reg_index = reg_index, + .value = cpu_to_le64(value), + }; + + return gunyah_rm_call(rm, GUNYAH_RM_RPC_VM_SET_BOOT_CONTEXT, + &req_payload, sizeof(req_payload), NULL, NULL); +} + /** * gunyah_rm_get_hyp_resources() - Retrieve hypervisor resources (capabilities) associated with a VM * @rm: Handle to a Gunyah resource manager -- 2.34.1