mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
target/ppc: Disconnect hflags from MSR
Copying flags directly from msr has drawbacks: (1) msr bits mean different things per cpu, (2) msr has 64 bits on 64 cpus while tb->flags has only 32 bits. Create a enum to define these bits. Document the origin of each bit and validate those bits that must match MSR. This fixes the truncation of env->hflags to tb->flags, because we no longer have hflags bits set above bit 31. Most of the code in ppc_tr_init_disas_context is moved over to hreg_compute_hflags. Some of it is simple extractions from msr, some requires examining other cpu flags. Anything that is moved becomes a simple extract from hflags in ppc_tr_init_disas_context. Several existing bugs are left in ppc_tr_init_disas_context, where additional changes are required -- to be addressed in future patches. Remove a broken #if 0 block. Reported-by: Ivan Warren <ivan@vmfacility.fr> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210323184340.619757-3-richard.henderson@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
edece45d4a
commit
2df4fe7abe
3 changed files with 95 additions and 50 deletions
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "cpu.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "sysemu/kvm.h"
|
||||
|
@ -87,24 +88,66 @@ void hreg_compute_mem_idx(CPUPPCState *env)
|
|||
|
||||
void hreg_compute_hflags(CPUPPCState *env)
|
||||
{
|
||||
target_ulong hflags_mask;
|
||||
target_ulong msr = env->msr;
|
||||
uint32_t ppc_flags = env->flags;
|
||||
uint32_t hflags = 0;
|
||||
uint32_t msr_mask;
|
||||
|
||||
/* We 'forget' FE0 & FE1: we'll never generate imprecise exceptions */
|
||||
hflags_mask = (1 << MSR_VR) | (1 << MSR_AP) | (1 << MSR_SA) |
|
||||
(1 << MSR_PR) | (1 << MSR_FP) | (1 << MSR_SE) | (1 << MSR_BE) |
|
||||
(1 << MSR_LE) | (1 << MSR_VSX) | (1 << MSR_IR) | (1 << MSR_DR);
|
||||
hflags_mask |= (1ULL << MSR_CM) | (1ULL << MSR_SF) | MSR_HVB;
|
||||
hreg_compute_mem_idx(env);
|
||||
env->hflags = env->msr & hflags_mask;
|
||||
/* Some bits come straight across from MSR. */
|
||||
QEMU_BUILD_BUG_ON(MSR_LE != HFLAGS_LE);
|
||||
QEMU_BUILD_BUG_ON(MSR_PR != HFLAGS_PR);
|
||||
QEMU_BUILD_BUG_ON(MSR_DR != HFLAGS_DR);
|
||||
QEMU_BUILD_BUG_ON(MSR_IR != HFLAGS_IR);
|
||||
QEMU_BUILD_BUG_ON(MSR_FP != HFLAGS_FP);
|
||||
QEMU_BUILD_BUG_ON(MSR_SA != HFLAGS_SA);
|
||||
QEMU_BUILD_BUG_ON(MSR_AP != HFLAGS_AP);
|
||||
msr_mask = ((1 << MSR_LE) | (1 << MSR_PR) |
|
||||
(1 << MSR_DR) | (1 << MSR_IR) |
|
||||
(1 << MSR_FP) | (1 << MSR_SA) | (1 << MSR_AP));
|
||||
|
||||
if (env->flags & POWERPC_FLAG_HID0_LE) {
|
||||
if (ppc_flags & POWERPC_FLAG_HID0_LE) {
|
||||
/*
|
||||
* Note that MSR_LE is not set in env->msr_mask for this cpu,
|
||||
* and so will never be set in msr or hflags at this point.
|
||||
* and so will never be set in msr.
|
||||
*/
|
||||
uint32_t le = extract32(env->spr[SPR_HID0], 3, 1);
|
||||
env->hflags |= le << MSR_LE;
|
||||
hflags |= le << MSR_LE;
|
||||
}
|
||||
|
||||
if (ppc_flags & POWERPC_FLAG_BE) {
|
||||
QEMU_BUILD_BUG_ON(MSR_BE != HFLAGS_BE);
|
||||
msr_mask |= 1 << MSR_BE;
|
||||
}
|
||||
if (ppc_flags & POWERPC_FLAG_SE) {
|
||||
QEMU_BUILD_BUG_ON(MSR_SE != HFLAGS_SE);
|
||||
msr_mask |= 1 << MSR_SE;
|
||||
}
|
||||
|
||||
if (msr_is_64bit(env, msr)) {
|
||||
hflags |= 1 << HFLAGS_64;
|
||||
}
|
||||
if ((ppc_flags & POWERPC_FLAG_SPE) && (msr & (1 << MSR_SPE))) {
|
||||
hflags |= 1 << HFLAGS_SPE;
|
||||
}
|
||||
if (ppc_flags & POWERPC_FLAG_VRE) {
|
||||
QEMU_BUILD_BUG_ON(MSR_VR != HFLAGS_VR);
|
||||
msr_mask |= 1 << MSR_VR;
|
||||
}
|
||||
if ((ppc_flags & POWERPC_FLAG_VSX) && (msr & (1 << MSR_VSX))) {
|
||||
hflags |= 1 << HFLAGS_VSX;
|
||||
}
|
||||
if ((ppc_flags & POWERPC_FLAG_TM) && (msr & (1ull << MSR_TM))) {
|
||||
hflags |= 1 << HFLAGS_TM;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
if (!env->has_hv_mode || (msr & (1ull << MSR_HV))) {
|
||||
hflags |= 1 << HFLAGS_HV;
|
||||
}
|
||||
#endif
|
||||
|
||||
env->hflags = hflags | (msr & msr_mask);
|
||||
hreg_compute_mem_idx(env);
|
||||
}
|
||||
|
||||
void cpu_interrupt_exittb(CPUState *cs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue