blob: 60bb82a400b76e8b75940c4bd88fd3d8cc1e0436 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#ifndef XEN_LIB_X86_PRIVATE_H
#define XEN_LIB_X86_PRIVATE_H
#ifdef __XEN__
#include <xen/bitops.h>
#include <xen/guest_access.h>
#include <xen/kernel.h>
#include <xen/lib.h>
#include <xen/nospec.h>
#include <xen/types.h>
#include <asm/msr-index.h>
#define copy_to_buffer_offset copy_to_guest_offset
#define copy_from_buffer_offset copy_from_guest_offset
#else
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <xen/asm/msr-index.h>
#include <xen/asm/x86-vendors.h>
#include <xen-tools/common-macros.h>
static inline bool test_bit(unsigned int bit, const void *vaddr)
{
const char *addr = vaddr;
return addr[bit / 8] & (1u << (bit % 8));
}
#define array_access_nospec(a, i) (a)[(i)]
/* memcpy(), but with copy_to_guest_offset()'s API. */
#define copy_to_buffer_offset(dst, index, src, nr) \
({ \
const typeof(*(src)) *src_ = (src); \
typeof(*(dst)) *dst_ = (dst); \
typeof(index) index_ = (index); \
typeof(nr) nr_ = (nr), i_; \
\
for ( i_ = 0; i_ < nr_; i_++ ) \
dst_[index_ + i_] = src_[i_]; \
0; \
})
/* memcpy(), but with copy_from_guest_offset()'s API. */
#define copy_from_buffer_offset(dst, src, index, nr) \
({ \
const typeof(*(src)) *src_ = (src); \
typeof(*(dst)) *dst_ = (dst); \
typeof(index) index_ = (index); \
typeof(nr) nr_ = (nr), i_; \
\
for ( i_ = 0; i_ < nr_; i_++ ) \
dst_[i_] = src_[index_ + i_]; \
0; \
})
#endif /* __XEN__ */
#endif /* XEN_LIB_X86_PRIVATE_H */
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
|