Skip to content

Commit cde6e29

Browse files
rajatgoyal47chetan-rathore
authored andcommitted
fix(mpam): enhancements to MPAM cache tests
- add cache invalidate before freeing monitor/cache test buffers - issue val_mem_issue_dsb() after invalidation for clean ordering - remove relative paths in include headers - enhancements related to mem alloc and dealloc in tests - bump up the MPAM ACS version to v0.7.0 Signed-off-by: Srikar Josyula <srikar.josyula@arm.com> Change-Id: I3647134db6f669d9281ca520df8fc34fc0f18c34
1 parent c4c1fa8 commit cde6e29

31 files changed

Lines changed: 539 additions & 150 deletions

apps/uefi/acs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353

5454
/* MPAM Release versions */
5555
#define MPAM_ACS_MAJOR_VER 0
56-
#define MPAM_ACS_MINOR_VER 5
57-
#define MPAM_ACS_SUBMINOR_VER 1
56+
#define MPAM_ACS_MINOR_VER 7
57+
#define MPAM_ACS_SUBMINOR_VER 0
5858

5959
/* PFDI Release versions */
6060
#define PFDI_ACS_MAJOR_VER 0

apps/uefi/mpam_main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,15 @@ VOID
166166
FreeMpamAcsMem (
167167
)
168168
{
169-
val_pe_free_info_table();
170-
val_gic_free_info_table();
171-
val_iovirt_free_info_table();
169+
val_free_shared_mem();
172170
val_mpam_free_info_table();
173-
val_hmat_free_info_table();
174171
val_srat_free_info_table();
172+
val_hmat_free_info_table();
175173
val_pcc_free_info_table();
176-
val_free_shared_mem();
174+
val_cache_free_info_table();
175+
val_iovirt_free_info_table();
176+
val_gic_free_info_table();
177+
val_pe_free_info_table();
177178
}
178179

179180
VOID

test_pool/mpam/error012.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
* limitations under the License.
1616
**/
1717

18-
#include "val/include/acs_val.h"
19-
#include "val/include/acs_pe.h"
20-
#include "val/include/acs_mpam.h"
21-
#include "val/include/acs_mpam_reg.h"
22-
#include "val/include/val_interface.h"
18+
#include "acs_val.h"
19+
#include "acs_pe.h"
20+
#include "acs_mpam.h"
21+
#include "acs_mpam_reg.h"
22+
#include "val_interface.h"
2323

2424
#define TEST_NUM ACS_MPAM_ERROR_TEST_NUM_BASE + 15
2525
#define TEST_DESC "Check MPAM IDR Zero for Undefined RIS "

test_pool/mpam/error013.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
* limitations under the License.
1616
**/
1717

18-
#include "val/include/acs_val.h"
19-
#include "val/include/acs_pe.h"
20-
#include "val/include/acs_mpam.h"
21-
#include "val/include/acs_mpam_reg.h"
22-
#include "val/include/val_interface.h"
18+
#include "acs_val.h"
19+
#include "acs_pe.h"
20+
#include "acs_mpam.h"
21+
#include "acs_mpam_reg.h"
22+
#include "val_interface.h"
2323

2424
#define TEST_NUM ACS_MPAM_ERROR_TEST_NUM_BASE + 16
2525
#define TEST_DESC "Check MPAMF_ESR.RIS field correctness "

test_pool/mpam/error014.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
* limitations under the License.
1616
**/
1717

18-
#include "val/include/acs_val.h"
19-
#include "val/include/acs_pe.h"
20-
#include "val/include/acs_mpam.h"
21-
#include "val/include/acs_mpam_reg.h"
22-
#include "val/include/val_interface.h"
18+
#include "acs_val.h"
19+
#include "acs_pe.h"
20+
#include "acs_mpam.h"
21+
#include "acs_mpam_reg.h"
22+
#include "val_interface.h"
2323

2424
#define TEST_NUM (ACS_MPAM_ERROR_TEST_NUM_BASE + 17)
2525
#define TEST_DESC "Check MPAM error overwrite behavior "

