diff options
| author | Jinyoung Park <jinyoungp@nvidia.com> | 2017-09-12 02:13:18 -0400 |
|---|---|---|
| committer | Jinyoung Park <jinyoungp@nvidia.com> | 2018-05-04 01:21:29 -0400 |
| commit | 16645f7c2ea6603bd68da633eb88226f1048cb86 (patch) | |
| tree | aafbf895c425e7b5d63570ab628f3246b5da1b92 /include | |
| parent | 0058ea9371f21062051086e428795a4b7769f9ce (diff) | |
virt: tegra: Added hvc to query guest state
Added hvc to query guest state. It returns the state of a specified
Guest such as boot, reboot, shutdown and suspend.
tegra_hv_pm_ctl driver provides a sysfs for this guest state.
Jira STR-227
Jira HYP-172
Change-Id: Id979d2f313f9f9051250e2667e508669001e2b04
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1557716
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sang-Hun Lee <sanlee@nvidia.com>
Reviewed-by: Dennis Kou <dkou@nvidia.com>
Reviewed-by: Kurt Yi <kyi@nvidia.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/soc/tegra/virt/syscalls.h | 19 | ||||
| -rw-r--r-- | include/soc/tegra/virt/tegra_hv_sysmgr.h | 12 |
2 files changed, 31 insertions, 0 deletions
diff --git a/include/soc/tegra/virt/syscalls.h b/include/soc/tegra/virt/syscalls.h index 70a2611a7..bacef2471 100644 --- a/include/soc/tegra/virt/syscalls.h +++ b/include/soc/tegra/virt/syscalls.h | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #define HVC_NR_RAISE_IRQ 4 | 42 | #define HVC_NR_RAISE_IRQ 4 |
| 43 | #define HVC_NR_READ_NGUESTS 5 | 43 | #define HVC_NR_READ_NGUESTS 5 |
| 44 | #define HVC_NR_READ_IPA_PA 6 | 44 | #define HVC_NR_READ_IPA_PA 6 |
| 45 | #define HVC_NR_READ_GUEST_STATE 7 | ||
| 45 | #define HVC_NR_READ_HYP_INFO 9 | 46 | #define HVC_NR_READ_HYP_INFO 9 |
| 46 | #define HVC_NR_GUEST_RESET 10 | 47 | #define HVC_NR_GUEST_RESET 10 |
| 47 | #define HVC_NR_SYSINFO_IPA 13 | 48 | #define HVC_NR_SYSINFO_IPA 13 |
| @@ -174,6 +175,9 @@ struct hyp_server_page { | |||
| 174 | 175 | ||
| 175 | #ifdef CONFIG_ARM64 | 176 | #ifdef CONFIG_ARM64 |
| 176 | 177 | ||
| 178 | #define _X3_X17 "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12", \ | ||
| 179 | "x13", "x14", "x15", "x16", "x17" | ||
| 180 | |||
| 177 | #define _X4_X17 "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12", \ | 181 | #define _X4_X17 "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12", \ |
| 178 | "x13", "x14", "x15", "x16", "x17" | 182 | "x13", "x14", "x15", "x16", "x17" |
| 179 | 183 | ||
| @@ -253,6 +257,20 @@ static inline int hyp_raise_irq(unsigned int irq, unsigned int vmid) | |||
| 253 | return (int)r0; | 257 | return (int)r0; |
| 254 | } | 258 | } |
| 255 | 259 | ||
| 260 | static inline int hyp_read_guest_state(unsigned int vmid, unsigned int *state) | ||
| 261 | { | ||
| 262 | register uint64_t r0 asm("x0") = vmid; | ||
| 263 | register uint64_t r1 asm("x1"); | ||
| 264 | |||
| 265 | asm("hvc %2" | ||
| 266 | : "+r"(r0), "=r"(r1) | ||
| 267 | : "i"(HVC_NR_READ_GUEST_STATE) | ||
| 268 | : "x2", _X3_X17); | ||
| 269 | |||
| 270 | *state = (unsigned int)r1; | ||
| 271 | return (int)r0; | ||
| 272 | } | ||
| 273 | |||
| 256 | static inline int hyp_read_hyp_info(uint64_t *hyp_info_page_pa) | 274 | static inline int hyp_read_hyp_info(uint64_t *hyp_info_page_pa) |
| 257 | { | 275 | { |
| 258 | register uint64_t r0 asm("x0"); | 276 | register uint64_t r0 asm("x0"); |
| @@ -302,6 +320,7 @@ static inline uint64_t hyp_sysinfo_ipa(void) | |||
| 302 | return r0; | 320 | return r0; |
| 303 | } | 321 | } |
| 304 | 322 | ||
| 323 | #undef _X3_X17 | ||
| 305 | #undef _X4_X17 | 324 | #undef _X4_X17 |
| 306 | 325 | ||
| 307 | #else | 326 | #else |
diff --git a/include/soc/tegra/virt/tegra_hv_sysmgr.h b/include/soc/tegra/virt/tegra_hv_sysmgr.h index 62b66fc19..e93879277 100644 --- a/include/soc/tegra/virt/tegra_hv_sysmgr.h +++ b/include/soc/tegra/virt/tegra_hv_sysmgr.h | |||
| @@ -101,6 +101,18 @@ enum system_function_id { | |||
| 101 | MAX_FUNC_ID, | 101 | MAX_FUNC_ID, |
| 102 | }; | 102 | }; |
| 103 | 103 | ||
| 104 | typedef enum { | ||
| 105 | VM_STATE_BOOT, | ||
| 106 | VM_STATE_HALT, | ||
| 107 | VM_STATE_UNHALT, | ||
| 108 | VM_STATE_REBOOT, | ||
| 109 | VM_STATE_SHUTDOWN, | ||
| 110 | VM_STATE_SUSPEND, | ||
| 111 | VM_STATE_RESUME, | ||
| 112 | VM_STATE_INVALID, | ||
| 113 | VM_STATE_MAX | ||
| 114 | } vm_state; | ||
| 115 | |||
| 104 | #define CREATE_CMD(func_id, vmid) ((func_id << 24U) | vmid) | 116 | #define CREATE_CMD(func_id, vmid) ((func_id << 24U) | vmid) |
| 105 | 117 | ||
| 106 | #define QUERY_CMD CREATE_CMD(QUERY_SYSTEM_STATE, 0) | 118 | #define QUERY_CMD CREATE_CMD(QUERY_SYSTEM_STATE, 0) |
