]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - mm/kasan/report_hw_tags.c
Documentation: Add documentation for Processor MMIO Stale Data
[mirror_ubuntu-jammy-kernel.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 void *kasan_find_first_bad_addr(void *addr, size_t size)
19 {
20 return kasan_reset_tag(addr);
21 }
22
23 void kasan_metadata_fetch_row(char *buffer, void *row)
24 {
25 int i;
26
27 for (i = 0; i < META_BYTES_PER_ROW; i++)
28 buffer[i] = hw_get_mem_tag(row + i * KASAN_GRANULE_SIZE);
29 }
30
31 void kasan_print_tags(u8 addr_tag, const void *addr)
32 {
33 u8 memory_tag = hw_get_mem_tag((void *)addr);
34
35 pr_err("Pointer tag: [%02x], memory tag: [%02x]\n",
36 addr_tag, memory_tag);
37 }