target-ppc: Simplify HPTE matching
ppc_hash64_pteg_search() explicitly checks each HPTE's VALID and SECONDARY bits, then uses the HPTE64_V_COMPARE() macro to check the B field and AVPN. However, a small tweak to HPTE64_V_COMPARE() means we can check all of these bits at once with a suitable ptem value. So, consolidate all the comparisons for simplicity. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
651060aba7
commit
073de86aa9
@ -488,8 +488,8 @@ static unsigned hpte_page_shift(const struct ppc_one_seg_page_size *sps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
|
static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
|
||||||
ppc_slb_t *slb, bool secondary,
|
ppc_slb_t *slb, target_ulong ptem,
|
||||||
target_ulong ptem, ppc_hash_pte64_t *pte)
|
ppc_hash_pte64_t *pte)
|
||||||
{
|
{
|
||||||
CPUPPCState *env = &cpu->env;
|
CPUPPCState *env = &cpu->env;
|
||||||
int i;
|
int i;
|
||||||
@ -506,9 +506,8 @@ static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
|
|||||||
pte0 = ppc_hash64_load_hpte0(cpu, token, i);
|
pte0 = ppc_hash64_load_hpte0(cpu, token, i);
|
||||||
pte1 = ppc_hash64_load_hpte1(cpu, token, i);
|
pte1 = ppc_hash64_load_hpte1(cpu, token, i);
|
||||||
|
|
||||||
if ((pte0 & HPTE64_V_VALID)
|
/* This compares V, B, H (secondary) and the AVPN */
|
||||||
&& (secondary == !!(pte0 & HPTE64_V_SECONDARY))
|
if (HPTE64_V_COMPARE(pte0, ptem)) {
|
||||||
&& HPTE64_V_COMPARE(pte0, ptem)) {
|
|
||||||
unsigned pshift = hpte_page_shift(slb->sps, pte0, pte1);
|
unsigned pshift = hpte_page_shift(slb->sps, pte0, pte1);
|
||||||
/*
|
/*
|
||||||
* If there is no match, ignore the PTE, it could simply
|
* If there is no match, ignore the PTE, it could simply
|
||||||
@ -563,6 +562,7 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu,
|
|||||||
hash = vsid ^ (epn >> slb->sps->page_shift);
|
hash = vsid ^ (epn >> slb->sps->page_shift);
|
||||||
}
|
}
|
||||||
ptem = (slb->vsid & SLB_VSID_PTEM) | ((epn >> 16) & HPTE64_V_AVPN);
|
ptem = (slb->vsid & SLB_VSID_PTEM) | ((epn >> 16) & HPTE64_V_AVPN);
|
||||||
|
ptem |= HPTE64_V_VALID;
|
||||||
|
|
||||||
/* Page address translation */
|
/* Page address translation */
|
||||||
qemu_log_mask(CPU_LOG_MMU,
|
qemu_log_mask(CPU_LOG_MMU,
|
||||||
@ -576,17 +576,18 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu,
|
|||||||
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
|
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
|
||||||
" hash=" TARGET_FMT_plx "\n",
|
" hash=" TARGET_FMT_plx "\n",
|
||||||
env->htab_base, env->htab_mask, vsid, ptem, hash);
|
env->htab_base, env->htab_mask, vsid, ptem, hash);
|
||||||
pte_offset = ppc_hash64_pteg_search(cpu, hash, slb, 0, ptem, pte);
|
pte_offset = ppc_hash64_pteg_search(cpu, hash, slb, ptem, pte);
|
||||||
|
|
||||||
if (pte_offset == -1) {
|
if (pte_offset == -1) {
|
||||||
/* Secondary PTEG lookup */
|
/* Secondary PTEG lookup */
|
||||||
|
ptem |= HPTE64_V_SECONDARY;
|
||||||
qemu_log_mask(CPU_LOG_MMU,
|
qemu_log_mask(CPU_LOG_MMU,
|
||||||
"1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
|
"1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
|
||||||
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
|
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
|
||||||
" hash=" TARGET_FMT_plx "\n", env->htab_base,
|
" hash=" TARGET_FMT_plx "\n", env->htab_base,
|
||||||
env->htab_mask, vsid, ptem, ~hash);
|
env->htab_mask, vsid, ptem, ~hash);
|
||||||
|
|
||||||
pte_offset = ppc_hash64_pteg_search(cpu, ~hash, slb, 1, ptem, pte);
|
pte_offset = ppc_hash64_pteg_search(cpu, ~hash, slb, ptem, pte);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pte_offset;
|
return pte_offset;
|
||||||
|
@ -62,7 +62,7 @@ unsigned ppc_hash64_hpte_page_shift_noslb(PowerPCCPU *cpu,
|
|||||||
#define HPTE64_V_AVPN_SHIFT 7
|
#define HPTE64_V_AVPN_SHIFT 7
|
||||||
#define HPTE64_V_AVPN 0x3fffffffffffff80ULL
|
#define HPTE64_V_AVPN 0x3fffffffffffff80ULL
|
||||||
#define HPTE64_V_AVPN_VAL(x) (((x) & HPTE64_V_AVPN) >> HPTE64_V_AVPN_SHIFT)
|
#define HPTE64_V_AVPN_VAL(x) (((x) & HPTE64_V_AVPN) >> HPTE64_V_AVPN_SHIFT)
|
||||||
#define HPTE64_V_COMPARE(x, y) (!(((x) ^ (y)) & 0xffffffffffffff80ULL))
|
#define HPTE64_V_COMPARE(x, y) (!(((x) ^ (y)) & 0xffffffffffffff83ULL))
|
||||||
#define HPTE64_V_LARGE 0x0000000000000004ULL
|
#define HPTE64_V_LARGE 0x0000000000000004ULL
|
||||||
#define HPTE64_V_SECONDARY 0x0000000000000002ULL
|
#define HPTE64_V_SECONDARY 0x0000000000000002ULL
|
||||||
#define HPTE64_V_VALID 0x0000000000000001ULL
|
#define HPTE64_V_VALID 0x0000000000000001ULL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user