mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge tag 'pull-riscv-to-apply-20231012-1' of https://github.com/alistair23/qemu into staging
Second RISC-V PR for 8.2 * Add support for the max CPU * Detect user choice in TCG * Clear CSR values at reset and sync MPSTATE with host * Fix the typo of inverted order of pmpaddr13 and pmpaddr14 * Split TCG/KVM accelerators from cpu.c * Add extension properties for all cpus * Replace GDB exit calls with proper shutdown * Support KVM_GET_REG_LIST * Remove RVG warning * Use env_archcpu for better performance * Deprecate capital 'Z' CPU properties * Fix vfwmaccbf16.vf # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEEaukCtqfKh31tZZKWr3yVEwxTgBMFAmUncYAACgkQr3yVEwxT # gBPQ3g/9Fi4uYRK7dymHHAQbOO9NPlmVPPSxmQ8fNUhoZUkbHfm56JEl42Xr02rA # Lg2ORRQxJhAinANV8CotnbyLRHNCAvouCMCQEjHo1YEHzdXc0tQzp+rIOHT7v9rH # 6OQpI6RuCjO+0LQPMgzJx8yokMw/9b0uma3+RkNKod1XsSySo6JvDkMZGGZZWuVX # Que3TMHzc4513PWEwRS9NaAHqRdy/ax0aPu9khswTYBxeJ/mBTLvGj4wBq5wnS7+ # JPvq0M5ScUMl4K5o884wsAzOdxRk8QZOMx3duMCbqXw0xFmYZj/EzcIeHdnXwuDB # lcANd6LcESMNUb8iDBaFRjLnZ/gNiu20/P/LPWyTirfoZXzZ+h6WPnSeli36xtzO # KKWtvS1YggCjsDvh9/PLYAvUGBcS/kUhIynN10YKnoKB+wSDxxyvBS1GU6c8czgc # WDf3V4P3Z8oPKDA/24Qd9Uiho1Gq9FED4eBQPb9PuvkfboKE/g7lUp708XXDFVld # hkJMsYROSRvk54RHITrD9Z+XFQ2TfC8wHLH0IwlyynQnc1sKvXaR6U1hZTAVtE4f # yley/xCQ7OUV+hrx1sQLURcN6A+SPummOY5jdHiD29QcJnOZnkSy5j2KOlnHSa5i # 6v/6EFCgxwr69N6Q6X34VDv6+DZqLO2dNncQCInYFfupRhQ7t1E= # =SUon # -----END PGP SIGNATURE----- # gpg: Signature made Thu 12 Oct 2023 00:09:36 EDT # gpg: using RSA key 6AE902B6A7CA877D6D659296AF7C95130C538013 # gpg: Good signature from "Alistair Francis <alistair@alistair23.me>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 6AE9 02B6 A7CA 877D 6D65 9296 AF7C 9513 0C53 8013 * tag 'pull-riscv-to-apply-20231012-1' of https://github.com/alistair23/qemu: (54 commits) target/riscv: Fix vfwmaccbf16.vf target/riscv: deprecate capital 'Z' CPU properties target/riscv: Use env_archcpu for better performance target/riscv/tcg: remove RVG warning target/riscv/kvm: support KVM_GET_REG_LIST target/riscv/kvm: improve 'init_multiext_cfg' error msg gdbstub: replace exit calls with proper shutdown for softmmu hw/char: riscv_htif: replace exit calls with proper shutdown hw/misc/sifive_test.c: replace exit calls with proper shutdown softmmu: pass the main loop status to gdb "Wxx" packet softmmu: add means to pass an exit code when requesting a shutdown target/riscv/tcg-cpu.c: add extension properties for all cpus target/riscv: add riscv_cpu_get_name() target/riscv/cpu: move priv spec functions to tcg-cpu.c target/riscv/cpu.c: export isa_edata_arr[] target/riscv/tcg: move riscv_cpu_add_misa_properties() to tcg-cpu.c target/riscv/cpu.c: make misa_ext_cfgs[] 'const' target/riscv/tcg: introduce tcg_cpu_instance_init() target/riscv/cpu.c: export set_misa() target/riscv/kvm: do not use riscv_cpu_add_misa_properties() ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
+2
-2
@@ -2116,8 +2116,8 @@ static const char *csr_name(int csrno)
|
||||
case 0x03ba: return "pmpaddr10";
|
||||
case 0x03bb: return "pmpaddr11";
|
||||
case 0x03bc: return "pmpaddr12";
|
||||
case 0x03bd: return "pmpaddr14";
|
||||
case 0x03be: return "pmpaddr13";
|
||||
case 0x03bd: return "pmpaddr13";
|
||||
case 0x03be: return "pmpaddr14";
|
||||
case 0x03bf: return "pmpaddr15";
|
||||
case 0x0780: return "mtohost";
|
||||
case 0x0781: return "mfromhost";
|
||||
|
||||
@@ -327,6 +327,41 @@ QEMU's ``vhost`` feature, which would eliminate the high latency costs under
|
||||
which the 9p ``proxy`` backend currently suffers. However as of to date nobody
|
||||
has indicated plans for such kind of reimplementation unfortunately.
|
||||
|
||||
RISC-V 'any' CPU type ``-cpu any`` (since 8.2)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The 'any' CPU type was introduced back in 2018 and has been around since the
|
||||
initial RISC-V QEMU port. Its usage has always been unclear: users don't know
|
||||
what to expect from a CPU called 'any', and in fact the CPU does not do anything
|
||||
special that isn't already done by the default CPUs rv32/rv64.
|
||||
|
||||
After the introduction of the 'max' CPU type, RISC-V now has a good coverage
|
||||
of generic CPUs: rv32 and rv64 as default CPUs and 'max' as a feature complete
|
||||
CPU for both 32 and 64 bit builds. Users are then discouraged to use the 'any'
|
||||
CPU type starting in 8.2.
|
||||
|
||||
RISC-V CPU properties which start with capital 'Z' (since 8.2)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
All RISC-V CPU properties which start with capital 'Z' are being deprecated
|
||||
starting in 8.2. The reason is that they were wrongly added with capital 'Z'
|
||||
in the past. CPU properties were later added with lower-case names, which
|
||||
is the format we want to use from now on.
|
||||
|
||||
Users which try to use these deprecated properties will receive a warning
|
||||
recommending to switch to their stable counterparts:
|
||||
|
||||
- "Zifencei" should be replaced with "zifencei"
|
||||
- "Zicsr" should be replaced with "zicsr"
|
||||
- "Zihintntl" should be replaced with "zihintntl"
|
||||
- "Zihintpause" should be replaced with "zihintpause"
|
||||
- "Zawrs" should be replaced with "zawrs"
|
||||
- "Zfa" should be replaced with "zfa"
|
||||
- "Zfh" should be replaced with "zfh"
|
||||
- "Zfhmin" should be replaced with "zfhmin"
|
||||
- "Zve32f" should be replaced with "zve32f"
|
||||
- "Zve64f" should be replaced with "zve64f"
|
||||
- "Zve64d" should be replaced with "zve64d"
|
||||
|
||||
Block device options
|
||||
''''''''''''''''''''
|
||||
|
||||
+3
-2
@@ -1324,7 +1324,7 @@ static void handle_v_kill(GArray *params, void *user_ctx)
|
||||
gdb_put_packet("OK");
|
||||
error_report("QEMU: Terminated via GDBstub");
|
||||
gdb_exit(0);
|
||||
exit(0);
|
||||
gdb_qemu_exit(0);
|
||||
}
|
||||
|
||||
static const GdbCmdParseEntry gdb_v_commands_table[] = {
|
||||
@@ -1843,7 +1843,8 @@ static int gdb_handle_packet(const char *line_buf)
|
||||
/* Kill the target */
|
||||
error_report("QEMU: Terminated via GDBstub");
|
||||
gdb_exit(0);
|
||||
exit(0);
|
||||
gdb_qemu_exit(0);
|
||||
break;
|
||||
case 'D':
|
||||
{
|
||||
static const GdbCmdParseEntry detach_cmd_desc = {
|
||||
|
||||
@@ -435,6 +435,12 @@ void gdb_exit(int code)
|
||||
qemu_chr_fe_deinit(&gdbserver_system_state.chr, true);
|
||||
}
|
||||
|
||||
void gdb_qemu_exit(int code)
|
||||
{
|
||||
qemu_system_shutdown_request_with_code(SHUTDOWN_CAUSE_GUEST_SHUTDOWN,
|
||||
code);
|
||||
}
|
||||
|
||||
/*
|
||||
* Memory access
|
||||
*/
|
||||
|
||||
@@ -113,6 +113,12 @@ void gdb_exit(int code)
|
||||
gdb_put_packet(buf);
|
||||
gdbserver_state.allow_stop_reply = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void gdb_qemu_exit(int code)
|
||||
{
|
||||
exit(code);
|
||||
}
|
||||
|
||||
int gdb_handlesig(CPUState *cpu, int sig)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "exec/address-spaces.h"
|
||||
#include "exec/tswap.h"
|
||||
#include "sysemu/dma.h"
|
||||
#include "sysemu/runstate.h"
|
||||
|
||||
#define RISCV_DEBUG_HTIF 0
|
||||
#define HTIF_DEBUG(fmt, ...) \
|
||||
@@ -206,7 +207,9 @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
|
||||
g_free(sig_data);
|
||||
}
|
||||
|
||||
exit(exit_code);
|
||||
qemu_system_shutdown_request_with_code(
|
||||
SHUTDOWN_CAUSE_GUEST_SHUTDOWN, exit_code);
|
||||
return;
|
||||
} else {
|
||||
uint64_t syscall[8];
|
||||
cpu_physical_memory_read(payload, syscall, sizeof(syscall));
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "target/riscv/cpu.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "sysemu/kvm.h"
|
||||
#include "kvm_riscv.h"
|
||||
#include "kvm/kvm_riscv.h"
|
||||
#include "migration/vmstate.h"
|
||||
|
||||
#define APLIC_MAX_IDC (1UL << 14)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "qemu/module.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "hw/misc/sifive_test.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
|
||||
static uint64_t sifive_test_read(void *opaque, hwaddr addr, unsigned int size)
|
||||
{
|
||||
@@ -39,9 +40,13 @@ static void sifive_test_write(void *opaque, hwaddr addr,
|
||||
int code = (val64 >> 16) & 0xffff;
|
||||
switch (status) {
|
||||
case FINISHER_FAIL:
|
||||
exit(code);
|
||||
qemu_system_shutdown_request_with_code(
|
||||
SHUTDOWN_CAUSE_GUEST_PANIC, code);
|
||||
return;
|
||||
case FINISHER_PASS:
|
||||
exit(0);
|
||||
qemu_system_shutdown_request_with_code(
|
||||
SHUTDOWN_CAUSE_GUEST_SHUTDOWN, code);
|
||||
return;
|
||||
case FINISHER_RESET:
|
||||
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
|
||||
return;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
#include "hw/riscv/virt.h"
|
||||
#include "hw/riscv/boot.h"
|
||||
#include "hw/riscv/numa.h"
|
||||
#include "kvm_riscv.h"
|
||||
#include "kvm/kvm_riscv.h"
|
||||
#include "hw/intc/riscv_aclint.h"
|
||||
#include "hw/intc/riscv_aplic.h"
|
||||
#include "hw/intc/riscv_imsic.h"
|
||||
|
||||
@@ -110,4 +110,13 @@ int use_gdb_syscalls(void);
|
||||
*/
|
||||
void gdb_exit(int code);
|
||||
|
||||
/**
|
||||
* gdb_qemu_exit: ask qemu to exit
|
||||
* @code: exit code reported
|
||||
*
|
||||
* This requests qemu to exit. This function is allowed to return as
|
||||
* the exit request might be processed asynchronously by qemu backend.
|
||||
*/
|
||||
void gdb_qemu_exit(int code);
|
||||
|
||||
#endif /* _SYSCALLS_H_ */
|
||||
|
||||
@@ -68,6 +68,8 @@ void qemu_system_wakeup_request(WakeupReason reason, Error **errp);
|
||||
void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
|
||||
void qemu_register_wakeup_notifier(Notifier *notifier);
|
||||
void qemu_register_wakeup_support(void);
|
||||
void qemu_system_shutdown_request_with_code(ShutdownCause reason,
|
||||
int exit_code);
|
||||
void qemu_system_shutdown_request(ShutdownCause reason);
|
||||
void qemu_system_powerdown_request(void);
|
||||
void qemu_register_powerdown_notifier(Notifier *notifier);
|
||||
|
||||
@@ -101,7 +101,7 @@ bool defaults_enabled(void);
|
||||
|
||||
void qemu_init(int argc, char **argv);
|
||||
int qemu_main_loop(void);
|
||||
void qemu_cleanup(void);
|
||||
void qemu_cleanup(int);
|
||||
|
||||
extern QemuOptsList qemu_legacy_drive_opts;
|
||||
extern QemuOptsList qemu_common_drive_opts;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ int qemu_default_main(void)
|
||||
int status;
|
||||
|
||||
status = qemu_main_loop();
|
||||
qemu_cleanup();
|
||||
qemu_cleanup(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
+13
-3
@@ -385,6 +385,7 @@ void vm_state_notify(bool running, RunState state)
|
||||
|
||||
static ShutdownCause reset_requested;
|
||||
static ShutdownCause shutdown_requested;
|
||||
static int shutdown_exit_code = EXIT_SUCCESS;
|
||||
static int shutdown_signal;
|
||||
static pid_t shutdown_pid;
|
||||
static int powerdown_requested;
|
||||
@@ -664,6 +665,13 @@ void qemu_system_killed(int signal, pid_t pid)
|
||||
qemu_notify_event();
|
||||
}
|
||||
|
||||
void qemu_system_shutdown_request_with_code(ShutdownCause reason,
|
||||
int exit_code)
|
||||
{
|
||||
shutdown_exit_code = exit_code;
|
||||
qemu_system_shutdown_request(reason);
|
||||
}
|
||||
|
||||
void qemu_system_shutdown_request(ShutdownCause reason)
|
||||
{
|
||||
trace_qemu_system_shutdown_request(reason);
|
||||
@@ -725,7 +733,9 @@ static bool main_loop_should_exit(int *status)
|
||||
if (shutdown_action == SHUTDOWN_ACTION_PAUSE) {
|
||||
vm_stop(RUN_STATE_SHUTDOWN);
|
||||
} else {
|
||||
if (request == SHUTDOWN_CAUSE_GUEST_PANIC &&
|
||||
if (shutdown_exit_code != EXIT_SUCCESS) {
|
||||
*status = shutdown_exit_code;
|
||||
} else if (request == SHUTDOWN_CAUSE_GUEST_PANIC &&
|
||||
panic_action == PANIC_ACTION_EXIT_FAILURE) {
|
||||
*status = EXIT_FAILURE;
|
||||
}
|
||||
@@ -824,9 +834,9 @@ void qemu_init_subsystems(void)
|
||||
}
|
||||
|
||||
|
||||
void qemu_cleanup(void)
|
||||
void qemu_cleanup(int status)
|
||||
{
|
||||
gdb_exit(0);
|
||||
gdb_exit(status);
|
||||
|
||||
/*
|
||||
* cleaning up the migration object cancels any existing migration
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#define CPU_RESOLVING_TYPE TYPE_RISCV_CPU
|
||||
|
||||
#define TYPE_RISCV_CPU_ANY RISCV_CPU_TYPE_NAME("any")
|
||||
#define TYPE_RISCV_CPU_MAX RISCV_CPU_TYPE_NAME("max")
|
||||
#define TYPE_RISCV_CPU_BASE32 RISCV_CPU_TYPE_NAME("rv32")
|
||||
#define TYPE_RISCV_CPU_BASE64 RISCV_CPU_TYPE_NAME("rv64")
|
||||
#define TYPE_RISCV_CPU_BASE128 RISCV_CPU_TYPE_NAME("x-rv128")
|
||||
|
||||
+202
-832
File diff suppressed because it is too large
Load Diff
+32
-2
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "hw/core/cpu.h"
|
||||
#include "hw/registerfields.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "exec/cpu-defs.h"
|
||||
#include "qemu/cpu-float.h"
|
||||
#include "qom/object.h"
|
||||
@@ -42,7 +43,7 @@
|
||||
#define RV(x) ((target_ulong)1 << (x - 'A'))
|
||||
|
||||
/*
|
||||
* Consider updating misa_ext_info_arr[] and misa_ext_cfgs[]
|
||||
* Update misa_bits[], misa_ext_info_arr[] and misa_ext_cfgs[]
|
||||
* when adding new MISA bits here.
|
||||
*/
|
||||
#define RVI RV('I')
|
||||
@@ -59,9 +60,12 @@
|
||||
#define RVJ RV('J')
|
||||
#define RVG RV('G')
|
||||
|
||||
extern const uint32_t misa_bits[];
|
||||
const char *riscv_get_misa_ext_name(uint32_t bit);
|
||||
const char *riscv_get_misa_ext_description(uint32_t bit);
|
||||
|
||||
#define CPU_CFG_OFFSET(_prop) offsetof(struct RISCVCPUConfig, _prop)
|
||||
|
||||
/* Privileged specification version */
|
||||
enum {
|
||||
PRIV_VERSION_1_10_0 = 0,
|
||||
@@ -443,7 +447,6 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
|
||||
bool probe, uintptr_t retaddr);
|
||||
char *riscv_isa_string(RISCVCPU *cpu);
|
||||
void riscv_cpu_list(void);
|
||||
void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp);
|
||||
|
||||
#define cpu_list riscv_cpu_list
|
||||
#define cpu_mmu_index riscv_cpu_mmu_index
|
||||
@@ -705,6 +708,33 @@ enum riscv_pmu_event_idx {
|
||||
RISCV_PMU_EVENT_CACHE_ITLB_PREFETCH_MISS = 0x10021,
|
||||
};
|
||||
|
||||
/* used by tcg/tcg-cpu.c*/
|
||||
void isa_ext_update_enabled(RISCVCPU *cpu, uint32_t ext_offset, bool en);
|
||||
bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset);
|
||||
void riscv_cpu_set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext);
|
||||
|
||||
typedef struct RISCVCPUMultiExtConfig {
|
||||
const char *name;
|
||||
uint32_t offset;
|
||||
bool enabled;
|
||||
} RISCVCPUMultiExtConfig;
|
||||
|
||||
extern const RISCVCPUMultiExtConfig riscv_cpu_extensions[];
|
||||
extern const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[];
|
||||
extern const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[];
|
||||
extern const RISCVCPUMultiExtConfig riscv_cpu_deprecated_exts[];
|
||||
extern Property riscv_cpu_options[];
|
||||
|
||||
typedef struct isa_ext_data {
|
||||
const char *name;
|
||||
int min_version;
|
||||
int ext_enable_offset;
|
||||
} RISCVIsaExtData;
|
||||
extern const RISCVIsaExtData isa_edata_arr[];
|
||||
char *riscv_cpu_get_name(RISCVCPU *cpu);
|
||||
|
||||
void riscv_add_satp_mode_properties(Object *obj);
|
||||
|
||||
/* CSR function table */
|
||||
extern riscv_csr_operations csr_ops[CSR_TABLE_SIZE];
|
||||
|
||||
|
||||
@@ -65,8 +65,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)
|
||||
void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc,
|
||||
uint64_t *cs_base, uint32_t *pflags)
|
||||
{
|
||||
CPUState *cs = env_cpu(env);
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
RISCVCPU *cpu = env_archcpu(env);
|
||||
RISCVExtStatus fs, vs;
|
||||
uint32_t flags = 0;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "qemu/log.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "cpu.h"
|
||||
#include "tcg/tcg-cpu.h"
|
||||
#include "pmu.h"
|
||||
#include "time_helper.h"
|
||||
#include "exec/exec-all.h"
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* QEMU KVM RISC-V specific function stubs
|
||||
*
|
||||
* Copyright (c) 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2 or later, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
#include "cpu.h"
|
||||
#include "kvm_riscv.h"
|
||||
|
||||
void kvm_riscv_reset_vcpu(RISCVCPU *cpu)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user