Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp648655rdb; Thu, 22 Feb 2024 15:20:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVioxfQowqltl4B1dJ8VaaDodO/m5yq6pmPdlQAY+JPn3JE4118JEbcnbJSMAcBD/6pXcX/Pnc344DRD3ibAFLI2DFZu8Q654JU/GhovA== X-Google-Smtp-Source: AGHT+IF6QhJDzvoPZ4Bn4xaIdF7hjso7CNhW8S9qzlNgawkZPRXMmIA/MRoUCNlPsvqFVBz9j9uI X-Received: by 2002:a17:902:ec8b:b0:1db:8c27:c24d with SMTP id x11-20020a170902ec8b00b001db8c27c24dmr411203plg.50.1708644034736; Thu, 22 Feb 2024 15:20:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708644034; cv=pass; d=google.com; s=arc-20160816; b=pjFEfHZSfXcdoopT7v06SFfXIMSlzxA7zEyfsRWk7CA9dtB1UC9WHLJHb9iD0NJMFI rLQw0Zhve5ip2cBji/ipE2S1dLXWjucXm4g3alOvvAho8MhHDo81Tdd8PQKV1uIp+b60 2cr295E+TR4Eu01ZfDIuaRAv5g1czcIWGPfXvCG3jQJIRUEjP0teljIApvi/mc9hqyDQ sz1Cmg4AOgus2pw8LDqf237NDKeaqc0D1os31O4rspTsyzJpSOA704/jjh3ZBfxJkelC TWPrw2+OgEcOa/8pG8n7ysUct1le5Kl1rvdyNfAO1CcudjJCWHClJ3nWMM6usiwXeFdv Ldjg== ARC-Message-Signature: i=2; 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=UTw6fdMTFcjfZ33gKj3XSf3I7tXoLgizXBMgo1kqPAM=; fh=j53ffieBeHmuArQHAkiXDczYOIriM+Jf92hqYE3BW8U=; b=XAienk1lF2eLA9KQ6CKNYo+l5Vqt2foWQJzEOUZLZsL8b58JtMDx/ift7SQ9XteUav TSZ7cC5lKpkRCE/oPxG93XGbQmvUlE67TtQcGc9QxB/qXcJiOlTzBDMlsEv8cBsgg8kN GfnqMmFna8RjYQWYLVVn8xKW68ASotxyFv9jv+XAUjo0OtBVGtxaJ3SpswkIz+PNsgAI sX8UjBmN/EUAolSwwA0rZM9B7Hgd3N3ldkfY7971MMVHT/TDpoKpc7JMOfvl16Lmk1G8 3l3qJabOEQr3HReOET9x8ea8dZ204wEd8ucX4AkaetMQyZ1y03iPnO8sN2l/5SnMgJff 21rA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=U+sTJqFd; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-77508-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77508-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c17-20020a170902d49100b001d9c329474dsi5701684plg.375.2024.02.22.15.20.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:20:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77508-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=U+sTJqFd; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-77508-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77508-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E9BC5B23C05 for ; Thu, 22 Feb 2024 23:20:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B1CC143C5B; Thu, 22 Feb 2024 23:17:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="U+sTJqFd" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 9C9C213BADE; Thu, 22 Feb 2024 23:17:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708643830; cv=none; b=mLyOfxkXqe1gjIsHCTCQjsg7mCbzTPtnqpVvLRho402iSApG9q/GkQ+F8Geh4LIzi7TjbYm8czKwvu1KUN+m/lIGmSgrJJr2SQCf0sDmbRJ1TE/GCqd+i5rM4+yz9m2ozamyjurz4eP9Hi4DtICYRncBjMRriHKlOc7BtHB+fpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708643830; c=relaxed/simple; bh=9Alalk7LXfV/SaxnGokCnM4bydl53hwoFnS2Yh52xcQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Rpk+F4nWXsWP/UuuQaTcdsyg/FrrLBJFKxZdeknbDudZ0xhSU4i3jZ2mAwxZhVjZskbPznBHK4rQvRxOvwf/W4+C2TSP4MmQrm+v1lwrHliPQxaesuhuUmOzdy43GNSKBk81bUSJssoXPsjRW82ANtkNDYbEFmJ4IuATLAE74zI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=U+sTJqFd; arc=none smtp.client-ip=205.220.180.131 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 (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 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: <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-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 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 | 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 -- 2.34.1