ppc patch queue for 2020-03-24

Here's a final pull request before the qemu-5.0 hard freeze.
 
 We have an implementation of the POWER9 forms of the slbia
 instruction, a small cleanup and a handful of assorted fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAl55lr4ACgkQbDjKyiDZ
 s5LcrRAAyY7tEzJJnJUW+z9Hdmd0kqGbm1q7AwzX2Nb5X1ELbf8ZI7FoZ+dfehNi
 7dQbnCwVtbQPQhnqoNMBZiHIxOS8lUa6O9iI+xKxgX4aDuIhH3s1VSIzbaWgimA5
 Ho2i2uDr9p4DVRiy8INmZrdVMYuv6Le7jhILKYr6qQDFykWepi26IAN7PZ0UOnIT
 4R78AfveLFSnvdFCLMED1WpGthaaEg9enjyv13gj9h+TkLRaHkvwjTRREEU880UP
 HmbN2FbdfNjxnkCIfRWbBwV/AjsHmW7OwMZeWKbGQkhtJ2bZ50+lGbagcebe8Enc
 GTqFYc4i96ulWVJHtH8sO/3cFXTnNoTZ7pj7+3IEjv8J/HpUd6jyJjF1rpXiFxcV
 7+F0lJETgEPuRHsxs9Xkuhm0YisfIo3QUKEGRycty5lmMIb3Hr/3FcFepdzDbwtK
 PiDISncQcO5fymHxNBJKJMKziLPQ959/fngrtk+pgvzDg2CpKU2euWIc2k70SV/L
 3f5SHr6CnHrMB21c0YHjNb5qY7JdFk5dr9rO5+yd9urI6ObMVztRB2Ign+HaFzDf
 BAYTj1YKKz8RkZcULHGdr/1kcr3/Hxj3bHPEocvsh5n1b8BsPAjQMLjNVxUv2ler
 UzbvQIZDsEKI/2bxA8ZSdMUftpEC6dd+k91tu1H/EumEidqk/Ag=
 =hGAI
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.0-20200324' into staging

ppc patch queue for 2020-03-24

Here's a final pull request before the qemu-5.0 hard freeze.

We have an implementation of the POWER9 forms of the slbia
instruction, a small cleanup and a handful of assorted fixes.

# gpg: Signature made Tue 24 Mar 2020 05:12:30 GMT
# gpg:                using RSA key 75F46586AE61A66CC44E87DC6C38CACA20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>" [full]
# gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>" [full]
# gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>" [full]
# gpg:                 aka "David Gibson (kernel.org) <dwg@kernel.org>" [unknown]
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392

* remotes/dgibson/tags/ppc-for-5.0-20200324:
  ppc/ppc405_boards: Remove unnecessary NULL check
  hw/ppc: Take QEMU lock when calling ppc_dcr_read/write()
  spapr: Fix memory leak in h_client_architecture_support()
  target/ppc: don't byte swap ELFv2 signal handler
  target/ppc: Fix ISA v3.0 (POWER9) slbia implementation
  target/ppc: Fix slbia TLB invalidation gap
  ppc/spapr: Set the effective address provided flag in mc error log.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
master
Peter Maydell 2020-03-24 09:50:46 +00:00
commit 09a98dd988
8 changed files with 125 additions and 34 deletions

View File

