s390x/mmu: Clean up mmu_translate_asc()
We can get rid of the switch(asc) in mmu_translate_asc() by simply selecting the right control register ASCE in the mmu_translate() function already. This patch is based on an original patch/idea by Ralf Hoppe. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
This commit is contained in:
parent
b4ecbf8071
commit
9d77309c9f
@ -214,29 +214,13 @@ static int mmu_translate_region(CPUS390XState *env, target_ulong vaddr,
|
||||
raddr, flags, rw, exc);
|
||||
}
|
||||
|
||||
static int mmu_translate_asc(CPUS390XState *env, target_ulong vaddr,
|
||||
uint64_t asc, target_ulong *raddr, int *flags,
|
||||
int rw, bool exc)
|
||||
static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
|
||||
uint64_t asc, uint64_t asce, target_ulong *raddr,
|
||||
int *flags, int rw, bool exc)
|
||||
{
|
||||
uint64_t asce = 0;
|
||||
int level;
|
||||
int r;
|
||||
|
||||
switch (asc) {
|
||||
case PSW_ASC_PRIMARY:
|
||||
PTE_DPRINTF("%s: asc=primary\n", __func__);
|
||||
asce = env->cregs[1];
|
||||
break;
|
||||
case PSW_ASC_SECONDARY:
|
||||
PTE_DPRINTF("%s: asc=secondary\n", __func__);
|
||||
asce = env->cregs[7];
|
||||
break;
|
||||
case PSW_ASC_HOME:
|
||||
PTE_DPRINTF("%s: asc=home\n", __func__);
|
||||
asce = env->cregs[13];
|
||||
break;
|
||||
}
|
||||
|
||||
if (asce & _ASCE_REAL_SPACE) {
|
||||
/* direct mapping */
|
||||
*raddr = vaddr;
|
||||
@ -326,21 +310,28 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
|
||||
|
||||
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);
|
||||
break;
|
||||
case PSW_ASC_HOME:
|
||||
r = mmu_translate_asc(env, vaddr, asc, raddr, flags, rw, exc);
|
||||
PTE_DPRINTF("%s: asc=home\n", __func__);
|
||||
r = mmu_translate_asce(env, vaddr, asc, env->cregs[13], raddr, flags,
|
||||
rw, exc);
|
||||
break;
|
||||
case PSW_ASC_SECONDARY:
|
||||
PTE_DPRINTF("%s: asc=secondary\n", __func__);
|
||||
/*
|
||||
* Instruction: Primary
|
||||
* Data: Secondary
|
||||
*/
|
||||
if (rw == 2) {
|
||||
r = mmu_translate_asc(env, vaddr, PSW_ASC_PRIMARY, raddr, flags,
|
||||
rw, exc);
|
||||
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_asc(env, vaddr, PSW_ASC_SECONDARY, raddr, flags,
|
||||
rw, exc);
|
||||
r = mmu_translate_asce(env, vaddr, PSW_ASC_SECONDARY, env->cregs[7],
|
||||
raddr, flags, rw, exc);
|
||||
*flags &= ~(PAGE_EXEC);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user