From: "Cédric Le Goater" <clg@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: "Alexander Graf" <agraf@suse.de>,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
"Cédric Le Goater" <clg@kaod.org>
Subject: [Qemu-devel] [PATCH 4/4] ppc: fix VRMA support
Date: Fri, 1 Jul 2016 09:10:13 +0200 [thread overview]
Message-ID: <1467357013-4039-5-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1467357013-4039-1-git-send-email-clg@kaod.org>
commit 08109fd4360d ('ppc: Add proper real mode translation support')
introduced VRMA support for which SLB entries need to be created. But
it did not take into account the changes in ppc_slb_t and missed the
setting of the segment page size attribute.
However, gcc spotted it :
target-ppc/mmu-hash64.c: In function 'ppc_hash64_get_phys_page_debug':
target-ppc/mmu-hash64.c:936:16: error: '*((void *)&slb+16)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
pte_offset = ppc_hash64_htab_lookup(cpu, &slb, addr, &pte);
This adds an extra routine to built the slb and compute the segment
page size.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
I am not sure how to handle errors. Could there be one ? If so,
should we generate a POWERPC_EXCP_MCHECK ?
target-ppc/mmu-hash64.c | 53 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 14 deletions(-)
diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c
index 7ef45ee53bf5..117f198a9a2e 100644
--- a/target-ppc/mmu-hash64.c
+++ b/target-ppc/mmu-hash64.c
@@ -684,6 +684,43 @@ static int64_t ppc_hash64_get_rmls(CPUPPCState *env)
}
}
+static int ppc_hash64_make_vrma_slb(CPUPPCState *env, ppc_slb_t *slb)
+{
+ uint32_t vrmasd;
+ const struct ppc_one_seg_page_size *sps = NULL;
+ target_ulong esid, vsid;
+ int i;
+
+ vsid = SLB_VSID_VRMA;
+ vrmasd = (env->spr[SPR_LPCR] & LPCR_VRMASD) >> LPCR_VRMASD_SHIFT;
+ vsid |= (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP);
+ esid = SLB_ESID_V;
+
+ for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) {
+ const struct ppc_one_seg_page_size *sps1 = &env->sps.sps[i];
+
+ if (!sps1->page_shift) {
+ break;
+ }
+
+ if ((vsid & SLB_VSID_LLP_MASK) == sps1->slb_enc) {
+ sps = sps1;
+ break;
+ }
+ }
+
+ if (!sps) {
+ error_report("Bad page size encoding esid 0x"TARGET_FMT_lx
+ " vsid 0x"TARGET_FMT_lx, esid, vsid);
+ return -1;
+ }
+
+ slb->vsid = vsid;
+ slb->esid = esid;
+ slb->sps = sps;
+ return 0;
+}
+
int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,
int rwx, int mmu_idx)
{
@@ -722,13 +759,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,
} else {
/* Otherwise, check VPM for RMA vs VRMA */
if (env->spr[SPR_LPCR] & LPCR_VPM0) {
- uint32_t vrmasd;
- /* VRMA, we make up an SLB entry */
- slb.vsid = SLB_VSID_VRMA;
- vrmasd = (env->spr[SPR_LPCR] & LPCR_VRMASD) >>
- LPCR_VRMASD_SHIFT;
- slb.vsid |= (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP);
- slb.esid = SLB_ESID_V;
+ ppc_hash64_make_vrma_slb(env, &slb);
goto skip_slb;
}
/* RMA. Check bounds in RMLS */
@@ -893,13 +924,7 @@ hwaddr ppc_hash64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong addr)
/* Otherwise, check VPM for RMA vs VRMA */
if (env->spr[SPR_LPCR] & LPCR_VPM0) {
- uint32_t vrmasd;
-
- /* VRMA, we make up an SLB entry */
- slb.vsid = SLB_VSID_VRMA;
- vrmasd = (env->spr[SPR_LPCR] & LPCR_VRMASD) >> LPCR_VRMASD_SHIFT;
- slb.vsid |= (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP);
- slb.esid = SLB_ESID_V;
+ ppc_hash64_make_vrma_slb(env, &slb);
goto skip_slb;
}
/* RMA. Check bounds in RMLS */
--
2.1.4
next prev parent reply other threads:[~2016-07-01 7:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-01 7:10 [Qemu-devel] [PATCH 0/4] ppc: fixes for large page and VRMA support Cédric Le Goater
2016-07-01 7:10 ` [Qemu-devel] [PATCH 1/4] ppc: simplify ppc_hash64_hpte_page_shift_noslb() Cédric Le Goater
2016-07-04 4:46 ` David Gibson
2016-07-04 5:17 ` David Gibson
2016-07-01 7:10 ` [Qemu-devel] [PATCH 2/4] ppc: fix large page support Cédric Le Goater
2016-07-01 7:10 ` [Qemu-devel] [PATCH 3/4] ppc: simplify ppc_hash64_pteg_search() Cédric Le Goater
2016-07-01 7:10 ` Cédric Le Goater [this message]
2016-07-04 6:11 ` [Qemu-devel] [PATCH 0/4] ppc: fixes for large page and VRMA support Benjamin Herrenschmidt
2016-07-04 6:26 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467357013-4039-5-git-send-email-clg@kaod.org \
--to=clg@kaod.org \
--cc=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).