test_pool/mpam/feat001.c

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
* limitations under the License.
1616
**/
1717

18-
#include "val/include/acs_val.h"
19-
#include "val/include/acs_pe.h"
20-
#include "val/include/acs_mpam.h"
21-
#include "val/include/acs_memory.h"
22-
#include "val/include/val_interface.h"
18+
#include "acs_val.h"
19+
#include "acs_pe.h"
20+
#include "acs_mpam.h"
21+
#include "acs_memory.h"
22+
#include "val_interface.h"
2323

2424
#define TEST_NUM ACS_MPAM_CACHE_TEST_NUM_BASE + 25
2525
#define TEST_RULE ""
@@ -47,7 +47,7 @@ Value B < Value A: confirms that the disabled PARTID was deprioritized or blocke
4747
If both conditions hold, the test is passed.
4848
*/
4949

50-
#define BUFFER_SIZE 0x6400000 /* 100 MB */
50+
#define BUFFER_SIZE 0x100000 /* 1MB */
5151
#define NUM_SCENARIOS 3
5252

5353
static void
@@ -173,6 +173,10 @@ payload(void)
173173
if ((src_buf == NULL) || (dest_buf == NULL)) {
174174
val_print(ACS_PRINT_ERR, "\n Mem allocation failed", 0);
175175
val_set_status(index, RESULT_FAIL(TEST_NUM, 01));
176+
if (dest_buf != NULL)
177+
val_memory_free_aligned(dest_buf);
178+
if (src_buf != NULL)
179+
val_memory_free_aligned(src_buf);
176180
return;
177181
}
178182

@@ -212,6 +216,8 @@ payload(void)
212216

213217
/* Step 5: Start mem copy */
214218
val_memcpy(src_buf, dest_buf, BUFFER_SIZE);
219+
/* Wait for some time before the memcpy settles and counters update */
220+
val_time_delay_ms(TIMEOUT_MEDIUM);
215221

216222
/* Read CSU monitor cnt - number of cache lines filled by PARTID_X at this point */
217223
end_count = val_mpam_read_csumon(msc_index);
@@ -231,6 +237,11 @@ payload(void)
231237
goto cleanup;
232238
}
233239

240+
/* Invalidate the caches before next scenario */
241+
val_pe_cache_invalidate_range((uint64_t)src_buf, BUFFER_SIZE);
242+
val_pe_cache_invalidate_range((uint64_t)dest_buf, BUFFER_SIZE);
243+
val_mem_issue_dsb();
244+
234245
/* Step 7: Disable PARTID_X. MPAMCFG_DIS.PARTID = PARTID_X.
235246
Do not set NFU. We need the PARTID later */
236247
status = val_mpam_msc_endis_partid(msc_index, 0, 0, partid_x);
@@ -253,6 +264,10 @@ payload(void)
253264
if (status) {
254265
val_print(ACS_PRINT_ERR, "\n MPAM2_EL2 programming failed", 0);
255266
/* Free the buffers to the heap manager */
267+
val_pe_cache_invalidate_range((uint64_t)src_buf, BUFFER_SIZE);
268+
val_pe_cache_invalidate_range((uint64_t)dest_buf, BUFFER_SIZE);
269+
val_mem_issue_dsb();
270+
256271
val_memory_free_aligned(src_buf);
257272
val_memory_free_aligned(dest_buf);
258273
val_set_status(index, RESULT_FAIL(TEST_NUM, 03));
@@ -269,6 +284,8 @@ payload(void)
269284
};
270285

271286
val_memcpy(src_buf, dest_buf, BUFFER_SIZE);
287+
/* Wait for some time before the memcpy settles and counters update */
288+
val_time_delay_ms(TIMEOUT_MEDIUM);
272289

273290
/* Step 9 */
274291
end_count = val_mpam_read_csumon(msc_index);
@@ -290,6 +307,10 @@ payload(void)
290307
goto cleanup;
291308
}
292309