@ -191,7 +191,7 @@ static void ref405ep_init(MachineState *machine)
bios_size = 8 * MiB;
pflash_cfi02_register((uint32_t)(-bios_size),
"ef405ep.bios", bios_size,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
blk_by_legacy_dinfo(dinfo),
64 * KiB, 1,
2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
@ -459,7 +459,7 @@ static void taihu_405ep_init(MachineState *machine)
bios_size = 2 * MiB;
pflash_cfi02_register(0xFFE00000,
"taihu_405ep.bios", bios_size,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
blk_by_legacy_dinfo(dinfo),
64 * KiB, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
@ -494,7 +494,7 @@ static void taihu_405ep_init(MachineState *machine)
if (dinfo) {
bios_size = 32 * MiB;
pflash_cfi02_register(0xfc000000, "taihu_405ep.flash", bios_size,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
blk_by_legacy_dinfo(dinfo),
64 * KiB, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);

View File

@ -243,6 +243,14 @@ struct rtas_event_log_v6_mc {
#define RTAS_LOG_V6_MC_TLB_PARITY 1
#define RTAS_LOG_V6_MC_TLB_MULTIHIT 2
#define RTAS_LOG_V6_MC_TLB_INDETERMINATE 3
/*
* Per PAPR,
* For UE error type, set bit 1 of sub_err_type to indicate effective addr is
* provided. For other error types (SLB/ERAT/TLB), set bit 0 to indicate
* same.
*/
#define RTAS_LOG_V6_MC_UE_EA_ADDR_PROVIDED 0x40
#define RTAS_LOG_V6_MC_EA_ADDR_PROVIDED 0x80
uint8_t reserved_1[6];
uint64_t effective_address;
uint64_t logical_address;
@ -726,6 +734,22 @@ void spapr_hotplug_req_remove_by_count_indexed(SpaprDrcType drc_type,
RTAS_LOG_V6_HP_ACTION_REMOVE, drc_type, &drc_id);
}
static void spapr_mc_set_ea_provided_flag(struct mc_extended_log *ext_elog)
{
switch (ext_elog->mc.error_type) {
case RTAS_LOG_V6_MC_TYPE_UE:
ext_elog->mc.sub_err_type |= RTAS_LOG_V6_MC_UE_EA_ADDR_PROVIDED;
break;
case RTAS_LOG_V6_MC_TYPE_SLB:
case RTAS_LOG_V6_MC_TYPE_ERAT:
case RTAS_LOG_V6_MC_TYPE_TLB:
ext_elog->mc.sub_err_type |= RTAS_LOG_V6_MC_EA_ADDR_PROVIDED;
break;
default:
break;
}
}
static uint32_t spapr_mce_get_elog_type(PowerPCCPU *cpu, bool recovered,
struct mc_extended_log *ext_elog)
{
@ -751,6 +775,7 @@ static uint32_t spapr_mce_get_elog_type(PowerPCCPU *cpu, bool recovered,
ext_elog->mc.sub_err_type = mc_derror_table[i].error_subtype;
if (mc_derror_table[i].dar_valid) {
ext_elog->mc.effective_address = cpu_to_be64(env->spr[SPR_DAR]);
spapr_mc_set_ea_provided_flag(ext_elog);
}
summary |= mc_derror_table[i].initiator
@ -769,6 +794,7 @@ static uint32_t spapr_mce_get_elog_type(PowerPCCPU *cpu, bool recovered,
ext_elog->mc.sub_err_type = mc_ierror_table[i].error_subtype;
if (mc_ierror_table[i].nip_valid) {
ext_elog->mc.effective_address = cpu_to_be64(env->nip);
spapr_mc_set_ea_provided_flag(ext_elog);
}
summary |= mc_ierror_table[i].initiator

View File

@ -1726,6 +1726,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
}
ov5_guest = spapr_ovec_parse_vector(ov_table, 5);
if (!ov5_guest) {
spapr_ovec_cleanup(ov1_guest);
warn_report("guest didn't provide option vector 5");
return H_PARAMETER;
}

View File

@ -567,10 +567,8 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
env->nip = tswapl(handler->entry);
env->gpr[2] = tswapl(handler->toc);
} else {
/* ELFv2 PPC64 function pointers are entry points, but R12
* must also be set */
env->nip = tswapl((target_ulong) ka->_sa_handler);
env->gpr[12] = env->nip;
/* ELFv2 PPC64 function pointers are entry points. R12 must also be set. */
env->gpr[12] = env->nip = ka->_sa_handler;
}
#else
env->nip = (target_ulong) ka->_sa_handler;

View File

@ -614,7 +614,7 @@ DEF_HELPER_FLAGS_3(store_slb, TCG_CALL_NO_RWG, void, env, tl, tl)
DEF_HELPER_2(load_slb_esid, tl, env, tl)
DEF_HELPER_2(load_slb_vsid, tl, env, tl)
DEF_HELPER_2(find_slb_vsid, tl, env, tl)
DEF_HELPER_FLAGS_1(slbia, TCG_CALL_NO_RWG, void, env)
DEF_HELPER_FLAGS_2(slbia, TCG_CALL_NO_RWG, void, env, i32)
DEF_HELPER_FLAGS_2(slbie, TCG_CALL_NO_RWG, void, env, tl)
DEF_HELPER_FLAGS_2(slbieg, TCG_CALL_NO_RWG, void, env, tl)
#endif

View File

@ -95,24 +95,75 @@ void dump_slb(PowerPCCPU *cpu)
}
}
void helper_slbia(CPUPPCState *env)
void helper_slbia(CPUPPCState *env, uint32_t ih)
{
PowerPCCPU *cpu = env_archcpu(env);
int starting_entry;
int n;
/* XXX: Warning: slbia never invalidates the first segment */
for (n = 1; n < cpu->hash64_opts->slb_size; n++) {
/*
* slbia must always flush all TLB (which is equivalent to ERAT in ppc
* architecture). Matching on SLB_ESID_V is not good enough, because slbmte
* can overwrite a valid SLB without flushing its lookaside information.
*
* It would be possible to keep the TLB in synch with the SLB by flushing
* when a valid entry is overwritten by slbmte, and therefore slbia would
* not have to flush unless it evicts a valid SLB entry. However it is
* expected that slbmte is more common than slbia, and slbia is usually
* going to evict valid SLB entries, so that tradeoff is unlikely to be a
* good one.
*
* ISA v2.05 introduced IH field with values 0,1,2,6. These all invalidate
* the same SLB entries (everything but entry 0), but differ in what
* "lookaside information" is invalidated. TCG can ignore this and flush
* everything.
*
* ISA v3.0 introduced additional values 3,4,7, which change what SLBs are
* invalidated.
*/
env->tlb_need_flush |= TLB_NEED_LOCAL_FLUSH;
starting_entry = 1; /* default for IH=0,1,2,6 */
if (env->mmu_model == POWERPC_MMU_3_00) {
switch (ih) {
case 0x7:
/* invalidate no SLBs, but all lookaside information */
return;
case 0x3:
case 0x4:
/* also considers SLB entry 0 */
starting_entry = 0;
break;
case 0x5:
/* treat undefined values as ih==0, and warn */
qemu_log_mask(LOG_GUEST_ERROR,
"slbia undefined IH field %u.\n", ih);
break;
default:
/* 0,1,2,6 */
break;
}
}
for (n = starting_entry; n < cpu->hash64_opts->slb_size; n++) {
ppc_slb_t *slb = &env->slb[n];
if (slb->esid & SLB_ESID_V) {
slb->esid &= ~SLB_ESID_V;
/*
* XXX: given the fact that segment size is 256 MB or 1TB,
* and we still don't have a tlb_flush_mask(env, n, mask)
* in QEMU, we just invalidate all TLBs
*/
env->tlb_need_flush |= TLB_NEED_LOCAL_FLUSH;
if (!(slb->esid & SLB_ESID_V)) {
continue;
}
if (env->mmu_model == POWERPC_MMU_3_00) {
if (ih == 0x3 && (slb->vsid & SLB_VSID_C) == 0) {
/* preserves entries with a class value of 0 */
continue;
}
}
slb->esid &= ~SLB_ESID_V;
}
}

View File

@ -21,6 +21,7 @@
#include "exec/helper-proto.h"
#include "exec/exec-all.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
/*****************************************************************************/
/* SPR accesses */
@ -167,13 +168,19 @@ target_ulong helper_load_dcr(CPUPPCState *env, target_ulong dcrn)
raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_INVAL |
POWERPC_EXCP_INVAL_INVAL, GETPC());
} else if (unlikely(ppc_dcr_read(env->dcr_env,
(uint32_t)dcrn, &val) != 0)) {
qemu_log_mask(LOG_GUEST_ERROR, "DCR read error %d %03x\n",
(uint32_t)dcrn, (uint32_t)dcrn);
raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_INVAL |
POWERPC_EXCP_PRIV_REG, GETPC());
} else {
int ret;
qemu_mutex_lock_iothread();
ret = ppc_dcr_read(env->dcr_env, (uint32_t)dcrn, &val);
qemu_mutex_unlock_iothread();
if (unlikely(ret != 0)) {
qemu_log_mask(LOG_GUEST_ERROR, "DCR read error %d %03x\n",
(uint32_t)dcrn, (uint32_t)dcrn);
raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_INVAL |
POWERPC_EXCP_PRIV_REG, GETPC());
}
}
return val;
}
@ -185,12 +192,17 @@ void helper_store_dcr(CPUPPCState *env, target_ulong dcrn, target_ulong val)
raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_INVAL |
POWERPC_EXCP_INVAL_INVAL, GETPC());
} else if (unlikely(ppc_dcr_write(env->dcr_env, (uint32_t)dcrn,
(uint32_t)val) != 0)) {
qemu_log_mask(LOG_GUEST_ERROR, "DCR write error %d %03x\n",
(uint32_t)dcrn, (uint32_t)dcrn);
raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_INVAL |
POWERPC_EXCP_PRIV_REG, GETPC());
} else {
int ret;
qemu_mutex_lock_iothread();
ret = ppc_dcr_write(env->dcr_env, (uint32_t)dcrn, (uint32_t)val);
qemu_mutex_unlock_iothread();
if (unlikely(ret != 0)) {
qemu_log_mask(LOG_GUEST_ERROR, "DCR write error %d %03x\n",
(uint32_t)dcrn, (uint32_t)dcrn);
raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_INVAL |
POWERPC_EXCP_PRIV_REG, GETPC());
}
}
}

View File

@ -4997,9 +4997,12 @@ static void gen_slbia(DisasContext *ctx)
#if defined(CONFIG_USER_ONLY)
GEN_PRIV;
#else
uint32_t ih = (ctx->opcode >> 21) & 0x7;
TCGv_i32 t0 = tcg_const_i32(ih);
CHK_SV;
gen_helper_slbia(cpu_env);
gen_helper_slbia(cpu_env, t0);
#endif /* defined(CONFIG_USER_ONLY) */
}