tools headers UAPI: Sync linux/prctl.h with the kernel sources
[linux-2.6-microblaze.git] / mm / kasan / report_hw_tags.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * This file contains hardware tag-based KASAN specific error reporting code.
4  *
5  * Copyright (c) 2020 Google, Inc.
6  * Author: Andrey Konovalov <andreyknvl@google.com>
7  */
8
9 #include <linux/kasan.h>
10 #include <linux/kernel.h>
11 #include <linux/memory.h>
12 #include <linux/mm.h>
13 #include <linux/string.h>
14 #include <linux/types.h>
15
16 #include "kasan.h"
17
18 const char *get_bug_type(struct kasan_access_info *info)
19 {
20         return "invalid-access";
21 }
22
23 void *find_first_bad_addr(void *addr, size_t size)
24 {
25         return kasan_reset_tag(addr);
26 }
27
28 void metadata_fetch_row(char *buffer, void *row)
29 {
30         int i;
31
32         for (i = 0; i < META_BYTES_PER_ROW; i++)
33                 buffer[i] = hw_get_mem_tag(row + i * KASAN_GRANULE_SIZE);
34 }
35
36 void print_tags(u8 addr_tag, const void *addr)
37 {
38         u8 memory_tag = hw_get_mem_tag((void *)addr);
39
40         pr_err("Pointer tag: [%02x], memory tag: [%02x]\n",
41                 addr_tag, memory_tag);
42 }