qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

vhost, pc, virtio features, fixes, cleanups

New features:
VT-d support for devices behind a bridge
vhost-user migration support

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

# gpg: Signature made Thu 22 Oct 2015 12:39:19 BST using RSA key ID D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg: aka "Michael S. Tsirkin <mst@redhat.com>"

* remotes/mst/tags/for_upstream: (37 commits)
hw/isa/lpc_ich9: inject the SMI on the VCPU that is writing to APM_CNT
i386: keep cpu_model field in MachineState uptodate
vhost: set the correct queue index in case of migration with multiqueue
piix: fix resource leak reported by Coverity
seccomp: add memfd_create to whitelist
vhost-user-test: check ownership during migration
vhost-user-test: add live-migration test
vhost-user-test: learn to tweak various qemu arguments
vhost-user-test: wrap server in TestServer struct
vhost-user-test: remove useless static check
vhost-user-test: move wait_for_fds() out
vhost: add migration block if memfd failed
vhost-user: use an enum helper for features mask
vhost user: add rarp sending after live migration for legacy guest
vhost user: add support of live migration
net: add trace_vhost_user_event
vhost-user: document migration log
vhost: use a function for each call
vhost-user: add a migration blocker
vhost-user: send log shm fd along with log_base
...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+5064 -450
+19
configure
··· 3491 3491 eventfd=yes 3492 3492 fi 3493 3493 3494 + # check if memfd is supported 3495 + memfd=no 3496 + cat > $TMPC << EOF 3497 + #include <sys/memfd.h> 3498 + 3499 + int main(void) 3500 + { 3501 + return memfd_create("foo", MFD_ALLOW_SEALING); 3502 + } 3503 + EOF 3504 + if compile_prog "" "" ; then 3505 + memfd=yes 3506 + fi 3507 + 3508 + 3509 + 3494 3510 # check for fallocate 3495 3511 fallocate=no 3496 3512 cat > $TMPC << EOF ··· 4884 4900 fi 4885 4901 if test "$eventfd" = "yes" ; then 4886 4902 echo "CONFIG_EVENTFD=y" >> $config_host_mak 4903 + fi 4904 + if test "$memfd" = "yes" ; then 4905 + echo "CONFIG_MEMFD=y" >> $config_host_mak 4887 4906 fi 4888 4907 if test "$fallocate" = "yes" ; then 4889 4908 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
+61 -2
docs/specs/vhost-user.txt
··· 115 115 * VHOST_GET_FEATURES 116 116 * VHOST_GET_PROTOCOL_FEATURES 117 117 * VHOST_GET_VRING_BASE 118 + * VHOST_SET_LOG_BASE (if VHOST_USER_PROTOCOL_F_LOG_SHMFD) 118 119 119 120 There are several messages that the master sends with file descriptors passed 120 121 in the ancillary data: 121 122 122 123 * VHOST_SET_MEM_TABLE 124 + * VHOST_SET_LOG_BASE (if VHOST_USER_PROTOCOL_F_LOG_SHMFD) 123 125 * VHOST_SET_LOG_FD 124 126 * VHOST_SET_VRING_KICK 125 127 * VHOST_SET_VRING_CALL ··· 140 142 141 143 Multiple queue is treated as a protocol extension, hence the slave has to 142 144 implement protocol features first. The multiple queues feature is supported 143 - only when the protocol feature VHOST_USER_PROTOCOL_F_MQ (bit 0) is set: 144 - #define VHOST_USER_PROTOCOL_F_MQ 0 145 + only when the protocol feature VHOST_USER_PROTOCOL_F_MQ (bit 0) is set. 145 146 146 147 The max number of queues the slave supports can be queried with message 147 148 VHOST_USER_GET_PROTOCOL_FEATURES. Master should stop when the number of ··· 152 153 is enabled initially. More queues are enabled dynamically, by sending 153 154 message VHOST_USER_SET_VRING_ENABLE. 154 155 156 + Migration 157 + --------- 158 + 159 + During live migration, the master may need to track the modifications 160 + the slave makes to the memory mapped regions. The client should mark 161 + the dirty pages in a log. Once it complies to this logging, it may 162 + declare the VHOST_F_LOG_ALL vhost feature. 163 + 164 + All the modifications to memory pointed by vring "descriptor" should 165 + be marked. Modifications to "used" vring should be marked if 166 + VHOST_VRING_F_LOG is part of ring's features. 167 + 168 + Dirty pages are of size: 169 + #define VHOST_LOG_PAGE 0x1000 170 + 171 + The log memory fd is provided in the ancillary data of 172 + VHOST_USER_SET_LOG_BASE message when the slave has 173 + VHOST_USER_PROTOCOL_F_LOG_SHMFD protocol feature. 174 + 175 + The size of the log may be computed by using all the known guest 176 + addresses. The log covers from address 0 to the maximum of guest 177 + regions. In pseudo-code, to mark page at "addr" as dirty: 178 + 179 + page = addr / VHOST_LOG_PAGE 180 + log[page / 8] |= 1 << page % 8 181 + 182 + Use atomic operations, as the log may be concurrently manipulated. 183 + 184 + VHOST_USER_SET_LOG_FD is an optional message with an eventfd in 185 + ancillary data, it may be used to inform the master that the log has 186 + been modified. 187 + 188 + Once the source has finished migration, VHOST_USER_RESET_OWNER message 189 + will be sent by the source. No further update must be done before the 190 + destination takes over with new regions & rings. 191 + 192 + Protocol features 193 + ----------------- 194 + 195 + #define VHOST_USER_PROTOCOL_F_MQ 0 196 + #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 197 + #define VHOST_USER_PROTOCOL_F_RARP 2 198 + 155 199 Message types 156 200 ------------- 157 201 ··· 236 280 Id: 6 237 281 Equivalent ioctl: VHOST_SET_LOG_BASE 238 282 Master payload: u64 283 + Slave payload: N/A 239 284 240 285 Sets the logging base address. 241 286 ··· 337 382 Master payload: vring state description 338 383 339 384 Signal slave to enable or disable corresponding vring. 385 + 386 + * VHOST_USER_SEND_RARP 387 + 388 + Id: 19 389 + Equivalent ioctl: N/A 390 + Master payload: u64 391 + 392 + Ask vhost user backend to broadcast a fake RARP to notify the migration 393 + is terminated for guest that does not support GUEST_ANNOUNCE. 394 + Only legal if feature bit VHOST_USER_F_PROTOCOL_FEATURES is present in 395 + VHOST_USER_GET_FEATURES and protocol feature bit VHOST_USER_PROTOCOL_F_RARP 396 + is present in VHOST_USER_GET_PROTOCOL_FEATURES. 397 + The first 6 bytes of the payload contain the mac address of the guest to 398 + allow the vhost user backend to construct and broadcast the fake RARP.
+106
docs/virtio-migration.txt
··· 1 + Virtio devices and migration 2 + ============================ 3 + 4 + Copyright 2015 IBM Corp. 5 + 6 + This work is licensed under the terms of the GNU GPL, version 2 or later. See 7 + the COPYING file in the top-level directory. 8 + 9 + Saving and restoring the state of virtio devices is a bit of a twisty maze, 10 + for several reasons: 11 + - state is distributed between several parts: 12 + - virtio core, for common fields like features, number of queues, ... 13 + - virtio transport (pci, ccw, ...), for the different proxy devices and 14 + transport specific state (msix vectors, indicators, ...) 15 + - virtio device (net, blk, ...), for the different device types and their 16 + state (mac address, request queue, ...) 17 + - most fields are saved via the stream interface; subsequently, subsections 18 + have been added to make cross-version migration possible 19 + 20 + This file attempts to document the current procedure and point out some 21 + caveats. 22 + 23 + 24 + Save state procedure 25 + ==================== 26 + 27 + virtio core virtio transport virtio device 28 + ----------- ---------------- ------------- 29 + 30 + save() function registered 31 + via register_savevm() 32 + virtio_save() <---------- 33 + ------> save_config() 34 + - save proxy device 35 + - save transport-specific 36 + device fields 37 + - save common device 38 + fields 39 + - save common virtqueue 40 + fields 41 + ------> save_queue() 42 + - save transport-specific 43 + virtqueue fields 44 + ------> save_device() 45 + - save device-specific 46 + fields 47 + - save subsections 48 + - device endianness, 49 + if changed from 50 + default endianness 51 + - 64 bit features, if 52 + any high feature bit 53 + is set 54 + - virtio-1 virtqueue 55 + fields, if VERSION_1 56 + is set 57 + 58 + 59 + Load state procedure 60 + ==================== 61 + 62 + virtio core virtio transport virtio device 63 + ----------- ---------------- ------------- 64 + 65 + load() function registered 66 + via register_savevm() 67 + virtio_load() <---------- 68 + ------> load_config() 69 + - load proxy device 70 + - load transport-specific 71 + device fields 72 + - load common device 73 + fields 74 + - load common virtqueue 75 + fields 76 + ------> load_queue() 77 + - load transport-specific 78 + virtqueue fields 79 + - notify guest 80 + ------> load_device() 81 + - load device-specific 82 + fields 83 + - load subsections 84 + - device endianness 85 + - 64 bit features 86 + - virtio-1 virtqueue 87 + fields 88 + - sanitize endianness 89 + - sanitize features 90 + - virtqueue index sanity 91 + check 92 + - feature-dependent setup 93 + 94 + 95 + Implications of this setup 96 + ========================== 97 + 98 + Devices need to be careful in their state processing during load: The 99 + load_device() procedure is invoked by the core before subsections have 100 + been loaded. Any code that depends on information transmitted in subsections 101 + therefore has to be invoked in the device's load() function _after_ 102 + virtio_load() returned (like e.g. code depending on features). 103 + 104 + Any extension of the state being migrated should be done in subsections 105 + added to the core for compatibility reasons. If transport or device specific 106 + state is added, core needs to invoke a callback from the new subsection.
+10 -37
exec.c
··· 55 55 #include "exec/ram_addr.h" 56 56 57 57 #include "qemu/range.h" 58 + #ifndef _WIN32 59 + #include "qemu/mmap-alloc.h" 60 + #endif 58 61 59 62 //#define DEBUG_SUBPAGE 60 63 ··· 84 87 */ 85 88 #define RAM_RESIZEABLE (1 << 2) 86 89 87 - /* An extra page is mapped on top of this RAM. 90 + /* RAM is backed by an mmapped file. 88 91 */ 89 - #define RAM_EXTRA (1 << 3) 92 + #define RAM_FILE (1 << 3) 90 93 #endif 91 94 92 95 struct CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus); ··· 1205 1208 char *filename; 1206 1209 char *sanitized_name; 1207 1210 char *c; 1208 - void *ptr; 1209 - void *area = NULL; 1211 + void *area; 1210 1212 int fd; 1211 1213 uint64_t hpagesize; 1212 - uint64_t total; 1213 1214 Error *local_err = NULL; 1214 - size_t offset; 1215 1215 1216 1216 hpagesize = gethugepagesize(path, &local_err); 1217 1217 if (local_err) { ··· 1255 1255 g_free(filename); 1256 1256 1257 1257 memory = ROUND_UP(memory, hpagesize); 1258 - total = memory + hpagesize; 1259 1258 1260 1259 /* 1261 1260 * ftruncate is not supported by hugetlbfs in older ··· 1267 1266 perror("ftruncate"); 1268 1267 } 1269 1268 1270 - ptr = mmap(0, total, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 1271 - -1, 0); 1272 - if (ptr == MAP_FAILED) { 1273 - error_setg_errno(errp, errno, 1274 - "unable to allocate memory range for hugepages"); 1275 - close(fd); 1276 - goto error; 1277 - } 1278 - 1279 - offset = QEMU_ALIGN_UP((uintptr_t)ptr, hpagesize) - (uintptr_t)ptr; 1280 - 1281 - area = mmap(ptr + offset, memory, PROT_READ | PROT_WRITE, 1282 - (block->flags & RAM_SHARED ? MAP_SHARED : MAP_PRIVATE) | 1283 - MAP_FIXED, 1284 - fd, 0); 1269 + area = qemu_ram_mmap(fd, memory, hpagesize, block->flags & RAM_SHARED); 1285 1270 if (area == MAP_FAILED) { 1286 1271 error_setg_errno(errp, errno, 1287 1272 "unable to map backing store for hugepages"); 1288 - munmap(ptr, total); 1289 1273 close(fd); 1290 1274 goto error; 1291 - } 1292 - 1293 - if (offset > 0) { 1294 - munmap(ptr, offset); 1295 - } 1296 - ptr += offset; 1297 - total -= offset; 1298 - 1299 - if (total > memory + getpagesize()) { 1300 - munmap(ptr + memory + getpagesize(), 1301 - total - memory - getpagesize()); 1302 1275 } 1303 1276 1304 1277 if (mem_prealloc) { ··· 1618 1591 new_block->used_length = size; 1619 1592 new_block->max_length = size; 1620 1593 new_block->flags = share ? RAM_SHARED : 0; 1621 - new_block->flags |= RAM_EXTRA; 1594 + new_block->flags |= RAM_FILE; 1622 1595 new_block->host = file_ram_alloc(new_block, size, 1623 1596 mem_path, errp); 1624 1597 if (!new_block->host) { ··· 1720 1693 xen_invalidate_map_cache_entry(block->host); 1721 1694 #ifndef _WIN32 1722 1695 } else if (block->fd >= 0) { 1723 - if (block->flags & RAM_EXTRA) { 1724 - munmap(block->host, block->max_length + getpagesize()); 1696 + if (block->flags & RAM_FILE) { 1697 + qemu_ram_munmap(block->host, block->max_length); 1725 1698 } else { 1726 1699 munmap(block->host, block->max_length); 1727 1700 }
+73 -16
hw/i386/intel_iommu.c
··· 22 22 #include "hw/sysbus.h" 23 23 #include "exec/address-spaces.h" 24 24 #include "intel_iommu_internal.h" 25 + #include "hw/pci/pci.h" 25 26 26 27 /*#define DEBUG_INTEL_IOMMU*/ 27 28 #ifdef DEBUG_INTEL_IOMMU ··· 166 167 */ 167 168 static void vtd_reset_context_cache(IntelIOMMUState *s) 168 169 { 169 - VTDAddressSpace **pvtd_as; 170 170 VTDAddressSpace *vtd_as; 171 - uint32_t bus_it; 171 + VTDBus *vtd_bus; 172 + GHashTableIter bus_it; 172 173 uint32_t devfn_it; 173 174 175 + g_hash_table_iter_init(&bus_it, s->vtd_as_by_busptr); 176 + 174 177 VTD_DPRINTF(CACHE, "global context_cache_gen=1"); 175 - for (bus_it = 0; bus_it < VTD_PCI_BUS_MAX; ++bus_it) { 176 - pvtd_as = s->address_spaces[bus_it]; 177 - if (!pvtd_as) { 178 - continue; 179 - } 178 + while (g_hash_table_iter_next (&bus_it, NULL, (void**)&vtd_bus)) { 180 179 for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX; ++devfn_it) { 181 - vtd_as = pvtd_as[devfn_it]; 180 + vtd_as = vtd_bus->dev_as[devfn_it]; 182 181 if (!vtd_as) { 183 182 continue; 184 183 } ··· 754 753 * @is_write: The access is a write operation 755 754 * @entry: IOMMUTLBEntry that contain the addr to be translated and result 756 755 */ 757 - static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, uint8_t bus_num, 756 + static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, 758 757 uint8_t devfn, hwaddr addr, bool is_write, 759 758 IOMMUTLBEntry *entry) 760 759 { 761 760 IntelIOMMUState *s = vtd_as->iommu_state; 762 761 VTDContextEntry ce; 762 + uint8_t bus_num = pci_bus_num(bus); 763 763 VTDContextCacheEntry *cc_entry = &vtd_as->context_cache_entry; 764 764 uint64_t slpte; 765 765 uint32_t level; ··· 874 874 } 875 875 } 876 876 877 + 878 + /* Find the VTD address space currently associated with a given bus number, 879 + */ 880 + static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s, uint8_t bus_num) 881 + { 882 + VTDBus *vtd_bus = s->vtd_as_by_bus_num[bus_num]; 883 + if (!vtd_bus) { 884 + /* Iterate over the registered buses to find the one 885 + * which currently hold this bus number, and update the bus_num lookup table: 886 + */ 887 + GHashTableIter iter; 888 + 889 + g_hash_table_iter_init(&iter, s->vtd_as_by_busptr); 890 + while (g_hash_table_iter_next (&iter, NULL, (void**)&vtd_bus)) { 891 + if (pci_bus_num(vtd_bus->bus) == bus_num) { 892 + s->vtd_as_by_bus_num[bus_num] = vtd_bus; 893 + return vtd_bus; 894 + } 895 + } 896 + } 897 + return vtd_bus; 898 + } 899 + 877 900 /* Do a context-cache device-selective invalidation. 878 901 * @func_mask: FM field after shifting 879 902 */ ··· 882 905 uint16_t func_mask) 883 906 { 884 907 uint16_t mask; 885 - VTDAddressSpace **pvtd_as; 908 + VTDBus *vtd_bus; 886 909 VTDAddressSpace *vtd_as; 887 910 uint16_t devfn; 888 911 uint16_t devfn_it; ··· 903 926 } 904 927 VTD_DPRINTF(INV, "device-selective invalidation source 0x%"PRIx16 905 928 " mask %"PRIu16, source_id, mask); 906 - pvtd_as = s->address_spaces[VTD_SID_TO_BUS(source_id)]; 907 - if (pvtd_as) { 929 + vtd_bus = vtd_find_as_from_bus_num(s, VTD_SID_TO_BUS(source_id)); 930 + if (vtd_bus) { 908 931 devfn = VTD_SID_TO_DEVFN(source_id); 909 932 for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX; ++devfn_it) { 910 - vtd_as = pvtd_as[devfn_it]; 933 + vtd_as = vtd_bus->dev_as[devfn_it]; 911 934 if (vtd_as && ((devfn_it & mask) == (devfn & mask))) { 912 935 VTD_DPRINTF(INV, "invalidate context-cahce of devfn 0x%"PRIx16, 913 936 devfn_it); ··· 1805 1828 return ret; 1806 1829 } 1807 1830 1808 - vtd_do_iommu_translate(vtd_as, vtd_as->bus_num, vtd_as->devfn, addr, 1831 + vtd_do_iommu_translate(vtd_as, vtd_as->bus, vtd_as->devfn, addr, 1809 1832 is_write, &ret); 1810 1833 VTD_DPRINTF(MMU, 1811 1834 "bus %"PRIu8 " slot %"PRIu8 " func %"PRIu8 " devfn %"PRIu8 1812 - " gpa 0x%"PRIx64 " hpa 0x%"PRIx64, vtd_as->bus_num, 1835 + " gpa 0x%"PRIx64 " hpa 0x%"PRIx64, pci_bus_num(vtd_as->bus), 1813 1836 VTD_PCI_SLOT(vtd_as->devfn), VTD_PCI_FUNC(vtd_as->devfn), 1814 1837 vtd_as->devfn, addr, ret.translated_addr); 1815 1838 return ret; ··· 1838 1861 DEFINE_PROP_UINT32("version", IntelIOMMUState, version, 0), 1839 1862 DEFINE_PROP_END_OF_LIST(), 1840 1863 }; 1864 + 1865 + 1866 + VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) 1867 + { 1868 + uintptr_t key = (uintptr_t)bus; 1869 + VTDBus *vtd_bus = g_hash_table_lookup(s->vtd_as_by_busptr, &key); 1870 + VTDAddressSpace *vtd_dev_as; 1871 + 1872 + if (!vtd_bus) { 1873 + /* No corresponding free() */ 1874 + vtd_bus = g_malloc0(sizeof(VTDBus) + sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX); 1875 + vtd_bus->bus = bus; 1876 + key = (uintptr_t)bus; 1877 + g_hash_table_insert(s->vtd_as_by_busptr, &key, vtd_bus); 1878 + } 1879 + 1880 + vtd_dev_as = vtd_bus->dev_as[devfn]; 1881 + 1882 + if (!vtd_dev_as) { 1883 + vtd_bus->dev_as[devfn] = vtd_dev_as = g_malloc0(sizeof(VTDAddressSpace)); 1884 + 1885 + vtd_dev_as->bus = bus; 1886 + vtd_dev_as->devfn = (uint8_t)devfn; 1887 + vtd_dev_as->iommu_state = s; 1888 + vtd_dev_as->context_cache_entry.context_cache_gen = 0; 1889 + memory_region_init_iommu(&vtd_dev_as->iommu, OBJECT(s), 1890 + &s->iommu_ops, "intel_iommu", UINT64_MAX); 1891 + address_space_init(&vtd_dev_as->as, 1892 + &vtd_dev_as->iommu, "intel_iommu"); 1893 + } 1894 + return vtd_dev_as; 1895 + } 1841 1896 1842 1897 /* Do the initialization. It will also be called when reset, so pay 1843 1898 * attention when adding new initialization stuff. ··· 1931 1986 IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev); 1932 1987 1933 1988 VTD_DPRINTF(GENERAL, ""); 1934 - memset(s->address_spaces, 0, sizeof(s->address_spaces)); 1989 + memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num)); 1935 1990 memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, 1936 1991 "intel_iommu", DMAR_REG_SIZE); 1937 1992 sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem); 1938 1993 /* No corresponding destroy */ 1939 1994 s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal, 1940 1995 g_free, g_free); 1996 + s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal, 1997 + g_free, g_free); 1941 1998 vtd_init(s); 1942 1999 } 1943 2000
+8 -9
hw/i386/pc.c
··· 1078 1078 return cpu; 1079 1079 } 1080 1080 1081 - static const char *current_cpu_model; 1082 - 1083 1081 void pc_hot_add_cpu(const int64_t id, Error **errp) 1084 1082 { 1085 1083 X86CPU *cpu; 1084 + MachineState *machine = MACHINE(qdev_get_machine()); 1086 1085 int64_t apic_id = x86_cpu_apic_id_from_index(id); 1087 1086 Error *local_err = NULL; 1088 1087 ··· 1110 1109 return; 1111 1110 } 1112 1111 1113 - cpu = pc_new_cpu(current_cpu_model, apic_id, &local_err); 1112 + cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err); 1114 1113 if (local_err) { 1115 1114 error_propagate(errp, local_err); 1116 1115 return; ··· 1118 1117 object_unref(OBJECT(cpu)); 1119 1118 } 1120 1119 1121 - void pc_cpus_init(const char *cpu_model) 1120 + void pc_cpus_init(PCMachineState *pcms) 1122 1121 { 1123 1122 int i; 1124 1123 X86CPU *cpu = NULL; 1124 + MachineState *machine = MACHINE(pcms); 1125 1125 Error *error = NULL; 1126 1126 unsigned long apic_id_limit; 1127 1127 1128 1128 /* init CPUs */ 1129 - if (cpu_model == NULL) { 1129 + if (machine->cpu_model == NULL) { 1130 1130 #ifdef TARGET_X86_64 1131 - cpu_model = "qemu64"; 1131 + machine->cpu_model = "qemu64"; 1132 1132 #else 1133 - cpu_model = "qemu32"; 1133 + machine->cpu_model = "qemu32"; 1134 1134 #endif 1135 1135 } 1136 - current_cpu_model = cpu_model; 1137 1136 1138 1137 apic_id_limit = pc_apic_id_limit(max_cpus); 1139 1138 if (apic_id_limit > ACPI_CPU_HOTPLUG_ID_LIMIT) { ··· 1143 1142 } 1144 1143 1145 1144 for (i = 0; i < smp_cpus; i++) { 1146 - cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i), 1145 + cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i), 1147 1146 &error); 1148 1147 if (error) { 1149 1148 error_report_err(error);
+1 -1
hw/i386/pc_piix.c
··· 139 139 exit(1); 140 140 } 141 141 142 - pc_cpus_init(machine->cpu_model); 142 + pc_cpus_init(pcms); 143 143 144 144 if (kvm_enabled() && kvmclock_enabled) { 145 145 kvmclock_create();
+1 -1
hw/i386/pc_q35.c
··· 128 128 exit(1); 129 129 } 130 130 131 - pc_cpus_init(machine->cpu_model); 131 + pc_cpus_init(pcms); 132 132 pc_acpi_init("q35-acpi-dsdt.aml"); 133 133 134 134 kvmclock_create();
+1 -1
hw/isa/lpc_ich9.c
··· 394 394 395 395 /* SMI_EN = PMBASE + 30. SMI control and enable register */ 396 396 if (lpc->pm.smi_en & ICH9_PMIO_SMI_EN_APMC_EN) { 397 - cpu_interrupt(first_cpu, CPU_INTERRUPT_SMI); 397 + cpu_interrupt(current_cpu, CPU_INTERRUPT_SMI); 398 398 } 399 399 } 400 400
+7
hw/mem/pc-dimm.c
··· 25 25 #include "sysemu/numa.h" 26 26 #include "sysemu/kvm.h" 27 27 #include "trace.h" 28 + #include "hw/virtio/vhost.h" 28 29 29 30 typedef struct pc_dimms_capacity { 30 31 uint64_t size; ··· 93 94 94 95 if (kvm_enabled() && !kvm_has_free_slot(machine)) { 95 96 error_setg(&local_err, "hypervisor has no free memory slots left"); 97 + goto out; 98 + } 99 + 100 + if (!vhost_has_free_slot()) { 101 + error_setg(&local_err, "a used vhost backend has no free" 102 + " memory slots left"); 96 103 goto out; 97 104 } 98 105
+25 -10
hw/net/vhost_net.c
··· 85 85 VIRTIO_NET_F_CTRL_MAC_ADDR, 86 86 VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, 87 87 88 + VIRTIO_NET_F_GUEST_ANNOUNCE, 89 + 88 90 VIRTIO_NET_F_MQ, 89 91 90 92 VHOST_INVALID_FEATURE_BIT ··· 252 254 file.fd = net->backend; 253 255 for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { 254 256 const VhostOps *vhost_ops = net->dev.vhost_ops; 255 - r = vhost_ops->vhost_call(&net->dev, VHOST_NET_SET_BACKEND, 256 - &file); 257 + r = vhost_ops->vhost_net_set_backend(&net->dev, &file); 257 258 if (r < 0) { 258 259 r = -errno; 259 260 goto fail; ··· 266 267 if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) { 267 268 while (file.index-- > 0) { 268 269 const VhostOps *vhost_ops = net->dev.vhost_ops; 269 - int r = vhost_ops->vhost_call(&net->dev, VHOST_NET_SET_BACKEND, 270 - &file); 270 + int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); 271 271 assert(r >= 0); 272 272 } 273 273 } ··· 289 289 if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) { 290 290 for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { 291 291 const VhostOps *vhost_ops = net->dev.vhost_ops; 292 - int r = vhost_ops->vhost_call(&net->dev, VHOST_NET_SET_BACKEND, 293 - &file); 292 + int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); 294 293 assert(r >= 0); 295 294 } 296 295 } else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { 297 296 for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { 298 297 const VhostOps *vhost_ops = net->dev.vhost_ops; 299 - int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_DEVICE, 300 - NULL); 298 + int r = vhost_ops->vhost_reset_device(&net->dev); 301 299 assert(r >= 0); 302 300 } 303 301 } ··· 390 388 g_free(net); 391 389 } 392 390 391 + int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr) 392 + { 393 + const VhostOps *vhost_ops = net->dev.vhost_ops; 394 + int r = -1; 395 + 396 + if (vhost_ops->vhost_migration_done) { 397 + r = vhost_ops->vhost_migration_done(&net->dev, mac_addr); 398 + } 399 + 400 + return r; 401 + } 402 + 393 403 bool vhost_net_virtqueue_pending(VHostNetState *net, int idx) 394 404 { 395 405 return vhost_virtqueue_pending(&net->dev, idx); ··· 428 438 VHostNetState *net = get_vhost_net(nc); 429 439 const VhostOps *vhost_ops = net->dev.vhost_ops; 430 440 431 - if (vhost_ops->vhost_backend_set_vring_enable) { 432 - return vhost_ops->vhost_backend_set_vring_enable(&net->dev, enable); 441 + if (vhost_ops->vhost_set_vring_enable) { 442 + return vhost_ops->vhost_set_vring_enable(&net->dev, enable); 433 443 } 434 444 435 445 return 0; ··· 479 489 void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, 480 490 int idx, bool mask) 481 491 { 492 + } 493 + 494 + int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr) 495 + { 496 + return -1; 482 497 } 483 498 484 499 VHostNetState *get_vhost_net(NetClientState *nc)
+7 -4
hw/pci-host/piix.c
··· 764 764 /* Access real host bridge. */ 765 765 int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s", 766 766 0, 0, 0, 0, "config"); 767 + int ret = 0; 767 768 768 769 if (rc >= size || rc < 0) { 769 770 return -ENODEV; ··· 775 776 } 776 777 777 778 if (lseek(config_fd, pos, SEEK_SET) != pos) { 778 - return -errno; 779 + ret = -errno; 780 + goto out; 779 781 } 780 782 do { 781 783 rc = read(config_fd, (uint8_t *)&val, len); 782 784 } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); 783 785 if (rc != len) { 784 - return -errno; 786 + ret = -errno; 785 787 } 786 - 787 - return 0; 788 + out: 789 + close(config_fd); 790 + return ret; 788 791 } 789 792 790 793 static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev)
+3 -22
hw/pci-host/q35.c
··· 426 426 static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) 427 427 { 428 428 IntelIOMMUState *s = opaque; 429 - VTDAddressSpace **pvtd_as; 430 - int bus_num = pci_bus_num(bus); 429 + VTDAddressSpace *vtd_as; 431 430 432 - assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX); 433 431 assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX); 434 432 435 - pvtd_as = s->address_spaces[bus_num]; 436 - if (!pvtd_as) { 437 - /* No corresponding free() */ 438 - pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX); 439 - s->address_spaces[bus_num] = pvtd_as; 440 - } 441 - if (!pvtd_as[devfn]) { 442 - pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace)); 443 - 444 - pvtd_as[devfn]->bus_num = (uint8_t)bus_num; 445 - pvtd_as[devfn]->devfn = (uint8_t)devfn; 446 - pvtd_as[devfn]->iommu_state = s; 447 - pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0; 448 - memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s), 449 - &s->iommu_ops, "intel_iommu", UINT64_MAX); 450 - address_space_init(&pvtd_as[devfn]->as, 451 - &pvtd_as[devfn]->iommu, "intel_iommu"); 452 - } 453 - return &pvtd_as[devfn]->as; 433 + vtd_as = vtd_find_add_as(s, bus, devfn); 434 + return &vtd_as->as; 454 435 } 455 436 456 437 static void mch_init_dmar(MCHPCIState *mch)
+3 -4
hw/scsi/vhost-scsi.c
··· 46 46 47 47 memset(&backend, 0, sizeof(backend)); 48 48 pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn); 49 - ret = vhost_ops->vhost_call(&s->dev, VHOST_SCSI_SET_ENDPOINT, &backend); 49 + ret = vhost_ops->vhost_scsi_set_endpoint(&s->dev, &backend); 50 50 if (ret < 0) { 51 51 return -errno; 52 52 } ··· 61 61 62 62 memset(&backend, 0, sizeof(backend)); 63 63 pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn); 64 - vhost_ops->vhost_call(&s->dev, VHOST_SCSI_CLEAR_ENDPOINT, &backend); 64 + vhost_ops->vhost_scsi_clear_endpoint(&s->dev, &backend); 65 65 } 66 66 67 67 static int vhost_scsi_start(VHostSCSI *s) ··· 77 77 return -ENOSYS; 78 78 } 79 79 80 - ret = vhost_ops->vhost_call(&s->dev, 81 - VHOST_SCSI_GET_ABI_VERSION, &abi_version); 80 + ret = vhost_ops->vhost_scsi_get_abi_version(&s->dev, &abi_version); 82 81 if (ret < 0) { 83 82 return -errno; 84 83 }
+136 -2
hw/virtio/vhost-backend.c
··· 11 11 #include "hw/virtio/vhost.h" 12 12 #include "hw/virtio/vhost-backend.h" 13 13 #include "qemu/error-report.h" 14 + #include "linux/vhost.h" 14 15 15 16 #include <sys/ioctl.h> 16 17 ··· 42 43 return close(fd); 43 44 } 44 45 46 + static int vhost_kernel_memslots_limit(struct vhost_dev *dev) 47 + { 48 + int limit = 64; 49 + char *s; 50 + 51 + if (g_file_get_contents("/sys/module/vhost/parameters/max_mem_regions", 52 + &s, NULL, NULL)) { 53 + uint64_t val = g_ascii_strtoull(s, NULL, 10); 54 + if (!((val == G_MAXUINT64 || !val) && errno)) { 55 + return val; 56 + } 57 + error_report("ignoring invalid max_mem_regions value in vhost module:" 58 + " %s", s); 59 + } 60 + return limit; 61 + } 62 + 63 + static int vhost_kernel_net_set_backend(struct vhost_dev *dev, 64 + struct vhost_vring_file *file) 65 + { 66 + return vhost_kernel_call(dev, VHOST_NET_SET_BACKEND, file); 67 + } 68 + 69 + static int vhost_kernel_scsi_set_endpoint(struct vhost_dev *dev, 70 + struct vhost_scsi_target *target) 71 + { 72 + return vhost_kernel_call(dev, VHOST_SCSI_SET_ENDPOINT, target); 73 + } 74 + 75 + static int vhost_kernel_scsi_clear_endpoint(struct vhost_dev *dev, 76 + struct vhost_scsi_target *target) 77 + { 78 + return vhost_kernel_call(dev, VHOST_SCSI_CLEAR_ENDPOINT, target); 79 + } 80 + 81 + static int vhost_kernel_scsi_get_abi_version(struct vhost_dev *dev, int *version) 82 + { 83 + return vhost_kernel_call(dev, VHOST_SCSI_GET_ABI_VERSION, version); 84 + } 85 + 86 + static int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base, 87 + struct vhost_log *log) 88 + { 89 + return vhost_kernel_call(dev, VHOST_SET_LOG_BASE, &base); 90 + } 91 + 92 + static int vhost_kernel_set_mem_table(struct vhost_dev *dev, 93 + struct vhost_memory *mem) 94 + { 95 + return vhost_kernel_call(dev, VHOST_SET_MEM_TABLE, mem); 96 + } 97 + 98 + static int vhost_kernel_set_vring_addr(struct vhost_dev *dev, 99 + struct vhost_vring_addr *addr) 100 + { 101 + return vhost_kernel_call(dev, VHOST_SET_VRING_ADDR, addr); 102 + } 103 + 104 + static int vhost_kernel_set_vring_endian(struct vhost_dev *dev, 105 + struct vhost_vring_state *ring) 106 + { 107 + return vhost_kernel_call(dev, VHOST_SET_VRING_ENDIAN, ring); 108 + } 109 + 110 + static int vhost_kernel_set_vring_num(struct vhost_dev *dev, 111 + struct vhost_vring_state *ring) 112 + { 113 + return vhost_kernel_call(dev, VHOST_SET_VRING_NUM, ring); 114 + } 115 + 116 + static int vhost_kernel_set_vring_base(struct vhost_dev *dev, 117 + struct vhost_vring_state *ring) 118 + { 119 + return vhost_kernel_call(dev, VHOST_SET_VRING_BASE, ring); 120 + } 121 + 122 + static int vhost_kernel_get_vring_base(struct vhost_dev *dev, 123 + struct vhost_vring_state *ring) 124 + { 125 + return vhost_kernel_call(dev, VHOST_GET_VRING_BASE, ring); 126 + } 127 + 128 + static int vhost_kernel_set_vring_kick(struct vhost_dev *dev, 129 + struct vhost_vring_file *file) 130 + { 131 + return vhost_kernel_call(dev, VHOST_SET_VRING_KICK, file); 132 + } 133 + 134 + static int vhost_kernel_set_vring_call(struct vhost_dev *dev, 135 + struct vhost_vring_file *file) 136 + { 137 + return vhost_kernel_call(dev, VHOST_SET_VRING_CALL, file); 138 + } 139 + 140 + static int vhost_kernel_set_features(struct vhost_dev *dev, 141 + uint64_t features) 142 + { 143 + return vhost_kernel_call(dev, VHOST_SET_FEATURES, &features); 144 + } 145 + 146 + static int vhost_kernel_get_features(struct vhost_dev *dev, 147 + uint64_t *features) 148 + { 149 + return vhost_kernel_call(dev, VHOST_GET_FEATURES, features); 150 + } 151 + 152 + static int vhost_kernel_set_owner(struct vhost_dev *dev) 153 + { 154 + return vhost_kernel_call(dev, VHOST_SET_OWNER, NULL); 155 + } 156 + 157 + static int vhost_kernel_reset_device(struct vhost_dev *dev) 158 + { 159 + return vhost_kernel_call(dev, VHOST_RESET_DEVICE, NULL); 160 + } 161 + 45 162 static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx) 46 163 { 47 164 assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs); ··· 51 168 52 169 static const VhostOps kernel_ops = { 53 170 .backend_type = VHOST_BACKEND_TYPE_KERNEL, 54 - .vhost_call = vhost_kernel_call, 55 171 .vhost_backend_init = vhost_kernel_init, 56 172 .vhost_backend_cleanup = vhost_kernel_cleanup, 57 - .vhost_backend_get_vq_index = vhost_kernel_get_vq_index, 173 + .vhost_backend_memslots_limit = vhost_kernel_memslots_limit, 174 + .vhost_net_set_backend = vhost_kernel_net_set_backend, 175 + .vhost_scsi_set_endpoint = vhost_kernel_scsi_set_endpoint, 176 + .vhost_scsi_clear_endpoint = vhost_kernel_scsi_clear_endpoint, 177 + .vhost_scsi_get_abi_version = vhost_kernel_scsi_get_abi_version, 178 + .vhost_set_log_base = vhost_kernel_set_log_base, 179 + .vhost_set_mem_table = vhost_kernel_set_mem_table, 180 + .vhost_set_vring_addr = vhost_kernel_set_vring_addr, 181 + .vhost_set_vring_endian = vhost_kernel_set_vring_endian, 182 + .vhost_set_vring_num = vhost_kernel_set_vring_num, 183 + .vhost_set_vring_base = vhost_kernel_set_vring_base, 184 + .vhost_get_vring_base = vhost_kernel_get_vring_base, 185 + .vhost_set_vring_kick = vhost_kernel_set_vring_kick, 186 + .vhost_set_vring_call = vhost_kernel_set_vring_call, 187 + .vhost_set_features = vhost_kernel_set_features, 188 + .vhost_get_features = vhost_kernel_get_features, 189 + .vhost_set_owner = vhost_kernel_set_owner, 190 + .vhost_reset_device = vhost_kernel_reset_device, 191 + .vhost_get_vq_index = vhost_kernel_get_vq_index, 58 192 }; 59 193 60 194 int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type)
+370 -195
hw/virtio/vhost-user.c
··· 10 10 11 11 #include "hw/virtio/vhost.h" 12 12 #include "hw/virtio/vhost-backend.h" 13 + #include "hw/virtio/virtio-net.h" 13 14 #include "sysemu/char.h" 14 15 #include "sysemu/kvm.h" 15 16 #include "qemu/error-report.h" 16 17 #include "qemu/sockets.h" 17 18 #include "exec/ram_addr.h" 19 + #include "migration/migration.h" 18 20 19 21 #include <fcntl.h> 20 22 #include <unistd.h> ··· 25 27 26 28 #define VHOST_MEMORY_MAX_NREGIONS 8 27 29 #define VHOST_USER_F_PROTOCOL_FEATURES 30 28 - #define VHOST_USER_PROTOCOL_FEATURE_MASK 0x1ULL 29 30 30 - #define VHOST_USER_PROTOCOL_F_MQ 0 31 + enum VhostUserProtocolFeature { 32 + VHOST_USER_PROTOCOL_F_MQ = 0, 33 + VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1, 34 + VHOST_USER_PROTOCOL_F_RARP = 2, 35 + 36 + VHOST_USER_PROTOCOL_F_MAX 37 + }; 38 + 39 + #define VHOST_USER_PROTOCOL_FEATURE_MASK ((1 << VHOST_USER_PROTOCOL_F_MAX) - 1) 31 40 32 41 typedef enum VhostUserRequest { 33 42 VHOST_USER_NONE = 0, ··· 49 58 VHOST_USER_SET_PROTOCOL_FEATURES = 16, 50 59 VHOST_USER_GET_QUEUE_NUM = 17, 51 60 VHOST_USER_SET_VRING_ENABLE = 18, 61 + VHOST_USER_SEND_RARP = 19, 52 62 VHOST_USER_MAX 53 63 } VhostUserRequest; 54 64 ··· 97 107 return kvm_enabled() && kvm_eventfds_enabled(); 98 108 } 99 109 100 - static unsigned long int ioctl_to_vhost_user_request[VHOST_USER_MAX] = { 101 - -1, /* VHOST_USER_NONE */ 102 - VHOST_GET_FEATURES, /* VHOST_USER_GET_FEATURES */ 103 - VHOST_SET_FEATURES, /* VHOST_USER_SET_FEATURES */ 104 - VHOST_SET_OWNER, /* VHOST_USER_SET_OWNER */ 105 - VHOST_RESET_DEVICE, /* VHOST_USER_RESET_DEVICE */ 106 - VHOST_SET_MEM_TABLE, /* VHOST_USER_SET_MEM_TABLE */ 107 - VHOST_SET_LOG_BASE, /* VHOST_USER_SET_LOG_BASE */ 108 - VHOST_SET_LOG_FD, /* VHOST_USER_SET_LOG_FD */ 109 - VHOST_SET_VRING_NUM, /* VHOST_USER_SET_VRING_NUM */ 110 - VHOST_SET_VRING_ADDR, /* VHOST_USER_SET_VRING_ADDR */ 111 - VHOST_SET_VRING_BASE, /* VHOST_USER_SET_VRING_BASE */ 112 - VHOST_GET_VRING_BASE, /* VHOST_USER_GET_VRING_BASE */ 113 - VHOST_SET_VRING_KICK, /* VHOST_USER_SET_VRING_KICK */ 114 - VHOST_SET_VRING_CALL, /* VHOST_USER_SET_VRING_CALL */ 115 - VHOST_SET_VRING_ERR /* VHOST_USER_SET_VRING_ERR */ 116 - }; 117 - 118 - static VhostUserRequest vhost_user_request_translate(unsigned long int request) 119 - { 120 - VhostUserRequest idx; 121 - 122 - for (idx = 0; idx < VHOST_USER_MAX; idx++) { 123 - if (ioctl_to_vhost_user_request[idx] == request) { 124 - break; 125 - } 126 - } 127 - 128 - return (idx == VHOST_USER_MAX) ? VHOST_USER_NONE : idx; 129 - } 130 - 131 110 static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg) 132 111 { 133 112 CharDriverState *chr = dev->opaque; ··· 174 153 return -1; 175 154 } 176 155 156 + static bool vhost_user_one_time_request(VhostUserRequest request) 157 + { 158 + switch (request) { 159 + case VHOST_USER_SET_OWNER: 160 + case VHOST_USER_RESET_DEVICE: 161 + case VHOST_USER_SET_MEM_TABLE: 162 + case VHOST_USER_GET_QUEUE_NUM: 163 + return true; 164 + default: 165 + return false; 166 + } 167 + } 168 + 169 + /* most non-init callers ignore the error */ 177 170 static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, 178 171 int *fds, int fd_num) 179 172 { 180 173 CharDriverState *chr = dev->opaque; 181 174 int size = VHOST_USER_HDR_SIZE + msg->size; 182 175 176 + /* 177 + * For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE, 178 + * we just need send it once in the first time. For later such 179 + * request, we just ignore it. 180 + */ 181 + if (vhost_user_one_time_request(msg->request) && dev->vq_index != 0) { 182 + return 0; 183 + } 184 + 183 185 if (fd_num) { 184 186 qemu_chr_fe_set_msgfds(chr, fds, fd_num); 185 187 } ··· 188 190 0 : -1; 189 191 } 190 192 191 - static bool vhost_user_one_time_request(VhostUserRequest request) 193 + static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, 194 + struct vhost_log *log) 192 195 { 193 - switch (request) { 194 - case VHOST_USER_SET_OWNER: 195 - case VHOST_USER_RESET_DEVICE: 196 - case VHOST_USER_SET_MEM_TABLE: 197 - case VHOST_USER_GET_QUEUE_NUM: 198 - return true; 199 - default: 200 - return false; 196 + int fds[VHOST_MEMORY_MAX_NREGIONS]; 197 + size_t fd_num = 0; 198 + bool shmfd = virtio_has_feature(dev->protocol_features, 199 + VHOST_USER_PROTOCOL_F_LOG_SHMFD); 200 + VhostUserMsg msg = { 201 + .request = VHOST_USER_SET_LOG_BASE, 202 + .flags = VHOST_USER_VERSION, 203 + .u64 = base, 204 + .size = sizeof(m.u64), 205 + }; 206 + 207 + if (shmfd && log->fd != -1) { 208 + fds[fd_num++] = log->fd; 209 + } 210 + 211 + vhost_user_write(dev, &msg, fds, fd_num); 212 + 213 + if (shmfd) { 214 + msg.size = 0; 215 + if (vhost_user_read(dev, &msg) < 0) { 216 + return 0; 217 + } 218 + 219 + if (msg.request != VHOST_USER_SET_LOG_BASE) { 220 + error_report("Received unexpected msg type. " 221 + "Expected %d received %d", 222 + VHOST_USER_SET_LOG_BASE, msg.request); 223 + return -1; 224 + } 201 225 } 226 + 227 + return 0; 202 228 } 203 229 204 - static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, 205 - void *arg) 230 + static int vhost_user_set_mem_table(struct vhost_dev *dev, 231 + struct vhost_memory *mem) 206 232 { 207 - VhostUserMsg msg; 208 - VhostUserRequest msg_request; 209 - struct vhost_vring_file *file = 0; 210 - int need_reply = 0; 211 233 int fds[VHOST_MEMORY_MAX_NREGIONS]; 212 234 int i, fd; 213 235 size_t fd_num = 0; 236 + VhostUserMsg msg = { 237 + .request = VHOST_USER_SET_MEM_TABLE, 238 + .flags = VHOST_USER_VERSION, 239 + }; 214 240 215 - assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); 241 + for (i = 0; i < dev->mem->nregions; ++i) { 242 + struct vhost_memory_region *reg = dev->mem->regions + i; 243 + ram_addr_t ram_addr; 216 244 217 - /* only translate vhost ioctl requests */ 218 - if (request > VHOST_USER_MAX) { 219 - msg_request = vhost_user_request_translate(request); 220 - } else { 221 - msg_request = request; 245 + assert((uintptr_t)reg->userspace_addr == reg->userspace_addr); 246 + qemu_ram_addr_from_host((void *)(uintptr_t)reg->userspace_addr, 247 + &ram_addr); 248 + fd = qemu_get_ram_fd(ram_addr); 249 + if (fd > 0) { 250 + msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr; 251 + msg.memory.regions[fd_num].memory_size = reg->memory_size; 252 + msg.memory.regions[fd_num].guest_phys_addr = reg->guest_phys_addr; 253 + msg.memory.regions[fd_num].mmap_offset = reg->userspace_addr - 254 + (uintptr_t) qemu_get_ram_block_host_ptr(ram_addr); 255 + assert(fd_num < VHOST_MEMORY_MAX_NREGIONS); 256 + fds[fd_num++] = fd; 257 + } 222 258 } 223 259 224 - /* 225 - * For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE, 226 - * we just need send it once in the first time. For later such 227 - * request, we just ignore it. 228 - */ 229 - if (vhost_user_one_time_request(msg_request) && dev->vq_index != 0) { 230 - return 0; 260 + msg.memory.nregions = fd_num; 261 + 262 + if (!fd_num) { 263 + error_report("Failed initializing vhost-user memory map, " 264 + "consider using -object memory-backend-file share=on"); 265 + return -1; 231 266 } 232 267 233 - msg.request = msg_request; 234 - msg.flags = VHOST_USER_VERSION; 235 - msg.size = 0; 268 + msg.size = sizeof(m.memory.nregions); 269 + msg.size += sizeof(m.memory.padding); 270 + msg.size += fd_num * sizeof(VhostUserMemoryRegion); 271 + 272 + vhost_user_write(dev, &msg, fds, fd_num); 273 + 274 + return 0; 275 + } 276 + 277 + static int vhost_user_set_vring_addr(struct vhost_dev *dev, 278 + struct vhost_vring_addr *addr) 279 + { 280 + VhostUserMsg msg = { 281 + .request = VHOST_USER_SET_VRING_ADDR, 282 + .flags = VHOST_USER_VERSION, 283 + .addr = *addr, 284 + .size = sizeof(*addr), 285 + }; 286 + 287 + vhost_user_write(dev, &msg, NULL, 0); 288 + 289 + return 0; 290 + } 236 291 237 - switch (msg_request) { 238 - case VHOST_USER_GET_FEATURES: 239 - case VHOST_USER_GET_PROTOCOL_FEATURES: 240 - case VHOST_USER_GET_QUEUE_NUM: 241 - need_reply = 1; 242 - break; 292 + static int vhost_user_set_vring_endian(struct vhost_dev *dev, 293 + struct vhost_vring_state *ring) 294 + { 295 + error_report("vhost-user trying to send unhandled ioctl"); 296 + return -1; 297 + } 298 + 299 + static int vhost_set_vring(struct vhost_dev *dev, 300 + unsigned long int request, 301 + struct vhost_vring_state *ring) 302 + { 303 + VhostUserMsg msg = { 304 + .request = request, 305 + .flags = VHOST_USER_VERSION, 306 + .state = *ring, 307 + .size = sizeof(*ring), 308 + }; 243 309 244 - case VHOST_USER_SET_FEATURES: 245 - case VHOST_USER_SET_LOG_BASE: 246 - case VHOST_USER_SET_PROTOCOL_FEATURES: 247 - msg.u64 = *((__u64 *) arg); 248 - msg.size = sizeof(m.u64); 249 - break; 310 + vhost_user_write(dev, &msg, NULL, 0); 250 311 251 - case VHOST_USER_SET_OWNER: 252 - case VHOST_USER_RESET_DEVICE: 253 - break; 312 + return 0; 313 + } 254 314 255 - case VHOST_USER_SET_MEM_TABLE: 256 - for (i = 0; i < dev->mem->nregions; ++i) { 257 - struct vhost_memory_region *reg = dev->mem->regions + i; 258 - ram_addr_t ram_addr; 315 + static int vhost_user_set_vring_num(struct vhost_dev *dev, 316 + struct vhost_vring_state *ring) 317 + { 318 + return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring); 319 + } 259 320 260 - assert((uintptr_t)reg->userspace_addr == reg->userspace_addr); 261 - qemu_ram_addr_from_host((void *)(uintptr_t)reg->userspace_addr, &ram_addr); 262 - fd = qemu_get_ram_fd(ram_addr); 263 - if (fd > 0) { 264 - msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr; 265 - msg.memory.regions[fd_num].memory_size = reg->memory_size; 266 - msg.memory.regions[fd_num].guest_phys_addr = reg->guest_phys_addr; 267 - msg.memory.regions[fd_num].mmap_offset = reg->userspace_addr - 268 - (uintptr_t) qemu_get_ram_block_host_ptr(ram_addr); 269 - assert(fd_num < VHOST_MEMORY_MAX_NREGIONS); 270 - fds[fd_num++] = fd; 271 - } 272 - } 321 + static int vhost_user_set_vring_base(struct vhost_dev *dev, 322 + struct vhost_vring_state *ring) 323 + { 324 + return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring); 325 + } 273 326 274 - msg.memory.nregions = fd_num; 327 + static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) 328 + { 329 + struct vhost_vring_state state = { 330 + .index = dev->vq_index, 331 + .num = enable, 332 + }; 275 333 276 - if (!fd_num) { 277 - error_report("Failed initializing vhost-user memory map, " 278 - "consider using -object memory-backend-file share=on"); 279 - return -1; 280 - } 334 + if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ))) { 335 + return -1; 336 + } 281 337 282 - msg.size = sizeof(m.memory.nregions); 283 - msg.size += sizeof(m.memory.padding); 284 - msg.size += fd_num * sizeof(VhostUserMemoryRegion); 338 + return vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); 339 + } 285 340 286 - break; 287 341 288 - case VHOST_USER_SET_LOG_FD: 289 - fds[fd_num++] = *((int *) arg); 290 - break; 342 + static int vhost_user_get_vring_base(struct vhost_dev *dev, 343 + struct vhost_vring_state *ring) 344 + { 345 + VhostUserMsg msg = { 346 + .request = VHOST_USER_GET_VRING_BASE, 347 + .flags = VHOST_USER_VERSION, 348 + .state = *ring, 349 + .size = sizeof(*ring), 350 + }; 291 351 292 - case VHOST_USER_SET_VRING_NUM: 293 - case VHOST_USER_SET_VRING_BASE: 294 - case VHOST_USER_SET_VRING_ENABLE: 295 - memcpy(&msg.state, arg, sizeof(struct vhost_vring_state)); 296 - msg.size = sizeof(m.state); 297 - break; 352 + vhost_user_write(dev, &msg, NULL, 0); 298 353 299 - case VHOST_USER_GET_VRING_BASE: 300 - memcpy(&msg.state, arg, sizeof(struct vhost_vring_state)); 301 - msg.size = sizeof(m.state); 302 - need_reply = 1; 303 - break; 354 + if (vhost_user_read(dev, &msg) < 0) { 355 + return 0; 356 + } 304 357 305 - case VHOST_USER_SET_VRING_ADDR: 306 - memcpy(&msg.addr, arg, sizeof(struct vhost_vring_addr)); 307 - msg.size = sizeof(m.addr); 308 - break; 358 + if (msg.request != VHOST_USER_GET_VRING_BASE) { 359 + error_report("Received unexpected msg type. Expected %d received %d", 360 + VHOST_USER_GET_VRING_BASE, msg.request); 361 + return -1; 362 + } 309 363 310 - case VHOST_USER_SET_VRING_KICK: 311 - case VHOST_USER_SET_VRING_CALL: 312 - case VHOST_USER_SET_VRING_ERR: 313 - file = arg; 314 - msg.u64 = file->index & VHOST_USER_VRING_IDX_MASK; 315 - msg.size = sizeof(m.u64); 316 - if (ioeventfd_enabled() && file->fd > 0) { 317 - fds[fd_num++] = file->fd; 318 - } else { 319 - msg.u64 |= VHOST_USER_VRING_NOFD_MASK; 320 - } 321 - break; 322 - default: 323 - error_report("vhost-user trying to send unhandled ioctl"); 364 + if (msg.size != sizeof(m.state)) { 365 + error_report("Received bad msg size."); 324 366 return -1; 325 - break; 367 + } 368 + 369 + *ring = msg.state; 370 + 371 + return 0; 372 + } 373 + 374 + static int vhost_set_vring_file(struct vhost_dev *dev, 375 + VhostUserRequest request, 376 + struct vhost_vring_file *file) 377 + { 378 + int fds[VHOST_MEMORY_MAX_NREGIONS]; 379 + size_t fd_num = 0; 380 + VhostUserMsg msg = { 381 + .request = request, 382 + .flags = VHOST_USER_VERSION, 383 + .u64 = file->index & VHOST_USER_VRING_IDX_MASK, 384 + .size = sizeof(m.u64), 385 + }; 386 + 387 + if (ioeventfd_enabled() && file->fd > 0) { 388 + fds[fd_num++] = file->fd; 389 + } else { 390 + msg.u64 |= VHOST_USER_VRING_NOFD_MASK; 326 391 } 327 392 328 - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { 393 + vhost_user_write(dev, &msg, fds, fd_num); 394 + 395 + return 0; 396 + } 397 + 398 + static int vhost_user_set_vring_kick(struct vhost_dev *dev, 399 + struct vhost_vring_file *file) 400 + { 401 + return vhost_set_vring_file(dev, VHOST_USER_SET_VRING_KICK, file); 402 + } 403 + 404 + static int vhost_user_set_vring_call(struct vhost_dev *dev, 405 + struct vhost_vring_file *file) 406 + { 407 + return vhost_set_vring_file(dev, VHOST_USER_SET_VRING_CALL, file); 408 + } 409 + 410 + static int vhost_user_set_u64(struct vhost_dev *dev, int request, uint64_t u64) 411 + { 412 + VhostUserMsg msg = { 413 + .request = request, 414 + .flags = VHOST_USER_VERSION, 415 + .u64 = u64, 416 + .size = sizeof(m.u64), 417 + }; 418 + 419 + vhost_user_write(dev, &msg, NULL, 0); 420 + 421 + return 0; 422 + } 423 + 424 + static int vhost_user_set_features(struct vhost_dev *dev, 425 + uint64_t features) 426 + { 427 + return vhost_user_set_u64(dev, VHOST_USER_SET_FEATURES, features); 428 + } 429 + 430 + static int vhost_user_set_protocol_features(struct vhost_dev *dev, 431 + uint64_t features) 432 + { 433 + return vhost_user_set_u64(dev, VHOST_USER_SET_PROTOCOL_FEATURES, features); 434 + } 435 + 436 + static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t *u64) 437 + { 438 + VhostUserMsg msg = { 439 + .request = request, 440 + .flags = VHOST_USER_VERSION, 441 + }; 442 + 443 + if (vhost_user_one_time_request(request) && dev->vq_index != 0) { 329 444 return 0; 330 445 } 331 446 332 - if (need_reply) { 333 - if (vhost_user_read(dev, &msg) < 0) { 334 - return 0; 335 - } 447 + vhost_user_write(dev, &msg, NULL, 0); 336 448 337 - if (msg_request != msg.request) { 338 - error_report("Received unexpected msg type." 339 - " Expected %d received %d", msg_request, msg.request); 340 - return -1; 341 - } 449 + if (vhost_user_read(dev, &msg) < 0) { 450 + return 0; 451 + } 342 452 343 - switch (msg_request) { 344 - case VHOST_USER_GET_FEATURES: 345 - case VHOST_USER_GET_PROTOCOL_FEATURES: 346 - case VHOST_USER_GET_QUEUE_NUM: 347 - if (msg.size != sizeof(m.u64)) { 348 - error_report("Received bad msg size."); 349 - return -1; 350 - } 351 - *((__u64 *) arg) = msg.u64; 352 - break; 353 - case VHOST_USER_GET_VRING_BASE: 354 - if (msg.size != sizeof(m.state)) { 355 - error_report("Received bad msg size."); 356 - return -1; 357 - } 358 - memcpy(arg, &msg.state, sizeof(struct vhost_vring_state)); 359 - break; 360 - default: 361 - error_report("Received unexpected msg type."); 362 - return -1; 363 - break; 364 - } 453 + if (msg.request != request) { 454 + error_report("Received unexpected msg type. Expected %d received %d", 455 + request, msg.request); 456 + return -1; 365 457 } 366 458 459 + if (msg.size != sizeof(m.u64)) { 460 + error_report("Received bad msg size."); 461 + return -1; 462 + } 463 + 464 + *u64 = msg.u64; 465 + 466 + return 0; 467 + } 468 + 469 + static int vhost_user_get_features(struct vhost_dev *dev, uint64_t *features) 470 + { 471 + return vhost_user_get_u64(dev, VHOST_USER_GET_FEATURES, features); 472 + } 473 + 474 + static int vhost_user_set_owner(struct vhost_dev *dev) 475 + { 476 + VhostUserMsg msg = { 477 + .request = VHOST_USER_SET_OWNER, 478 + .flags = VHOST_USER_VERSION, 479 + }; 480 + 481 + vhost_user_write(dev, &msg, NULL, 0); 482 + 483 + return 0; 484 + } 485 + 486 + static int vhost_user_reset_device(struct vhost_dev *dev) 487 + { 488 + VhostUserMsg msg = { 489 + .request = VHOST_USER_RESET_DEVICE, 490 + .flags = VHOST_USER_VERSION, 491 + }; 492 + 493 + vhost_user_write(dev, &msg, NULL, 0); 494 + 367 495 return 0; 368 496 } 369 497 370 498 static int vhost_user_init(struct vhost_dev *dev, void *opaque) 371 499 { 372 - unsigned long long features; 500 + uint64_t features; 373 501 int err; 374 502 375 503 assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); 376 504 377 505 dev->opaque = opaque; 378 506 379 - err = vhost_user_call(dev, VHOST_USER_GET_FEATURES, &features); 507 + err = vhost_user_get_features(dev, &features); 380 508 if (err < 0) { 381 509 return err; 382 510 } ··· 384 512 if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEATURES)) { 385 513 dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES; 386 514 387 - err = vhost_user_call(dev, VHOST_USER_GET_PROTOCOL_FEATURES, &features); 515 + err = vhost_user_get_u64(dev, VHOST_USER_GET_PROTOCOL_FEATURES, 516 + &features); 388 517 if (err < 0) { 389 518 return err; 390 519 } 391 520 392 521 dev->protocol_features = features & VHOST_USER_PROTOCOL_FEATURE_MASK; 393 - err = vhost_user_call(dev, VHOST_USER_SET_PROTOCOL_FEATURES, 394 - &dev->protocol_features); 522 + err = vhost_user_set_protocol_features(dev, dev->protocol_features); 395 523 if (err < 0) { 396 524 return err; 397 525 } 398 526 399 527 /* query the max queues we support if backend supports Multiple Queue */ 400 528 if (dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ)) { 401 - err = vhost_user_call(dev, VHOST_USER_GET_QUEUE_NUM, &dev->max_queues); 529 + err = vhost_user_get_u64(dev, VHOST_USER_GET_QUEUE_NUM, 530 + &dev->max_queues); 402 531 if (err < 0) { 403 532 return err; 404 533 } 405 534 } 406 535 } 407 536 408 - return 0; 409 - } 410 - 411 - static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) 412 - { 413 - struct vhost_vring_state state = { 414 - .index = dev->vq_index, 415 - .num = enable, 416 - }; 417 - 418 - assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); 419 - 420 - if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ))) { 421 - return -1; 537 + if (dev->migration_blocker == NULL && 538 + !virtio_has_feature(dev->protocol_features, 539 + VHOST_USER_PROTOCOL_F_LOG_SHMFD)) { 540 + error_setg(&dev->migration_blocker, 541 + "Migration disabled: vhost-user backend lacks " 542 + "VHOST_USER_PROTOCOL_F_LOG_SHMFD feature."); 422 543 } 423 544 424 - return vhost_user_call(dev, VHOST_USER_SET_VRING_ENABLE, &state); 545 + return 0; 425 546 } 426 547 427 548 static int vhost_user_cleanup(struct vhost_dev *dev) ··· 440 561 return idx; 441 562 } 442 563 564 + static int vhost_user_memslots_limit(struct vhost_dev *dev) 565 + { 566 + return VHOST_MEMORY_MAX_NREGIONS; 567 + } 568 + 569 + static bool vhost_user_requires_shm_log(struct vhost_dev *dev) 570 + { 571 + assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); 572 + 573 + return virtio_has_feature(dev->protocol_features, 574 + VHOST_USER_PROTOCOL_F_LOG_SHMFD); 575 + } 576 + 577 + static int vhost_user_migration_done(struct vhost_dev *dev, char* mac_addr) 578 + { 579 + VhostUserMsg msg = { 0 }; 580 + int err; 581 + 582 + assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); 583 + 584 + /* If guest supports GUEST_ANNOUNCE do nothing */ 585 + if (virtio_has_feature(dev->acked_features, VIRTIO_NET_F_GUEST_ANNOUNCE)) { 586 + return 0; 587 + } 588 + 589 + /* if backend supports VHOST_USER_PROTOCOL_F_RARP ask it to send the RARP */ 590 + if (virtio_has_feature(dev->protocol_features, 591 + VHOST_USER_PROTOCOL_F_RARP)) { 592 + msg.request = VHOST_USER_SEND_RARP; 593 + msg.flags = VHOST_USER_VERSION; 594 + memcpy((char *)&msg.u64, mac_addr, 6); 595 + msg.size = sizeof(m.u64); 596 + 597 + err = vhost_user_write(dev, &msg, NULL, 0); 598 + return err; 599 + } 600 + return -1; 601 + } 602 + 443 603 const VhostOps user_ops = { 444 604 .backend_type = VHOST_BACKEND_TYPE_USER, 445 - .vhost_call = vhost_user_call, 446 605 .vhost_backend_init = vhost_user_init, 447 606 .vhost_backend_cleanup = vhost_user_cleanup, 448 - .vhost_backend_get_vq_index = vhost_user_get_vq_index, 449 - .vhost_backend_set_vring_enable = vhost_user_set_vring_enable, 607 + .vhost_backend_memslots_limit = vhost_user_memslots_limit, 608 + .vhost_set_log_base = vhost_user_set_log_base, 609 + .vhost_set_mem_table = vhost_user_set_mem_table, 610 + .vhost_set_vring_addr = vhost_user_set_vring_addr, 611 + .vhost_set_vring_endian = vhost_user_set_vring_endian, 612 + .vhost_set_vring_num = vhost_user_set_vring_num, 613 + .vhost_set_vring_base = vhost_user_set_vring_base, 614 + .vhost_get_vring_base = vhost_user_get_vring_base, 615 + .vhost_set_vring_kick = vhost_user_set_vring_kick, 616 + .vhost_set_vring_call = vhost_user_set_vring_call, 617 + .vhost_set_features = vhost_user_set_features, 618 + .vhost_get_features = vhost_user_get_features, 619 + .vhost_set_owner = vhost_user_set_owner, 620 + .vhost_reset_device = vhost_user_reset_device, 621 + .vhost_get_vq_index = vhost_user_get_vq_index, 622 + .vhost_set_vring_enable = vhost_user_set_vring_enable, 623 + .vhost_requires_shm_log = vhost_user_requires_shm_log, 624 + .vhost_migration_done = vhost_user_migration_done, 450 625 };
+118 -38
hw/virtio/vhost.c
··· 18 18 #include "qemu/atomic.h" 19 19 #include "qemu/range.h" 20 20 #include "qemu/error-report.h" 21 + #include "qemu/memfd.h" 21 22 #include <linux/vhost.h> 22 23 #include "exec/address-spaces.h" 23 24 #include "hw/virtio/virtio-bus.h" ··· 25 26 #include "migration/migration.h" 26 27 27 28 static struct vhost_log *vhost_log; 29 + static struct vhost_log *vhost_log_shm; 30 + 31 + static unsigned int used_memslots; 32 + static QLIST_HEAD(, vhost_dev) vhost_devices = 33 + QLIST_HEAD_INITIALIZER(vhost_devices); 34 + 35 + bool vhost_has_free_slot(void) 36 + { 37 + unsigned int slots_limit = ~0U; 38 + struct vhost_dev *hdev; 39 + 40 + QLIST_FOREACH(hdev, &vhost_devices, entry) { 41 + unsigned int r = hdev->vhost_ops->vhost_backend_memslots_limit(hdev); 42 + slots_limit = MIN(slots_limit, r); 43 + } 44 + return slots_limit > used_memslots; 45 + } 28 46 29 47 static void vhost_dev_sync_region(struct vhost_dev *dev, 30 48 MemoryRegionSection *section, ··· 286 304 } 287 305 return log_size; 288 306 } 289 - static struct vhost_log *vhost_log_alloc(uint64_t size) 307 + 308 + static struct vhost_log *vhost_log_alloc(uint64_t size, bool share) 290 309 { 291 - struct vhost_log *log = g_malloc0(sizeof *log + size * sizeof(*(log->log))); 310 + struct vhost_log *log; 311 + uint64_t logsize = size * sizeof(*(log->log)); 312 + int fd = -1; 313 + 314 + log = g_new0(struct vhost_log, 1); 315 + if (share) { 316 + log->log = qemu_memfd_alloc("vhost-log", logsize, 317 + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL, 318 + &fd); 319 + memset(log->log, 0, logsize); 320 + } else { 321 + log->log = g_malloc0(logsize); 322 + } 292 323 293 324 log->size = size; 294 325 log->refcnt = 1; 326 + log->fd = fd; 295 327 296 328 return log; 297 329 } 298 330 299 - static struct vhost_log *vhost_log_get(uint64_t size) 331 + static struct vhost_log *vhost_log_get(uint64_t size, bool share) 300 332 { 301 - if (!vhost_log || vhost_log->size != size) { 302 - vhost_log = vhost_log_alloc(size); 333 + struct vhost_log *log = share ? vhost_log_shm : vhost_log; 334 + 335 + if (!log || log->size != size) { 336 + log = vhost_log_alloc(size, share); 337 + if (share) { 338 + vhost_log_shm = log; 339 + } else { 340 + vhost_log = log; 341 + } 303 342 } else { 304 - ++vhost_log->refcnt; 343 + ++log->refcnt; 305 344 } 306 345 307 - return vhost_log; 346 + return log; 308 347 } 309 348 310 349 static void vhost_log_put(struct vhost_dev *dev, bool sync) ··· 321 360 if (dev->log_size && sync) { 322 361 vhost_log_sync_range(dev, 0, dev->log_size * VHOST_LOG_CHUNK - 1); 323 362 } 363 + 324 364 if (vhost_log == log) { 365 + g_free(log->log); 325 366 vhost_log = NULL; 367 + } else if (vhost_log_shm == log) { 368 + qemu_memfd_free(log->log, log->size * sizeof(*(log->log)), 369 + log->fd); 370 + vhost_log_shm = NULL; 326 371 } 372 + 327 373 g_free(log); 328 374 } 329 375 } 330 376 331 - static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size) 377 + static bool vhost_dev_log_is_shared(struct vhost_dev *dev) 378 + { 379 + return dev->vhost_ops->vhost_requires_shm_log && 380 + dev->vhost_ops->vhost_requires_shm_log(dev); 381 + } 382 + 383 + static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size) 332 384 { 333 - struct vhost_log *log = vhost_log_get(size); 385 + struct vhost_log *log = vhost_log_get(size, vhost_dev_log_is_shared(dev)); 334 386 uint64_t log_base = (uintptr_t)log->log; 335 387 int r; 336 388 337 - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_LOG_BASE, &log_base); 389 + /* inform backend of log switching, this must be done before 390 + releasing the current log, to ensure no logging is lost */ 391 + r = dev->vhost_ops->vhost_set_log_base(dev, log_base, log); 338 392 assert(r >= 0); 339 393 vhost_log_put(dev, true); 340 394 dev->log = log; ··· 457 511 dev->mem_changed_start_addr = MIN(dev->mem_changed_start_addr, start_addr); 458 512 dev->mem_changed_end_addr = MAX(dev->mem_changed_end_addr, start_addr + size - 1); 459 513 dev->memory_changed = true; 514 + used_memslots = dev->mem->nregions; 460 515 } 461 516 462 517 static bool vhost_section(MemoryRegionSection *section) ··· 500 555 } 501 556 502 557 if (!dev->log_enabled) { 503 - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_MEM_TABLE, dev->mem); 558 + r = dev->vhost_ops->vhost_set_mem_table(dev, dev->mem); 504 559 assert(r >= 0); 505 560 dev->memory_changed = false; 506 561 return; ··· 513 568 if (dev->log_size < log_size) { 514 569 vhost_dev_log_resize(dev, log_size + VHOST_LOG_BUFFER); 515 570 } 516 - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_MEM_TABLE, dev->mem); 571 + r = dev->vhost_ops->vhost_set_mem_table(dev, dev->mem); 517 572 assert(r >= 0); 518 573 /* To log less, can only decrease log size after table update. */ 519 574 if (dev->log_size > log_size + VHOST_LOG_BUFFER) { ··· 581 636 .log_guest_addr = vq->used_phys, 582 637 .flags = enable_log ? (1 << VHOST_VRING_F_LOG) : 0, 583 638 }; 584 - int r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_ADDR, &addr); 639 + int r = dev->vhost_ops->vhost_set_vring_addr(dev, &addr); 585 640 if (r < 0) { 586 641 return -errno; 587 642 } ··· 595 650 if (enable_log) { 596 651 features |= 0x1ULL << VHOST_F_LOG_ALL; 597 652 } 598 - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_FEATURES, &features); 653 + r = dev->vhost_ops->vhost_set_features(dev, features); 599 654 return r < 0 ? -errno : 0; 600 655 } 601 656 602 657 static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) 603 658 { 604 - int r, t, i; 659 + int r, t, i, idx; 605 660 r = vhost_dev_set_features(dev, enable_log); 606 661 if (r < 0) { 607 662 goto err_features; 608 663 } 609 664 for (i = 0; i < dev->nvqs; ++i) { 610 - r = vhost_virtqueue_set_addr(dev, dev->vqs + i, i, 665 + idx = dev->vhost_ops->vhost_get_vq_index(dev, dev->vq_index + i); 666 + r = vhost_virtqueue_set_addr(dev, dev->vqs + i, idx, 611 667 enable_log); 612 668 if (r < 0) { 613 669 goto err_vq; ··· 616 672 return 0; 617 673 err_vq: 618 674 for (; i >= 0; --i) { 619 - t = vhost_virtqueue_set_addr(dev, dev->vqs + i, i, 675 + idx = dev->vhost_ops->vhost_get_vq_index(dev, dev->vq_index + i); 676 + t = vhost_virtqueue_set_addr(dev, dev->vqs + i, idx, 620 677 dev->log_enabled); 621 678 assert(t >= 0); 622 679 } ··· 700 757 .num = is_big_endian 701 758 }; 702 759 703 - if (!dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_ENDIAN, &s)) { 760 + if (!dev->vhost_ops->vhost_set_vring_endian(dev, &s)) { 704 761 return 0; 705 762 } 706 763 ··· 719 776 { 720 777 hwaddr s, l, a; 721 778 int r; 722 - int vhost_vq_index = dev->vhost_ops->vhost_backend_get_vq_index(dev, idx); 779 + int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx); 723 780 struct vhost_vring_file file = { 724 781 .index = vhost_vq_index 725 782 }; ··· 730 787 731 788 732 789 vq->num = state.num = virtio_queue_get_num(vdev, idx); 733 - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_NUM, &state); 790 + r = dev->vhost_ops->vhost_set_vring_num(dev, &state); 734 791 if (r) { 735 792 return -errno; 736 793 } 737 794 738 795 state.num = virtio_queue_get_last_avail_idx(vdev, idx); 739 - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_BASE, &state); 796 + r = dev->vhost_ops->vhost_set_vring_base(dev, &state); 740 797 if (r) { 741 798 return -errno; 742 799 } ··· 788 845 } 789 846 790 847 file.fd = event_notifier_get_fd(virtio_queue_get_host_notifier(vvq)); 791 - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_KICK, &file); 848 + r = dev->vhost_ops->vhost_set_vring_kick(dev, &file); 792 849 if (r) { 793 850 r = -errno; 794 851 goto fail_kick; ··· 821 878 struct vhost_virtqueue *vq, 822 879 unsigned idx) 823 880 { 824 - int vhost_vq_index = dev->vhost_ops->vhost_backend_get_vq_index(dev, idx); 881 + int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx); 825 882 struct vhost_vring_state state = { 826 883 .index = vhost_vq_index, 827 884 }; 828 885 int r; 829 886 830 - r = dev->vhost_ops->vhost_call(dev, VHOST_GET_VRING_BASE, &state); 887 + r = dev->vhost_ops->vhost_get_vring_base(dev, &state); 831 888 if (r < 0) { 832 889 fprintf(stderr, "vhost VQ %d ring restore failed: %d\n", idx, r); 833 890 fflush(stderr); ··· 874 931 static int vhost_virtqueue_init(struct vhost_dev *dev, 875 932 struct vhost_virtqueue *vq, int n) 876 933 { 877 - int vhost_vq_index = dev->vhost_ops->vhost_backend_get_vq_index(dev, n); 934 + int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, n); 878 935 struct vhost_vring_file file = { 879 936 .index = vhost_vq_index, 880 937 }; ··· 884 941 } 885 942 886 943 file.fd = event_notifier_get_fd(&vq->masked_notifier); 887 - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_CALL, &file); 944 + r = dev->vhost_ops->vhost_set_vring_call(dev, &file); 888 945 if (r) { 889 946 r = -errno; 890 947 goto fail_call; ··· 906 963 uint64_t features; 907 964 int i, r; 908 965 966 + hdev->migration_blocker = NULL; 967 + 909 968 if (vhost_set_backend_type(hdev, backend_type) < 0) { 910 969 close((uintptr_t)opaque); 911 970 return -1; ··· 916 975 return -errno; 917 976 } 918 977 919 - r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_OWNER, NULL); 978 + if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hdev)) { 979 + fprintf(stderr, "vhost backend memory slots limit is less" 980 + " than current number of present memory slots\n"); 981 + close((uintptr_t)opaque); 982 + return -1; 983 + } 984 + QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); 985 + 986 + r = hdev->vhost_ops->vhost_set_owner(hdev); 920 987 if (r < 0) { 921 988 goto fail; 922 989 } 923 990 924 - r = hdev->vhost_ops->vhost_call(hdev, VHOST_GET_FEATURES, &features); 991 + r = hdev->vhost_ops->vhost_get_features(hdev, &features); 925 992 if (r < 0) { 926 993 goto fail; 927 994 } ··· 949 1016 .eventfd_del = vhost_eventfd_del, 950 1017 .priority = 10 951 1018 }; 952 - hdev->migration_blocker = NULL; 953 - if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { 954 - error_setg(&hdev->migration_blocker, 955 - "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature."); 1019 + 1020 + if (hdev->migration_blocker == NULL) { 1021 + if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { 1022 + error_setg(&hdev->migration_blocker, 1023 + "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature."); 1024 + } else if (!qemu_memfd_check()) { 1025 + error_setg(&hdev->migration_blocker, 1026 + "Migration disabled: failed to allocate shared memory"); 1027 + } 1028 + } 1029 + 1030 + if (hdev->migration_blocker != NULL) { 956 1031 migrate_add_blocker(hdev->migration_blocker); 957 1032 } 1033 + 958 1034 hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions)); 959 1035 hdev->n_mem_sections = 0; 960 1036 hdev->mem_sections = NULL; ··· 972 1048 fail: 973 1049 r = -errno; 974 1050 hdev->vhost_ops->vhost_backend_cleanup(hdev); 1051 + QLIST_REMOVE(hdev, entry); 975 1052 return r; 976 1053 } 977 1054 ··· 989 1066 g_free(hdev->mem); 990 1067 g_free(hdev->mem_sections); 991 1068 hdev->vhost_ops->vhost_backend_cleanup(hdev); 1069 + QLIST_REMOVE(hdev, entry); 992 1070 } 993 1071 994 1072 /* Stop processing guest IO notifications in qemu. ··· 1074 1152 file.fd = event_notifier_get_fd(virtio_queue_get_guest_notifier(vvq)); 1075 1153 } 1076 1154 1077 - file.index = hdev->vhost_ops->vhost_backend_get_vq_index(hdev, n); 1078 - r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_VRING_CALL, &file); 1155 + file.index = hdev->vhost_ops->vhost_get_vq_index(hdev, n); 1156 + r = hdev->vhost_ops->vhost_set_vring_call(hdev, &file); 1079 1157 assert(r >= 0); 1080 1158 } 1081 1159 ··· 1117 1195 if (r < 0) { 1118 1196 goto fail_features; 1119 1197 } 1120 - r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_MEM_TABLE, hdev->mem); 1198 + r = hdev->vhost_ops->vhost_set_mem_table(hdev, hdev->mem); 1121 1199 if (r < 0) { 1122 1200 r = -errno; 1123 1201 goto fail_mem; ··· 1136 1214 uint64_t log_base; 1137 1215 1138 1216 hdev->log_size = vhost_get_log_size(hdev); 1139 - hdev->log = vhost_log_get(hdev->log_size); 1217 + hdev->log = vhost_log_get(hdev->log_size, 1218 + vhost_dev_log_is_shared(hdev)); 1140 1219 log_base = (uintptr_t)hdev->log->log; 1141 - r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE, 1142 - hdev->log_size ? &log_base : NULL); 1220 + r = hdev->vhost_ops->vhost_set_log_base(hdev, 1221 + hdev->log_size ? log_base : 0, 1222 + hdev->log); 1143 1223 if (r < 0) { 1144 1224 r = -errno; 1145 1225 goto fail_log;
+14 -2
include/hw/i386/intel_iommu.h
··· 49 49 typedef struct IntelIOMMUState IntelIOMMUState; 50 50 typedef struct VTDAddressSpace VTDAddressSpace; 51 51 typedef struct VTDIOTLBEntry VTDIOTLBEntry; 52 + typedef struct VTDBus VTDBus; 52 53 53 54 /* Context-Entry */ 54 55 struct VTDContextEntry { ··· 65 66 }; 66 67 67 68 struct VTDAddressSpace { 68 - uint8_t bus_num; 69 + PCIBus *bus; 69 70 uint8_t devfn; 70 71 AddressSpace as; 71 72 MemoryRegion iommu; 72 73 IntelIOMMUState *iommu_state; 73 74 VTDContextCacheEntry context_cache_entry; 75 + }; 76 + 77 + struct VTDBus { 78 + PCIBus* bus; /* A reference to the bus to provide translation for */ 79 + VTDAddressSpace *dev_as[0]; /* A table of VTDAddressSpace objects indexed by devfn */ 74 80 }; 75 81 76 82 struct VTDIOTLBEntry { ··· 114 120 GHashTable *iotlb; /* IOTLB */ 115 121 116 122 MemoryRegionIOMMUOps iommu_ops; 117 - VTDAddressSpace **address_spaces[VTD_PCI_BUS_MAX]; 123 + GHashTable *vtd_as_by_busptr; /* VTDBus objects indexed by PCIBus* reference */ 124 + VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */ 118 125 }; 126 + 127 + /* Find the VTD Address space associated with the given bus pointer, 128 + * create a new one if none exists 129 + */ 130 + VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn); 119 131 120 132 #endif
+1 -1
include/hw/i386/pc.h
··· 168 168 void pc_register_ferr_irq(qemu_irq irq); 169 169 void pc_acpi_smi_interrupt(void *opaque, int irq, int level); 170 170 171 - void pc_cpus_init(const char *cpu_model); 171 + void pc_cpus_init(PCMachineState *pcms); 172 172 void pc_hot_add_cpu(const int64_t id, Error **errp); 173 173 void pc_acpi_init(const char *default_dsdt); 174 174
+70 -7
include/hw/virtio/vhost-backend.h
··· 11 11 #ifndef VHOST_BACKEND_H_ 12 12 #define VHOST_BACKEND_H_ 13 13 14 + #include <stdbool.h> 15 + 14 16 typedef enum VhostBackendType { 15 17 VHOST_BACKEND_TYPE_NONE = 0, 16 18 VHOST_BACKEND_TYPE_KERNEL = 1, ··· 19 21 } VhostBackendType; 20 22 21 23 struct vhost_dev; 24 + struct vhost_log; 25 + struct vhost_memory; 26 + struct vhost_vring_file; 27 + struct vhost_vring_state; 28 + struct vhost_vring_addr; 29 + struct vhost_scsi_target; 22 30 23 - typedef int (*vhost_call)(struct vhost_dev *dev, unsigned long int request, 24 - void *arg); 25 31 typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque); 26 32 typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev); 27 - typedef int (*vhost_backend_get_vq_index)(struct vhost_dev *dev, int idx); 28 - typedef int (*vhost_backend_set_vring_enable)(struct vhost_dev *dev, int enable); 33 + typedef int (*vhost_backend_memslots_limit)(struct vhost_dev *dev); 34 + 35 + typedef int (*vhost_net_set_backend_op)(struct vhost_dev *dev, 36 + struct vhost_vring_file *file); 37 + typedef int (*vhost_scsi_set_endpoint_op)(struct vhost_dev *dev, 38 + struct vhost_scsi_target *target); 39 + typedef int (*vhost_scsi_clear_endpoint_op)(struct vhost_dev *dev, 40 + struct vhost_scsi_target *target); 41 + typedef int (*vhost_scsi_get_abi_version_op)(struct vhost_dev *dev, 42 + int *version); 43 + typedef int (*vhost_set_log_base_op)(struct vhost_dev *dev, uint64_t base, 44 + struct vhost_log *log); 45 + typedef int (*vhost_set_mem_table_op)(struct vhost_dev *dev, 46 + struct vhost_memory *mem); 47 + typedef int (*vhost_set_vring_addr_op)(struct vhost_dev *dev, 48 + struct vhost_vring_addr *addr); 49 + typedef int (*vhost_set_vring_endian_op)(struct vhost_dev *dev, 50 + struct vhost_vring_state *ring); 51 + typedef int (*vhost_set_vring_num_op)(struct vhost_dev *dev, 52 + struct vhost_vring_state *ring); 53 + typedef int (*vhost_set_vring_base_op)(struct vhost_dev *dev, 54 + struct vhost_vring_state *ring); 55 + typedef int (*vhost_get_vring_base_op)(struct vhost_dev *dev, 56 + struct vhost_vring_state *ring); 57 + typedef int (*vhost_set_vring_kick_op)(struct vhost_dev *dev, 58 + struct vhost_vring_file *file); 59 + typedef int (*vhost_set_vring_call_op)(struct vhost_dev *dev, 60 + struct vhost_vring_file *file); 61 + typedef int (*vhost_set_features_op)(struct vhost_dev *dev, 62 + uint64_t features); 63 + typedef int (*vhost_get_features_op)(struct vhost_dev *dev, 64 + uint64_t *features); 65 + typedef int (*vhost_set_owner_op)(struct vhost_dev *dev); 66 + typedef int (*vhost_reset_device_op)(struct vhost_dev *dev); 67 + typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx); 68 + typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev, 69 + int enable); 70 + typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev); 71 + typedef int (*vhost_migration_done_op)(struct vhost_dev *dev, 72 + char *mac_addr); 29 73 30 74 typedef struct VhostOps { 31 75 VhostBackendType backend_type; 32 - vhost_call vhost_call; 33 76 vhost_backend_init vhost_backend_init; 34 77 vhost_backend_cleanup vhost_backend_cleanup; 35 - vhost_backend_get_vq_index vhost_backend_get_vq_index; 36 - vhost_backend_set_vring_enable vhost_backend_set_vring_enable; 78 + vhost_backend_memslots_limit vhost_backend_memslots_limit; 79 + vhost_net_set_backend_op vhost_net_set_backend; 80 + vhost_scsi_set_endpoint_op vhost_scsi_set_endpoint; 81 + vhost_scsi_clear_endpoint_op vhost_scsi_clear_endpoint; 82 + vhost_scsi_get_abi_version_op vhost_scsi_get_abi_version; 83 + vhost_set_log_base_op vhost_set_log_base; 84 + vhost_set_mem_table_op vhost_set_mem_table; 85 + vhost_set_vring_addr_op vhost_set_vring_addr; 86 + vhost_set_vring_endian_op vhost_set_vring_endian; 87 + vhost_set_vring_num_op vhost_set_vring_num; 88 + vhost_set_vring_base_op vhost_set_vring_base; 89 + vhost_get_vring_base_op vhost_get_vring_base; 90 + vhost_set_vring_kick_op vhost_set_vring_kick; 91 + vhost_set_vring_call_op vhost_set_vring_call; 92 + vhost_set_features_op vhost_set_features; 93 + vhost_get_features_op vhost_get_features; 94 + vhost_set_owner_op vhost_set_owner; 95 + vhost_reset_device_op vhost_reset_device; 96 + vhost_get_vq_index_op vhost_get_vq_index; 97 + vhost_set_vring_enable_op vhost_set_vring_enable; 98 + vhost_requires_shm_log_op vhost_requires_shm_log; 99 + vhost_migration_done_op vhost_migration_done; 37 100 } VhostOps; 38 101 39 102 extern const VhostOps user_ops;
+10 -7
include/hw/virtio/vhost.h
··· 31 31 struct vhost_log { 32 32 unsigned long long size; 33 33 int refcnt; 34 - vhost_log_chunk_t log[0]; 34 + int fd; 35 + vhost_log_chunk_t *log; 35 36 }; 36 37 37 38 struct vhost_memory; ··· 44 45 int nvqs; 45 46 /* the first virtqueue which would be used by this vhost dev */ 46 47 int vq_index; 47 - unsigned long long features; 48 - unsigned long long acked_features; 49 - unsigned long long backend_features; 50 - unsigned long long protocol_features; 51 - unsigned long long max_queues; 48 + uint64_t features; 49 + uint64_t acked_features; 50 + uint64_t backend_features; 51 + uint64_t protocol_features; 52 + uint64_t max_queues; 52 53 bool started; 53 54 bool log_enabled; 54 - unsigned long long log_size; 55 + uint64_t log_size; 55 56 Error *migration_blocker; 56 57 bool memory_changed; 57 58 hwaddr mem_changed_start_addr; ··· 59 60 const VhostOps *vhost_ops; 60 61 void *opaque; 61 62 struct vhost_log *log; 63 + QLIST_ENTRY(vhost_dev) entry; 62 64 }; 63 65 64 66 int vhost_dev_init(struct vhost_dev *hdev, void *opaque, ··· 83 85 uint64_t features); 84 86 void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, 85 87 uint64_t features); 88 + bool vhost_has_free_slot(void); 86 89 #endif
+1
include/net/vhost_net.h
··· 27 27 bool vhost_net_virtqueue_pending(VHostNetState *net, int n); 28 28 void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, 29 29 int idx, bool mask); 30 + int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr); 30 31 VHostNetState *get_vhost_net(NetClientState *nc); 31 32 32 33 int vhost_set_vring_enable(NetClientState * nc, int enable);
+26
include/qemu/memfd.h
··· 1 + #ifndef QEMU_MEMFD_H 2 + #define QEMU_MEMFD_H 3 + 4 + #include "config-host.h" 5 + #include <stdbool.h> 6 + 7 + #ifndef F_LINUX_SPECIFIC_BASE 8 + #define F_LINUX_SPECIFIC_BASE 1024 9 + #endif 10 + 11 + #ifndef F_ADD_SEALS 12 + #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) 13 + #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) 14 + 15 + #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ 16 + #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ 17 + #define F_SEAL_GROW 0x0004 /* prevent file from growing */ 18 + #define F_SEAL_WRITE 0x0008 /* prevent writes */ 19 + #endif 20 + 21 + void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, 22 + int *fd); 23 + void qemu_memfd_free(void *ptr, size_t size, int fd); 24 + bool qemu_memfd_check(void); 25 + 26 + #endif /* QEMU_MEMFD_H */
+10
include/qemu/mmap-alloc.h
··· 1 + #ifndef QEMU_MMAP_ALLOC 2 + #define QEMU_MMAP_ALLOC 3 + 4 + #include "qemu-common.h" 5 + 6 + void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared); 7 + 8 + void qemu_ram_munmap(void *ptr, size_t size); 9 + 10 + #endif
+448
linux-headers/asm-arm/unistd.h
··· 1 + /* 2 + * arch/arm/include/asm/unistd.h 3 + * 4 + * Copyright (C) 2001-2005 Russell King 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + * 10 + * Please forward _all_ changes to this file to rmk@arm.linux.org.uk, 11 + * no matter what the change is. Thanks! 12 + */ 13 + #ifndef __ASM_ARM_UNISTD_H 14 + #define __ASM_ARM_UNISTD_H 15 + 16 + #define __NR_OABI_SYSCALL_BASE 0x900000 17 + 18 + #if defined(__thumb__) || defined(__ARM_EABI__) 19 + #define __NR_SYSCALL_BASE 0 20 + #else 21 + #define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE 22 + #endif 23 + 24 + /* 25 + * This file contains the system call numbers. 26 + */ 27 + 28 + #define __NR_restart_syscall (__NR_SYSCALL_BASE+ 0) 29 + #define __NR_exit (__NR_SYSCALL_BASE+ 1) 30 + #define __NR_fork (__NR_SYSCALL_BASE+ 2) 31 + #define __NR_read (__NR_SYSCALL_BASE+ 3) 32 + #define __NR_write (__NR_SYSCALL_BASE+ 4) 33 + #define __NR_open (__NR_SYSCALL_BASE+ 5) 34 + #define __NR_close (__NR_SYSCALL_BASE+ 6) 35 + /* 7 was sys_waitpid */ 36 + #define __NR_creat (__NR_SYSCALL_BASE+ 8) 37 + #define __NR_link (__NR_SYSCALL_BASE+ 9) 38 + #define __NR_unlink (__NR_SYSCALL_BASE+ 10) 39 + #define __NR_execve (__NR_SYSCALL_BASE+ 11) 40 + #define __NR_chdir (__NR_SYSCALL_BASE+ 12) 41 + #define __NR_time (__NR_SYSCALL_BASE+ 13) 42 + #define __NR_mknod (__NR_SYSCALL_BASE+ 14) 43 + #define __NR_chmod (__NR_SYSCALL_BASE+ 15) 44 + #define __NR_lchown (__NR_SYSCALL_BASE+ 16) 45 + /* 17 was sys_break */ 46 + /* 18 was sys_stat */ 47 + #define __NR_lseek (__NR_SYSCALL_BASE+ 19) 48 + #define __NR_getpid (__NR_SYSCALL_BASE+ 20) 49 + #define __NR_mount (__NR_SYSCALL_BASE+ 21) 50 + #define __NR_umount (__NR_SYSCALL_BASE+ 22) 51 + #define __NR_setuid (__NR_SYSCALL_BASE+ 23) 52 + #define __NR_getuid (__NR_SYSCALL_BASE+ 24) 53 + #define __NR_stime (__NR_SYSCALL_BASE+ 25) 54 + #define __NR_ptrace (__NR_SYSCALL_BASE+ 26) 55 + #define __NR_alarm (__NR_SYSCALL_BASE+ 27) 56 + /* 28 was sys_fstat */ 57 + #define __NR_pause (__NR_SYSCALL_BASE+ 29) 58 + #define __NR_utime (__NR_SYSCALL_BASE+ 30) 59 + /* 31 was sys_stty */ 60 + /* 32 was sys_gtty */ 61 + #define __NR_access (__NR_SYSCALL_BASE+ 33) 62 + #define __NR_nice (__NR_SYSCALL_BASE+ 34) 63 + /* 35 was sys_ftime */ 64 + #define __NR_sync (__NR_SYSCALL_BASE+ 36) 65 + #define __NR_kill (__NR_SYSCALL_BASE+ 37) 66 + #define __NR_rename (__NR_SYSCALL_BASE+ 38) 67 + #define __NR_mkdir (__NR_SYSCALL_BASE+ 39) 68 + #define __NR_rmdir (__NR_SYSCALL_BASE+ 40) 69 + #define __NR_dup (__NR_SYSCALL_BASE+ 41) 70 + #define __NR_pipe (__NR_SYSCALL_BASE+ 42) 71 + #define __NR_times (__NR_SYSCALL_BASE+ 43) 72 + /* 44 was sys_prof */ 73 + #define __NR_brk (__NR_SYSCALL_BASE+ 45) 74 + #define __NR_setgid (__NR_SYSCALL_BASE+ 46) 75 + #define __NR_getgid (__NR_SYSCALL_BASE+ 47) 76 + /* 48 was sys_signal */ 77 + #define __NR_geteuid (__NR_SYSCALL_BASE+ 49) 78 + #define __NR_getegid (__NR_SYSCALL_BASE+ 50) 79 + #define __NR_acct (__NR_SYSCALL_BASE+ 51) 80 + #define __NR_umount2 (__NR_SYSCALL_BASE+ 52) 81 + /* 53 was sys_lock */ 82 + #define __NR_ioctl (__NR_SYSCALL_BASE+ 54) 83 + #define __NR_fcntl (__NR_SYSCALL_BASE+ 55) 84 + /* 56 was sys_mpx */ 85 + #define __NR_setpgid (__NR_SYSCALL_BASE+ 57) 86 + /* 58 was sys_ulimit */ 87 + /* 59 was sys_olduname */ 88 + #define __NR_umask (__NR_SYSCALL_BASE+ 60) 89 + #define __NR_chroot (__NR_SYSCALL_BASE+ 61) 90 + #define __NR_ustat (__NR_SYSCALL_BASE+ 62) 91 + #define __NR_dup2 (__NR_SYSCALL_BASE+ 63) 92 + #define __NR_getppid (__NR_SYSCALL_BASE+ 64) 93 + #define __NR_getpgrp (__NR_SYSCALL_BASE+ 65) 94 + #define __NR_setsid (__NR_SYSCALL_BASE+ 66) 95 + #define __NR_sigaction (__NR_SYSCALL_BASE+ 67) 96 + /* 68 was sys_sgetmask */ 97 + /* 69 was sys_ssetmask */ 98 + #define __NR_setreuid (__NR_SYSCALL_BASE+ 70) 99 + #define __NR_setregid (__NR_SYSCALL_BASE+ 71) 100 + #define __NR_sigsuspend (__NR_SYSCALL_BASE+ 72) 101 + #define __NR_sigpending (__NR_SYSCALL_BASE+ 73) 102 + #define __NR_sethostname (__NR_SYSCALL_BASE+ 74) 103 + #define __NR_setrlimit (__NR_SYSCALL_BASE+ 75) 104 + #define __NR_getrlimit (__NR_SYSCALL_BASE+ 76) /* Back compat 2GB limited rlimit */ 105 + #define __NR_getrusage (__NR_SYSCALL_BASE+ 77) 106 + #define __NR_gettimeofday (__NR_SYSCALL_BASE+ 78) 107 + #define __NR_settimeofday (__NR_SYSCALL_BASE+ 79) 108 + #define __NR_getgroups (__NR_SYSCALL_BASE+ 80) 109 + #define __NR_setgroups (__NR_SYSCALL_BASE+ 81) 110 + #define __NR_select (__NR_SYSCALL_BASE+ 82) 111 + #define __NR_symlink (__NR_SYSCALL_BASE+ 83) 112 + /* 84 was sys_lstat */ 113 + #define __NR_readlink (__NR_SYSCALL_BASE+ 85) 114 + #define __NR_uselib (__NR_SYSCALL_BASE+ 86) 115 + #define __NR_swapon (__NR_SYSCALL_BASE+ 87) 116 + #define __NR_reboot (__NR_SYSCALL_BASE+ 88) 117 + #define __NR_readdir (__NR_SYSCALL_BASE+ 89) 118 + #define __NR_mmap (__NR_SYSCALL_BASE+ 90) 119 + #define __NR_munmap (__NR_SYSCALL_BASE+ 91) 120 + #define __NR_truncate (__NR_SYSCALL_BASE+ 92) 121 + #define __NR_ftruncate (__NR_SYSCALL_BASE+ 93) 122 + #define __NR_fchmod (__NR_SYSCALL_BASE+ 94) 123 + #define __NR_fchown (__NR_SYSCALL_BASE+ 95) 124 + #define __NR_getpriority (__NR_SYSCALL_BASE+ 96) 125 + #define __NR_setpriority (__NR_SYSCALL_BASE+ 97) 126 + /* 98 was sys_profil */ 127 + #define __NR_statfs (__NR_SYSCALL_BASE+ 99) 128 + #define __NR_fstatfs (__NR_SYSCALL_BASE+100) 129 + /* 101 was sys_ioperm */ 130 + #define __NR_socketcall (__NR_SYSCALL_BASE+102) 131 + #define __NR_syslog (__NR_SYSCALL_BASE+103) 132 + #define __NR_setitimer (__NR_SYSCALL_BASE+104) 133 + #define __NR_getitimer (__NR_SYSCALL_BASE+105) 134 + #define __NR_stat (__NR_SYSCALL_BASE+106) 135 + #define __NR_lstat (__NR_SYSCALL_BASE+107) 136 + #define __NR_fstat (__NR_SYSCALL_BASE+108) 137 + /* 109 was sys_uname */ 138 + /* 110 was sys_iopl */ 139 + #define __NR_vhangup (__NR_SYSCALL_BASE+111) 140 + /* 112 was sys_idle */ 141 + #define __NR_syscall (__NR_SYSCALL_BASE+113) /* syscall to call a syscall! */ 142 + #define __NR_wait4 (__NR_SYSCALL_BASE+114) 143 + #define __NR_swapoff (__NR_SYSCALL_BASE+115) 144 + #define __NR_sysinfo (__NR_SYSCALL_BASE+116) 145 + #define __NR_ipc (__NR_SYSCALL_BASE+117) 146 + #define __NR_fsync (__NR_SYSCALL_BASE+118) 147 + #define __NR_sigreturn (__NR_SYSCALL_BASE+119) 148 + #define __NR_clone (__NR_SYSCALL_BASE+120) 149 + #define __NR_setdomainname (__NR_SYSCALL_BASE+121) 150 + #define __NR_uname (__NR_SYSCALL_BASE+122) 151 + /* 123 was sys_modify_ldt */ 152 + #define __NR_adjtimex (__NR_SYSCALL_BASE+124) 153 + #define __NR_mprotect (__NR_SYSCALL_BASE+125) 154 + #define __NR_sigprocmask (__NR_SYSCALL_BASE+126) 155 + /* 127 was sys_create_module */ 156 + #define __NR_init_module (__NR_SYSCALL_BASE+128) 157 + #define __NR_delete_module (__NR_SYSCALL_BASE+129) 158 + /* 130 was sys_get_kernel_syms */ 159 + #define __NR_quotactl (__NR_SYSCALL_BASE+131) 160 + #define __NR_getpgid (__NR_SYSCALL_BASE+132) 161 + #define __NR_fchdir (__NR_SYSCALL_BASE+133) 162 + #define __NR_bdflush (__NR_SYSCALL_BASE+134) 163 + #define __NR_sysfs (__NR_SYSCALL_BASE+135) 164 + #define __NR_personality (__NR_SYSCALL_BASE+136) 165 + /* 137 was sys_afs_syscall */ 166 + #define __NR_setfsuid (__NR_SYSCALL_BASE+138) 167 + #define __NR_setfsgid (__NR_SYSCALL_BASE+139) 168 + #define __NR__llseek (__NR_SYSCALL_BASE+140) 169 + #define __NR_getdents (__NR_SYSCALL_BASE+141) 170 + #define __NR__newselect (__NR_SYSCALL_BASE+142) 171 + #define __NR_flock (__NR_SYSCALL_BASE+143) 172 + #define __NR_msync (__NR_SYSCALL_BASE+144) 173 + #define __NR_readv (__NR_SYSCALL_BASE+145) 174 + #define __NR_writev (__NR_SYSCALL_BASE+146) 175 + #define __NR_getsid (__NR_SYSCALL_BASE+147) 176 + #define __NR_fdatasync (__NR_SYSCALL_BASE+148) 177 + #define __NR__sysctl (__NR_SYSCALL_BASE+149) 178 + #define __NR_mlock (__NR_SYSCALL_BASE+150) 179 + #define __NR_munlock (__NR_SYSCALL_BASE+151) 180 + #define __NR_mlockall (__NR_SYSCALL_BASE+152) 181 + #define __NR_munlockall (__NR_SYSCALL_BASE+153) 182 + #define __NR_sched_setparam (__NR_SYSCALL_BASE+154) 183 + #define __NR_sched_getparam (__NR_SYSCALL_BASE+155) 184 + #define __NR_sched_setscheduler (__NR_SYSCALL_BASE+156) 185 + #define __NR_sched_getscheduler (__NR_SYSCALL_BASE+157) 186 + #define __NR_sched_yield (__NR_SYSCALL_BASE+158) 187 + #define __NR_sched_get_priority_max (__NR_SYSCALL_BASE+159) 188 + #define __NR_sched_get_priority_min (__NR_SYSCALL_BASE+160) 189 + #define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE+161) 190 + #define __NR_nanosleep (__NR_SYSCALL_BASE+162) 191 + #define __NR_mremap (__NR_SYSCALL_BASE+163) 192 + #define __NR_setresuid (__NR_SYSCALL_BASE+164) 193 + #define __NR_getresuid (__NR_SYSCALL_BASE+165) 194 + /* 166 was sys_vm86 */ 195 + /* 167 was sys_query_module */ 196 + #define __NR_poll (__NR_SYSCALL_BASE+168) 197 + #define __NR_nfsservctl (__NR_SYSCALL_BASE+169) 198 + #define __NR_setresgid (__NR_SYSCALL_BASE+170) 199 + #define __NR_getresgid (__NR_SYSCALL_BASE+171) 200 + #define __NR_prctl (__NR_SYSCALL_BASE+172) 201 + #define __NR_rt_sigreturn (__NR_SYSCALL_BASE+173) 202 + #define __NR_rt_sigaction (__NR_SYSCALL_BASE+174) 203 + #define __NR_rt_sigprocmask (__NR_SYSCALL_BASE+175) 204 + #define __NR_rt_sigpending (__NR_SYSCALL_BASE+176) 205 + #define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE+177) 206 + #define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE+178) 207 + #define __NR_rt_sigsuspend (__NR_SYSCALL_BASE+179) 208 + #define __NR_pread64 (__NR_SYSCALL_BASE+180) 209 + #define __NR_pwrite64 (__NR_SYSCALL_BASE+181) 210 + #define __NR_chown (__NR_SYSCALL_BASE+182) 211 + #define __NR_getcwd (__NR_SYSCALL_BASE+183) 212 + #define __NR_capget (__NR_SYSCALL_BASE+184) 213 + #define __NR_capset (__NR_SYSCALL_BASE+185) 214 + #define __NR_sigaltstack (__NR_SYSCALL_BASE+186) 215 + #define __NR_sendfile (__NR_SYSCALL_BASE+187) 216 + /* 188 reserved */ 217 + /* 189 reserved */ 218 + #define __NR_vfork (__NR_SYSCALL_BASE+190) 219 + #define __NR_ugetrlimit (__NR_SYSCALL_BASE+191) /* SuS compliant getrlimit */ 220 + #define __NR_mmap2 (__NR_SYSCALL_BASE+192) 221 + #define __NR_truncate64 (__NR_SYSCALL_BASE+193) 222 + #define __NR_ftruncate64 (__NR_SYSCALL_BASE+194) 223 + #define __NR_stat64 (__NR_SYSCALL_BASE+195) 224 + #define __NR_lstat64 (__NR_SYSCALL_BASE+196) 225 + #define __NR_fstat64 (__NR_SYSCALL_BASE+197) 226 + #define __NR_lchown32 (__NR_SYSCALL_BASE+198) 227 + #define __NR_getuid32 (__NR_SYSCALL_BASE+199) 228 + #define __NR_getgid32 (__NR_SYSCALL_BASE+200) 229 + #define __NR_geteuid32 (__NR_SYSCALL_BASE+201) 230 + #define __NR_getegid32 (__NR_SYSCALL_BASE+202) 231 + #define __NR_setreuid32 (__NR_SYSCALL_BASE+203) 232 + #define __NR_setregid32 (__NR_SYSCALL_BASE+204) 233 + #define __NR_getgroups32 (__NR_SYSCALL_BASE+205) 234 + #define __NR_setgroups32 (__NR_SYSCALL_BASE+206) 235 + #define __NR_fchown32 (__NR_SYSCALL_BASE+207) 236 + #define __NR_setresuid32 (__NR_SYSCALL_BASE+208) 237 + #define __NR_getresuid32 (__NR_SYSCALL_BASE+209) 238 + #define __NR_setresgid32 (__NR_SYSCALL_BASE+210) 239 + #define __NR_getresgid32 (__NR_SYSCALL_BASE+211) 240 + #define __NR_chown32 (__NR_SYSCALL_BASE+212) 241 + #define __NR_setuid32 (__NR_SYSCALL_BASE+213) 242 + #define __NR_setgid32 (__NR_SYSCALL_BASE+214) 243 + #define __NR_setfsuid32 (__NR_SYSCALL_BASE+215) 244 + #define __NR_setfsgid32 (__NR_SYSCALL_BASE+216) 245 + #define __NR_getdents64 (__NR_SYSCALL_BASE+217) 246 + #define __NR_pivot_root (__NR_SYSCALL_BASE+218) 247 + #define __NR_mincore (__NR_SYSCALL_BASE+219) 248 + #define __NR_madvise (__NR_SYSCALL_BASE+220) 249 + #define __NR_fcntl64 (__NR_SYSCALL_BASE+221) 250 + /* 222 for tux */ 251 + /* 223 is unused */ 252 + #define __NR_gettid (__NR_SYSCALL_BASE+224) 253 + #define __NR_readahead (__NR_SYSCALL_BASE+225) 254 + #define __NR_setxattr (__NR_SYSCALL_BASE+226) 255 + #define __NR_lsetxattr (__NR_SYSCALL_BASE+227) 256 + #define __NR_fsetxattr (__NR_SYSCALL_BASE+228) 257 + #define __NR_getxattr (__NR_SYSCALL_BASE+229) 258 + #define __NR_lgetxattr (__NR_SYSCALL_BASE+230) 259 + #define __NR_fgetxattr (__NR_SYSCALL_BASE+231) 260 + #define __NR_listxattr (__NR_SYSCALL_BASE+232) 261 + #define __NR_llistxattr (__NR_SYSCALL_BASE+233) 262 + #define __NR_flistxattr (__NR_SYSCALL_BASE+234) 263 + #define __NR_removexattr (__NR_SYSCALL_BASE+235) 264 + #define __NR_lremovexattr (__NR_SYSCALL_BASE+236) 265 + #define __NR_fremovexattr (__NR_SYSCALL_BASE+237) 266 + #define __NR_tkill (__NR_SYSCALL_BASE+238) 267 + #define __NR_sendfile64 (__NR_SYSCALL_BASE+239) 268 + #define __NR_futex (__NR_SYSCALL_BASE+240) 269 + #define __NR_sched_setaffinity (__NR_SYSCALL_BASE+241) 270 + #define __NR_sched_getaffinity (__NR_SYSCALL_BASE+242) 271 + #define __NR_io_setup (__NR_SYSCALL_BASE+243) 272 + #define __NR_io_destroy (__NR_SYSCALL_BASE+244) 273 + #define __NR_io_getevents (__NR_SYSCALL_BASE+245) 274 + #define __NR_io_submit (__NR_SYSCALL_BASE+246) 275 + #define __NR_io_cancel (__NR_SYSCALL_BASE+247) 276 + #define __NR_exit_group (__NR_SYSCALL_BASE+248) 277 + #define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249) 278 + #define __NR_epoll_create (__NR_SYSCALL_BASE+250) 279 + #define __NR_epoll_ctl (__NR_SYSCALL_BASE+251) 280 + #define __NR_epoll_wait (__NR_SYSCALL_BASE+252) 281 + #define __NR_remap_file_pages (__NR_SYSCALL_BASE+253) 282 + /* 254 for set_thread_area */ 283 + /* 255 for get_thread_area */ 284 + #define __NR_set_tid_address (__NR_SYSCALL_BASE+256) 285 + #define __NR_timer_create (__NR_SYSCALL_BASE+257) 286 + #define __NR_timer_settime (__NR_SYSCALL_BASE+258) 287 + #define __NR_timer_gettime (__NR_SYSCALL_BASE+259) 288 + #define __NR_timer_getoverrun (__NR_SYSCALL_BASE+260) 289 + #define __NR_timer_delete (__NR_SYSCALL_BASE+261) 290 + #define __NR_clock_settime (__NR_SYSCALL_BASE+262) 291 + #define __NR_clock_gettime (__NR_SYSCALL_BASE+263) 292 + #define __NR_clock_getres (__NR_SYSCALL_BASE+264) 293 + #define __NR_clock_nanosleep (__NR_SYSCALL_BASE+265) 294 + #define __NR_statfs64 (__NR_SYSCALL_BASE+266) 295 + #define __NR_fstatfs64 (__NR_SYSCALL_BASE+267) 296 + #define __NR_tgkill (__NR_SYSCALL_BASE+268) 297 + #define __NR_utimes (__NR_SYSCALL_BASE+269) 298 + #define __NR_arm_fadvise64_64 (__NR_SYSCALL_BASE+270) 299 + #define __NR_pciconfig_iobase (__NR_SYSCALL_BASE+271) 300 + #define __NR_pciconfig_read (__NR_SYSCALL_BASE+272) 301 + #define __NR_pciconfig_write (__NR_SYSCALL_BASE+273) 302 + #define __NR_mq_open (__NR_SYSCALL_BASE+274) 303 + #define __NR_mq_unlink (__NR_SYSCALL_BASE+275) 304 + #define __NR_mq_timedsend (__NR_SYSCALL_BASE+276) 305 + #define __NR_mq_timedreceive (__NR_SYSCALL_BASE+277) 306 + #define __NR_mq_notify (__NR_SYSCALL_BASE+278) 307 + #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279) 308 + #define __NR_waitid (__NR_SYSCALL_BASE+280) 309 + #define __NR_socket (__NR_SYSCALL_BASE+281) 310 + #define __NR_bind (__NR_SYSCALL_BASE+282) 311 + #define __NR_connect (__NR_SYSCALL_BASE+283) 312 + #define __NR_listen (__NR_SYSCALL_BASE+284) 313 + #define __NR_accept (__NR_SYSCALL_BASE+285) 314 + #define __NR_getsockname (__NR_SYSCALL_BASE+286) 315 + #define __NR_getpeername (__NR_SYSCALL_BASE+287) 316 + #define __NR_socketpair (__NR_SYSCALL_BASE+288) 317 + #define __NR_send (__NR_SYSCALL_BASE+289) 318 + #define __NR_sendto (__NR_SYSCALL_BASE+290) 319 + #define __NR_recv (__NR_SYSCALL_BASE+291) 320 + #define __NR_recvfrom (__NR_SYSCALL_BASE+292) 321 + #define __NR_shutdown (__NR_SYSCALL_BASE+293) 322 + #define __NR_setsockopt (__NR_SYSCALL_BASE+294) 323 + #define __NR_getsockopt (__NR_SYSCALL_BASE+295) 324 + #define __NR_sendmsg (__NR_SYSCALL_BASE+296) 325 + #define __NR_recvmsg (__NR_SYSCALL_BASE+297) 326 + #define __NR_semop (__NR_SYSCALL_BASE+298) 327 + #define __NR_semget (__NR_SYSCALL_BASE+299) 328 + #define __NR_semctl (__NR_SYSCALL_BASE+300) 329 + #define __NR_msgsnd (__NR_SYSCALL_BASE+301) 330 + #define __NR_msgrcv (__NR_SYSCALL_BASE+302) 331 + #define __NR_msgget (__NR_SYSCALL_BASE+303) 332 + #define __NR_msgctl (__NR_SYSCALL_BASE+304) 333 + #define __NR_shmat (__NR_SYSCALL_BASE+305) 334 + #define __NR_shmdt (__NR_SYSCALL_BASE+306) 335 + #define __NR_shmget (__NR_SYSCALL_BASE+307) 336 + #define __NR_shmctl (__NR_SYSCALL_BASE+308) 337 + #define __NR_add_key (__NR_SYSCALL_BASE+309) 338 + #define __NR_request_key (__NR_SYSCALL_BASE+310) 339 + #define __NR_keyctl (__NR_SYSCALL_BASE+311) 340 + #define __NR_semtimedop (__NR_SYSCALL_BASE+312) 341 + #define __NR_vserver (__NR_SYSCALL_BASE+313) 342 + #define __NR_ioprio_set (__NR_SYSCALL_BASE+314) 343 + #define __NR_ioprio_get (__NR_SYSCALL_BASE+315) 344 + #define __NR_inotify_init (__NR_SYSCALL_BASE+316) 345 + #define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317) 346 + #define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318) 347 + #define __NR_mbind (__NR_SYSCALL_BASE+319) 348 + #define __NR_get_mempolicy (__NR_SYSCALL_BASE+320) 349 + #define __NR_set_mempolicy (__NR_SYSCALL_BASE+321) 350 + #define __NR_openat (__NR_SYSCALL_BASE+322) 351 + #define __NR_mkdirat (__NR_SYSCALL_BASE+323) 352 + #define __NR_mknodat (__NR_SYSCALL_BASE+324) 353 + #define __NR_fchownat (__NR_SYSCALL_BASE+325) 354 + #define __NR_futimesat (__NR_SYSCALL_BASE+326) 355 + #define __NR_fstatat64 (__NR_SYSCALL_BASE+327) 356 + #define __NR_unlinkat (__NR_SYSCALL_BASE+328) 357 + #define __NR_renameat (__NR_SYSCALL_BASE+329) 358 + #define __NR_linkat (__NR_SYSCALL_BASE+330) 359 + #define __NR_symlinkat (__NR_SYSCALL_BASE+331) 360 + #define __NR_readlinkat (__NR_SYSCALL_BASE+332) 361 + #define __NR_fchmodat (__NR_SYSCALL_BASE+333) 362 + #define __NR_faccessat (__NR_SYSCALL_BASE+334) 363 + #define __NR_pselect6 (__NR_SYSCALL_BASE+335) 364 + #define __NR_ppoll (__NR_SYSCALL_BASE+336) 365 + #define __NR_unshare (__NR_SYSCALL_BASE+337) 366 + #define __NR_set_robust_list (__NR_SYSCALL_BASE+338) 367 + #define __NR_get_robust_list (__NR_SYSCALL_BASE+339) 368 + #define __NR_splice (__NR_SYSCALL_BASE+340) 369 + #define __NR_arm_sync_file_range (__NR_SYSCALL_BASE+341) 370 + #define __NR_sync_file_range2 __NR_arm_sync_file_range 371 + #define __NR_tee (__NR_SYSCALL_BASE+342) 372 + #define __NR_vmsplice (__NR_SYSCALL_BASE+343) 373 + #define __NR_move_pages (__NR_SYSCALL_BASE+344) 374 + #define __NR_getcpu (__NR_SYSCALL_BASE+345) 375 + #define __NR_epoll_pwait (__NR_SYSCALL_BASE+346) 376 + #define __NR_kexec_load (__NR_SYSCALL_BASE+347) 377 + #define __NR_utimensat (__NR_SYSCALL_BASE+348) 378 + #define __NR_signalfd (__NR_SYSCALL_BASE+349) 379 + #define __NR_timerfd_create (__NR_SYSCALL_BASE+350) 380 + #define __NR_eventfd (__NR_SYSCALL_BASE+351) 381 + #define __NR_fallocate (__NR_SYSCALL_BASE+352) 382 + #define __NR_timerfd_settime (__NR_SYSCALL_BASE+353) 383 + #define __NR_timerfd_gettime (__NR_SYSCALL_BASE+354) 384 + #define __NR_signalfd4 (__NR_SYSCALL_BASE+355) 385 + #define __NR_eventfd2 (__NR_SYSCALL_BASE+356) 386 + #define __NR_epoll_create1 (__NR_SYSCALL_BASE+357) 387 + #define __NR_dup3 (__NR_SYSCALL_BASE+358) 388 + #define __NR_pipe2 (__NR_SYSCALL_BASE+359) 389 + #define __NR_inotify_init1 (__NR_SYSCALL_BASE+360) 390 + #define __NR_preadv (__NR_SYSCALL_BASE+361) 391 + #define __NR_pwritev (__NR_SYSCALL_BASE+362) 392 + #define __NR_rt_tgsigqueueinfo (__NR_SYSCALL_BASE+363) 393 + #define __NR_perf_event_open (__NR_SYSCALL_BASE+364) 394 + #define __NR_recvmmsg (__NR_SYSCALL_BASE+365) 395 + #define __NR_accept4 (__NR_SYSCALL_BASE+366) 396 + #define __NR_fanotify_init (__NR_SYSCALL_BASE+367) 397 + #define __NR_fanotify_mark (__NR_SYSCALL_BASE+368) 398 + #define __NR_prlimit64 (__NR_SYSCALL_BASE+369) 399 + #define __NR_name_to_handle_at (__NR_SYSCALL_BASE+370) 400 + #define __NR_open_by_handle_at (__NR_SYSCALL_BASE+371) 401 + #define __NR_clock_adjtime (__NR_SYSCALL_BASE+372) 402 + #define __NR_syncfs (__NR_SYSCALL_BASE+373) 403 + #define __NR_sendmmsg (__NR_SYSCALL_BASE+374) 404 + #define __NR_setns (__NR_SYSCALL_BASE+375) 405 + #define __NR_process_vm_readv (__NR_SYSCALL_BASE+376) 406 + #define __NR_process_vm_writev (__NR_SYSCALL_BASE+377) 407 + #define __NR_kcmp (__NR_SYSCALL_BASE+378) 408 + #define __NR_finit_module (__NR_SYSCALL_BASE+379) 409 + #define __NR_sched_setattr (__NR_SYSCALL_BASE+380) 410 + #define __NR_sched_getattr (__NR_SYSCALL_BASE+381) 411 + #define __NR_renameat2 (__NR_SYSCALL_BASE+382) 412 + #define __NR_seccomp (__NR_SYSCALL_BASE+383) 413 + #define __NR_getrandom (__NR_SYSCALL_BASE+384) 414 + #define __NR_memfd_create (__NR_SYSCALL_BASE+385) 415 + #define __NR_bpf (__NR_SYSCALL_BASE+386) 416 + #define __NR_execveat (__NR_SYSCALL_BASE+387) 417 + #define __NR_userfaultfd (__NR_SYSCALL_BASE+388) 418 + #define __NR_membarrier (__NR_SYSCALL_BASE+389) 419 + 420 + /* 421 + * The following SWIs are ARM private. 422 + */ 423 + #define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000) 424 + #define __ARM_NR_breakpoint (__ARM_NR_BASE+1) 425 + #define __ARM_NR_cacheflush (__ARM_NR_BASE+2) 426 + #define __ARM_NR_usr26 (__ARM_NR_BASE+3) 427 + #define __ARM_NR_usr32 (__ARM_NR_BASE+4) 428 + #define __ARM_NR_set_tls (__ARM_NR_BASE+5) 429 + 430 + /* 431 + * The following syscalls are obsolete and no longer available for EABI. 432 + */ 433 + #if defined(__ARM_EABI__) 434 + #undef __NR_time 435 + #undef __NR_umount 436 + #undef __NR_stime 437 + #undef __NR_alarm 438 + #undef __NR_utime 439 + #undef __NR_getrlimit 440 + #undef __NR_select 441 + #undef __NR_readdir 442 + #undef __NR_mmap 443 + #undef __NR_socketcall 444 + #undef __NR_syscall 445 + #undef __NR_ipc 446 + #endif 447 + 448 + #endif /* __ASM_ARM_UNISTD_H */
+16
linux-headers/asm-arm64/unistd.h
··· 1 + /* 2 + * Copyright (C) 2012 ARM Ltd. 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License version 2 as 6 + * published by the Free Software Foundation. 7 + * 8 + * This program is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + * 13 + * You should have received a copy of the GNU General Public License 14 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 + */ 16 + #include <asm-generic/unistd.h>
+1063
linux-headers/asm-mips/unistd.h
··· 1 + /* 2 + * This file is subject to the terms and conditions of the GNU General Public 3 + * License. See the file "COPYING" in the main directory of this archive 4 + * for more details. 5 + * 6 + * Copyright (C) 1995, 96, 97, 98, 99, 2000 by Ralf Baechle 7 + * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 8 + * 9 + * Changed system calls macros _syscall5 - _syscall7 to push args 5 to 7 onto 10 + * the stack. Robin Farine for ACN S.A, Copyright (C) 1996 by ACN S.A 11 + */ 12 + #ifndef _ASM_UNISTD_H 13 + #define _ASM_UNISTD_H 14 + 15 + #include <asm/sgidefs.h> 16 + 17 + #if _MIPS_SIM == _MIPS_SIM_ABI32 18 + 19 + /* 20 + * Linux o32 style syscalls are in the range from 4000 to 4999. 21 + */ 22 + #define __NR_Linux 4000 23 + #define __NR_syscall (__NR_Linux + 0) 24 + #define __NR_exit (__NR_Linux + 1) 25 + #define __NR_fork (__NR_Linux + 2) 26 + #define __NR_read (__NR_Linux + 3) 27 + #define __NR_write (__NR_Linux + 4) 28 + #define __NR_open (__NR_Linux + 5) 29 + #define __NR_close (__NR_Linux + 6) 30 + #define __NR_waitpid (__NR_Linux + 7) 31 + #define __NR_creat (__NR_Linux + 8) 32 + #define __NR_link (__NR_Linux + 9) 33 + #define __NR_unlink (__NR_Linux + 10) 34 + #define __NR_execve (__NR_Linux + 11) 35 + #define __NR_chdir (__NR_Linux + 12) 36 + #define __NR_time (__NR_Linux + 13) 37 + #define __NR_mknod (__NR_Linux + 14) 38 + #define __NR_chmod (__NR_Linux + 15) 39 + #define __NR_lchown (__NR_Linux + 16) 40 + #define __NR_break (__NR_Linux + 17) 41 + #define __NR_unused18 (__NR_Linux + 18) 42 + #define __NR_lseek (__NR_Linux + 19) 43 + #define __NR_getpid (__NR_Linux + 20) 44 + #define __NR_mount (__NR_Linux + 21) 45 + #define __NR_umount (__NR_Linux + 22) 46 + #define __NR_setuid (__NR_Linux + 23) 47 + #define __NR_getuid (__NR_Linux + 24) 48 + #define __NR_stime (__NR_Linux + 25) 49 + #define __NR_ptrace (__NR_Linux + 26) 50 + #define __NR_alarm (__NR_Linux + 27) 51 + #define __NR_unused28 (__NR_Linux + 28) 52 + #define __NR_pause (__NR_Linux + 29) 53 + #define __NR_utime (__NR_Linux + 30) 54 + #define __NR_stty (__NR_Linux + 31) 55 + #define __NR_gtty (__NR_Linux + 32) 56 + #define __NR_access (__NR_Linux + 33) 57 + #define __NR_nice (__NR_Linux + 34) 58 + #define __NR_ftime (__NR_Linux + 35) 59 + #define __NR_sync (__NR_Linux + 36) 60 + #define __NR_kill (__NR_Linux + 37) 61 + #define __NR_rename (__NR_Linux + 38) 62 + #define __NR_mkdir (__NR_Linux + 39) 63 + #define __NR_rmdir (__NR_Linux + 40) 64 + #define __NR_dup (__NR_Linux + 41) 65 + #define __NR_pipe (__NR_Linux + 42) 66 + #define __NR_times (__NR_Linux + 43) 67 + #define __NR_prof (__NR_Linux + 44) 68 + #define __NR_brk (__NR_Linux + 45) 69 + #define __NR_setgid (__NR_Linux + 46) 70 + #define __NR_getgid (__NR_Linux + 47) 71 + #define __NR_signal (__NR_Linux + 48) 72 + #define __NR_geteuid (__NR_Linux + 49) 73 + #define __NR_getegid (__NR_Linux + 50) 74 + #define __NR_acct (__NR_Linux + 51) 75 + #define __NR_umount2 (__NR_Linux + 52) 76 + #define __NR_lock (__NR_Linux + 53) 77 + #define __NR_ioctl (__NR_Linux + 54) 78 + #define __NR_fcntl (__NR_Linux + 55) 79 + #define __NR_mpx (__NR_Linux + 56) 80 + #define __NR_setpgid (__NR_Linux + 57) 81 + #define __NR_ulimit (__NR_Linux + 58) 82 + #define __NR_unused59 (__NR_Linux + 59) 83 + #define __NR_umask (__NR_Linux + 60) 84 + #define __NR_chroot (__NR_Linux + 61) 85 + #define __NR_ustat (__NR_Linux + 62) 86 + #define __NR_dup2 (__NR_Linux + 63) 87 + #define __NR_getppid (__NR_Linux + 64) 88 + #define __NR_getpgrp (__NR_Linux + 65) 89 + #define __NR_setsid (__NR_Linux + 66) 90 + #define __NR_sigaction (__NR_Linux + 67) 91 + #define __NR_sgetmask (__NR_Linux + 68) 92 + #define __NR_ssetmask (__NR_Linux + 69) 93 + #define __NR_setreuid (__NR_Linux + 70) 94 + #define __NR_setregid (__NR_Linux + 71) 95 + #define __NR_sigsuspend (__NR_Linux + 72) 96 + #define __NR_sigpending (__NR_Linux + 73) 97 + #define __NR_sethostname (__NR_Linux + 74) 98 + #define __NR_setrlimit (__NR_Linux + 75) 99 + #define __NR_getrlimit (__NR_Linux + 76) 100 + #define __NR_getrusage (__NR_Linux + 77) 101 + #define __NR_gettimeofday (__NR_Linux + 78) 102 + #define __NR_settimeofday (__NR_Linux + 79) 103 + #define __NR_getgroups (__NR_Linux + 80) 104 + #define __NR_setgroups (__NR_Linux + 81) 105 + #define __NR_reserved82 (__NR_Linux + 82) 106 + #define __NR_symlink (__NR_Linux + 83) 107 + #define __NR_unused84 (__NR_Linux + 84) 108 + #define __NR_readlink (__NR_Linux + 85) 109 + #define __NR_uselib (__NR_Linux + 86) 110 + #define __NR_swapon (__NR_Linux + 87) 111 + #define __NR_reboot (__NR_Linux + 88) 112 + #define __NR_readdir (__NR_Linux + 89) 113 + #define __NR_mmap (__NR_Linux + 90) 114 + #define __NR_munmap (__NR_Linux + 91) 115 + #define __NR_truncate (__NR_Linux + 92) 116 + #define __NR_ftruncate (__NR_Linux + 93) 117 + #define __NR_fchmod (__NR_Linux + 94) 118 + #define __NR_fchown (__NR_Linux + 95) 119 + #define __NR_getpriority (__NR_Linux + 96) 120 + #define __NR_setpriority (__NR_Linux + 97) 121 + #define __NR_profil (__NR_Linux + 98) 122 + #define __NR_statfs (__NR_Linux + 99) 123 + #define __NR_fstatfs (__NR_Linux + 100) 124 + #define __NR_ioperm (__NR_Linux + 101) 125 + #define __NR_socketcall (__NR_Linux + 102) 126 + #define __NR_syslog (__NR_Linux + 103) 127 + #define __NR_setitimer (__NR_Linux + 104) 128 + #define __NR_getitimer (__NR_Linux + 105) 129 + #define __NR_stat (__NR_Linux + 106) 130 + #define __NR_lstat (__NR_Linux + 107) 131 + #define __NR_fstat (__NR_Linux + 108) 132 + #define __NR_unused109 (__NR_Linux + 109) 133 + #define __NR_iopl (__NR_Linux + 110) 134 + #define __NR_vhangup (__NR_Linux + 111) 135 + #define __NR_idle (__NR_Linux + 112) 136 + #define __NR_vm86 (__NR_Linux + 113) 137 + #define __NR_wait4 (__NR_Linux + 114) 138 + #define __NR_swapoff (__NR_Linux + 115) 139 + #define __NR_sysinfo (__NR_Linux + 116) 140 + #define __NR_ipc (__NR_Linux + 117) 141 + #define __NR_fsync (__NR_Linux + 118) 142 + #define __NR_sigreturn (__NR_Linux + 119) 143 + #define __NR_clone (__NR_Linux + 120) 144 + #define __NR_setdomainname (__NR_Linux + 121) 145 + #define __NR_uname (__NR_Linux + 122) 146 + #define __NR_modify_ldt (__NR_Linux + 123) 147 + #define __NR_adjtimex (__NR_Linux + 124) 148 + #define __NR_mprotect (__NR_Linux + 125) 149 + #define __NR_sigprocmask (__NR_Linux + 126) 150 + #define __NR_create_module (__NR_Linux + 127) 151 + #define __NR_init_module (__NR_Linux + 128) 152 + #define __NR_delete_module (__NR_Linux + 129) 153 + #define __NR_get_kernel_syms (__NR_Linux + 130) 154 + #define __NR_quotactl (__NR_Linux + 131) 155 + #define __NR_getpgid (__NR_Linux + 132) 156 + #define __NR_fchdir (__NR_Linux + 133) 157 + #define __NR_bdflush (__NR_Linux + 134) 158 + #define __NR_sysfs (__NR_Linux + 135) 159 + #define __NR_personality (__NR_Linux + 136) 160 + #define __NR_afs_syscall (__NR_Linux + 137) /* Syscall for Andrew File System */ 161 + #define __NR_setfsuid (__NR_Linux + 138) 162 + #define __NR_setfsgid (__NR_Linux + 139) 163 + #define __NR__llseek (__NR_Linux + 140) 164 + #define __NR_getdents (__NR_Linux + 141) 165 + #define __NR__newselect (__NR_Linux + 142) 166 + #define __NR_flock (__NR_Linux + 143) 167 + #define __NR_msync (__NR_Linux + 144) 168 + #define __NR_readv (__NR_Linux + 145) 169 + #define __NR_writev (__NR_Linux + 146) 170 + #define __NR_cacheflush (__NR_Linux + 147) 171 + #define __NR_cachectl (__NR_Linux + 148) 172 + #define __NR_sysmips (__NR_Linux + 149) 173 + #define __NR_unused150 (__NR_Linux + 150) 174 + #define __NR_getsid (__NR_Linux + 151) 175 + #define __NR_fdatasync (__NR_Linux + 152) 176 + #define __NR__sysctl (__NR_Linux + 153) 177 + #define __NR_mlock (__NR_Linux + 154) 178 + #define __NR_munlock (__NR_Linux + 155) 179 + #define __NR_mlockall (__NR_Linux + 156) 180 + #define __NR_munlockall (__NR_Linux + 157) 181 + #define __NR_sched_setparam (__NR_Linux + 158) 182 + #define __NR_sched_getparam (__NR_Linux + 159) 183 + #define __NR_sched_setscheduler (__NR_Linux + 160) 184 + #define __NR_sched_getscheduler (__NR_Linux + 161) 185 + #define __NR_sched_yield (__NR_Linux + 162) 186 + #define __NR_sched_get_priority_max (__NR_Linux + 163) 187 + #define __NR_sched_get_priority_min (__NR_Linux + 164) 188 + #define __NR_sched_rr_get_interval (__NR_Linux + 165) 189 + #define __NR_nanosleep (__NR_Linux + 166) 190 + #define __NR_mremap (__NR_Linux + 167) 191 + #define __NR_accept (__NR_Linux + 168) 192 + #define __NR_bind (__NR_Linux + 169) 193 + #define __NR_connect (__NR_Linux + 170) 194 + #define __NR_getpeername (__NR_Linux + 171) 195 + #define __NR_getsockname (__NR_Linux + 172) 196 + #define __NR_getsockopt (__NR_Linux + 173) 197 + #define __NR_listen (__NR_Linux + 174) 198 + #define __NR_recv (__NR_Linux + 175) 199 + #define __NR_recvfrom (__NR_Linux + 176) 200 + #define __NR_recvmsg (__NR_Linux + 177) 201 + #define __NR_send (__NR_Linux + 178) 202 + #define __NR_sendmsg (__NR_Linux + 179) 203 + #define __NR_sendto (__NR_Linux + 180) 204 + #define __NR_setsockopt (__NR_Linux + 181) 205 + #define __NR_shutdown (__NR_Linux + 182) 206 + #define __NR_socket (__NR_Linux + 183) 207 + #define __NR_socketpair (__NR_Linux + 184) 208 + #define __NR_setresuid (__NR_Linux + 185) 209 + #define __NR_getresuid (__NR_Linux + 186) 210 + #define __NR_query_module (__NR_Linux + 187) 211 + #define __NR_poll (__NR_Linux + 188) 212 + #define __NR_nfsservctl (__NR_Linux + 189) 213 + #define __NR_setresgid (__NR_Linux + 190) 214 + #define __NR_getresgid (__NR_Linux + 191) 215 + #define __NR_prctl (__NR_Linux + 192) 216 + #define __NR_rt_sigreturn (__NR_Linux + 193) 217 + #define __NR_rt_sigaction (__NR_Linux + 194) 218 + #define __NR_rt_sigprocmask (__NR_Linux + 195) 219 + #define __NR_rt_sigpending (__NR_Linux + 196) 220 + #define __NR_rt_sigtimedwait (__NR_Linux + 197) 221 + #define __NR_rt_sigqueueinfo (__NR_Linux + 198) 222 + #define __NR_rt_sigsuspend (__NR_Linux + 199) 223 + #define __NR_pread64 (__NR_Linux + 200) 224 + #define __NR_pwrite64 (__NR_Linux + 201) 225 + #define __NR_chown (__NR_Linux + 202) 226 + #define __NR_getcwd (__NR_Linux + 203) 227 + #define __NR_capget (__NR_Linux + 204) 228 + #define __NR_capset (__NR_Linux + 205) 229 + #define __NR_sigaltstack (__NR_Linux + 206) 230 + #define __NR_sendfile (__NR_Linux + 207) 231 + #define __NR_getpmsg (__NR_Linux + 208) 232 + #define __NR_putpmsg (__NR_Linux + 209) 233 + #define __NR_mmap2 (__NR_Linux + 210) 234 + #define __NR_truncate64 (__NR_Linux + 211) 235 + #define __NR_ftruncate64 (__NR_Linux + 212) 236 + #define __NR_stat64 (__NR_Linux + 213) 237 + #define __NR_lstat64 (__NR_Linux + 214) 238 + #define __NR_fstat64 (__NR_Linux + 215) 239 + #define __NR_pivot_root (__NR_Linux + 216) 240 + #define __NR_mincore (__NR_Linux + 217) 241 + #define __NR_madvise (__NR_Linux + 218) 242 + #define __NR_getdents64 (__NR_Linux + 219) 243 + #define __NR_fcntl64 (__NR_Linux + 220) 244 + #define __NR_reserved221 (__NR_Linux + 221) 245 + #define __NR_gettid (__NR_Linux + 222) 246 + #define __NR_readahead (__NR_Linux + 223) 247 + #define __NR_setxattr (__NR_Linux + 224) 248 + #define __NR_lsetxattr (__NR_Linux + 225) 249 + #define __NR_fsetxattr (__NR_Linux + 226) 250 + #define __NR_getxattr (__NR_Linux + 227) 251 + #define __NR_lgetxattr (__NR_Linux + 228) 252 + #define __NR_fgetxattr (__NR_Linux + 229) 253 + #define __NR_listxattr (__NR_Linux + 230) 254 + #define __NR_llistxattr (__NR_Linux + 231) 255 + #define __NR_flistxattr (__NR_Linux + 232) 256 + #define __NR_removexattr (__NR_Linux + 233) 257 + #define __NR_lremovexattr (__NR_Linux + 234) 258 + #define __NR_fremovexattr (__NR_Linux + 235) 259 + #define __NR_tkill (__NR_Linux + 236) 260 + #define __NR_sendfile64 (__NR_Linux + 237) 261 + #define __NR_futex (__NR_Linux + 238) 262 + #define __NR_sched_setaffinity (__NR_Linux + 239) 263 + #define __NR_sched_getaffinity (__NR_Linux + 240) 264 + #define __NR_io_setup (__NR_Linux + 241) 265 + #define __NR_io_destroy (__NR_Linux + 242) 266 + #define __NR_io_getevents (__NR_Linux + 243) 267 + #define __NR_io_submit (__NR_Linux + 244) 268 + #define __NR_io_cancel (__NR_Linux + 245) 269 + #define __NR_exit_group (__NR_Linux + 246) 270 + #define __NR_lookup_dcookie (__NR_Linux + 247) 271 + #define __NR_epoll_create (__NR_Linux + 248) 272 + #define __NR_epoll_ctl (__NR_Linux + 249) 273 + #define __NR_epoll_wait (__NR_Linux + 250) 274 + #define __NR_remap_file_pages (__NR_Linux + 251) 275 + #define __NR_set_tid_address (__NR_Linux + 252) 276 + #define __NR_restart_syscall (__NR_Linux + 253) 277 + #define __NR_fadvise64 (__NR_Linux + 254) 278 + #define __NR_statfs64 (__NR_Linux + 255) 279 + #define __NR_fstatfs64 (__NR_Linux + 256) 280 + #define __NR_timer_create (__NR_Linux + 257) 281 + #define __NR_timer_settime (__NR_Linux + 258) 282 + #define __NR_timer_gettime (__NR_Linux + 259) 283 + #define __NR_timer_getoverrun (__NR_Linux + 260) 284 + #define __NR_timer_delete (__NR_Linux + 261) 285 + #define __NR_clock_settime (__NR_Linux + 262) 286 + #define __NR_clock_gettime (__NR_Linux + 263) 287 + #define __NR_clock_getres (__NR_Linux + 264) 288 + #define __NR_clock_nanosleep (__NR_Linux + 265) 289 + #define __NR_tgkill (__NR_Linux + 266) 290 + #define __NR_utimes (__NR_Linux + 267) 291 + #define __NR_mbind (__NR_Linux + 268) 292 + #define __NR_get_mempolicy (__NR_Linux + 269) 293 + #define __NR_set_mempolicy (__NR_Linux + 270) 294 + #define __NR_mq_open (__NR_Linux + 271) 295 + #define __NR_mq_unlink (__NR_Linux + 272) 296 + #define __NR_mq_timedsend (__NR_Linux + 273) 297 + #define __NR_mq_timedreceive (__NR_Linux + 274) 298 + #define __NR_mq_notify (__NR_Linux + 275) 299 + #define __NR_mq_getsetattr (__NR_Linux + 276) 300 + #define __NR_vserver (__NR_Linux + 277) 301 + #define __NR_waitid (__NR_Linux + 278) 302 + /* #define __NR_sys_setaltroot (__NR_Linux + 279) */ 303 + #define __NR_add_key (__NR_Linux + 280) 304 + #define __NR_request_key (__NR_Linux + 281) 305 + #define __NR_keyctl (__NR_Linux + 282) 306 + #define __NR_set_thread_area (__NR_Linux + 283) 307 + #define __NR_inotify_init (__NR_Linux + 284) 308 + #define __NR_inotify_add_watch (__NR_Linux + 285) 309 + #define __NR_inotify_rm_watch (__NR_Linux + 286) 310 + #define __NR_migrate_pages (__NR_Linux + 287) 311 + #define __NR_openat (__NR_Linux + 288) 312 + #define __NR_mkdirat (__NR_Linux + 289) 313 + #define __NR_mknodat (__NR_Linux + 290) 314 + #define __NR_fchownat (__NR_Linux + 291) 315 + #define __NR_futimesat (__NR_Linux + 292) 316 + #define __NR_fstatat64 (__NR_Linux + 293) 317 + #define __NR_unlinkat (__NR_Linux + 294) 318 + #define __NR_renameat (__NR_Linux + 295) 319 + #define __NR_linkat (__NR_Linux + 296) 320 + #define __NR_symlinkat (__NR_Linux + 297) 321 + #define __NR_readlinkat (__NR_Linux + 298) 322 + #define __NR_fchmodat (__NR_Linux + 299) 323 + #define __NR_faccessat (__NR_Linux + 300) 324 + #define __NR_pselect6 (__NR_Linux + 301) 325 + #define __NR_ppoll (__NR_Linux + 302) 326 + #define __NR_unshare (__NR_Linux + 303) 327 + #define __NR_splice (__NR_Linux + 304) 328 + #define __NR_sync_file_range (__NR_Linux + 305) 329 + #define __NR_tee (__NR_Linux + 306) 330 + #define __NR_vmsplice (__NR_Linux + 307) 331 + #define __NR_move_pages (__NR_Linux + 308) 332 + #define __NR_set_robust_list (__NR_Linux + 309) 333 + #define __NR_get_robust_list (__NR_Linux + 310) 334 + #define __NR_kexec_load (__NR_Linux + 311) 335 + #define __NR_getcpu (__NR_Linux + 312) 336 + #define __NR_epoll_pwait (__NR_Linux + 313) 337 + #define __NR_ioprio_set (__NR_Linux + 314) 338 + #define __NR_ioprio_get (__NR_Linux + 315) 339 + #define __NR_utimensat (__NR_Linux + 316) 340 + #define __NR_signalfd (__NR_Linux + 317) 341 + #define __NR_timerfd (__NR_Linux + 318) 342 + #define __NR_eventfd (__NR_Linux + 319) 343 + #define __NR_fallocate (__NR_Linux + 320) 344 + #define __NR_timerfd_create (__NR_Linux + 321) 345 + #define __NR_timerfd_gettime (__NR_Linux + 322) 346 + #define __NR_timerfd_settime (__NR_Linux + 323) 347 + #define __NR_signalfd4 (__NR_Linux + 324) 348 + #define __NR_eventfd2 (__NR_Linux + 325) 349 + #define __NR_epoll_create1 (__NR_Linux + 326) 350 + #define __NR_dup3 (__NR_Linux + 327) 351 + #define __NR_pipe2 (__NR_Linux + 328) 352 + #define __NR_inotify_init1 (__NR_Linux + 329) 353 + #define __NR_preadv (__NR_Linux + 330) 354 + #define __NR_pwritev (__NR_Linux + 331) 355 + #define __NR_rt_tgsigqueueinfo (__NR_Linux + 332) 356 + #define __NR_perf_event_open (__NR_Linux + 333) 357 + #define __NR_accept4 (__NR_Linux + 334) 358 + #define __NR_recvmmsg (__NR_Linux + 335) 359 + #define __NR_fanotify_init (__NR_Linux + 336) 360 + #define __NR_fanotify_mark (__NR_Linux + 337) 361 + #define __NR_prlimit64 (__NR_Linux + 338) 362 + #define __NR_name_to_handle_at (__NR_Linux + 339) 363 + #define __NR_open_by_handle_at (__NR_Linux + 340) 364 + #define __NR_clock_adjtime (__NR_Linux + 341) 365 + #define __NR_syncfs (__NR_Linux + 342) 366 + #define __NR_sendmmsg (__NR_Linux + 343) 367 + #define __NR_setns (__NR_Linux + 344) 368 + #define __NR_process_vm_readv (__NR_Linux + 345) 369 + #define __NR_process_vm_writev (__NR_Linux + 346) 370 + #define __NR_kcmp (__NR_Linux + 347) 371 + #define __NR_finit_module (__NR_Linux + 348) 372 + #define __NR_sched_setattr (__NR_Linux + 349) 373 + #define __NR_sched_getattr (__NR_Linux + 350) 374 + #define __NR_renameat2 (__NR_Linux + 351) 375 + #define __NR_seccomp (__NR_Linux + 352) 376 + #define __NR_getrandom (__NR_Linux + 353) 377 + #define __NR_memfd_create (__NR_Linux + 354) 378 + #define __NR_bpf (__NR_Linux + 355) 379 + #define __NR_execveat (__NR_Linux + 356) 380 + 381 + /* 382 + * Offset of the last Linux o32 flavoured syscall 383 + */ 384 + #define __NR_Linux_syscalls 356 385 + 386 + #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 387 + 388 + #define __NR_O32_Linux 4000 389 + #define __NR_O32_Linux_syscalls 356 390 + 391 + #if _MIPS_SIM == _MIPS_SIM_ABI64 392 + 393 + /* 394 + * Linux 64-bit syscalls are in the range from 5000 to 5999. 395 + */ 396 + #define __NR_Linux 5000 397 + #define __NR_read (__NR_Linux + 0) 398 + #define __NR_write (__NR_Linux + 1) 399 + #define __NR_open (__NR_Linux + 2) 400 + #define __NR_close (__NR_Linux + 3) 401 + #define __NR_stat (__NR_Linux + 4) 402 + #define __NR_fstat (__NR_Linux + 5) 403 + #define __NR_lstat (__NR_Linux + 6) 404 + #define __NR_poll (__NR_Linux + 7) 405 + #define __NR_lseek (__NR_Linux + 8) 406 + #define __NR_mmap (__NR_Linux + 9) 407 + #define __NR_mprotect (__NR_Linux + 10) 408 + #define __NR_munmap (__NR_Linux + 11) 409 + #define __NR_brk (__NR_Linux + 12) 410 + #define __NR_rt_sigaction (__NR_Linux + 13) 411 + #define __NR_rt_sigprocmask (__NR_Linux + 14) 412 + #define __NR_ioctl (__NR_Linux + 15) 413 + #define __NR_pread64 (__NR_Linux + 16) 414 + #define __NR_pwrite64 (__NR_Linux + 17) 415 + #define __NR_readv (__NR_Linux + 18) 416 + #define __NR_writev (__NR_Linux + 19) 417 + #define __NR_access (__NR_Linux + 20) 418 + #define __NR_pipe (__NR_Linux + 21) 419 + #define __NR__newselect (__NR_Linux + 22) 420 + #define __NR_sched_yield (__NR_Linux + 23) 421 + #define __NR_mremap (__NR_Linux + 24) 422 + #define __NR_msync (__NR_Linux + 25) 423 + #define __NR_mincore (__NR_Linux + 26) 424 + #define __NR_madvise (__NR_Linux + 27) 425 + #define __NR_shmget (__NR_Linux + 28) 426 + #define __NR_shmat (__NR_Linux + 29) 427 + #define __NR_shmctl (__NR_Linux + 30) 428 + #define __NR_dup (__NR_Linux + 31) 429 + #define __NR_dup2 (__NR_Linux + 32) 430 + #define __NR_pause (__NR_Linux + 33) 431 + #define __NR_nanosleep (__NR_Linux + 34) 432 + #define __NR_getitimer (__NR_Linux + 35) 433 + #define __NR_setitimer (__NR_Linux + 36) 434 + #define __NR_alarm (__NR_Linux + 37) 435 + #define __NR_getpid (__NR_Linux + 38) 436 + #define __NR_sendfile (__NR_Linux + 39) 437 + #define __NR_socket (__NR_Linux + 40) 438 + #define __NR_connect (__NR_Linux + 41) 439 + #define __NR_accept (__NR_Linux + 42) 440 + #define __NR_sendto (__NR_Linux + 43) 441 + #define __NR_recvfrom (__NR_Linux + 44) 442 + #define __NR_sendmsg (__NR_Linux + 45) 443 + #define __NR_recvmsg (__NR_Linux + 46) 444 + #define __NR_shutdown (__NR_Linux + 47) 445 + #define __NR_bind (__NR_Linux + 48) 446 + #define __NR_listen (__NR_Linux + 49) 447 + #define __NR_getsockname (__NR_Linux + 50) 448 + #define __NR_getpeername (__NR_Linux + 51) 449 + #define __NR_socketpair (__NR_Linux + 52) 450 + #define __NR_setsockopt (__NR_Linux + 53) 451 + #define __NR_getsockopt (__NR_Linux + 54) 452 + #define __NR_clone (__NR_Linux + 55) 453 + #define __NR_fork (__NR_Linux + 56) 454 + #define __NR_execve (__NR_Linux + 57) 455 + #define __NR_exit (__NR_Linux + 58) 456 + #define __NR_wait4 (__NR_Linux + 59) 457 + #define __NR_kill (__NR_Linux + 60) 458 + #define __NR_uname (__NR_Linux + 61) 459 + #define __NR_semget (__NR_Linux + 62) 460 + #define __NR_semop (__NR_Linux + 63) 461 + #define __NR_semctl (__NR_Linux + 64) 462 + #define __NR_shmdt (__NR_Linux + 65) 463 + #define __NR_msgget (__NR_Linux + 66) 464 + #define __NR_msgsnd (__NR_Linux + 67) 465 + #define __NR_msgrcv (__NR_Linux + 68) 466 + #define __NR_msgctl (__NR_Linux + 69) 467 + #define __NR_fcntl (__NR_Linux + 70) 468 + #define __NR_flock (__NR_Linux + 71) 469 + #define __NR_fsync (__NR_Linux + 72) 470 + #define __NR_fdatasync (__NR_Linux + 73) 471 + #define __NR_truncate (__NR_Linux + 74) 472 + #define __NR_ftruncate (__NR_Linux + 75) 473 + #define __NR_getdents (__NR_Linux + 76) 474 + #define __NR_getcwd (__NR_Linux + 77) 475 + #define __NR_chdir (__NR_Linux + 78) 476 + #define __NR_fchdir (__NR_Linux + 79) 477 + #define __NR_rename (__NR_Linux + 80) 478 + #define __NR_mkdir (__NR_Linux + 81) 479 + #define __NR_rmdir (__NR_Linux + 82) 480 + #define __NR_creat (__NR_Linux + 83) 481 + #define __NR_link (__NR_Linux + 84) 482 + #define __NR_unlink (__NR_Linux + 85) 483 + #define __NR_symlink (__NR_Linux + 86) 484 + #define __NR_readlink (__NR_Linux + 87) 485 + #define __NR_chmod (__NR_Linux + 88) 486 + #define __NR_fchmod (__NR_Linux + 89) 487 + #define __NR_chown (__NR_Linux + 90) 488 + #define __NR_fchown (__NR_Linux + 91) 489 + #define __NR_lchown (__NR_Linux + 92) 490 + #define __NR_umask (__NR_Linux + 93) 491 + #define __NR_gettimeofday (__NR_Linux + 94) 492 + #define __NR_getrlimit (__NR_Linux + 95) 493 + #define __NR_getrusage (__NR_Linux + 96) 494 + #define __NR_sysinfo (__NR_Linux + 97) 495 + #define __NR_times (__NR_Linux + 98) 496 + #define __NR_ptrace (__NR_Linux + 99) 497 + #define __NR_getuid (__NR_Linux + 100) 498 + #define __NR_syslog (__NR_Linux + 101) 499 + #define __NR_getgid (__NR_Linux + 102) 500 + #define __NR_setuid (__NR_Linux + 103) 501 + #define __NR_setgid (__NR_Linux + 104) 502 + #define __NR_geteuid (__NR_Linux + 105) 503 + #define __NR_getegid (__NR_Linux + 106) 504 + #define __NR_setpgid (__NR_Linux + 107) 505 + #define __NR_getppid (__NR_Linux + 108) 506 + #define __NR_getpgrp (__NR_Linux + 109) 507 + #define __NR_setsid (__NR_Linux + 110) 508 + #define __NR_setreuid (__NR_Linux + 111) 509 + #define __NR_setregid (__NR_Linux + 112) 510 + #define __NR_getgroups (__NR_Linux + 113) 511 + #define __NR_setgroups (__NR_Linux + 114) 512 + #define __NR_setresuid (__NR_Linux + 115) 513 + #define __NR_getresuid (__NR_Linux + 116) 514 + #define __NR_setresgid (__NR_Linux + 117) 515 + #define __NR_getresgid (__NR_Linux + 118) 516 + #define __NR_getpgid (__NR_Linux + 119) 517 + #define __NR_setfsuid (__NR_Linux + 120) 518 + #define __NR_setfsgid (__NR_Linux + 121) 519 + #define __NR_getsid (__NR_Linux + 122) 520 + #define __NR_capget (__NR_Linux + 123) 521 + #define __NR_capset (__NR_Linux + 124) 522 + #define __NR_rt_sigpending (__NR_Linux + 125) 523 + #define __NR_rt_sigtimedwait (__NR_Linux + 126) 524 + #define __NR_rt_sigqueueinfo (__NR_Linux + 127) 525 + #define __NR_rt_sigsuspend (__NR_Linux + 128) 526 + #define __NR_sigaltstack (__NR_Linux + 129) 527 + #define __NR_utime (__NR_Linux + 130) 528 + #define __NR_mknod (__NR_Linux + 131) 529 + #define __NR_personality (__NR_Linux + 132) 530 + #define __NR_ustat (__NR_Linux + 133) 531 + #define __NR_statfs (__NR_Linux + 134) 532 + #define __NR_fstatfs (__NR_Linux + 135) 533 + #define __NR_sysfs (__NR_Linux + 136) 534 + #define __NR_getpriority (__NR_Linux + 137) 535 + #define __NR_setpriority (__NR_Linux + 138) 536 + #define __NR_sched_setparam (__NR_Linux + 139) 537 + #define __NR_sched_getparam (__NR_Linux + 140) 538 + #define __NR_sched_setscheduler (__NR_Linux + 141) 539 + #define __NR_sched_getscheduler (__NR_Linux + 142) 540 + #define __NR_sched_get_priority_max (__NR_Linux + 143) 541 + #define __NR_sched_get_priority_min (__NR_Linux + 144) 542 + #define __NR_sched_rr_get_interval (__NR_Linux + 145) 543 + #define __NR_mlock (__NR_Linux + 146) 544 + #define __NR_munlock (__NR_Linux + 147) 545 + #define __NR_mlockall (__NR_Linux + 148) 546 + #define __NR_munlockall (__NR_Linux + 149) 547 + #define __NR_vhangup (__NR_Linux + 150) 548 + #define __NR_pivot_root (__NR_Linux + 151) 549 + #define __NR__sysctl (__NR_Linux + 152) 550 + #define __NR_prctl (__NR_Linux + 153) 551 + #define __NR_adjtimex (__NR_Linux + 154) 552 + #define __NR_setrlimit (__NR_Linux + 155) 553 + #define __NR_chroot (__NR_Linux + 156) 554 + #define __NR_sync (__NR_Linux + 157) 555 + #define __NR_acct (__NR_Linux + 158) 556 + #define __NR_settimeofday (__NR_Linux + 159) 557 + #define __NR_mount (__NR_Linux + 160) 558 + #define __NR_umount2 (__NR_Linux + 161) 559 + #define __NR_swapon (__NR_Linux + 162) 560 + #define __NR_swapoff (__NR_Linux + 163) 561 + #define __NR_reboot (__NR_Linux + 164) 562 + #define __NR_sethostname (__NR_Linux + 165) 563 + #define __NR_setdomainname (__NR_Linux + 166) 564 + #define __NR_create_module (__NR_Linux + 167) 565 + #define __NR_init_module (__NR_Linux + 168) 566 + #define __NR_delete_module (__NR_Linux + 169) 567 + #define __NR_get_kernel_syms (__NR_Linux + 170) 568 + #define __NR_query_module (__NR_Linux + 171) 569 + #define __NR_quotactl (__NR_Linux + 172) 570 + #define __NR_nfsservctl (__NR_Linux + 173) 571 + #define __NR_getpmsg (__NR_Linux + 174) 572 + #define __NR_putpmsg (__NR_Linux + 175) 573 + #define __NR_afs_syscall (__NR_Linux + 176) 574 + #define __NR_reserved177 (__NR_Linux + 177) 575 + #define __NR_gettid (__NR_Linux + 178) 576 + #define __NR_readahead (__NR_Linux + 179) 577 + #define __NR_setxattr (__NR_Linux + 180) 578 + #define __NR_lsetxattr (__NR_Linux + 181) 579 + #define __NR_fsetxattr (__NR_Linux + 182) 580 + #define __NR_getxattr (__NR_Linux + 183) 581 + #define __NR_lgetxattr (__NR_Linux + 184) 582 + #define __NR_fgetxattr (__NR_Linux + 185) 583 + #define __NR_listxattr (__NR_Linux + 186) 584 + #define __NR_llistxattr (__NR_Linux + 187) 585 + #define __NR_flistxattr (__NR_Linux + 188) 586 + #define __NR_removexattr (__NR_Linux + 189) 587 + #define __NR_lremovexattr (__NR_Linux + 190) 588 + #define __NR_fremovexattr (__NR_Linux + 191) 589 + #define __NR_tkill (__NR_Linux + 192) 590 + #define __NR_reserved193 (__NR_Linux + 193) 591 + #define __NR_futex (__NR_Linux + 194) 592 + #define __NR_sched_setaffinity (__NR_Linux + 195) 593 + #define __NR_sched_getaffinity (__NR_Linux + 196) 594 + #define __NR_cacheflush (__NR_Linux + 197) 595 + #define __NR_cachectl (__NR_Linux + 198) 596 + #define __NR_sysmips (__NR_Linux + 199) 597 + #define __NR_io_setup (__NR_Linux + 200) 598 + #define __NR_io_destroy (__NR_Linux + 201) 599 + #define __NR_io_getevents (__NR_Linux + 202) 600 + #define __NR_io_submit (__NR_Linux + 203) 601 + #define __NR_io_cancel (__NR_Linux + 204) 602 + #define __NR_exit_group (__NR_Linux + 205) 603 + #define __NR_lookup_dcookie (__NR_Linux + 206) 604 + #define __NR_epoll_create (__NR_Linux + 207) 605 + #define __NR_epoll_ctl (__NR_Linux + 208) 606 + #define __NR_epoll_wait (__NR_Linux + 209) 607 + #define __NR_remap_file_pages (__NR_Linux + 210) 608 + #define __NR_rt_sigreturn (__NR_Linux + 211) 609 + #define __NR_set_tid_address (__NR_Linux + 212) 610 + #define __NR_restart_syscall (__NR_Linux + 213) 611 + #define __NR_semtimedop (__NR_Linux + 214) 612 + #define __NR_fadvise64 (__NR_Linux + 215) 613 + #define __NR_timer_create (__NR_Linux + 216) 614 + #define __NR_timer_settime (__NR_Linux + 217) 615 + #define __NR_timer_gettime (__NR_Linux + 218) 616 + #define __NR_timer_getoverrun (__NR_Linux + 219) 617 + #define __NR_timer_delete (__NR_Linux + 220) 618 + #define __NR_clock_settime (__NR_Linux + 221) 619 + #define __NR_clock_gettime (__NR_Linux + 222) 620 + #define __NR_clock_getres (__NR_Linux + 223) 621 + #define __NR_clock_nanosleep (__NR_Linux + 224) 622 + #define __NR_tgkill (__NR_Linux + 225) 623 + #define __NR_utimes (__NR_Linux + 226) 624 + #define __NR_mbind (__NR_Linux + 227) 625 + #define __NR_get_mempolicy (__NR_Linux + 228) 626 + #define __NR_set_mempolicy (__NR_Linux + 229) 627 + #define __NR_mq_open (__NR_Linux + 230) 628 + #define __NR_mq_unlink (__NR_Linux + 231) 629 + #define __NR_mq_timedsend (__NR_Linux + 232) 630 + #define __NR_mq_timedreceive (__NR_Linux + 233) 631 + #define __NR_mq_notify (__NR_Linux + 234) 632 + #define __NR_mq_getsetattr (__NR_Linux + 235) 633 + #define __NR_vserver (__NR_Linux + 236) 634 + #define __NR_waitid (__NR_Linux + 237) 635 + /* #define __NR_sys_setaltroot (__NR_Linux + 238) */ 636 + #define __NR_add_key (__NR_Linux + 239) 637 + #define __NR_request_key (__NR_Linux + 240) 638 + #define __NR_keyctl (__NR_Linux + 241) 639 + #define __NR_set_thread_area (__NR_Linux + 242) 640 + #define __NR_inotify_init (__NR_Linux + 243) 641 + #define __NR_inotify_add_watch (__NR_Linux + 244) 642 + #define __NR_inotify_rm_watch (__NR_Linux + 245) 643 + #define __NR_migrate_pages (__NR_Linux + 246) 644 + #define __NR_openat (__NR_Linux + 247) 645 + #define __NR_mkdirat (__NR_Linux + 248) 646 + #define __NR_mknodat (__NR_Linux + 249) 647 + #define __NR_fchownat (__NR_Linux + 250) 648 + #define __NR_futimesat (__NR_Linux + 251) 649 + #define __NR_newfstatat (__NR_Linux + 252) 650 + #define __NR_unlinkat (__NR_Linux + 253) 651 + #define __NR_renameat (__NR_Linux + 254) 652 + #define __NR_linkat (__NR_Linux + 255) 653 + #define __NR_symlinkat (__NR_Linux + 256) 654 + #define __NR_readlinkat (__NR_Linux + 257) 655 + #define __NR_fchmodat (__NR_Linux + 258) 656 + #define __NR_faccessat (__NR_Linux + 259) 657 + #define __NR_pselect6 (__NR_Linux + 260) 658 + #define __NR_ppoll (__NR_Linux + 261) 659 + #define __NR_unshare (__NR_Linux + 262) 660 + #define __NR_splice (__NR_Linux + 263) 661 + #define __NR_sync_file_range (__NR_Linux + 264) 662 + #define __NR_tee (__NR_Linux + 265) 663 + #define __NR_vmsplice (__NR_Linux + 266) 664 + #define __NR_move_pages (__NR_Linux + 267) 665 + #define __NR_set_robust_list (__NR_Linux + 268) 666 + #define __NR_get_robust_list (__NR_Linux + 269) 667 + #define __NR_kexec_load (__NR_Linux + 270) 668 + #define __NR_getcpu (__NR_Linux + 271) 669 + #define __NR_epoll_pwait (__NR_Linux + 272) 670 + #define __NR_ioprio_set (__NR_Linux + 273) 671 + #define __NR_ioprio_get (__NR_Linux + 274) 672 + #define __NR_utimensat (__NR_Linux + 275) 673 + #define __NR_signalfd (__NR_Linux + 276) 674 + #define __NR_timerfd (__NR_Linux + 277) 675 + #define __NR_eventfd (__NR_Linux + 278) 676 + #define __NR_fallocate (__NR_Linux + 279) 677 + #define __NR_timerfd_create (__NR_Linux + 280) 678 + #define __NR_timerfd_gettime (__NR_Linux + 281) 679 + #define __NR_timerfd_settime (__NR_Linux + 282) 680 + #define __NR_signalfd4 (__NR_Linux + 283) 681 + #define __NR_eventfd2 (__NR_Linux + 284) 682 + #define __NR_epoll_create1 (__NR_Linux + 285) 683 + #define __NR_dup3 (__NR_Linux + 286) 684 + #define __NR_pipe2 (__NR_Linux + 287) 685 + #define __NR_inotify_init1 (__NR_Linux + 288) 686 + #define __NR_preadv (__NR_Linux + 289) 687 + #define __NR_pwritev (__NR_Linux + 290) 688 + #define __NR_rt_tgsigqueueinfo (__NR_Linux + 291) 689 + #define __NR_perf_event_open (__NR_Linux + 292) 690 + #define __NR_accept4 (__NR_Linux + 293) 691 + #define __NR_recvmmsg (__NR_Linux + 294) 692 + #define __NR_fanotify_init (__NR_Linux + 295) 693 + #define __NR_fanotify_mark (__NR_Linux + 296) 694 + #define __NR_prlimit64 (__NR_Linux + 297) 695 + #define __NR_name_to_handle_at (__NR_Linux + 298) 696 + #define __NR_open_by_handle_at (__NR_Linux + 299) 697 + #define __NR_clock_adjtime (__NR_Linux + 300) 698 + #define __NR_syncfs (__NR_Linux + 301) 699 + #define __NR_sendmmsg (__NR_Linux + 302) 700 + #define __NR_setns (__NR_Linux + 303) 701 + #define __NR_process_vm_readv (__NR_Linux + 304) 702 + #define __NR_process_vm_writev (__NR_Linux + 305) 703 + #define __NR_kcmp (__NR_Linux + 306) 704 + #define __NR_finit_module (__NR_Linux + 307) 705 + #define __NR_getdents64 (__NR_Linux + 308) 706 + #define __NR_sched_setattr (__NR_Linux + 309) 707 + #define __NR_sched_getattr (__NR_Linux + 310) 708 + #define __NR_renameat2 (__NR_Linux + 311) 709 + #define __NR_seccomp (__NR_Linux + 312) 710 + #define __NR_getrandom (__NR_Linux + 313) 711 + #define __NR_memfd_create (__NR_Linux + 314) 712 + #define __NR_bpf (__NR_Linux + 315) 713 + #define __NR_execveat (__NR_Linux + 316) 714 + 715 + /* 716 + * Offset of the last Linux 64-bit flavoured syscall 717 + */ 718 + #define __NR_Linux_syscalls 316 719 + 720 + #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 721 + 722 + #define __NR_64_Linux 5000 723 + #define __NR_64_Linux_syscalls 316 724 + 725 + #if _MIPS_SIM == _MIPS_SIM_NABI32 726 + 727 + /* 728 + * Linux N32 syscalls are in the range from 6000 to 6999. 729 + */ 730 + #define __NR_Linux 6000 731 + #define __NR_read (__NR_Linux + 0) 732 + #define __NR_write (__NR_Linux + 1) 733 + #define __NR_open (__NR_Linux + 2) 734 + #define __NR_close (__NR_Linux + 3) 735 + #define __NR_stat (__NR_Linux + 4) 736 + #define __NR_fstat (__NR_Linux + 5) 737 + #define __NR_lstat (__NR_Linux + 6) 738 + #define __NR_poll (__NR_Linux + 7) 739 + #define __NR_lseek (__NR_Linux + 8) 740 + #define __NR_mmap (__NR_Linux + 9) 741 + #define __NR_mprotect (__NR_Linux + 10) 742 + #define __NR_munmap (__NR_Linux + 11) 743 + #define __NR_brk (__NR_Linux + 12) 744 + #define __NR_rt_sigaction (__NR_Linux + 13) 745 + #define __NR_rt_sigprocmask (__NR_Linux + 14) 746 + #define __NR_ioctl (__NR_Linux + 15) 747 + #define __NR_pread64 (__NR_Linux + 16) 748 + #define __NR_pwrite64 (__NR_Linux + 17) 749 + #define __NR_readv (__NR_Linux + 18) 750 + #define __NR_writev (__NR_Linux + 19) 751 + #define __NR_access (__NR_Linux + 20) 752 + #define __NR_pipe (__NR_Linux + 21) 753 + #define __NR__newselect (__NR_Linux + 22) 754 + #define __NR_sched_yield (__NR_Linux + 23) 755 + #define __NR_mremap (__NR_Linux + 24) 756 + #define __NR_msync (__NR_Linux + 25) 757 + #define __NR_mincore (__NR_Linux + 26) 758 + #define __NR_madvise (__NR_Linux + 27) 759 + #define __NR_shmget (__NR_Linux + 28) 760 + #define __NR_shmat (__NR_Linux + 29) 761 + #define __NR_shmctl (__NR_Linux + 30) 762 + #define __NR_dup (__NR_Linux + 31) 763 + #define __NR_dup2 (__NR_Linux + 32) 764 + #define __NR_pause (__NR_Linux + 33) 765 + #define __NR_nanosleep (__NR_Linux + 34) 766 + #define __NR_getitimer (__NR_Linux + 35) 767 + #define __NR_setitimer (__NR_Linux + 36) 768 + #define __NR_alarm (__NR_Linux + 37) 769 + #define __NR_getpid (__NR_Linux + 38) 770 + #define __NR_sendfile (__NR_Linux + 39) 771 + #define __NR_socket (__NR_Linux + 40) 772 + #define __NR_connect (__NR_Linux + 41) 773 + #define __NR_accept (__NR_Linux + 42) 774 + #define __NR_sendto (__NR_Linux + 43) 775 + #define __NR_recvfrom (__NR_Linux + 44) 776 + #define __NR_sendmsg (__NR_Linux + 45) 777 + #define __NR_recvmsg (__NR_Linux + 46) 778 + #define __NR_shutdown (__NR_Linux + 47) 779 + #define __NR_bind (__NR_Linux + 48) 780 + #define __NR_listen (__NR_Linux + 49) 781 + #define __NR_getsockname (__NR_Linux + 50) 782 + #define __NR_getpeername (__NR_Linux + 51) 783 + #define __NR_socketpair (__NR_Linux + 52) 784 + #define __NR_setsockopt (__NR_Linux + 53) 785 + #define __NR_getsockopt (__NR_Linux + 54) 786 + #define __NR_clone (__NR_Linux + 55) 787 + #define __NR_fork (__NR_Linux + 56) 788 + #define __NR_execve (__NR_Linux + 57) 789 + #define __NR_exit (__NR_Linux + 58) 790 + #define __NR_wait4 (__NR_Linux + 59) 791 + #define __NR_kill (__NR_Linux + 60) 792 + #define __NR_uname (__NR_Linux + 61) 793 + #define __NR_semget (__NR_Linux + 62) 794 + #define __NR_semop (__NR_Linux + 63) 795 + #define __NR_semctl (__NR_Linux + 64) 796 + #define __NR_shmdt (__NR_Linux + 65) 797 + #define __NR_msgget (__NR_Linux + 66) 798 + #define __NR_msgsnd (__NR_Linux + 67) 799 + #define __NR_msgrcv (__NR_Linux + 68) 800 + #define __NR_msgctl (__NR_Linux + 69) 801 + #define __NR_fcntl (__NR_Linux + 70) 802 + #define __NR_flock (__NR_Linux + 71) 803 + #define __NR_fsync (__NR_Linux + 72) 804 + #define __NR_fdatasync (__NR_Linux + 73) 805 + #define __NR_truncate (__NR_Linux + 74) 806 + #define __NR_ftruncate (__NR_Linux + 75) 807 + #define __NR_getdents (__NR_Linux + 76) 808 + #define __NR_getcwd (__NR_Linux + 77) 809 + #define __NR_chdir (__NR_Linux + 78) 810 + #define __NR_fchdir (__NR_Linux + 79) 811 + #define __NR_rename (__NR_Linux + 80) 812 + #define __NR_mkdir (__NR_Linux + 81) 813 + #define __NR_rmdir (__NR_Linux + 82) 814 + #define __NR_creat (__NR_Linux + 83) 815 + #define __NR_link (__NR_Linux + 84) 816 + #define __NR_unlink (__NR_Linux + 85) 817 + #define __NR_symlink (__NR_Linux + 86) 818 + #define __NR_readlink (__NR_Linux + 87) 819 + #define __NR_chmod (__NR_Linux + 88) 820 + #define __NR_fchmod (__NR_Linux + 89) 821 + #define __NR_chown (__NR_Linux + 90) 822 + #define __NR_fchown (__NR_Linux + 91) 823 + #define __NR_lchown (__NR_Linux + 92) 824 + #define __NR_umask (__NR_Linux + 93) 825 + #define __NR_gettimeofday (__NR_Linux + 94) 826 + #define __NR_getrlimit (__NR_Linux + 95) 827 + #define __NR_getrusage (__NR_Linux + 96) 828 + #define __NR_sysinfo (__NR_Linux + 97) 829 + #define __NR_times (__NR_Linux + 98) 830 + #define __NR_ptrace (__NR_Linux + 99) 831 + #define __NR_getuid (__NR_Linux + 100) 832 + #define __NR_syslog (__NR_Linux + 101) 833 + #define __NR_getgid (__NR_Linux + 102) 834 + #define __NR_setuid (__NR_Linux + 103) 835 + #define __NR_setgid (__NR_Linux + 104) 836 + #define __NR_geteuid (__NR_Linux + 105) 837 + #define __NR_getegid (__NR_Linux + 106) 838 + #define __NR_setpgid (__NR_Linux + 107) 839 + #define __NR_getppid (__NR_Linux + 108) 840 + #define __NR_getpgrp (__NR_Linux + 109) 841 + #define __NR_setsid (__NR_Linux + 110) 842 + #define __NR_setreuid (__NR_Linux + 111) 843 + #define __NR_setregid (__NR_Linux + 112) 844 + #define __NR_getgroups (__NR_Linux + 113) 845 + #define __NR_setgroups (__NR_Linux + 114) 846 + #define __NR_setresuid (__NR_Linux + 115) 847 + #define __NR_getresuid (__NR_Linux + 116) 848 + #define __NR_setresgid (__NR_Linux + 117) 849 + #define __NR_getresgid (__NR_Linux + 118) 850 + #define __NR_getpgid (__NR_Linux + 119) 851 + #define __NR_setfsuid (__NR_Linux + 120) 852 + #define __NR_setfsgid (__NR_Linux + 121) 853 + #define __NR_getsid (__NR_Linux + 122) 854 + #define __NR_capget (__NR_Linux + 123) 855 + #define __NR_capset (__NR_Linux + 124) 856 + #define __NR_rt_sigpending (__NR_Linux + 125) 857 + #define __NR_rt_sigtimedwait (__NR_Linux + 126) 858 + #define __NR_rt_sigqueueinfo (__NR_Linux + 127) 859 + #define __NR_rt_sigsuspend (__NR_Linux + 128) 860 + #define __NR_sigaltstack (__NR_Linux + 129) 861 + #define __NR_utime (__NR_Linux + 130) 862 + #define __NR_mknod (__NR_Linux + 131) 863 + #define __NR_personality (__NR_Linux + 132) 864 + #define __NR_ustat (__NR_Linux + 133) 865 + #define __NR_statfs (__NR_Linux + 134) 866 + #define __NR_fstatfs (__NR_Linux + 135) 867 + #define __NR_sysfs (__NR_Linux + 136) 868 + #define __NR_getpriority (__NR_Linux + 137) 869 + #define __NR_setpriority (__NR_Linux + 138) 870 + #define __NR_sched_setparam (__NR_Linux + 139) 871 + #define __NR_sched_getparam (__NR_Linux + 140) 872 + #define __NR_sched_setscheduler (__NR_Linux + 141) 873 + #define __NR_sched_getscheduler (__NR_Linux + 142) 874 + #define __NR_sched_get_priority_max (__NR_Linux + 143) 875 + #define __NR_sched_get_priority_min (__NR_Linux + 144) 876 + #define __NR_sched_rr_get_interval (__NR_Linux + 145) 877 + #define __NR_mlock (__NR_Linux + 146) 878 + #define __NR_munlock (__NR_Linux + 147) 879 + #define __NR_mlockall (__NR_Linux + 148) 880 + #define __NR_munlockall (__NR_Linux + 149) 881 + #define __NR_vhangup (__NR_Linux + 150) 882 + #define __NR_pivot_root (__NR_Linux + 151) 883 + #define __NR__sysctl (__NR_Linux + 152) 884 + #define __NR_prctl (__NR_Linux + 153) 885 + #define __NR_adjtimex (__NR_Linux + 154) 886 + #define __NR_setrlimit (__NR_Linux + 155) 887 + #define __NR_chroot (__NR_Linux + 156) 888 + #define __NR_sync (__NR_Linux + 157) 889 + #define __NR_acct (__NR_Linux + 158) 890 + #define __NR_settimeofday (__NR_Linux + 159) 891 + #define __NR_mount (__NR_Linux + 160) 892 + #define __NR_umount2 (__NR_Linux + 161) 893 + #define __NR_swapon (__NR_Linux + 162) 894 + #define __NR_swapoff (__NR_Linux + 163) 895 + #define __NR_reboot (__NR_Linux + 164) 896 + #define __NR_sethostname (__NR_Linux + 165) 897 + #define __NR_setdomainname (__NR_Linux + 166) 898 + #define __NR_create_module (__NR_Linux + 167) 899 + #define __NR_init_module (__NR_Linux + 168) 900 + #define __NR_delete_module (__NR_Linux + 169) 901 + #define __NR_get_kernel_syms (__NR_Linux + 170) 902 + #define __NR_query_module (__NR_Linux + 171) 903 + #define __NR_quotactl (__NR_Linux + 172) 904 + #define __NR_nfsservctl (__NR_Linux + 173) 905 + #define __NR_getpmsg (__NR_Linux + 174) 906 + #define __NR_putpmsg (__NR_Linux + 175) 907 + #define __NR_afs_syscall (__NR_Linux + 176) 908 + #define __NR_reserved177 (__NR_Linux + 177) 909 + #define __NR_gettid (__NR_Linux + 178) 910 + #define __NR_readahead (__NR_Linux + 179) 911 + #define __NR_setxattr (__NR_Linux + 180) 912 + #define __NR_lsetxattr (__NR_Linux + 181) 913 + #define __NR_fsetxattr (__NR_Linux + 182) 914 + #define __NR_getxattr (__NR_Linux + 183) 915 + #define __NR_lgetxattr (__NR_Linux + 184) 916 + #define __NR_fgetxattr (__NR_Linux + 185) 917 + #define __NR_listxattr (__NR_Linux + 186) 918 + #define __NR_llistxattr (__NR_Linux + 187) 919 + #define __NR_flistxattr (__NR_Linux + 188) 920 + #define __NR_removexattr (__NR_Linux + 189) 921 + #define __NR_lremovexattr (__NR_Linux + 190) 922 + #define __NR_fremovexattr (__NR_Linux + 191) 923 + #define __NR_tkill (__NR_Linux + 192) 924 + #define __NR_reserved193 (__NR_Linux + 193) 925 + #define __NR_futex (__NR_Linux + 194) 926 + #define __NR_sched_setaffinity (__NR_Linux + 195) 927 + #define __NR_sched_getaffinity (__NR_Linux + 196) 928 + #define __NR_cacheflush (__NR_Linux + 197) 929 + #define __NR_cachectl (__NR_Linux + 198) 930 + #define __NR_sysmips (__NR_Linux + 199) 931 + #define __NR_io_setup (__NR_Linux + 200) 932 + #define __NR_io_destroy (__NR_Linux + 201) 933 + #define __NR_io_getevents (__NR_Linux + 202) 934 + #define __NR_io_submit (__NR_Linux + 203) 935 + #define __NR_io_cancel (__NR_Linux + 204) 936 + #define __NR_exit_group (__NR_Linux + 205) 937 + #define __NR_lookup_dcookie (__NR_Linux + 206) 938 + #define __NR_epoll_create (__NR_Linux + 207) 939 + #define __NR_epoll_ctl (__NR_Linux + 208) 940 + #define __NR_epoll_wait (__NR_Linux + 209) 941 + #define __NR_remap_file_pages (__NR_Linux + 210) 942 + #define __NR_rt_sigreturn (__NR_Linux + 211) 943 + #define __NR_fcntl64 (__NR_Linux + 212) 944 + #define __NR_set_tid_address (__NR_Linux + 213) 945 + #define __NR_restart_syscall (__NR_Linux + 214) 946 + #define __NR_semtimedop (__NR_Linux + 215) 947 + #define __NR_fadvise64 (__NR_Linux + 216) 948 + #define __NR_statfs64 (__NR_Linux + 217) 949 + #define __NR_fstatfs64 (__NR_Linux + 218) 950 + #define __NR_sendfile64 (__NR_Linux + 219) 951 + #define __NR_timer_create (__NR_Linux + 220) 952 + #define __NR_timer_settime (__NR_Linux + 221) 953 + #define __NR_timer_gettime (__NR_Linux + 222) 954 + #define __NR_timer_getoverrun (__NR_Linux + 223) 955 + #define __NR_timer_delete (__NR_Linux + 224) 956 + #define __NR_clock_settime (__NR_Linux + 225) 957 + #define __NR_clock_gettime (__NR_Linux + 226) 958 + #define __NR_clock_getres (__NR_Linux + 227) 959 + #define __NR_clock_nanosleep (__NR_Linux + 228) 960 + #define __NR_tgkill (__NR_Linux + 229) 961 + #define __NR_utimes (__NR_Linux + 230) 962 + #define __NR_mbind (__NR_Linux + 231) 963 + #define __NR_get_mempolicy (__NR_Linux + 232) 964 + #define __NR_set_mempolicy (__NR_Linux + 233) 965 + #define __NR_mq_open (__NR_Linux + 234) 966 + #define __NR_mq_unlink (__NR_Linux + 235) 967 + #define __NR_mq_timedsend (__NR_Linux + 236) 968 + #define __NR_mq_timedreceive (__NR_Linux + 237) 969 + #define __NR_mq_notify (__NR_Linux + 238) 970 + #define __NR_mq_getsetattr (__NR_Linux + 239) 971 + #define __NR_vserver (__NR_Linux + 240) 972 + #define __NR_waitid (__NR_Linux + 241) 973 + /* #define __NR_sys_setaltroot (__NR_Linux + 242) */ 974 + #define __NR_add_key (__NR_Linux + 243) 975 + #define __NR_request_key (__NR_Linux + 244) 976 + #define __NR_keyctl (__NR_Linux + 245) 977 + #define __NR_set_thread_area (__NR_Linux + 246) 978 + #define __NR_inotify_init (__NR_Linux + 247) 979 + #define __NR_inotify_add_watch (__NR_Linux + 248) 980 + #define __NR_inotify_rm_watch (__NR_Linux + 249) 981 + #define __NR_migrate_pages (__NR_Linux + 250) 982 + #define __NR_openat (__NR_Linux + 251) 983 + #define __NR_mkdirat (__NR_Linux + 252) 984 + #define __NR_mknodat (__NR_Linux + 253) 985 + #define __NR_fchownat (__NR_Linux + 254) 986 + #define __NR_futimesat (__NR_Linux + 255) 987 + #define __NR_newfstatat (__NR_Linux + 256) 988 + #define __NR_unlinkat (__NR_Linux + 257) 989 + #define __NR_renameat (__NR_Linux + 258) 990 + #define __NR_linkat (__NR_Linux + 259) 991 + #define __NR_symlinkat (__NR_Linux + 260) 992 + #define __NR_readlinkat (__NR_Linux + 261) 993 + #define __NR_fchmodat (__NR_Linux + 262) 994 + #define __NR_faccessat (__NR_Linux + 263) 995 + #define __NR_pselect6 (__NR_Linux + 264) 996 + #define __NR_ppoll (__NR_Linux + 265) 997 + #define __NR_unshare (__NR_Linux + 266) 998 + #define __NR_splice (__NR_Linux + 267) 999 + #define __NR_sync_file_range (__NR_Linux + 268) 1000 + #define __NR_tee (__NR_Linux + 269) 1001 + #define __NR_vmsplice (__NR_Linux + 270) 1002 + #define __NR_move_pages (__NR_Linux + 271) 1003 + #define __NR_set_robust_list (__NR_Linux + 272) 1004 + #define __NR_get_robust_list (__NR_Linux + 273) 1005 + #define __NR_kexec_load (__NR_Linux + 274) 1006 + #define __NR_getcpu (__NR_Linux + 275) 1007 + #define __NR_epoll_pwait (__NR_Linux + 276) 1008 + #define __NR_ioprio_set (__NR_Linux + 277) 1009 + #define __NR_ioprio_get (__NR_Linux + 278) 1010 + #define __NR_utimensat (__NR_Linux + 279) 1011 + #define __NR_signalfd (__NR_Linux + 280) 1012 + #define __NR_timerfd (__NR_Linux + 281) 1013 + #define __NR_eventfd (__NR_Linux + 282) 1014 + #define __NR_fallocate (__NR_Linux + 283) 1015 + #define __NR_timerfd_create (__NR_Linux + 284) 1016 + #define __NR_timerfd_gettime (__NR_Linux + 285) 1017 + #define __NR_timerfd_settime (__NR_Linux + 286) 1018 + #define __NR_signalfd4 (__NR_Linux + 287) 1019 + #define __NR_eventfd2 (__NR_Linux + 288) 1020 + #define __NR_epoll_create1 (__NR_Linux + 289) 1021 + #define __NR_dup3 (__NR_Linux + 290) 1022 + #define __NR_pipe2 (__NR_Linux + 291) 1023 + #define __NR_inotify_init1 (__NR_Linux + 292) 1024 + #define __NR_preadv (__NR_Linux + 293) 1025 + #define __NR_pwritev (__NR_Linux + 294) 1026 + #define __NR_rt_tgsigqueueinfo (__NR_Linux + 295) 1027 + #define __NR_perf_event_open (__NR_Linux + 296) 1028 + #define __NR_accept4 (__NR_Linux + 297) 1029 + #define __NR_recvmmsg (__NR_Linux + 298) 1030 + #define __NR_getdents64 (__NR_Linux + 299) 1031 + #define __NR_fanotify_init (__NR_Linux + 300) 1032 + #define __NR_fanotify_mark (__NR_Linux + 301) 1033 + #define __NR_prlimit64 (__NR_Linux + 302) 1034 + #define __NR_name_to_handle_at (__NR_Linux + 303) 1035 + #define __NR_open_by_handle_at (__NR_Linux + 304) 1036 + #define __NR_clock_adjtime (__NR_Linux + 305) 1037 + #define __NR_syncfs (__NR_Linux + 306) 1038 + #define __NR_sendmmsg (__NR_Linux + 307) 1039 + #define __NR_setns (__NR_Linux + 308) 1040 + #define __NR_process_vm_readv (__NR_Linux + 309) 1041 + #define __NR_process_vm_writev (__NR_Linux + 310) 1042 + #define __NR_kcmp (__NR_Linux + 311) 1043 + #define __NR_finit_module (__NR_Linux + 312) 1044 + #define __NR_sched_setattr (__NR_Linux + 313) 1045 + #define __NR_sched_getattr (__NR_Linux + 314) 1046 + #define __NR_renameat2 (__NR_Linux + 315) 1047 + #define __NR_seccomp (__NR_Linux + 316) 1048 + #define __NR_getrandom (__NR_Linux + 317) 1049 + #define __NR_memfd_create (__NR_Linux + 318) 1050 + #define __NR_bpf (__NR_Linux + 319) 1051 + #define __NR_execveat (__NR_Linux + 320) 1052 + 1053 + /* 1054 + * Offset of the last N32 flavoured syscall 1055 + */ 1056 + #define __NR_Linux_syscalls 320 1057 + 1058 + #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 1059 + 1060 + #define __NR_N32_Linux 6000 1061 + #define __NR_N32_Linux_syscalls 320 1062 + 1063 + #endif /* _ASM_UNISTD_H */
+392
linux-headers/asm-powerpc/unistd.h
··· 1 + /* 2 + * This file contains the system call numbers. 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License 6 + * as published by the Free Software Foundation; either version 7 + * 2 of the License, or (at your option) any later version. 8 + */ 9 + #ifndef _ASM_POWERPC_UNISTD_H_ 10 + #define _ASM_POWERPC_UNISTD_H_ 11 + 12 + 13 + #define __NR_restart_syscall 0 14 + #define __NR_exit 1 15 + #define __NR_fork 2 16 + #define __NR_read 3 17 + #define __NR_write 4 18 + #define __NR_open 5 19 + #define __NR_close 6 20 + #define __NR_waitpid 7 21 + #define __NR_creat 8 22 + #define __NR_link 9 23 + #define __NR_unlink 10 24 + #define __NR_execve 11 25 + #define __NR_chdir 12 26 + #define __NR_time 13 27 + #define __NR_mknod 14 28 + #define __NR_chmod 15 29 + #define __NR_lchown 16 30 + #define __NR_break 17 31 + #define __NR_oldstat 18 32 + #define __NR_lseek 19 33 + #define __NR_getpid 20 34 + #define __NR_mount 21 35 + #define __NR_umount 22 36 + #define __NR_setuid 23 37 + #define __NR_getuid 24 38 + #define __NR_stime 25 39 + #define __NR_ptrace 26 40 + #define __NR_alarm 27 41 + #define __NR_oldfstat 28 42 + #define __NR_pause 29 43 + #define __NR_utime 30 44 + #define __NR_stty 31 45 + #define __NR_gtty 32 46 + #define __NR_access 33 47 + #define __NR_nice 34 48 + #define __NR_ftime 35 49 + #define __NR_sync 36 50 + #define __NR_kill 37 51 + #define __NR_rename 38 52 + #define __NR_mkdir 39 53 + #define __NR_rmdir 40 54 + #define __NR_dup 41 55 + #define __NR_pipe 42 56 + #define __NR_times 43 57 + #define __NR_prof 44 58 + #define __NR_brk 45 59 + #define __NR_setgid 46 60 + #define __NR_getgid 47 61 + #define __NR_signal 48 62 + #define __NR_geteuid 49 63 + #define __NR_getegid 50 64 + #define __NR_acct 51 65 + #define __NR_umount2 52 66 + #define __NR_lock 53 67 + #define __NR_ioctl 54 68 + #define __NR_fcntl 55 69 + #define __NR_mpx 56 70 + #define __NR_setpgid 57 71 + #define __NR_ulimit 58 72 + #define __NR_oldolduname 59 73 + #define __NR_umask 60 74 + #define __NR_chroot 61 75 + #define __NR_ustat 62 76 + #define __NR_dup2 63 77 + #define __NR_getppid 64 78 + #define __NR_getpgrp 65 79 + #define __NR_setsid 66 80 + #define __NR_sigaction 67 81 + #define __NR_sgetmask 68 82 + #define __NR_ssetmask 69 83 + #define __NR_setreuid 70 84 + #define __NR_setregid 71 85 + #define __NR_sigsuspend 72 86 + #define __NR_sigpending 73 87 + #define __NR_sethostname 74 88 + #define __NR_setrlimit 75 89 + #define __NR_getrlimit 76 90 + #define __NR_getrusage 77 91 + #define __NR_gettimeofday 78 92 + #define __NR_settimeofday 79 93 + #define __NR_getgroups 80 94 + #define __NR_setgroups 81 95 + #define __NR_select 82 96 + #define __NR_symlink 83 97 + #define __NR_oldlstat 84 98 + #define __NR_readlink 85 99 + #define __NR_uselib 86 100 + #define __NR_swapon 87 101 + #define __NR_reboot 88 102 + #define __NR_readdir 89 103 + #define __NR_mmap 90 104 + #define __NR_munmap 91 105 + #define __NR_truncate 92 106 + #define __NR_ftruncate 93 107 + #define __NR_fchmod 94 108 + #define __NR_fchown 95 109 + #define __NR_getpriority 96 110 + #define __NR_setpriority 97 111 + #define __NR_profil 98 112 + #define __NR_statfs 99 113 + #define __NR_fstatfs 100 114 + #define __NR_ioperm 101 115 + #define __NR_socketcall 102 116 + #define __NR_syslog 103 117 + #define __NR_setitimer 104 118 + #define __NR_getitimer 105 119 + #define __NR_stat 106 120 + #define __NR_lstat 107 121 + #define __NR_fstat 108 122 + #define __NR_olduname 109 123 + #define __NR_iopl 110 124 + #define __NR_vhangup 111 125 + #define __NR_idle 112 126 + #define __NR_vm86 113 127 + #define __NR_wait4 114 128 + #define __NR_swapoff 115 129 + #define __NR_sysinfo 116 130 + #define __NR_ipc 117 131 + #define __NR_fsync 118 132 + #define __NR_sigreturn 119 133 + #define __NR_clone 120 134 + #define __NR_setdomainname 121 135 + #define __NR_uname 122 136 + #define __NR_modify_ldt 123 137 + #define __NR_adjtimex 124 138 + #define __NR_mprotect 125 139 + #define __NR_sigprocmask 126 140 + #define __NR_create_module 127 141 + #define __NR_init_module 128 142 + #define __NR_delete_module 129 143 + #define __NR_get_kernel_syms 130 144 + #define __NR_quotactl 131 145 + #define __NR_getpgid 132 146 + #define __NR_fchdir 133 147 + #define __NR_bdflush 134 148 + #define __NR_sysfs 135 149 + #define __NR_personality 136 150 + #define __NR_afs_syscall 137 /* Syscall for Andrew File System */ 151 + #define __NR_setfsuid 138 152 + #define __NR_setfsgid 139 153 + #define __NR__llseek 140 154 + #define __NR_getdents 141 155 + #define __NR__newselect 142 156 + #define __NR_flock 143 157 + #define __NR_msync 144 158 + #define __NR_readv 145 159 + #define __NR_writev 146 160 + #define __NR_getsid 147 161 + #define __NR_fdatasync 148 162 + #define __NR__sysctl 149 163 + #define __NR_mlock 150 164 + #define __NR_munlock 151 165 + #define __NR_mlockall 152 166 + #define __NR_munlockall 153 167 + #define __NR_sched_setparam 154 168 + #define __NR_sched_getparam 155 169 + #define __NR_sched_setscheduler 156 170 + #define __NR_sched_getscheduler 157 171 + #define __NR_sched_yield 158 172 + #define __NR_sched_get_priority_max 159 173 + #define __NR_sched_get_priority_min 160 174 + #define __NR_sched_rr_get_interval 161 175 + #define __NR_nanosleep 162 176 + #define __NR_mremap 163 177 + #define __NR_setresuid 164 178 + #define __NR_getresuid 165 179 + #define __NR_query_module 166 180 + #define __NR_poll 167 181 + #define __NR_nfsservctl 168 182 + #define __NR_setresgid 169 183 + #define __NR_getresgid 170 184 + #define __NR_prctl 171 185 + #define __NR_rt_sigreturn 172 186 + #define __NR_rt_sigaction 173 187 + #define __NR_rt_sigprocmask 174 188 + #define __NR_rt_sigpending 175 189 + #define __NR_rt_sigtimedwait 176 190 + #define __NR_rt_sigqueueinfo 177 191 + #define __NR_rt_sigsuspend 178 192 + #define __NR_pread64 179 193 + #define __NR_pwrite64 180 194 + #define __NR_chown 181 195 + #define __NR_getcwd 182 196 + #define __NR_capget 183 197 + #define __NR_capset 184 198 + #define __NR_sigaltstack 185 199 + #define __NR_sendfile 186 200 + #define __NR_getpmsg 187 /* some people actually want streams */ 201 + #define __NR_putpmsg 188 /* some people actually want streams */ 202 + #define __NR_vfork 189 203 + #define __NR_ugetrlimit 190 /* SuS compliant getrlimit */ 204 + #define __NR_readahead 191 205 + #ifndef __powerpc64__ /* these are 32-bit only */ 206 + #define __NR_mmap2 192 207 + #define __NR_truncate64 193 208 + #define __NR_ftruncate64 194 209 + #define __NR_stat64 195 210 + #define __NR_lstat64 196 211 + #define __NR_fstat64 197 212 + #endif 213 + #define __NR_pciconfig_read 198 214 + #define __NR_pciconfig_write 199 215 + #define __NR_pciconfig_iobase 200 216 + #define __NR_multiplexer 201 217 + #define __NR_getdents64 202 218 + #define __NR_pivot_root 203 219 + #ifndef __powerpc64__ 220 + #define __NR_fcntl64 204 221 + #endif 222 + #define __NR_madvise 205 223 + #define __NR_mincore 206 224 + #define __NR_gettid 207 225 + #define __NR_tkill 208 226 + #define __NR_setxattr 209 227 + #define __NR_lsetxattr 210 228 + #define __NR_fsetxattr 211 229 + #define __NR_getxattr 212 230 + #define __NR_lgetxattr 213 231 + #define __NR_fgetxattr 214 232 + #define __NR_listxattr 215 233 + #define __NR_llistxattr 216 234 + #define __NR_flistxattr 217 235 + #define __NR_removexattr 218 236 + #define __NR_lremovexattr 219 237 + #define __NR_fremovexattr 220 238 + #define __NR_futex 221 239 + #define __NR_sched_setaffinity 222 240 + #define __NR_sched_getaffinity 223 241 + /* 224 currently unused */ 242 + #define __NR_tuxcall 225 243 + #ifndef __powerpc64__ 244 + #define __NR_sendfile64 226 245 + #endif 246 + #define __NR_io_setup 227 247 + #define __NR_io_destroy 228 248 + #define __NR_io_getevents 229 249 + #define __NR_io_submit 230 250 + #define __NR_io_cancel 231 251 + #define __NR_set_tid_address 232 252 + #define __NR_fadvise64 233 253 + #define __NR_exit_group 234 254 + #define __NR_lookup_dcookie 235 255 + #define __NR_epoll_create 236 256 + #define __NR_epoll_ctl 237 257 + #define __NR_epoll_wait 238 258 + #define __NR_remap_file_pages 239 259 + #define __NR_timer_create 240 260 + #define __NR_timer_settime 241 261 + #define __NR_timer_gettime 242 262 + #define __NR_timer_getoverrun 243 263 + #define __NR_timer_delete 244 264 + #define __NR_clock_settime 245 265 + #define __NR_clock_gettime 246 266 + #define __NR_clock_getres 247 267 + #define __NR_clock_nanosleep 248 268 + #define __NR_swapcontext 249 269 + #define __NR_tgkill 250 270 + #define __NR_utimes 251 271 + #define __NR_statfs64 252 272 + #define __NR_fstatfs64 253 273 + #ifndef __powerpc64__ 274 + #define __NR_fadvise64_64 254 275 + #endif 276 + #define __NR_rtas 255 277 + #define __NR_sys_debug_setcontext 256 278 + /* Number 257 is reserved for vserver */ 279 + #define __NR_migrate_pages 258 280 + #define __NR_mbind 259 281 + #define __NR_get_mempolicy 260 282 + #define __NR_set_mempolicy 261 283 + #define __NR_mq_open 262 284 + #define __NR_mq_unlink 263 285 + #define __NR_mq_timedsend 264 286 + #define __NR_mq_timedreceive 265 287 + #define __NR_mq_notify 266 288 + #define __NR_mq_getsetattr 267 289 + #define __NR_kexec_load 268 290 + #define __NR_add_key 269 291 + #define __NR_request_key 270 292 + #define __NR_keyctl 271 293 + #define __NR_waitid 272 294 + #define __NR_ioprio_set 273 295 + #define __NR_ioprio_get 274 296 + #define __NR_inotify_init 275 297 + #define __NR_inotify_add_watch 276 298 + #define __NR_inotify_rm_watch 277 299 + #define __NR_spu_run 278 300 + #define __NR_spu_create 279 301 + #define __NR_pselect6 280 302 + #define __NR_ppoll 281 303 + #define __NR_unshare 282 304 + #define __NR_splice 283 305 + #define __NR_tee 284 306 + #define __NR_vmsplice 285 307 + #define __NR_openat 286 308 + #define __NR_mkdirat 287 309 + #define __NR_mknodat 288 310 + #define __NR_fchownat 289 311 + #define __NR_futimesat 290 312 + #ifdef __powerpc64__ 313 + #define __NR_newfstatat 291 314 + #else 315 + #define __NR_fstatat64 291 316 + #endif 317 + #define __NR_unlinkat 292 318 + #define __NR_renameat 293 319 + #define __NR_linkat 294 320 + #define __NR_symlinkat 295 321 + #define __NR_readlinkat 296 322 + #define __NR_fchmodat 297 323 + #define __NR_faccessat 298 324 + #define __NR_get_robust_list 299 325 + #define __NR_set_robust_list 300 326 + #define __NR_move_pages 301 327 + #define __NR_getcpu 302 328 + #define __NR_epoll_pwait 303 329 + #define __NR_utimensat 304 330 + #define __NR_signalfd 305 331 + #define __NR_timerfd_create 306 332 + #define __NR_eventfd 307 333 + #define __NR_sync_file_range2 308 334 + #define __NR_fallocate 309 335 + #define __NR_subpage_prot 310 336 + #define __NR_timerfd_settime 311 337 + #define __NR_timerfd_gettime 312 338 + #define __NR_signalfd4 313 339 + #define __NR_eventfd2 314 340 + #define __NR_epoll_create1 315 341 + #define __NR_dup3 316 342 + #define __NR_pipe2 317 343 + #define __NR_inotify_init1 318 344 + #define __NR_perf_event_open 319 345 + #define __NR_preadv 320 346 + #define __NR_pwritev 321 347 + #define __NR_rt_tgsigqueueinfo 322 348 + #define __NR_fanotify_init 323 349 + #define __NR_fanotify_mark 324 350 + #define __NR_prlimit64 325 351 + #define __NR_socket 326 352 + #define __NR_bind 327 353 + #define __NR_connect 328 354 + #define __NR_listen 329 355 + #define __NR_accept 330 356 + #define __NR_getsockname 331 357 + #define __NR_getpeername 332 358 + #define __NR_socketpair 333 359 + #define __NR_send 334 360 + #define __NR_sendto 335 361 + #define __NR_recv 336 362 + #define __NR_recvfrom 337 363 + #define __NR_shutdown 338 364 + #define __NR_setsockopt 339 365 + #define __NR_getsockopt 340 366 + #define __NR_sendmsg 341 367 + #define __NR_recvmsg 342 368 + #define __NR_recvmmsg 343 369 + #define __NR_accept4 344 370 + #define __NR_name_to_handle_at 345 371 + #define __NR_open_by_handle_at 346 372 + #define __NR_clock_adjtime 347 373 + #define __NR_syncfs 348 374 + #define __NR_sendmmsg 349 375 + #define __NR_setns 350 376 + #define __NR_process_vm_readv 351 377 + #define __NR_process_vm_writev 352 378 + #define __NR_finit_module 353 379 + #define __NR_kcmp 354 380 + #define __NR_sched_setattr 355 381 + #define __NR_sched_getattr 356 382 + #define __NR_renameat2 357 383 + #define __NR_seccomp 358 384 + #define __NR_getrandom 359 385 + #define __NR_memfd_create 360 386 + #define __NR_bpf 361 387 + #define __NR_execveat 362 388 + #define __NR_switch_endian 363 389 + #define __NR_userfaultfd 364 390 + #define __NR_membarrier 365 391 + 392 + #endif /* _ASM_POWERPC_UNISTD_H_ */
+404
linux-headers/asm-s390/unistd.h
··· 1 + /* 2 + * S390 version 3 + * 4 + * Derived from "include/asm-i386/unistd.h" 5 + */ 6 + 7 + #ifndef _ASM_S390_UNISTD_H_ 8 + #define _ASM_S390_UNISTD_H_ 9 + 10 + /* 11 + * This file contains the system call numbers. 12 + */ 13 + 14 + #define __NR_exit 1 15 + #define __NR_fork 2 16 + #define __NR_read 3 17 + #define __NR_write 4 18 + #define __NR_open 5 19 + #define __NR_close 6 20 + #define __NR_restart_syscall 7 21 + #define __NR_creat 8 22 + #define __NR_link 9 23 + #define __NR_unlink 10 24 + #define __NR_execve 11 25 + #define __NR_chdir 12 26 + #define __NR_mknod 14 27 + #define __NR_chmod 15 28 + #define __NR_lseek 19 29 + #define __NR_getpid 20 30 + #define __NR_mount 21 31 + #define __NR_umount 22 32 + #define __NR_ptrace 26 33 + #define __NR_alarm 27 34 + #define __NR_pause 29 35 + #define __NR_utime 30 36 + #define __NR_access 33 37 + #define __NR_nice 34 38 + #define __NR_sync 36 39 + #define __NR_kill 37 40 + #define __NR_rename 38 41 + #define __NR_mkdir 39 42 + #define __NR_rmdir 40 43 + #define __NR_dup 41 44 + #define __NR_pipe 42 45 + #define __NR_times 43 46 + #define __NR_brk 45 47 + #define __NR_signal 48 48 + #define __NR_acct 51 49 + #define __NR_umount2 52 50 + #define __NR_ioctl 54 51 + #define __NR_fcntl 55 52 + #define __NR_setpgid 57 53 + #define __NR_umask 60 54 + #define __NR_chroot 61 55 + #define __NR_ustat 62 56 + #define __NR_dup2 63 57 + #define __NR_getppid 64 58 + #define __NR_getpgrp 65 59 + #define __NR_setsid 66 60 + #define __NR_sigaction 67 61 + #define __NR_sigsuspend 72 62 + #define __NR_sigpending 73 63 + #define __NR_sethostname 74 64 + #define __NR_setrlimit 75 65 + #define __NR_getrusage 77 66 + #define __NR_gettimeofday 78 67 + #define __NR_settimeofday 79 68 + #define __NR_symlink 83 69 + #define __NR_readlink 85 70 + #define __NR_uselib 86 71 + #define __NR_swapon 87 72 + #define __NR_reboot 88 73 + #define __NR_readdir 89 74 + #define __NR_mmap 90 75 + #define __NR_munmap 91 76 + #define __NR_truncate 92 77 + #define __NR_ftruncate 93 78 + #define __NR_fchmod 94 79 + #define __NR_getpriority 96 80 + #define __NR_setpriority 97 81 + #define __NR_statfs 99 82 + #define __NR_fstatfs 100 83 + #define __NR_socketcall 102 84 + #define __NR_syslog 103 85 + #define __NR_setitimer 104 86 + #define __NR_getitimer 105 87 + #define __NR_stat 106 88 + #define __NR_lstat 107 89 + #define __NR_fstat 108 90 + #define __NR_lookup_dcookie 110 91 + #define __NR_vhangup 111 92 + #define __NR_idle 112 93 + #define __NR_wait4 114 94 + #define __NR_swapoff 115 95 + #define __NR_sysinfo 116 96 + #define __NR_ipc 117 97 + #define __NR_fsync 118 98 + #define __NR_sigreturn 119 99 + #define __NR_clone 120 100 + #define __NR_setdomainname 121 101 + #define __NR_uname 122 102 + #define __NR_adjtimex 124 103 + #define __NR_mprotect 125 104 + #define __NR_sigprocmask 126 105 + #define __NR_create_module 127 106 + #define __NR_init_module 128 107 + #define __NR_delete_module 129 108 + #define __NR_get_kernel_syms 130 109 + #define __NR_quotactl 131 110 + #define __NR_getpgid 132 111 + #define __NR_fchdir 133 112 + #define __NR_bdflush 134 113 + #define __NR_sysfs 135 114 + #define __NR_personality 136 115 + #define __NR_afs_syscall 137 /* Syscall for Andrew File System */ 116 + #define __NR_getdents 141 117 + #define __NR_flock 143 118 + #define __NR_msync 144 119 + #define __NR_readv 145 120 + #define __NR_writev 146 121 + #define __NR_getsid 147 122 + #define __NR_fdatasync 148 123 + #define __NR__sysctl 149 124 + #define __NR_mlock 150 125 + #define __NR_munlock 151 126 + #define __NR_mlockall 152 127 + #define __NR_munlockall 153 128 + #define __NR_sched_setparam 154 129 + #define __NR_sched_getparam 155 130 + #define __NR_sched_setscheduler 156 131 + #define __NR_sched_getscheduler 157 132 + #define __NR_sched_yield 158 133 + #define __NR_sched_get_priority_max 159 134 + #define __NR_sched_get_priority_min 160 135 + #define __NR_sched_rr_get_interval 161 136 + #define __NR_nanosleep 162 137 + #define __NR_mremap 163 138 + #define __NR_query_module 167 139 + #define __NR_poll 168 140 + #define __NR_nfsservctl 169 141 + #define __NR_prctl 172 142 + #define __NR_rt_sigreturn 173 143 + #define __NR_rt_sigaction 174 144 + #define __NR_rt_sigprocmask 175 145 + #define __NR_rt_sigpending 176 146 + #define __NR_rt_sigtimedwait 177 147 + #define __NR_rt_sigqueueinfo 178 148 + #define __NR_rt_sigsuspend 179 149 + #define __NR_pread64 180 150 + #define __NR_pwrite64 181 151 + #define __NR_getcwd 183 152 + #define __NR_capget 184 153 + #define __NR_capset 185 154 + #define __NR_sigaltstack 186 155 + #define __NR_sendfile 187 156 + #define __NR_getpmsg 188 157 + #define __NR_putpmsg 189 158 + #define __NR_vfork 190 159 + #define __NR_pivot_root 217 160 + #define __NR_mincore 218 161 + #define __NR_madvise 219 162 + #define __NR_getdents64 220 163 + #define __NR_readahead 222 164 + #define __NR_setxattr 224 165 + #define __NR_lsetxattr 225 166 + #define __NR_fsetxattr 226 167 + #define __NR_getxattr 227 168 + #define __NR_lgetxattr 228 169 + #define __NR_fgetxattr 229 170 + #define __NR_listxattr 230 171 + #define __NR_llistxattr 231 172 + #define __NR_flistxattr 232 173 + #define __NR_removexattr 233 174 + #define __NR_lremovexattr 234 175 + #define __NR_fremovexattr 235 176 + #define __NR_gettid 236 177 + #define __NR_tkill 237 178 + #define __NR_futex 238 179 + #define __NR_sched_setaffinity 239 180 + #define __NR_sched_getaffinity 240 181 + #define __NR_tgkill 241 182 + /* Number 242 is reserved for tux */ 183 + #define __NR_io_setup 243 184 + #define __NR_io_destroy 244 185 + #define __NR_io_getevents 245 186 + #define __NR_io_submit 246 187 + #define __NR_io_cancel 247 188 + #define __NR_exit_group 248 189 + #define __NR_epoll_create 249 190 + #define __NR_epoll_ctl 250 191 + #define __NR_epoll_wait 251 192 + #define __NR_set_tid_address 252 193 + #define __NR_fadvise64 253 194 + #define __NR_timer_create 254 195 + #define __NR_timer_settime (__NR_timer_create+1) 196 + #define __NR_timer_gettime (__NR_timer_create+2) 197 + #define __NR_timer_getoverrun (__NR_timer_create+3) 198 + #define __NR_timer_delete (__NR_timer_create+4) 199 + #define __NR_clock_settime (__NR_timer_create+5) 200 + #define __NR_clock_gettime (__NR_timer_create+6) 201 + #define __NR_clock_getres (__NR_timer_create+7) 202 + #define __NR_clock_nanosleep (__NR_timer_create+8) 203 + /* Number 263 is reserved for vserver */ 204 + #define __NR_statfs64 265 205 + #define __NR_fstatfs64 266 206 + #define __NR_remap_file_pages 267 207 + #define __NR_mbind 268 208 + #define __NR_get_mempolicy 269 209 + #define __NR_set_mempolicy 270 210 + #define __NR_mq_open 271 211 + #define __NR_mq_unlink 272 212 + #define __NR_mq_timedsend 273 213 + #define __NR_mq_timedreceive 274 214 + #define __NR_mq_notify 275 215 + #define __NR_mq_getsetattr 276 216 + #define __NR_kexec_load 277 217 + #define __NR_add_key 278 218 + #define __NR_request_key 279 219 + #define __NR_keyctl 280 220 + #define __NR_waitid 281 221 + #define __NR_ioprio_set 282 222 + #define __NR_ioprio_get 283 223 + #define __NR_inotify_init 284 224 + #define __NR_inotify_add_watch 285 225 + #define __NR_inotify_rm_watch 286 226 + #define __NR_migrate_pages 287 227 + #define __NR_openat 288 228 + #define __NR_mkdirat 289 229 + #define __NR_mknodat 290 230 + #define __NR_fchownat 291 231 + #define __NR_futimesat 292 232 + #define __NR_unlinkat 294 233 + #define __NR_renameat 295 234 + #define __NR_linkat 296 235 + #define __NR_symlinkat 297 236 + #define __NR_readlinkat 298 237 + #define __NR_fchmodat 299 238 + #define __NR_faccessat 300 239 + #define __NR_pselect6 301 240 + #define __NR_ppoll 302 241 + #define __NR_unshare 303 242 + #define __NR_set_robust_list 304 243 + #define __NR_get_robust_list 305 244 + #define __NR_splice 306 245 + #define __NR_sync_file_range 307 246 + #define __NR_tee 308 247 + #define __NR_vmsplice 309 248 + #define __NR_move_pages 310 249 + #define __NR_getcpu 311 250 + #define __NR_epoll_pwait 312 251 + #define __NR_utimes 313 252 + #define __NR_fallocate 314 253 + #define __NR_utimensat 315 254 + #define __NR_signalfd 316 255 + #define __NR_timerfd 317 256 + #define __NR_eventfd 318 257 + #define __NR_timerfd_create 319 258 + #define __NR_timerfd_settime 320 259 + #define __NR_timerfd_gettime 321 260 + #define __NR_signalfd4 322 261 + #define __NR_eventfd2 323 262 + #define __NR_inotify_init1 324 263 + #define __NR_pipe2 325 264 + #define __NR_dup3 326 265 + #define __NR_epoll_create1 327 266 + #define __NR_preadv 328 267 + #define __NR_pwritev 329 268 + #define __NR_rt_tgsigqueueinfo 330 269 + #define __NR_perf_event_open 331 270 + #define __NR_fanotify_init 332 271 + #define __NR_fanotify_mark 333 272 + #define __NR_prlimit64 334 273 + #define __NR_name_to_handle_at 335 274 + #define __NR_open_by_handle_at 336 275 + #define __NR_clock_adjtime 337 276 + #define __NR_syncfs 338 277 + #define __NR_setns 339 278 + #define __NR_process_vm_readv 340 279 + #define __NR_process_vm_writev 341 280 + #define __NR_s390_runtime_instr 342 281 + #define __NR_kcmp 343 282 + #define __NR_finit_module 344 283 + #define __NR_sched_setattr 345 284 + #define __NR_sched_getattr 346 285 + #define __NR_renameat2 347 286 + #define __NR_seccomp 348 287 + #define __NR_getrandom 349 288 + #define __NR_memfd_create 350 289 + #define __NR_bpf 351 290 + #define __NR_s390_pci_mmio_write 352 291 + #define __NR_s390_pci_mmio_read 353 292 + #define __NR_execveat 354 293 + #define __NR_userfaultfd 355 294 + #define __NR_membarrier 356 295 + #define __NR_recvmmsg 357 296 + #define __NR_sendmmsg 358 297 + #define __NR_socket 359 298 + #define __NR_socketpair 360 299 + #define __NR_bind 361 300 + #define __NR_connect 362 301 + #define __NR_listen 363 302 + #define __NR_accept4 364 303 + #define __NR_getsockopt 365 304 + #define __NR_setsockopt 366 305 + #define __NR_getsockname 367 306 + #define __NR_getpeername 368 307 + #define __NR_sendto 369 308 + #define __NR_sendmsg 370 309 + #define __NR_recvfrom 371 310 + #define __NR_recvmsg 372 311 + #define __NR_shutdown 373 312 + #define NR_syscalls 374 313 + 314 + /* 315 + * There are some system calls that are not present on 64 bit, some 316 + * have a different name although they do the same (e.g. __NR_chown32 317 + * is __NR_chown on 64 bit). 318 + */ 319 + #ifndef __s390x__ 320 + 321 + #define __NR_time 13 322 + #define __NR_lchown 16 323 + #define __NR_setuid 23 324 + #define __NR_getuid 24 325 + #define __NR_stime 25 326 + #define __NR_setgid 46 327 + #define __NR_getgid 47 328 + #define __NR_geteuid 49 329 + #define __NR_getegid 50 330 + #define __NR_setreuid 70 331 + #define __NR_setregid 71 332 + #define __NR_getrlimit 76 333 + #define __NR_getgroups 80 334 + #define __NR_setgroups 81 335 + #define __NR_fchown 95 336 + #define __NR_ioperm 101 337 + #define __NR_setfsuid 138 338 + #define __NR_setfsgid 139 339 + #define __NR__llseek 140 340 + #define __NR__newselect 142 341 + #define __NR_setresuid 164 342 + #define __NR_getresuid 165 343 + #define __NR_setresgid 170 344 + #define __NR_getresgid 171 345 + #define __NR_chown 182 346 + #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ 347 + #define __NR_mmap2 192 348 + #define __NR_truncate64 193 349 + #define __NR_ftruncate64 194 350 + #define __NR_stat64 195 351 + #define __NR_lstat64 196 352 + #define __NR_fstat64 197 353 + #define __NR_lchown32 198 354 + #define __NR_getuid32 199 355 + #define __NR_getgid32 200 356 + #define __NR_geteuid32 201 357 + #define __NR_getegid32 202 358 + #define __NR_setreuid32 203 359 + #define __NR_setregid32 204 360 + #define __NR_getgroups32 205 361 + #define __NR_setgroups32 206 362 + #define __NR_fchown32 207 363 + #define __NR_setresuid32 208 364 + #define __NR_getresuid32 209 365 + #define __NR_setresgid32 210 366 + #define __NR_getresgid32 211 367 + #define __NR_chown32 212 368 + #define __NR_setuid32 213 369 + #define __NR_setgid32 214 370 + #define __NR_setfsuid32 215 371 + #define __NR_setfsgid32 216 372 + #define __NR_fcntl64 221 373 + #define __NR_sendfile64 223 374 + #define __NR_fadvise64_64 264 375 + #define __NR_fstatat64 293 376 + 377 + #else 378 + 379 + #define __NR_select 142 380 + #define __NR_getrlimit 191 /* SuS compliant getrlimit */ 381 + #define __NR_lchown 198 382 + #define __NR_getuid 199 383 + #define __NR_getgid 200 384 + #define __NR_geteuid 201 385 + #define __NR_getegid 202 386 + #define __NR_setreuid 203 387 + #define __NR_setregid 204 388 + #define __NR_getgroups 205 389 + #define __NR_setgroups 206 390 + #define __NR_fchown 207 391 + #define __NR_setresuid 208 392 + #define __NR_getresuid 209 393 + #define __NR_setresgid 210 394 + #define __NR_getresgid 211 395 + #define __NR_chown 212 396 + #define __NR_setuid 213 397 + #define __NR_setgid 214 398 + #define __NR_setfsuid 215 399 + #define __NR_setfsgid 216 400 + #define __NR_newfstatat 293 401 + 402 + #endif 403 + 404 + #endif /* _ASM_S390_UNISTD_H_ */
+15
linux-headers/asm-x86/unistd.h
··· 1 + #ifndef _ASM_X86_UNISTD_H 2 + #define _ASM_X86_UNISTD_H 3 + 4 + /* x32 syscall flag bit */ 5 + #define __X32_SYSCALL_BIT 0x40000000 6 + 7 + # ifdef __i386__ 8 + # include <asm/unistd_32.h> 9 + # elif defined(__ILP32__) 10 + # include <asm/unistd_x32.h> 11 + # else 12 + # include <asm/unistd_64.h> 13 + # endif 14 + 15 + #endif /* _ASM_X86_UNISTD_H */
+377
linux-headers/asm-x86/unistd_32.h
··· 1 + #ifndef _ASM_X86_UNISTD_32_H 2 + #define _ASM_X86_UNISTD_32_H 1 3 + 4 + #define __NR_restart_syscall 0 5 + #define __NR_exit 1 6 + #define __NR_fork 2 7 + #define __NR_read 3 8 + #define __NR_write 4 9 + #define __NR_open 5 10 + #define __NR_close 6 11 + #define __NR_waitpid 7 12 + #define __NR_creat 8 13 + #define __NR_link 9 14 + #define __NR_unlink 10 15 + #define __NR_execve 11 16 + #define __NR_chdir 12 17 + #define __NR_time 13 18 + #define __NR_mknod 14 19 + #define __NR_chmod 15 20 + #define __NR_lchown 16 21 + #define __NR_break 17 22 + #define __NR_oldstat 18 23 + #define __NR_lseek 19 24 + #define __NR_getpid 20 25 + #define __NR_mount 21 26 + #define __NR_umount 22 27 + #define __NR_setuid 23 28 + #define __NR_getuid 24 29 + #define __NR_stime 25 30 + #define __NR_ptrace 26 31 + #define __NR_alarm 27 32 + #define __NR_oldfstat 28 33 + #define __NR_pause 29 34 + #define __NR_utime 30 35 + #define __NR_stty 31 36 + #define __NR_gtty 32 37 + #define __NR_access 33 38 + #define __NR_nice 34 39 + #define __NR_ftime 35 40 + #define __NR_sync 36 41 + #define __NR_kill 37 42 + #define __NR_rename 38 43 + #define __NR_mkdir 39 44 + #define __NR_rmdir 40 45 + #define __NR_dup 41 46 + #define __NR_pipe 42 47 + #define __NR_times 43 48 + #define __NR_prof 44 49 + #define __NR_brk 45 50 + #define __NR_setgid 46 51 + #define __NR_getgid 47 52 + #define __NR_signal 48 53 + #define __NR_geteuid 49 54 + #define __NR_getegid 50 55 + #define __NR_acct 51 56 + #define __NR_umount2 52 57 + #define __NR_lock 53 58 + #define __NR_ioctl 54 59 + #define __NR_fcntl 55 60 + #define __NR_mpx 56 61 + #define __NR_setpgid 57 62 + #define __NR_ulimit 58 63 + #define __NR_oldolduname 59 64 + #define __NR_umask 60 65 + #define __NR_chroot 61 66 + #define __NR_ustat 62 67 + #define __NR_dup2 63 68 + #define __NR_getppid 64 69 + #define __NR_getpgrp 65 70 + #define __NR_setsid 66 71 + #define __NR_sigaction 67 72 + #define __NR_sgetmask 68 73 + #define __NR_ssetmask 69 74 + #define __NR_setreuid 70 75 + #define __NR_setregid 71 76 + #define __NR_sigsuspend 72 77 + #define __NR_sigpending 73 78 + #define __NR_sethostname 74 79 + #define __NR_setrlimit 75 80 + #define __NR_getrlimit 76 81 + #define __NR_getrusage 77 82 + #define __NR_gettimeofday 78 83 + #define __NR_settimeofday 79 84 + #define __NR_getgroups 80 85 + #define __NR_setgroups 81 86 + #define __NR_select 82 87 + #define __NR_symlink 83 88 + #define __NR_oldlstat 84 89 + #define __NR_readlink 85 90 + #define __NR_uselib 86 91 + #define __NR_swapon 87 92 + #define __NR_reboot 88 93 + #define __NR_readdir 89 94 + #define __NR_mmap 90 95 + #define __NR_munmap 91 96 + #define __NR_truncate 92 97 + #define __NR_ftruncate 93 98 + #define __NR_fchmod 94 99 + #define __NR_fchown 95 100 + #define __NR_getpriority 96 101 + #define __NR_setpriority 97 102 + #define __NR_profil 98 103 + #define __NR_statfs 99 104 + #define __NR_fstatfs 100 105 + #define __NR_ioperm 101 106 + #define __NR_socketcall 102 107 + #define __NR_syslog 103 108 + #define __NR_setitimer 104 109 + #define __NR_getitimer 105 110 + #define __NR_stat 106 111 + #define __NR_lstat 107 112 + #define __NR_fstat 108 113 + #define __NR_olduname 109 114 + #define __NR_iopl 110 115 + #define __NR_vhangup 111 116 + #define __NR_idle 112 117 + #define __NR_vm86old 113 118 + #define __NR_wait4 114 119 + #define __NR_swapoff 115 120 + #define __NR_sysinfo 116 121 + #define __NR_ipc 117 122 + #define __NR_fsync 118 123 + #define __NR_sigreturn 119 124 + #define __NR_clone 120 125 + #define __NR_setdomainname 121 126 + #define __NR_uname 122 127 + #define __NR_modify_ldt 123 128 + #define __NR_adjtimex 124 129 + #define __NR_mprotect 125 130 + #define __NR_sigprocmask 126 131 + #define __NR_create_module 127 132 + #define __NR_init_module 128 133 + #define __NR_delete_module 129 134 + #define __NR_get_kernel_syms 130 135 + #define __NR_quotactl 131 136 + #define __NR_getpgid 132 137 + #define __NR_fchdir 133 138 + #define __NR_bdflush 134 139 + #define __NR_sysfs 135 140 + #define __NR_personality 136 141 + #define __NR_afs_syscall 137 142 + #define __NR_setfsuid 138 143 + #define __NR_setfsgid 139 144 + #define __NR__llseek 140 145 + #define __NR_getdents 141 146 + #define __NR__newselect 142 147 + #define __NR_flock 143 148 + #define __NR_msync 144 149 + #define __NR_readv 145 150 + #define __NR_writev 146 151 + #define __NR_getsid 147 152 + #define __NR_fdatasync 148 153 + #define __NR__sysctl 149 154 + #define __NR_mlock 150 155 + #define __NR_munlock 151 156 + #define __NR_mlockall 152 157 + #define __NR_munlockall 153 158 + #define __NR_sched_setparam 154 159 + #define __NR_sched_getparam 155 160 + #define __NR_sched_setscheduler 156 161 + #define __NR_sched_getscheduler 157 162 + #define __NR_sched_yield 158 163 + #define __NR_sched_get_priority_max 159 164 + #define __NR_sched_get_priority_min 160 165 + #define __NR_sched_rr_get_interval 161 166 + #define __NR_nanosleep 162 167 + #define __NR_mremap 163 168 + #define __NR_setresuid 164 169 + #define __NR_getresuid 165 170 + #define __NR_vm86 166 171 + #define __NR_query_module 167 172 + #define __NR_poll 168 173 + #define __NR_nfsservctl 169 174 + #define __NR_setresgid 170 175 + #define __NR_getresgid 171 176 + #define __NR_prctl 172 177 + #define __NR_rt_sigreturn 173 178 + #define __NR_rt_sigaction 174 179 + #define __NR_rt_sigprocmask 175 180 + #define __NR_rt_sigpending 176 181 + #define __NR_rt_sigtimedwait 177 182 + #define __NR_rt_sigqueueinfo 178 183 + #define __NR_rt_sigsuspend 179 184 + #define __NR_pread64 180 185 + #define __NR_pwrite64 181 186 + #define __NR_chown 182 187 + #define __NR_getcwd 183 188 + #define __NR_capget 184 189 + #define __NR_capset 185 190 + #define __NR_sigaltstack 186 191 + #define __NR_sendfile 187 192 + #define __NR_getpmsg 188 193 + #define __NR_putpmsg 189 194 + #define __NR_vfork 190 195 + #define __NR_ugetrlimit 191 196 + #define __NR_mmap2 192 197 + #define __NR_truncate64 193 198 + #define __NR_ftruncate64 194 199 + #define __NR_stat64 195 200 + #define __NR_lstat64 196 201 + #define __NR_fstat64 197 202 + #define __NR_lchown32 198 203 + #define __NR_getuid32 199 204 + #define __NR_getgid32 200 205 + #define __NR_geteuid32 201 206 + #define __NR_getegid32 202 207 + #define __NR_setreuid32 203 208 + #define __NR_setregid32 204 209 + #define __NR_getgroups32 205 210 + #define __NR_setgroups32 206 211 + #define __NR_fchown32 207 212 + #define __NR_setresuid32 208 213 + #define __NR_getresuid32 209 214 + #define __NR_setresgid32 210 215 + #define __NR_getresgid32 211 216 + #define __NR_chown32 212 217 + #define __NR_setuid32 213 218 + #define __NR_setgid32 214 219 + #define __NR_setfsuid32 215 220 + #define __NR_setfsgid32 216 221 + #define __NR_pivot_root 217 222 + #define __NR_mincore 218 223 + #define __NR_madvise 219 224 + #define __NR_getdents64 220 225 + #define __NR_fcntl64 221 226 + #define __NR_gettid 224 227 + #define __NR_readahead 225 228 + #define __NR_setxattr 226 229 + #define __NR_lsetxattr 227 230 + #define __NR_fsetxattr 228 231 + #define __NR_getxattr 229 232 + #define __NR_lgetxattr 230 233 + #define __NR_fgetxattr 231 234 + #define __NR_listxattr 232 235 + #define __NR_llistxattr 233 236 + #define __NR_flistxattr 234 237 + #define __NR_removexattr 235 238 + #define __NR_lremovexattr 236 239 + #define __NR_fremovexattr 237 240 + #define __NR_tkill 238 241 + #define __NR_sendfile64 239 242 + #define __NR_futex 240 243 + #define __NR_sched_setaffinity 241 244 + #define __NR_sched_getaffinity 242 245 + #define __NR_set_thread_area 243 246 + #define __NR_get_thread_area 244 247 + #define __NR_io_setup 245 248 + #define __NR_io_destroy 246 249 + #define __NR_io_getevents 247 250 + #define __NR_io_submit 248 251 + #define __NR_io_cancel 249 252 + #define __NR_fadvise64 250 253 + #define __NR_exit_group 252 254 + #define __NR_lookup_dcookie 253 255 + #define __NR_epoll_create 254 256 + #define __NR_epoll_ctl 255 257 + #define __NR_epoll_wait 256 258 + #define __NR_remap_file_pages 257 259 + #define __NR_set_tid_address 258 260 + #define __NR_timer_create 259 261 + #define __NR_timer_settime 260 262 + #define __NR_timer_gettime 261 263 + #define __NR_timer_getoverrun 262 264 + #define __NR_timer_delete 263 265 + #define __NR_clock_settime 264 266 + #define __NR_clock_gettime 265 267 + #define __NR_clock_getres 266 268 + #define __NR_clock_nanosleep 267 269 + #define __NR_statfs64 268 270 + #define __NR_fstatfs64 269 271 + #define __NR_tgkill 270 272 + #define __NR_utimes 271 273 + #define __NR_fadvise64_64 272 274 + #define __NR_vserver 273 275 + #define __NR_mbind 274 276 + #define __NR_get_mempolicy 275 277 + #define __NR_set_mempolicy 276 278 + #define __NR_mq_open 277 279 + #define __NR_mq_unlink 278 280 + #define __NR_mq_timedsend 279 281 + #define __NR_mq_timedreceive 280 282 + #define __NR_mq_notify 281 283 + #define __NR_mq_getsetattr 282 284 + #define __NR_kexec_load 283 285 + #define __NR_waitid 284 286 + #define __NR_add_key 286 287 + #define __NR_request_key 287 288 + #define __NR_keyctl 288 289 + #define __NR_ioprio_set 289 290 + #define __NR_ioprio_get 290 291 + #define __NR_inotify_init 291 292 + #define __NR_inotify_add_watch 292 293 + #define __NR_inotify_rm_watch 293 294 + #define __NR_migrate_pages 294 295 + #define __NR_openat 295 296 + #define __NR_mkdirat 296 297 + #define __NR_mknodat 297 298 + #define __NR_fchownat 298 299 + #define __NR_futimesat 299 300 + #define __NR_fstatat64 300 301 + #define __NR_unlinkat 301 302 + #define __NR_renameat 302 303 + #define __NR_linkat 303 304 + #define __NR_symlinkat 304 305 + #define __NR_readlinkat 305 306 + #define __NR_fchmodat 306 307 + #define __NR_faccessat 307 308 + #define __NR_pselect6 308 309 + #define __NR_ppoll 309 310 + #define __NR_unshare 310 311 + #define __NR_set_robust_list 311 312 + #define __NR_get_robust_list 312 313 + #define __NR_splice 313 314 + #define __NR_sync_file_range 314 315 + #define __NR_tee 315 316 + #define __NR_vmsplice 316 317 + #define __NR_move_pages 317 318 + #define __NR_getcpu 318 319 + #define __NR_epoll_pwait 319 320 + #define __NR_utimensat 320 321 + #define __NR_signalfd 321 322 + #define __NR_timerfd_create 322 323 + #define __NR_eventfd 323 324 + #define __NR_fallocate 324 325 + #define __NR_timerfd_settime 325 326 + #define __NR_timerfd_gettime 326 327 + #define __NR_signalfd4 327 328 + #define __NR_eventfd2 328 329 + #define __NR_epoll_create1 329 330 + #define __NR_dup3 330 331 + #define __NR_pipe2 331 332 + #define __NR_inotify_init1 332 333 + #define __NR_preadv 333 334 + #define __NR_pwritev 334 335 + #define __NR_rt_tgsigqueueinfo 335 336 + #define __NR_perf_event_open 336 337 + #define __NR_recvmmsg 337 338 + #define __NR_fanotify_init 338 339 + #define __NR_fanotify_mark 339 340 + #define __NR_prlimit64 340 341 + #define __NR_name_to_handle_at 341 342 + #define __NR_open_by_handle_at 342 343 + #define __NR_clock_adjtime 343 344 + #define __NR_syncfs 344 345 + #define __NR_sendmmsg 345 346 + #define __NR_setns 346 347 + #define __NR_process_vm_readv 347 348 + #define __NR_process_vm_writev 348 349 + #define __NR_kcmp 349 350 + #define __NR_finit_module 350 351 + #define __NR_sched_setattr 351 352 + #define __NR_sched_getattr 352 353 + #define __NR_renameat2 353 354 + #define __NR_seccomp 354 355 + #define __NR_getrandom 355 356 + #define __NR_memfd_create 356 357 + #define __NR_bpf 357 358 + #define __NR_execveat 358 359 + #define __NR_socket 359 360 + #define __NR_socketpair 360 361 + #define __NR_bind 361 362 + #define __NR_connect 362 363 + #define __NR_listen 363 364 + #define __NR_accept4 364 365 + #define __NR_getsockopt 365 366 + #define __NR_setsockopt 366 367 + #define __NR_getsockname 367 368 + #define __NR_getpeername 368 369 + #define __NR_sendto 369 370 + #define __NR_sendmsg 370 371 + #define __NR_recvfrom 371 372 + #define __NR_recvmsg 372 373 + #define __NR_shutdown 373 374 + #define __NR_userfaultfd 374 375 + #define __NR_membarrier 375 376 + 377 + #endif /* _ASM_X86_UNISTD_32_H */
+330
linux-headers/asm-x86/unistd_64.h
··· 1 + #ifndef _ASM_X86_UNISTD_64_H 2 + #define _ASM_X86_UNISTD_64_H 1 3 + 4 + #define __NR_read 0 5 + #define __NR_write 1 6 + #define __NR_open 2 7 + #define __NR_close 3 8 + #define __NR_stat 4 9 + #define __NR_fstat 5 10 + #define __NR_lstat 6 11 + #define __NR_poll 7 12 + #define __NR_lseek 8 13 + #define __NR_mmap 9 14 + #define __NR_mprotect 10 15 + #define __NR_munmap 11 16 + #define __NR_brk 12 17 + #define __NR_rt_sigaction 13 18 + #define __NR_rt_sigprocmask 14 19 + #define __NR_rt_sigreturn 15 20 + #define __NR_ioctl 16 21 + #define __NR_pread64 17 22 + #define __NR_pwrite64 18 23 + #define __NR_readv 19 24 + #define __NR_writev 20 25 + #define __NR_access 21 26 + #define __NR_pipe 22 27 + #define __NR_select 23 28 + #define __NR_sched_yield 24 29 + #define __NR_mremap 25 30 + #define __NR_msync 26 31 + #define __NR_mincore 27 32 + #define __NR_madvise 28 33 + #define __NR_shmget 29 34 + #define __NR_shmat 30 35 + #define __NR_shmctl 31 36 + #define __NR_dup 32 37 + #define __NR_dup2 33 38 + #define __NR_pause 34 39 + #define __NR_nanosleep 35 40 + #define __NR_getitimer 36 41 + #define __NR_alarm 37 42 + #define __NR_setitimer 38 43 + #define __NR_getpid 39 44 + #define __NR_sendfile 40 45 + #define __NR_socket 41 46 + #define __NR_connect 42 47 + #define __NR_accept 43 48 + #define __NR_sendto 44 49 + #define __NR_recvfrom 45 50 + #define __NR_sendmsg 46 51 + #define __NR_recvmsg 47 52 + #define __NR_shutdown 48 53 + #define __NR_bind 49 54 + #define __NR_listen 50 55 + #define __NR_getsockname 51 56 + #define __NR_getpeername 52 57 + #define __NR_socketpair 53 58 + #define __NR_setsockopt 54 59 + #define __NR_getsockopt 55 60 + #define __NR_clone 56 61 + #define __NR_fork 57 62 + #define __NR_vfork 58 63 + #define __NR_execve 59 64 + #define __NR_exit 60 65 + #define __NR_wait4 61 66 + #define __NR_kill 62 67 + #define __NR_uname 63 68 + #define __NR_semget 64 69 + #define __NR_semop 65 70 + #define __NR_semctl 66 71 + #define __NR_shmdt 67 72 + #define __NR_msgget 68 73 + #define __NR_msgsnd 69 74 + #define __NR_msgrcv 70 75 + #define __NR_msgctl 71 76 + #define __NR_fcntl 72 77 + #define __NR_flock 73 78 + #define __NR_fsync 74 79 + #define __NR_fdatasync 75 80 + #define __NR_truncate 76 81 + #define __NR_ftruncate 77 82 + #define __NR_getdents 78 83 + #define __NR_getcwd 79 84 + #define __NR_chdir 80 85 + #define __NR_fchdir 81 86 + #define __NR_rename 82 87 + #define __NR_mkdir 83 88 + #define __NR_rmdir 84 89 + #define __NR_creat 85 90 + #define __NR_link 86 91 + #define __NR_unlink 87 92 + #define __NR_symlink 88 93 + #define __NR_readlink 89 94 + #define __NR_chmod 90 95 + #define __NR_fchmod 91 96 + #define __NR_chown 92 97 + #define __NR_fchown 93 98 + #define __NR_lchown 94 99 + #define __NR_umask 95 100 + #define __NR_gettimeofday 96 101 + #define __NR_getrlimit 97 102 + #define __NR_getrusage 98 103 + #define __NR_sysinfo 99 104 + #define __NR_times 100 105 + #define __NR_ptrace 101 106 + #define __NR_getuid 102 107 + #define __NR_syslog 103 108 + #define __NR_getgid 104 109 + #define __NR_setuid 105 110 + #define __NR_setgid 106 111 + #define __NR_geteuid 107 112 + #define __NR_getegid 108 113 + #define __NR_setpgid 109 114 + #define __NR_getppid 110 115 + #define __NR_getpgrp 111 116 + #define __NR_setsid 112 117 + #define __NR_setreuid 113 118 + #define __NR_setregid 114 119 + #define __NR_getgroups 115 120 + #define __NR_setgroups 116 121 + #define __NR_setresuid 117 122 + #define __NR_getresuid 118 123 + #define __NR_setresgid 119 124 + #define __NR_getresgid 120 125 + #define __NR_getpgid 121 126 + #define __NR_setfsuid 122 127 + #define __NR_setfsgid 123 128 + #define __NR_getsid 124 129 + #define __NR_capget 125 130 + #define __NR_capset 126 131 + #define __NR_rt_sigpending 127 132 + #define __NR_rt_sigtimedwait 128 133 + #define __NR_rt_sigqueueinfo 129 134 + #define __NR_rt_sigsuspend 130 135 + #define __NR_sigaltstack 131 136 + #define __NR_utime 132 137 + #define __NR_mknod 133 138 + #define __NR_uselib 134 139 + #define __NR_personality 135 140 + #define __NR_ustat 136 141 + #define __NR_statfs 137 142 + #define __NR_fstatfs 138 143 + #define __NR_sysfs 139 144 + #define __NR_getpriority 140 145 + #define __NR_setpriority 141 146 + #define __NR_sched_setparam 142 147 + #define __NR_sched_getparam 143 148 + #define __NR_sched_setscheduler 144 149 + #define __NR_sched_getscheduler 145 150 + #define __NR_sched_get_priority_max 146 151 + #define __NR_sched_get_priority_min 147 152 + #define __NR_sched_rr_get_interval 148 153 + #define __NR_mlock 149 154 + #define __NR_munlock 150 155 + #define __NR_mlockall 151 156 + #define __NR_munlockall 152 157 + #define __NR_vhangup 153 158 + #define __NR_modify_ldt 154 159 + #define __NR_pivot_root 155 160 + #define __NR__sysctl 156 161 + #define __NR_prctl 157 162 + #define __NR_arch_prctl 158 163 + #define __NR_adjtimex 159 164 + #define __NR_setrlimit 160 165 + #define __NR_chroot 161 166 + #define __NR_sync 162 167 + #define __NR_acct 163 168 + #define __NR_settimeofday 164 169 + #define __NR_mount 165 170 + #define __NR_umount2 166 171 + #define __NR_swapon 167 172 + #define __NR_swapoff 168 173 + #define __NR_reboot 169 174 + #define __NR_sethostname 170 175 + #define __NR_setdomainname 171 176 + #define __NR_iopl 172 177 + #define __NR_ioperm 173 178 + #define __NR_create_module 174 179 + #define __NR_init_module 175 180 + #define __NR_delete_module 176 181 + #define __NR_get_kernel_syms 177 182 + #define __NR_query_module 178 183 + #define __NR_quotactl 179 184 + #define __NR_nfsservctl 180 185 + #define __NR_getpmsg 181 186 + #define __NR_putpmsg 182 187 + #define __NR_afs_syscall 183 188 + #define __NR_tuxcall 184 189 + #define __NR_security 185 190 + #define __NR_gettid 186 191 + #define __NR_readahead 187 192 + #define __NR_setxattr 188 193 + #define __NR_lsetxattr 189 194 + #define __NR_fsetxattr 190 195 + #define __NR_getxattr 191 196 + #define __NR_lgetxattr 192 197 + #define __NR_fgetxattr 193 198 + #define __NR_listxattr 194 199 + #define __NR_llistxattr 195 200 + #define __NR_flistxattr 196 201 + #define __NR_removexattr 197 202 + #define __NR_lremovexattr 198 203 + #define __NR_fremovexattr 199 204 + #define __NR_tkill 200 205 + #define __NR_time 201 206 + #define __NR_futex 202 207 + #define __NR_sched_setaffinity 203 208 + #define __NR_sched_getaffinity 204 209 + #define __NR_set_thread_area 205 210 + #define __NR_io_setup 206 211 + #define __NR_io_destroy 207 212 + #define __NR_io_getevents 208 213 + #define __NR_io_submit 209 214 + #define __NR_io_cancel 210 215 + #define __NR_get_thread_area 211 216 + #define __NR_lookup_dcookie 212 217 + #define __NR_epoll_create 213 218 + #define __NR_epoll_ctl_old 214 219 + #define __NR_epoll_wait_old 215 220 + #define __NR_remap_file_pages 216 221 + #define __NR_getdents64 217 222 + #define __NR_set_tid_address 218 223 + #define __NR_restart_syscall 219 224 + #define __NR_semtimedop 220 225 + #define __NR_fadvise64 221 226 + #define __NR_timer_create 222 227 + #define __NR_timer_settime 223 228 + #define __NR_timer_gettime 224 229 + #define __NR_timer_getoverrun 225 230 + #define __NR_timer_delete 226 231 + #define __NR_clock_settime 227 232 + #define __NR_clock_gettime 228 233 + #define __NR_clock_getres 229 234 + #define __NR_clock_nanosleep 230 235 + #define __NR_exit_group 231 236 + #define __NR_epoll_wait 232 237 + #define __NR_epoll_ctl 233 238 + #define __NR_tgkill 234 239 + #define __NR_utimes 235 240 + #define __NR_vserver 236 241 + #define __NR_mbind 237 242 + #define __NR_set_mempolicy 238 243 + #define __NR_get_mempolicy 239 244 + #define __NR_mq_open 240 245 + #define __NR_mq_unlink 241 246 + #define __NR_mq_timedsend 242 247 + #define __NR_mq_timedreceive 243 248 + #define __NR_mq_notify 244 249 + #define __NR_mq_getsetattr 245 250 + #define __NR_kexec_load 246 251 + #define __NR_waitid 247 252 + #define __NR_add_key 248 253 + #define __NR_request_key 249 254 + #define __NR_keyctl 250 255 + #define __NR_ioprio_set 251 256 + #define __NR_ioprio_get 252 257 + #define __NR_inotify_init 253 258 + #define __NR_inotify_add_watch 254 259 + #define __NR_inotify_rm_watch 255 260 + #define __NR_migrate_pages 256 261 + #define __NR_openat 257 262 + #define __NR_mkdirat 258 263 + #define __NR_mknodat 259 264 + #define __NR_fchownat 260 265 + #define __NR_futimesat 261 266 + #define __NR_newfstatat 262 267 + #define __NR_unlinkat 263 268 + #define __NR_renameat 264 269 + #define __NR_linkat 265 270 + #define __NR_symlinkat 266 271 + #define __NR_readlinkat 267 272 + #define __NR_fchmodat 268 273 + #define __NR_faccessat 269 274 + #define __NR_pselect6 270 275 + #define __NR_ppoll 271 276 + #define __NR_unshare 272 277 + #define __NR_set_robust_list 273 278 + #define __NR_get_robust_list 274 279 + #define __NR_splice 275 280 + #define __NR_tee 276 281 + #define __NR_sync_file_range 277 282 + #define __NR_vmsplice 278 283 + #define __NR_move_pages 279 284 + #define __NR_utimensat 280 285 + #define __NR_epoll_pwait 281 286 + #define __NR_signalfd 282 287 + #define __NR_timerfd_create 283 288 + #define __NR_eventfd 284 289 + #define __NR_fallocate 285 290 + #define __NR_timerfd_settime 286 291 + #define __NR_timerfd_gettime 287 292 + #define __NR_accept4 288 293 + #define __NR_signalfd4 289 294 + #define __NR_eventfd2 290 295 + #define __NR_epoll_create1 291 296 + #define __NR_dup3 292 297 + #define __NR_pipe2 293 298 + #define __NR_inotify_init1 294 299 + #define __NR_preadv 295 300 + #define __NR_pwritev 296 301 + #define __NR_rt_tgsigqueueinfo 297 302 + #define __NR_perf_event_open 298 303 + #define __NR_recvmmsg 299 304 + #define __NR_fanotify_init 300 305 + #define __NR_fanotify_mark 301 306 + #define __NR_prlimit64 302 307 + #define __NR_name_to_handle_at 303 308 + #define __NR_open_by_handle_at 304 309 + #define __NR_clock_adjtime 305 310 + #define __NR_syncfs 306 311 + #define __NR_sendmmsg 307 312 + #define __NR_setns 308 313 + #define __NR_getcpu 309 314 + #define __NR_process_vm_readv 310 315 + #define __NR_process_vm_writev 311 316 + #define __NR_kcmp 312 317 + #define __NR_finit_module 313 318 + #define __NR_sched_setattr 314 319 + #define __NR_sched_getattr 315 320 + #define __NR_renameat2 316 321 + #define __NR_seccomp 317 322 + #define __NR_getrandom 318 323 + #define __NR_memfd_create 319 324 + #define __NR_kexec_file_load 320 325 + #define __NR_bpf 321 326 + #define __NR_execveat 322 327 + #define __NR_userfaultfd 323 328 + #define __NR_membarrier 324 329 + 330 + #endif /* _ASM_X86_UNISTD_64_H */
+319
linux-headers/asm-x86/unistd_x32.h
··· 1 + #ifndef _ASM_X86_UNISTD_X32_H 2 + #define _ASM_X86_UNISTD_X32_H 1 3 + 4 + #define __NR_read (__X32_SYSCALL_BIT + 0) 5 + #define __NR_write (__X32_SYSCALL_BIT + 1) 6 + #define __NR_open (__X32_SYSCALL_BIT + 2) 7 + #define __NR_close (__X32_SYSCALL_BIT + 3) 8 + #define __NR_stat (__X32_SYSCALL_BIT + 4) 9 + #define __NR_fstat (__X32_SYSCALL_BIT + 5) 10 + #define __NR_lstat (__X32_SYSCALL_BIT + 6) 11 + #define __NR_poll (__X32_SYSCALL_BIT + 7) 12 + #define __NR_lseek (__X32_SYSCALL_BIT + 8) 13 + #define __NR_mmap (__X32_SYSCALL_BIT + 9) 14 + #define __NR_mprotect (__X32_SYSCALL_BIT + 10) 15 + #define __NR_munmap (__X32_SYSCALL_BIT + 11) 16 + #define __NR_brk (__X32_SYSCALL_BIT + 12) 17 + #define __NR_rt_sigprocmask (__X32_SYSCALL_BIT + 14) 18 + #define __NR_pread64 (__X32_SYSCALL_BIT + 17) 19 + #define __NR_pwrite64 (__X32_SYSCALL_BIT + 18) 20 + #define __NR_access (__X32_SYSCALL_BIT + 21) 21 + #define __NR_pipe (__X32_SYSCALL_BIT + 22) 22 + #define __NR_select (__X32_SYSCALL_BIT + 23) 23 + #define __NR_sched_yield (__X32_SYSCALL_BIT + 24) 24 + #define __NR_mremap (__X32_SYSCALL_BIT + 25) 25 + #define __NR_msync (__X32_SYSCALL_BIT + 26) 26 + #define __NR_mincore (__X32_SYSCALL_BIT + 27) 27 + #define __NR_madvise (__X32_SYSCALL_BIT + 28) 28 + #define __NR_shmget (__X32_SYSCALL_BIT + 29) 29 + #define __NR_shmat (__X32_SYSCALL_BIT + 30) 30 + #define __NR_shmctl (__X32_SYSCALL_BIT + 31) 31 + #define __NR_dup (__X32_SYSCALL_BIT + 32) 32 + #define __NR_dup2 (__X32_SYSCALL_BIT + 33) 33 + #define __NR_pause (__X32_SYSCALL_BIT + 34) 34 + #define __NR_nanosleep (__X32_SYSCALL_BIT + 35) 35 + #define __NR_getitimer (__X32_SYSCALL_BIT + 36) 36 + #define __NR_alarm (__X32_SYSCALL_BIT + 37) 37 + #define __NR_setitimer (__X32_SYSCALL_BIT + 38) 38 + #define __NR_getpid (__X32_SYSCALL_BIT + 39) 39 + #define __NR_sendfile (__X32_SYSCALL_BIT + 40) 40 + #define __NR_socket (__X32_SYSCALL_BIT + 41) 41 + #define __NR_connect (__X32_SYSCALL_BIT + 42) 42 + #define __NR_accept (__X32_SYSCALL_BIT + 43) 43 + #define __NR_sendto (__X32_SYSCALL_BIT + 44) 44 + #define __NR_shutdown (__X32_SYSCALL_BIT + 48) 45 + #define __NR_bind (__X32_SYSCALL_BIT + 49) 46 + #define __NR_listen (__X32_SYSCALL_BIT + 50) 47 + #define __NR_getsockname (__X32_SYSCALL_BIT + 51) 48 + #define __NR_getpeername (__X32_SYSCALL_BIT + 52) 49 + #define __NR_socketpair (__X32_SYSCALL_BIT + 53) 50 + #define __NR_clone (__X32_SYSCALL_BIT + 56) 51 + #define __NR_fork (__X32_SYSCALL_BIT + 57) 52 + #define __NR_vfork (__X32_SYSCALL_BIT + 58) 53 + #define __NR_exit (__X32_SYSCALL_BIT + 60) 54 + #define __NR_wait4 (__X32_SYSCALL_BIT + 61) 55 + #define __NR_kill (__X32_SYSCALL_BIT + 62) 56 + #define __NR_uname (__X32_SYSCALL_BIT + 63) 57 + #define __NR_semget (__X32_SYSCALL_BIT + 64) 58 + #define __NR_semop (__X32_SYSCALL_BIT + 65) 59 + #define __NR_semctl (__X32_SYSCALL_BIT + 66) 60 + #define __NR_shmdt (__X32_SYSCALL_BIT + 67) 61 + #define __NR_msgget (__X32_SYSCALL_BIT + 68) 62 + #define __NR_msgsnd (__X32_SYSCALL_BIT + 69) 63 + #define __NR_msgrcv (__X32_SYSCALL_BIT + 70) 64 + #define __NR_msgctl (__X32_SYSCALL_BIT + 71) 65 + #define __NR_fcntl (__X32_SYSCALL_BIT + 72) 66 + #define __NR_flock (__X32_SYSCALL_BIT + 73) 67 + #define __NR_fsync (__X32_SYSCALL_BIT + 74) 68 + #define __NR_fdatasync (__X32_SYSCALL_BIT + 75) 69 + #define __NR_truncate (__X32_SYSCALL_BIT + 76) 70 + #define __NR_ftruncate (__X32_SYSCALL_BIT + 77) 71 + #define __NR_getdents (__X32_SYSCALL_BIT + 78) 72 + #define __NR_getcwd (__X32_SYSCALL_BIT + 79) 73 + #define __NR_chdir (__X32_SYSCALL_BIT + 80) 74 + #define __NR_fchdir (__X32_SYSCALL_BIT + 81) 75 + #define __NR_rename (__X32_SYSCALL_BIT + 82) 76 + #define __NR_mkdir (__X32_SYSCALL_BIT + 83) 77 + #define __NR_rmdir (__X32_SYSCALL_BIT + 84) 78 + #define __NR_creat (__X32_SYSCALL_BIT + 85) 79 + #define __NR_link (__X32_SYSCALL_BIT + 86) 80 + #define __NR_unlink (__X32_SYSCALL_BIT + 87) 81 + #define __NR_symlink (__X32_SYSCALL_BIT + 88) 82 + #define __NR_readlink (__X32_SYSCALL_BIT + 89) 83 + #define __NR_chmod (__X32_SYSCALL_BIT + 90) 84 + #define __NR_fchmod (__X32_SYSCALL_BIT + 91) 85 + #define __NR_chown (__X32_SYSCALL_BIT + 92) 86 + #define __NR_fchown (__X32_SYSCALL_BIT + 93) 87 + #define __NR_lchown (__X32_SYSCALL_BIT + 94) 88 + #define __NR_umask (__X32_SYSCALL_BIT + 95) 89 + #define __NR_gettimeofday (__X32_SYSCALL_BIT + 96) 90 + #define __NR_getrlimit (__X32_SYSCALL_BIT + 97) 91 + #define __NR_getrusage (__X32_SYSCALL_BIT + 98) 92 + #define __NR_sysinfo (__X32_SYSCALL_BIT + 99) 93 + #define __NR_times (__X32_SYSCALL_BIT + 100) 94 + #define __NR_getuid (__X32_SYSCALL_BIT + 102) 95 + #define __NR_syslog (__X32_SYSCALL_BIT + 103) 96 + #define __NR_getgid (__X32_SYSCALL_BIT + 104) 97 + #define __NR_setuid (__X32_SYSCALL_BIT + 105) 98 + #define __NR_setgid (__X32_SYSCALL_BIT + 106) 99 + #define __NR_geteuid (__X32_SYSCALL_BIT + 107) 100 + #define __NR_getegid (__X32_SYSCALL_BIT + 108) 101 + #define __NR_setpgid (__X32_SYSCALL_BIT + 109) 102 + #define __NR_getppid (__X32_SYSCALL_BIT + 110) 103 + #define __NR_getpgrp (__X32_SYSCALL_BIT + 111) 104 + #define __NR_setsid (__X32_SYSCALL_BIT + 112) 105 + #define __NR_setreuid (__X32_SYSCALL_BIT + 113) 106 + #define __NR_setregid (__X32_SYSCALL_BIT + 114) 107 + #define __NR_getgroups (__X32_SYSCALL_BIT + 115) 108 + #define __NR_setgroups (__X32_SYSCALL_BIT + 116) 109 + #define __NR_setresuid (__X32_SYSCALL_BIT + 117) 110 + #define __NR_getresuid (__X32_SYSCALL_BIT + 118) 111 + #define __NR_setresgid (__X32_SYSCALL_BIT + 119) 112 + #define __NR_getresgid (__X32_SYSCALL_BIT + 120) 113 + #define __NR_getpgid (__X32_SYSCALL_BIT + 121) 114 + #define __NR_setfsuid (__X32_SYSCALL_BIT + 122) 115 + #define __NR_setfsgid (__X32_SYSCALL_BIT + 123) 116 + #define __NR_getsid (__X32_SYSCALL_BIT + 124) 117 + #define __NR_capget (__X32_SYSCALL_BIT + 125) 118 + #define __NR_capset (__X32_SYSCALL_BIT + 126) 119 + #define __NR_rt_sigsuspend (__X32_SYSCALL_BIT + 130) 120 + #define __NR_utime (__X32_SYSCALL_BIT + 132) 121 + #define __NR_mknod (__X32_SYSCALL_BIT + 133) 122 + #define __NR_personality (__X32_SYSCALL_BIT + 135) 123 + #define __NR_ustat (__X32_SYSCALL_BIT + 136) 124 + #define __NR_statfs (__X32_SYSCALL_BIT + 137) 125 + #define __NR_fstatfs (__X32_SYSCALL_BIT + 138) 126 + #define __NR_sysfs (__X32_SYSCALL_BIT + 139) 127 + #define __NR_getpriority (__X32_SYSCALL_BIT + 140) 128 + #define __NR_setpriority (__X32_SYSCALL_BIT + 141) 129 + #define __NR_sched_setparam (__X32_SYSCALL_BIT + 142) 130 + #define __NR_sched_getparam (__X32_SYSCALL_BIT + 143) 131 + #define __NR_sched_setscheduler (__X32_SYSCALL_BIT + 144) 132 + #define __NR_sched_getscheduler (__X32_SYSCALL_BIT + 145) 133 + #define __NR_sched_get_priority_max (__X32_SYSCALL_BIT + 146) 134 + #define __NR_sched_get_priority_min (__X32_SYSCALL_BIT + 147) 135 + #define __NR_sched_rr_get_interval (__X32_SYSCALL_BIT + 148) 136 + #define __NR_mlock (__X32_SYSCALL_BIT + 149) 137 + #define __NR_munlock (__X32_SYSCALL_BIT + 150) 138 + #define __NR_mlockall (__X32_SYSCALL_BIT + 151) 139 + #define __NR_munlockall (__X32_SYSCALL_BIT + 152) 140 + #define __NR_vhangup (__X32_SYSCALL_BIT + 153) 141 + #define __NR_modify_ldt (__X32_SYSCALL_BIT + 154) 142 + #define __NR_pivot_root (__X32_SYSCALL_BIT + 155) 143 + #define __NR_prctl (__X32_SYSCALL_BIT + 157) 144 + #define __NR_arch_prctl (__X32_SYSCALL_BIT + 158) 145 + #define __NR_adjtimex (__X32_SYSCALL_BIT + 159) 146 + #define __NR_setrlimit (__X32_SYSCALL_BIT + 160) 147 + #define __NR_chroot (__X32_SYSCALL_BIT + 161) 148 + #define __NR_sync (__X32_SYSCALL_BIT + 162) 149 + #define __NR_acct (__X32_SYSCALL_BIT + 163) 150 + #define __NR_settimeofday (__X32_SYSCALL_BIT + 164) 151 + #define __NR_mount (__X32_SYSCALL_BIT + 165) 152 + #define __NR_umount2 (__X32_SYSCALL_BIT + 166) 153 + #define __NR_swapon (__X32_SYSCALL_BIT + 167) 154 + #define __NR_swapoff (__X32_SYSCALL_BIT + 168) 155 + #define __NR_reboot (__X32_SYSCALL_BIT + 169) 156 + #define __NR_sethostname (__X32_SYSCALL_BIT + 170) 157 + #define __NR_setdomainname (__X32_SYSCALL_BIT + 171) 158 + #define __NR_iopl (__X32_SYSCALL_BIT + 172) 159 + #define __NR_ioperm (__X32_SYSCALL_BIT + 173) 160 + #define __NR_init_module (__X32_SYSCALL_BIT + 175) 161 + #define __NR_delete_module (__X32_SYSCALL_BIT + 176) 162 + #define __NR_quotactl (__X32_SYSCALL_BIT + 179) 163 + #define __NR_getpmsg (__X32_SYSCALL_BIT + 181) 164 + #define __NR_putpmsg (__X32_SYSCALL_BIT + 182) 165 + #define __NR_afs_syscall (__X32_SYSCALL_BIT + 183) 166 + #define __NR_tuxcall (__X32_SYSCALL_BIT + 184) 167 + #define __NR_security (__X32_SYSCALL_BIT + 185) 168 + #define __NR_gettid (__X32_SYSCALL_BIT + 186) 169 + #define __NR_readahead (__X32_SYSCALL_BIT + 187) 170 + #define __NR_setxattr (__X32_SYSCALL_BIT + 188) 171 + #define __NR_lsetxattr (__X32_SYSCALL_BIT + 189) 172 + #define __NR_fsetxattr (__X32_SYSCALL_BIT + 190) 173 + #define __NR_getxattr (__X32_SYSCALL_BIT + 191) 174 + #define __NR_lgetxattr (__X32_SYSCALL_BIT + 192) 175 + #define __NR_fgetxattr (__X32_SYSCALL_BIT + 193) 176 + #define __NR_listxattr (__X32_SYSCALL_BIT + 194) 177 + #define __NR_llistxattr (__X32_SYSCALL_BIT + 195) 178 + #define __NR_flistxattr (__X32_SYSCALL_BIT + 196) 179 + #define __NR_removexattr (__X32_SYSCALL_BIT + 197) 180 + #define __NR_lremovexattr (__X32_SYSCALL_BIT + 198) 181 + #define __NR_fremovexattr (__X32_SYSCALL_BIT + 199) 182 + #define __NR_tkill (__X32_SYSCALL_BIT + 200) 183 + #define __NR_time (__X32_SYSCALL_BIT + 201) 184 + #define __NR_futex (__X32_SYSCALL_BIT + 202) 185 + #define __NR_sched_setaffinity (__X32_SYSCALL_BIT + 203) 186 + #define __NR_sched_getaffinity (__X32_SYSCALL_BIT + 204) 187 + #define __NR_io_destroy (__X32_SYSCALL_BIT + 207) 188 + #define __NR_io_getevents (__X32_SYSCALL_BIT + 208) 189 + #define __NR_io_cancel (__X32_SYSCALL_BIT + 210) 190 + #define __NR_lookup_dcookie (__X32_SYSCALL_BIT + 212) 191 + #define __NR_epoll_create (__X32_SYSCALL_BIT + 213) 192 + #define __NR_remap_file_pages (__X32_SYSCALL_BIT + 216) 193 + #define __NR_getdents64 (__X32_SYSCALL_BIT + 217) 194 + #define __NR_set_tid_address (__X32_SYSCALL_BIT + 218) 195 + #define __NR_restart_syscall (__X32_SYSCALL_BIT + 219) 196 + #define __NR_semtimedop (__X32_SYSCALL_BIT + 220) 197 + #define __NR_fadvise64 (__X32_SYSCALL_BIT + 221) 198 + #define __NR_timer_settime (__X32_SYSCALL_BIT + 223) 199 + #define __NR_timer_gettime (__X32_SYSCALL_BIT + 224) 200 + #define __NR_timer_getoverrun (__X32_SYSCALL_BIT + 225) 201 + #define __NR_timer_delete (__X32_SYSCALL_BIT + 226) 202 + #define __NR_clock_settime (__X32_SYSCALL_BIT + 227) 203 + #define __NR_clock_gettime (__X32_SYSCALL_BIT + 228) 204 + #define __NR_clock_getres (__X32_SYSCALL_BIT + 229) 205 + #define __NR_clock_nanosleep (__X32_SYSCALL_BIT + 230) 206 + #define __NR_exit_group (__X32_SYSCALL_BIT + 231) 207 + #define __NR_epoll_wait (__X32_SYSCALL_BIT + 232) 208 + #define __NR_epoll_ctl (__X32_SYSCALL_BIT + 233) 209 + #define __NR_tgkill (__X32_SYSCALL_BIT + 234) 210 + #define __NR_utimes (__X32_SYSCALL_BIT + 235) 211 + #define __NR_mbind (__X32_SYSCALL_BIT + 237) 212 + #define __NR_set_mempolicy (__X32_SYSCALL_BIT + 238) 213 + #define __NR_get_mempolicy (__X32_SYSCALL_BIT + 239) 214 + #define __NR_mq_open (__X32_SYSCALL_BIT + 240) 215 + #define __NR_mq_unlink (__X32_SYSCALL_BIT + 241) 216 + #define __NR_mq_timedsend (__X32_SYSCALL_BIT + 242) 217 + #define __NR_mq_timedreceive (__X32_SYSCALL_BIT + 243) 218 + #define __NR_mq_getsetattr (__X32_SYSCALL_BIT + 245) 219 + #define __NR_add_key (__X32_SYSCALL_BIT + 248) 220 + #define __NR_request_key (__X32_SYSCALL_BIT + 249) 221 + #define __NR_keyctl (__X32_SYSCALL_BIT + 250) 222 + #define __NR_ioprio_set (__X32_SYSCALL_BIT + 251) 223 + #define __NR_ioprio_get (__X32_SYSCALL_BIT + 252) 224 + #define __NR_inotify_init (__X32_SYSCALL_BIT + 253) 225 + #define __NR_inotify_add_watch (__X32_SYSCALL_BIT + 254) 226 + #define __NR_inotify_rm_watch (__X32_SYSCALL_BIT + 255) 227 + #define __NR_migrate_pages (__X32_SYSCALL_BIT + 256) 228 + #define __NR_openat (__X32_SYSCALL_BIT + 257) 229 + #define __NR_mkdirat (__X32_SYSCALL_BIT + 258) 230 + #define __NR_mknodat (__X32_SYSCALL_BIT + 259) 231 + #define __NR_fchownat (__X32_SYSCALL_BIT + 260) 232 + #define __NR_futimesat (__X32_SYSCALL_BIT + 261) 233 + #define __NR_newfstatat (__X32_SYSCALL_BIT + 262) 234 + #define __NR_unlinkat (__X32_SYSCALL_BIT + 263) 235 + #define __NR_renameat (__X32_SYSCALL_BIT + 264) 236 + #define __NR_linkat (__X32_SYSCALL_BIT + 265) 237 + #define __NR_symlinkat (__X32_SYSCALL_BIT + 266) 238 + #define __NR_readlinkat (__X32_SYSCALL_BIT + 267) 239 + #define __NR_fchmodat (__X32_SYSCALL_BIT + 268) 240 + #define __NR_faccessat (__X32_SYSCALL_BIT + 269) 241 + #define __NR_pselect6 (__X32_SYSCALL_BIT + 270) 242 + #define __NR_ppoll (__X32_SYSCALL_BIT + 271) 243 + #define __NR_unshare (__X32_SYSCALL_BIT + 272) 244 + #define __NR_splice (__X32_SYSCALL_BIT + 275) 245 + #define __NR_tee (__X32_SYSCALL_BIT + 276) 246 + #define __NR_sync_file_range (__X32_SYSCALL_BIT + 277) 247 + #define __NR_utimensat (__X32_SYSCALL_BIT + 280) 248 + #define __NR_epoll_pwait (__X32_SYSCALL_BIT + 281) 249 + #define __NR_signalfd (__X32_SYSCALL_BIT + 282) 250 + #define __NR_timerfd_create (__X32_SYSCALL_BIT + 283) 251 + #define __NR_eventfd (__X32_SYSCALL_BIT + 284) 252 + #define __NR_fallocate (__X32_SYSCALL_BIT + 285) 253 + #define __NR_timerfd_settime (__X32_SYSCALL_BIT + 286) 254 + #define __NR_timerfd_gettime (__X32_SYSCALL_BIT + 287) 255 + #define __NR_accept4 (__X32_SYSCALL_BIT + 288) 256 + #define __NR_signalfd4 (__X32_SYSCALL_BIT + 289) 257 + #define __NR_eventfd2 (__X32_SYSCALL_BIT + 290) 258 + #define __NR_epoll_create1 (__X32_SYSCALL_BIT + 291) 259 + #define __NR_dup3 (__X32_SYSCALL_BIT + 292) 260 + #define __NR_pipe2 (__X32_SYSCALL_BIT + 293) 261 + #define __NR_inotify_init1 (__X32_SYSCALL_BIT + 294) 262 + #define __NR_perf_event_open (__X32_SYSCALL_BIT + 298) 263 + #define __NR_fanotify_init (__X32_SYSCALL_BIT + 300) 264 + #define __NR_fanotify_mark (__X32_SYSCALL_BIT + 301) 265 + #define __NR_prlimit64 (__X32_SYSCALL_BIT + 302) 266 + #define __NR_name_to_handle_at (__X32_SYSCALL_BIT + 303) 267 + #define __NR_open_by_handle_at (__X32_SYSCALL_BIT + 304) 268 + #define __NR_clock_adjtime (__X32_SYSCALL_BIT + 305) 269 + #define __NR_syncfs (__X32_SYSCALL_BIT + 306) 270 + #define __NR_setns (__X32_SYSCALL_BIT + 308) 271 + #define __NR_getcpu (__X32_SYSCALL_BIT + 309) 272 + #define __NR_kcmp (__X32_SYSCALL_BIT + 312) 273 + #define __NR_finit_module (__X32_SYSCALL_BIT + 313) 274 + #define __NR_sched_setattr (__X32_SYSCALL_BIT + 314) 275 + #define __NR_sched_getattr (__X32_SYSCALL_BIT + 315) 276 + #define __NR_renameat2 (__X32_SYSCALL_BIT + 316) 277 + #define __NR_seccomp (__X32_SYSCALL_BIT + 317) 278 + #define __NR_getrandom (__X32_SYSCALL_BIT + 318) 279 + #define __NR_memfd_create (__X32_SYSCALL_BIT + 319) 280 + #define __NR_kexec_file_load (__X32_SYSCALL_BIT + 320) 281 + #define __NR_bpf (__X32_SYSCALL_BIT + 321) 282 + #define __NR_userfaultfd (__X32_SYSCALL_BIT + 323) 283 + #define __NR_membarrier (__X32_SYSCALL_BIT + 324) 284 + #define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512) 285 + #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513) 286 + #define __NR_ioctl (__X32_SYSCALL_BIT + 514) 287 + #define __NR_readv (__X32_SYSCALL_BIT + 515) 288 + #define __NR_writev (__X32_SYSCALL_BIT + 516) 289 + #define __NR_recvfrom (__X32_SYSCALL_BIT + 517) 290 + #define __NR_sendmsg (__X32_SYSCALL_BIT + 518) 291 + #define __NR_recvmsg (__X32_SYSCALL_BIT + 519) 292 + #define __NR_execve (__X32_SYSCALL_BIT + 520) 293 + #define __NR_ptrace (__X32_SYSCALL_BIT + 521) 294 + #define __NR_rt_sigpending (__X32_SYSCALL_BIT + 522) 295 + #define __NR_rt_sigtimedwait (__X32_SYSCALL_BIT + 523) 296 + #define __NR_rt_sigqueueinfo (__X32_SYSCALL_BIT + 524) 297 + #define __NR_sigaltstack (__X32_SYSCALL_BIT + 525) 298 + #define __NR_timer_create (__X32_SYSCALL_BIT + 526) 299 + #define __NR_mq_notify (__X32_SYSCALL_BIT + 527) 300 + #define __NR_kexec_load (__X32_SYSCALL_BIT + 528) 301 + #define __NR_waitid (__X32_SYSCALL_BIT + 529) 302 + #define __NR_set_robust_list (__X32_SYSCALL_BIT + 530) 303 + #define __NR_get_robust_list (__X32_SYSCALL_BIT + 531) 304 + #define __NR_vmsplice (__X32_SYSCALL_BIT + 532) 305 + #define __NR_move_pages (__X32_SYSCALL_BIT + 533) 306 + #define __NR_preadv (__X32_SYSCALL_BIT + 534) 307 + #define __NR_pwritev (__X32_SYSCALL_BIT + 535) 308 + #define __NR_rt_tgsigqueueinfo (__X32_SYSCALL_BIT + 536) 309 + #define __NR_recvmmsg (__X32_SYSCALL_BIT + 537) 310 + #define __NR_sendmmsg (__X32_SYSCALL_BIT + 538) 311 + #define __NR_process_vm_readv (__X32_SYSCALL_BIT + 539) 312 + #define __NR_process_vm_writev (__X32_SYSCALL_BIT + 540) 313 + #define __NR_setsockopt (__X32_SYSCALL_BIT + 541) 314 + #define __NR_getsockopt (__X32_SYSCALL_BIT + 542) 315 + #define __NR_io_setup (__X32_SYSCALL_BIT + 543) 316 + #define __NR_io_submit (__X32_SYSCALL_BIT + 544) 317 + #define __NR_execveat (__X32_SYSCALL_BIT + 545) 318 + 319 + #endif /* _ASM_X86_UNISTD_X32_H */
+8
net/net.c
··· 524 524 525 525 int qemu_set_vnet_le(NetClientState *nc, bool is_le) 526 526 { 527 + #ifdef HOST_WORDS_BIGENDIAN 527 528 if (!nc || !nc->info->set_vnet_le) { 528 529 return -ENOSYS; 529 530 } 530 531 531 532 return nc->info->set_vnet_le(nc, is_le); 533 + #else 534 + return 0; 535 + #endif 532 536 } 533 537 534 538 int qemu_set_vnet_be(NetClientState *nc, bool is_be) 535 539 { 540 + #ifdef HOST_WORDS_BIGENDIAN 541 + return 0; 542 + #else 536 543 if (!nc || !nc->info->set_vnet_be) { 537 544 return -ENOSYS; 538 545 } 539 546 540 547 return nc->info->set_vnet_be(nc, is_be); 548 + #endif 541 549 } 542 550 543 551 int qemu_can_send_packet(NetClientState *sender)
+32 -4
net/vhost-user.c
··· 15 15 #include "qemu/config-file.h" 16 16 #include "qemu/error-report.h" 17 17 #include "qmp-commands.h" 18 + #include "trace.h" 18 19 19 20 typedef struct VhostUserState { 20 21 NetClientState nc; ··· 102 103 return -1; 103 104 } 104 105 106 + static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf, 107 + size_t size) 108 + { 109 + /* In case of RARP (message size is 60) notify backup to send a fake RARP. 110 + This fake RARP will be sent by backend only for guest 111 + without GUEST_ANNOUNCE capability. 112 + */ 113 + if (size == 60) { 114 + VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc); 115 + int r; 116 + static int display_rarp_failure = 1; 117 + char mac_addr[6]; 118 + 119 + /* extract guest mac address from the RARP message */ 120 + memcpy(mac_addr, &buf[6], 6); 121 + 122 + r = vhost_net_notify_migration_done(s->vhost_net, mac_addr); 123 + 124 + if ((r != 0) && (display_rarp_failure)) { 125 + fprintf(stderr, 126 + "Vhost user backend fails to broadcast fake RARP\n"); 127 + fflush(stderr); 128 + display_rarp_failure = 0; 129 + } 130 + } 131 + 132 + return size; 133 + } 134 + 105 135 static void vhost_user_cleanup(NetClientState *nc) 106 136 { 107 137 VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc); ··· 131 161 static NetClientInfo net_vhost_user_info = { 132 162 .type = NET_CLIENT_OPTIONS_KIND_VHOST_USER, 133 163 .size = sizeof(VhostUserState), 164 + .receive = vhost_user_receive, 134 165 .cleanup = vhost_user_cleanup, 135 166 .has_vnet_hdr = vhost_user_has_vnet_hdr, 136 167 .has_ufo = vhost_user_has_ufo, ··· 148 179 NET_CLIENT_OPTIONS_KIND_NIC, 149 180 MAX_QUEUE_NUM); 150 181 s = DO_UPCAST(VhostUserState, nc, ncs[0]); 182 + trace_vhost_user_event(s->chr->label, event); 151 183 switch (event) { 152 184 case CHR_EVENT_OPENED: 153 185 if (vhost_user_start(queues, ncs) < 0) { 154 186 exit(1); 155 187 } 156 188 qmp_set_link(name, true, &err); 157 - error_report("chardev \"%s\" went up", s->chr->label); 158 189 break; 159 190 case CHR_EVENT_CLOSED: 160 191 qmp_set_link(name, true, &err); 161 192 vhost_user_stop(queues, ncs); 162 - error_report("chardev \"%s\" went down", s->chr->label); 163 193 break; 164 194 } 165 195 ··· 182 212 snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user%d to %s", 183 213 i, chr->label); 184 214 185 - /* We don't provide a receive callback */ 186 - nc->receive_disabled = 1; 187 215 nc->queue_index = i; 188 216 189 217 s = DO_UPCAST(VhostUserState, nc, nc);
+2 -1
qemu-seccomp.c
··· 237 237 { SCMP_SYS(fadvise64), 240 }, 238 238 { SCMP_SYS(inotify_init1), 240 }, 239 239 { SCMP_SYS(inotify_add_watch), 240 }, 240 - { SCMP_SYS(mbind), 240 } 240 + { SCMP_SYS(mbind), 240 }, 241 + { SCMP_SYS(memfd_create), 240 } 241 242 }; 242 243 243 244 int seccomp_start(void)
+5 -2
scripts/update-linux-headers.sh
··· 69 69 fi 70 70 71 71 # Blacklist architectures which have KVM headers but are actually dead 72 - if [ "$arch" = "ia64" ]; then 72 + if [ "$arch" = "ia64" -o "$arch" = "mips" ]; then 73 73 continue 74 74 fi 75 75 ··· 77 77 78 78 rm -rf "$output/linux-headers/asm-$arch" 79 79 mkdir -p "$output/linux-headers/asm-$arch" 80 - for header in kvm.h kvm_para.h; do 80 + for header in kvm.h kvm_para.h unistd.h; do 81 81 cp "$tmpdir/include/asm/$header" "$output/linux-headers/asm-$arch" 82 82 done 83 83 if [ $arch = powerpc ]; then ··· 92 92 fi 93 93 if [ $arch = x86 ]; then 94 94 cp_portable "$tmpdir/include/asm/hyperv.h" "$output/include/standard-headers/asm-x86/" 95 + cp "$tmpdir/include/asm/unistd_32.h" "$output/linux-headers/asm-x86/" 96 + cp "$tmpdir/include/asm/unistd_x32.h" "$output/linux-headers/asm-x86/" 97 + cp "$tmpdir/include/asm/unistd_64.h" "$output/linux-headers/asm-x86/" 95 98 fi 96 99 done 97 100
+1
stubs/Makefile.objs
··· 34 34 stub-obj-y += kvm.o 35 35 stub-obj-y += qmp_pc_dimm_device_list.o 36 36 stub-obj-y += target-monitor-defs.o 37 + stub-obj-y += vhost.o
+6
stubs/vhost.c
··· 1 + #include "hw/virtio/vhost.h" 2 + 3 + bool vhost_has_free_slot(void) 4 + { 5 + return true; 6 + }
+315 -57
tests/vhost-user-test.c
··· 12 12 13 13 #include "libqtest.h" 14 14 #include "qemu/option.h" 15 + #include "qemu/range.h" 15 16 #include "sysemu/char.h" 16 17 #include "sysemu/sysemu.h" 17 18 ··· 30 31 #endif 31 32 32 33 #define QEMU_CMD_ACCEL " -machine accel=tcg" 33 - #define QEMU_CMD_MEM " -m 512 -object memory-backend-file,id=mem,size=512M,"\ 34 + #define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=mem,size=%dM,"\ 34 35 "mem-path=%s,share=on -numa node,memdev=mem" 35 - #define QEMU_CMD_CHR " -chardev socket,id=chr0,path=%s" 36 - #define QEMU_CMD_NETDEV " -netdev vhost-user,id=net0,chardev=chr0,vhostforce" 36 + #define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s" 37 + #define QEMU_CMD_NETDEV " -netdev vhost-user,id=net0,chardev=%s,vhostforce" 37 38 #define QEMU_CMD_NET " -device virtio-net-pci,netdev=net0 " 38 39 #define QEMU_CMD_ROM " -option-rom ../pc-bios/pxe-virtio.rom" 39 40 ··· 47 48 #define VHOST_MEMORY_MAX_NREGIONS 8 48 49 49 50 #define VHOST_USER_F_PROTOCOL_FEATURES 30 51 + #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 52 + 53 + #define VHOST_LOG_PAGE 0x1000 50 54 51 55 typedef enum VhostUserRequest { 52 56 VHOST_USER_NONE = 0, ··· 108 112 #define VHOST_USER_VERSION (0x1) 109 113 /*****************************************************************************/ 110 114 111 - int fds_num = 0, fds[VHOST_MEMORY_MAX_NREGIONS]; 112 - static VhostUserMemory memory; 113 - static CompatGMutex data_mutex; 114 - static CompatGCond data_cond; 115 + typedef struct TestServer { 116 + gchar *socket_path; 117 + gchar *chr_name; 118 + CharDriverState *chr; 119 + int fds_num; 120 + int fds[VHOST_MEMORY_MAX_NREGIONS]; 121 + VhostUserMemory memory; 122 + GMutex data_mutex; 123 + GCond data_cond; 124 + int log_fd; 125 + } TestServer; 115 126 116 127 #if !GLIB_CHECK_VERSION(2, 32, 0) 117 128 static gboolean g_cond_wait_until(CompatGCond cond, CompatGMutex mutex, ··· 126 137 } 127 138 #endif 128 139 129 - static void read_guest_mem(void) 140 + static const char *tmpfs; 141 + static const char *root; 142 + 143 + static void wait_for_fds(TestServer *s) 130 144 { 131 - uint32_t *guest_mem; 132 145 gint64 end_time; 133 - int i, j; 134 - size_t size; 135 146 136 - g_mutex_lock(&data_mutex); 147 + g_mutex_lock(&s->data_mutex); 137 148 138 149 end_time = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND; 139 - while (!fds_num) { 140 - if (!g_cond_wait_until(&data_cond, &data_mutex, end_time)) { 150 + while (!s->fds_num) { 151 + if (!g_cond_wait_until(&s->data_cond, &s->data_mutex, end_time)) { 141 152 /* timeout has passed */ 142 - g_assert(fds_num); 153 + g_assert(s->fds_num); 143 154 break; 144 155 } 145 156 } 146 157 147 158 /* check for sanity */ 148 - g_assert_cmpint(fds_num, >, 0); 149 - g_assert_cmpint(fds_num, ==, memory.nregions); 159 + g_assert_cmpint(s->fds_num, >, 0); 160 + g_assert_cmpint(s->fds_num, ==, s->memory.nregions); 161 + 162 + g_mutex_unlock(&s->data_mutex); 163 + } 164 + 165 + static void read_guest_mem(TestServer *s) 166 + { 167 + uint32_t *guest_mem; 168 + int i, j; 169 + size_t size; 170 + 171 + wait_for_fds(s); 172 + 173 + g_mutex_lock(&s->data_mutex); 150 174 151 175 /* iterate all regions */ 152 - for (i = 0; i < fds_num; i++) { 176 + for (i = 0; i < s->fds_num; i++) { 153 177 154 178 /* We'll check only the region statring at 0x0*/ 155 - if (memory.regions[i].guest_phys_addr != 0x0) { 179 + if (s->memory.regions[i].guest_phys_addr != 0x0) { 156 180 continue; 157 181 } 158 182 159 - g_assert_cmpint(memory.regions[i].memory_size, >, 1024); 183 + g_assert_cmpint(s->memory.regions[i].memory_size, >, 1024); 160 184 161 - size = memory.regions[i].memory_size + memory.regions[i].mmap_offset; 185 + size = s->memory.regions[i].memory_size + 186 + s->memory.regions[i].mmap_offset; 162 187 163 188 guest_mem = mmap(0, size, PROT_READ | PROT_WRITE, 164 - MAP_SHARED, fds[i], 0); 189 + MAP_SHARED, s->fds[i], 0); 165 190 166 191 g_assert(guest_mem != MAP_FAILED); 167 - guest_mem += (memory.regions[i].mmap_offset / sizeof(*guest_mem)); 192 + guest_mem += (s->memory.regions[i].mmap_offset / sizeof(*guest_mem)); 168 193 169 194 for (j = 0; j < 256; j++) { 170 - uint32_t a = readl(memory.regions[i].guest_phys_addr + j*4); 195 + uint32_t a = readl(s->memory.regions[i].guest_phys_addr + j*4); 171 196 uint32_t b = guest_mem[j]; 172 197 173 198 g_assert_cmpint(a, ==, b); 174 199 } 175 200 176 - munmap(guest_mem, memory.regions[i].memory_size); 201 + munmap(guest_mem, s->memory.regions[i].memory_size); 177 202 } 178 203 179 - g_assert_cmpint(1, ==, 1); 180 - g_mutex_unlock(&data_mutex); 204 + g_mutex_unlock(&s->data_mutex); 181 205 } 182 206 183 207 static void *thread_function(void *data) ··· 195 219 196 220 static void chr_read(void *opaque, const uint8_t *buf, int size) 197 221 { 198 - CharDriverState *chr = opaque; 222 + TestServer *s = opaque; 223 + CharDriverState *chr = s->chr; 199 224 VhostUserMsg msg; 200 225 uint8_t *p = (uint8_t *) &msg; 201 226 int fd; ··· 205 230 return; 206 231 } 207 232 208 - g_mutex_lock(&data_mutex); 233 + g_mutex_lock(&s->data_mutex); 209 234 memcpy(p, buf, VHOST_USER_HDR_SIZE); 210 235 211 236 if (msg.size) { 212 237 p += VHOST_USER_HDR_SIZE; 213 - qemu_chr_fe_read_all(chr, p, msg.size); 238 + g_assert_cmpint(qemu_chr_fe_read_all(chr, p, msg.size), ==, msg.size); 214 239 } 215 240 216 241 switch (msg.request) { ··· 218 243 /* send back features to qemu */ 219 244 msg.flags |= VHOST_USER_REPLY_MASK; 220 245 msg.size = sizeof(m.u64); 221 - msg.u64 = 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; 246 + msg.u64 = 0x1ULL << VHOST_F_LOG_ALL | 247 + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; 222 248 p = (uint8_t *) &msg; 223 249 qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); 224 250 break; ··· 232 258 /* send back features to qemu */ 233 259 msg.flags |= VHOST_USER_REPLY_MASK; 234 260 msg.size = sizeof(m.u64); 235 - msg.u64 = 0; 261 + msg.u64 = 1 << VHOST_USER_PROTOCOL_F_LOG_SHMFD; 236 262 p = (uint8_t *) &msg; 237 263 qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); 238 264 break; ··· 248 274 249 275 case VHOST_USER_SET_MEM_TABLE: 250 276 /* received the mem table */ 251 - memcpy(&memory, &msg.memory, sizeof(msg.memory)); 252 - fds_num = qemu_chr_fe_get_msgfds(chr, fds, sizeof(fds) / sizeof(int)); 277 + memcpy(&s->memory, &msg.memory, sizeof(msg.memory)); 278 + s->fds_num = qemu_chr_fe_get_msgfds(chr, s->fds, G_N_ELEMENTS(s->fds)); 253 279 254 280 /* signal the test that it can continue */ 255 - g_cond_signal(&data_cond); 281 + g_cond_signal(&s->data_cond); 256 282 break; 257 283 258 284 case VHOST_USER_SET_VRING_KICK: ··· 266 292 */ 267 293 qemu_set_nonblock(fd); 268 294 break; 295 + 296 + case VHOST_USER_SET_LOG_BASE: 297 + if (s->log_fd != -1) { 298 + close(s->log_fd); 299 + s->log_fd = -1; 300 + } 301 + qemu_chr_fe_get_msgfds(chr, &s->log_fd, 1); 302 + msg.flags |= VHOST_USER_REPLY_MASK; 303 + msg.size = 0; 304 + p = (uint8_t *) &msg; 305 + qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE); 306 + 307 + g_cond_signal(&s->data_cond); 308 + break; 309 + 310 + case VHOST_USER_RESET_DEVICE: 311 + s->fds_num = 0; 312 + break; 313 + 269 314 default: 270 315 break; 271 316 } 272 - g_mutex_unlock(&data_mutex); 317 + 318 + g_mutex_unlock(&s->data_mutex); 273 319 } 274 320 275 321 static const char *init_hugepagefs(const char *path) ··· 299 345 return path; 300 346 } 301 347 348 + static TestServer *test_server_new(const gchar *name) 349 + { 350 + TestServer *server = g_new0(TestServer, 1); 351 + gchar *chr_path; 352 + 353 + server->socket_path = g_strdup_printf("%s/%s.sock", tmpfs, name); 354 + 355 + chr_path = g_strdup_printf("unix:%s,server,nowait", server->socket_path); 356 + server->chr_name = g_strdup_printf("chr-%s", name); 357 + server->chr = qemu_chr_new(server->chr_name, chr_path, NULL); 358 + g_free(chr_path); 359 + 360 + qemu_chr_add_handlers(server->chr, chr_can_read, chr_read, NULL, server); 361 + 362 + g_mutex_init(&server->data_mutex); 363 + g_cond_init(&server->data_cond); 364 + 365 + server->log_fd = -1; 366 + 367 + return server; 368 + } 369 + 370 + #define GET_QEMU_CMD(s) \ 371 + g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ 372 + (s)->socket_path, (s)->chr_name) 373 + 374 + #define GET_QEMU_CMDE(s, mem, extra, ...) \ 375 + g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ 376 + (s)->socket_path, (s)->chr_name, ##__VA_ARGS__) 377 + 378 + static void test_server_free(TestServer *server) 379 + { 380 + int i; 381 + 382 + qemu_chr_delete(server->chr); 383 + 384 + for (i = 0; i < server->fds_num; i++) { 385 + close(server->fds[i]); 386 + } 387 + 388 + if (server->log_fd != -1) { 389 + close(server->log_fd); 390 + } 391 + 392 + unlink(server->socket_path); 393 + g_free(server->socket_path); 394 + 395 + 396 + g_free(server->chr_name); 397 + g_free(server); 398 + } 399 + 400 + static void wait_for_log_fd(TestServer *s) 401 + { 402 + gint64 end_time; 403 + 404 + g_mutex_lock(&s->data_mutex); 405 + end_time = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND; 406 + while (s->log_fd == -1) { 407 + if (!g_cond_wait_until(&s->data_cond, &s->data_mutex, end_time)) { 408 + /* timeout has passed */ 409 + g_assert(s->log_fd != -1); 410 + break; 411 + } 412 + } 413 + 414 + g_mutex_unlock(&s->data_mutex); 415 + } 416 + 417 + static void write_guest_mem(TestServer *s, uint32 seed) 418 + { 419 + uint32_t *guest_mem; 420 + int i, j; 421 + size_t size; 422 + 423 + wait_for_fds(s); 424 + 425 + /* iterate all regions */ 426 + for (i = 0; i < s->fds_num; i++) { 427 + 428 + /* We'll write only the region statring at 0x0 */ 429 + if (s->memory.regions[i].guest_phys_addr != 0x0) { 430 + continue; 431 + } 432 + 433 + g_assert_cmpint(s->memory.regions[i].memory_size, >, 1024); 434 + 435 + size = s->memory.regions[i].memory_size + 436 + s->memory.regions[i].mmap_offset; 437 + 438 + guest_mem = mmap(0, size, PROT_READ | PROT_WRITE, 439 + MAP_SHARED, s->fds[i], 0); 440 + 441 + g_assert(guest_mem != MAP_FAILED); 442 + guest_mem += (s->memory.regions[i].mmap_offset / sizeof(*guest_mem)); 443 + 444 + for (j = 0; j < 256; j++) { 445 + guest_mem[j] = seed + j; 446 + } 447 + 448 + munmap(guest_mem, s->memory.regions[i].memory_size); 449 + break; 450 + } 451 + } 452 + 453 + static guint64 get_log_size(TestServer *s) 454 + { 455 + guint64 log_size = 0; 456 + int i; 457 + 458 + for (i = 0; i < s->memory.nregions; ++i) { 459 + VhostUserMemoryRegion *reg = &s->memory.regions[i]; 460 + guint64 last = range_get_last(reg->guest_phys_addr, 461 + reg->memory_size); 462 + log_size = MAX(log_size, last / (8 * VHOST_LOG_PAGE) + 1); 463 + } 464 + 465 + return log_size; 466 + } 467 + 468 + typedef struct TestMigrateSource { 469 + GSource source; 470 + TestServer *src; 471 + TestServer *dest; 472 + } TestMigrateSource; 473 + 474 + static gboolean 475 + test_migrate_source_check(GSource *source) 476 + { 477 + TestMigrateSource *t = (TestMigrateSource *)source; 478 + gboolean overlap = t->src->fds_num > 0 && t->dest->fds_num > 0; 479 + 480 + g_assert(!overlap); 481 + 482 + return FALSE; 483 + } 484 + 485 + GSourceFuncs test_migrate_source_funcs = { 486 + NULL, 487 + test_migrate_source_check, 488 + NULL, 489 + NULL 490 + }; 491 + 492 + static void test_migrate(void) 493 + { 494 + TestServer *s = test_server_new("src"); 495 + TestServer *dest = test_server_new("dest"); 496 + const char *uri = "tcp:127.0.0.1:1234"; 497 + QTestState *global = global_qtest, *from, *to; 498 + GSource *source; 499 + gchar *cmd; 500 + QDict *rsp; 501 + guint8 *log; 502 + guint64 size; 503 + 504 + cmd = GET_QEMU_CMDE(s, 2, ""); 505 + from = qtest_start(cmd); 506 + g_free(cmd); 507 + 508 + wait_for_fds(s); 509 + size = get_log_size(s); 510 + g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)); 511 + 512 + cmd = GET_QEMU_CMDE(dest, 2, " -incoming %s", uri); 513 + to = qtest_init(cmd); 514 + g_free(cmd); 515 + 516 + source = g_source_new(&test_migrate_source_funcs, 517 + sizeof(TestMigrateSource)); 518 + ((TestMigrateSource *)source)->src = s; 519 + ((TestMigrateSource *)source)->dest = dest; 520 + g_source_attach(source, NULL); 521 + 522 + /* slow down migration to have time to fiddle with log */ 523 + /* TODO: qtest could learn to break on some places */ 524 + rsp = qmp("{ 'execute': 'migrate_set_speed'," 525 + "'arguments': { 'value': 10 } }"); 526 + g_assert(qdict_haskey(rsp, "return")); 527 + QDECREF(rsp); 528 + 529 + cmd = g_strdup_printf("{ 'execute': 'migrate'," 530 + "'arguments': { 'uri': '%s' } }", 531 + uri); 532 + rsp = qmp(cmd); 533 + g_free(cmd); 534 + g_assert(qdict_haskey(rsp, "return")); 535 + QDECREF(rsp); 536 + 537 + wait_for_log_fd(s); 538 + 539 + log = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, s->log_fd, 0); 540 + g_assert(log != MAP_FAILED); 541 + 542 + /* modify first page */ 543 + write_guest_mem(s, 0x42); 544 + log[0] = 1; 545 + munmap(log, size); 546 + 547 + /* speed things up */ 548 + rsp = qmp("{ 'execute': 'migrate_set_speed'," 549 + "'arguments': { 'value': 0 } }"); 550 + g_assert(qdict_haskey(rsp, "return")); 551 + QDECREF(rsp); 552 + 553 + qmp_eventwait("STOP"); 554 + 555 + global_qtest = to; 556 + qmp_eventwait("RESUME"); 557 + 558 + read_guest_mem(dest); 559 + 560 + g_source_destroy(source); 561 + g_source_unref(source); 562 + 563 + qtest_quit(to); 564 + test_server_free(dest); 565 + qtest_quit(from); 566 + test_server_free(s); 567 + 568 + global_qtest = global; 569 + } 570 + 302 571 int main(int argc, char **argv) 303 572 { 304 573 QTestState *s = NULL; 305 - CharDriverState *chr = NULL; 574 + TestServer *server = NULL; 306 575 const char *hugefs; 307 - char *socket_path = 0; 308 - char *qemu_cmd = 0; 309 - char *chr_path = 0; 576 + char *qemu_cmd = NULL; 310 577 int ret; 311 578 char template[] = "/tmp/vhost-test-XXXXXX"; 312 - const char *tmpfs; 313 - const char *root; 314 579 315 580 g_test_init(&argc, &argv, NULL); 316 581 317 582 module_call_init(MODULE_INIT_QOM); 583 + qemu_add_opts(&qemu_chardev_opts); 318 584 319 585 tmpfs = mkdtemp(template); 320 586 if (!tmpfs) { 321 - g_test_message("mkdtemp on path (%s): %s\n", template, strerror(errno)); 587 + g_test_message("mkdtemp on path (%s): %s\n", template, strerror(errno)); 322 588 } 323 589 g_assert(tmpfs); 324 590 ··· 330 596 root = tmpfs; 331 597 } 332 598 333 - socket_path = g_strdup_printf("%s/vhost.sock", tmpfs); 334 - 335 - /* create char dev and add read handlers */ 336 - qemu_add_opts(&qemu_chardev_opts); 337 - chr_path = g_strdup_printf("unix:%s,server,nowait", socket_path); 338 - chr = qemu_chr_new("chr0", chr_path, NULL); 339 - g_free(chr_path); 340 - qemu_chr_add_handlers(chr, chr_can_read, chr_read, NULL, chr); 599 + server = test_server_new("test"); 341 600 342 601 /* run the main loop thread so the chardev may operate */ 343 - g_mutex_init(&data_mutex); 344 - g_cond_init(&data_cond); 345 602 g_thread_new(NULL, thread_function, NULL); 346 603 347 - qemu_cmd = g_strdup_printf(QEMU_CMD, root, socket_path); 604 + qemu_cmd = GET_QEMU_CMD(server); 605 + 348 606 s = qtest_start(qemu_cmd); 349 607 g_free(qemu_cmd); 350 608 351 - qtest_add_func("/vhost-user/read-guest-mem", read_guest_mem); 609 + qtest_add_data_func("/vhost-user/read-guest-mem", server, read_guest_mem); 610 + qtest_add_func("/vhost-user/migrate", test_migrate); 352 611 353 612 ret = g_test_run(); 354 613 ··· 357 616 } 358 617 359 618 /* cleanup */ 360 - unlink(socket_path); 361 - g_free(socket_path); 619 + test_server_free(server); 362 620 363 621 ret = rmdir(tmpfs); 364 622 if (ret != 0) {
+3
trace-events
··· 1705 1705 1706 1706 # crypto/tlssession.c 1707 1707 qcrypto_tls_session_new(void *session, void *creds, const char *hostname, const char *aclname, int endpoint) "TLS session new session=%p creds=%p hostname=%s aclname=%s endpoint=%d" 1708 + 1709 + # net/vhost-user.c 1710 + vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
+10 -3
util/Makefile.objs
··· 1 1 util-obj-y = osdep.o cutils.o unicode.o qemu-timer-common.o 2 - util-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o event_notifier-win32.o 3 - util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o event_notifier-posix.o qemu-openpty.o 2 + util-obj-$(CONFIG_POSIX) += compatfd.o 3 + util-obj-$(CONFIG_POSIX) += event_notifier-posix.o 4 + util-obj-$(CONFIG_POSIX) += mmap-alloc.o 5 + util-obj-$(CONFIG_POSIX) += oslib-posix.o 6 + util-obj-$(CONFIG_POSIX) += qemu-openpty.o 7 + util-obj-$(CONFIG_POSIX) += qemu-thread-posix.o 8 + util-obj-$(CONFIG_WIN32) += event_notifier-win32.o 9 + util-obj-$(CONFIG_POSIX) += memfd.o 10 + util-obj-$(CONFIG_WIN32) += oslib-win32.o 11 + util-obj-$(CONFIG_WIN32) += qemu-thread-win32.o 4 12 util-obj-y += envlist.o path.o module.o 5 13 util-obj-$(call lnot,$(CONFIG_INT128)) += host-utils.o 6 14 util-obj-y += bitmap.o bitops.o hbitmap.o 7 15 util-obj-y += fifo8.o 8 16 util-obj-y += acl.o 9 17 util-obj-y += error.o qemu-error.o 10 - util-obj-$(CONFIG_POSIX) += compatfd.o 11 18 util-obj-y += id.o 12 19 util-obj-y += iov.o qemu-config.o qemu-sockets.o uri.o notify.o 13 20 util-obj-y += qemu-option.o qemu-progress.o
+162
util/memfd.c
··· 1 + /* 2 + * memfd.c 3 + * 4 + * Copyright (c) 2015 Red Hat, Inc. 5 + * 6 + * QEMU library functions on POSIX which are shared between QEMU and 7 + * the QEMU tools. 8 + * 9 + * Permission is hereby granted, free of charge, to any person obtaining a copy 10 + * of this software and associated documentation files (the "Software"), to deal 11 + * in the Software without restriction, including without limitation the rights 12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 + * copies of the Software, and to permit persons to whom the Software is 14 + * furnished to do so, subject to the following conditions: 15 + * 16 + * The above copyright notice and this permission notice shall be included in 17 + * all copies or substantial portions of the Software. 18 + * 19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 + * THE SOFTWARE. 26 + */ 27 + 28 + #include "qemu/osdep.h" 29 + 30 + #include <glib.h> 31 + #include <glib/gprintf.h> 32 + 33 + #include <sys/mman.h> 34 + 35 + #include "qemu/memfd.h" 36 + 37 + #ifdef CONFIG_MEMFD 38 + #include <sys/memfd.h> 39 + #elif defined CONFIG_LINUX 40 + #include <sys/syscall.h> 41 + #include <asm/unistd.h> 42 + 43 + static int memfd_create(const char *name, unsigned int flags) 44 + { 45 + #ifdef __NR_memfd_create 46 + return syscall(__NR_memfd_create, name, flags); 47 + #else 48 + return -1; 49 + #endif 50 + } 51 + #endif 52 + 53 + #ifndef MFD_CLOEXEC 54 + #define MFD_CLOEXEC 0x0001U 55 + #endif 56 + 57 + #ifndef MFD_ALLOW_SEALING 58 + #define MFD_ALLOW_SEALING 0x0002U 59 + #endif 60 + 61 + /* 62 + * This is a best-effort helper for shared memory allocation, with 63 + * optional sealing. The helper will do his best to allocate using 64 + * memfd with sealing, but may fallback on other methods without 65 + * sealing. 66 + */ 67 + void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, 68 + int *fd) 69 + { 70 + void *ptr; 71 + int mfd = -1; 72 + 73 + *fd = -1; 74 + 75 + #ifdef CONFIG_LINUX 76 + if (seals) { 77 + mfd = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC); 78 + } 79 + 80 + if (mfd == -1) { 81 + /* some systems have memfd without sealing */ 82 + mfd = memfd_create(name, MFD_CLOEXEC); 83 + seals = 0; 84 + } 85 + #endif 86 + 87 + if (mfd != -1) { 88 + if (ftruncate(mfd, size) == -1) { 89 + perror("ftruncate"); 90 + close(mfd); 91 + return NULL; 92 + } 93 + 94 + if (seals && fcntl(mfd, F_ADD_SEALS, seals) == -1) { 95 + perror("fcntl"); 96 + close(mfd); 97 + return NULL; 98 + } 99 + } else { 100 + const char *tmpdir = g_get_tmp_dir(); 101 + gchar *fname; 102 + 103 + fname = g_strdup_printf("%s/memfd-XXXXXX", tmpdir); 104 + mfd = mkstemp(fname); 105 + unlink(fname); 106 + g_free(fname); 107 + 108 + if (mfd == -1) { 109 + perror("mkstemp"); 110 + return NULL; 111 + } 112 + 113 + if (ftruncate(mfd, size) == -1) { 114 + perror("ftruncate"); 115 + close(mfd); 116 + return NULL; 117 + } 118 + } 119 + 120 + ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0); 121 + if (ptr == MAP_FAILED) { 122 + perror("mmap"); 123 + close(mfd); 124 + return NULL; 125 + } 126 + 127 + *fd = mfd; 128 + return ptr; 129 + } 130 + 131 + void qemu_memfd_free(void *ptr, size_t size, int fd) 132 + { 133 + if (ptr) { 134 + munmap(ptr, size); 135 + } 136 + 137 + if (fd != -1) { 138 + close(fd); 139 + } 140 + } 141 + 142 + enum { 143 + MEMFD_KO, 144 + MEMFD_OK, 145 + MEMFD_TODO 146 + }; 147 + 148 + bool qemu_memfd_check(void) 149 + { 150 + static int memfd_check = MEMFD_TODO; 151 + 152 + if (memfd_check == MEMFD_TODO) { 153 + int fd; 154 + void *ptr; 155 + 156 + ptr = qemu_memfd_alloc("test", 4096, 0, &fd); 157 + memfd_check = ptr ? MEMFD_OK : MEMFD_KO; 158 + qemu_memfd_free(ptr, 4096, fd); 159 + } 160 + 161 + return memfd_check == MEMFD_OK; 162 + }
+71
util/mmap-alloc.c
··· 1 + /* 2 + * Support for RAM backed by mmaped host memory. 3 + * 4 + * Copyright (c) 2015 Red Hat, Inc. 5 + * 6 + * Authors: 7 + * Michael S. Tsirkin <mst@redhat.com> 8 + * 9 + * This work is licensed under the terms of the GNU GPL, version 2 or 10 + * later. See the COPYING file in the top-level directory. 11 + */ 12 + #include <qemu/mmap-alloc.h> 13 + #include <sys/types.h> 14 + #include <sys/mman.h> 15 + #include <assert.h> 16 + 17 + void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) 18 + { 19 + /* 20 + * Note: this always allocates at least one extra page of virtual address 21 + * space, even if size is already aligned. 22 + */ 23 + size_t total = size + align; 24 + void *ptr = mmap(0, total, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); 25 + size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr; 26 + void *ptr1; 27 + 28 + if (ptr == MAP_FAILED) { 29 + return NULL; 30 + } 31 + 32 + /* Make sure align is a power of 2 */ 33 + assert(!(align & (align - 1))); 34 + /* Always align to host page size */ 35 + assert(align >= getpagesize()); 36 + 37 + ptr1 = mmap(ptr + offset, size, PROT_READ | PROT_WRITE, 38 + MAP_FIXED | 39 + (fd == -1 ? MAP_ANONYMOUS : 0) | 40 + (shared ? MAP_SHARED : MAP_PRIVATE), 41 + fd, 0); 42 + if (ptr1 == MAP_FAILED) { 43 + munmap(ptr, total); 44 + return NULL; 45 + } 46 + 47 + ptr += offset; 48 + total -= offset; 49 + 50 + if (offset > 0) { 51 + munmap(ptr - offset, offset); 52 + } 53 + 54 + /* 55 + * Leave a single PROT_NONE page allocated after the RAM block, to serve as 56 + * a guard page guarding against potential buffer overflows. 57 + */ 58 + if (total > size + getpagesize()) { 59 + munmap(ptr + size + getpagesize(), total - size - getpagesize()); 60 + } 61 + 62 + return ptr; 63 + } 64 + 65 + void qemu_ram_munmap(void *ptr, size_t size) 66 + { 67 + if (ptr) { 68 + /* Unmap both the RAM block and the guard page */ 69 + munmap(ptr, size + getpagesize()); 70 + } 71 + }
+4 -24
util/oslib-posix.c
··· 72 72 #include <sys/sysctl.h> 73 73 #endif 74 74 75 + #include <qemu/mmap-alloc.h> 76 + 75 77 int qemu_get_thread_id(void) 76 78 { 77 79 #if defined(__linux__) ··· 128 130 void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment) 129 131 { 130 132 size_t align = QEMU_VMALLOC_ALIGN; 131 - size_t total = size + align; 132 - void *ptr = mmap(0, total, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); 133 - size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr; 134 - void *ptr1; 133 + void *ptr = qemu_ram_mmap(-1, size, align, false); 135 134 136 135 if (ptr == MAP_FAILED) { 137 136 return NULL; ··· 141 140 *alignment = align; 142 141 } 143 142 144 - ptr1 = mmap(ptr + offset, size, PROT_READ | PROT_WRITE, 145 - MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); 146 - if (ptr1 == MAP_FAILED) { 147 - munmap(ptr, total); 148 - return NULL; 149 - } 150 - 151 - ptr += offset; 152 - total -= offset; 153 - 154 - if (offset > 0) { 155 - munmap(ptr - offset, offset); 156 - } 157 - if (total > size + getpagesize()) { 158 - munmap(ptr + size + getpagesize(), total - size - getpagesize()); 159 - } 160 - 161 143 trace_qemu_anon_ram_alloc(size, ptr); 162 144 return ptr; 163 145 } ··· 171 153 void qemu_anon_ram_free(void *ptr, size_t size) 172 154 { 173 155 trace_qemu_anon_ram_free(ptr, size); 174 - if (ptr) { 175 - munmap(ptr, size + getpagesize()); 176 - } 156 + qemu_ram_munmap(ptr, size); 177 157 } 178 158 179 159 void qemu_set_block(int fd)