From 044431cfe7a9325cc5c22b5feb5a6116d0264e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 4 Oct 2023 11:25:09 +0200 Subject: sysemu/kvm: Restrict hvf_get_supported_cpuid() to x86 targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hvf_get_supported_cpuid() is only defined for x86 targets (in target/i386/hvf/x86_cpuid.c). Its declaration is pointless on all other targets. All the calls to it in target/i386/cpu.c are guarded by a call on hvf_enabled(), so are elided when HVF is not built in. Therefore we can remove the unnecessary function stub. Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20231004092510.39498-3-philmd@linaro.org> Signed-off-by: Paolo Bonzini --- include/sysemu/hvf.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h index 4037cd6..4a7c6af 100644 --- a/include/sysemu/hvf.h +++ b/include/sysemu/hvf.h @@ -20,13 +20,10 @@ #include "cpu.h" #ifdef CONFIG_HVF -uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx, - int reg); extern bool hvf_allowed; #define hvf_enabled() (hvf_allowed) #else /* !CONFIG_HVF */ #define hvf_enabled() 0 -#define hvf_get_supported_cpuid(func, idx, reg) 0 #endif /* !CONFIG_HVF */ #endif /* NEED_CPU_H */ -- cgit v1.1 From 7893e42d5d9cafeeab30a114e8ec86517f8a1b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 4 Oct 2023 11:06:20 +0200 Subject: tcg: Correct invalid mentions of 'softmmu' by 'system-mode' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20231004090629.37473-6-philmd@linaro.org> Signed-off-by: Paolo Bonzini --- include/qemu/atomic128.h | 4 ++-- include/tcg/tcg-op-common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h index 34554bf..88af6d4 100644 --- a/include/qemu/atomic128.h +++ b/include/qemu/atomic128.h @@ -43,8 +43,8 @@ * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80878 * * This interpretation is not especially helpful for QEMU. - * For softmmu, all RAM is always read/write from the hypervisor. - * For user-only, if the guest doesn't implement such an __atomic_read + * For system-mode, all RAM is always read/write from the hypervisor. + * For user-mode, if the guest doesn't implement such an __atomic_read * then the host need not worry about it either. * * Moreover, using libatomic is not an option, because its interface is diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index a53b159..2048f92 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -265,7 +265,7 @@ void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx); * * See tcg/README for more info about this TCG operation. * - * NOTE: In softmmu emulation, direct jumps with goto_tb are only safe within + * NOTE: In system emulation, direct jumps with goto_tb are only safe within * the pages this TB resides in because we don't take care of direct jumps when * address mapping changes, e.g. in tlb_flush(). In user mode, there's only a * static address translation, so the destination address is always valid, TBs -- cgit v1.1 From f14eced5ac9ae2db10a661e0fdef52a2f0316699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 4 Oct 2023 11:06:23 +0200 Subject: semihosting: Rename softmmu_FOO_user() -> uaccess_FOO_user() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a check in 'softmmu-uaccess.h' that the header is only include in system emulation, and rename it as 'uaccess.h'. Rename the API methods: - softmmu_[un]lock_user*() -> uaccess_[un]lock_user*() - softmmu_strlen_user() -> uaccess_strlen_user(). Update a pair of comments. Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20231004090629.37473-9-philmd@linaro.org> Signed-off-by: Paolo Bonzini --- include/semihosting/softmmu-uaccess.h | 59 -------------------------------- include/semihosting/uaccess.h | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 59 deletions(-) delete mode 100644 include/semihosting/softmmu-uaccess.h create mode 100644 include/semihosting/uaccess.h (limited to 'include') diff --git a/include/semihosting/softmmu-uaccess.h b/include/semihosting/softmmu-uaccess.h deleted file mode 100644 index 4f08dfc..0000000 --- a/include/semihosting/softmmu-uaccess.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Helper routines to provide target memory access for semihosting - * syscalls in system emulation mode. - * - * Copyright (c) 2007 CodeSourcery. - * - * This code is licensed under the GPL - */ - -#ifndef SEMIHOSTING_SOFTMMU_UACCESS_H -#define SEMIHOSTING_SOFTMMU_UACCESS_H - -#include "cpu.h" - -#define get_user_u64(val, addr) \ - ({ uint64_t val_ = 0; \ - int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ - &val_, sizeof(val_), 0); \ - (val) = tswap64(val_); ret_; }) - -#define get_user_u32(val, addr) \ - ({ uint32_t val_ = 0; \ - int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ - &val_, sizeof(val_), 0); \ - (val) = tswap32(val_); ret_; }) - -#define get_user_u8(val, addr) \ - ({ uint8_t val_ = 0; \ - int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ - &val_, sizeof(val_), 0); \ - (val) = val_; ret_; }) - -#define get_user_ual(arg, p) get_user_u32(arg, p) - -#define put_user_u64(val, addr) \ - ({ uint64_t val_ = tswap64(val); \ - cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); }) - -#define put_user_u32(val, addr) \ - ({ uint32_t val_ = tswap32(val); \ - cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); }) - -#define put_user_ual(arg, p) put_user_u32(arg, p) - -void *softmmu_lock_user(CPUArchState *env, target_ulong addr, - target_ulong len, bool copy); -#define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy) - -char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr); -#define lock_user_string(p) softmmu_lock_user_string(env, p) - -void softmmu_unlock_user(CPUArchState *env, void *p, - target_ulong addr, target_ulong len); -#define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len) - -ssize_t softmmu_strlen_user(CPUArchState *env, target_ulong addr); -#define target_strlen(p) softmmu_strlen_user(env, p) - -#endif /* SEMIHOSTING_SOFTMMU_UACCESS_H */ diff --git a/include/semihosting/uaccess.h b/include/semihosting/uaccess.h new file mode 100644 index 0000000..3963eaf --- /dev/null +++ b/include/semihosting/uaccess.h @@ -0,0 +1,63 @@ +/* + * Helper routines to provide target memory access for semihosting + * syscalls in system emulation mode. + * + * Copyright (c) 2007 CodeSourcery. + * + * This code is licensed under the GPL + */ + +#ifndef SEMIHOSTING_UACCESS_H +#define SEMIHOSTING_UACCESS_H + +#ifdef CONFIG_USER_ONLY +#error Cannot include semihosting/uaccess.h from user emulation +#endif + +#include "cpu.h" + +#define get_user_u64(val, addr) \ + ({ uint64_t val_ = 0; \ + int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ + &val_, sizeof(val_), 0); \ + (val) = tswap64(val_); ret_; }) + +#define get_user_u32(val, addr) \ + ({ uint32_t val_ = 0; \ + int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ + &val_, sizeof(val_), 0); \ + (val) = tswap32(val_); ret_; }) + +#define get_user_u8(val, addr) \ + ({ uint8_t val_ = 0; \ + int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ + &val_, sizeof(val_), 0); \ + (val) = val_; ret_; }) + +#define get_user_ual(arg, p) get_user_u32(arg, p) + +#define put_user_u64(val, addr) \ + ({ uint64_t val_ = tswap64(val); \ + cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); }) + +#define put_user_u32(val, addr) \ + ({ uint32_t val_ = tswap32(val); \ + cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); }) + +#define put_user_ual(arg, p) put_user_u32(arg, p) + +void *uaccess_lock_user(CPUArchState *env, target_ulong addr, + target_ulong len, bool copy); +#define lock_user(type, p, len, copy) uaccess_lock_user(env, p, len, copy) + +char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr); +#define lock_user_string(p) uaccess_lock_user_string(env, p) + +void uaccess_unlock_user(CPUArchState *env, void *p, + target_ulong addr, target_ulong len); +#define unlock_user(s, args, len) uaccess_unlock_user(env, s, args, len) + +ssize_t uaccess_strlen_user(CPUArchState *env, target_ulong addr); +#define target_strlen(p) uaccess_strlen_user(env, p) + +#endif /* SEMIHOSTING_SOFTMMU_UACCESS_H */ -- cgit v1.1 From 8d7f2e767d8cd058c817dbe31430b89f2e11535d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 4 Oct 2023 11:06:28 +0200 Subject: system: Rename softmmu/ directory as system/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The softmmu/ directory contains files specific to system emulation. Rename it as system/. Update meson rules, the MAINTAINERS file and all the documentation and comments. Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20231004090629.37473-14-philmd@linaro.org> Signed-off-by: Paolo Bonzini --- include/sysemu/cpu-timers-internal.h | 71 ++++++++++++++++++++++++++++++++++++ include/sysemu/runstate-action.h | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 include/sysemu/cpu-timers-internal.h (limited to 'include') diff --git a/include/sysemu/cpu-timers-internal.h b/include/sysemu/cpu-timers-internal.h new file mode 100644 index 0000000..94bb739 --- /dev/null +++ b/include/sysemu/cpu-timers-internal.h @@ -0,0 +1,71 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef TIMERS_STATE_H +#define TIMERS_STATE_H + +/* timers state, for sharing between icount and cpu-timers */ + +typedef struct TimersState { + /* Protected by BQL. */ + int64_t cpu_ticks_prev; + int64_t cpu_ticks_offset; + + /* + * Protect fields that can be respectively read outside the + * BQL, and written from multiple threads. + */ + QemuSeqLock vm_clock_seqlock; + QemuSpin vm_clock_lock; + + int16_t cpu_ticks_enabled; + + /* Conversion factor from emulated instructions to virtual clock ticks. */ + int16_t icount_time_shift; + /* Icount delta used for shift auto adjust. */ + int64_t last_delta; + + /* Compensate for varying guest execution speed. */ + aligned_int64_t qemu_icount_bias; + + int64_t vm_clock_warp_start; + int64_t cpu_clock_offset; + + /* Only written by TCG thread */ + int64_t qemu_icount; + + /* for adjusting icount */ + QEMUTimer *icount_rt_timer; + QEMUTimer *icount_vm_timer; + QEMUTimer *icount_warp_timer; +} TimersState; + +extern TimersState timers_state; + +/* + * icount needs this internal from cpu-timers when adjusting the icount shift. + */ +int64_t cpu_get_clock_locked(void); + +#endif /* TIMERS_STATE_H */ diff --git a/include/sysemu/runstate-action.h b/include/sysemu/runstate-action.h index cff45a0..db4e309 100644 --- a/include/sysemu/runstate-action.h +++ b/include/sysemu/runstate-action.h @@ -11,7 +11,7 @@ #include "qapi/qapi-commands-run-state.h" -/* in softmmu/runstate-action.c */ +/* in system/runstate-action.c */ extern RebootAction reboot_action; extern ShutdownAction shutdown_action; extern PanicAction panic_action; -- cgit v1.1