Skip to content

Commit c5108c1

Browse files
committed
Update ISA test for ISA changes.
Still some TODOs to resolve.
1 parent e06fd1e commit c5108c1

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

tests/isa-test.cc

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ namespace
275275
capability.permissions() &= mask;
276276
TEST(capability.permissions() == expectedPermissions,
277277
"permissions {} did not match expected {}",
278-
capability.permissions(),
278+
static_cast<PermissionSet>(capability.permissions()),
279279
expectedPermissions);
280280
}
281281

@@ -317,18 +317,33 @@ namespace
317317

318318
void test_sentries()
319319
{
320-
Capability interruptsEnabledSentry = {get_interrupts_enabled_sentry()};
321-
debug_log("interrupts enabled sentry {}", interruptsEnabledSentry);
322-
TEST(interruptsEnabledSentry.type() == 3,
323-
"Expected type 3 but got {}",
324-
interruptsEnabledSentry.type());
325-
326-
Capability interruptsDisabledSentry = {
327-
get_interrupts_disabled_sentry()};
328-
debug_log("interrupts disabled sentry {}", interruptsDisabledSentry);
329-
TEST(interruptsDisabledSentry.type() == 2,
330-
"Expected type 2 but got {}",
331-
interruptsDisabledSentry.type());
320+
// XXX the following produces a linker error:
321+
// error: ld.lld: error: Compartment 'isa_test' imports library function '__library_export_isa_test__ZN12_GLOBAL__N_129get_interrupts_enabled_sentryEv' as cross-compartment call
322+
// possible compiler / linker bug?
323+
324+
// Capability interruptsEnabledSentry = {get_interrupts_enabled_sentry};
325+
// debug_log("interrupts enabled sentry {}", reinterpret_cast<void*>(interruptsEnabledSentry.get()));
326+
// TEST(interruptsEnabledSentry.type() == 3,
327+
// "Expected type 3 but got {}",
328+
// interruptsEnabledSentry.type());
329+
330+
// Capability interruptsDisabledSentry = {&get_interrupts_disabled_sentry};
331+
// debug_log("interrupts disabled sentry {}", reinterpret_cast<void*>(interruptsDisabledSentry.get()));
332+
// TEST(interruptsDisabledSentry.type() == 2,
333+
// "Expected type 2 but got {}",
334+
// interruptsDisabledSentry.type());
335+
336+
Capability interruptsEnabledReturnSentry = {get_interrupts_enabled_sentry()};
337+
debug_log("interrupts enabled sentry {}", interruptsEnabledReturnSentry);
338+
TEST(interruptsEnabledReturnSentry.type() == 5,
339+
"Expected type 5 but got {}",
340+
interruptsEnabledReturnSentry.type());
341+
342+
Capability interruptsDisabledReturnSentry = {get_interrupts_disabled_sentry()};
343+
debug_log("interrupts disabled sentry {}", interruptsDisabledReturnSentry);
344+
TEST(interruptsDisabledReturnSentry.type() == 4,
345+
"Expected type 4 but got {}",
346+
interruptsDisabledReturnSentry.type());
332347
}
333348

334349
/*
@@ -532,12 +547,15 @@ namespace
532547
permission_filter<PermissionSet{Permission::Load,
533548
Permission::Store}>);
534549

550+
// TODO this is no longer expected to trap -- but would be good to check tag is cleared
535551
debug_log("Attempting to store local capability in global");
536552
do_store_test(
537-
CauseCode::PermitStoreLocalCapabilityViolation,
553+
std::nullopt,
538554
permission_filter<PermissionSet{Permission::Load,
539555
Permission::Store,
540-
Permission::LoadStoreCapability}>);
556+
Permission::LoadStoreCapability}>,
557+
identity_filter,
558+
std::nullopt);
541559

542560
debug_log("Attempt to store capability via too small bounds");
543561
do_store_test(
@@ -593,12 +611,14 @@ namespace
593611

594612
void test_restricted_loads()
595613
{
614+
// This test used to expect reduced permissions in the result but this
615+
// was changed in an ISA update.
596616
debug_log("Attempting to load capability via not-load-cap cap.");
597617
test_restricted_load(
598618
false,
599619
{Permission::Load},
600620
false,
601-
{Permission::Load, Permission::LoadStoreCapability});
621+
GlobalPermissions);
602622

603623
debug_log(
604624
"Attempting to load untagged capability via not-load-mutable cap.");
@@ -666,8 +686,9 @@ namespace
666686
do_jalr_test(CauseCode::PermitExecuteViolation,
667687
permission_filter<PermissionSet(Permission::Load)>);
668688

669-
debug_log("Attempting to jump to capability with too small bounds");
670-
do_jalr_test(CauseCode::BoundsViolation, restrict_bounds_filter);
689+
// TODO we can no longer recover from this crash as the failure occurs at dest, not caller
690+
// debug_log("Attempting to jump to capability with too small bounds");
691+
// do_jalr_test(CauseCode::BoundsViolation, restrict_bounds_filter);
671692
}
672693

673694
/*

0 commit comments

Comments
 (0)