Skip to content

Commit cc661dc

Browse files
committed
Clang format.
1 parent f688457 commit cc661dc

File tree

2 files changed

+66
-56
lines changed

2 files changed

+66
-56
lines changed

sdk/include/cheri.hh

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -309,68 +309,71 @@ namespace CHERI
309309
[[nodiscard]] constexpr PermissionSet get_max_format_perms() const
310310
{
311311
if (this->contains(Permission::Execute,
312-
Permission::Load,
313-
Permission::LoadStoreCapability))
312+
Permission::Load,
313+
Permission::LoadStoreCapability))
314314
{
315315
// Executable format
316316
return PermissionSet{Permission::Global,
317-
Permission::Execute,
318-
Permission::Load,
319-
Permission::LoadStoreCapability,
320-
Permission::LoadGlobal,
321-
Permission::LoadMutable,
322-
Permission::AccessSystemRegisters};
317+
Permission::Execute,
318+
Permission::Load,
319+
Permission::LoadStoreCapability,
320+
Permission::LoadGlobal,
321+
Permission::LoadMutable,
322+
Permission::AccessSystemRegisters};
323323
}
324324
if (this->contains(Permission::Load,
325-
Permission::Store,
326-
Permission::LoadStoreCapability))
325+
Permission::Store,
326+
Permission::LoadStoreCapability))
327327
{
328328
// cap-rw format
329329
return PermissionSet{Permission::Global,
330-
Permission::Load,
331-
Permission::Store,
332-
Permission::LoadStoreCapability,
333-
Permission::LoadGlobal,
334-
Permission::LoadMutable,
335-
Permission::StoreLocal};
330+
Permission::Load,
331+
Permission::Store,
332+
Permission::LoadStoreCapability,
333+
Permission::LoadGlobal,
334+
Permission::LoadMutable,
335+
Permission::StoreLocal};
336336
}
337-
if (this->contains(Permission::Load, Permission::LoadStoreCapability))
337+
if (this->contains(Permission::Load,
338+
Permission::LoadStoreCapability))
338339
{
339340
// cap-ro format
340341
return PermissionSet{Permission::Global,
341-
Permission::Load,
342-
Permission::LoadStoreCapability,
343-
Permission::LoadGlobal,
344-
Permission::LoadMutable};
342+
Permission::Load,
343+
Permission::LoadStoreCapability,
344+
Permission::LoadGlobal,
345+
Permission::LoadMutable};
345346
}
346-
if (this->contains(Permission::Store, Permission::LoadStoreCapability))
347+
if (this->contains(Permission::Store,
348+
Permission::LoadStoreCapability))
347349
{
348350
// cap-wo format
349351
return PermissionSet{Permission::Global,
350-
Permission::Store,
351-
Permission::LoadStoreCapability};
352+
Permission::Store,
353+
Permission::LoadStoreCapability};
352354
}
353-
if (this->contains(Permission::Store) || this->contains(Permission::Load))
355+
if (this->contains(Permission::Store) ||
356+
this->contains(Permission::Load))
354357
{
355358
// data-rw format
356359
return PermissionSet{
357-
Permission::Global, Permission::Load, Permission::Store};
360+
Permission::Global, Permission::Load, Permission::Store};
358361
}
359362
// sealing format
360363
return PermissionSet{Permission::Global,
361-
Permission::Seal,
362-
Permission::Unseal,
363-
Permission::User0};
364+
Permission::Seal,
365+
Permission::Unseal,
366+
Permission::User0};
364367
}
365368

