|
@@ -19,18 +19,12 @@
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/osdep.h"
|
|
#include "qapi/error.h"
|
|
#include "qapi/error.h"
|
|
-
|
|
|
|
-#include "exec/target_page.h"
|
|
|
|
-#include "exec/page-protection.h"
|
|
|
|
#include "hw/qdev-core.h"
|
|
#include "hw/qdev-core.h"
|
|
#include "hw/qdev-properties.h"
|
|
#include "hw/qdev-properties.h"
|
|
#include "qemu/error-report.h"
|
|
#include "qemu/error-report.h"
|
|
#include "qemu/qemu-print.h"
|
|
#include "qemu/qemu-print.h"
|
|
#include "migration/vmstate.h"
|
|
#include "migration/vmstate.h"
|
|
-#ifdef CONFIG_USER_ONLY
|
|
|
|
-#include "qemu.h"
|
|
|
|
-#include "user/page-protection.h"
|
|
|
|
-#else
|
|
|
|
|
|
+#ifndef CONFIG_USER_ONLY
|
|
#include "hw/core/sysemu-cpu-ops.h"
|
|
#include "hw/core/sysemu-cpu-ops.h"
|
|
#include "exec/address-spaces.h"
|
|
#include "exec/address-spaces.h"
|
|
#include "exec/memory.h"
|
|
#include "exec/memory.h"
|
|
@@ -43,11 +37,11 @@
|
|
#include "exec/cpu-common.h"
|
|
#include "exec/cpu-common.h"
|
|
#include "exec/exec-all.h"
|
|
#include "exec/exec-all.h"
|
|
#include "exec/tb-flush.h"
|
|
#include "exec/tb-flush.h"
|
|
-#include "exec/translation-block.h"
|
|
|
|
#include "exec/log.h"
|
|
#include "exec/log.h"
|
|
#include "accel/accel-cpu-target.h"
|
|
#include "accel/accel-cpu-target.h"
|
|
#include "trace/trace-root.h"
|
|
#include "trace/trace-root.h"
|
|
#include "qemu/accel.h"
|
|
#include "qemu/accel.h"
|
|
|
|
+#include "hw/core/cpu.h"
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
#ifndef CONFIG_USER_ONLY
|
|
static int cpu_common_post_load(void *opaque, int version_id)
|
|
static int cpu_common_post_load(void *opaque, int version_id)
|
|
@@ -367,86 +361,6 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
|
|
abort();
|
|
abort();
|
|
}
|
|
}
|
|
|
|
|
|
-/* physical memory access (slow version, mainly for debug) */
|
|
|
|
-#if defined(CONFIG_USER_ONLY)
|
|
|
|
-int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
|
|
|
|
- void *ptr, size_t len, bool is_write)
|
|
|
|
-{
|
|
|
|
- int flags;
|
|
|
|
- vaddr l, page;
|
|
|
|
- uint8_t *buf = ptr;
|
|
|
|
- ssize_t written;
|
|
|
|
- int ret = -1;
|
|
|
|
- int fd = -1;
|
|
|
|
-
|
|
|
|
- mmap_lock();
|
|
|
|
-
|
|
|
|
- while (len > 0) {
|
|
|
|
- page = addr & TARGET_PAGE_MASK;
|
|
|
|
- l = (page + TARGET_PAGE_SIZE) - addr;
|
|
|
|
- if (l > len)
|
|
|
|
- l = len;
|
|
|
|
- flags = page_get_flags(page);
|
|
|
|
- if (!(flags & PAGE_VALID)) {
|
|
|
|
- goto out_close;
|
|
|
|
- }
|
|
|
|
- if (is_write) {
|
|
|
|
- if (flags & PAGE_WRITE) {
|
|
|
|
- memcpy(g2h(cpu, addr), buf, l);
|
|
|
|
- } else {
|
|
|
|
- /* Bypass the host page protection using ptrace. */
|
|
|
|
- if (fd == -1) {
|
|
|
|
- fd = open("/proc/self/mem", O_WRONLY);
|
|
|
|
- if (fd == -1) {
|
|
|
|
- goto out;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- * If there is a TranslationBlock and we weren't bypassing the
|
|
|
|
- * host page protection, the memcpy() above would SEGV,
|
|
|
|
- * ultimately leading to page_unprotect(). So invalidate the
|
|
|
|
- * translations manually. Both invalidation and pwrite() must
|
|
|
|
- * be under mmap_lock() in order to prevent the creation of
|
|
|
|
- * another TranslationBlock in between.
|
|
|
|
- */
|
|
|
|
- tb_invalidate_phys_range(addr, addr + l - 1);
|
|
|
|
- written = pwrite(fd, buf, l,
|
|
|
|
- (off_t)(uintptr_t)g2h_untagged(addr));
|
|
|
|
- if (written != l) {
|
|
|
|
- goto out_close;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if (flags & PAGE_READ) {
|
|
|
|
- memcpy(buf, g2h(cpu, addr), l);
|
|
|
|
- } else {
|
|
|
|
- /* Bypass the host page protection using ptrace. */
|
|
|
|
- if (fd == -1) {
|
|
|
|
- fd = open("/proc/self/mem", O_RDONLY);
|
|
|
|
- if (fd == -1) {
|
|
|
|
- goto out;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (pread(fd, buf, l,
|
|
|
|
- (off_t)(uintptr_t)g2h_untagged(addr)) != l) {
|
|
|
|
- goto out_close;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- len -= l;
|
|
|
|
- buf += l;
|
|
|
|
- addr += l;
|
|
|
|
- }
|
|
|
|
- ret = 0;
|
|
|
|
-out_close:
|
|
|
|
- if (fd != -1) {
|
|
|
|
- close(fd);
|
|
|
|
- }
|
|
|
|
-out:
|
|
|
|
- mmap_unlock();
|
|
|
|
-
|
|
|
|
- return ret;
|
|
|
|
-}
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
bool target_words_bigendian(void)
|
|
bool target_words_bigendian(void)
|
|
{
|
|
{
|
|
return TARGET_BIG_ENDIAN;
|
|
return TARGET_BIG_ENDIAN;
|