1 /*
2  * Copyright 2022 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 #include "../msr.h"
10 #include "partition_services.h"
11 #include "test/hftest.h"
12 
sp_check_cpu_idx_cmd(ffa_vm_id_t test_source,ffa_vcpu_index_t received_cpu_idx)13 struct ffa_value sp_check_cpu_idx_cmd(ffa_vm_id_t test_source,
14 				      ffa_vcpu_index_t received_cpu_idx)
15 {
16 	ffa_vm_id_t own_id = hf_vm_get_id();
17 	ffa_vcpu_index_t core_idx =
18 		(ffa_vcpu_index_t)(read_msr(mpidr_el1) & ~0x80000000ULL);
19 
20 	if (core_idx != received_cpu_idx) {
21 		return sp_error(own_id, test_source, core_idx);
22 	}
23 	return sp_success(own_id, test_source, core_idx);
24 }
25