/root/src/xen/xen/include/asm/x86_64/system.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef __X86_64_SYSTEM_H__ |
2 | | #define __X86_64_SYSTEM_H__ |
3 | | |
4 | | #define cmpxchg(ptr,o,n) \ |
5 | 2.50M | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \ |
6 | 0 | (unsigned long)(n),sizeof(*(ptr)))) |
7 | | |
8 | | /* |
9 | | * Atomic 16 bytes compare and exchange. Compare OLD with MEM, if |
10 | | * identical, store NEW in MEM. Return the initial value in MEM. |
11 | | * Success is indicated by comparing RETURN with OLD. |
12 | | * |
13 | | * This function can only be called when cpu_has_cx16 is true. |
14 | | */ |
15 | | |
16 | | static always_inline __uint128_t __cmpxchg16b( |
17 | | volatile void *ptr, const __uint128_t *oldp, const __uint128_t *newp) |
18 | 177 | { |
19 | 177 | union { |
20 | 177 | struct { uint64_t lo, hi; }; |
21 | 177 | __uint128_t raw; |
22 | 177 | } new = { .raw = *newp }, old = { .raw = *oldp }, prev; |
23 | 177 | |
24 | 177 | ASSERT(cpu_has_cx16); |
25 | 177 | |
26 | 177 | /* Don't use "=A" here - clang can't deal with that. */ |
27 | 177 | asm volatile ( "lock; cmpxchg16b %2" |
28 | 177 | : "=d" (prev.hi), "=a" (prev.lo), "+m" (*__xg(ptr)) |
29 | 177 | : "c" (new.hi), "b" (new.lo), "0" (old.hi), "1" (old.lo) ); |
30 | 177 | |
31 | 177 | return prev.raw; |
32 | 177 | } Unexecuted instantiation: core_parking.c:__cmpxchg16b Unexecuted instantiation: cpu.c:__cmpxchg16b Unexecuted instantiation: cpupool.c:__cmpxchg16b Unexecuted instantiation: domctl.c:__cmpxchg16b Unexecuted instantiation: domain.c:__cmpxchg16b Unexecuted instantiation: event_2l.c:__cmpxchg16b Unexecuted instantiation: event_channel.c:__cmpxchg16b Unexecuted instantiation: event_fifo.c:__cmpxchg16b Unexecuted instantiation: grant_table.c:__cmpxchg16b Unexecuted instantiation: guestcopy.c:__cmpxchg16b Unexecuted instantiation: irq.c:__cmpxchg16b Unexecuted instantiation: kernel.c:__cmpxchg16b Unexecuted instantiation: keyhandler.c:__cmpxchg16b Unexecuted instantiation: kexec.c:__cmpxchg16b Unexecuted instantiation: kimage.c:__cmpxchg16b Unexecuted instantiation: mem_access.c:__cmpxchg16b Unexecuted instantiation: memory.c:__cmpxchg16b Unexecuted instantiation: monitor.c:__cmpxchg16b Unexecuted instantiation: multicall.c:__cmpxchg16b Unexecuted instantiation: notifier.c:__cmpxchg16b Unexecuted instantiation: page_alloc.c:__cmpxchg16b Unexecuted instantiation: pdx.c:__cmpxchg16b Unexecuted instantiation: preempt.c:__cmpxchg16b Unexecuted instantiation: rangeset.c:__cmpxchg16b Unexecuted instantiation: radix-tree.c:__cmpxchg16b Unexecuted instantiation: rcupdate.c:__cmpxchg16b Unexecuted instantiation: rwlock.c:__cmpxchg16b Unexecuted instantiation: sched_arinc653.c:__cmpxchg16b Unexecuted instantiation: sched_credit.c:__cmpxchg16b Unexecuted instantiation: sched_credit2.c:__cmpxchg16b Unexecuted instantiation: sched_rt.c:__cmpxchg16b Unexecuted instantiation: sched_null.c:__cmpxchg16b Unexecuted instantiation: schedule.c:__cmpxchg16b Unexecuted instantiation: shutdown.c:__cmpxchg16b Unexecuted instantiation: softirq.c:__cmpxchg16b Unexecuted instantiation: smp.c:__cmpxchg16b Unexecuted instantiation: spinlock.c:__cmpxchg16b Unexecuted instantiation: stop_machine.c:__cmpxchg16b Unexecuted instantiation: symbols.c:__cmpxchg16b Unexecuted instantiation: sysctl.c:__cmpxchg16b Unexecuted instantiation: tasklet.c:__cmpxchg16b Unexecuted instantiation: time.c:__cmpxchg16b Unexecuted instantiation: timer.c:__cmpxchg16b Unexecuted instantiation: trace.c:__cmpxchg16b Unexecuted instantiation: virtual_region.c:__cmpxchg16b Unexecuted instantiation: vm_event.c:__cmpxchg16b Unexecuted instantiation: vmap.c:__cmpxchg16b Unexecuted instantiation: vsprintf.c:__cmpxchg16b Unexecuted instantiation: wait.c:__cmpxchg16b Unexecuted instantiation: xenoprof.c:__cmpxchg16b Unexecuted instantiation: xmalloc_tlsf.c:__cmpxchg16b Unexecuted instantiation: tmem.c:__cmpxchg16b Unexecuted instantiation: tmem_xen.c:__cmpxchg16b Unexecuted instantiation: tmem_control.c:__cmpxchg16b Unexecuted instantiation: llvm.c:__cmpxchg16b Unexecuted instantiation: libelf-loader.c:__cmpxchg16b Unexecuted instantiation: console.c:__cmpxchg16b Unexecuted instantiation: ns16550.c:__cmpxchg16b Unexecuted instantiation: ehci-dbgp.c:__cmpxchg16b Unexecuted instantiation: serial.c:__cmpxchg16b Unexecuted instantiation: cpufreq.c:__cmpxchg16b Unexecuted instantiation: cpufreq_ondemand.c:__cmpxchg16b Unexecuted instantiation: cpufreq_misc_governors.c:__cmpxchg16b Unexecuted instantiation: utility.c:__cmpxchg16b Unexecuted instantiation: pci.c:__cmpxchg16b Unexecuted instantiation: vpci.c:__cmpxchg16b Unexecuted instantiation: header.c:__cmpxchg16b Unexecuted instantiation: msi.c:__cmpxchg16b Unexecuted instantiation: msix.c:__cmpxchg16b Unexecuted instantiation: iommu.c:__cmpxchg16b Unexecuted instantiation: io.c:__cmpxchg16b Unexecuted instantiation: dmar.c:__cmpxchg16b Unexecuted instantiation: utils.c:__cmpxchg16b Unexecuted instantiation: qinval.c:__cmpxchg16b Line | Count | Source | 18 | 177 | { | 19 | 177 | union { | 20 | 177 | struct { uint64_t lo, hi; }; | 21 | 177 | __uint128_t raw; | 22 | 177 | } new = { .raw = *newp }, old = { .raw = *oldp }, prev; | 23 | 177 | | 24 | 177 | ASSERT(cpu_has_cx16); | 25 | 177 | | 26 | 177 | /* Don't use "=A" here - clang can't deal with that. */ | 27 | 177 | asm volatile ( "lock; cmpxchg16b %2" | 28 | 177 | : "=d" (prev.hi), "=a" (prev.lo), "+m" (*__xg(ptr)) | 29 | 177 | : "c" (new.hi), "b" (new.lo), "0" (old.hi), "1" (old.lo) ); | 30 | 177 | | 31 | 177 | return prev.raw; | 32 | 177 | } |
Unexecuted instantiation: quirks.c:__cmpxchg16b Unexecuted instantiation: vtd.c:__cmpxchg16b Unexecuted instantiation: ats.c:__cmpxchg16b Unexecuted instantiation: iommu_init.c:__cmpxchg16b Unexecuted instantiation: iommu_map.c:__cmpxchg16b Unexecuted instantiation: pci_amd_iommu.c:__cmpxchg16b Unexecuted instantiation: iommu_intr.c:__cmpxchg16b Unexecuted instantiation: iommu_cmd.c:__cmpxchg16b Unexecuted instantiation: iommu_guest.c:__cmpxchg16b Unexecuted instantiation: numa.c:__cmpxchg16b Unexecuted instantiation: osl.c:__cmpxchg16b Unexecuted instantiation: pmstat.c:__cmpxchg16b Unexecuted instantiation: hwregs.c:__cmpxchg16b Unexecuted instantiation: reboot.c:__cmpxchg16b Unexecuted instantiation: tbutils.c:__cmpxchg16b Unexecuted instantiation: utglobal.c:__cmpxchg16b Unexecuted instantiation: erst.c:__cmpxchg16b Unexecuted instantiation: hest.c:__cmpxchg16b Unexecuted instantiation: apei-base.c:__cmpxchg16b Unexecuted instantiation: apei-io.c:__cmpxchg16b Unexecuted instantiation: vga.c:__cmpxchg16b Unexecuted instantiation: vesa.c:__cmpxchg16b Unexecuted instantiation: xsm_core.c:__cmpxchg16b Unexecuted instantiation: apic.c:__cmpxchg16b Unexecuted instantiation: cpuid.c:__cmpxchg16b Unexecuted instantiation: compat.c:__cmpxchg16b Unexecuted instantiation: crash.c:__cmpxchg16b Unexecuted instantiation: debug.c:__cmpxchg16b Unexecuted instantiation: domain_page.c:__cmpxchg16b Unexecuted instantiation: e820.c:__cmpxchg16b Unexecuted instantiation: extable.c:__cmpxchg16b Unexecuted instantiation: flushtlb.c:__cmpxchg16b Unexecuted instantiation: hypercall.c:__cmpxchg16b Unexecuted instantiation: i387.c:__cmpxchg16b Unexecuted instantiation: i8259.c:__cmpxchg16b Unexecuted instantiation: io_apic.c:__cmpxchg16b Unexecuted instantiation: msr.c:__cmpxchg16b Unexecuted instantiation: ioport_emulate.c:__cmpxchg16b Unexecuted instantiation: machine_kexec.c:__cmpxchg16b Unexecuted instantiation: microcode_amd.c:__cmpxchg16b Unexecuted instantiation: microcode_intel.c:__cmpxchg16b Unexecuted instantiation: microcode.c:__cmpxchg16b Unexecuted instantiation: mm.c:__cmpxchg16b Unexecuted instantiation: mpparse.c:__cmpxchg16b Unexecuted instantiation: nmi.c:__cmpxchg16b Unexecuted instantiation: percpu.c:__cmpxchg16b Unexecuted instantiation: physdev.c:__cmpxchg16b Unexecuted instantiation: platform_hypercall.c:__cmpxchg16b Unexecuted instantiation: psr.c:__cmpxchg16b Unexecuted instantiation: setup.c:__cmpxchg16b Unexecuted instantiation: smpboot.c:__cmpxchg16b Unexecuted instantiation: srat.c:__cmpxchg16b Unexecuted instantiation: traps.c:__cmpxchg16b Unexecuted instantiation: usercopy.c:__cmpxchg16b Unexecuted instantiation: x86_emulate.c:__cmpxchg16b Unexecuted instantiation: tboot.c:__cmpxchg16b Unexecuted instantiation: hpet.c:__cmpxchg16b Unexecuted instantiation: xstate.c:__cmpxchg16b Unexecuted instantiation: lib.c:__cmpxchg16b Unexecuted instantiation: power.c:__cmpxchg16b Unexecuted instantiation: suspend.c:__cmpxchg16b Unexecuted instantiation: cpu_idle.c:__cmpxchg16b Unexecuted instantiation: cpuidle_menu.c:__cmpxchg16b Unexecuted instantiation: powernow.c:__cmpxchg16b Unexecuted instantiation: amd.c:__cmpxchg16b Unexecuted instantiation: common.c:__cmpxchg16b Unexecuted instantiation: intel.c:__cmpxchg16b Unexecuted instantiation: mwait-idle.c:__cmpxchg16b Unexecuted instantiation: vpmu.c:__cmpxchg16b Unexecuted instantiation: vpmu_amd.c:__cmpxchg16b Unexecuted instantiation: vpmu_intel.c:__cmpxchg16b Unexecuted instantiation: amd_nonfatal.c:__cmpxchg16b Unexecuted instantiation: mce_amd.c:__cmpxchg16b Unexecuted instantiation: mcaction.c:__cmpxchg16b Unexecuted instantiation: barrier.c:__cmpxchg16b Unexecuted instantiation: mctelem.c:__cmpxchg16b Unexecuted instantiation: mce.c:__cmpxchg16b Unexecuted instantiation: mce-apei.c:__cmpxchg16b Unexecuted instantiation: mce_intel.c:__cmpxchg16b Unexecuted instantiation: non-fatal.c:__cmpxchg16b Unexecuted instantiation: util.c:__cmpxchg16b Unexecuted instantiation: vmce.c:__cmpxchg16b Unexecuted instantiation: generic.c:__cmpxchg16b Unexecuted instantiation: main.c:__cmpxchg16b Unexecuted instantiation: bigsmp.c:__cmpxchg16b Unexecuted instantiation: x2apic.c:__cmpxchg16b Unexecuted instantiation: default.c:__cmpxchg16b Unexecuted instantiation: delivery.c:__cmpxchg16b Unexecuted instantiation: probe.c:__cmpxchg16b Unexecuted instantiation: asid.c:__cmpxchg16b Unexecuted instantiation: dm.c:__cmpxchg16b Unexecuted instantiation: emulate.c:__cmpxchg16b Unexecuted instantiation: hvm.c:__cmpxchg16b Unexecuted instantiation: i8254.c:__cmpxchg16b Unexecuted instantiation: intercept.c:__cmpxchg16b Unexecuted instantiation: ioreq.c:__cmpxchg16b Unexecuted instantiation: mtrr.c:__cmpxchg16b Unexecuted instantiation: nestedhvm.c:__cmpxchg16b Unexecuted instantiation: pmtimer.c:__cmpxchg16b Unexecuted instantiation: rtc.c:__cmpxchg16b Unexecuted instantiation: save.c:__cmpxchg16b Unexecuted instantiation: stdvga.c:__cmpxchg16b Unexecuted instantiation: vioapic.c:__cmpxchg16b Unexecuted instantiation: viridian.c:__cmpxchg16b Unexecuted instantiation: vlapic.c:__cmpxchg16b Unexecuted instantiation: vmsi.c:__cmpxchg16b Unexecuted instantiation: vpic.c:__cmpxchg16b Unexecuted instantiation: vpt.c:__cmpxchg16b Unexecuted instantiation: intr.c:__cmpxchg16b Unexecuted instantiation: nestedsvm.c:__cmpxchg16b Unexecuted instantiation: svm.c:__cmpxchg16b Unexecuted instantiation: svmdebug.c:__cmpxchg16b Unexecuted instantiation: vmcb.c:__cmpxchg16b Unexecuted instantiation: realmode.c:__cmpxchg16b Unexecuted instantiation: vmcs.c:__cmpxchg16b Unexecuted instantiation: vmx.c:__cmpxchg16b Unexecuted instantiation: vvmx.c:__cmpxchg16b Unexecuted instantiation: paging.c:__cmpxchg16b Unexecuted instantiation: p2m.c:__cmpxchg16b Unexecuted instantiation: p2m-pt.c:__cmpxchg16b Unexecuted instantiation: p2m-ept.c:__cmpxchg16b Unexecuted instantiation: p2m-pod.c:__cmpxchg16b Unexecuted instantiation: altp2m.c:__cmpxchg16b Unexecuted instantiation: guest_walk.c:__cmpxchg16b Unexecuted instantiation: mem_paging.c:__cmpxchg16b Unexecuted instantiation: mem_sharing.c:__cmpxchg16b Unexecuted instantiation: multi.c:__cmpxchg16b Unexecuted instantiation: hap.c:__cmpxchg16b Unexecuted instantiation: nested_hap.c:__cmpxchg16b Unexecuted instantiation: nested_ept.c:__cmpxchg16b Unexecuted instantiation: nmi_int.c:__cmpxchg16b Unexecuted instantiation: op_model_p4.c:__cmpxchg16b Unexecuted instantiation: op_model_ppro.c:__cmpxchg16b Unexecuted instantiation: op_model_athlon.c:__cmpxchg16b Unexecuted instantiation: backtrace.c:__cmpxchg16b Unexecuted instantiation: callback.c:__cmpxchg16b Unexecuted instantiation: descriptor-tables.c:__cmpxchg16b Unexecuted instantiation: emul-gate-op.c:__cmpxchg16b Unexecuted instantiation: emul-inv-op.c:__cmpxchg16b Unexecuted instantiation: emul-priv-op.c:__cmpxchg16b Unexecuted instantiation: iret.c:__cmpxchg16b Unexecuted instantiation: misc-hypercalls.c:__cmpxchg16b Unexecuted instantiation: ro-page-fault.c:__cmpxchg16b Unexecuted instantiation: acpi_mmcfg.c:__cmpxchg16b Unexecuted instantiation: mmconf-fam10h.c:__cmpxchg16b Unexecuted instantiation: mmconfig_64.c:__cmpxchg16b Unexecuted instantiation: mmconfig-shared.c:__cmpxchg16b |
33 | | |
34 | 177 | #define cmpxchg16b(ptr, o, n) ({ \ |
35 | 177 | volatile void *_p = (ptr); \ |
36 | 177 | ASSERT(!((unsigned long)_p & 0xf)); \ |
37 | 177 | BUILD_BUG_ON(sizeof(*(o)) != sizeof(__uint128_t)); \ |
38 | 177 | BUILD_BUG_ON(sizeof(*(n)) != sizeof(__uint128_t)); \ |
39 | 177 | __cmpxchg16b(_p, (void *)(o), (void *)(n)); \ |
40 | 177 | }) |
41 | | |
42 | | /* |
43 | | * This function causes value _o to be changed to _n at location _p. |
44 | | * If this access causes a fault then we return 1, otherwise we return 0. |
45 | | * If no fault occurs then _o is updated to the value we saw at _p. If this |
46 | | * is the same as the initial value of _o then _n is written to location _p. |
47 | | */ |
48 | | #define __cmpxchg_user(_p,_o,_n,_isuff,_oppre,_regtype) \ |
49 | 0 | stac(); \ |
50 | 0 | asm volatile ( \ |
51 | 0 | "1: lock; cmpxchg"_isuff" %"_oppre"2,%3\n" \ |
52 | 0 | "2:\n" \ |
53 | 0 | ".section .fixup,\"ax\"\n" \ |
54 | 0 | "3: movl $1,%1\n" \ |
55 | 0 | " jmp 2b\n" \ |
56 | 0 | ".previous\n" \ |
57 | 0 | _ASM_EXTABLE(1b, 3b) \ |
58 | 0 | : "=a" (_o), "=r" (_rc) \ |
59 | 0 | : _regtype (_n), "m" (*__xg((volatile void *)_p)), "0" (_o), "1" (0) \ |
60 | 0 | : "memory"); \ |
61 | 0 | clac() |
62 | | |
63 | 0 | #define cmpxchg_user(_p,_o,_n) \ |
64 | 0 | ({ \ |
65 | 0 | int _rc; \ |
66 | 0 | switch ( sizeof(*(_p)) ) { \ |
67 | 0 | case 1: \ |
68 | 0 | __cmpxchg_user(_p,_o,_n,"b","b","q"); \ |
69 | 0 | break; \ |
70 | 0 | case 2: \ |
71 | 0 | __cmpxchg_user(_p,_o,_n,"w","w","r"); \ |
72 | 0 | break; \ |
73 | 0 | case 4: \ |
74 | 0 | __cmpxchg_user(_p,_o,_n,"l","k","r"); \ |
75 | 0 | break; \ |
76 | 0 | case 8: \ |
77 | 0 | __cmpxchg_user(_p,_o,_n,"q","","r"); \ |
78 | 0 | break; \ |
79 | 0 | } \ |
80 | 0 | _rc; \ |
81 | 0 | }) |
82 | | |
83 | | #define mb() \ |
84 | 8.94M | asm volatile ( "mfence" : : : "memory" ) |
85 | | |
86 | | #endif /* __X86_64_SYSTEM_H__ */ |