Import QEMU upstream snapshot d2e570c
Upstream: https://gitlab.com/qemu-project/qemu.git Upstream-Commit: d2e570cc0f97b936902a5b1b86b73c0f5998b475
This commit is contained in:
commit
cf256aa081
11315 files changed
+3598369
No files matched your search
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* host-signal.h: signal info dependent on the host architecture
|
||||
*
|
||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||
* Copyright (c) 2021 Linaro Limited
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef AARCH64_HOST_SIGNAL_H
|
||||
#define AARCH64_HOST_SIGNAL_H
|
||||
|
||||
/* The third argument to a SA_SIGINFO handler is ucontext_t. */
|
||||
typedef ucontext_t host_sigcontext;
|
||||
|
||||
/* Pre-3.16 kernel headers don't have these, so provide fallback definitions */
|
||||
#ifndef ESR_MAGIC
|
||||
#define ESR_MAGIC 0x45535201
|
||||
struct esr_context {
|
||||
struct _aarch64_ctx head;
|
||||
uint64_t esr;
|
||||
};
|
||||
#endif
|
||||
|
||||
static inline struct _aarch64_ctx *first_ctx(host_sigcontext *uc)
|
||||
{
|
||||
return (struct _aarch64_ctx *)&uc->uc_mcontext.__reserved;
|
||||
}
|
||||
|
||||
static inline struct _aarch64_ctx *next_ctx(struct _aarch64_ctx *hdr)
|
||||
{
|
||||
return (struct _aarch64_ctx *)((char *)hdr + hdr->size);
|
||||
}
|
||||
|
||||
static inline uintptr_t host_signal_pc(host_sigcontext *uc)
|
||||
{
|
||||
return uc->uc_mcontext.pc;
|
||||
}
|
||||
|
||||
static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
|
||||
{
|
||||
uc->uc_mcontext.pc = pc;
|
||||
}
|
||||
|
||||
static inline void *host_signal_mask(host_sigcontext *uc)
|
||||
{
|
||||
return &uc->uc_sigmask;
|
||||
}
|
||||
|
||||
static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
|
||||
{
|
||||
struct _aarch64_ctx *hdr;
|
||||
uint32_t insn;
|
||||
|
||||
/* Find the esr_context, which has the WnR bit in it */
|
||||
for (hdr = first_ctx(uc); hdr->magic; hdr = next_ctx(hdr)) {
|
||||
if (hdr->magic == ESR_MAGIC) {
|
||||
struct esr_context const *ec = (struct esr_context const *)hdr;
|
||||
uint64_t esr = ec->esr;
|
||||
|
||||
/* For data aborts ESR.EC is 0b10010x: then bit 6 is the WnR bit */
|
||||
return extract32(esr, 27, 5) == 0x12 && extract32(esr, 6, 1) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fall back to parsing instructions; will only be needed
|
||||
* for really ancient (pre-3.16) kernels.
|
||||
*/
|
||||
insn = *(uint32_t *)host_signal_pc(uc);
|
||||
|
||||
return (insn & 0xbfff0000) == 0x0c000000 /* C3.3.1 */
|
||||
|| (insn & 0xbfe00000) == 0x0c800000 /* C3.3.2 */
|
||||
|| (insn & 0xbfdf0000) == 0x0d000000 /* C3.3.3 */
|
||||
|| (insn & 0xbfc00000) == 0x0d800000 /* C3.3.4 */
|
||||
|| (insn & 0x3f400000) == 0x08000000 /* C3.3.6 */
|
||||
|| (insn & 0x3bc00000) == 0x39000000 /* C3.3.13 */
|
||||
|| (insn & 0x3fc00000) == 0x3d800000 /* ... 128bit */
|
||||
/* Ignore bits 10, 11 & 21, controlling indexing. */
|
||||
|| (insn & 0x3bc00000) == 0x38000000 /* C3.3.8-12 */
|
||||
|| (insn & 0x3fe00000) == 0x3c800000 /* ... 128bit */
|
||||
/* Ignore bits 23 & 24, controlling indexing. */
|
||||
|| (insn & 0x3a400000) == 0x28000000; /* C3.3.7,14-16 */
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* host-signal.h: signal info dependent on the host architecture
|
||||
*
|
||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||
* Copyright (c) 2021 WANG Xuerui <[email protected]>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef LOONGARCH64_HOST_SIGNAL_H
|
||||
#define LOONGARCH64_HOST_SIGNAL_H
|
||||
|
||||
/* The third argument to a SA_SIGINFO handler is ucontext_t. */
|
||||
typedef ucontext_t host_sigcontext;
|
||||
|
||||
static inline uintptr_t host_signal_pc(host_sigcontext *uc)
|
||||
{
|
||||
return uc->uc_mcontext.__pc;
|
||||
}
|
||||
|
||||
static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
|
||||
{
|
||||
uc->uc_mcontext.__pc = pc;
|
||||
}
|
||||
|
||||
static inline void *host_signal_mask(host_sigcontext *uc)
|
||||
{
|
||||
return &uc->uc_sigmask;
|
||||
}
|
||||
|
||||
static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
|
||||
{
|
||||
const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc);
|
||||
uint32_t insn = pinsn[0];
|
||||
|
||||
/* Detect store by reading the instruction at the program counter. */
|
||||
switch ((insn >> 26) & 0b111111) {
|
||||
case 0b001000: /* {ll,sc}.[wd] */
|
||||
switch ((insn >> 24) & 0b11) {
|
||||
case 0b01: /* sc.w */
|
||||
case 0b11: /* sc.d */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0b001001: /* {ld,st}ox4.[wd] ({ld,st}ptr.[wd]) */
|
||||
switch ((insn >> 24) & 0b11) {
|
||||
case 0b01: /* stox4.w (stptr.w) */
|
||||
case 0b11: /* stox4.d (stptr.d) */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0b001010: /* {ld,st}.* family */
|
||||
switch ((insn >> 22) & 0b1111) {
|
||||
case 0b0100: /* st.b */
|
||||
case 0b0101: /* st.h */
|
||||
case 0b0110: /* st.w */
|
||||
case 0b0111: /* st.d */
|
||||
case 0b1101: /* fst.s */
|
||||
case 0b1111: /* fst.d */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0b001110: /* indexed, atomic, bounds-checking memory operations */
|
||||
switch ((insn >> 15) & 0b11111111111) {
|
||||
case 0b00000100000: /* stx.b */
|
||||
case 0b00000101000: /* stx.h */
|
||||
case 0b00000110000: /* stx.w */
|
||||
case 0b00000111000: /* stx.d */
|
||||
case 0b00001110000: /* fstx.s */
|
||||
case 0b00001111000: /* fstx.d */
|
||||
case 0b00011101100: /* fstgt.s */
|
||||
case 0b00011101101: /* fstgt.d */
|
||||
case 0b00011101110: /* fstle.s */
|
||||
case 0b00011101111: /* fstle.d */
|
||||
case 0b00011111000: /* stgt.b */
|
||||
case 0b00011111001: /* stgt.h */
|
||||
case 0b00011111010: /* stgt.w */
|
||||
case 0b00011111011: /* stgt.d */
|
||||
case 0b00011111100: /* stle.b */
|
||||
case 0b00011111101: /* stle.h */
|
||||
case 0b00011111110: /* stle.w */
|
||||
case 0b00011111111: /* stle.d */
|
||||
case 0b00011000000 ... 0b00011100011: /* am* insns */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* host-signal.h: signal info dependent on the host architecture
|
||||
*
|
||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||
* Copyright (c) 2021 Linaro Limited
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef PPC_HOST_SIGNAL_H
|
||||
#define PPC_HOST_SIGNAL_H
|
||||
|
||||
/* Needed for PT_* constants */
|
||||
#include <asm/ptrace.h>
|
||||
|
||||
/* The third argument to a SA_SIGINFO handler is ucontext_t. */
|
||||
typedef ucontext_t host_sigcontext;
|
||||
|
||||
static inline uintptr_t host_signal_pc(host_sigcontext *uc)
|
||||
{
|
||||
return uc->uc_mcontext.gp_regs[PT_NIP];
|
||||
}
|
||||
|
||||
static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
|
||||
{
|
||||
uc->uc_mcontext.gp_regs[PT_NIP] = pc;
|
||||
}
|
||||
|
||||
static inline void *host_signal_mask(host_sigcontext *uc)
|
||||
{
|
||||
return &uc->uc_sigmask;
|
||||
}
|
||||
|
||||
static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
|
||||
{
|
||||
return uc->uc_mcontext.gp_regs[PT_TRAP] != 0x400
|
||||
&& (uc->uc_mcontext.gp_regs[PT_DSISR] & 0x02000000);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* host-signal.h: signal info dependent on the host architecture
|
||||
*
|
||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||
* Copyright (c) 2021 Linaro Limited
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef RISCV_HOST_SIGNAL_H
|
||||
#define RISCV_HOST_SIGNAL_H
|
||||
|
||||
/* The third argument to a SA_SIGINFO handler is ucontext_t. */
|
||||
typedef ucontext_t host_sigcontext;
|
||||
|
||||
static inline uintptr_t host_signal_pc(host_sigcontext *uc)
|
||||
{
|
||||
return uc->uc_mcontext.__gregs[REG_PC];
|
||||
}
|
||||
|
||||
static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
|
||||
{
|
||||
uc->uc_mcontext.__gregs[REG_PC] = pc;
|
||||
}
|
||||
|
||||
static inline void *host_signal_mask(host_sigcontext *uc)
|
||||
{
|
||||
return &uc->uc_sigmask;
|
||||
}
|
||||
|
||||
static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
|
||||
{
|
||||
/*
|
||||
* Detect store by reading the instruction at the program counter.
|
||||
* Do not read more than 16 bits, because we have not yet determined
|
||||
* the size of the instruction.
|
||||
*/
|
||||
const uint16_t *pinsn = (const uint16_t *)host_signal_pc(uc);
|
||||
uint16_t insn = pinsn[0];
|
||||
|
||||
/* 16-bit instructions */
|
||||
switch (insn & 0xe003) {
|
||||
case 0xa000: /* c.fsd */
|
||||
case 0xc000: /* c.sw */
|
||||
case 0xe000: /* c.sd (rv64) / c.fsw (rv32) */
|
||||
case 0xa002: /* c.fsdsp */
|
||||
case 0xc002: /* c.swsp */
|
||||
case 0xe002: /* c.sdsp (rv64) / c.fswsp (rv32) */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 32-bit instructions, major opcodes */
|
||||
switch (insn & 0x7f) {
|
||||
case 0x23: /* store */
|
||||
case 0x27: /* store-fp */
|
||||
return true;
|
||||
case 0x2f: /* amo */
|
||||
/*
|
||||
* The AMO function code is in bits 25-31, unread as yet.
|
||||
* The AMO functions are LR (read), SC (write), and the
|
||||
* rest are all read-modify-write.
|
||||
*/
|
||||
insn = pinsn[1];
|
||||
return (insn >> 11) != 2; /* LR */
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* host-signal.h: signal info dependent on the host architecture
|
||||
*
|
||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||
* Copyright (c) 2021 Linaro Limited
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef S390_HOST_SIGNAL_H
|
||||
#define S390_HOST_SIGNAL_H
|
||||
|
||||
/* The third argument to a SA_SIGINFO handler is ucontext_t. */
|
||||
typedef ucontext_t host_sigcontext;
|
||||
|
||||
static inline uintptr_t host_signal_pc(host_sigcontext *uc)
|
||||
{
|
||||
return uc->uc_mcontext.psw.addr;
|
||||
}
|
||||
|
||||
static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
|
||||
{
|
||||
uc->uc_mcontext.psw.addr = pc;
|
||||
}
|
||||
|
||||
static inline void *host_signal_mask(host_sigcontext *uc)
|
||||
{
|
||||
return &uc->uc_sigmask;
|
||||
}
|
||||
|
||||
static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
|
||||
{
|
||||
uint16_t *pinsn = (uint16_t *)host_signal_pc(uc);
|
||||
|
||||
/*
|
||||
* ??? On linux, the non-rt signal handler has 4 (!) arguments instead
|
||||
* of the normal 2 arguments. The 4th argument contains the "Translation-
|
||||
* Exception Identification for DAT Exceptions" from the hardware (aka
|
||||
* "int_parm_long"), which does in fact contain the is_write value.
|
||||
* The rt signal handler, as far as I can tell, does not give this value
|
||||
* at all. Not that we could get to it from here even if it were.
|
||||
* So fall back to parsing instructions. Treat read-modify-write ones as
|
||||
* writes, which is not fully correct, but for tracking self-modifying code
|
||||
* this is better than treating them as reads. Checking si_addr page flags
|
||||
* might be a viable improvement, albeit a racy one.
|
||||
*/
|
||||
/* ??? This is not even close to complete. */
|
||||
switch (pinsn[0] >> 8) {
|
||||
case 0x50: /* ST */
|
||||
case 0x42: /* STC */
|
||||
case 0x40: /* STH */
|
||||
case 0x44: /* EX */
|
||||
case 0xba: /* CS */
|
||||
case 0xbb: /* CDS */
|
||||
return true;
|
||||
case 0xc4: /* RIL format insns */
|
||||
switch (pinsn[0] & 0xf) {
|
||||
case 0xf: /* STRL */
|
||||
case 0xb: /* STGRL */
|
||||
case 0x7: /* STHRL */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0xc6: /* RIL-b format insns */
|
||||
switch (pinsn[0] & 0xf) {
|
||||
case 0x0: /* EXRL */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0xc8: /* SSF format insns */
|
||||
switch (pinsn[0] & 0xf) {
|
||||
case 0x2: /* CSST */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0xe3: /* RXY format insns */
|
||||
switch (pinsn[2] & 0xff) {
|
||||
case 0x50: /* STY */
|
||||
case 0x24: /* STG */
|
||||
case 0x72: /* STCY */
|
||||
case 0x70: /* STHY */
|
||||
case 0x8e: /* STPQ */
|
||||
case 0x3f: /* STRVH */
|
||||
case 0x3e: /* STRV */
|
||||
case 0x2f: /* STRVG */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0xe6:
|
||||
switch (pinsn[2] & 0xff) {
|
||||
case 0x09: /* VSTEBRH */
|
||||
case 0x0a: /* VSTEBRG */
|
||||
case 0x0b: /* VSTEBRF */
|
||||
case 0x0e: /* VSTBR */
|
||||
case 0x0f: /* VSTER */
|
||||
case 0x3f: /* VSTRLR */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0xe7:
|
||||
switch (pinsn[2] & 0xff) {
|
||||
case 0x08: /* VSTEB */
|
||||
case 0x09: /* VSTEH */
|
||||
case 0x0a: /* VSTEG */
|
||||
case 0x0b: /* VSTEF */
|
||||
case 0x0e: /* VST */
|
||||
case 0x1a: /* VSCEG */
|
||||
case 0x1b: /* VSCEF */
|
||||
case 0x3e: /* VSTM */
|
||||
case 0x3f: /* VSTL */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0xeb: /* RSY format insns */
|
||||
switch (pinsn[2] & 0xff) {
|
||||
case 0x14: /* CSY */
|
||||
case 0x30: /* CSG */
|
||||
case 0x31: /* CDSY */
|
||||
case 0x3e: /* CDSG */
|
||||
case 0xe4: /* LANG */
|
||||
case 0xe6: /* LAOG */
|
||||
case 0xe7: /* LAXG */
|
||||
case 0xe8: /* LAAG */
|
||||
case 0xea: /* LAALG */
|
||||
case 0xf4: /* LAN */
|
||||
case 0xf6: /* LAO */
|
||||
case 0xf7: /* LAX */
|
||||
case 0xfa: /* LAAL */
|
||||
case 0xf8: /* LAA */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* host-signal.h: signal info dependent on the host architecture
|
||||
*
|
||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||
* Copyright (c) 2021 Linaro Limited
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef SPARC64_HOST_SIGNAL_H
|
||||
#define SPARC64_HOST_SIGNAL_H
|
||||
|
||||
/* The third argument to a SA_SIGINFO handler is struct sigcontext. */
|
||||
typedef struct sigcontext host_sigcontext;
|
||||
|
||||
static inline uintptr_t host_signal_pc(host_sigcontext *sc)
|
||||
{
|
||||
return sc->sigc_regs.tpc;
|
||||
}
|
||||
|
||||
static inline void host_signal_set_pc(host_sigcontext *sc, uintptr_t pc)
|
||||
{
|
||||
sc->sigc_regs.tpc = pc;
|
||||
sc->sigc_regs.tnpc = pc + 4;
|
||||
}
|
||||
|
||||
static inline void *host_signal_mask(host_sigcontext *sc)
|
||||
{
|
||||
return &sc->sigc_mask;
|
||||
}
|
||||
|
||||
static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
|
||||
{
|
||||
uint32_t insn = *(uint32_t *)host_signal_pc(uc);
|
||||
|
||||
if ((insn >> 30) == 3) {
|
||||
switch ((insn >> 19) & 0x3f) {
|
||||
case 0x05: /* stb */
|
||||
case 0x15: /* stba */
|
||||
case 0x06: /* sth */
|
||||
case 0x16: /* stha */
|
||||
case 0x04: /* st */
|
||||
case 0x14: /* sta */
|
||||
case 0x07: /* std */
|
||||
case 0x17: /* stda */
|
||||
case 0x0e: /* stx */
|
||||
case 0x1e: /* stxa */
|
||||
case 0x24: /* stf */
|
||||
case 0x34: /* stfa */
|
||||
case 0x27: /* stdf */
|
||||
case 0x37: /* stdfa */
|
||||
case 0x26: /* stqf */
|
||||
case 0x36: /* stqfa */
|
||||
case 0x25: /* stfsr */
|
||||
case 0x3c: /* casa */
|
||||
case 0x3e: /* casxa */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* host-signal.h: signal info dependent on the host architecture
|
||||
*
|
||||
* Copyright (C) 2021 Linaro Limited
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef X86_64_HOST_SIGNAL_H
|
||||
#define X86_64_HOST_SIGNAL_H
|
||||
|
||||
/* The third argument to a SA_SIGINFO handler is ucontext_t. */
|
||||
typedef ucontext_t host_sigcontext;
|
||||
|
||||
static inline uintptr_t host_signal_pc(host_sigcontext *uc)
|
||||
{
|
||||
return uc->uc_mcontext.gregs[REG_RIP];
|
||||
}
|
||||
|
||||
static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
|
||||
{
|
||||
uc->uc_mcontext.gregs[REG_RIP] = pc;
|
||||
}
|
||||
|
||||
static inline void *host_signal_mask(host_sigcontext *uc)
|
||||
{
|
||||
return &uc->uc_sigmask;
|
||||
}
|
||||
|
||||
static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
|
||||
{
|
||||
return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
|
||||
&& (uc->uc_mcontext.gregs[REG_ERR] & 0x2);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user