1 /* 2 * Copyright 2018 The Hafnium Authors. 3 * 4 * 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. 7 */ 8 9 #pragma once 10 11 #include "hf/mm.h" 12 13 #include "test/vmapi/ffa.h" 14 15 /* 16 * FF-A UUIDs related to the test partitions providing test services to the 17 * Primary VM. These service partitions can either be SPs or VMs, and should 18 * be used only once for either an SP or VM. 19 * This allows for the PVM to communicate with the service partition, regardless 20 * of the ID, which has a bit related to the security state of the partition. 21 * The PVM should use the UUID to retrieve the FF-A ID of the partition, before 22 * attempting to communicate with it. Thus, the code for the PVM becomes 23 * portable between setups where the test service is either a VM or an SP. 24 */ 25 #define PVM \ 26 (struct ffa_uuid) \ 27 { \ 28 { \ 29 0xbdfaab86, 0xe9ee, 0x409a, 0xde614c01, \ 30 } \ 31 } 32 33 #define SERVICE1 \ 34 (struct ffa_uuid) \ 35 { \ 36 { \ 37 0xb4b5671e, 0x4a904fe1, 0xb81ffb13, 0xdae1dacb, \ 38 } \ 39 } 40 41 #define SERVICE2 \ 42 (struct ffa_uuid) \ 43 { \ 44 { \ 45 0x5d45882e, 0xf637, 0xa720, 0xe8669dc, \ 46 } \ 47 } 48 49 #define SERVICE2_UUID2 \ 50 (struct ffa_uuid) \ 51 { \ 52 { \ 53 0x6e56993f, 0x0748, 0xb831, 0xf977aed, \ 54 } \ 55 } 56 57 #define SERVICE3 \ 58 (struct ffa_uuid) \ 59 { \ 60 { \ 61 0xcbd4482f, 0xcbab, 0x4dba, 0x0738d, \ 62 } \ 63 } 64 #define SERVICE4 \ 65 (struct ffa_uuid) \ 66 { \ 67 { \ 68 0xd6d78930, 0x6cb26103, 0xda311d35, 0xfc03fced \ 69 } \ 70 } 71 72 /* 73 * Helpers to get services information. 74 * Defined with SERVICE_PARTITION_INFO_GET macro. 75 */ 76 struct ffa_partition_info* service1(void* recv); 77 struct ffa_partition_info* service2(void* recv); 78 struct ffa_partition_info* service3(void* recv); 79 struct ffa_partition_info* service4(void* recv); 80 81 /* Precondition functions for this test setup. */ 82 bool service1_is_vm(void); 83 bool service1_is_not_vm(void); 84 bool service1_is_secure(void); 85 bool service1_and_service2_are_secure(void); 86 bool service1_service2_and_service3_are_secure(void); 87 bool service1_is_mp_sp(void); 88 bool service2_is_mp_sp(void); 89 bool service3_is_mp_sp(void); 90 bool service1_and_service2_are_mp_sp(void); 91 bool hypervisor_only(void); 92 93 #define SERVICE_VM1 (HF_VM_ID_OFFSET + 1) 94 #define SERVICE_VM2 (HF_VM_ID_OFFSET + 2) 95 #define SERVICE_VM3 (HF_VM_ID_OFFSET + 3) 96 97 #define SELF_INTERRUPT_ID 5 98 #define EXTERNAL_INTERRUPT_ID_A 7 99 #define EXTERNAL_INTERRUPT_ID_B 8 100 #define EXTERNAL_INTERRUPT_ID_C 9 101 102 /* Helpers common to the setup. */ 103 bool exception_received(struct ffa_value* run_res, const void* recv_buf); 104