Commit bb2ee7d6 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Vincenzo Frascino
Browse files

TMP: Add boot testing module


Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
[Added SLUB specific test]
Co-developed-by: Vincenzo Frascino's avatarVincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Vincenzo Frascino's avatarVincenzo Frascino <vincenzo.frascino@arm.com>
parent f1ed41d9
Pipeline #1 canceled with stages
......@@ -7,11 +7,86 @@
#include <linux/init.h>
#include <sound/core.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/gfp.h>
#include <linux/slab.h>
#include <asm/mte.h>
#define GOOD_TAG 0x3
#define BAD_TAG 0x4
static void slub_mte_test(void)
{
uint64_t *p = kmalloc(sizeof(uint64_t), GFP_ATOMIC);
size_t size = ksize(p);
printk(KERN_INFO "SLUB Memory Tagging Test\n");
printk(KERN_INFO "p: 0x%llx %zu\n", (uint64_t)p, size);
p[0] = 1;
printk(KERN_INFO "p val: %llu\n", p[0]);
printk(KERN_INFO "kfree(p)\n");
kfree(p);
printk(KERN_INFO "write p\n");
p[0] = 0;
}
static void mte_test(void)
{
unsigned long *p;
pr_err("Memory Tagging Test\n");
p = kmalloc(128, GFP_KERNEL);
mte_set_mem_tag_range(p, 128, GOOD_TAG);
p = (void *)__tag_set(p, 0xf0 | GOOD_TAG);
pr_err("p = %px\n", p);
pr_err("do p[0] = 1\n");
p[0] = 1;
p = (void *)__tag_set(p, 0xf0 | BAD_TAG);
pr_err("p = %px\n", p);
pr_err("do p[0] = 2\n");
p[0] = 2;
}
static void kasan_mte_test(void)
{
unsigned char *p;
pr_err("KASAN MTE Test\n");
p = kmalloc(128, GFP_KERNEL);
pr_err("p = %px\n", p);
pr_err("mte_get_mem_tag(p) = %02x\n", mte_get_mem_tag(p));
pr_err("do p[0] = 1\n");
p[0] = 1;
pr_err("do p[130] = 2\n");
p[130] = 2;
pr_err("do read (int *)&p[144]\n");
pr_err(" %x\n", *((int *)&p[144]));
pr_err("do kfree(p)\n");
kfree(p);
pr_err("do p[0] = 3\n");
p[0] = 3;
}
static int __init alsa_sound_last_init(void)
{
struct snd_card *card;
int idx, ok = 0;
printk(KERN_INFO "ALSA device list:\n");
for (idx = 0; idx < SNDRV_CARDS; idx++) {
card = snd_card_ref(idx);
......@@ -23,6 +98,11 @@ static int __init alsa_sound_last_init(void)
}
if (ok == 0)
printk(KERN_INFO " No soundcards found.\n");
slub_mte_test();
//mte_test();
//kasan_mte_test();
return 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment