Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arch/arm64/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <asm/cpu_ops.h>
#include <asm/ctxr_execmem.h>
#include <asm/daifflags.h>
#include <asm/kexec.h>
#include <asm/kvm_mmu.h>
#include <asm/mmu_context.h>
#include <asm/nmi.h>
Expand Down
8 changes: 7 additions & 1 deletion tools/aurora-sep/tests/test_diag_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ def test_selected_policy_and_identity_source_only(self):
prefix = '''#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
typedef uint64_t u64;
typedef uint32_t u32;
typedef int atomic_t;
typedef int64_t atomic64_t;
#define DECLARE_BITMAP(name, bits) unsigned long name[((bits) + 63) / 64]
struct device { int unused; };
struct device_attribute { int unused; };
#define atomic_read(p) (*(p))
Expand All @@ -47,6 +52,7 @@ def test_selected_policy_and_identity_source_only(self):
va_list args; va_start(args, fmt); int n = vsnprintf(out, 4096, fmt, args); va_end(args); return n;
}
'''
endpoint_limit = re.search(r'^#define SEP_DIAG_MAX_EP\s+\d+', text, re.M).group(0)
main = '''int main(void) {
char out[4096]; sep_diag.xart = true; sep_diag.xart_guard = 1;
sep_diag_set_policy(false, false, false, true, false, false);
Expand All @@ -60,7 +66,7 @@ def test_selected_policy_and_identity_source_only(self):
'''
with tempfile.TemporaryDirectory() as tmp:
source, program = Path(tmp) / 'policy.c', Path(tmp) / 'policy'
source.write_text(prefix + state + body + main)
source.write_text(prefix + endpoint_limit + '\n' + state + body + main)
subprocess.run([compiler, '-std=gnu11', '-Wall', '-Wextra', '-Werror',
'-Wno-unused-parameter', str(source), '-o', str(program)], check=True)
lines = subprocess.check_output([str(program)], text=True).splitlines()
Expand Down
61 changes: 60 additions & 1 deletion tools/aurora-sep/tests/test_diag_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
typedef uint64_t __u64; typedef uint32_t __u32; typedef uint16_t __u16; typedef uint8_t __u8;
typedef int64_t __s64; typedef int32_t __s32;
#define __user
#define READ_ONCE(x) __atomic_load_n(&(x), __ATOMIC_RELAXED)
#define WRITE_ONCE(x, v) __atomic_store_n(&(x), (v), __ATOMIC_RELAXED)
''',
'linux/atomic.h': r'''
#include <linux/types.h>
Expand All @@ -53,10 +55,50 @@
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
}
#define atomic_inc(v) __atomic_add_fetch(&(v)->counter, 1, __ATOMIC_SEQ_CST)
#define atomic_inc_return(v) atomic_inc(v)
#define atomic_xchg(v, i) __atomic_exchange_n(&(v)->counter, (i), __ATOMIC_SEQ_CST)
typedef struct { int64_t counter; } atomic64_t;
#define atomic64_read(v) __atomic_load_n(&(v)->counter, __ATOMIC_SEQ_CST)
static inline int64_t atomic64_cmpxchg(atomic64_t *v, int64_t old, int64_t new_)
{
__atomic_compare_exchange_n(&v->counter, &old, new_, false,
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
return old;
}
''',
'linux/bitmap.h': r'''
#include <linux/types.h>
#define BITS_PER_LONG (8 * sizeof(unsigned long))
#define DECLARE_BITMAP(name, bits) unsigned long name[((bits) + BITS_PER_LONG - 1) / BITS_PER_LONG]
static inline void set_bit(unsigned int bit, unsigned long *map)
{
map[bit / BITS_PER_LONG] |= 1UL << (bit % BITS_PER_LONG);
}
#define for_each_set_bit(bit, map, size) \
for ((bit) = 0; (bit) < (size); (bit)++) \
if ((map)[(bit) / BITS_PER_LONG] & (1UL << ((bit) % BITS_PER_LONG)))
''',
'linux/bitops.h': r'''
#define smp_rmb() __atomic_thread_fence(__ATOMIC_ACQUIRE)
#define smp_wmb() __atomic_thread_fence(__ATOMIC_RELEASE)
''',
'linux/ctype.h': '#include <ctype.h>\n',
'linux/ktime.h': r'''
#include <linux/types.h>
#include <time.h>
#define NSEC_PER_MSEC 1000000ULL
static inline u64 ktime_get_boottime_ns(void)
{
struct timespec now;
clock_gettime(CLOCK_BOOTTIME, &now);
return (u64)now.tv_sec * 1000000000ULL + now.tv_nsec;
}
static inline u64 div_u64(u64 value, u32 divisor) { return value / divisor; }
''',
'linux/device.h': r'''
#include <linux/types.h>
struct device { int unused; };
#define dev_info(dev, ...) ((void)(dev))
struct attribute { const char *name; umode_t mode; };
struct device_attribute {
struct attribute attr;
Expand Down Expand Up @@ -88,8 +130,25 @@
va_end(args);
return n;
}
static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
int n = vsnprintf(buf + at, 4096 - at, fmt, args);
va_end(args);
return n;
}
static inline int scnprintf(char *buf, size_t size, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
int n = vsnprintf(buf, size, fmt, args);
va_end(args);
return n < 0 ? 0 : ((size_t)n < size ? n : (size ? (int)size - 1 : 0));
}
''',
'linux/minmax.h': '#define min(a, b) ((a) < (b) ? (a) : (b))\n',
'linux/minmax.h': '#include <limits.h>\n#define min(a, b) ((a) < (b) ? (a) : (b))\n'
'#define min_t(type, a, b) min((type)(a), (type)(b))\n',
'linux/string.h': '#include <string.h>\n',
}

Expand Down
Loading