mirror of
https://github.com/xemu-project/xemu.git
synced 2025-01-26 05:54:44 +00:00
s390x updates:
- fix a bug in tcg vector handling - improved skey handling -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEEw9DWbcNiT/aowBjO3s9rk8bwL68FAl1enAISHGNvaHVja0By ZWRoYXQuY29tAAoJEN7Pa5PG8C+vLUYQAIR4olED4ughFsSoekOWNhQCIhlM+apl n4R+mQp++QT960xXyfX4Rl9L1PfgYindfpfJy5Sc5D2ThtyFZv0rqzZyBnyhwGxt 9dChp4rtVwhja1P24zLFFvXJVouvtwlJIzRRpYSPpaxpYFq5pv0ZDm5m4dwZgY8B Opg3HaXCZntMQl3f2WPAONHbW+zVeqkPBsfNIn4Omzp5I+L5tiay0tznJLe+OVP0 99Yrhvfmn7yfLPH10KjvISH24xTlxlU3gBUTsWU0xmsazR+cLn7VaIMsod5rhp27 YzUfQeijz/ste8J3T51ODVcv2oIMVdOWQmG0BLPjhLOZx5v0txozTvegk8z1XJgz WpD/Oe0ZLDc46P6ZIwUIGTOv9TSNTM+yhIeZrN+s7syMCQF2+RAoyuODBed2XY3c ByTt4R2J2v8ggUQOCmSt+hJW/WQRtsKbWeOdlYPjWmQJWJBRm2bNj2In3peUwf0G W+y7ZtwBSvRNnDRUx1qs4AlvgAHL7pF3feIp0uQc75nsOSqhaC/g6PqWz7bp/FJ4 aNQQBvY/jijJA4dr7tr/dvMMzwrUc8IPuJDulUeEgyBZu8HP9Iu3+4+6yZVSmBLW TIDVbVkZwhue5mIjek+IoUlQ5pkvhrLV1HSw9Ulk4/R6fQeMi/A9GIFVmAabmMvE e54dTcF1uZgp =8914 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging s390x updates: - fix a bug in tcg vector handling - improved skey handling # gpg: Signature made Thu 22 Aug 2019 14:43:30 BST # gpg: using RSA key C3D0D66DC3624FF6A8C018CEDECF6B93C6F02FAF # gpg: issuer "cohuck@redhat.com" # gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" [unknown] # gpg: aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" [full] # gpg: aka "Cornelia Huck <cornelia.huck@de.ibm.com>" [full] # gpg: aka "Cornelia Huck <cohuck@kernel.org>" [unknown] # gpg: aka "Cornelia Huck <cohuck@redhat.com>" [unknown] # Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0 18CE DECF 6B93 C6F0 2FAF * remotes/cohuck/tags/s390x-20190822: s390x/mmu: Factor out storage key handling s390x/mmu: Better storage key reference and change bit handling s390x/tcg: Flush the TLB of all CPUs on SSKE and RRBE s390x/tcg: Rework MMU selection for instruction fetches s390x/mmu: ASC selection in s390_cpu_get_phys_page_debug() s390x/mmu: Trace the right value if setting/getting the storage key fails s390x/tcg: Fix VERIM with 32/64 bit elements Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
586f3dced9
@ -332,6 +332,13 @@ static inline int cpu_mmu_index(CPUS390XState *env, bool ifetch)
|
||||
return MMU_REAL_IDX;
|
||||
}
|
||||
|
||||
if (ifetch) {
|
||||
if ((env->psw.mask & PSW_MASK_ASC) == PSW_ASC_HOME) {
|
||||
return MMU_HOME_IDX;
|
||||
}
|
||||
return MMU_PRIMARY_IDX;
|
||||
}
|
||||
|
||||
switch (env->psw.mask & PSW_MASK_ASC) {
|
||||
case PSW_ASC_PRIMARY:
|
||||
return MMU_PRIMARY_IDX;
|
||||
|
@ -58,6 +58,11 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)
|
||||
vaddr &= 0x7fffffff;
|
||||
}
|
||||
|
||||
/* We want to read the code (e.g., see what we are single-stepping).*/
|
||||
if (asc != PSW_ASC_HOME) {
|
||||
asc = PSW_ASC_PRIMARY;
|
||||
}
|
||||
|
||||
if (mmu_translate(env, vaddr, MMU_INST_FETCH, asc, &raddr, &prot, false)) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1815,6 +1815,11 @@ void HELPER(sske)(CPUS390XState *env, uint64_t r1, uint64_t r2)
|
||||
|
||||
key = (uint8_t) r1;
|
||||
skeyclass->set_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key);
|
||||
/*
|
||||
* As we can only flush by virtual address and not all the entries
|
||||
* that point to a physical address we have to flush the whole TLB.
|
||||
*/
|
||||
tlb_flush_all_cpus_synced(env_cpu(env));
|
||||
}
|
||||
|
||||
/* reset reference bit extended */
|
||||
@ -1843,6 +1848,11 @@ uint32_t HELPER(rrbe)(CPUS390XState *env, uint64_t r2)
|
||||
if (skeyclass->set_skeys(ss, r2 / TARGET_PAGE_SIZE, 1, &key)) {
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* As we can only flush by virtual address and not all the entries
|
||||
* that point to a physical address we have to flush the whole TLB.
|
||||
*/
|
||||
tlb_flush_all_cpus_synced(env_cpu(env));
|
||||
|
||||
/*
|
||||
* cc
|
||||
|
@ -335,6 +335,75 @@ static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
|
||||
return r;
|
||||
}
|
||||
|
||||
static void mmu_handle_skey(target_ulong addr, int rw, int *flags)
|
||||
{
|
||||
static S390SKeysClass *skeyclass;
|
||||
static S390SKeysState *ss;
|
||||
uint8_t key;
|
||||
int rc;
|
||||
|
||||
if (unlikely(addr >= ram_size)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (unlikely(!ss)) {
|
||||
ss = s390_get_skeys_device();
|
||||
skeyclass = S390_SKEYS_GET_CLASS(ss);
|
||||
}
|
||||
|
||||
/*
|
||||
* Whenever we create a new TLB entry, we set the storage key reference
|
||||
* bit. In case we allow write accesses, we set the storage key change
|
||||
* bit. Whenever the guest changes the storage key, we have to flush the
|
||||
* TLBs of all CPUs (the whole TLB or all affected entries), so that the
|
||||
* next reference/change will result in an MMU fault and make us properly
|
||||
* update the storage key here.
|
||||
*
|
||||
* Note 1: "record of references ... is not necessarily accurate",
|
||||
* "change bit may be set in case no storing has occurred".
|
||||
* -> We can set reference/change bits even on exceptions.
|
||||
* Note 2: certain accesses seem to ignore storage keys. For example,
|
||||
* DAT translation does not set reference bits for table accesses.
|
||||
*
|
||||
* TODO: key-controlled protection. Only CPU accesses make use of the
|
||||
* PSW key. CSS accesses are different - we have to pass in the key.
|
||||
*
|
||||
* TODO: we have races between getting and setting the key.
|
||||
*/
|
||||
rc = skeyclass->get_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key);
|
||||
if (rc) {
|
||||
trace_get_skeys_nonzero(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (rw) {
|
||||
case MMU_DATA_LOAD:
|
||||
case MMU_INST_FETCH:
|
||||
/*
|
||||
* The TLB entry has to remain write-protected on read-faults if
|
||||
* the storage key does not indicate a change already. Otherwise
|
||||
* we might miss setting the change bit on write accesses.
|
||||
*/
|
||||
if (!(key & SK_C)) {
|
||||
*flags &= ~PAGE_WRITE;
|
||||
}
|
||||
break;
|
||||
case MMU_DATA_STORE:
|
||||
key |= SK_C;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
/* Any store/fetch sets the reference bit */
|
||||
key |= SK_R;
|
||||
|
||||
rc = skeyclass->set_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key);
|
||||
if (rc) {
|
||||
trace_set_skeys_nonzero(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a virtual (logical) address into a physical (absolute) address.
|
||||
* @param vaddr the virtual address
|
||||
@ -348,15 +417,9 @@ static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
|
||||
int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
|
||||
target_ulong *raddr, int *flags, bool exc)
|
||||
{
|
||||
static S390SKeysState *ss;
|
||||
static S390SKeysClass *skeyclass;
|
||||
int r = -1;
|
||||
uint8_t key;
|
||||
uint64_t asce;
|
||||
int r;
|
||||
|
||||
if (unlikely(!ss)) {
|
||||
ss = s390_get_skeys_device();
|
||||
skeyclass = S390_SKEYS_GET_CLASS(ss);
|
||||
}
|
||||
|
||||
*flags = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
|
||||
if (is_low_address(vaddr & TARGET_PAGE_MASK) && lowprot_enabled(env, asc)) {
|
||||
@ -381,36 +444,21 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
|
||||
|
||||
if (!(env->psw.mask & PSW_MASK_DAT)) {
|
||||
*raddr = vaddr;
|
||||
r = 0;
|
||||
goto out;
|
||||
goto nodat;
|
||||
}
|
||||
|
||||
switch (asc) {
|
||||
case PSW_ASC_PRIMARY:
|
||||
PTE_DPRINTF("%s: asc=primary\n", __func__);
|
||||
r = mmu_translate_asce(env, vaddr, asc, env->cregs[1], raddr, flags,
|
||||
rw, exc);
|
||||
asce = env->cregs[1];
|
||||
break;
|
||||
case PSW_ASC_HOME:
|
||||
PTE_DPRINTF("%s: asc=home\n", __func__);
|
||||
r = mmu_translate_asce(env, vaddr, asc, env->cregs[13], raddr, flags,
|
||||
rw, exc);
|
||||
asce = env->cregs[13];
|
||||
break;
|
||||
case PSW_ASC_SECONDARY:
|
||||
PTE_DPRINTF("%s: asc=secondary\n", __func__);
|
||||
/*
|
||||
* Instruction: Primary
|
||||
* Data: Secondary
|
||||
*/
|
||||
if (rw == MMU_INST_FETCH) {
|
||||
r = mmu_translate_asce(env, vaddr, PSW_ASC_PRIMARY, env->cregs[1],
|
||||
raddr, flags, rw, exc);
|
||||
*flags &= ~(PAGE_READ | PAGE_WRITE);
|
||||
} else {
|
||||
r = mmu_translate_asce(env, vaddr, PSW_ASC_SECONDARY, env->cregs[7],
|
||||
raddr, flags, rw, exc);
|
||||
*flags &= ~(PAGE_EXEC);
|
||||
}
|
||||
asce = env->cregs[7];
|
||||
break;
|
||||
case PSW_ASC_ACCREG:
|
||||
default:
|
||||
@ -418,31 +466,18 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
/* perform the DAT translation */
|
||||
r = mmu_translate_asce(env, vaddr, asc, asce, raddr, flags, rw, exc);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
|
||||
nodat:
|
||||
/* Convert real address -> absolute address */
|
||||
*raddr = mmu_real2abs(env, *raddr);
|
||||
|
||||
if (r == 0 && *raddr < ram_size) {
|
||||
if (skeyclass->get_skeys(ss, *raddr / TARGET_PAGE_SIZE, 1, &key)) {
|
||||
trace_get_skeys_nonzero(r);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*flags & PAGE_READ) {
|
||||
key |= SK_R;
|
||||
}
|
||||
|
||||
if (*flags & PAGE_WRITE) {
|
||||
key |= SK_C;
|
||||
}
|
||||
|
||||
if (skeyclass->set_skeys(ss, *raddr / TARGET_PAGE_SIZE, 1, &key)) {
|
||||
trace_set_skeys_nonzero(r);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
mmu_handle_skey(*raddr, rw, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -559,6 +594,6 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw,
|
||||
|
||||
*addr = mmu_real2abs(env, raddr & TARGET_PAGE_MASK);
|
||||
|
||||
/* TODO: storage key handling */
|
||||
mmu_handle_skey(*addr, rw, flags);
|
||||
return 0;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ static void get_vec_element_ptr_i64(TCGv_ptr ptr, uint8_t reg, TCGv_i64 enr,
|
||||
vec_full_reg_offset(v3), ptr, 16, 16, data, fn)
|
||||
#define gen_gvec_3i(v1, v2, v3, c, gen) \
|
||||
tcg_gen_gvec_3i(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \
|
||||
vec_full_reg_offset(v3), c, 16, 16, gen)
|
||||
vec_full_reg_offset(v3), 16, 16, c, gen)
|
||||
#define gen_gvec_4(v1, v2, v3, v4, gen) \
|
||||
tcg_gen_gvec_4(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \
|
||||
vec_full_reg_offset(v3), vec_full_reg_offset(v4), \
|
||||
|
Loading…
x
Reference in New Issue
Block a user