366369
/**
367-
* Returns a new PermissionSet that is the set of permissions that the
368-
* hardware would return if asked to encode this PermissionSet by
369-
* CAndPerms.
370-
*
371-
* The returned PermissionSet will always be a (possibly empty) subset of
372-
* `this`.
373-
*/
370+
* Returns a new PermissionSet that is the set of permissions that the
371+
* hardware would return if asked to encode this PermissionSet by
372+
* CAndPerms.
373+
*
374+
* The returned PermissionSet will always be a (possibly empty) subset
375+
* of `this`.
376+
*/
374377
[[nodiscard]] constexpr PermissionSet to_representable() const
375378
{
376379
return this->get_max_format_perms() & (*this);

tests/isa-test.cc

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ namespace
198198
{
199199
PermissionSet requestedPermissions(mask);
200200
requestedPermissions &= capability.permissions();
201-
PermissionSet expectedPermissions = requestedPermissions.to_representable();
201+
PermissionSet expectedPermissions =
202+
requestedPermissions.to_representable();
202203
capability.permissions() &= mask;
203204
TEST(capability.permissions() == expectedPermissions,
204205
"permissions {} did not match expected {}",
@@ -245,29 +246,36 @@ namespace
245246
void test_sentries()
246247
{
247248
// XXX the following produces a linker error:
248-
// 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
249-
// possible compiler / linker bug?
249+
// error: ld.lld: error: Compartment 'isa_test' imports library function
250+
// '__library_export_isa_test__ZN12_GLOBAL__N_129get_interrupts_enabled_sentryEv'
251+
// as cross-compartment call possible compiler / linker bug?
250252

251253
// Capability interruptsEnabledSentry = {get_interrupts_enabled_sentry};
252-
// debug_log("interrupts enabled sentry {}", reinterpret_cast<void*>(interruptsEnabledSentry.get()));
254+
// debug_log("interrupts enabled sentry {}",
255+
// reinterpret_cast<void*>(interruptsEnabledSentry.get()));
253256
// TEST(interruptsEnabledSentry.type() == 3,
254257
// "Expected type 3 but got {}",
255258
// interruptsEnabledSentry.type());
256259

257-
// Capability interruptsDisabledSentry = {&get_interrupts_disabled_sentry};
258-
// debug_log("interrupts disabled sentry {}", reinterpret_cast<void*>(interruptsDisabledSentry.get()));
260+
// Capability interruptsDisabledSentry =
261+
// {&get_interrupts_disabled_sentry}; debug_log("interrupts disabled
262+
// sentry {}", reinterpret_cast<void*>(interruptsDisabledSentry.get()));
259263
// TEST(interruptsDisabledSentry.type() == 2,
260264
// "Expected type 2 but got {}",
261265
// interruptsDisabledSentry.type());
262266

263-
Capability interruptsEnabledReturnSentry = {get_interrupts_enabled_sentry()};
264-
debug_log("interrupts enabled sentry {}", interruptsEnabledReturnSentry);
267+
Capability interruptsEnabledReturnSentry = {
268+
get_interrupts_enabled_sentry()};
269+
debug_log("interrupts enabled sentry {}",
270+
interruptsEnabledReturnSentry);
265271
TEST(interruptsEnabledReturnSentry.type() == 5,
266272
"Expected type 5 but got {}",
267273
interruptsEnabledReturnSentry.type());
268274

269-
Capability interruptsDisabledReturnSentry = {get_interrupts_disabled_sentry()};
270-
debug_log("interrupts disabled sentry {}", interruptsDisabledReturnSentry);
275+
Capability interruptsDisabledReturnSentry = {
276+
get_interrupts_disabled_sentry()};
277+
debug_log("interrupts disabled sentry {}",
278+
interruptsDisabledReturnSentry);
271279
TEST(interruptsDisabledReturnSentry.type() == 4,
272280
"Expected type 4 but got {}",
273281
interruptsDisabledReturnSentry.type());
@@ -463,15 +471,16 @@ namespace
463471
permission_filter<PermissionSet{Permission::Load,
464472
Permission::Store}>);
465473

466-
// TODO this is no longer expected to trap -- but would be good to check tag is cleared
474+
// TODO this is no longer expected to trap -- but would be good to check
475+
// tag is cleared
467476
debug_log("Attempting to store local capability in global");
468477
do_store_test(
469478
std::nullopt,
470479
permission_filter<PermissionSet{Permission::Load,
471480
Permission::Store,
472481
Permission::LoadStoreCapability}>,
473-
identity_filter,
474-
std::nullopt);
482+
identity_filter,
483+
std::nullopt);
475484

476485
debug_log("Attempt to store capability via too small bounds");
477486
do_store_test(
@@ -531,10 +540,7 @@ namespace
531540
// was changed in an ISA update.
532541
debug_log("Attempting to load capability via not-load-cap cap.");
533542
test_restricted_load(
534-
false,
535-
{Permission::Load},
536-
false,
537-
GlobalPermissions);
543+
false, {Permission::Load}, false, GlobalPermissions);
538544

539545
debug_log(
540546
"Attempting to load untagged capability via not-load-mutable cap.");
@@ -602,9 +608,10 @@ namespace
602608
do_jalr_test(CauseCode::PermitExecuteViolation,
603609
permission_filter<PermissionSet(Permission::Load)>);
604610

605-
// TODO we can no longer recover from this crash as the failure occurs at dest, not caller
606-
// debug_log("Attempting to jump to capability with too small bounds");
607-
// do_jalr_test(CauseCode::BoundsViolation, restrict_bounds_filter);
611+
// TODO we can no longer recover from this crash as the failure occurs
612+
// at dest, not caller debug_log("Attempting to jump to capability with
613+
// too small bounds"); do_jalr_test(CauseCode::BoundsViolation,
614+
// restrict_bounds_filter);
608615
}
609616

610617
/*

0 commit comments

Comments
 (0)