[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240222-gunyah-v17-29-1e9da6763d38@quicinc.com>
Date: Thu, 22 Feb 2024 15:16:52 -0800
From: Elliot Berman <quic_eberman@...cinc.com>
To: Alex Elder <elder@...aro.org>,
Srinivas Kandagatla
<srinivas.kandagatla@...aro.org>,
Murali Nalajal <quic_mnalajal@...cinc.com>,
Trilok Soni <quic_tsoni@...cinc.com>,
Srivatsa Vaddagiri
<quic_svaddagi@...cinc.com>,
Carl van Schaik <quic_cvanscha@...cinc.com>,
Philip Derrin <quic_pderrin@...cinc.com>,
Prakruthi Deepak Heragu
<quic_pheragu@...cinc.com>,
Jonathan Corbet <corbet@....net>, Rob Herring
<robh+dt@...nel.org>,
Krzysztof Kozlowski
<krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>,
Bjorn Andersson
<andersson@...nel.org>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
"Fuad
Tabba" <tabba@...gle.com>,
Sean Christopherson <seanjc@...gle.com>,
"Andrew
Morton" <akpm@...ux-foundation.org>
CC: <linux-arm-msm@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <linux-mm@...ck.org>,
Elliot Berman
<quic_eberman@...cinc.com>
Subject: [PATCH v17 29/35] gunyah: rsc_mgr: Add RPC to set VM boot context
The initial context of a the primary vCPU can be initialized by
performing RM RPC calls.
Signed-off-by: Elliot Berman <quic_eberman@...cinc.com>
---
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
Powered by blists - more mailing lists