blob: 133b8a7ac0e5486bfc8f895ae84ed0962b783696 [file] [log] [blame]
David Brazdil7a462ec2019-08-15 12:27:47 +01001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
Andrew Walbrane959ec12020-06-17 15:01:09 +01004 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/BSD-3-Clause.
David Brazdil7a462ec2019-08-15 12:27:47 +01007 */
8
9#pragma once
10
Olivier Deprez62d99e32020-01-09 15:58:07 +010011#include "hf/addr.h"
Raghu Krishnamurthyb49549e2021-07-02 08:27:38 -070012#include "hf/fdt.h"
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010013#include "hf/ffa.h"
J-Alves7ec9d6e2023-02-28 16:39:56 +000014#include "hf/ffa_partition_manifest.h"
David Brazdil7a462ec2019-08-15 12:27:47 +010015#include "hf/memiter.h"
David Brazdil136f2942019-09-23 14:11:03 +010016#include "hf/string.h"
Andrew Scullae9962e2019-10-03 16:51:16 +010017#include "hf/vm.h"
David Brazdil0dbb41f2019-09-09 18:03:35 +010018
Olivier Deprez62d99e32020-01-09 15:58:07 +010019/**
David Brazdil7a462ec2019-08-15 12:27:47 +010020 * Holds information about one of the VMs described in the manifest.
21 */
22struct manifest_vm {
23 /* Properties defined for both primary and secondary VMs. */
David Brazdil136f2942019-09-23 14:11:03 +010024 struct string debug_name;
25 struct string kernel_filename;
Andrew Scullae9962e2019-10-03 16:51:16 +010026 struct smc_whitelist smc_whitelist;
Olivier Deprez62d99e32020-01-09 15:58:07 +010027 bool is_ffa_partition;
Raghu Krishnamurthyb49549e2021-07-02 08:27:38 -070028 bool is_hyp_loaded;
J-Alves7ec9d6e2023-02-28 16:39:56 +000029 struct ffa_partition_manifest partition;
David Brazdil7a462ec2019-08-15 12:27:47 +010030
David Brazdile6f83222019-09-23 14:47:37 +010031 union {
32 /* Properties specific to the primary VM. */
33 struct {
David Brazdil080ee312020-02-25 15:30:30 -080034 uint64_t boot_address;
David Brazdile6f83222019-09-23 14:47:37 +010035 struct string ramdisk_filename;
36 } primary;
37 /* Properties specific to secondary VMs. */
38 struct {
39 uint64_t mem_size;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010040 ffa_vcpu_count_t vcpu_count;
Fuad Tabba50469e02020-06-30 15:14:28 +010041 struct string fdt_filename;
David Brazdile6f83222019-09-23 14:47:37 +010042 } secondary;
43 };
David Brazdil7a462ec2019-08-15 12:27:47 +010044};
45
46/**
47 * Hafnium manifest parsed from FDT.
48 */
49struct manifest {
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010050 bool ffa_tee_enabled;
51 ffa_vm_count_t vm_count;
David Brazdil7a462ec2019-08-15 12:27:47 +010052 struct manifest_vm vm[MAX_VMS];
53};
54
55enum manifest_return_code {
56 MANIFEST_SUCCESS = 0,
David Brazdila2358d42020-01-27 18:51:38 +000057 MANIFEST_ERROR_FILE_SIZE,
Olivier Deprez62d99e32020-01-09 15:58:07 +010058 MANIFEST_ERROR_MALFORMED_DTB,
David Brazdila2358d42020-01-27 18:51:38 +000059 MANIFEST_ERROR_NO_ROOT_NODE,
David Brazdil7a462ec2019-08-15 12:27:47 +010060 MANIFEST_ERROR_NO_HYPERVISOR_FDT_NODE,
David Brazdil74e9c3b2019-08-28 11:09:08 +010061 MANIFEST_ERROR_NOT_COMPATIBLE,
David Brazdil7a462ec2019-08-15 12:27:47 +010062 MANIFEST_ERROR_RESERVED_VM_ID,
63 MANIFEST_ERROR_NO_PRIMARY_VM,
64 MANIFEST_ERROR_TOO_MANY_VMS,
65 MANIFEST_ERROR_PROPERTY_NOT_FOUND,
66 MANIFEST_ERROR_MALFORMED_STRING,
David Brazdil0dbb41f2019-09-09 18:03:35 +010067 MANIFEST_ERROR_STRING_TOO_LONG,
David Brazdil7a462ec2019-08-15 12:27:47 +010068 MANIFEST_ERROR_MALFORMED_INTEGER,
69 MANIFEST_ERROR_INTEGER_OVERFLOW,
Andrew Scullae9962e2019-10-03 16:51:16 +010070 MANIFEST_ERROR_MALFORMED_INTEGER_LIST,
Andrew Scullb2c3a242019-11-04 13:52:36 +000071 MANIFEST_ERROR_MALFORMED_BOOLEAN,
J-Alves35315782022-01-25 17:58:32 +000072 MANIFEST_ERROR_ARGUMENTS_LIST_EMPTY,
Manish Pandey6542f5c2020-04-27 14:37:46 +010073 MANIFEST_ERROR_MEMORY_REGION_NODE_EMPTY,
Manish Pandeye68e7932020-04-23 15:29:28 +010074 MANIFEST_ERROR_DEVICE_REGION_NODE_EMPTY,
Manish Pandeyf06c9072020-09-29 15:41:58 +010075 MANIFEST_ERROR_RXTX_SIZE_MISMATCH,
Varun Wadekar4afbfd72022-10-13 14:30:18 +010076 MANIFEST_ERROR_MEM_REGION_EMPTY,
Daniel Boulbyc1a613d2022-10-18 11:26:17 +010077 MANIFEST_ERROR_MEM_REGION_UNALIGNED,
Daniel Boulbya7e9e182022-06-27 14:21:01 +010078 MANIFEST_ERROR_MEM_REGION_OVERLAP,
Raghu Krishnamurthy384693c2021-10-11 13:56:24 -070079 MANIFEST_ERROR_INVALID_MEM_PERM,
Daniel Boulby801f8ef2022-06-27 14:21:01 +010080 MANIFEST_ERROR_INTERRUPT_ID_REPEATED,
Madhukar Pappireddy5c04a382022-12-28 11:29:26 -060081 MANIFEST_ERROR_ILLEGAL_NS_INT_ACTION,
Raghu Krishnamurthy98da1ca2022-10-04 08:59:01 -070082 MANIFEST_ERROR_INTERRUPT_ID_NOT_IN_LIST,
Madhukar Pappireddy5c04a382022-12-28 11:29:26 -060083 MANIFEST_ERROR_ILLEGAL_OTHER_S_INT_ACTION,
David Brazdil7a462ec2019-08-15 12:27:47 +010084};
85
Olivier Deprez62d99e32020-01-09 15:58:07 +010086enum manifest_return_code manifest_init(struct mm_stage1_locked stage1_locked,
Olivier Deprez93644652022-09-09 11:01:12 +020087 struct manifest **manifest,
Olivier Deprez62d99e32020-01-09 15:58:07 +010088 struct memiter *manifest_fdt,
89 struct mpool *ppool);
Daniel Boulby801f8ef2022-06-27 14:21:01 +010090void manifest_deinit(struct mpool *ppool);
Olivier Deprez62d99e32020-01-09 15:58:07 +010091
Raghu Krishnamurthyb49549e2021-07-02 08:27:38 -070092enum manifest_return_code parse_ffa_manifest(struct fdt *fdt,
J-Alves35315782022-01-25 17:58:32 +000093 struct manifest_vm *vm,
94 struct fdt_node *boot_info);
95
Olivier Deprez62d99e32020-01-09 15:58:07 +010096void manifest_dump(struct manifest_vm *vm);
David Brazdil7a462ec2019-08-15 12:27:47 +010097
98const char *manifest_strerror(enum manifest_return_code ret_code);