From patchwork Thu Feb 22 23:16:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 13568246 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A90F4C47DD9 for ; Thu, 22 Feb 2024 23:17:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F6836B00A3; Thu, 22 Feb 2024 18:16:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 008B96B00A4; Thu, 22 Feb 2024 18:16:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A47026B00A3; Thu, 22 Feb 2024 18:16:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6F7A76B00A6 for ; Thu, 22 Feb 2024 18:16:53 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4EA31A0E7C for ; Thu, 22 Feb 2024 23:16:53 +0000 (UTC) X-FDA: 81821001906.04.DFC9F34 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf11.hostedemail.com (Postfix) with ESMTP id 601BF40003 for ; Thu, 22 Feb 2024 23:16:51 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=U+sTJqFd; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf11.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708643811; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UTw6fdMTFcjfZ33gKj3XSf3I7tXoLgizXBMgo1kqPAM=; b=OG9SBxPETJRcOjHvCFj8/BJgreb3bqiLBJHEDTdaamR+jwHqLltQiPVn1u0JFxqy243ZK9 99vkum6C4+2vXCaQmbquFkuVHxPPcgEZUgLzw3XLSl6VbTV/Z6aRnij3vrNcMFHvcnFX5r Zu3ez/pRx3nNhrI/qB2oXlw5uueFbso= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=U+sTJqFd; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf11.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708643811; a=rsa-sha256; cv=none; b=8ijMqFAD2wlbFyl87nDGocVHqpEd85crrc6iFK+6NlRxREQbsOkr+ZRe0qgHWjHEMFLFlr l9DUu5d4g2CDJ7iTCFeIJkJ2HfIOKPw7jyURCHTuYOKPIxvwBBX15kXob+6vlJZ8uIQ+Dw UvqtfSpq6qvtcWX6DXkIEQZkmZ8G9nw= Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41MN1qgD012101; Thu, 22 Feb 2024 23:16:45 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=UTw6fdMTFcjfZ33gKj3XSf3I7tXoLgizXBMgo1kqPAM =; b=U+sTJqFdPtYFI9+8gqCMOwjh27gzGPcH+qsSLx4MufdlHO9LkEf7qf7ovPi ihfRPS7yIKvuWsNlm79oYxdt5QESg0SMMV3yXcwYzo7h7ZcMU8w4biOvwyEWvKB4 CI2ZJ4GFhKZdQh8y9CD8oNJ0J0Wqqz1k4MYuV98SNyirx3GS+qVM05+9uLuWcM3w GflnMQrs5QyhHqppmshSKwJ2L2hMU4aabmMgWIZRozWCydZu1UuoopYXnqcD6DlG wd/TAz4240tRmK7d9h4d8s/KjIf3MnP3+KjW6Pjag3OKgpn7/8nvxejhmakPxOk0 CSXDQOcslaPX//MjSUXoF0G2RiA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3we97tgf8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 23:16:44 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41MNGhSG017967 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 23:16:43 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; Thu, 22 Feb 2024 15:16:43 -0800 From: Elliot Berman Date: Thu, 22 Feb 2024 15:16:52 -0800 Subject: [PATCH v17 29/35] gunyah: rsc_mgr: Add RPC to set VM boot context MIME-Version: 1.0 Message-ID: <20240222-gunyah-v17-29-1e9da6763d38@quicinc.com> References: <20240222-gunyah-v17-0-1e9da6763d38@quicinc.com> In-Reply-To: <20240222-gunyah-v17-0-1e9da6763d38@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.12.4 X-Originating-IP: [10.49.16.6] 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: LYAEtq1tGFHE7mfHB6YGiz_72K1Y_peD X-Proofpoint-ORIG-GUID: LYAEtq1tGFHE7mfHB6YGiz_72K1Y_peD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-22_15,2024-02-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 adultscore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402220179 X-Rspamd-Queue-Id: 601BF40003 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 5gyui8675967bqy5bru91d1qwsporsbu X-HE-Tag: 1708643811-783139 X-HE-Meta: U2FsdGVkX19VtvIFsnC/jl8xfHnxJYbSOWTYgdD4kWegrXfgGO/kPH4FnYZexZkiYCHPDL4gl7GvPuchTc7wCPH5kLKeh6CCNGUkoppfPK8DBG11fl0VxQnaDSIlOOP5mtzNESFGMYuDHZ0HHm9AkTZ+r7crkRBU6Q57DDUQUqIEAYn80TI8y/r8UAgG4+4ckTCjB+WZ+4cSKSCSIK6GiylaWu0/oboftXoroX4bmTqp4XyxpL9YoTdBQkEdzb4monpEhv8cGMz0GJ729FOuDZJ1tq/6aNmdfck4KiFbaQIxEMzydRvYjCoGU02KJ4fNvLWKmbPqN8K6M3AsqK18LFQCJpRFmXQILYJJd6SOwZudcOK2Ud1ojTJyGIQ/DIFwt2AVrUrMgvfyDqOBSUnq0/6n3Oa19zuxVpI+tdKxD92z+pdg4jgwJYYKgZkRqzgvLrndmIVgx/AKmddD8cUkpLhC7dH4uxH1rRWPwr7Rnrt6Jrm1GWZ3gFaJvyv1JVqf6jLbm7Lf6YHscqoD7j1ksnghWoGiQD6ZLUX/RaBkua+ZQ1/IaaGxVa1H8ImQ6yswSj2azHnSGpXUTCALREEaxNDoZaZCI+PJs47noX8/MW/KZ8tT6RFlfiRA28UbYQwUBDQTaganUcg8W1ImRJUIzjQH8clS9OKpkNXk7C/5D12lEDQ7sC8UByv4Lv6LRgP24xFoe/k4IhfONIhXmx1H7hIDFYRoEPDxZ9yzLbForocFTtjP6QO41/fgezVGjyl3Y5F+31MhSIR7K3jjsf0mchXjU0XO6aA5qFq32M17EzyO0EcRY8/pOgB1rlzA3RvFU0onIHLRPn00Fj68RbK3x4hGT8A94Yl1vRz5PaTZpHmWSplPCwtctjnWlZI6AJk8o6moKl+54954APJZHYQD6wFsSa5Fnd5BzGL+GAdriHGnxhEwxzYIkyphOxaYxwa2j5cNM93xExNmwOfpYU3 Kwcb1CWR 1QEzXYMe34FMoUSHqYJaBx+VMDUzIE20o9iNB X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The initial context of a the primary vCPU can be initialized by performing RM RPC calls. Signed-off-by: Elliot Berman Reviewed-by: Srivatsa Vaddagiri --- drivers/virt/gunyah/rsc_mgr.h | 2 ++ drivers/virt/gunyah/rsc_mgr_rpc.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/virt/gunyah/rsc_mgr.h b/drivers/virt/gunyah/rsc_mgr.h index 99c2db18579ca..2acaf8dff365e 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 dfffcf02ddaea..eabf8659eb8f9 100644 --- a/drivers/virt/gunyah/rsc_mgr_rpc.c +++ b/drivers/virt/gunyah/rsc_mgr_rpc.c @@ -24,6 +24,7 @@ #define GUNYAH_RM_RPC_VM_INIT 0x5600000B #define GUNYAH_RM_RPC_VM_GET_HYP_RESOURCES 0x56000020 #define GUNYAH_RM_RPC_VM_GET_VMID 0x56000024 +#define GUNYAH_RM_RPC_VM_SET_BOOT_CONTEXT 0x56000031 #define GUNYAH_RM_RPC_VM_SET_DEMAND_PAGING 0x56000033 #define GUNYAH_RM_RPC_VM_SET_ADDRESS_LAYOUT 0x56000034 /* clang-format on */ @@ -105,6 +106,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; @@ -447,6 +457,29 @@ int gunyah_rm_vm_init(struct gunyah_rm *rm, u16 vmid) } ALLOW_ERROR_INJECTION(gunyah_rm_vm_init, ERRNO); +/** + * 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); +} +ALLOW_ERROR_INJECTION(gunyah_rm_vm_set_boot_context, ERRNO); + /** * gunyah_rm_get_hyp_resources() - Retrieve hypervisor resources (capabilities) associated with a VM * @rm: Handle to a Gunyah resource manager