Misc (mostly i386) patches for 2021-05-11
The following changes since commit e58c7a3bba3076890592f02d2b0e596bf191b5c2:
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210510-1' into staging (2021-05-10 17:28:11 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 8708c1e0182293b51e07c0640848f93a3354376e:
coverity-scan: list components, move model to scripts/coverity-scan (2021-05-11 04:11:14 -0400)
----------------------------------------------------------------
* AccelCPUClass and sysemu/user split for i386 (Claudio)
* i386 page walk unification
* Fix detection of gdbus-codegen
* Misc refactoring
* snapshot-load bugfix
----------------------------------------------------------------
Claudio Fontana (18):
i386: split cpu accelerators from cpu.c, using AccelCPUClass
cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn
accel: introduce new accessor functions
target/i386: fix host_cpu_adjust_phys_bits error handling
accel-cpu: make cpu_realizefn return a bool
i386: split smm helper (sysemu)
i386: split tcg excp_helper into sysemu and user parts
i386: move TCG bpt_helper into sysemu/
i386: split misc helper user stubs and sysemu part
i386: separate fpu_helper sysemu-only parts
i386: split svm_helper into sysemu and stub-only user
i386: split seg_helper into user-only and sysemu parts
i386: split off sysemu part of cpu.c
target/i386: gdbstub: introduce aux functions to read/write CS64 regs target/i386: gdbstub: only write CR0/CR2/CR3/EFER for sysemu
i386: make cpu_load_efer sysemu-only
accel: move call to accel_init_interfaces
accel: add init_accel_cpu for adapting accel behavior to CPU type
Paolo Bonzini (13):
i386: split off sysemu-only functionality in tcg-cpu target/i386: merge SVM_NPTEXIT_* with PF_ERROR_* constants target/i386: move paging mode constants from SVM to cpu.h target/i386: extract mmu_translate
target/i386: pass cr3 to mmu_translate
target/i386: extend pg_mode to more CR0 and CR4 bits target/i386: allow customizing the next phase of the translation target/i386: use mmu_translate for NPT walk
main-loop: remove dead code
migration: do not restart VM after successful snapshot-load
qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict
configure: fix detection of gdbus-codegen
coverity-scan: list components, move model to scripts/coverity-scan
Richard Henderson (2):
target/i386: Rename helper_fldt, helper_fstt target/i386: Split out do_fsave, do_frstor, do_fxsave, do_fxrstor
MAINTAINERS | 2 +-
accel/accel-common.c | 32 +
bsd-user/main.c | 2 +-
configure | 4 +-
cpu.c | 5 +-
hw/core/machine.c | 1 +
hw/i386/pc_piix.c | 1 +
include/hw/core/accel-cpu.h | 2 +-
include/hw/core/cpu.h | 6 +
include/qemu/accel.h | 13 +
include/qemu/main-loop.h | 18 -
linux-user/main.c | 2 +-
migration/savevm.c | 16 +-
monitor/hmp-cmds.c | 7 +-
scripts/coverity-scan/COMPONENTS.md | 154 ++++
.../{coverity-model.c => coverity-scan/model.c} | 0
softmmu/vl.c | 1 -
target/i386/cpu-internal.h | 70 ++
target/i386/cpu-sysemu.c | 352 ++++++++++
target/i386/cpu.c | 775 ++-------------------
target/i386/cpu.h | 59 +-
target/i386/gdbstub.c | 165 ++---
target/i386/helper.c | 13 +
target/i386/helper.h | 11 +
target/i386/host-cpu.c | 204 ++++++
target/i386/host-cpu.h | 19 +
target/i386/hvf/hvf-cpu.c | 68 ++
target/i386/hvf/meson.build | 1 +
target/i386/kvm/kvm-cpu.c | 151 ++++
target/i386/kvm/kvm-cpu.h | 41 ++
target/i386/kvm/kvm.c | 3 +-
target/i386/kvm/meson.build | 7 +-
target/i386/meson.build | 9 +-
target/i386/svm.h | 10 -
target/i386/tcg/bpt_helper.c | 276 --------
target/i386/tcg/excp_helper.c | 573 ---------------
target/i386/tcg/fpu_helper.c | 106 ++-
target/i386/tcg/helper-tcg.h | 8 +
target/i386/tcg/meson.build | 5 +-
target/i386/tcg/misc_helper.c | 467 -------------
target/i386/tcg/seg_helper.c | 237 +------
target/i386/tcg/seg_helper.h | 66 ++
target/i386/tcg/sysemu/bpt_helper.c | 293 ++++++++
target/i386/tcg/sysemu/excp_helper.c | 471 +++++++++++++
target/i386/tcg/sysemu/fpu_helper.c | 57 ++
target/i386/tcg/sysemu/meson.build | 10 +
target/i386/tcg/sysemu/misc_helper.c | 442 ++++++++++++
target/i386/tcg/sysemu/seg_helper.c | 125 ++++
target/i386/tcg/{ => sysemu}/smm_helper.c | 19 +-
target/i386/tcg/{ => sysemu}/svm_helper.c | 75 +-
target/i386/tcg/sysemu/tcg-cpu.c | 83 +++
target/i386/tcg/tcg-cpu.c | 56 +-
target/i386/tcg/tcg-cpu.h | 21 +-
target/i386/tcg/translate.c | 13 +-
target/i386/tcg/user/excp_helper.c | 39 ++
target/i386/tcg/user/meson.build | 6 +
target/i386/tcg/user/misc_stubs.c | 75 ++
target/i386/tcg/user/seg_helper.c | 109 +++
target/i386/tcg/user/svm_stubs.c | 76 ++
util/main-loop.c | 61 --
util/qemu-option.c | 3 +-
61 files changed, 3308 insertions(+), 2688 deletions(-)
create mode 100644 scripts/coverity-scan/COMPONENTS.md
rename scripts/{coverity-model.c => coverity-scan/model.c} (100%)
create mode 100644 target/i386/cpu-internal.h
create mode 100644 target/i386/cpu-sysemu.c
create mode 100644 target/i386/host-cpu.c
create mode 100644 target/i386/host-cpu.h
create mode 100644 target/i386/hvf/hvf-cpu.c
create mode 100644 target/i386/kvm/kvm-cpu.c
create mode 100644 target/i386/kvm/kvm-cpu.h
create mode 100644 target/i386/tcg/seg_helper.h
create mode 100644 target/i386/tcg/sysemu/bpt_helper.c
create mode 100644 target/i386/tcg/sysemu/excp_helper.c
create mode 100644 target/i386/tcg/sysemu/fpu_helper.c
create mode 100644 target/i386/tcg/sysemu/meson.build
create mode 100644 target/i386/tcg/sysemu/misc_helper.c
create mode 100644 target/i386/tcg/sysemu/seg_helper.c
rename target/i386/tcg/{ => sysemu}/smm_helper.c (98%)
rename target/i386/tcg/{ => sysemu}/svm_helper.c (95%)
create mode 100644 target/i386/tcg/sysemu/tcg-cpu.c
create mode 100644 target/i386/tcg/user/excp_helper.c
create mode 100644 target/i386/tcg/user/meson.build
create mode 100644 target/i386/tcg/user/misc_stubs.c
create mode 100644 target/i386/tcg/user/seg_helper.c
create mode 100644 target/i386/tcg/user/svm_stubs.cSignature · 1 line
2.26.2
[PULL 02/33] target/i386: Split out do_fsave, do_frstor, do_fxsave, do_fxrstor
From: Richard Henderson <[email protected]>
The helper_* functions must use GETPC() to unwind from TCG. The cpu_x86_* functions cannot, and directly calling the helper_* functions is a bug. Split out new functions that perform the work and can be used by both.
Message-Id: <[email protected]>
--- target/i386/tcg/fpu_helper.c | 50 ++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 16 deletions(-)
target/i386/tcg/fpu_helper.c +34 -16
@@ -2457,17 +2457,18 @@ void helper_fldenv(CPUX86State *env, target_ulong ptr, int data32)do_fldenv (env, ptr, data32,GETPC ()); } -void helper_fsave (CPUX86State *env,target_ulong ptr,int data32) +static void do_fsave (CPUX86State *env,target_ulong ptr,int data32, +uintptr_t retaddr) {floatx80 tmp;int i; -do_fstenv (env, ptr, data32,GETPC ()); +do_fstenv (env, ptr, data32, retaddr); ptr += (14 << data32);for (i =0 ; i <8 ; i++) { tmp =ST (i); -do_fstt (env, tmp, ptr,GETPC ()); +do_fstt (env, tmp, ptr, retaddr); ptr +=10 ; }
@@ -2485,30 +2486,41 @@ void helper_fsave(CPUX86State *env, target_ulong ptr, int data32) env->fptags[7 ] =1 ; } -void helper_frstor (CPUX86State *env,target_ulong ptr,int data32) +void helper_fsave (CPUX86State *env,target_ulong ptr,int data32) +{ +do_fsave (env, ptr, data32,GETPC ()); +} + +static void do_frstor (CPUX86State *env,target_ulong ptr,int data32, +uintptr_t retaddr) {floatx80 tmp;int i; -do_fldenv (env, ptr, data32,GETPC ()); +do_fldenv (env, ptr, data32, retaddr); ptr += (14 << data32);for (i =0 ; i <8 ; i++) { - tmp =do_fldt (env, ptr,GETPC ()); + tmp =do_fldt (env, ptr, retaddr);ST (i) = tmp; ptr +=10 ; } } +void helper_frstor (CPUX86State *env,target_ulong ptr,int data32) +{ +do_frstor (env, ptr, data32,GETPC ()); +} +#if defined(CONFIG_USER_ONLY )void cpu_x86_fsave (CPUX86State *env,target_ulong ptr,int data32) { -helper_fsave (env, ptr, data32); +do_fsave (env, ptr, data32,0 ); }void cpu_x86_frstor (CPUX86State *env,target_ulong ptr,int data32) { -helper_frstor (env, ptr, data32); +do_frstor (env, ptr, data32,0 ); }#endif
@@ -2593,10 +2605,8 @@ static void do_xsave_pkru(CPUX86State *env, target_ulong ptr, uintptr_t ra)cpu_stq_data_ra (env, ptr, env->pkru, ra); } -void helper_fxsave (CPUX86State *env,target_ulong ptr) +static void do_fxsave (CPUX86State *env,target_ulong ptr,uintptr_t ra) { -uintptr_t ra =GETPC (); -/* The operand must be 16 byte aligned */ if (ptr &0xf ) {raise_exception_ra (env,EXCP0D_GPF , ra);
@@ -2615,6 +2625,11 @@ void helper_fxsave(CPUX86State *env, target_ulong ptr) } } +void helper_fxsave (CPUX86State *env,target_ulong ptr) +{ +do_fxsave (env, ptr,GETPC ()); +} +static uint64_t get_xinuse (CPUX86State *env) {uint64_t inuse =-1 ;
@@ -2757,10 +2772,8 @@ static void do_xrstor_pkru(CPUX86State *env, target_ulong ptr, uintptr_t ra) env->pkru =cpu_ldq_data_ra (env, ptr, ra); } -void helper_fxrstor (CPUX86State *env,target_ulong ptr) +static void do_fxrstor (CPUX86State *env,target_ulong ptr,uintptr_t ra) { -uintptr_t ra =GETPC (); -/* The operand must be 16 byte aligned */ if (ptr &0xf ) {raise_exception_ra (env,EXCP0D_GPF , ra);
@@ -2779,15 +2792,20 @@ void helper_fxrstor(CPUX86State *env, target_ulong ptr) } } +void helper_fxrstor (CPUX86State *env,target_ulong ptr) +{ +do_fxrstor (env, ptr,GETPC ()); +} +#if defined(CONFIG_USER_ONLY )void cpu_x86_fxsave (CPUX86State *env,target_ulong ptr) { -helper_fxsave (env, ptr); +do_fxsave (env, ptr,0 ); }void cpu_x86_fxrstor (CPUX86State *env,target_ulong ptr) { -helper_fxrstor (env, ptr); +do_fxrstor (env, ptr,0 ); }#endif
Signature · 1 line
2.26.2
[PULL 04/33] cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
move the call to accel_cpu->cpu_realizefn to the general cpu_exec_realizefn from target/i386, so it does not need to be called for every target explicitly as we enable more targets.
Message-Id: <[email protected]>
--- cpu.c | 6 ++++++ target/i386/cpu.c | 20 +++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-)
cpu.c +6 -0
@@ -36,6 +36,7 @@#include "sysemu/replay.h" #include "exec/translate-all.h" #include "exec/log.h" +#include "hw/core/accel-cpu.h" uintptr_t qemu_host_page_size;intptr_t qemu_host_page_mask;
@@ -130,6 +131,11 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)cpu_list_add (cpu); +if (cc->accel_cpu) { +/* NB: errp parameter is unused currently */ + cc->accel_cpu->cpu_realizefn (cpu, errp); + } +#ifdef CONFIG_TCG /* NB: errp parameter is unused currently */ if (tcg_enabled ()) {
target/i386/cpu.c +7 -13
@@ -6457,16 +6457,19 @@ static void x86_cpu_hyperv_realize(X86CPU *cpu)static void x86_cpu_realizefn (DeviceState *dev,Error **errp) {CPUState *cs =CPU (dev); -CPUClass *cc =CPU_GET_CLASS (cs);X86CPU *cpu =X86_CPU (dev);X86CPUClass *xcc =X86_CPU_GET_CLASS (dev);CPUX86State *env = &cpu->env;Error *local_err =NULL ;static bool ht_warned; -/* The accelerator realizefn needs to be called first. */ -if (cc->accel_cpu) { - cc->accel_cpu->cpu_realizefn (cs, errp); +/* Process Hyper-V enlightenments */ +x86_cpu_hyperv_realize (cpu); + +cpu_exec_realizefn (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; }if (xcc->host_cpuid_required && !accel_uses_host_cpuid ()) {
@@ -6584,15 +6587,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) env->cache_info_amd.l3_cache = &legacy_l3_cache; } -/* Process Hyper-V enlightenments */ -x86_cpu_hyperv_realize (cpu); - -cpu_exec_realizefn (cs, &local_err); -if (local_err !=NULL ) { -error_propagate (errp, local_err); -return ; - } -#ifndef CONFIG_USER_ONLY MachineState *ms =MACHINE (qdev_get_machine ());qemu_register_reset (x86_cpu_machine_reset_cb, cpu);
Signature · 1 line
2.26.2
[PULL 07/33] accel-cpu: make cpu_realizefn return a bool
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
overall, all devices' realize functions take an Error **errp, but return void.
hw/core/qdev.c code, which realizes devices, therefore does:
local_err = NULL;dc->realize(dev, &local_err);
if (local_err != NULL) {
goto fail;
}However, we can improve at least accel_cpu to return a meaningful bool value.
Message-Id: <[email protected]>
--- accel/accel-common.c | 6 +++--- cpu.c | 5 +++-- include/hw/core/accel-cpu.h | 2 +- include/qemu/accel.h | 2 +- target/i386/host-cpu.c | 5 +++-- target/i386/host-cpu.h | 2 +- target/i386/kvm/kvm-cpu.c | 4 ++-- target/i386/tcg/tcg-cpu.c | 6 ++++-- 8 files changed, 18 insertions(+), 14 deletions(-)
accel/accel-common.c +3 -3
@@ -98,14 +98,14 @@ void accel_cpu_instance_init(CPUState *cpu) } } -void accel_cpu_realizefn (CPUState *cpu,Error **errp) +bool accel_cpu_realizefn (CPUState *cpu,Error **errp) {CPUClass *cc =CPU_GET_CLASS (cpu);if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn) { -/* NB: errp parameter is unused currently */ - cc->accel_cpu->cpu_realizefn (cpu, errp); +return cc->accel_cpu->cpu_realizefn (cpu, errp); } +return true; }static const TypeInfo accel_cpu_type = {
cpu.c +3 -2
@@ -130,8 +130,9 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)CPUClass *cc =CPU_GET_CLASS (cpu);cpu_list_add (cpu); -accel_cpu_realizefn (cpu, errp); - +if (!accel_cpu_realizefn (cpu, errp)) { +return ; + }#ifdef CONFIG_TCG /* NB: errp parameter is unused currently */ if (tcg_enabled ()) {
include/hw/core/accel-cpu.h +1 -1
@@ -32,7 +32,7 @@ typedef struct AccelCPUClass {void (*cpu_class_init)(CPUClass *cc);void (*cpu_instance_init)(CPUState *cpu); - void (*cpu_realizefn)(CPUState *cpu, Error **errp); + bool (*cpu_realizefn)(CPUState *cpu, Error **errp); } AccelCPUClass;#endif /* ACCEL_CPU_H */
include/qemu/accel.h +1 -1
@@ -89,6 +89,6 @@ void accel_cpu_instance_init(CPUState *cpu);* @cpu: The CPU that needs to call accel-specific cpu realization. * @errp: currently unused. */ -void accel_cpu_realizefn (CPUState *cpu,Error **errp); +bool accel_cpu_realizefn (CPUState *cpu,Error **errp);#endif /* QEMU_ACCEL_H */
target/i386/host-cpu.c +3 -2
@@ -80,7 +80,7 @@ static uint32_t host_cpu_adjust_phys_bits(X86CPU *cpu)return phys_bits; } -void host_cpu_realizefn (CPUState *cs,Error **errp) +bool host_cpu_realizefn (CPUState *cs,Error **errp) {X86CPU *cpu =X86_CPU (cs);CPUX86State *env = &cpu->env;
@@ -97,10 +97,11 @@ void host_cpu_realizefn(CPUState *cs, Error **errp)error_setg (errp,"phys-bits should be between 32 and %u " " (but is %u)" ,TARGET_PHYS_ADDR_SPACE_BITS , phys_bits); -return ; +return false; } cpu->phys_bits = phys_bits; } +return true; }#define CPUID_MODEL_ID_SZ 48
target/i386/host-cpu.h +1 -1
@@ -12,7 +12,7 @@void host_cpu_instance_init (X86CPU *cpu);void host_cpu_max_instance_init (X86CPU *cpu); -void host_cpu_realizefn (CPUState *cs,Error **errp); +bool host_cpu_realizefn (CPUState *cs,Error **errp);void host_cpu_vendor_fms (char *vendor,int *family,int *model,int *stepping);
target/i386/kvm/kvm-cpu.c +2 -2
@@ -18,7 +18,7 @@#include "kvm_i386.h" #include "hw/core/accel-cpu.h" -static void kvm_cpu_realizefn (CPUState *cs,Error **errp) +static bool kvm_cpu_realizefn (CPUState *cs,Error **errp) {X86CPU *cpu =X86_CPU (cs);CPUX86State *env = &cpu->env;
@@ -41,7 +41,7 @@ static void kvm_cpu_realizefn(CPUState *cs, Error **errp) MSR_IA32_UCODE_REV); } } -host_cpu_realizefn (cs, errp); +return host_cpu_realizefn (cs, errp); }/*
target/i386/tcg/tcg-cpu.c +4 -2
@@ -96,7 +96,7 @@ static void x86_cpu_machine_done(Notifier *n, void *unused) } } -static void tcg_cpu_realizefn (CPUState *cs,Error **errp) +static bool tcg_cpu_realizefn (CPUState *cs,Error **errp) {X86CPU *cpu =X86_CPU (cs);
@@ -132,12 +132,14 @@ static void tcg_cpu_realizefn(CPUState *cs, Error **errp)/* ... SMRAM with higher priority, linked from /machine/smram. */ cpu->machine_done.notify = x86_cpu_machine_done;qemu_add_machine_init_done_notifier (&cpu->machine_done); + return true; }#else /* CONFIG_USER_ONLY */ -static void tcg_cpu_realizefn (CPUState *cs,Error **errp) +static bool tcg_cpu_realizefn (CPUState *cs,Error **errp) { +return true; }#endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.26.2
[PULL 01/33] target/i386: Rename helper_fldt, helper_fstt
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
Change the prefix from "helper" to "do". The former should be reserved for those functions that are called from TCG; the latter is in use within the file already for those functions that are called from the helper functions, adding a "retaddr" argument.
Message-Id: <[email protected]>
--- target/i386/tcg/fpu_helper.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
target/i386/tcg/fpu_helper.c +9 -10
@@ -117,8 +117,7 @@ static inline void fpop(CPUX86State *env) env->fpstt = (env->fpstt +1 ) &7 ; } -static inline floatx80 helper_fldt (CPUX86State *env,target_ulong ptr, -uintptr_t retaddr) +static floatx80 do_fldt (CPUX86State *env,target_ulong ptr,uintptr_t retaddr) {CPU_LDoubleU temp;
@@ -127,8 +126,8 @@ static inline floatx80 helper_fldt(CPUX86State *env, target_ulong ptr,return temp.d; } -static inline void helper_fstt (CPUX86State *env,floatx80 f,target_ulong ptr, -uintptr_t retaddr) +static void do_fstt (CPUX86State *env,floatx80 f,target_ulong ptr, +uintptr_t retaddr) {CPU_LDoubleU temp;
@@ -405,14 +404,14 @@ void helper_fldt_ST0(CPUX86State *env, target_ulong ptr)int new_fpstt; new_fpstt = (env->fpstt -1 ) &7 ; - env->fpregs[new_fpstt].d =helper_fldt (env, ptr,GETPC ()); + env->fpregs[new_fpstt].d =do_fldt (env, ptr,GETPC ()); env->fpstt = new_fpstt; env->fptags[new_fpstt] =0 ;/* validate stack entry */ }void helper_fstt_ST0 (CPUX86State *env,target_ulong ptr) { -helper_fstt (env,ST0 , ptr,GETPC ()); +do_fstt (env,ST0 , ptr,GETPC ()); }void helper_fpush (CPUX86State *env)
@@ -2468,7 +2467,7 @@ void helper_fsave(CPUX86State *env, target_ulong ptr, int data32) ptr += (14 << data32);for (i =0 ; i <8 ; i++) { tmp =ST (i); -helper_fstt (env, tmp, ptr,GETPC ()); +do_fstt (env, tmp, ptr,GETPC ()); ptr +=10 ; }
@@ -2495,7 +2494,7 @@ void helper_frstor(CPUX86State *env, target_ulong ptr, int data32) ptr += (14 << data32);for (i =0 ; i <8 ; i++) { - tmp =helper_fldt (env, ptr,GETPC ()); + tmp =do_fldt (env, ptr,GETPC ());ST (i) = tmp; ptr +=10 ; }
@@ -2539,7 +2538,7 @@ static void do_xsave_fpu(CPUX86State *env, target_ulong ptr, uintptr_t ra) addr = ptr +XO (legacy.fpregs);for (i =0 ; i <8 ; i++) {floatx80 tmp =ST (i); -helper_fstt (env, tmp, addr, ra); +do_fstt (env, tmp, addr, ra); addr +=16 ; } }
@@ -2703,7 +2702,7 @@ static void do_xrstor_fpu(CPUX86State *env, target_ulong ptr, uintptr_t ra) addr = ptr +XO (legacy.fpregs);for (i =0 ; i <8 ; i++) { -floatx80 tmp =helper_fldt (env, addr, ra); +floatx80 tmp =do_fldt (env, addr, ra);ST (i) = tmp; addr +=16 ; }
Signature · 1 line
2.26.2
[PULL 06/33] target/i386: fix host_cpu_adjust_phys_bits error handling
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
move the check for phys_bits outside of host_cpu_adjust_phys_bits, because otherwise it is impossible to return an error condition explicitly.
Message-Id: <[email protected]>
--- target/i386/host-cpu.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
target/i386/host-cpu.c +12 -10
@@ -50,7 +50,7 @@ static void host_cpu_enable_cpu_pm(X86CPU *cpu) env->features[FEAT_1_ECX ] |=CPUID_EXT_MONITOR ; } -static uint32_t host_cpu_adjust_phys_bits (X86CPU *cpu,Error **errp) +static uint32_t host_cpu_adjust_phys_bits (X86CPU *cpu) {uint32_t host_phys_bits =host_cpu_phys_bits ();uint32_t phys_bits = cpu->phys_bits;
@@ -77,14 +77,6 @@ static uint32_t host_cpu_adjust_phys_bits(X86CPU *cpu, Error **errp) } } -if (phys_bits && - (phys_bits >TARGET_PHYS_ADDR_SPACE_BITS || - phys_bits <32 )) { -error_setg (errp,"phys-bits should be between 32 and %u " -" (but is %u)" , -TARGET_PHYS_ADDR_SPACE_BITS , phys_bits); - } -return phys_bits; }
@@ -97,7 +89,17 @@ void host_cpu_realizefn(CPUState *cs, Error **errp)host_cpu_enable_cpu_pm (cpu); }if (env->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_LM ) { - cpu->phys_bits =host_cpu_adjust_phys_bits (cpu, errp); +uint32_t phys_bits =host_cpu_adjust_phys_bits (cpu); + +if (phys_bits && + (phys_bits >TARGET_PHYS_ADDR_SPACE_BITS || + phys_bits <32 )) { +error_setg (errp,"phys-bits should be between 32 and %u " +" (but is %u)" , +TARGET_PHYS_ADDR_SPACE_BITS , phys_bits); +return ; + } + cpu->phys_bits = phys_bits; } }
Signature · 1 line
2.26.2
[PULL 08/33] i386: split off sysemu-only functionality in tcg-cpu
In reply to Paolo BonziniMessage-Id: <[email protected]>
--- target/i386/meson.build | 2 + target/i386/tcg/meson.build | 3 ++ target/i386/tcg/sysemu/meson.build | 3 ++ target/i386/tcg/sysemu/tcg-cpu.c | 83 ++++++++++++++++++++++++++++++ target/i386/tcg/tcg-cpu.c | 75 ++------------------------- target/i386/tcg/tcg-cpu.h | 24 +++++++++ target/i386/tcg/user/meson.build | 2 + 7 files changed, 121 insertions(+), 71 deletions(-) create mode 100644 target/i386/tcg/sysemu/meson.build create mode 100644 target/i386/tcg/sysemu/tcg-cpu.c create mode 100644 target/i386/tcg/tcg-cpu.h create mode 100644 target/i386/tcg/user/meson.build
target/i386/meson.build +2 -0
@@ -19,6 +19,7 @@ i386_softmmu_ss.add(files( 'machine.c', 'monitor.c', )) +i386_user_ss = ss.source_set() subdir('kvm') subdir('hax')
@@ -29,3 +30,4 @@ subdir('tcg') target_arch += {'i386': i386_ss} target_softmmu_arch += {'i386': i386_softmmu_ss} +target_user_arch += {'i386': i386_user_ss}
target/i386/tcg/meson.build +3 -0
@@ -12,3 +12,6 @@ i386_ss.add(when: 'CONFIG_TCG', if_true: files( 'svm_helper.c', 'tcg-cpu.c', 'translate.c'), if_false: files('tcg-stub.c')) + +subdir('sysemu') +subdir('user')
target/i386/tcg/sysemu/meson.build new file +3 -0
@@ -0,0 +1,3 @@ +i386_softmmu_ss.add(when: ['CONFIG_TCG', 'CONFIG_SOFTMMU'], if_true: files( + 'tcg-cpu.c', +))
target/i386/tcg/sysemu/tcg-cpu.c new file +83 -0
83 lines not on this page · raw message
target/i386/tcg/tcg-cpu.c +4 -71
94 lines not on this page · raw message
target/i386/tcg/tcg-cpu.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* i386 TCG cpu class initialization functions +* +* Copyright (c) 2003 Fabrice Bellard +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef TCG_CPU_H +#define TCG_CPU_H + +bool tcg_cpu_realizefn (CPUState *cs,Error **errp); + +#endif /* TCG_CPU_H */
target/i386/tcg/user/meson.build new file +2 -0
@@ -0,0 +1,2 @@ +i386_user_ss.add(when: ['CONFIG_TCG', 'CONFIG_USER_ONLY'], if_true: files( +))
Signature · 1 line
2.26.2
[PULL 09/33] i386: split smm helper (sysemu)
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
smm is only really useful for sysemu, split in two modules around the CONFIG_USER_ONLY, in order to remove the ifdef and use the build system instead.
add cpu_abort() when detecting attempts to enter SMM mode via SMI interrupt in user-mode, and assert that the cpu is not in SMM mode while translating RSM instructions.
Message-Id: <[email protected]>
---
target/i386/helper.h | 4 ++++
target/i386/tcg/meson.build | 1 -
target/i386/tcg/seg_helper.c | 4 ++++
target/i386/tcg/sysemu/meson.build | 1 +
target/i386/tcg/{ => sysemu}/smm_helper.c | 19 ++-----------------
target/i386/tcg/translate.c | 5 +++++
6 files changed, 16 insertions(+), 18 deletions(-)
rename target/i386/tcg/{ => sysemu}/smm_helper.c (98%)target/i386/helper.h +4 -0
@@ -70,7 +70,11 @@ DEF_HELPER_1(clac, void, env) DEF_HELPER_1(stac, void, env) DEF_HELPER_3(boundw, void, env, tl, int) DEF_HELPER_3(boundl, void, env, tl, int) + +#ifndef CONFIG_USER_ONLY DEF_HELPER_1(rsm, void, env) +#endif /* !CONFIG_USER_ONLY */ + DEF_HELPER_2(into, void, env, int) DEF_HELPER_2(cmpxchg8b_unlocked, void, env, tl)DEF_HELPER_2 (cmpxchg8b, void, env, tl)
target/i386/tcg/meson.build +0 -1
@@ -8,7 +8,6 @@ i386_ss.add(when: 'CONFIG_TCG', if_true: files( 'misc_helper.c', 'mpx_helper.c', 'seg_helper.c', - 'smm_helper.c', 'svm_helper.c', 'tcg-cpu.c', 'translate.c'), if_false: files('tcg-stub.c'))
target/i386/tcg/seg_helper.c +4 -0
@@ -1351,7 +1351,11 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt_request)case CPU_INTERRUPT_SMI :cpu_svm_check_intercept_param (env,SVM_EXIT_SMI ,0 ,0 ); cs->interrupt_request &= ~CPU_INTERRUPT_SMI ; +#ifdef CONFIG_USER_ONLY +cpu_abort (CPU (cpu),"SMI interrupt: cannot enter SMM in user-mode" ); +#else do_smm_enter (cpu); +#endif /* CONFIG_USER_ONLY */ break ;case CPU_INTERRUPT_NMI :cpu_svm_check_intercept_param (env,SVM_EXIT_NMI ,0 ,0 );
target/i386/tcg/sysemu/meson.build +1 -0
@@ -1,3 +1,4 @@ i386_softmmu_ss.add(when: ['CONFIG_TCG', 'CONFIG_SOFTMMU'], if_true: files( 'tcg-cpu.c', + 'smm_helper.c', ))
target/i386/tcg/sysemu/smm_helper.c renamed from target/i386/tcg/smm_helper.c +2 -17
@@ -1,5 +1,5 @@/* -* x86 SMM helpers +* x86 SMM helpers (sysemu-only) * * Copyright (c) 2003 Fabrice Bellard *
@@ -18,27 +18,14 @@*/ #include "qemu/osdep.h" -#include "qemu/main-loop.h" #include "cpu.h" #include "exec/helper-proto.h" #include "exec/log.h" -#include "helper-tcg.h" +#include "tcg/helper-tcg.h" /* SMM support */ -#if defined(CONFIG_USER_ONLY ) - -void do_smm_enter (X86CPU *cpu) -{ -} - -void helper_rsm (CPUX86State *env) -{ -} - -#else -#ifdef TARGET_X86_64 #define SMM_REVISION_ID 0x00020064#else
@@ -330,5 +317,3 @@ void helper_rsm(CPUX86State *env)qemu_log_mask (CPU_LOG_INT ,"SMM: after RSM\n" );log_cpu_state_mask (CPU_LOG_INT ,CPU (cpu),CPU_DUMP_CCOP ); } - -#endif /* !CONFIG_USER_ONLY */
target/i386/tcg/translate.c +5 -0
@@ -8325,9 +8325,14 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_svm_check_intercept (s, pc_start,SVM_EXIT_RSM );if (!(s->flags &HF_SMM_MASK )) goto illegal_op; +#ifdef CONFIG_USER_ONLY +/* we should not be in SMM mode */ +g_assert_not_reached (); +#else gen_update_cc_op (s);gen_jmp_im (s, s->pc - s->cs_base);gen_helper_rsm (cpu_env); +#endif /* CONFIG_USER_ONLY */ gen_eob (s);break ;case 0x1b8 :/* SSE4.2 popcnt */
Signature · 1 line
2.26.2
[PULL 14/33] i386: split svm_helper into sysemu and stub-only user
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
For now we just copy over the previous user stubs, but really,
everything that requires s->cpl == 0 should be impossible to trigger from user-mode emulation.
Later on we should add a check that asserts this easily f.e.:
static bool check_cpl0(DisasContext *s)
{
int cpl = s->cpl;
#ifdef CONFIG_USER_ONLY
assert(cpl == 3);
#endif
if (cpl != 0) {
gen_exception(s, EXCP0D_GPF, s->pc_start - s->cs_base);
return false;
}
return true;
}Message-Id: <[email protected]>
---
target/i386/tcg/meson.build | 1 -
target/i386/tcg/sysemu/meson.build | 1 +
target/i386/tcg/{ => sysemu}/svm_helper.c | 62 +-----------------
target/i386/tcg/user/meson.build | 1 +
target/i386/tcg/user/svm_stubs.c | 76 +++++++++++++++++++++++
5 files changed, 80 insertions(+), 61 deletions(-)
rename target/i386/tcg/{ => sysemu}/svm_helper.c (96%)
create mode 100644 target/i386/tcg/user/svm_stubs.ctarget/i386/tcg/meson.build +0 -1
@@ -8,7 +8,6 @@ i386_ss.add(when: 'CONFIG_TCG', if_true: files( 'misc_helper.c', 'mpx_helper.c', 'seg_helper.c', - 'svm_helper.c', 'tcg-cpu.c', 'translate.c'), if_false: files('tcg-stub.c'))
target/i386/tcg/sysemu/meson.build +1 -0
@@ -5,4 +5,5 @@ i386_softmmu_ss.add(when: ['CONFIG_TCG', 'CONFIG_SOFTMMU'], if_true: files( 'bpt_helper.c', 'misc_helper.c', 'fpu_helper.c', + 'svm_helper.c', ))
target/i386/tcg/sysemu/svm_helper.c renamed from target/i386/tcg/svm_helper.c +2 -60
78 lines not on this page · raw message
target/i386/tcg/user/meson.build +1 -0
@@ -1,4 +1,5 @@ i386_user_ss.add(when: ['CONFIG_TCG', 'CONFIG_USER_ONLY'], if_true: files( 'excp_helper.c', 'misc_stubs.c', + 'svm_stubs.c', ))
target/i386/tcg/user/svm_stubs.c new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 05/33] accel: introduce new accessor functions
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
avoid open coding the accesses to cpu->accel_cpu interfaces, and instead introduce:
accel_cpu_instance_init,accel_cpu_realizefn
to be used by the targets/ initfn code, and by cpu_exec_realizefn respectively.
Message-Id: <[email protected]>
--- accel/accel-common.c | 19 +++++++++++++++++++ cpu.c | 6 +----- include/qemu/accel.h | 13 +++++++++++++ target/i386/cpu.c | 9 ++------- 4 files changed, 35 insertions(+), 12 deletions(-)
accel/accel-common.c +19 -0
@@ -89,6 +89,25 @@ void accel_init_interfaces(AccelClass *ac)accel_init_cpu_interfaces (ac); } +void accel_cpu_instance_init (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->accel_cpu && cc->accel_cpu->cpu_instance_init) { + cc->accel_cpu->cpu_instance_init (cpu); + } +} + +void accel_cpu_realizefn (CPUState *cpu,Error **errp) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn) { +/* NB: errp parameter is unused currently */ + cc->accel_cpu->cpu_realizefn (cpu, errp); + } +} +static const TypeInfo accel_cpu_type = { .name =TYPE_ACCEL_CPU , .parent =TYPE_OBJECT ,
cpu.c +1 -5
@@ -130,11 +130,7 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)CPUClass *cc =CPU_GET_CLASS (cpu);cpu_list_add (cpu); - -if (cc->accel_cpu) { -/* NB: errp parameter is unused currently */ - cc->accel_cpu->cpu_realizefn (cpu, errp); - } +accel_cpu_realizefn (cpu, errp);#ifdef CONFIG_TCG /* NB: errp parameter is unused currently */
include/qemu/accel.h +13 -0
@@ -78,4 +78,17 @@ int accel_init_machine(AccelState *accel, MachineState *ms);void accel_setup_post (MachineState *ms);#endif /* !CONFIG_USER_ONLY */ +/** +* accel_cpu_instance_init: +* @cpu: The CPU that needs to do accel-specific object initializations. +*/ +void accel_cpu_instance_init (CPUState *cpu); + +/** +* accel_cpu_realizefn: +* @cpu: The CPU that needs to call accel-specific cpu realization. +* @errp: currently unused. +*/ +void accel_cpu_realizefn (CPUState *cpu,Error **errp); +#endif /* QEMU_ACCEL_H */
target/i386/cpu.c +2 -7
@@ -28,7 +28,6 @@#include "sysemu/kvm.h" #include "sysemu/reset.h" #include "sysemu/hvf.h" -#include "hw/core/accel-cpu.h" #include "sysemu/xen.h" #include "sysemu/whpx.h" #include "kvm/kvm_i386.h"
@@ -6800,8 +6799,6 @@ static void x86_cpu_initfn(Object *obj) {X86CPU *cpu =X86_CPU (obj);X86CPUClass *xcc =X86_CPU_GET_CLASS (obj); -CPUClass *cc =CPU_CLASS (xcc); -CPUX86State *env = &cpu->env; env->nr_dies =1 ;
@@ -6850,10 +6847,8 @@ static void x86_cpu_initfn(Object *obj)x86_cpu_load_model (cpu, xcc->model); } -/* if required, do the accelerator-specific cpu initialization */ -if (cc->accel_cpu) { - cc->accel_cpu->cpu_instance_init (CPU (obj)); - } +/* if required, do accelerator-specific cpu initializations */ +accel_cpu_instance_init (CPU (obj)); }static int64_t x86_cpu_get_arch_id (CPUState *cs)
Signature · 1 line
2.26.2
[PULL 03/33] i386: split cpu accelerators from cpu.c, using AccelCPUClass
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
i386 is the first user of AccelCPUClass, allowing to split cpu.c into:
cpu.c cpuid and common x86 cpu functionality host-cpu.c host x86 cpu functions and "host" cpu type kvm/kvm-cpu.c KVM x86 AccelCPUClass hvf/hvf-cpu.c HVF x86 AccelCPUClass tcg/tcg-cpu.c TCG x86 AccelCPUClass
[claudio]:
Rebased on commit b8184135 ("target/i386: allow modifying TCG phys-addr-bits")
Message-Id: <[email protected]>
--- MAINTAINERS | 2 +- hw/i386/pc_piix.c | 1 + target/i386/cpu.c | 383 ++++-------------------------------- target/i386/cpu.h | 20 +- target/i386/host-cpu.c | 201 +++++++++++++++++++ target/i386/host-cpu.h | 19 ++ target/i386/hvf/hvf-cpu.c | 68 +++++++ target/i386/hvf/meson.build | 1 + target/i386/kvm/kvm-cpu.c | 151 ++++++++++++++ target/i386/kvm/kvm-cpu.h | 41 ++++ target/i386/kvm/kvm.c | 3 +- target/i386/kvm/meson.build | 7 +- target/i386/meson.build | 6 +- target/i386/tcg/tcg-cpu.c | 113 ++++++++++- target/i386/tcg/tcg-cpu.h | 15 -- 15 files changed, 652 insertions(+), 379 deletions(-) create mode 100644 target/i386/host-cpu.c create mode 100644 target/i386/host-cpu.h create mode 100644 target/i386/hvf/hvf-cpu.c create mode 100644 target/i386/kvm/kvm-cpu.c create mode 100644 target/i386/kvm/kvm-cpu.h delete mode 100644 target/i386/tcg/tcg-cpu.h
MAINTAINERS +1 -1
@@ -351,7 +351,7 @@ M: Paolo Bonzini <[email protected]> M: Richard Henderson <[email protected]> M: Eduardo Habkost <[email protected]> S: Maintained -F: target/i386/ +F: target/i386/tcg/ F: tests/tcg/i386/ F: tests/tcg/x86_64/ F: hw/i386/
hw/i386/pc_piix.c +1 -0
@@ -61,6 +61,7 @@#include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" #include "hw/i386/acpi-build.h" +#include "kvm/kvm-cpu.h" #define MAX_IDE_BUS 2
target/i386/cpu.c +41 -342
548 lines not on this page · raw message
target/i386/cpu.h +8 -12
@@ -1926,13 +1926,20 @@ int cpu_x86_signal_handler(int host_signum, void *pinfo, void *puc);/* cpu.c */ +void x86_cpu_vendor_words2str (char *dst,uint32_t vendor1, +uint32_t vendor2,uint32_t vendor3); +typedef struct PropValue { +const char *prop, *value; +}PropValue ; +void x86_cpu_apply_props (X86CPU *cpu,PropValue *props); + +/* cpu.c other functions (cpuid) */ void cpu_x86_cpuid (CPUX86State *env,uint32_t index,uint32_t count,uint32_t *eax,uint32_t *ebx,uint32_t *ecx,uint32_t *edx);void cpu_clear_apic_feature (CPUX86State *env);void host_cpuid (uint32_t function,uint32_t count,uint32_t *eax,uint32_t *ebx,uint32_t *ecx,uint32_t *edx); -void host_vendor_fms (char *vendor,int *family,int *model,int *stepping);/* helper.c */ void x86_cpu_set_a20 (X86CPU *cpu,int a20_state);
@@ -2137,17 +2144,6 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access);void apic_handle_tpr_access_report (DeviceState *d,target_ulong ip,TPRAccess access); - -/* Change the value of a KVM-specific default -* -* If value is NULL, no default will be set and the original -* value from the CPU model table will be kept. -* -* It is valid to call this function only for properties that -* are already present in the kvm_default_props table. -*/ -void x86_cpu_change_kvm_default (const char *prop,const char *value); -/* Special values for X86CPUVersion: */ /* Resolve to latest CPU version */
target/i386/host-cpu.c new file +201 -0
201 lines not on this page · raw message
target/i386/host-cpu.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* x86 host CPU type initialization and host CPU functions +* +* Copyright 2021 SUSE LLC +* +* 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 HOST_CPU_H +#define HOST_CPU_H + +void host_cpu_instance_init (X86CPU *cpu); +void host_cpu_max_instance_init (X86CPU *cpu); +void host_cpu_realizefn (CPUState *cs,Error **errp); + +void host_cpu_vendor_fms (char *vendor,int *family,int *model,int *stepping); + +#endif /* HOST_CPU_H */
target/i386/hvf/hvf-cpu.c new file +68 -0
68 lines not on this page · raw message
target/i386/hvf/meson.build +1 -0
@@ -10,4 +10,5 @@ i386_softmmu_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files( 'x86_mmu.c', 'x86_task.c', 'x86hvf.c', + 'hvf-cpu.c', ))
target/i386/kvm/kvm-cpu.c new file +151 -0
151 lines not on this page · raw message
target/i386/kvm/kvm-cpu.h new file +41 -0
41 lines not on this page · raw message
target/i386/kvm/kvm.c +2 -1
@@ -22,6 +22,7 @@#include "standard-headers/asm-x86/kvm_para.h" #include "cpu.h" +#include "host-cpu.h" #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "sysemu/kvm_int.h"
@@ -288,7 +289,7 @@ static bool host_tsx_broken(void)int family, model, stepping;\char vendor[CPUID_VENDOR_SZ +1 ]; -host_vendor_fms (vendor, &family, &model, &stepping); +host_cpu_vendor_fms (vendor, &family, &model, &stepping);/* Check if we are running on a Haswell host known to have broken TSX */ return !strcmp(vendor, CPUID_VENDOR_INTEL) &&
target/i386/kvm/meson.build +6 -1
@@ -1,3 +1,8 @@ i386_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) -i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) + +i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files( + 'kvm.c', + 'kvm-cpu.c', +)) + i386_softmmu_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'), if_false: files('hyperv-stub.c'))
target/i386/meson.build +5 -1
@@ -6,7 +6,11 @@ i386_ss.add(files( 'xsave_helper.c', 'cpu-dump.c', )) -i386_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-stub.c')) +i386_ss.add(when: 'CONFIG_SEV', if_true: files('host-cpu.c', 'sev.c'), if_false: files('sev-stub.c')) + +# x86 cpu type +i386_ss.add(when: 'CONFIG_KVM', if_true: files('host-cpu.c')) +i386_ss.add(when: 'CONFIG_HVF', if_true: files('host-cpu.c')) i386_softmmu_ss = ss.source_set() i386_softmmu_ss.add(files(
target/i386/tcg/tcg-cpu.c +107 -6
127 lines not on this page · raw message
target/i386/tcg/tcg-cpu.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* i386 TCG CPU class initialization -* -* Copyright 2020 SUSE LLC -* -* 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 TCG_CPU_H -#define TCG_CPU_H - -void tcg_cpu_common_class_init (CPUClass *cc); - -#endif /* TCG_CPU_H */
Signature · 1 line
2.26.2
Re: [PULL 03/33] i386: split cpu accelerators from cpu.c, using AccelCPUClass
Quoted 29 lines · Paolo Bonzini
From: Claudio Fontana <[email protected]>
i386 is the first user of AccelCPUClass, allowing to split
cpu.cinto:cpu.c cpuid and common x86 cpu functionality host-cpu.c host x86 cpu functions and "host" cpu type kvm/kvm-cpu.c KVM x86 AccelCPUClass hvf/hvf-cpu.c HVF x86 AccelCPUClass tcg/tcg-cpu.c TCG x86 AccelCPUClassSigned-off-by Claudio Fontana <[email protected]>Reviewed-by Alex Bennée <[email protected]>Reviewed-by Richard Henderson <[email protected]>[claudio]:
Rebased on commitb8184135("target/i386: allow modifying TCG phys-addr-bits")Signed-off-by Claudio Fontana <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>---
MAINTAINERS +0
-0
MAINTAINERS M: Paolo Bonzini <[email protected]> · line 357
Quoted 8 lines
MAINTAINERS +1
-1@@ -351,7 +351,7 @@ M: Paolo Bonzini <[email protected]> M: Richard Henderson <[email protected]> M: Eduardo Habkost <[email protected]> S: Maintained -F: target/i386/ +F: target/i386/tcg/ F: tests/tcg/i386/ F: tests/tcg/x86_64/ F: hw/i386/
This change to MAINTAINERS has left all the .c files in target/i386 that are not in one of the tcg, hvf, whpx, kvm, hax, nvmm subdirectories orphaned -- they are no longer covered by any MAINTAINERS section.
Where should those files be listed ?
(I just discovered this when get_maintainers.pl said it couldn't find a maintainer for a change I made to target/i386/sev.c.)
thanks
-- PMM
Re: [PULL 03/33] i386: split cpu accelerators from cpu.c, using AccelCPUClass
Quoted 44 lines · Peter Maydell
Quoted 29 lines · Paolo Bonzini
From: Claudio Fontana <[email protected]>
i386 is the first user of AccelCPUClass, allowing to split
cpu.cinto:cpu.c cpuid and common x86 cpu functionality host-cpu.c host x86 cpu functions and "host" cpu type kvm/kvm-cpu.c KVM x86 AccelCPUClass hvf/hvf-cpu.c HVF x86 AccelCPUClass tcg/tcg-cpu.c TCG x86 AccelCPUClassSigned-off-by Claudio Fontana <[email protected]>Reviewed-by Alex Bennée <[email protected]>Reviewed-by Richard Henderson <[email protected]>[claudio]:
Rebased on commitb8184135("target/i386: allow modifying TCG phys-addr-bits")Signed-off-by Claudio Fontana <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>---
MAINTAINERS +0
-0MAINTAINERS M: Paolo Bonzini <[email protected]> · line 357
Quoted 8 lines
MAINTAINERS +1
-1@@ -351,7 +351,7 @@ M: Paolo Bonzini <[email protected]> M: Richard Henderson <[email protected]> M: Eduardo Habkost <[email protected]> S: Maintained -F: target/i386/ +F: target/i386/tcg/ F: tests/tcg/i386/ F: tests/tcg/x86_64/ F: hw/i386/This change to
MAINTAINERShas left all the .c files in target/i386 that are not in one of the tcg, hvf, whpx, kvm, hax, nvmm subdirectories orphaned -- they are no longer covered by anyMAINTAINERSsection.
Quoted 4 lines
Where should those files be listed ?
(I just discovered this when get_maintainers.pl said it couldn't find a maintainer for a change I made to
target/i386/sev.c.)
This patch maybe got lost:
https://www.mail-archive.com/[email protected]/msg816326.html
Re: [PULL 03/33] i386: split cpu accelerators from cpu.c, using AccelCPUClass
Quoted 46 lines · Philippe Mathieu-Daudé
Quoted 44 lines · Peter Maydell
Quoted 29 lines · Paolo Bonzini
From: Claudio Fontana <[email protected]>
i386 is the first user of AccelCPUClass, allowing to split
cpu.cinto:cpu.c cpuid and common x86 cpu functionality host-cpu.c host x86 cpu functions and "host" cpu type kvm/kvm-cpu.c KVM x86 AccelCPUClass hvf/hvf-cpu.c HVF x86 AccelCPUClass tcg/tcg-cpu.c TCG x86 AccelCPUClassSigned-off-by Claudio Fontana <[email protected]>Reviewed-by Alex Bennée <[email protected]>Reviewed-by Richard Henderson <[email protected]>[claudio]:
Rebased on commitb8184135("target/i386: allow modifying TCG phys-addr-bits")Signed-off-by Claudio Fontana <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>---
MAINTAINERS +0
-0MAINTAINERS M: Paolo Bonzini <[email protected]> · line 357
Quoted 8 lines
MAINTAINERS +1
-1@@ -351,7 +351,7 @@ M: Paolo Bonzini <[email protected]> M: Richard Henderson <[email protected]> M: Eduardo Habkost <[email protected]> S: Maintained -F: target/i386/ +F: target/i386/tcg/ F: tests/tcg/i386/ F: tests/tcg/x86_64/ F: hw/i386/This change to
MAINTAINERShas left all the .c files in target/i386 that are not in one of the tcg, hvf, whpx, kvm, hax, nvmm subdirectories orphaned -- they are no longer covered by anyMAINTAINERSsection.
Quoted 7 lines
Quoted 4 lines
Where should those files be listed ?
(I just discovered this when get_maintainers.pl said it couldn't find a maintainer for a change I made to
target/i386/sev.c.)This patch maybe got lost:
https://www.mail-archive.com/[email protected]/msg816326.html
Looks like it, but we should have a general fallback for target/i386 as well...
-- PMM
[PULL 10/33] i386: split tcg excp_helper into sysemu and user parts
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
[claudio]:
Rebased on commit b8184135 ("target/i386: allow modifying TCG phys-addr-bits")
Message-Id: <[email protected]>
--- target/i386/tcg/excp_helper.c | 573 -------------------------- target/i386/tcg/sysemu/excp_helper.c | 582 +++++++++++++++++++++++++++ target/i386/tcg/sysemu/meson.build | 1 + target/i386/tcg/user/excp_helper.c | 39 ++ target/i386/tcg/user/meson.build | 1 + 5 files changed, 623 insertions(+), 573 deletions(-) create mode 100644 target/i386/tcg/sysemu/excp_helper.c create mode 100644 target/i386/tcg/user/excp_helper.c
target/i386/tcg/excp_helper.c +0 -573
@@ -137,576 +137,3 @@ void raise_exception_ra(CPUX86State *env, int exception_index, uintptr_t retaddr {raise_interrupt2 (env, exception_index,0 ,0 ,0 , retaddr); } - -#if !defined(CONFIG_USER_ONLY ) -static hwaddr get_hphys (CPUState *cs,hwaddr gphys,MMUAccessType access_type, -int *prot) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; -uint64_t rsvd_mask =PG_ADDRESS_MASK & ~MAKE_64BIT_MASK (0 , cpu->phys_bits); -uint64_t ptep, pte; -uint64_t exit_info_1 =0 ; -target_ulong pde_addr, pte_addr; -uint32_t page_offset; -int page_size; - -if (likely (!(env->hflags2 &HF2_NPT_MASK ))) { -return gphys; - } - -if (!(env->nested_pg_mode &SVM_NPT_NXE )) { - rsvd_mask |=PG_NX_MASK ; - } - -if (env->nested_pg_mode &SVM_NPT_PAE ) { -uint64_t pde, pdpe; -target_ulong pdpe_addr; - -#ifdef TARGET_X86_64 -if (env->nested_pg_mode &SVM_NPT_LMA ) { -uint64_t pml5e; -uint64_t pml4e_addr, pml4e; - - pml5e = env->nested_cr3; - ptep =PG_NX_MASK |PG_USER_MASK |PG_RW_MASK ; - - pml4e_addr = (pml5e &PG_ADDRESS_MASK ) + - (((gphys >>39 ) &0x1ff ) <<3 ); - pml4e =x86_ldq_phys (cs, pml4e_addr); -if (!(pml4e &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pml4e & (rsvd_mask |PG_PSE_MASK )) { - goto do_fault_rsvd; - } -if (!(pml4e &PG_ACCESSED_MASK )) { - pml4e |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pml4e_addr, pml4e); - } - ptep &= pml4e ^PG_NX_MASK ; - pdpe_addr = (pml4e &PG_ADDRESS_MASK ) + - (((gphys >>30 ) &0x1ff ) <<3 ); - pdpe =x86_ldq_phys (cs, pdpe_addr); -if (!(pdpe &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pdpe & rsvd_mask) { - goto do_fault_rsvd; - } - ptep &= pdpe ^PG_NX_MASK ; -if (!(pdpe &PG_ACCESSED_MASK )) { - pdpe |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pdpe_addr, pdpe); - } -if (pdpe &PG_PSE_MASK ) { -/* 1 GB page */ - page_size =1024 *1024 *1024 ; - pte_addr = pdpe_addr; - pte = pdpe; - goto do_check_protect; - } - } else -#endif - { - pdpe_addr = (env->nested_cr3 & ~0x1f ) + ((gphys >>27 ) &0x18 ); - pdpe =x86_ldq_phys (cs, pdpe_addr); -if (!(pdpe &PG_PRESENT_MASK )) { - goto do_fault; - } - rsvd_mask |=PG_HI_USER_MASK ; -if (pdpe & (rsvd_mask |PG_NX_MASK )) { - goto do_fault_rsvd; - } - ptep =PG_NX_MASK |PG_USER_MASK |PG_RW_MASK ; - } - - pde_addr = (pdpe &PG_ADDRESS_MASK ) + (((gphys >>21 ) &0x1ff ) <<3 ); - pde =x86_ldq_phys (cs, pde_addr); -if (!(pde &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pde & rsvd_mask) { - goto do_fault_rsvd; - } - ptep &= pde ^PG_NX_MASK ; -if (pde &PG_PSE_MASK ) { -/* 2 MB page */ - page_size =2048 *1024 ; - pte_addr = pde_addr; - pte = pde; - goto do_check_protect; - } -/* 4 KB page */ -if (!(pde &PG_ACCESSED_MASK )) { - pde |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pde_addr, pde); - } - pte_addr = (pde &PG_ADDRESS_MASK ) + (((gphys >>12 ) &0x1ff ) <<3 ); - pte =x86_ldq_phys (cs, pte_addr); -if (!(pte &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pte & rsvd_mask) { - goto do_fault_rsvd; - } -/* combine pde and pte nx, user and rw protections */ - ptep &= pte ^PG_NX_MASK ; - page_size =4096 ; - }else { -uint32_t pde; - -/* page directory entry */ - pde_addr = (env->nested_cr3 & ~0xfff ) + ((gphys >>20 ) &0xffc ); - pde =x86_ldl_phys (cs, pde_addr); -if (!(pde &PG_PRESENT_MASK )) { - goto do_fault; - } - ptep = pde |PG_NX_MASK ; - -/* if host cr4 PSE bit is set, then we use a 4MB page */ -if ((pde &PG_PSE_MASK ) && (env->nested_pg_mode &SVM_NPT_PSE )) { - page_size =4096 *1024 ; - pte_addr = pde_addr; - -/* Bits 20-13 provide bits 39-32 of the address, bit 21 is reserved. -* Leave bits 20-13 in place for setting accessed/dirty bits below. -*/ - pte = pde | ((pde &0x1fe000LL ) << (32 -13 )); - rsvd_mask =0x200000 ; - goto do_check_protect_pse36; - } - -if (!(pde &PG_ACCESSED_MASK )) { - pde |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pde_addr, pde); - } - -/* page directory entry */ - pte_addr = (pde & ~0xfff ) + ((gphys >>10 ) &0xffc ); - pte =x86_ldl_phys (cs, pte_addr); -if (!(pte &PG_PRESENT_MASK )) { - goto do_fault; - } -/* combine pde and pte user and rw protections */ - ptep &= pte |PG_NX_MASK ; - page_size =4096 ; - rsvd_mask =0 ; - } - - do_check_protect: - rsvd_mask |= (page_size -1 ) &PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK ; - do_check_protect_pse36: -if (pte & rsvd_mask) { - goto do_fault_rsvd; - } - ptep ^=PG_NX_MASK ; - -if (!(ptep &PG_USER_MASK )) { - goto do_fault_protect; - } -if (ptep &PG_NX_MASK ) { -if (access_type ==MMU_INST_FETCH ) { - goto do_fault_protect; - } - *prot &= ~PAGE_EXEC ; - } -if (!(ptep &PG_RW_MASK )) { -if (access_type ==MMU_DATA_STORE ) { - goto do_fault_protect; - } - *prot &= ~PAGE_WRITE ; - } - - pte &=PG_ADDRESS_MASK & ~(page_size -1 ); - page_offset = gphys & (page_size -1 ); -return pte + page_offset; - - do_fault_rsvd: - exit_info_1 |=SVM_NPTEXIT_RSVD ; - do_fault_protect: - exit_info_1 |=SVM_NPTEXIT_P ; - do_fault: - x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), - gphys); - exit_info_1 |=SVM_NPTEXIT_US ; -if (access_type ==MMU_DATA_STORE ) { - exit_info_1 |=SVM_NPTEXIT_RW ; - }else if (access_type ==MMU_INST_FETCH ) { - exit_info_1 |=SVM_NPTEXIT_ID ; - } -if (prot) { - exit_info_1 |=SVM_NPTEXIT_GPA ; - }else {/* page table access */ - exit_info_1 |=SVM_NPTEXIT_GPT ; - } -cpu_vmexit (env,SVM_EXIT_NPF , exit_info_1, env->retaddr); -} - -/* return value: -* -1 = cannot handle fault -* 0 = nothing more to do -* 1 = generate PF fault -*/ -static int handle_mmu_fault (CPUState *cs,vaddr addr,int size, -int is_write1,int mmu_idx) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; -uint64_t ptep, pte; -int32_t a20_mask; -target_ulong pde_addr, pte_addr; -int error_code =0 ; -int is_dirty, prot, page_size, is_write, is_user; -hwaddr paddr; -uint64_t rsvd_mask =PG_ADDRESS_MASK & ~MAKE_64BIT_MASK (0 , cpu->phys_bits); -uint32_t page_offset; -target_ulong vaddr; -uint32_t pkr; - - is_user = mmu_idx ==MMU_USER_IDX ; -#if defined(DEBUG_MMU ) -printf ("MMU fault: addr=%" VADDR_PRIx" w=%d u=%d eip=" TARGET_FMT_lx"\n" , - addr, is_write1, is_user, env->eip); -#endif - is_write = is_write1 &1 ; - - a20_mask =x86_get_a20_mask (env); -if (!(env->cr[0 ] &CR0_PG_MASK )) { - pte = addr; -#ifdef TARGET_X86_64 -if (!(env->hflags &HF_LMA_MASK )) { -/* Without long mode we can only address 32bits in real mode */ - pte = (uint32_t )pte; - } -#endif - prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; - page_size =4096 ; - goto do_mapping; - } - -if (!(env->efer &MSR_EFER_NXE )) { - rsvd_mask |=PG_NX_MASK ; - } - -if (env->cr[4 ] &CR4_PAE_MASK ) { -uint64_t pde, pdpe; -target_ulong pdpe_addr; - -#ifdef TARGET_X86_64 -if (env->hflags &HF_LMA_MASK ) { -bool la57 = env->cr[4 ] &CR4_LA57_MASK ; -uint64_t pml5e_addr, pml5e; -uint64_t pml4e_addr, pml4e; -int32_t sext; - -/* test virtual address sign extension */ - sext = la57 ? (int64_t )addr >>56 : (int64_t )addr >>47 ; -if (sext !=0 && sext !=-1 ) { - env->error_code =0 ; - cs->exception_index =EXCP0D_GPF ; -return 1 ; - } - -if (la57) { - pml5e_addr = ((env->cr[3 ] & ~0xfff ) + - (((addr >>48 ) &0x1ff ) <<3 )) & a20_mask; - pml5e_addr =get_hphys (cs, pml5e_addr,MMU_DATA_STORE ,NULL ); - pml5e =x86_ldq_phys (cs, pml5e_addr); -if (!(pml5e &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pml5e & (rsvd_mask |PG_PSE_MASK )) { - goto do_fault_rsvd; - } -if (!(pml5e &PG_ACCESSED_MASK )) { - pml5e |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pml5e_addr, pml5e); - } - ptep = pml5e ^PG_NX_MASK ; - }else { - pml5e = env->cr[3 ]; - ptep =PG_NX_MASK |PG_USER_MASK |PG_RW_MASK ; - } - - pml4e_addr = ((pml5e &PG_ADDRESS_MASK ) + - (((addr >>39 ) &0x1ff ) <<3 )) & a20_mask; - pml4e_addr =get_hphys (cs, pml4e_addr,MMU_DATA_STORE , false); - pml4e =x86_ldq_phys (cs, pml4e_addr); -if (!(pml4e &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pml4e & (rsvd_mask |PG_PSE_MASK )) { - goto do_fault_rsvd; - } -if (!(pml4e &PG_ACCESSED_MASK )) { - pml4e |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pml4e_addr, pml4e); - } - ptep &= pml4e ^PG_NX_MASK ; - pdpe_addr = ((pml4e &PG_ADDRESS_MASK ) + (((addr >>30 ) &0x1ff ) <<3 )) & - a20_mask; - pdpe_addr =get_hphys (cs, pdpe_addr,MMU_DATA_STORE ,NULL ); - pdpe =x86_ldq_phys (cs, pdpe_addr); -if (!(pdpe &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pdpe & rsvd_mask) { - goto do_fault_rsvd; - } - ptep &= pdpe ^PG_NX_MASK ; -if (!(pdpe &PG_ACCESSED_MASK )) { - pdpe |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pdpe_addr, pdpe); - } -if (pdpe &PG_PSE_MASK ) { -/* 1 GB page */ - page_size =1024 *1024 *1024 ; - pte_addr = pdpe_addr; - pte = pdpe; - goto do_check_protect; - } - } else -#endif - { -/* XXX: load them when cr3 is loaded ? */ - pdpe_addr = ((env->cr[3 ] & ~0x1f ) + ((addr >>27 ) &0x18 )) & - a20_mask; - pdpe_addr =get_hphys (cs, pdpe_addr,MMU_DATA_STORE , false); - pdpe =x86_ldq_phys (cs, pdpe_addr); -if (!(pdpe &PG_PRESENT_MASK )) { - goto do_fault; - } - rsvd_mask |=PG_HI_USER_MASK ; -if (pdpe & (rsvd_mask |PG_NX_MASK )) { - goto do_fault_rsvd; - } - ptep =PG_NX_MASK |PG_USER_MASK |PG_RW_MASK ; - } - - pde_addr = ((pdpe &PG_ADDRESS_MASK ) + (((addr >>21 ) &0x1ff ) <<3 )) & - a20_mask; - pde_addr =get_hphys (cs, pde_addr,MMU_DATA_STORE ,NULL ); - pde =x86_ldq_phys (cs, pde_addr); -if (!(pde &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pde & rsvd_mask) { - goto do_fault_rsvd; - } - ptep &= pde ^PG_NX_MASK ; -if (pde &PG_PSE_MASK ) { -/* 2 MB page */ - page_size =2048 *1024 ; - pte_addr = pde_addr; - pte = pde; - goto do_check_protect; - } -/* 4 KB page */ -if (!(pde &PG_ACCESSED_MASK )) { - pde |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pde_addr, pde); - } - pte_addr = ((pde &PG_ADDRESS_MASK ) + (((addr >>12 ) &0x1ff ) <<3 )) & - a20_mask; - pte_addr =get_hphys (cs, pte_addr,MMU_DATA_STORE ,NULL ); - pte =x86_ldq_phys (cs, pte_addr); -if (!(pte &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pte & rsvd_mask) { - goto do_fault_rsvd; - } -/* combine pde and pte nx, user and rw protections */ - ptep &= pte ^PG_NX_MASK ; - page_size =4096 ; - }else { -uint32_t pde; - -/* page directory entry */ - pde_addr = ((env->cr[3 ] & ~0xfff ) + ((addr >>20 ) &0xffc )) & - a20_mask; - pde_addr =get_hphys (cs, pde_addr,MMU_DATA_STORE ,NULL ); - pde =x86_ldl_phys (cs, pde_addr); -if (!(pde &PG_PRESENT_MASK )) { - goto do_fault; - } - ptep = pde |PG_NX_MASK ; - -/* if PSE bit is set, then we use a 4MB page */ -if ((pde &PG_PSE_MASK ) && (env->cr[4 ] &CR4_PSE_MASK )) { - page_size =4096 *1024 ; - pte_addr = pde_addr; - -/* Bits 20-13 provide bits 39-32 of the address, bit 21 is reserved. -* Leave bits 20-13 in place for setting accessed/dirty bits below. -*/ - pte = pde | ((pde &0x1fe000LL ) << (32 -13 )); - rsvd_mask =0x200000 ; - goto do_check_protect_pse36; - } - -if (!(pde &PG_ACCESSED_MASK )) { - pde |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pde_addr, pde); - } - -/* page directory entry */ - pte_addr = ((pde & ~0xfff ) + ((addr >>10 ) &0xffc )) & - a20_mask; - pte_addr =get_hphys (cs, pte_addr,MMU_DATA_STORE ,NULL ); - pte =x86_ldl_phys (cs, pte_addr); -if (!(pte &PG_PRESENT_MASK )) { - goto do_fault; - } -/* combine pde and pte user and rw protections */ - ptep &= pte |PG_NX_MASK ; - page_size =4096 ; - rsvd_mask =0 ; - } - -do_check_protect: - rsvd_mask |= (page_size -1 ) &PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK ; -do_check_protect_pse36: -if (pte & rsvd_mask) { - goto do_fault_rsvd; - } - ptep ^=PG_NX_MASK ; - -/* can the page can be put in the TLB? prot will tell us */ -if (is_user && !(ptep &PG_USER_MASK )) { - goto do_fault_protect; - } - - prot =0 ; -if (mmu_idx !=MMU_KSMAP_IDX || !(ptep &PG_USER_MASK )) { - prot |=PAGE_READ ; -if ((ptep &PG_RW_MASK ) || (!is_user && !(env->cr[0 ] &CR0_WP_MASK ))) { - prot |=PAGE_WRITE ; - } - } -if (!(ptep &PG_NX_MASK ) && - (mmu_idx ==MMU_USER_IDX || - !((env->cr[4 ] &CR4_SMEP_MASK ) && (ptep &PG_USER_MASK )))) { - prot |=PAGE_EXEC ; - } - -if (!(env->hflags &HF_LMA_MASK )) { - pkr =0 ; - }else if (ptep &PG_USER_MASK ) { - pkr = env->cr[4 ] &CR4_PKE_MASK ? env->pkru :0 ; - }else { - pkr = env->cr[4 ] &CR4_PKS_MASK ? env->pkrs :0 ; - } -if (pkr) { -uint32_t pk = (pte &PG_PKRU_MASK ) >>PG_PKRU_BIT ; -uint32_t pkr_ad = (pkr >> pk *2 ) &1 ; -uint32_t pkr_wd = (pkr >> pk *2 ) &2 ; -uint32_t pkr_prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; - -if (pkr_ad) { - pkr_prot &= ~(PAGE_READ |PAGE_WRITE ); - }else if (pkr_wd && (is_user || env->cr[0 ] &CR0_WP_MASK )) { - pkr_prot &= ~PAGE_WRITE ; - } - - prot &= pkr_prot; -if ((pkr_prot & (1 << is_write1)) ==0 ) { -assert (is_write1 !=2 ); - error_code |=PG_ERROR_PK_MASK ; - goto do_fault_protect; - } - } - -if ((prot & (1 << is_write1)) ==0 ) { - goto do_fault_protect; - } - -/* yes, it can! */ - is_dirty = is_write && !(pte &PG_DIRTY_MASK ); -if (!(pte &PG_ACCESSED_MASK ) || is_dirty) { - pte |=PG_ACCESSED_MASK ; -if (is_dirty) { - pte |=PG_DIRTY_MASK ; - } -x86_stl_phys_notdirty (cs, pte_addr, pte); - } - -if (!(pte &PG_DIRTY_MASK )) { -/* only set write access if already dirty... otherwise wait -for dirty access */ -assert (!is_write); - prot &= ~PAGE_WRITE ; - } - - do_mapping: - pte = pte & a20_mask; - -/* align to page_size */ - pte &=PG_ADDRESS_MASK & ~(page_size -1 ); - page_offset = addr & (page_size -1 ); - paddr =get_hphys (cs, pte + page_offset, is_write1, &prot); - -/* Even if 4MB pages, we map only one 4KB page in the cache to -avoid filling it too fast */ - vaddr = addr &TARGET_PAGE_MASK ; - paddr &=TARGET_PAGE_MASK ; - -assert (prot & (1 << is_write1)); -tlb_set_page_with_attrs (cs, vaddr, paddr,cpu_get_mem_attrs (env), - prot, mmu_idx, page_size); -return 0 ; - do_fault_rsvd: - error_code |=PG_ERROR_RSVD_MASK ; - do_fault_protect: - error_code |=PG_ERROR_P_MASK ; - do_fault: - error_code |= (is_write <<PG_ERROR_W_BIT ); -if (is_user) - error_code |=PG_ERROR_U_MASK ; -if (is_write1 ==2 && - (((env->efer &MSR_EFER_NXE ) && - (env->cr[4 ] &CR4_PAE_MASK )) || - (env->cr[4 ] &CR4_SMEP_MASK ))) - error_code |=PG_ERROR_I_D_MASK ; -if (env->intercept_exceptions & (1 <<EXCP0E_PAGE )) { -/* cr2 is not modified in case of exceptions */ -x86_stq_phys (cs, - env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), - addr); - }else { - env->cr[2 ] = addr; - } - env->error_code = error_code; - cs->exception_index =EXCP0E_PAGE ; -return 1 ; -} -#endif - -bool x86_cpu_tlb_fill (CPUState *cs,vaddr addr,int size, -MMUAccessType access_type,int mmu_idx, -bool probe,uintptr_t retaddr) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; - -#ifdef CONFIG_USER_ONLY -/* user mode only emulation */ - env->cr[2 ] = addr; - env->error_code = (access_type ==MMU_DATA_STORE ) <<PG_ERROR_W_BIT ; - env->error_code |=PG_ERROR_U_MASK ; - cs->exception_index =EXCP0E_PAGE ; - env->exception_is_int =0 ; - env->exception_next_eip =-1 ; -cpu_loop_exit_restore (cs, retaddr); -#else - env->retaddr = retaddr; -if (handle_mmu_fault (cs, addr, size, access_type, mmu_idx)) { -/* FIXME: On error in get_hphys we have already jumped out. */ -g_assert (!probe); -raise_exception_err_ra (env, cs->exception_index, - env->error_code, retaddr); - } -return true; -#endif -}
target/i386/tcg/sysemu/excp_helper.c new file +582 -0
582 lines not on this page · raw message
target/i386/tcg/sysemu/meson.build +1 -0
@@ -1,4 +1,5 @@ i386_softmmu_ss.add(when: ['CONFIG_TCG', 'CONFIG_SOFTMMU'], if_true: files( 'tcg-cpu.c', 'smm_helper.c', + 'excp_helper.c', ))
target/i386/tcg/user/excp_helper.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* x86 exception helpers - user-mode specific code +* +* Copyright (c) 2003 Fabrice Bellard +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "exec/exec-all.h" +#include "tcg/helper-tcg.h" + +bool x86_cpu_tlb_fill (CPUState *cs,vaddr addr,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + + env->cr[2 ] = addr; + env->error_code = (access_type ==MMU_DATA_STORE ) <<PG_ERROR_W_BIT ; + env->error_code |=PG_ERROR_U_MASK ; + cs->exception_index =EXCP0E_PAGE ; + env->exception_is_int =0 ; + env->exception_next_eip =-1 ; +cpu_loop_exit_restore (cs, retaddr); +}
target/i386/tcg/user/meson.build +1 -0
@@ -1,2 +1,3 @@ i386_user_ss.add(when: ['CONFIG_TCG', 'CONFIG_USER_ONLY'], if_true: files( + 'excp_helper.c', ))
Signature · 1 line
2.26.2
[PULL 17/33] target/i386: gdbstub: introduce aux functions to read/write CS64 regs
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
a number of registers are read as 64bit under the condition that (hflags & HF_CS64_MASK) || TARGET_X86_64)
and a number of registers are written as 64bit under the condition that (hflags & HF_CS64_MASK).
Provide some auxiliary functions that do that.
Message-Id: <[email protected]>
--- target/i386/gdbstub.c | 155 ++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 104 deletions(-)
target/i386/gdbstub.c +51 -104
@@ -78,6 +78,23 @@ static const int gpr_map32[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };#define GDB_FORCE_64 0#endif +static int gdb_read_reg_cs64 (uint32_t hflags,GByteArray *buf,target_ulong val) +{ +if ((hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { +return gdb_get_reg64 (buf, val); + } +return gdb_get_reg32 (buf, val); +} + +static int gdb_write_reg_cs64 (uint32_t hflags,uint8_t *buf,target_ulong *val) +{ +if (hflags &HF_CS64_MASK ) { + *val =ldq_p (buf); +return 8 ; + } + *val =ldl_p (buf); +return 4 ; +}int x86_cpu_gdb_read_register (CPUState *cs,GByteArray *mem_buf,int n) {
@@ -142,25 +159,14 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)return gdb_get_reg32 (mem_buf, env->segs[R_FS ].selector);case IDX_SEG_REGS +5 :return gdb_get_reg32 (mem_buf, env->segs[R_GS ].selector); -case IDX_SEG_REGS +6 : -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, env->segs[R_FS ].base); - } -return gdb_get_reg32 (mem_buf, env->segs[R_FS ].base); - +return gdb_read_reg_cs64 (env->hflags, mem_buf, env->segs[R_FS ].base);case IDX_SEG_REGS +7 : -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, env->segs[R_GS ].base); - } -return gdb_get_reg32 (mem_buf, env->segs[R_GS ].base); +return gdb_read_reg_cs64 (env->hflags, mem_buf, env->segs[R_GS ].base);case IDX_SEG_REGS +8 :#ifdef TARGET_X86_64 -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, env->kernelgsbase); - } -return gdb_get_reg32 (mem_buf, env->kernelgsbase); +return gdb_read_reg_cs64 (env->hflags, mem_buf, env->kernelgsbase);#else return gdb_get_reg32 (mem_buf,0 );#endif
@@ -188,45 +194,23 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)return gdb_get_reg32 (mem_buf, env->mxcsr);case IDX_CTL_CR0_REG : -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, env->cr[0 ]); - } -return gdb_get_reg32 (mem_buf, env->cr[0 ]); - +return gdb_read_reg_cs64 (env->hflags, mem_buf, env->cr[0 ]);case IDX_CTL_CR2_REG : -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, env->cr[2 ]); - } -return gdb_get_reg32 (mem_buf, env->cr[2 ]); - +return gdb_read_reg_cs64 (env->hflags, mem_buf, env->cr[2 ]);case IDX_CTL_CR3_REG : -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, env->cr[3 ]); - } -return gdb_get_reg32 (mem_buf, env->cr[3 ]); - +return gdb_read_reg_cs64 (env->hflags, mem_buf, env->cr[3 ]);case IDX_CTL_CR4_REG : -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, env->cr[4 ]); - } -return gdb_get_reg32 (mem_buf, env->cr[4 ]); - +return gdb_read_reg_cs64 (env->hflags, mem_buf, env->cr[4 ]);case IDX_CTL_CR8_REG : -#ifdef CONFIG_SOFTMMU +#ifndef CONFIG_USER_ONLY tpr =cpu_get_apic_tpr (cpu->apic_state);#else tpr =0 ;#endif -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, tpr); - } -return gdb_get_reg32 (mem_buf, tpr); +return gdb_read_reg_cs64 (env->hflags, mem_buf, tpr);case IDX_CTL_EFER_REG : -if ((env->hflags &HF_CS64_MASK ) ||GDB_FORCE_64 ) { -return gdb_get_reg64 (mem_buf, env->efer); - } -return gdb_get_reg32 (mem_buf, env->efer); +return gdb_read_reg_cs64 (env->hflags, mem_buf, env->efer); } }return 0 ;
@@ -266,7 +250,8 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) {X86CPU *cpu =X86_CPU (cs);CPUX86State *env = &cpu->env; -uint32_t tmp; +target_ulong tmp; +int len;/* N.B. GDB can't deal with changes in registers or sizes in the middle of a session. So if we're in 32-bit mode on a 64-bit cpu, still act
@@ -329,30 +314,13 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)return x86_cpu_gdb_load_seg (cpu,R_FS , mem_buf);case IDX_SEG_REGS +5 :return x86_cpu_gdb_load_seg (cpu,R_GS , mem_buf); -case IDX_SEG_REGS +6 : -if (env->hflags &HF_CS64_MASK ) { - env->segs[R_FS ].base =ldq_p (mem_buf); -return 8 ; - } - env->segs[R_FS ].base =ldl_p (mem_buf); -return 4 ; - +return gdb_write_reg_cs64 (env->hflags, mem_buf, &env->segs[R_FS ].base);case IDX_SEG_REGS +7 : -if (env->hflags &HF_CS64_MASK ) { - env->segs[R_GS ].base =ldq_p (mem_buf); -return 8 ; - } - env->segs[R_GS ].base =ldl_p (mem_buf); -return 4 ; - +return gdb_write_reg_cs64 (env->hflags, mem_buf, &env->segs[R_GS ].base);case IDX_SEG_REGS +8 :#ifdef TARGET_X86_64 -if (env->hflags &HF_CS64_MASK ) { - env->kernelgsbase =ldq_p (mem_buf); -return 8 ; - } - env->kernelgsbase =ldl_p (mem_buf); +return gdb_write_reg_cs64 (env->hflags, mem_buf, &env->kernelgsbase);#endif return 4 ;
@@ -382,57 +350,36 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)return 4 ;case IDX_CTL_CR0_REG : -if (env->hflags &HF_CS64_MASK ) { -cpu_x86_update_cr0 (env,ldq_p (mem_buf)); -return 8 ; - } -cpu_x86_update_cr0 (env,ldl_p (mem_buf)); -return 4 ; + len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +cpu_x86_update_cr0 (env, tmp); +return len;case IDX_CTL_CR2_REG : -if (env->hflags &HF_CS64_MASK ) { - env->cr[2 ] =ldq_p (mem_buf); -return 8 ; - } - env->cr[2 ] =ldl_p (mem_buf); -return 4 ; + len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); + env->cr[2 ] = tmp; +return len;case IDX_CTL_CR3_REG : -if (env->hflags &HF_CS64_MASK ) { -cpu_x86_update_cr3 (env,ldq_p (mem_buf)); -return 8 ; - } -cpu_x86_update_cr3 (env,ldl_p (mem_buf)); -return 4 ; + len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +cpu_x86_update_cr3 (env, tmp); +return len;case IDX_CTL_CR4_REG : -if (env->hflags &HF_CS64_MASK ) { -cpu_x86_update_cr4 (env,ldq_p (mem_buf)); -return 8 ; - } -cpu_x86_update_cr4 (env,ldl_p (mem_buf)); -return 4 ; + len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +cpu_x86_update_cr4 (env, tmp); +return len;case IDX_CTL_CR8_REG : -if (env->hflags &HF_CS64_MASK ) { -#ifdef CONFIG_SOFTMMU -cpu_set_apic_tpr (cpu->apic_state,ldq_p (mem_buf)); + len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +#ifndef CONFIG_USER_ONLY +cpu_set_apic_tpr (cpu->apic_state, tmp);#endif -return 8 ; - } -#ifdef CONFIG_SOFTMMU -cpu_set_apic_tpr (cpu->apic_state,ldl_p (mem_buf)); -#endif -return 4 ; +return len;case IDX_CTL_EFER_REG : -if (env->hflags &HF_CS64_MASK ) { -cpu_load_efer (env,ldq_p (mem_buf)); -return 8 ; - } -cpu_load_efer (env,ldl_p (mem_buf)); -return 4 ; - + len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +cpu_load_efer (env, tmp); +return len; } }/* Unrecognised register. */
Signature · 1 line
2.26.2
[PULL 19/33] i386: make cpu_load_efer sysemu-only
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
cpu_load_efer is now used only for sysemu code.
Therefore, move this function implementation to
sysemu-only section of helper.c
Message-Id: <[email protected]>
--- target/i386/cpu.h | 20 +++++--------------- target/i386/helper.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-)
target/i386/cpu.h +5 -15
@@ -1958,6 +1958,11 @@ static inline AddressSpace *cpu_addressspace(CPUState *cs, MemTxAttrs attrs)return cpu_get_address_space (cs,cpu_asidx_from_attrs (cs, attrs)); } +/* +* load efer and update the corresponding hflags. XXX: do consistency +* checks with cpuid bits? +*/ +void cpu_load_efer (CPUX86State *env,uint64_t val);uint8_t x86_ldub_phys (CPUState *cs,hwaddr addr);uint32_t x86_lduw_phys (CPUState *cs,hwaddr addr);uint32_t x86_ldl_phys (CPUState *cs,hwaddr addr);
@@ -2054,21 +2059,6 @@ static inline uint32_t cpu_compute_eflags(CPUX86State *env)return eflags; } - -/* load efer and update the corresponding hflags. XXX: do consistency -checks with cpuid bits? */ -static inline void cpu_load_efer (CPUX86State *env,uint64_t val) -{ - env->efer = val; - env->hflags &= ~(HF_LMA_MASK |HF_SVME_MASK ); -if (env->efer &MSR_EFER_LMA ) { - env->hflags |=HF_LMA_MASK ; - } -if (env->efer &MSR_EFER_SVME ) { - env->hflags |=HF_SVME_MASK ; - } -} -static inline MemTxAttrs cpu_get_mem_attrs (CPUX86State *env) {return ((MemTxAttrs ) { .secure = (env->hflags &HF_SMM_MASK ) !=0 });
target/i386/helper.c +13 -0
@@ -574,6 +574,19 @@ void do_cpu_sipi(X86CPU *cpu)#endif #ifndef CONFIG_USER_ONLY + +void cpu_load_efer (CPUX86State *env,uint64_t val) +{ + env->efer = val; + env->hflags &= ~(HF_LMA_MASK |HF_SVME_MASK ); +if (env->efer &MSR_EFER_LMA ) { + env->hflags |=HF_LMA_MASK ; + } +if (env->efer &MSR_EFER_SVME ) { + env->hflags |=HF_SVME_MASK ; + } +} +uint8_t x86_ldub_phys (CPUState *cs,hwaddr addr) {X86CPU *cpu =X86_CPU (cs);
Signature · 1 line
2.26.2
[PULL 11/33] i386: move TCG bpt_helper into sysemu/
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
for user-mode, assert that the hidden IOBPT flags are not set while attempting to generate io_bpt helpers.
Message-Id: <[email protected]>
--- target/i386/helper.h | 7 + target/i386/tcg/bpt_helper.c | 276 -------------------------- target/i386/tcg/helper-tcg.h | 3 + target/i386/tcg/sysemu/bpt_helper.c | 293 ++++++++++++++++++++++++++++ target/i386/tcg/sysemu/meson.build | 1 + target/i386/tcg/translate.c | 8 +- 6 files changed, 311 insertions(+), 277 deletions(-) create mode 100644 target/i386/tcg/sysemu/bpt_helper.c
target/i386/helper.h +7 -0
@@ -46,7 +46,11 @@ DEF_HELPER_2(read_crN, tl, env, int) DEF_HELPER_3(write_crN, void, env, int, tl) DEF_HELPER_2(lmsw, void, env, tl) DEF_HELPER_1(clts, void, env) + +#ifndef CONFIG_USER_ONLY DEF_HELPER_FLAGS_3(set_dr, TCG_CALL_NO_WG, void, env, int, tl) +#endif /* !CONFIG_USER_ONLY */ + DEF_HELPER_FLAGS_2(get_dr, TCG_CALL_NO_WG, tl, env, int)DEF_HELPER_2 (invlpg, void, env, tl)
@@ -100,7 +104,10 @@ DEF_HELPER_3(outw, void, env, i32, i32) DEF_HELPER_2(inw, tl, env, i32) DEF_HELPER_3(outl, void, env, i32, i32) DEF_HELPER_2(inl, tl, env, i32) + +#ifndef CONFIG_USER_ONLY DEF_HELPER_FLAGS_4(bpt_io, TCG_CALL_NO_WG, void, env, i32, i32, tl) +#endif /* !CONFIG_USER_ONLY */ DEF_HELPER_3(svm_check_intercept_param, void, env, i32, i64)DEF_HELPER_4 (svm_check_io, void, env, i32, i32, i32)
target/i386/tcg/bpt_helper.c +0 -276
294 lines not on this page · raw message
target/i386/tcg/helper-tcg.h +3 -0
@@ -88,4 +88,7 @@ void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw);/* smm_helper.c */ void do_smm_enter (X86CPU *cpu); +/* bpt_helper.c */ +bool check_hw_breakpoints (CPUX86State *env,bool force_dr6_update); +#endif /* I386_HELPER_TCG_H */
target/i386/tcg/sysemu/bpt_helper.c new file +293 -0
293 lines not on this page · raw message
target/i386/tcg/sysemu/meson.build +1 -0
@@ -2,4 +2,5 @@ i386_softmmu_ss.add(when: ['CONFIG_TCG', 'CONFIG_SOFTMMU'], if_true: files( 'tcg-cpu.c', 'smm_helper.c', 'excp_helper.c', + 'bpt_helper.c', ))
target/i386/tcg/translate.c +7 -1
@@ -1117,16 +1117,20 @@ static inline void gen_cmps(DisasContext *s, MemOp ot)static void gen_bpt_io (DisasContext *s,TCGv_i32 t_port,int ot) {if (s->flags &HF_IOBPT_MASK ) { +#ifdef CONFIG_USER_ONLY +/* user-mode cpu should not be in IOBPT mode */ +g_assert_not_reached (); +#else TCGv_i32 t_size =tcg_const_i32 (1 << ot);TCGv t_next =tcg_const_tl (s->pc - s->cs_base);gen_helper_bpt_io (cpu_env, t_port, t_size, t_next);tcg_temp_free_i32 (t_size);tcg_temp_free (t_next); +#endif /* CONFIG_USER_ONLY */ } } -static inline void gen_ins (DisasContext *s,MemOp ot) {gen_string_movl_A0_EDI (s);
@@ -8061,6 +8065,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)if (s->cpl !=0 ) {gen_exception (s,EXCP0D_GPF , pc_start - s->cs_base); }else { +#ifndef CONFIG_USER_ONLY modrm =x86_ldub_code (env, s);/* Ignore the mod bits (assume (modrm&0xc0)==0xc0). * AMD documentation (24594.pdf) and testing of
@@ -8089,6 +8094,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_helper_get_dr (s->T0, cpu_env, s->tmp2_i32); gen_op_mov_reg_v(s, ot, rm, s->T0); } +#endif /* !CONFIG_USER_ONLY */ }break ;case 0x106 :/* clts */
Signature · 1 line
2.26.2
[PULL 18/33] target/i386: gdbstub: only write CR0/CR2/CR3/EFER for sysemu
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
Message-Id: <[email protected]>
--- target/i386/gdbstub.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
target/i386/gdbstub.c +10 -0
@@ -351,22 +351,30 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)case IDX_CTL_CR0_REG : len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +#ifndef CONFIG_USER_ONLY cpu_x86_update_cr0 (env, tmp); +#endif return len;case IDX_CTL_CR2_REG : len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +#ifndef CONFIG_USER_ONLY env->cr[2 ] = tmp; +#endif return len;case IDX_CTL_CR3_REG : len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +#ifndef CONFIG_USER_ONLY cpu_x86_update_cr3 (env, tmp); +#endif return len;case IDX_CTL_CR4_REG : len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +#ifndef CONFIG_USER_ONLY cpu_x86_update_cr4 (env, tmp); +#endif return len;case IDX_CTL_CR8_REG :
@@ -378,7 +386,9 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)case IDX_CTL_EFER_REG : len =gdb_write_reg_cs64 (env->hflags, mem_buf, &tmp); +#ifndef CONFIG_USER_ONLY cpu_load_efer (env, tmp); +#endif return len; } }
Signature · 1 line
2.26.2
[PULL 28/33] target/i386: use mmu_translate for NPT walk
In reply to Paolo BonziniUnify the duplicate code between get_hphys and mmu_translate, by simply making get_hphys call mmu_translate. This also fixes the support for 5-level nested page tables.
--- target/i386/tcg/sysemu/excp_helper.c | 243 ++++----------------------- 1 file changed, 36 insertions(+), 207 deletions(-)
target/i386/tcg/sysemu/excp_helper.c +36 -207
@@ -54,210 +54,6 @@ int get_pg_mode(CPUX86State *env)return pg_mode; } -static hwaddr get_hphys (CPUState *cs,hwaddr gphys,MMUAccessType access_type, -int *prot) -{ -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; -uint64_t rsvd_mask =PG_ADDRESS_MASK & ~MAKE_64BIT_MASK (0 , cpu->phys_bits); -uint64_t ptep, pte; -uint64_t exit_info_1 =0 ; -target_ulong pde_addr, pte_addr; -uint32_t page_offset; -int page_size; - -if (likely (!(env->hflags2 &HF2_NPT_MASK ))) { -return gphys; - } - -if (!(env->nested_pg_mode &PG_MODE_NXE )) { - rsvd_mask |=PG_NX_MASK ; - } - -if (env->nested_pg_mode &PG_MODE_PAE ) { -uint64_t pde, pdpe; -target_ulong pdpe_addr; - -#ifdef TARGET_X86_64 -if (env->nested_pg_mode &PG_MODE_LMA ) { -uint64_t pml5e; -uint64_t pml4e_addr, pml4e; - - pml5e = env->nested_cr3; - ptep =PG_NX_MASK |PG_USER_MASK |PG_RW_MASK ; - - pml4e_addr = (pml5e &PG_ADDRESS_MASK ) + - (((gphys >>39 ) &0x1ff ) <<3 ); - pml4e =x86_ldq_phys (cs, pml4e_addr); -if (!(pml4e &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pml4e & (rsvd_mask |PG_PSE_MASK )) { - goto do_fault_rsvd; - } -if (!(pml4e &PG_ACCESSED_MASK )) { - pml4e |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pml4e_addr, pml4e); - } - ptep &= pml4e ^PG_NX_MASK ; - pdpe_addr = (pml4e &PG_ADDRESS_MASK ) + - (((gphys >>30 ) &0x1ff ) <<3 ); - pdpe =x86_ldq_phys (cs, pdpe_addr); -if (!(pdpe &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pdpe & rsvd_mask) { - goto do_fault_rsvd; - } - ptep &= pdpe ^PG_NX_MASK ; -if (!(pdpe &PG_ACCESSED_MASK )) { - pdpe |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pdpe_addr, pdpe); - } -if (pdpe &PG_PSE_MASK ) { -/* 1 GB page */ - page_size =1024 *1024 *1024 ; - pte_addr = pdpe_addr; - pte = pdpe; - goto do_check_protect; - } - } else -#endif - { - pdpe_addr = (env->nested_cr3 & ~0x1f ) + ((gphys >>27 ) &0x18 ); - pdpe =x86_ldq_phys (cs, pdpe_addr); -if (!(pdpe &PG_PRESENT_MASK )) { - goto do_fault; - } - rsvd_mask |=PG_HI_USER_MASK ; -if (pdpe & (rsvd_mask |PG_NX_MASK )) { - goto do_fault_rsvd; - } - ptep =PG_NX_MASK |PG_USER_MASK |PG_RW_MASK ; - } - - pde_addr = (pdpe &PG_ADDRESS_MASK ) + (((gphys >>21 ) &0x1ff ) <<3 ); - pde =x86_ldq_phys (cs, pde_addr); -if (!(pde &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pde & rsvd_mask) { - goto do_fault_rsvd; - } - ptep &= pde ^PG_NX_MASK ; -if (pde &PG_PSE_MASK ) { -/* 2 MB page */ - page_size =2048 *1024 ; - pte_addr = pde_addr; - pte = pde; - goto do_check_protect; - } -/* 4 KB page */ -if (!(pde &PG_ACCESSED_MASK )) { - pde |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pde_addr, pde); - } - pte_addr = (pde &PG_ADDRESS_MASK ) + (((gphys >>12 ) &0x1ff ) <<3 ); - pte =x86_ldq_phys (cs, pte_addr); -if (!(pte &PG_PRESENT_MASK )) { - goto do_fault; - } -if (pte & rsvd_mask) { - goto do_fault_rsvd; - } -/* combine pde and pte nx, user and rw protections */ - ptep &= pte ^PG_NX_MASK ; - page_size =4096 ; - }else { -uint32_t pde; - -/* page directory entry */ - pde_addr = (env->nested_cr3 & ~0xfff ) + ((gphys >>20 ) &0xffc ); - pde =x86_ldl_phys (cs, pde_addr); -if (!(pde &PG_PRESENT_MASK )) { - goto do_fault; - } - ptep = pde |PG_NX_MASK ; - -/* if host cr4 PSE bit is set, then we use a 4MB page */ -if ((pde &PG_PSE_MASK ) && (env->nested_pg_mode &PG_MODE_PSE )) { - page_size =4096 *1024 ; - pte_addr = pde_addr; - -/* Bits 20-13 provide bits 39-32 of the address, bit 21 is reserved. -* Leave bits 20-13 in place for setting accessed/dirty bits below. -*/ - pte = pde | ((pde &0x1fe000LL ) << (32 -13 )); - rsvd_mask =0x200000 ; - goto do_check_protect_pse36; - } - -if (!(pde &PG_ACCESSED_MASK )) { - pde |=PG_ACCESSED_MASK ; -x86_stl_phys_notdirty (cs, pde_addr, pde); - } - -/* page directory entry */ - pte_addr = (pde & ~0xfff ) + ((gphys >>10 ) &0xffc ); - pte =x86_ldl_phys (cs, pte_addr); -if (!(pte &PG_PRESENT_MASK )) { - goto do_fault; - } -/* combine pde and pte user and rw protections */ - ptep &= pte |PG_NX_MASK ; - page_size =4096 ; - rsvd_mask =0 ; - } - - do_check_protect: - rsvd_mask |= (page_size -1 ) &PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK ; - do_check_protect_pse36: -if (pte & rsvd_mask) { - goto do_fault_rsvd; - } - ptep ^=PG_NX_MASK ; - -if (!(ptep &PG_USER_MASK )) { - goto do_fault_protect; - } -if (ptep &PG_NX_MASK ) { -if (access_type ==MMU_INST_FETCH ) { - goto do_fault_protect; - } - *prot &= ~PAGE_EXEC ; - } -if (!(ptep &PG_RW_MASK )) { -if (access_type ==MMU_DATA_STORE ) { - goto do_fault_protect; - } - *prot &= ~PAGE_WRITE ; - } - - pte &=PG_ADDRESS_MASK & ~(page_size -1 ); - page_offset = gphys & (page_size -1 ); -return pte + page_offset; - - do_fault_rsvd: - exit_info_1 |=PG_ERROR_RSVD_MASK ; - do_fault_protect: - exit_info_1 |=PG_ERROR_P_MASK ; - do_fault: - x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), - gphys); - exit_info_1 |=PG_ERROR_U_MASK ; -if (access_type ==MMU_DATA_STORE ) { - exit_info_1 |=PG_ERROR_W_MASK ; - }else if (access_type ==MMU_INST_FETCH ) { - exit_info_1 |=PG_ERROR_I_D_MASK ; - } -if (prot) { - exit_info_1 |=SVM_NPTEXIT_GPA ; - }else {/* page table access */ - exit_info_1 |=SVM_NPTEXIT_GPT ; - } -cpu_vmexit (env,SVM_EXIT_NPF , exit_info_1, env->retaddr); -} -#define PG_ERROR_OK (-1) typedef hwaddr (*MMUTranslateFunc)(CPUState *cs, hwaddr gphys, MMUAccessType access_type,
@@ -266,9 +62,9 @@ typedef hwaddr (*MMUTranslateFunc)(CPUState *cs, hwaddr gphys, MMUAccessType acc#define GET_HPHYS (cs, gpa, access_type, prot) \ (get_hphys_func ? get_hphys_func(cs, gpa, access_type, prot) : gpa) -static int mmu_translate (CPUState *cs,vaddr addr,MMUTranslateFunc get_hphys_func, +static int mmu_translate (CPUState *cs,hwaddr addr,MMUTranslateFunc get_hphys_func,uint64_t cr3,int is_write1,int mmu_idx,int pg_mode, -vaddr *xlat,int *page_size,int *prot) +hwaddr *xlat,int *page_size,int *prot) {X86CPU *cpu =X86_CPU (cs);CPUX86State *env = &cpu->env;
@@ -562,6 +358,39 @@ do_check_protect_pse36:return error_code; } +static hwaddr get_hphys (CPUState *cs,hwaddr gphys,MMUAccessType access_type, +int *prot) +{ +CPUX86State *env = &X86_CPU (cs)->env; +uint64_t exit_info_1; +int page_size; +int next_prot; +hwaddr hphys; + +if (likely (!(env->hflags2 &HF2_NPT_MASK ))) { +return gphys; + } + + exit_info_1 =mmu_translate (cs, gphys,NULL , env->nested_cr3, + access_type,MMU_USER_IDX , env->nested_pg_mode, + &hphys, &page_size, &next_prot); +if (exit_info_1 ==PG_ERROR_OK ) { +if (prot) { + *prot &= next_prot; + } +return hphys; + } + + x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), + gphys); +if (prot) { + exit_info_1 |=SVM_NPTEXIT_GPA ; + }else {/* page table access */ + exit_info_1 |=SVM_NPTEXIT_GPT ; + } +cpu_vmexit (env,SVM_EXIT_NPF , exit_info_1, env->retaddr); +} +/* return value: * -1 = cannot handle fault * 0 = nothing more to do
@@ -575,7 +404,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size,int error_code =PG_ERROR_OK ;int pg_mode, prot, page_size;hwaddr paddr; -target_ulong vaddr; +hwaddr vaddr;#if defined(DEBUG_MMU ) printf("MMU fault: addr=%" VADDR_PRIx " w=%d mmu=%d eip=" TARGET_FMT_lx "\n",
Signature · 1 line
2.26.2
[PULL 15/33] i386: split seg_helper into user-only and sysemu parts
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
[claudio]:
Rebased on commit 68775856 ("target/i386: svm: do not discard high 32 bits")
Message-Id: <[email protected]>
--- target/i386/tcg/helper-tcg.h | 5 + target/i386/tcg/seg_helper.c | 233 +--------------------------- target/i386/tcg/seg_helper.h | 66 ++++++++ target/i386/tcg/sysemu/meson.build | 1 + target/i386/tcg/sysemu/seg_helper.c | 125 +++++++++++++++ target/i386/tcg/user/meson.build | 1 + target/i386/tcg/user/seg_helper.c | 109 +++++++++++++ 7 files changed, 311 insertions(+), 229 deletions(-) create mode 100644 target/i386/tcg/seg_helper.h create mode 100644 target/i386/tcg/sysemu/seg_helper.c create mode 100644 target/i386/tcg/user/seg_helper.c
target/i386/tcg/helper-tcg.h +5 -0
@@ -84,6 +84,11 @@ void do_vmexit(CPUX86State *env);/* seg_helper.c */ void do_interrupt_x86_hardirq (CPUX86State *env,int intno,int is_hw); +void do_interrupt_all (X86CPU *cpu,int intno,int is_int, +int error_code,target_ulong next_eip,int is_hw); +void handle_even_inj (CPUX86State *env,int intno,int is_int, +int error_code,int is_hw,int rm); +int exception_has_error_code (int intno);/* smm_helper.c */ void do_smm_enter (X86CPU *cpu);
target/i386/tcg/seg_helper.c +4 -229
274 lines not on this page · raw message
target/i386/tcg/seg_helper.h new file +66 -0
66 lines not on this page · raw message
target/i386/tcg/sysemu/meson.build +1 -0
@@ -6,4 +6,5 @@ i386_softmmu_ss.add(when: ['CONFIG_TCG', 'CONFIG_SOFTMMU'], if_true: files( 'misc_helper.c', 'fpu_helper.c', 'svm_helper.c', + 'seg_helper.c', ))
target/i386/tcg/sysemu/seg_helper.c new file +125 -0
125 lines not on this page · raw message
target/i386/tcg/user/meson.build +1 -0
@@ -2,4 +2,5 @@ i386_user_ss.add(when: ['CONFIG_TCG', 'CONFIG_USER_ONLY'], if_true: files( 'excp_helper.c', 'misc_stubs.c', 'svm_stubs.c', + 'seg_helper.c', ))
target/i386/tcg/user/seg_helper.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 12/33] i386: split misc helper user stubs and sysemu part
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
[claudio]:
Rebased on da3f3b02("target/i386: fail if toggling LA57 in 64-bitmode")
Message-Id: <[email protected]>
--- target/i386/tcg/misc_helper.c | 467 --------------------------- target/i386/tcg/sysemu/meson.build | 1 + target/i386/tcg/sysemu/misc_helper.c | 442 +++++++++++++++++++++++++ target/i386/tcg/user/meson.build | 1 + target/i386/tcg/user/misc_stubs.c | 75 +++++ 5 files changed, 519 insertions(+), 467 deletions(-) create mode 100644 target/i386/tcg/sysemu/misc_helper.c create mode 100644 target/i386/tcg/user/misc_stubs.c
target/i386/tcg/misc_helper.c +0 -467
@@ -18,12 +18,9 @@*/ #include "qemu/osdep.h" -#include "qemu/main-loop.h" #include "cpu.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" -#include "exec/cpu_ldst.h" -#include "exec/address-spaces.h" #include "helper-tcg.h" /*
@@ -39,69 +36,6 @@ void cpu_load_eflags(CPUX86State *env, int eflags, int update_mask) (eflags & update_mask) |0x2 ; } -void helper_outb (CPUX86State *env,uint32_t port,uint32_t data) -{ -#ifdef CONFIG_USER_ONLY -fprintf (stderr,"outb: port=0x%04x, data=%02x\n" , port, data); -#else -address_space_stb (&address_space_io, port, data, -cpu_get_mem_attrs (env),NULL ); -#endif -} - -target_ulong helper_inb (CPUX86State *env,uint32_t port) -{ -#ifdef CONFIG_USER_ONLY -fprintf (stderr,"inb: port=0x%04x\n" , port); -return 0 ; -#else -return address_space_ldub (&address_space_io, port, -cpu_get_mem_attrs (env),NULL ); -#endif -} - -void helper_outw (CPUX86State *env,uint32_t port,uint32_t data) -{ -#ifdef CONFIG_USER_ONLY -fprintf (stderr,"outw: port=0x%04x, data=%04x\n" , port, data); -#else -address_space_stw (&address_space_io, port, data, -cpu_get_mem_attrs (env),NULL ); -#endif -} - -target_ulong helper_inw (CPUX86State *env,uint32_t port) -{ -#ifdef CONFIG_USER_ONLY -fprintf (stderr,"inw: port=0x%04x\n" , port); -return 0 ; -#else -return address_space_lduw (&address_space_io, port, -cpu_get_mem_attrs (env),NULL ); -#endif -} - -void helper_outl (CPUX86State *env,uint32_t port,uint32_t data) -{ -#ifdef CONFIG_USER_ONLY -fprintf (stderr,"outl: port=0x%04x, data=%08x\n" , port, data); -#else -address_space_stl (&address_space_io, port, data, -cpu_get_mem_attrs (env),NULL ); -#endif -} - -target_ulong helper_inl (CPUX86State *env,uint32_t port) -{ -#ifdef CONFIG_USER_ONLY -fprintf (stderr,"inl: port=0x%04x\n" , port); -return 0 ; -#else -return address_space_ldl (&address_space_io, port, -cpu_get_mem_attrs (env),NULL ); -#endif -} -void helper_into (CPUX86State *env,int next_eip_addend) {int eflags;
@@ -126,68 +60,6 @@ void helper_cpuid(CPUX86State *env) env->regs[R_EDX ] = edx; } -#if defined(CONFIG_USER_ONLY ) -target_ulong helper_read_crN (CPUX86State *env,int reg) -{ -return 0 ; -} - -void helper_write_crN (CPUX86State *env,int reg,target_ulong t0) -{ -} -#else -target_ulong helper_read_crN (CPUX86State *env,int reg) -{ -target_ulong val; - -cpu_svm_check_intercept_param (env,SVM_EXIT_READ_CR0 + reg,0 ,GETPC ()); -switch (reg) { -default : - val = env->cr[reg]; -break ; -case 8 : -if (!(env->hflags2 &HF2_VINTR_MASK )) { - val =cpu_get_apic_tpr (env_archcpu (env)->apic_state); - }else { - val = env->v_tpr; - } -break ; - } -return val; -} - -void helper_write_crN (CPUX86State *env,int reg,target_ulong t0) -{ -cpu_svm_check_intercept_param (env,SVM_EXIT_WRITE_CR0 + reg,0 ,GETPC ()); -switch (reg) { -case 0 : -cpu_x86_update_cr0 (env, t0); -break ; -case 3 : -cpu_x86_update_cr3 (env, t0); -break ; -case 4 : -if (((t0 ^ env->cr[4 ]) &CR4_LA57_MASK ) && - (env->hflags &HF_CS64_MASK )) { -raise_exception_ra (env,EXCP0D_GPF ,GETPC ()); - } -cpu_x86_update_cr4 (env, t0); -break ; -case 8 : -if (!(env->hflags2 &HF2_VINTR_MASK )) { -qemu_mutex_lock_iothread (); -cpu_set_apic_tpr (env_archcpu (env)->apic_state, t0); -qemu_mutex_unlock_iothread (); - } - env->v_tpr = t0 &0x0f ; -break ; -default : - env->cr[reg] = t0; -break ; - } -} -#endif -void helper_lmsw (CPUX86State *env,target_ulong t0) {/* only 4 lower bits of CR0 are modified. PE cannot be set to zero
@@ -237,345 +109,6 @@ void helper_rdpmc(CPUX86State *env)raise_exception_err (env,EXCP06_ILLOP ,0 ); } -#if defined(CONFIG_USER_ONLY ) -void helper_wrmsr (CPUX86State *env) -{ -} - -void helper_rdmsr (CPUX86State *env) -{ -} -#else -void helper_wrmsr (CPUX86State *env) -{ -uint64_t val; -CPUState *cs =env_cpu (env); - -cpu_svm_check_intercept_param (env,SVM_EXIT_MSR ,1 ,GETPC ()); - - val = ((uint32_t )env->regs[R_EAX ]) | - ((uint64_t )((uint32_t )env->regs[R_EDX ]) <<32 ); - -switch ((uint32_t )env->regs[R_ECX ]) { -case MSR_IA32_SYSENTER_CS : - env->sysenter_cs = val &0xffff ; -break ; -case MSR_IA32_SYSENTER_ESP : - env->sysenter_esp = val; -break ; -case MSR_IA32_SYSENTER_EIP : - env->sysenter_eip = val; -break ; -case MSR_IA32_APICBASE : -cpu_set_apic_base (env_archcpu (env)->apic_state, val); -break ; -case MSR_EFER : - { -uint64_t update_mask; - - update_mask =0 ; -if (env->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_SYSCALL ) { - update_mask |=MSR_EFER_SCE ; - } -if (env->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_LM ) { - update_mask |=MSR_EFER_LME ; - } -if (env->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_FFXSR ) { - update_mask |=MSR_EFER_FFXSR ; - } -if (env->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_NX ) { - update_mask |=MSR_EFER_NXE ; - } -if (env->features[FEAT_8000_0001_ECX ] &CPUID_EXT3_SVM ) { - update_mask |=MSR_EFER_SVME ; - } -if (env->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_FFXSR ) { - update_mask |=MSR_EFER_FFXSR ; - } -cpu_load_efer (env, (env->efer & ~update_mask) | - (val & update_mask)); - } -break ; -case MSR_STAR : - env->star = val; -break ; -case MSR_PAT : - env->pat = val; -break ; -case MSR_IA32_PKRS : -if (val &0xFFFFFFFF00000000ull ) { - goto error; - } - env->pkrs = val; -tlb_flush (cs); -break ; -case MSR_VM_HSAVE_PA : - env->vm_hsave = val; -break ; -#ifdef TARGET_X86_64 -case MSR_LSTAR : - env->lstar = val; -break ; -case MSR_CSTAR : - env->cstar = val; -break ; -case MSR_FMASK : - env->fmask = val; -break ; -case MSR_FSBASE : - env->segs[R_FS ].base = val; -break ; -case MSR_GSBASE : - env->segs[R_GS ].base = val; -break ; -case MSR_KERNELGSBASE : - env->kernelgsbase = val; -break ; -#endif -case MSR_MTRRphysBase (0 ): -case MSR_MTRRphysBase (1 ): -case MSR_MTRRphysBase (2 ): -case MSR_MTRRphysBase (3 ): -case MSR_MTRRphysBase (4 ): -case MSR_MTRRphysBase (5 ): -case MSR_MTRRphysBase (6 ): -case MSR_MTRRphysBase (7 ): - env->mtrr_var[((uint32_t )env->regs[R_ECX ] - -MSR_MTRRphysBase (0 )) /2 ].base = val; -break ; -case MSR_MTRRphysMask (0 ): -case MSR_MTRRphysMask (1 ): -case MSR_MTRRphysMask (2 ): -case MSR_MTRRphysMask (3 ): -case MSR_MTRRphysMask (4 ): -case MSR_MTRRphysMask (5 ): -case MSR_MTRRphysMask (6 ): -case MSR_MTRRphysMask (7 ): - env->mtrr_var[((uint32_t )env->regs[R_ECX ] - -MSR_MTRRphysMask (0 )) /2 ].mask = val; -break ; -case MSR_MTRRfix64K_00000: - env->mtrr_fixed[(uint32_t )env->regs[R_ECX ] - - MSR_MTRRfix64K_00000] = val; -break ; -case MSR_MTRRfix16K_80000: -case MSR_MTRRfix16K_A0000: - env->mtrr_fixed[(uint32_t )env->regs[R_ECX ] - - MSR_MTRRfix16K_80000 +1 ] = val; -break ; -case MSR_MTRRfix4K_C0000: -case MSR_MTRRfix4K_C8000: -case MSR_MTRRfix4K_D0000: -case MSR_MTRRfix4K_D8000: -case MSR_MTRRfix4K_E0000: -case MSR_MTRRfix4K_E8000: -case MSR_MTRRfix4K_F0000: -case MSR_MTRRfix4K_F8000: - env->mtrr_fixed[(uint32_t )env->regs[R_ECX ] - - MSR_MTRRfix4K_C0000 +3 ] = val; -break ; -case MSR_MTRRdefType: - env->mtrr_deftype = val; -break ; -case MSR_MCG_STATUS : - env->mcg_status = val; -break ; -case MSR_MCG_CTL : -if ((env->mcg_cap &MCG_CTL_P ) - && (val ==0 || val == ~(uint64_t )0 )) { - env->mcg_ctl = val; - } -break ; -case MSR_TSC_AUX : - env->tsc_aux = val; -break ; -case MSR_IA32_MISC_ENABLE : - env->msr_ia32_misc_enable = val; -break ; -case MSR_IA32_BNDCFGS : -/* FIXME: #GP if reserved bits are set. */ -/* FIXME: Extend highest implemented bit of linear address. */ - env->msr_bndcfgs = val; -cpu_sync_bndcs_hflags (env); -break ; -default : -if ((uint32_t )env->regs[R_ECX ] >=MSR_MC0_CTL - && (uint32_t )env->regs[R_ECX ] <MSR_MC0_CTL + - (4 * env->mcg_cap &0xff )) { -uint32_t offset = (uint32_t )env->regs[R_ECX ] -MSR_MC0_CTL ; -if ((offset &0x3 ) !=0 - || (val ==0 || val == ~(uint64_t )0 )) { - env->mce_banks[offset] = val; - } -break ; - } -/* XXX: exception? */ -break ; - } -return ; -error: -raise_exception_err_ra (env,EXCP0D_GPF ,0 ,GETPC ()); -} - -void helper_rdmsr (CPUX86State *env) -{ -X86CPU *x86_cpu =env_archcpu (env); -uint64_t val; - -cpu_svm_check_intercept_param (env,SVM_EXIT_MSR ,0 ,GETPC ()); - -switch ((uint32_t )env->regs[R_ECX ]) { -case MSR_IA32_SYSENTER_CS : - val = env->sysenter_cs; -break ; -case MSR_IA32_SYSENTER_ESP : - val = env->sysenter_esp; -break ; -case MSR_IA32_SYSENTER_EIP : - val = env->sysenter_eip; -break ; -case MSR_IA32_APICBASE : - val =cpu_get_apic_base (env_archcpu (env)->apic_state); -break ; -case MSR_EFER : - val = env->efer; -break ; -case MSR_STAR : - val = env->star; -break ; -case MSR_PAT : - val = env->pat; -break ; -case MSR_IA32_PKRS : - val = env->pkrs; -break ; -case MSR_VM_HSAVE_PA : - val = env->vm_hsave; -break ; -case MSR_IA32_PERF_STATUS : -/* tsc_increment_by_tick */ - val =1000ULL ; -/* CPU multiplier */ - val |= (((uint64_t )4ULL ) <<40 ); -break ; -#ifdef TARGET_X86_64 -case MSR_LSTAR : - val = env->lstar; -break ; -case MSR_CSTAR : - val = env->cstar; -break ; -case MSR_FMASK : - val = env->fmask; -break ; -case MSR_FSBASE : - val = env->segs[R_FS ].base; -break ; -case MSR_GSBASE : - val = env->segs[R_GS ].base; -break ; -case MSR_KERNELGSBASE : - val = env->kernelgsbase; -break ; -case MSR_TSC_AUX : - val = env->tsc_aux; -break ; -#endif -case MSR_SMI_COUNT : - val = env->msr_smi_count; -break ; -case MSR_MTRRphysBase (0 ): -case MSR_MTRRphysBase (1 ): -case MSR_MTRRphysBase (2 ): -case MSR_MTRRphysBase (3 ): -case MSR_MTRRphysBase (4 ): -case MSR_MTRRphysBase (5 ): -case MSR_MTRRphysBase (6 ): -case MSR_MTRRphysBase (7 ): - val = env->mtrr_var[((uint32_t )env->regs[R_ECX ] - -MSR_MTRRphysBase (0 )) /2 ].base; -break ; -case MSR_MTRRphysMask (0 ): -case MSR_MTRRphysMask (1 ): -case MSR_MTRRphysMask (2 ): -case MSR_MTRRphysMask (3 ): -case MSR_MTRRphysMask (4 ): -case MSR_MTRRphysMask (5 ): -case MSR_MTRRphysMask (6 ): -case MSR_MTRRphysMask (7 ): - val = env->mtrr_var[((uint32_t )env->regs[R_ECX ] - -MSR_MTRRphysMask (0 )) /2 ].mask; -break ; -case MSR_MTRRfix64K_00000: - val = env->mtrr_fixed[0 ]; -break ; -case MSR_MTRRfix16K_80000: -case MSR_MTRRfix16K_A0000: - val = env->mtrr_fixed[(uint32_t )env->regs[R_ECX ] - - MSR_MTRRfix16K_80000 +1 ]; -break ; -case MSR_MTRRfix4K_C0000: -case MSR_MTRRfix4K_C8000: -case MSR_MTRRfix4K_D0000: -case MSR_MTRRfix4K_D8000: -case MSR_MTRRfix4K_E0000: -case MSR_MTRRfix4K_E8000: -case MSR_MTRRfix4K_F0000: -case MSR_MTRRfix4K_F8000: - val = env->mtrr_fixed[(uint32_t )env->regs[R_ECX ] - - MSR_MTRRfix4K_C0000 +3 ]; -break ; -case MSR_MTRRdefType: - val = env->mtrr_deftype; -break ; -case MSR_MTRRcap: -if (env->features[FEAT_1_EDX ] &CPUID_MTRR ) { - val = MSR_MTRRcap_VCNT | MSR_MTRRcap_FIXRANGE_SUPPORT | - MSR_MTRRcap_WC_SUPPORTED; - }else { -/* XXX: exception? */ - val =0 ; - } -break ; -case MSR_MCG_CAP : - val = env->mcg_cap; -break ; -case MSR_MCG_CTL : -if (env->mcg_cap &MCG_CTL_P ) { - val = env->mcg_ctl; - }else { - val =0 ; - } -break ; -case MSR_MCG_STATUS : - val = env->mcg_status; -break ; -case MSR_IA32_MISC_ENABLE : - val = env->msr_ia32_misc_enable; -break ; -case MSR_IA32_BNDCFGS : - val = env->msr_bndcfgs; -break ; -case MSR_IA32_UCODE_REV : - val = x86_cpu->ucode_rev; -break ; -default : -if ((uint32_t )env->regs[R_ECX ] >=MSR_MC0_CTL - && (uint32_t )env->regs[R_ECX ] <MSR_MC0_CTL + - (4 * env->mcg_cap &0xff )) { -uint32_t offset = (uint32_t )env->regs[R_ECX ] -MSR_MC0_CTL ; - val = env->mce_banks[offset]; -break ; - } -/* XXX: exception? */ - val =0 ; -break ; - } - env->regs[R_EAX ] = (uint32_t )(val); - env->regs[R_EDX ] = (uint32_t )(val >>32 ); -} -#endif -static void do_pause (X86CPU *cpu) {CPUState *cs =CPU (cpu);
target/i386/tcg/sysemu/meson.build +1 -0
@@ -3,4 +3,5 @@ i386_softmmu_ss.add(when: ['CONFIG_TCG', 'CONFIG_SOFTMMU'], if_true: files( 'smm_helper.c', 'excp_helper.c', 'bpt_helper.c', + 'misc_helper.c', ))
target/i386/tcg/sysemu/misc_helper.c new file +442 -0
442 lines not on this page · raw message
target/i386/tcg/user/meson.build +1 -0
@@ -1,3 +1,4 @@ i386_user_ss.add(when: ['CONFIG_TCG', 'CONFIG_USER_ONLY'], if_true: files( 'excp_helper.c', + 'misc_stubs.c', ))
target/i386/tcg/user/misc_stubs.c new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 13/33] i386: separate fpu_helper sysemu-only parts
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
create a separate tcg/sysemu/fpu_helper.c for the sysemu-only parts.
For user mode, some small #ifdefs remain in tcg/fpu_helper.c which do not seem worth splitting into their own user-mode module.
Message-Id: <[email protected]>
--- target/i386/cpu.h | 3 ++ target/i386/tcg/fpu_helper.c | 41 +-------------------- target/i386/tcg/sysemu/fpu_helper.c | 57 +++++++++++++++++++++++++++++ target/i386/tcg/sysemu/meson.build | 1 + 4 files changed, 63 insertions(+), 39 deletions(-) create mode 100644 target/i386/tcg/sysemu/fpu_helper.c
target/i386/cpu.h +3 -0
@@ -1817,7 +1817,10 @@ int cpu_x86_support_mca_broadcast(CPUX86State *env);int cpu_get_pic_interrupt (CPUX86State *s);/* MSDOS compatibility mode FPU exception support */ void x86_register_ferr_irq (qemu_irq irq); +void fpu_check_raise_ferr_irq (CPUX86State *s);void cpu_set_ignne (void ); +void cpu_clear_ignne (void ); +/* mpx_helper.c */ void cpu_sync_bndcs_hflags (CPUX86State *env);
target/i386/tcg/fpu_helper.c +2 -39
63 lines not on this page · raw message
target/i386/tcg/sysemu/fpu_helper.c new file +57 -0
57 lines not on this page · raw message
target/i386/tcg/sysemu/meson.build +1 -0
@@ -4,4 +4,5 @@ i386_softmmu_ss.add(when: ['CONFIG_TCG', 'CONFIG_SOFTMMU'], if_true: files( 'excp_helper.c', 'bpt_helper.c', 'misc_helper.c', + 'fpu_helper.c', ))
Signature · 1 line
2.26.2
[PULL 27/33] target/i386: allow customizing the next phase of the translation
In reply to Paolo Bonzini--- target/i386/tcg/sysemu/excp_helper.c | 30 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-)
target/i386/tcg/sysemu/excp_helper.c +18 -12
@@ -260,7 +260,13 @@ static hwaddr get_hphys(CPUState *cs, hwaddr gphys, MMUAccessType access_type,#define PG_ERROR_OK (-1) -static int mmu_translate (CPUState *cs,vaddr addr, +typedef hwaddr (*MMUTranslateFunc )(CPUState *cs,hwaddr gphys,MMUAccessType access_type, +int *prot); + +#define GET_HPHYS (cs, gpa, access_type, prot) \ + (get_hphys_func ? get_hphys_func(cs, gpa, access_type, prot) : gpa) + +static int mmu_translate (CPUState *cs,vaddr addr,MMUTranslateFunc get_hphys_func,uint64_t cr3,int is_write1,int mmu_idx,int pg_mode,vaddr *xlat,int *page_size,int *prot) {
@@ -296,7 +302,7 @@ static int mmu_translate(CPUState *cs, vaddr addr,/* test virtual address sign extension */ sext = la57 ? (int64_t )addr >>56 : (int64_t )addr >>47 ; -if (sext !=0 && sext !=-1 ) { +if (get_hphys_func && sext !=0 && sext !=-1 ) { env->error_code =0 ; cs->exception_index =EXCP0D_GPF ;return 1 ;
@@ -305,7 +311,7 @@ static int mmu_translate(CPUState *cs, vaddr addr,if (la57) { pml5e_addr = ((cr3 & ~0xfff ) + (((addr >>48 ) &0x1ff ) <<3 )) & a20_mask; - pml5e_addr =get_hphys (cs, pml5e_addr,MMU_DATA_STORE ,NULL ); + pml5e_addr =GET_HPHYS (cs, pml5e_addr,MMU_DATA_STORE ,NULL ); pml5e =x86_ldq_phys (cs, pml5e_addr);if (!(pml5e &PG_PRESENT_MASK )) { goto do_fault;
@@ -325,7 +331,7 @@ static int mmu_translate(CPUState *cs, vaddr addr, pml4e_addr = ((pml5e &PG_ADDRESS_MASK ) + (((addr >>39 ) &0x1ff ) <<3 )) & a20_mask; - pml4e_addr =get_hphys (cs, pml4e_addr,MMU_DATA_STORE , false); + pml4e_addr =GET_HPHYS (cs, pml4e_addr,MMU_DATA_STORE ,NULL ); pml4e =x86_ldq_phys (cs, pml4e_addr);if (!(pml4e &PG_PRESENT_MASK )) { goto do_fault;
@@ -340,7 +346,7 @@ static int mmu_translate(CPUState *cs, vaddr addr, ptep &= pml4e ^PG_NX_MASK ; pdpe_addr = ((pml4e &PG_ADDRESS_MASK ) + (((addr >>30 ) &0x1ff ) <<3 )) & a20_mask; - pdpe_addr =get_hphys (cs, pdpe_addr,MMU_DATA_STORE ,NULL ); + pdpe_addr =GET_HPHYS (cs, pdpe_addr,MMU_DATA_STORE ,NULL ); pdpe =x86_ldq_phys (cs, pdpe_addr);if (!(pdpe &PG_PRESENT_MASK )) { goto do_fault;
@@ -366,7 +372,7 @@ static int mmu_translate(CPUState *cs, vaddr addr,/* XXX: load them when cr3 is loaded ? */ pdpe_addr = ((cr3 & ~0x1f ) + ((addr >>27 ) &0x18 )) & a20_mask; - pdpe_addr =get_hphys (cs, pdpe_addr,MMU_DATA_STORE , false); + pdpe_addr =GET_HPHYS (cs, pdpe_addr,MMU_DATA_STORE ,NULL ); pdpe =x86_ldq_phys (cs, pdpe_addr);if (!(pdpe &PG_PRESENT_MASK )) { goto do_fault;
@@ -380,7 +386,7 @@ static int mmu_translate(CPUState *cs, vaddr addr, pde_addr = ((pdpe &PG_ADDRESS_MASK ) + (((addr >>21 ) &0x1ff ) <<3 )) & a20_mask; - pde_addr =get_hphys (cs, pde_addr,MMU_DATA_STORE ,NULL ); + pde_addr =GET_HPHYS (cs, pde_addr,MMU_DATA_STORE ,NULL ); pde =x86_ldq_phys (cs, pde_addr);if (!(pde &PG_PRESENT_MASK )) { goto do_fault;
@@ -403,7 +409,7 @@ static int mmu_translate(CPUState *cs, vaddr addr, } pte_addr = ((pde &PG_ADDRESS_MASK ) + (((addr >>12 ) &0x1ff ) <<3 )) & a20_mask; - pte_addr =get_hphys (cs, pte_addr,MMU_DATA_STORE ,NULL ); + pte_addr =GET_HPHYS (cs, pte_addr,MMU_DATA_STORE ,NULL ); pte =x86_ldq_phys (cs, pte_addr);if (!(pte &PG_PRESENT_MASK )) { goto do_fault;
@@ -420,7 +426,7 @@ static int mmu_translate(CPUState *cs, vaddr addr,/* page directory entry */ pde_addr = ((cr3 & ~0xfff ) + ((addr >>20 ) &0xffc )) & a20_mask; - pde_addr =get_hphys (cs, pde_addr,MMU_DATA_STORE ,NULL ); + pde_addr =GET_HPHYS (cs, pde_addr,MMU_DATA_STORE ,NULL ); pde =x86_ldl_phys (cs, pde_addr);if (!(pde &PG_PRESENT_MASK )) { goto do_fault;
@@ -448,7 +454,7 @@ static int mmu_translate(CPUState *cs, vaddr addr,/* page directory entry */ pte_addr = ((pde & ~0xfff ) + ((addr >>10 ) &0xffc )) & a20_mask; - pte_addr =get_hphys (cs, pte_addr,MMU_DATA_STORE ,NULL ); + pte_addr =GET_HPHYS (cs, pte_addr,MMU_DATA_STORE ,NULL ); pte =x86_ldl_phys (cs, pte_addr);if (!(pte &PG_PRESENT_MASK )) { goto do_fault;
@@ -538,7 +544,7 @@ do_check_protect_pse36:/* align to page_size */ pte &=PG_ADDRESS_MASK & ~(*page_size -1 ); page_offset = addr & (*page_size -1 ); - *xlat =get_hphys (cs, pte + page_offset, is_write1, prot); + *xlat =GET_HPHYS (cs, pte + page_offset, is_write1, prot);return PG_ERROR_OK ; do_fault_rsvd:
@@ -588,7 +594,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size, page_size =4096 ; }else { pg_mode =get_pg_mode (env); - error_code =mmu_translate (cs, addr, env->cr[3 ], is_write1, + error_code =mmu_translate (cs, addr, get_hphys, env->cr[3 ], is_write1, mmu_idx, pg_mode, &paddr, &page_size, &prot); }
Signature · 1 line
2.26.2
[PULL 20/33] accel: move call to accel_init_interfaces
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
move the call for sysemu specifically in machine_run_board_init, mirror the calling sequence for user mode too.
Message-Id: <[email protected]>
--- bsd-user/main.c | 2 +- hw/core/machine.c | 1 + linux-user/main.c | 2 +- softmmu/vl.c | 1 - 4 files changed, 3 insertions(+), 3 deletions(-)
bsd-user/main.c +1 -1
@@ -913,8 +913,8 @@ int main(int argc, char **argv) {AccelClass *ac =ACCEL_GET_CLASS (current_accel ()); - ac->init_machine (NULL );accel_init_interfaces (ac); + ac->init_machine (NULL ); } cpu =cpu_create (cpu_type); env = cpu->env_ptr;
hw/core/machine.c +1 -0
@@ -1234,6 +1234,7 @@ void machine_run_board_init(MachineState *machine) "on", false); } +accel_init_interfaces (ACCEL_GET_CLASS (machine->accelerator)); machine_class->init (machine);phase_advance (PHASE_MACHINE_INITIALIZED ); }
linux-user/main.c +1 -1
@@ -729,8 +729,8 @@ int main(int argc, char **argv, char **envp) {AccelClass *ac =ACCEL_GET_CLASS (current_accel ()); - ac->init_machine (NULL );accel_init_interfaces (ac); + ac->init_machine (NULL ); } cpu =cpu_create (cpu_type); env = cpu->env_ptr;
softmmu/vl.c +0 -1
@@ -3595,7 +3595,6 @@ void qemu_init(int argc, char **argv, char **envp) current_machine->cpu_type =parse_cpu_option (cpu_option); }/* NB: for machine none cpu_type could STILL be NULL here! */ -accel_init_interfaces (ACCEL_GET_CLASS (current_machine->accelerator));qemu_resolve_machine_memdev ();parse_numa_opts (current_machine);
Signature · 1 line
2.26.2
[PULL 16/33] i386: split off sysemu part of cpu.c
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
Message-Id: <[email protected]>
--- target/i386/cpu-internal.h | 70 +++++++ target/i386/cpu-sysemu.c | 352 +++++++++++++++++++++++++++++++++ target/i386/cpu.c | 385 +------------------------------------ target/i386/meson.build | 1 + 4 files changed, 429 insertions(+), 379 deletions(-) create mode 100644 target/i386/cpu-internal.h create mode 100644 target/i386/cpu-sysemu.c
target/i386/cpu-internal.h new file +70 -0
@@ -0,0 +1,70 @@ +/* +* i386 CPU internal definitions to be shared between cpu.c and cpu-sysemu.c +* +* Copyright (c) 2003 Fabrice Bellard +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef I386_CPU_INTERNAL_H +#define I386_CPU_INTERNAL_H + +typedef enum FeatureWordType { +CPUID_FEATURE_WORD , +MSR_FEATURE_WORD , +}FeatureWordType ; + +typedef struct FeatureWordInfo { +FeatureWordType type; +/* feature flags names are taken from "Intel Processor Identification and +* the CPUID Instruction" and AMD's "CPUID Specification". +* In cases of disagreement between feature naming conventions, +* aliases may be added. +*/ +const char *feat_names[64 ]; +union { +/* If type==CPUID_FEATURE_WORD */ +struct { +uint32_t eax;/* Input EAX for CPUID */ +bool needs_ecx;/* CPUID instruction uses ECX as input */ +uint32_t ecx;/* Input ECX value for CPUID */ +int reg;/* output register (R_* constant) */ + } cpuid; +/* If type==MSR_FEATURE_WORD */ +struct { +uint32_t index; + } msr; + }; +uint64_t tcg_features;/* Feature flags supported by TCG */ +uint64_t unmigratable_flags;/* Feature flags known to be unmigratable */ +uint64_t migratable_flags;/* Feature flags known to be migratable */ +/* Features that shouldn't be auto-enabled by "-cpu host" */ +uint64_t no_autoenable_flags; +}FeatureWordInfo ; + +extern FeatureWordInfo feature_word_info[]; + +void x86_cpu_expand_features (X86CPU *cpu,Error **errp); + +#ifndef CONFIG_USER_ONLY +GuestPanicInformation *x86_cpu_get_crash_info (CPUState *cs); +void x86_cpu_get_crash_info_qom (Object *obj,Visitor *v, +const char *name,void *opaque,Error **errp); + +void x86_cpu_apic_create (X86CPU *cpu,Error **errp); +void x86_cpu_apic_realize (X86CPU *cpu,Error **errp); +void x86_cpu_machine_reset_cb (void *opaque); +#endif /* !CONFIG_USER_ONLY */ + +#endif /* I386_CPU_INTERNAL_H */
target/i386/cpu-sysemu.c new file +352 -0
352 lines not on this page · raw message
target/i386/cpu.c +6 -379
472 lines not on this page · raw message
target/i386/meson.build +1 -0
@@ -18,6 +18,7 @@ i386_softmmu_ss.add(files( 'arch_memory_mapping.c', 'machine.c', 'monitor.c', + 'cpu-sysemu.c', )) i386_user_ss = ss.source_set()
Signature · 1 line
2.26.2
[PULL 23/33] target/i386: move paging mode constants from SVM to cpu.h
In reply to Paolo BonziniWe will reuse the page walker for both SVM and regular accesses. To do so we will build a function that receives the currently active paging mode; start by including in cpu.h the constants and the function to go from cr4/hflags/efer to the paging mode.
--- target/i386/cpu.h | 8 ++++++++ target/i386/svm.h | 5 ----- target/i386/tcg/sysemu/excp_helper.c | 26 ++++++++++++++++++++++---- target/i386/tcg/sysemu/svm_helper.c | 13 +------------ 4 files changed, 31 insertions(+), 21 deletions(-)
target/i386/cpu.h +8 -0
@@ -303,6 +303,11 @@ typedef enum X86Seg {#define PG_ERROR_I_D_MASK 0x10#define PG_ERROR_PK_MASK 0x20 +#define PG_MODE_PAE (1 << 0) +#define PG_MODE_LMA (1 << 1) +#define PG_MODE_NXE (1 << 2) +#define PG_MODE_PSE (1 << 3) +#define MCG_CTL_P (1ULL<<8)/* MCG_CAP register available */ #define MCG_SER_P (1ULL<<24)/* MCA recovery/new status bits */ #define MCG_LMCE_P (1ULL<<27)/* Local Machine Check Supported */
@@ -2105,6 +2110,9 @@ static inline bool cpu_vmx_maybe_enabled(CPUX86State *env) ((env->cr[4 ] &CR4_VMXE_MASK ) || (env->hflags &HF_SMM_MASK )); } +/* excp_helper.c */ +int get_pg_mode (CPUX86State *env); +/* fpu_helper.c */ void update_fp_status (CPUX86State *env);void update_mxcsr_status (CPUX86State *env);
target/i386/svm.h +0 -5
@@ -132,11 +132,6 @@#define SVM_NPT_ENABLED (1 << 0) -#define SVM_NPT_PAE (1 << 0) -#define SVM_NPT_LMA (1 << 1) -#define SVM_NPT_NXE (1 << 2) -#define SVM_NPT_PSE (1 << 3) -#define SVM_NPTEXIT_GPA (1ULL << 32)#define SVM_NPTEXIT_GPT (1ULL << 33)
target/i386/tcg/sysemu/excp_helper.c +22 -4
@@ -21,6 +21,24 @@#include "cpu.h" #include "tcg/helper-tcg.h" +int get_pg_mode (CPUX86State *env) +{ +int pg_mode =0 ; +if (env->cr[4 ] &CR4_PAE_MASK ) { + pg_mode |=PG_MODE_PAE ; + } +if (env->cr[4 ] &CR4_PSE_MASK ) { + pg_mode |=PG_MODE_PSE ; + } +if (env->hflags &HF_LMA_MASK ) { + pg_mode |=PG_MODE_LMA ; + } +if (env->efer &MSR_EFER_NXE ) { + pg_mode |=PG_MODE_NXE ; + } +return pg_mode; +} +static hwaddr get_hphys (CPUState *cs,hwaddr gphys,MMUAccessType access_type,int *prot) {
@@ -37,16 +55,16 @@ static hwaddr get_hphys(CPUState *cs, hwaddr gphys, MMUAccessType access_type,return gphys; } -if (!(env->nested_pg_mode &SVM_NPT_NXE )) { +if (!(env->nested_pg_mode &PG_MODE_NXE )) { rsvd_mask |=PG_NX_MASK ; } -if (env->nested_pg_mode &SVM_NPT_PAE ) { +if (env->nested_pg_mode &PG_MODE_PAE ) {uint64_t pde, pdpe;target_ulong pdpe_addr;#ifdef TARGET_X86_64 -if (env->nested_pg_mode &SVM_NPT_LMA ) { +if (env->nested_pg_mode &PG_MODE_LMA ) {uint64_t pml5e;uint64_t pml4e_addr, pml4e;
@@ -147,7 +165,7 @@ static hwaddr get_hphys(CPUState *cs, hwaddr gphys, MMUAccessType access_type, ptep = pde |PG_NX_MASK ;/* if host cr4 PSE bit is set, then we use a 4MB page */ -if ((pde &PG_PSE_MASK ) && (env->nested_pg_mode &SVM_NPT_PSE )) { +if ((pde &PG_PSE_MASK ) && (env->nested_pg_mode &PG_MODE_PSE )) { page_size =4096 *1024 ; pte_addr = pde_addr;
target/i386/tcg/sysemu/svm_helper.c +1 -12
@@ -163,18 +163,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend) control.nested_cr3)); env->hflags2 |=HF2_NPT_MASK ; -if (env->cr[4 ] &CR4_PAE_MASK ) { - env->nested_pg_mode |=SVM_NPT_PAE ; - } -if (env->cr[4 ] &CR4_PSE_MASK ) { - env->nested_pg_mode |=SVM_NPT_PSE ; - } -if (env->hflags &HF_LMA_MASK ) { - env->nested_pg_mode |=SVM_NPT_LMA ; - } -if (env->efer &MSR_EFER_NXE ) { - env->nested_pg_mode |=SVM_NPT_NXE ; - } + env->nested_pg_mode =get_pg_mode (env); }/* enable intercepts */
Signature · 1 line
2.26.2
[PULL 25/33] target/i386: pass cr3 to mmu_translate
In reply to Paolo BonziniFirst step in unifying the nested and regular page table walk.
--- target/i386/tcg/sysemu/excp_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target/i386/tcg/sysemu/excp_helper.c +6 -6
@@ -246,7 +246,7 @@ static hwaddr get_hphys(CPUState *cs, hwaddr gphys, MMUAccessType access_type,#define PG_ERROR_OK (-1)static int mmu_translate (CPUState *cs,vaddr addr, -int is_write1,int mmu_idx, +uint64_t cr3,int is_write1,int mmu_idx,vaddr *xlat,int *page_size,int *prot) {X86CPU *cpu =X86_CPU (cs);
@@ -288,7 +288,7 @@ static int mmu_translate(CPUState *cs, vaddr addr, }if (la57) { - pml5e_addr = ((env->cr[3 ] & ~0xfff ) + + pml5e_addr = ((cr3 & ~0xfff ) + (((addr >>48 ) &0x1ff ) <<3 )) & a20_mask; pml5e_addr =get_hphys (cs, pml5e_addr,MMU_DATA_STORE ,NULL ); pml5e =x86_ldq_phys (cs, pml5e_addr);
@@ -304,7 +304,7 @@ static int mmu_translate(CPUState *cs, vaddr addr, } ptep = pml5e ^PG_NX_MASK ; }else { - pml5e = env->cr[3 ]; + pml5e = cr3; ptep =PG_NX_MASK |PG_USER_MASK |PG_RW_MASK ; }
@@ -349,7 +349,7 @@ static int mmu_translate(CPUState *cs, vaddr addr,#endif {/* XXX: load them when cr3 is loaded ? */ - pdpe_addr = ((env->cr[3 ] & ~0x1f ) + ((addr >>27 ) &0x18 )) & + pdpe_addr = ((cr3 & ~0x1f ) + ((addr >>27 ) &0x18 )) & a20_mask; pdpe_addr =get_hphys (cs, pdpe_addr,MMU_DATA_STORE , false); pdpe =x86_ldq_phys (cs, pdpe_addr);
@@ -403,7 +403,7 @@ static int mmu_translate(CPUState *cs, vaddr addr,uint32_t pde;/* page directory entry */ - pde_addr = ((env->cr[3 ] & ~0xfff ) + ((addr >>20 ) &0xffc )) & + pde_addr = ((cr3 & ~0xfff ) + ((addr >>20 ) &0xffc )) & a20_mask; pde_addr =get_hphys (cs, pde_addr,MMU_DATA_STORE ,NULL ); pde =x86_ldl_phys (cs, pde_addr);
@@ -573,7 +573,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size, prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; page_size =4096 ; }else { - error_code =mmu_translate (cs, addr, is_write1, + error_code =mmu_translate (cs, addr, env->cr[3 ], is_write1, mmu_idx, &paddr, &page_size, &prot); }
Signature · 1 line
2.26.2
[PULL 24/33] target/i386: extract mmu_translate
In reply to Paolo BonziniExtract the page table lookup out of handle_mmu_fault, which only has to invoke mmu_translate and either fill the TLB or deliver the page fault.
--- target/i386/tcg/sysemu/excp_helper.c | 151 +++++++++++++++------------ 1 file changed, 86 insertions(+), 65 deletions(-)
target/i386/tcg/sysemu/excp_helper.c +86 -65
@@ -243,13 +243,11 @@ static hwaddr get_hphys(CPUState *cs, hwaddr gphys, MMUAccessType access_type,cpu_vmexit (env,SVM_EXIT_NPF , exit_info_1, env->retaddr); } -/* return value: -* -1 = cannot handle fault -* 0 = nothing more to do -* 1 = generate PF fault -*/ -static int handle_mmu_fault (CPUState *cs,vaddr addr,int size, -int is_write1,int mmu_idx) +#define PG_ERROR_OK (-1) + +static int mmu_translate (CPUState *cs,vaddr addr, +int is_write1,int mmu_idx, +vaddr *xlat,int *page_size,int *prot) {X86CPU *cpu =X86_CPU (cs);CPUX86State *env = &cpu->env;
@@ -257,33 +255,14 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size,int32_t a20_mask;target_ulong pde_addr, pte_addr;int error_code =0 ; -int is_dirty, prot, page_size, is_write, is_user; -hwaddr paddr; +int is_dirty, is_write, is_user;uint64_t rsvd_mask =PG_ADDRESS_MASK & ~MAKE_64BIT_MASK (0 , cpu->phys_bits);uint32_t page_offset; -target_ulong vaddr;uint32_t pkr; - is_user = mmu_idx ==MMU_USER_IDX ; -#if defined(DEBUG_MMU ) -printf ("MMU fault: addr=%" VADDR_PRIx" w=%d u=%d eip=" TARGET_FMT_lx"\n" , - addr, is_write1, is_user, env->eip); -#endif + is_user = (mmu_idx ==MMU_USER_IDX ); is_write = is_write1 &1 ; - a20_mask =x86_get_a20_mask (env); -if (!(env->cr[0 ] &CR0_PG_MASK )) { - pte = addr; -#ifdef TARGET_X86_64 -if (!(env->hflags &HF_LMA_MASK )) { -/* Without long mode we can only address 32bits in real mode */ - pte = (uint32_t )pte; - } -#endif - prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; - page_size =4096 ; - goto do_mapping; - }if (!(env->efer &MSR_EFER_NXE )) { rsvd_mask |=PG_NX_MASK ;
@@ -361,7 +340,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size, }if (pdpe &PG_PSE_MASK ) {/* 1 GB page */ - page_size =1024 *1024 *1024 ; + *page_size =1024 *1024 *1024 ; pte_addr = pdpe_addr; pte = pdpe; goto do_check_protect;
@@ -397,7 +376,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size, ptep &= pde ^PG_NX_MASK ;if (pde &PG_PSE_MASK ) {/* 2 MB page */ - page_size =2048 *1024 ; + *page_size =2048 *1024 ; pte_addr = pde_addr; pte = pde; goto do_check_protect;
@@ -419,7 +398,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size, }/* combine pde and pte nx, user and rw protections */ ptep &= pte ^PG_NX_MASK ; - page_size =4096 ; + *page_size =4096 ; }else {uint32_t pde;
@@ -435,7 +414,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size,/* if PSE bit is set, then we use a 4MB page */ if ((pde &PG_PSE_MASK ) && (env->cr[4 ] &CR4_PSE_MASK )) { - page_size =4096 *1024 ; + *page_size =4096 *1024 ; pte_addr = pde_addr;/* Bits 20-13 provide bits 39-32 of the address, bit 21 is reserved.
@@ -461,12 +440,12 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size, }/* combine pde and pte user and rw protections */ ptep &= pte |PG_NX_MASK ; - page_size =4096 ; + *page_size =4096 ; rsvd_mask =0 ; } do_check_protect: - rsvd_mask |= (page_size -1 ) &PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK ; + rsvd_mask |= (*page_size -1 ) &PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK ; do_check_protect_pse36:if (pte & rsvd_mask) { goto do_fault_rsvd;
@@ -478,17 +457,17 @@ do_check_protect_pse36: goto do_fault_protect; } - prot =0 ; + *prot =0 ;if (mmu_idx !=MMU_KSMAP_IDX || !(ptep &PG_USER_MASK )) { - prot |=PAGE_READ ; + *prot |=PAGE_READ ;if ((ptep &PG_RW_MASK ) || (!is_user && !(env->cr[0 ] &CR0_WP_MASK ))) { - prot |=PAGE_WRITE ; + *prot |=PAGE_WRITE ; } }if (!(ptep &PG_NX_MASK ) && (mmu_idx ==MMU_USER_IDX || !((env->cr[4 ] &CR4_SMEP_MASK ) && (ptep &PG_USER_MASK )))) { - prot |=PAGE_EXEC ; + *prot |=PAGE_EXEC ; }if (!(env->hflags &HF_LMA_MASK )) {
@@ -510,7 +489,7 @@ do_check_protect_pse36: pkr_prot &= ~PAGE_WRITE ; } - prot &= pkr_prot; + *prot &= pkr_prot;if ((pkr_prot & (1 << is_write1)) ==0 ) {assert (is_write1 !=2 ); error_code |=PG_ERROR_PK_MASK ;
@@ -518,7 +497,7 @@ do_check_protect_pse36: } } -if ((prot & (1 << is_write1)) ==0 ) { +if ((*prot & (1 << is_write1)) ==0 ) { goto do_fault_protect; }
@@ -536,26 +515,17 @@ do_check_protect_pse36:/* only set write access if already dirty... otherwise wait for dirty access */ assert (!is_write); - prot &= ~PAGE_WRITE ; + *prot &= ~PAGE_WRITE ; } - do_mapping: pte = pte & a20_mask;/* align to page_size */ - pte &=PG_ADDRESS_MASK & ~(page_size -1 ); - page_offset = addr & (page_size -1 ); - paddr =get_hphys (cs, pte + page_offset, is_write1, &prot); - -/* Even if 4MB pages, we map only one 4KB page in the cache to -avoid filling it too fast */ - vaddr = addr &TARGET_PAGE_MASK ; - paddr &=TARGET_PAGE_MASK ; - -assert (prot & (1 << is_write1)); -tlb_set_page_with_attrs (cs, vaddr, paddr,cpu_get_mem_attrs (env), - prot, mmu_idx, page_size); -return 0 ; + pte &=PG_ADDRESS_MASK & ~(*page_size -1 ); + page_offset = addr & (*page_size -1 ); + *xlat =get_hphys (cs, pte + page_offset, is_write1, prot); +return PG_ERROR_OK ; + do_fault_rsvd: error_code |=PG_ERROR_RSVD_MASK ; do_fault_protect:
@@ -566,20 +536,71 @@ do_check_protect_pse36: error_code |=PG_ERROR_U_MASK ;if (is_write1 ==2 && (((env->efer &MSR_EFER_NXE ) && - (env->cr[4 ] &CR4_PAE_MASK )) || + (env->cr[4 ] &CR4_PAE_MASK )) || (env->cr[4 ] &CR4_SMEP_MASK ))) error_code |=PG_ERROR_I_D_MASK ; -if (env->intercept_exceptions & (1 <<EXCP0E_PAGE )) { -/* cr2 is not modified in case of exceptions */ -x86_stq_phys (cs, - env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), - addr); +return error_code; +} + +/* return value: +* -1 = cannot handle fault +* 0 = nothing more to do +* 1 = generate PF fault +*/ +static int handle_mmu_fault (CPUState *cs,vaddr addr,int size, +int is_write1,int mmu_idx) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; +int error_code =PG_ERROR_OK ; +int prot, page_size; +hwaddr paddr; +target_ulong vaddr; + +#if defined(DEBUG_MMU ) +printf ("MMU fault: addr=%" VADDR_PRIx" w=%d mmu=%d eip=" TARGET_FMT_lx"\n" , + addr, is_write1, mmu_idx, env->eip); +#endif + +if (!(env->cr[0 ] &CR0_PG_MASK )) { + paddr = addr; +#ifdef TARGET_X86_64 +if (!(env->hflags &HF_LMA_MASK )) { +/* Without long mode we can only address 32bits in real mode */ + paddr = (uint32_t )paddr; + } +#endif + prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; + page_size =4096 ; }else { - env->cr[2 ] = addr; + error_code =mmu_translate (cs, addr, is_write1, + mmu_idx, + &paddr, &page_size, &prot); + } + +if (error_code ==PG_ERROR_OK ) { +/* Even if 4MB pages, we map only one 4KB page in the cache to +avoid filling it too fast */ + vaddr = addr &TARGET_PAGE_MASK ; + paddr &=TARGET_PAGE_MASK ; + +assert (prot & (1 << is_write1)); +tlb_set_page_with_attrs (cs, vaddr, paddr,cpu_get_mem_attrs (env), + prot, mmu_idx, page_size); +return 0 ; + }else { +if (env->intercept_exceptions & (1 <<EXCP0E_PAGE )) { +/* cr2 is not modified in case of exceptions */ +x86_stq_phys (cs, + env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), + addr); + }else { + env->cr[2 ] = addr; + } + env->error_code = error_code; + cs->exception_index =EXCP0E_PAGE ; +return 1 ; } - env->error_code = error_code; - cs->exception_index =EXCP0E_PAGE ; -return 1 ; } bool x86_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
Signature · 1 line
2.26.2
[PULL 22/33] target/i386: merge SVM_NPTEXIT_* with PF_ERROR_* constants
In reply to Paolo BonziniThey are the same value, and are so by design.
--- target/i386/svm.h | 5 ----- target/i386/tcg/sysemu/excp_helper.c | 10 +++++----- 2 files changed, 5 insertions(+), 10 deletions(-)
target/i386/svm.h +0 -5
@@ -137,11 +137,6 @@#define SVM_NPT_NXE (1 << 2)#define SVM_NPT_PSE (1 << 3) -#define SVM_NPTEXIT_P (1ULL << 0) -#define SVM_NPTEXIT_RW (1ULL << 1) -#define SVM_NPTEXIT_US (1ULL << 2) -#define SVM_NPTEXIT_RSVD (1ULL << 3) -#define SVM_NPTEXIT_ID (1ULL << 4)#define SVM_NPTEXIT_GPA (1ULL << 32)#define SVM_NPTEXIT_GPT (1ULL << 33)
target/i386/tcg/sysemu/excp_helper.c +5 -5
@@ -205,17 +205,17 @@ static hwaddr get_hphys(CPUState *cs, hwaddr gphys, MMUAccessType access_type,return pte + page_offset; do_fault_rsvd: - exit_info_1 |=SVM_NPTEXIT_RSVD ; + exit_info_1 |=PG_ERROR_RSVD_MASK ; do_fault_protect: - exit_info_1 |=SVM_NPTEXIT_P ; + exit_info_1 |=PG_ERROR_P_MASK ; do_fault: x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), gphys); - exit_info_1 |=SVM_NPTEXIT_US ; + exit_info_1 |=PG_ERROR_U_MASK ;if (access_type ==MMU_DATA_STORE ) { - exit_info_1 |=SVM_NPTEXIT_RW ; + exit_info_1 |=PG_ERROR_W_MASK ; }else if (access_type ==MMU_INST_FETCH ) { - exit_info_1 |=SVM_NPTEXIT_ID ; + exit_info_1 |=PG_ERROR_I_D_MASK ; }if (prot) { exit_info_1 |=SVM_NPTEXIT_GPA ;
Signature · 1 line
2.26.2
[PULL 21/33] accel: add init_accel_cpu for adapting accel behavior to CPU type
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
while on x86 all CPU classes can use the same set of TCGCPUOps, on ARM the right accel behavior depends on the type of the CPU.
So we need a way to specialize the accel behavior according to the CPU. Therefore, add a second initialization, after the accel_cpu->cpu_class_init, that allows to do this.
Message-Id: <[email protected]>
--- accel/accel-common.c | 13 +++++++++++++ include/hw/core/cpu.h | 6 ++++++ target/i386/tcg/tcg-cpu.c | 8 +++++++- 3 files changed, 26 insertions(+), 1 deletion(-)
accel/accel-common.c +13 -0
@@ -54,10 +54,23 @@ static void accel_init_cpu_int_aux(ObjectClass *klass, void *opaque)CPUClass *cc =CPU_CLASS (klass);AccelCPUClass *accel_cpu = opaque; +/* +* The first callback allows accel-cpu to run initializations +* for the CPU, customizing CPU behavior according to the accelerator. +* +* The second one allows the CPU to customize the accel-cpu +* behavior according to the CPU. +* +* The second is currently only used by TCG, to specialize the +* TCGCPUOps depending on the CPU type. +*/ cc->accel_cpu = accel_cpu;if (accel_cpu->cpu_class_init) { accel_cpu->cpu_class_init (cc); } +if (cc->init_accel_cpu) { + cc->init_accel_cpu (accel_cpu, cc); + } }/* initialize the arch-specific accel CpuClass interfaces */
include/hw/core/cpu.h +6 -0
@@ -192,6 +192,12 @@ struct CPUClass {/* when TCG is not available, this pointer is NULL */ struct TCGCPUOps *tcg_ops; + +/* +* if not NULL, this is called in order for the CPUClass to initialize +* class data that depends on the accelerator, see accel/accel-common.c. +*/ +void (*init_accel_cpu)(struct AccelCPUClass *accel_cpu,CPUClass *cc); };/*
target/i386/tcg/tcg-cpu.c +7 -1
@@ -69,11 +69,17 @@ static struct TCGCPUOps x86_tcg_ops = {#endif /* !CONFIG_USER_ONLY */ }; -static void tcg_cpu_class_init (CPUClass *cc) +static void tcg_cpu_init_ops (AccelCPUClass *accel_cpu,CPUClass *cc) { +/* for x86, all cpus use the same set of operations */ cc->tcg_ops = &x86_tcg_ops; } +static void tcg_cpu_class_init (CPUClass *cc) +{ + cc->init_accel_cpu = tcg_cpu_init_ops; +} +/* * TCG-specific defaults that override all CPU models when using TCG */
Signature · 1 line
2.26.2
[PULL 32/33] configure: fix detection of gdbus-codegen
In reply to Paolo Bonzini"pkg-config --variable=gdbus_codegen gio-2.0" returns "gdbus-codegen", and it does not pass test -x (which does not walk the path).
Meson 0.58.0 notices that something is iffy, as the dbus_vmstate1 assignment in tests/qtest/meson.build uses an empty string as the command, and fails very eloquently:
../tests/qtest/meson.build:92:2: ERROR: No program name specified.
Use the "has" function instead of test -x, and fix the generation of config-host.mak since meson.build expects that GDBUS_CODEGEN is absent, rather than empty, if the tool is unavailable.
--- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
configure +3 -1
@@ -3341,7 +3341,7 @@ if ! test "$gio" = "no"; then gio_cflags=$($pkg_config --cflags gio-2.0) gio_libs=$($pkg_config --libs gio-2.0) gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) - if [ ! -x "$gdbus_codegen" ]; then + if ! has "$gdbus_codegen"; then gdbus_codegen= fi # Check that the libraries actually work -- Ubuntu 18.04 ships
@@ -5704,6 +5704,8 @@ if test "$gio" = "yes" ; then echo "CONFIG_GIO=y" >> $config_host_mak echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak echo "GIO_LIBS=$gio_libs" >> $config_host_mak +fi +if test "$gdbus_codegen" != "" ; then echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak fi echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
Signature · 1 line
2.26.2
[PULL 31/33] qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict
In reply to Paolo Bonzini--- util/qemu-option.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
util/qemu-option.c +2 -1
@@ -1056,7 +1056,8 @@ bool qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)while (entry !=NULL ) { next =qdict_next (qdict, entry); -if (find_desc_by_name (opts->list->desc, entry->key)) { +if (opts_accepts_any (opts->list) || +find_desc_by_name (opts->list->desc, entry->key)) {if (!qemu_opts_from_qdict_entry (opts, entry, errp)) {return false; }
Signature · 1 line
2.26.2
[PULL 26/33] target/i386: extend pg_mode to more CR0 and CR4 bits
In reply to Paolo BonziniIn order to unify the two stages of page table lookup, we need mmu_translate to use either the host CR0/EFER/CR4 or the guest's. To do so, make mmu_translate use the same pg_mode constants that were used for the NPT lookup.
This also prepares for adding 5-level NPT support, which however does not work yet.
--- target/i386/cpu.h | 8 +++++ target/i386/tcg/sysemu/excp_helper.c | 45 ++++++++++++++++++---------- target/i386/tcg/sysemu/svm_helper.c | 2 +- 3 files changed, 39 insertions(+), 16 deletions(-)
target/i386/cpu.h +8 -0
@@ -307,6 +307,14 @@ typedef enum X86Seg {#define PG_MODE_LMA (1 << 1)#define PG_MODE_NXE (1 << 2)#define PG_MODE_PSE (1 << 3) +#define PG_MODE_LA57 (1 << 4) +#define PG_MODE_SVM_MASK MAKE_64BIT_MASK(0, 15) + +/* Bits of CR4 that do not affect the NPT page format. */ +#define PG_MODE_WP (1 << 16) +#define PG_MODE_PKE (1 << 17) +#define PG_MODE_PKS (1 << 18) +#define PG_MODE_SMEP (1 << 19)#define MCG_CTL_P (1ULL<<8)/* MCG_CAP register available */ #define MCG_SER_P (1ULL<<24)/* MCA recovery/new status bits */
target/i386/tcg/sysemu/excp_helper.c +30 -15
126 lines not on this page · raw message
target/i386/tcg/sysemu/svm_helper.c +1 -1
@@ -163,7 +163,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend) control.nested_cr3)); env->hflags2 |=HF2_NPT_MASK ; - env->nested_pg_mode =get_pg_mode (env); + env->nested_pg_mode =get_pg_mode (env) &PG_MODE_SVM_MASK ; }/* enable intercepts */
Signature · 1 line
2.26.2
[PULL 29/33] main-loop: remove dead code
In reply to Paolo Bonziniqemu_add_child_watch is not called anywhere since commit 2bdb920ece ("slirp: simplify fork_exec()", 2019-01-14), remove it.
--- include/qemu/main-loop.h | 18 ------------ util/main-loop.c | 61 ---------------------------------------- 2 files changed, 79 deletions(-)
include/qemu/main-loop.h +0 -18
@@ -234,24 +234,6 @@ void event_notifier_set_handler(EventNotifier *e,GSource *iohandler_get_g_source (void );AioContext *iohandler_get_aio_context (void ); -#ifdef CONFIG_POSIX -/** -* qemu_add_child_watch: Register a child process for reaping. -* -* Under POSIX systems, a parent process must read the exit status of -* its child processes using waitpid, or the operating system will not -* free some of the resources attached to that process. -* -* This function directs the QEMU main loop to observe a child process -* and call waitpid as soon as it exits; the watch is then removed -* automatically. It is useful whenever QEMU forks a child process -* but will find out about its termination by other means such as a -* "broken pipe". -* -* @pid: The pid that QEMU should observe. -*/ -int qemu_add_child_watch (pid_t pid); -#endif /** * qemu_mutex_iothread_locked: Return lock status of the main loop mutex.
util/main-loop.c +0 -61
64 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 33/33] coverity-scan: list components, move model to scripts/coverity-scan
In reply to Paolo BonziniPlace all files that can be useful to rebuild the Coverity configuration in scripts/coverity-scan: the existing model file, and the components setup.
The Markdown syntax was tested with Pandoc (but in any case is meant more as a human-readable reference than as a part of documentation).
---
scripts/coverity-scan/COMPONENTS.md | 154 ++++++++++++++++++
.../model.c} | 0
2 files changed, 154 insertions(+)
create mode 100644 scripts/coverity-scan/COMPONENTS.md
rename scripts/{coverity-model.c => coverity-scan/model.c} (100%)scripts/coverity-scan/COMPONENTS.md new file +154 -0
@@ -0,0 +1,154 @@ +This is the list of currently configured Coverity components: + +alpha + ~ (/qemu)?((/include)?/hw/alpha/.*|/target/alpha/.*) + +arm + ~ (/qemu)?((/include)?/hw/arm/.*|(/include)?/hw/.*/(arm|allwinner-a10|bcm28|digic|exynos|imx|omap|stellaris|pxa2xx|versatile|zynq|cadence).*|/hw/net/xgmac.c|/hw/ssi/xilinx_spips.c|/target/arm/.*) + +avr + ~ (/qemu)?((/include)?/hw/avr/.*|/target/avr/.*) + +cris + ~ (/qemu)?((/include)?/hw/cris/.*|/target/cris/.*) + +hexagon + ~ (/qemu)?(/target/hexagon/.*) + +hppa + ~ (/qemu)?((/include)?/hw/hppa/.*|/target/hppa/.*) + +i386 + ~ (/qemu)?((/include)?/hw/i386/.*|/target/i386/.*|/hw/intc/[^/]*apic[^/]*\.c) + +lm32 + ~ (/qemu)?((/include)?/hw/lm32/.*|/target/lm32/.*|/hw/.*/(milkymist|lm32).*) + +m68k + ~ (/qemu)?((/include)?/hw/m68k/.*|/target/m68k/.*|(/include)?/hw(/.*)?/mcf.*) + +microblaze + ~ (/qemu)?((/include)?/hw/microblaze/.*|/target/microblaze/.*) + +mips + ~ (/qemu)?((/include)?/hw/mips/.*|/target/mips/.*) + +nios2 + ~ (/qemu)?((/include)?/hw/nios2/.*|/target/nios2/.*) + +ppc + ~ (/qemu)?((/include)?/hw/ppc/.*|/target/ppc/.*|/hw/pci-host/(uninorth.*|dec.*|prep.*|ppc.*)|/hw/misc/macio/.*|(/include)?/hw/.*/(xics|openpic|spapr).*) + +riscv + ~ (/qemu)?((/include)?/hw/riscv/.*|/target/riscv/.*) + +rx + ~ (/qemu)?((/include)?/hw/rx/.*|/target/rx/.*) + +s390 + ~ (/qemu)?((/include)?/hw/s390x/.*|/target/s390x/.*|/hw/.*/s390_.*) + +sh4 + ~ (/qemu)?((/include)?/hw/sh4/.*|/target/sh4/.*) + +sparc + ~ (/qemu)?((/include)?/hw/sparc(64)?.*|/target/sparc/.*|/hw/.*/grlib.*|/hw/display/cg3.c) + +tilegx + ~ (/qemu)?(/target/tilegx/.*) + +tricore + ~ (/qemu)?((/include)?/hw/tricore/.*|/target/tricore/.*) + +unicore32 + ~ (/qemu)?((/include)?/hw/unicore32/.*|/target/unicore32/.*) + +9pfs + ~ (/qemu)?(/hw/9pfs/.*|/fsdev/.*) + +audio + ~ (/qemu)?((/include)?/(audio|hw/audio)/.*) + +block + ~ (/qemu)?(/block.*|(/include?)(/hw)?/(block|storage-daemon)/.*|(/include)?/hw/ide/.*|/qemu-(img|io).*|/util/(aio|async|thread-pool).*) + +char + ~ (/qemu)?(/qemu-char\.c|/include/sysemu/char\.h|(/include)?/hw/char/.*) + +capstone + ~ (/qemu)?(/capstone/.*) + +crypto + ~ (/qemu)?((/include)?/crypto/.*|/hw/.*/crypto.*) + +disas + ~ (/qemu)?((/include)?/disas.*) + +fpu + ~ (/qemu)?((/include)?(/fpu|/libdecnumber)/.*) + +io + ~ (/qemu)?((/include)?/io/.*) + +ipmi + ~ (/qemu)?((/include)?/hw/ipmi/.*) + +libvixl + ~ (/qemu)?(/disas/libvixl/.*) + +migration + ~ (/qemu)?((/include)?/migration/.*) + +monitor + ~ (/qemu)?(/qapi.*|/qobject/.*|/monitor\..*|/[hq]mp\..*) + +nbd + ~ (/qemu)?(/nbd/.*|/include/block/nbd.*|/qemu-nbd\.c) + +net + ~ (/qemu)?((/include)?(/hw)?/(net|rdma)/.*) + +pci + ~ (/qemu)?(/hw/pci.*|/include/hw/pci.*) + +qemu-ga + ~ (/qemu)?(/qga/.*) + +scsi + ~ (/qemu)?(/scsi/.*|/hw/scsi/.*|/include/hw/scsi/.*) + +slirp + ~ (/qemu)?(/.*slirp.*) + +tcg + ~ (/qemu)?(/accel/tcg/.*|/replay/.*|/(.*/)?softmmu.*) + +trace + ~ (/qemu)?(/.*trace.*\.[ch]) + +ui + ~ (/qemu)?((/include)?(/ui|/hw/display|/hw/input)/.*) + +usb + ~ (/qemu)?(/hw/usb/.*|/include/hw/usb/.*) + +user + ~ (/qemu)?(/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*) + +util + ~ (/qemu)?(/util/.*|/include/qemu/.*) + +xen + ~ (/qemu)?(.*/xen.*) + +virtiofsd + ~ (/qemu)?(/tools/virtiofsd/.*) + +(headers) + ~ (/qemu)?(/include/.*) + +testlibs + ~ (/qemu)?(/tests/qtest(/libqos/.*|/libqtest.*)) + +tests + ~ (/qemu)?(/tests/.*)
scripts/coverity-scan/model.c renamed from scripts/coverity-model.c +0 -0
Signature · 1 line
2.26.2
[PULL 30/33] migration: do not restart VM after successful snapshot-load
In reply to Paolo BonziniThe HMP loadvm code is calling load_snapshot rather than qmp_snapshot_load, in order to bypass the job infrastructure. The code around it is almost the same, with one difference: hmp_loadvm is restarting the VM if load_snapshot fails, qmp_snapshot_load is doing so if load_snapshot succeeds.
Fix the bug in QMP by moving the common code to load_snapshot.
--- migration/savevm.c | 16 ++++++++-------- monitor/hmp-cmds.c | 7 +------ 2 files changed, 9 insertions(+), 14 deletions(-)
migration/savevm.c +8 -8
@@ -2992,6 +2992,7 @@ bool load_snapshot(const char *name, const char *vmstate,int ret;AioContext *aio_context;MigrationIncomingState *mis =migration_incoming_get_current (); +int saved_vm_running =runstate_is_running ();if (!bdrv_all_can_snapshot (has_devices, devices, errp)) {return false;
@@ -3024,6 +3025,8 @@ bool load_snapshot(const char *name, const char *vmstate,return false; } +vm_stop (RUN_STATE_RESTORE_VM ); +/* * Flush the record/replay queue. Now the VM state is going * to change. Therefore we don't need to preserve its consistency
@@ -3061,13 +3064,17 @@ bool load_snapshot(const char *name, const char *vmstate,if (ret <0 ) {error_setg (errp,"Error %d while loading VM state" , ret); -return false; + goto err_restart; }return true; err_drain:bdrv_drain_all_end (); +err_restart: +if (saved_vm_running) { +vm_start (); + }return false; }
@@ -3135,17 +3142,10 @@ static void snapshot_load_job_bh(void *opaque) {Job *job = opaque;SnapshotJob *s =container_of (job, SnapshotJob, common); -int orig_vm_running;job_progress_set_remaining (&s->common,1 ); - orig_vm_running =runstate_is_running (); -vm_stop (RUN_STATE_RESTORE_VM ); - s->ret =load_snapshot (s->tag, s->vmstate, true, s->devices, s->errp); -if (s->ret && orig_vm_running) { -vm_start (); - }job_progress_update (&s->common,1 );
monitor/hmp-cmds.c +1 -6
@@ -1127,15 +1127,10 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)void hmp_loadvm (Monitor *mon,const QDict *qdict) { -int saved_vm_running =runstate_is_running ();const char *name =qdict_get_str (qdict,"name" );Error *err =NULL ; -vm_stop (RUN_STATE_RESTORE_VM ); - -if (!load_snapshot (name,NULL , false,NULL , &err) && saved_vm_running) { -vm_start (); - } +load_snapshot (name,NULL , false,NULL , &err);hmp_handle_error (mon, err); }
Signature · 1 line
2.26.2
Re: [PULL 30/33] migration: do not restart VM after successful snapshot-load
Quoted 6 lines · Paolo Bonzini
The HMP loadvm code is calling
load_snapshotrather thanqmp_snapshot_load, in order to bypass the job infrastructure. The code around it is almost the same, with one difference:hmp_loadvmis restarting the VM ifload_snapshotfails,qmp_snapshot_loadis doing so ifload_snapshotsucceeds.
Quoted 8 lines
Fix the bug in QMP by moving the common code to
load_snapshot.Signed-off-by Paolo Bonzini <[email protected]>--- migration/savevm.c | 16 ++++++++-------- monitor/hmp-cmds.c | 7 +------ 2 files changed, 9 insertions(+), 14 deletions(-)
David had a question about safety on this patch that probably ought to be answered before merging
https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg01103.html
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PULL 30/33] migration: do not restart VM after successful snapshot-load
In reply to Paolo BonziniQuoted 7 lines · * Paolo Bonzini ([email protected]) wrote:
The HMP loadvm code is calling
load_snapshotrather thanqmp_snapshot_load, in order to bypass the job infrastructure. The code around it is almost the same, with one difference:hmp_loadvmis restarting the VM ifload_snapshotfails,qmp_snapshot_loadis doing so ifload_snapshotsucceeds.Fix the bug in QMP by moving the common code to
load_snapshot.
See my comment:
https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg01103.html
but you've also lost Eric's Rb.
Dave
Quoted 91 lines
Signed-off-by Paolo Bonzini <[email protected]>--- migration/savevm.c | 16 ++++++++-------- monitor/hmp-cmds.c | 7 +------ 2 files changed, 9 insertions(+), 14 deletions(-)migration/savevm.c +8
-8@@ -2992,6 +2992,7 @@ bool load_snapshot(const char *name, const char *vmstate,int ret;AioContext *aio_context;MigrationIncomingState *mis =migration_incoming_get_current (); +int saved_vm_running =runstate_is_running ();if (!bdrv_all_can_snapshot (has_devices, devices, errp)) {return false;@@ -3024,6 +3025,8 @@ bool load_snapshot(const char *name, const char *vmstate,return false; } +vm_stop (RUN_STATE_RESTORE_VM ); +/* * Flush the record/replay queue. Now the VM state is going * to change. Therefore we don't need to preserve its consistency @@ -3061,13 +3064,17 @@ bool load_snapshot(const char *name, const char *vmstate,if (ret <0 ) {error_setg (errp,"Error %d while loading VM state" , ret); -return false; + goto err_restart; }return true; err_drain:bdrv_drain_all_end (); +err_restart: +if (saved_vm_running) { +vm_start (); + }return false; }@@ -3135,17 +3142,10 @@ static void snapshot_load_job_bh(void *opaque) {Job *job = opaque;SnapshotJob *s =container_of (job, SnapshotJob, common); -int orig_vm_running;job_progress_set_remaining (&s->common,1 ); - orig_vm_running =runstate_is_running (); -vm_stop (RUN_STATE_RESTORE_VM ); - s->ret =load_snapshot (s->tag, s->vmstate, true, s->devices, s->errp); -if (s->ret && orig_vm_running) { -vm_start (); - }job_progress_update (&s->common,1 );monitor/hmp-cmds.c +1
-6@@ -1127,15 +1127,10 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)void hmp_loadvm (Monitor *mon,const QDict *qdict) { -int saved_vm_running =runstate_is_running ();const char *name =qdict_get_str (qdict,"name" );Error *err =NULL ; -vm_stop (RUN_STATE_RESTORE_VM ); - -if (!load_snapshot (name,NULL , false,NULL , &err) && saved_vm_running) { -vm_start (); - } +load_snapshot (name,NULL , false,NULL , &err);hmp_handle_error (mon, err); }Signature · 1 line
2.26.2
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PULL 30/33] migration: do not restart VM after successful snapshot-load
Quoted 7 lines · Dr. David Alan Gilbert
Quoted 6 lines · * Paolo Bonzini ([email protected]) wrote:
The HMP loadvm code is calling
load_snapshotrather thanqmp_snapshot_load, in order to bypass the job infrastructure. The code around it is almost the same, with one difference:hmp_loadvmis restarting the VM ifload_snapshotfails,qmp_snapshot_loadis doing so ifload_snapshotsucceeds.
Quoted 6 lines
Quoted 1 line
Fix the bug in QMP by moving the common code to
load_snapshot.See my comment:
https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg01103.htmlbut you've also lost Eric's Rb.
Sorry, I missed both replies. As Daniel pointed out, the bug is in the QMP version. Kevin has the correct fix, I'll send the cleanup of vm_stop/vm_start separately on top of his patch.
Paolo
Quoted 93 lines
Dave
Quoted 91 lines
Signed-off-by Paolo Bonzini <[email protected]>--- migration/savevm.c | 16 ++++++++-------- monitor/hmp-cmds.c | 7 +------ 2 files changed, 9 insertions(+), 14 deletions(-)migration/savevm.c +8
-8@@ -2992,6 +2992,7 @@ bool load_snapshot(const char *name, const char *vmstate,int ret;AioContext *aio_context;MigrationIncomingState *mis =migration_incoming_get_current (); +int saved_vm_running =runstate_is_running ();if (!bdrv_all_can_snapshot (has_devices, devices, errp)) {return false;@@ -3024,6 +3025,8 @@ bool load_snapshot(const char *name, const char *vmstate,return false; } +vm_stop (RUN_STATE_RESTORE_VM ); +/* * Flush the record/replay queue. Now the VM state is going * to change. Therefore we don't need to preserve its consistency @@ -3061,13 +3064,17 @@ bool load_snapshot(const char *name, const char *vmstate,if (ret <0 ) {error_setg (errp,"Error %d while loading VM state" , ret); -return false; + goto err_restart; }return true; err_drain:bdrv_drain_all_end (); +err_restart: +if (saved_vm_running) { +vm_start (); + }return false; }@@ -3135,17 +3142,10 @@ static void snapshot_load_job_bh(void *opaque) {Job *job = opaque;SnapshotJob *s =container_of (job, SnapshotJob, common); -int orig_vm_running;job_progress_set_remaining (&s->common,1 ); - orig_vm_running =runstate_is_running (); -vm_stop (RUN_STATE_RESTORE_VM ); - s->ret =load_snapshot (s->tag, s->vmstate, true, s->devices, s->errp); -if (s->ret && orig_vm_running) { -vm_start (); - }job_progress_update (&s->common,1 );monitor/hmp-cmds.c +1
-6@@ -1127,15 +1127,10 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)void hmp_loadvm (Monitor *mon,const QDict *qdict) { -int saved_vm_running =runstate_is_running ();const char *name =qdict_get_str (qdict,"name" );Error *err =NULL ; -vm_stop (RUN_STATE_RESTORE_VM ); - -if (!load_snapshot (name,NULL , false,NULL , &err) && saved_vm_running) { -vm_start (); - } +load_snapshot (name,NULL , false,NULL , &err);hmp_handle_error (mon, err); }Signature · 1 line
2.26.2
Re: [PULL 30/33] migration: do not restart VM after successful snapshot-load
In reply to Paolo BonziniQuoted 7 lines · Paolo Bonzini
The HMP loadvm code is calling
load_snapshotrather thanqmp_snapshot_load, in order to bypass the job infrastructure. The code around it is almost the same, with one difference:hmp_loadvmis restarting the VM ifload_snapshotfails,qmp_snapshot_loadis doing so ifload_snapshotsucceeds.Fix the bug in QMP by moving the common code to
load_snapshot.
This doesn't appear to have actually fixed the HMP regression. Instead I think it is duplicated the HMP bug in the QMP code too.
See the 068 iotest enhancement here that validates the expected state on success:
https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg03091.html
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PULL 30/33] migration: do not restart VM after successful snapshot-load
Am 11.05.2021 um 19:06 hat Daniel P. Berrangé geschrieben:
Quoted 9 lines · Paolo Bonzini
Quoted 7 lines
The HMP loadvm code is calling
load_snapshotrather thanqmp_snapshot_load, in order to bypass the job infrastructure. The code around it is almost the same, with one difference:hmp_loadvmis restarting the VM ifload_snapshotfails,qmp_snapshot_loadis doing so ifload_snapshotsucceeds.Fix the bug in QMP by moving the common code to
load_snapshot.
Quoted 8 lines
This doesn't appear to have actually fixed the HMP regression. Instead I think it is duplicated the HMP bug in the QMP code too.
See the 068 iotest enhancement here that validates the expected state on success:
https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg03091.html
I guess I'll wait for this new QMP bug to hit master, and then rebase my fix on top of it, with now two Fixes: lines.
Or do you want to send a v2 of this pull request without this patch, Paolo?
Kevin
Re: [PULL 30/33] migration: do not restart VM after successful snapshot-load
Quoted 5 lines · Kevin Wolf
I guess I'll wait for this new QMP bug to hit master, and then rebase my fix on top of it, with now two Fixes: lines.
Or do you want to send a v2 of this pull request without this patch, Paolo?
I managed to remove it from the tag before Peter pulled, so problem averted.
Paolo
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PULL 00/33] Misc (mostly i386) patches for 2021-05-11
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
11165dc coverity-scan: list components, move model to scripts/coverity-scan 8c04d1d configure: fix detection of gdbus-codegen
72d3908 qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict fa0a3a0 migration: do not restart VM after successful snapshot-load 314ce22 main-loop: remove dead code
fab0cca target/i386: use mmu_translate for NPT walk
fbfc2e7 target/i386: allow customizing the next phase of the translation b41eebf target/i386: extend pg_mode to more CR0 and CR4 bits e73fad8 target/i386: pass cr3 to mmu_translate
1d5c833 target/i386: extract mmu_translate
82189eb target/i386: move paging mode constants from SVM to cpu.h e158c09 target/i386: merge SVM_NPTEXIT_* with PF_ERROR_* constants e6027a1 accel: add init_accel_cpu for adapting accel behavior to CPU type a68180f accel: move call to accel_init_interfaces
95d9318 i386: make cpu_load_efer sysemu-only
8e1f9eb target/i386: gdbstub: only write CR0/CR2/CR3/EFER for sysemu cac1ed0 target/i386: gdbstub: introduce aux functions to read/write CS64 regs 92bc080 i386: split off sysemu part of cpu.c
f80829b i386: split seg_helper into user-only and sysemu parts 7802ef6 i386: split svm_helper into sysemu and stub-only user 205f16f i386: separate fpu_helper sysemu-only parts
aa80e42 i386: split misc helper user stubs and sysemu part e8f8ed2 i386: move TCG bpt_helper into sysemu/142ab958 i386: split tcg excp_helper into sysemu and user parts ff581ca i386: split smm helper (sysemu)
509d8ba i386: split off sysemu-only functionality in tcg-cpu 247ca58 accel-cpu: make cpu_realizefn return a bool
89b9a03 target/i386: fix host_cpu_adjust_phys_bits error handling 3845cbd accel: introduce new accessor functions
f466cc0 cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn 34dd642 i386: split cpu accelerators from cpu.c, using AccelCPUClass e418ab4 target/i386: Split out do_fsave, do_frstor, do_fxsave, do_fxrstor d191c6d target/i386: Rename helper_fldt, helper_fstt
=== OUTPUT BEGIN ===
1/33 Checking commit d191c6da5374 (target/i386: Rename helper_fldt, helper_fstt)
2/33 Checking commit e418ab44d351 (target/i386: Split out do_fsave, do_frstor, do_fxsave, do_fxrstor) 3/33 Checking commit 34dd6425b115 (i386: split cpu accelerators from cpu.c, using AccelCPUClass)
WARNING: line over 80 characters
#1337: FILE: target/i386/tcg/tcg-cpu.c:125:
+ memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_mem, 0);
total: 0 errors, 1 warnings, 1249 lines checked
Patch 3/33 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
4/33 Checking commit f466cc007ae9 (cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn) 5/33 Checking commit 3845cbd66375 (accel: introduce new accessor functions)
6/33 Checking commit 89b9a03dc7b9 (target/i386: fix host_cpu_adjust_phys_bits error handling) 7/33 Checking commit 247ca58bfdbd (accel-cpu: make cpu_realizefn return a bool) 8/33 Checking commit 509d8ba47db6 (i386: split off sysemu-only functionality in tcg-cpu) Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#51:
new file mode 100644
WARNING: line over 80 characters
#136: FILE: target/i386/tcg/sysemu/tcg-cpu.c:72:
+ memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_mem, 0);
total: 0 errors, 2 warnings, 223 lines checked
Patch 8/33 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
9/33 Checking commit ff581ca3760f (i386: split smm helper (sysemu))
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #26:
target/i386/tcg/{ => sysemu}/smm_helper.c | 19 ++-----------------total: 0 errors, 1 warnings, 84 lines checked
Patch 9/33 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
10/33 Checking commit 142ab958eba8 (i386: split tcg excp_helper into sysemu and user parts) Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#607:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #765: FILE: target/i386/tcg/sysemu/excp_helper.c:154:
+ /* Bits 20-13 provide bits 39-32 of the address, bit 21 is reserved.
WARNING: Block comments use a leading /* on a separate line #839: FILE: target/i386/tcg/sysemu/excp_helper.c:228:
+/* return value:
WARNING: line over 80 characters
#940: FILE: target/i386/tcg/sysemu/excp_helper.c:329:
+ pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((addr >> 30) & 0x1ff) << 3)) &
WARNING: Block comments use a leading /* on a separate line #1034: FILE: target/i386/tcg/sysemu/excp_helper.c:423:
+ /* Bits 20-13 provide bits 39-32 of the address, bit 21 is reserved.
WARNING: Block comments use a leading /* on a separate line #1129: FILE: target/i386/tcg/sysemu/excp_helper.c:518:
+ /* only set write access if already dirty... otherwise wait
WARNING: Block comments use * on subsequent lines #1130: FILE: target/i386/tcg/sysemu/excp_helper.c:519:
+ /* only set write access if already dirty... otherwise wait
+ for dirty access */
WARNING: Block comments use a trailing */ on a separate line #1130: FILE: target/i386/tcg/sysemu/excp_helper.c:519:
+ for dirty access */
WARNING: Block comments use a leading /* on a separate line #1143: FILE: target/i386/tcg/sysemu/excp_helper.c:532:
+ /* Even if 4MB pages, we map only one 4KB page in the cache to
WARNING: Block comments use * on subsequent lines #1144: FILE: target/i386/tcg/sysemu/excp_helper.c:533:
+ /* Even if 4MB pages, we map only one 4KB page in the cache to
+ avoid filling it too fast */
WARNING: Block comments use a trailing */ on a separate line #1144: FILE: target/i386/tcg/sysemu/excp_helper.c:533:
+ avoid filling it too fast */
ERROR: braces {} are necessary for all arms of this statement #1158: FILE: target/i386/tcg/sysemu/excp_helper.c:547:
+ if (is_user)
[...]
total: 1 errors, 11 warnings, 632 lines checked
Patch 10/33 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
11/33 Checking commit e8f8ed2330c0 (i386: move TCG bpt_helper into sysemu/)
Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#366:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #502: FILE: target/i386/tcg/sysemu/bpt_helper.c:132:
+ /* If nothing is changing except the global/local enable bits,
WARNING: Block comments use * on subsequent lines #503: FILE: target/i386/tcg/sysemu/bpt_helper.c:133:
+ /* If nothing is changing except the global/local enable bits,
+ then we can make the change more efficient. */
WARNING: Block comments use a trailing */ on a separate line #503: FILE: target/i386/tcg/sysemu/bpt_helper.c:133:
+ then we can make the change more efficient. */
WARNING: Block comments use a leading /* on a separate line #505: FILE: target/i386/tcg/sysemu/bpt_helper.c:135:
+ /* Fold the global and local enable bits together into the
WARNING: Block comments use * on subsequent lines #506: FILE: target/i386/tcg/sysemu/bpt_helper.c:136:
+ /* Fold the global and local enable bits together into the
+ global fields, then xor to show which registers have
WARNING: Block comments use a trailing */ on a separate line #507: FILE: target/i386/tcg/sysemu/bpt_helper.c:137:
+ changed collective enable state. */
total: 0 errors, 7 warnings, 628 lines checked
Patch 11/33 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
12/33 Checking commit aa80e4256955 (i386: split misc helper user stubs and sysemu part) Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#538:
new file mode 100644
ERROR: switch and case should be at the same indent #835: FILE: target/i386/tcg/sysemu/misc_helper.c:293:
+ switch ((uint32_t)env->regs[R_ECX]) {
[...]
+ case MSR_IA32_UCODE_REV:
total: 1 errors, 1 warnings, 1020 lines checked
Patch 12/33 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
13/33 Checking commit 205f16fd06d3 (i386: separate fpu_helper sysemu-only parts) Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#110:
new file mode 100644
total: 0 errors, 1 warnings, 135 lines checked
Patch 13/33 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
14/33 Checking commit 7802ef6d40e9 (i386: split svm_helper into sysemu and stub-only user)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #36:
target/i386/tcg/{ => sysemu}/svm_helper.c | 62 +------------------------total: 0 errors, 1 warnings, 169 lines checked
Patch 14/33 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
15/33 Checking commit f80829b357df (i386: split seg_helper into user-only and sysemu parts) Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#328:
new file mode 100644
ERROR: do not use C99 // comments
#355: FILE: target/i386/tcg/seg_helper.h:23:
+//#define DEBUG_PCALL
WARNING: Block comments use a leading /* on a separate line #628: FILE: target/i386/tcg/user/seg_helper.c:73:
+ /* Since we emulate only user space, we cannot do more than
WARNING: Block comments use * on subsequent lines
#629: FILE: target/i386/tcg/user/seg_helper.c:74:
+ /* Since we emulate only user space, we cannot do more than
+ exiting the emulation with the suitable exception and error
WARNING: Block comments use a trailing */ on a separate line #630: FILE: target/i386/tcg/user/seg_helper.c:75:
+ code. So update EIP for INT 0x80 and EXCP_SYSCALL. */
WARNING: Block comments use a leading /* on a separate line #641: FILE: target/i386/tcg/user/seg_helper.c:86:
+ /* if user mode only, we simulate a fake exception
WARNING: Block comments use * on subsequent lines
#642: FILE: target/i386/tcg/user/seg_helper.c:87:
+ /* if user mode only, we simulate a fake exception
+ which will be handled outside the cpu execution
WARNING: Block comments use a trailing */ on a separate line #643: FILE: target/i386/tcg/user/seg_helper.c:88:
+ loop */
total: 1 errors, 7 warnings, 595 lines checked
Patch 15/33 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
16/33 Checking commit 92bc08007a75 (i386: split off sysemu part of cpu.c)
Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#20:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #54: FILE: target/i386/cpu-internal.h:30:
+ /* feature flags names are taken from "Intel Processor Identification and
WARNING: Block comments use a leading /* on a separate line #137: FILE: target/i386/cpu-sysemu.c:37:
+/* Return a QDict containing keys for all properties that can be included
WARNING: Block comments use a leading /* on a separate line #190: FILE: target/i386/cpu-sysemu.c:90:
+/* Convert CPU model data from X86CPU object to a property dictionary
WARNING: Block comments use a leading /* on a separate line #204: FILE: target/i386/cpu-sysemu.c:104:
+/* Convert CPU model data from X86CPU object to a property dictionary
WARNING: Block comments use a leading /* on a separate line #220: FILE: target/i386/cpu-sysemu.c:120:
+ /* "hotplugged" is the only property that is configurable
WARNING: Block comments use a leading /* on a separate line #310: FILE: target/i386/cpu-sysemu.c:210:
+ /* As we don't return every single property, full expansion needs
total: 0 errors, 7 warnings, 901 lines checked
Patch 16/33 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
17/33 Checking commit cac1ed00200d (target/i386: gdbstub: introduce aux functions to read/write CS64 regs)
WARNING: line over 80 characters
#64: FILE: target/i386/gdbstub.c:163:
+ return gdb_read_reg_cs64(env->hflags, mem_buf, env->segs[R_FS].base);
WARNING: line over 80 characters
#70: FILE: target/i386/gdbstub.c:165:
+ return gdb_read_reg_cs64(env->hflags, mem_buf, env->segs[R_GS].base);
WARNING: line over 80 characters
#158: FILE: target/i386/gdbstub.c:318:
+ return gdb_write_reg_cs64(env->hflags, mem_buf, &env->segs[R_FS].base);
WARNING: line over 80 characters
#167: FILE: target/i386/gdbstub.c:320:
+ return gdb_write_reg_cs64(env->hflags, mem_buf, &env->segs[R_GS].base);
total: 0 errors, 4 warnings, 221 lines checked
Patch 17/33 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
18/33 Checking commit 8e1f9eb9ca5e (target/i386: gdbstub: only write CR0/CR2/CR3/EFER for sysemu) 19/33 Checking commit 95d93188b54e (i386: make cpu_load_efer sysemu-only)
20/33 Checking commit a68180fac1ba (accel: move call to accel_init_interfaces)
21/33 Checking commit e6027a1524d1 (accel: add init_accel_cpu for adapting accel behavior to CPU type) 22/33 Checking commit e158c09d46e9 (target/i386: merge SVM_NPTEXIT_* with PF_ERROR_* constants) 23/33 Checking commit 82189ebbef8b (target/i386: move paging mode constants from SVM to cpu.h) 24/33 Checking commit 1d5c83360ef4 (target/i386: extract mmu_translate)
ERROR: code indent should never use tabs
#204: FILE: target/i386/tcg/sysemu/excp_helper.c:539:
+^I (env->cr[4] & CR4_PAE_MASK)) ||$
WARNING: Block comments use a leading /* on a separate line #215: FILE: target/i386/tcg/sysemu/excp_helper.c:545:
+/* return value:
WARNING: line over 80 characters
#231: FILE: target/i386/tcg/sysemu/excp_helper.c:561:
+ printf("MMU fault: addr=%" VADDR_PRIx " w=%d mmu=%d eip=" TARGET_FMT_lx "\n",
WARNING: Block comments use a leading /* on a separate line #253: FILE: target/i386/tcg/sysemu/excp_helper.c:582:
+ /* Even if 4MB pages, we map only one 4KB page in the cache to
WARNING: Block comments use * on subsequent lines #254: FILE: target/i386/tcg/sysemu/excp_helper.c:583:
+ /* Even if 4MB pages, we map only one 4KB page in the cache to
+ avoid filling it too fast */
WARNING: Block comments use a trailing */ on a separate line #254: FILE: target/i386/tcg/sysemu/excp_helper.c:583:
+ avoid filling it too fast */
total: 1 errors, 5 warnings, 248 lines checked
Patch 24/33 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
25/33 Checking commit e73fad8dedfc (target/i386: pass cr3 to mmu_translate)
26/33 Checking commit b41eebf2958c (target/i386: extend pg_mode to more CR0 and CR4 bits) 27/33 Checking commit fbfc2e7057f2 (target/i386: allow customizing the next phase of the translation)
WARNING: line over 80 characters
#22: FILE: target/i386/tcg/sysemu/excp_helper.c:263:
+typedef hwaddr (*MMUTranslateFunc)(CPUState *cs, hwaddr gphys, MMUAccessType access_type,
ERROR: code indent should never use tabs #23: FILE: target/i386/tcg/sysemu/excp_helper.c:264:
+^I^I^I^Iint *prot);$
ERROR: code indent should never use tabs
#26: FILE: target/i386/tcg/sysemu/excp_helper.c:267:
+^I(get_hphys_func ? get_hphys_func(cs, gpa, access_type, prot) : gpa)$
WARNING: line over 80 characters
#28: FILE: target/i386/tcg/sysemu/excp_helper.c:269:
+static int mmu_translate(CPUState *cs, vaddr addr, MMUTranslateFunc get_hphys_func,
total: 2 errors, 2 warnings, 102 lines checked
Patch 27/33 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
28/33 Checking commit fab0cca38dbf (target/i386: use mmu_translate for NPT walk)
WARNING: line over 80 characters
#237: FILE: target/i386/tcg/sysemu/excp_helper.c:65:
+static int mmu_translate(CPUState *cs, hwaddr addr, MMUTranslateFunc get_hphys_func,
total: 0 errors, 1 warnings, 268 lines checked
Patch 28/33 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
29/33 Checking commit 314ce2200b5a (main-loop: remove dead code)
30/33 Checking commit fa0a3a00084a (migration: do not restart VM after successful snapshot-load) 31/33 Checking commit 72d3908a924f (qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict) 32/33 Checking commit 8c04d1df1780 (configure: fix detection of gdbus-codegen)
33/33 Checking commit 11165dcc3958 (coverity-scan: list components, move model to scripts/coverity-scan)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#20:
.../{coverity-model.c => coverity-scan/model.c} | 0total: 0 errors, 1 warnings, 154 lines checked
Patch 33/33 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Peter Maydell
AppliedQuoted 13 lines · Paolo Bonzini
The following changes since commit
e58c7a3bba3076890592f02d2b0e596bf191b5c2:Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210510-1' into staging (2021-05-10 17:28:11 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to
8708c1e0182293b51e07c0640848f93a3354376e:coverity-scan: list components, move model to
scripts/coverity-scan(2021-05-11 04:11:14 -0400)
Quoted 8 lines
----------------------------------------------------------------
* AccelCPUClass and sysemu/user split for i386 (Claudio)
* i386 page walk unification
* Fix detection of gdbus-codegen
* Misc refactoring
* snapshot-load bugfix----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.
-- PMM