projects/linux·blob master · refs

31 lines · 845 B

1// SPDX-License-Identifier: GPL-2.0
2
3/*
4 * simple_ring_buffer is used by the pKVM hypervisor which does not have access
5 * to all kernel symbols. Whatever is undefined when compiling this file is
6 * compiler and tooling-generated symbols that can safely be ignored for
7 * simple_ring_buffer.
8 */
9
10#include <linux/atomic.h>
11#include <linux/string.h>
12#include <asm/local.h>
13#include <asm/page.h>
14
15void undefsyms_base(void *p, int n);
16
17static char page[PAGE_SIZE] __aligned(PAGE_SIZE);
18
19void undefsyms_base(void *p, int n)
20{
21 char buffer[256] = { 0 };
22 u32 u = 0;
23
24 memset((char * volatile)page, 8, PAGE_SIZE);
25 memset((char * volatile)buffer, 8, sizeof(buffer));
26 memcpy((void * volatile)p, buffer, sizeof(buffer));
27 cmpxchg((u32 * volatile)&u, 0, 8);
28 cmpxchg((unsigned long *)p, 0, 8);
29 local_set((local_t *)p, 8);
30 WARN_ON(n == 0xdeadbeef);
31}