310+
val_pe_cache_invalidate_range((uint64_t)src_buf, BUFFER_SIZE);
311+
val_pe_cache_invalidate_range((uint64_t)dest_buf, BUFFER_SIZE);
312+
val_mem_issue_dsb();
313+
293314
/* Step 11: Enable PARTID_X and Disable PARTID_Y. H/w must remember PARTID_X config */
294315
status = val_mpam_msc_endis_partid(msc_index, 1, 0, partid_x);
295316
status |= val_mpam_msc_endis_partid(msc_index, 0, 0, partid_y);
@@ -304,6 +325,10 @@ payload(void)
304325
if (status) {
305326
val_print(ACS_PRINT_ERR, "\n MPAM2_EL2 programming failed", 0);
306327
/* Free the buffers to the heap manager */
328+
val_pe_cache_invalidate_range((uint64_t)src_buf, BUFFER_SIZE);
329+
val_pe_cache_invalidate_range((uint64_t)dest_buf, BUFFER_SIZE);
330+
val_mem_issue_dsb();
331+
307332
val_memory_free_aligned(src_buf);
308333
val_memory_free_aligned(dest_buf);
309334
val_set_status(index, RESULT_FAIL(TEST_NUM, 04));
@@ -323,6 +348,8 @@ payload(void)
323348
};
324349

325350
val_memcpy(src_buf, dest_buf, BUFFER_SIZE);
351+
/* Wait for some time before the memcpy settles and counters update */
352+
val_time_delay_ms(TIMEOUT_MEDIUM);
326353

327354
end_count = val_mpam_read_csumon(msc_index);
328355

@@ -347,6 +374,10 @@ payload(void)
347374
val_mpam_reg_write(MPAM2_EL2, saved_el2);
348375

349376
/* Free the buffers to the heap manager */
377+
val_pe_cache_invalidate_range((uint64_t)src_buf, BUFFER_SIZE);
378+
val_pe_cache_invalidate_range((uint64_t)dest_buf, BUFFER_SIZE);
379+
val_mem_issue_dsb();
380+
350381
val_memory_free_aligned(src_buf);
351382
val_memory_free_aligned(dest_buf);
352383
}

test_pool/mpam/intr003.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ void payload(void)
171171

172172
/* Start mem copy to cause the overflow interrupt */
173173
val_memcpy(src_buf, dest_buf, buf_size);
174+
/* Wait for some time before the memcpy settles and counters update */
175+
val_time_delay_ms(TIMEOUT_MEDIUM);
174176

175177
/* PE busy polls to check the completion of interrupt service routine */
176178
timeout = TIMEOUT_LARGE;

test_pool/mpam/intr004.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ mbwu_prepare_overflow_intr(uint32_t msc_idx,
9292

9393
/* Generate memory traffic to trigger the overflow */
9494
val_memcpy(src_buf, dest_buf, buf_size);
95+
/* Wait for some time before the memcpy settles and counters update */
96+
val_time_delay_ms(TIMEOUT_MEDIUM);
9597
val_mpam_mbwu_wait_for_update(msc_idx);
9698

9799
/* Overflow Status is Cleared in Handler */

test_pool/mpam/intr005.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ mbwu_prepare_overflow_intr(uint32_t msc_idx,
7979
val_mpam_mbwu_wait_for_update(msc_idx);
8080

8181
val_memcpy(src_buf, dest_buf, buf_size);
82+
/* Wait for some time before the memcpy settles and counters update */
83+
val_time_delay_ms(TIMEOUT_MEDIUM);
8284
val_mpam_mbwu_wait_for_update(msc_idx);
8385

8486
/* Overflow is cleared in the handler */

test_pool/mpam/mem001.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ void payload(void)
289289

290290
/* perform memory operation */
291291
val_memcpy(src_buf, dest_buf, buf_size);
292+
/* Wait for some time before the memcpy settles and counters update */
293+
val_time_delay_ms(TIMEOUT_MEDIUM);
292294

293295
while (nrdy_timeout) {
294296
--nrdy_timeout;

0 commit comments

Comments
 (0)