* [PATCH 0/2] target/cris: Pass MMUAccessType to cris_mmu_translate()
@ 2021-01-28 0:32 Philippe Mathieu-Daudé
2021-01-28 0:32 ` [PATCH 1/2] target/cris: Use MMUAccessType enum type when possible Philippe Mathieu-Daudé
2021-01-28 0:32 ` [PATCH 2/2] target/cris: Let cris_mmu_translate() use MMUAccessType access_type Philippe Mathieu-Daudé
0 siblings, 2 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-28 0:32 UTC (permalink / raw)
To: qemu-devel
Cc: Edgar E. Iglesias, Richard Henderson, Philippe Mathieu-Daudé,
Joe Komlodi
Taking notes while reviewing commit 671a0a1265a
("use MMUAccessType instead of int in mmu_translate").
Philippe Mathieu-Daudé (2):
target/cris: Use MMUAccessType enum type when possible
target/cris: Let cris_mmu_translate() use MMUAccessType access_type
target/cris/mmu.h | 2 +-
target/cris/helper.c | 4 ++--
target/cris/mmu.c | 31 +++++++++++++++----------------
3 files changed, 18 insertions(+), 19 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] target/cris: Use MMUAccessType enum type when possible
2021-01-28 0:32 [PATCH 0/2] target/cris: Pass MMUAccessType to cris_mmu_translate() Philippe Mathieu-Daudé
@ 2021-01-28 0:32 ` Philippe Mathieu-Daudé
2021-02-04 2:45 ` Richard Henderson
2021-01-28 0:32 ` [PATCH 2/2] target/cris: Let cris_mmu_translate() use MMUAccessType access_type Philippe Mathieu-Daudé
1 sibling, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-28 0:32 UTC (permalink / raw)
To: qemu-devel
Cc: Edgar E. Iglesias, Richard Henderson, Philippe Mathieu-Daudé,
Joe Komlodi
Replace the 0/1/2 magic values by the corresponding MMUAccessType.
We can remove a comment as enum names are self explicit.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
target/cris/helper.c | 4 ++--
target/cris/mmu.c | 13 ++++++-------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/target/cris/helper.c b/target/cris/helper.c
index ed45c3d9b70..cc110f1154d 100644
--- a/target/cris/helper.c
+++ b/target/cris/helper.c
@@ -274,10 +274,10 @@ hwaddr cris_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
struct cris_mmu_result res;
int miss;
- miss = cris_mmu_translate(&res, &cpu->env, addr, 0, 0, 1);
+ miss = cris_mmu_translate(&res, &cpu->env, addr, MMU_DATA_LOAD, 0, 1);
/* If D TLB misses, try I TLB. */
if (miss) {
- miss = cris_mmu_translate(&res, &cpu->env, addr, 2, 0, 1);
+ miss = cris_mmu_translate(&res, &cpu->env, addr, MMU_INST_FETCH, 0, 1);
}
if (!miss) {
diff --git a/target/cris/mmu.c b/target/cris/mmu.c
index a279b7f1b60..294de7dffd5 100644
--- a/target/cris/mmu.c
+++ b/target/cris/mmu.c
@@ -152,15 +152,15 @@ static int cris_mmu_translate_page(struct cris_mmu_result *res,
pid = env->pregs[PR_PID] & 0xff;
switch (rw) {
- case 2:
+ case MMU_INST_FETCH:
rwcause = CRIS_MMU_ERR_EXEC;
mmu = 0;
break;
- case 1:
+ case MMU_DATA_STORE:
rwcause = CRIS_MMU_ERR_WRITE;
break;
default:
- case 0:
+ case MMU_DATA_LOAD:
rwcause = CRIS_MMU_ERR_READ;
break;
}
@@ -219,13 +219,13 @@ static int cris_mmu_translate_page(struct cris_mmu_result *res,
vaddr, lo, env->pc));
match = 0;
res->bf_vec = vect_base + 2;
- } else if (rw == 1 && cfg_w && !tlb_w) {
+ } else if (rw == MMU_DATA_STORE && cfg_w && !tlb_w) {
D(printf("tlb: write protected %x lo=%x pc=%x\n",
vaddr, lo, env->pc));
match = 0;
/* write accesses never go through the I mmu. */
res->bf_vec = vect_base + 3;
- } else if (rw == 2 && cfg_x && !tlb_x) {
+ } else if (rw == MMU_INST_FETCH && cfg_x && !tlb_x) {
D(printf("tlb: exec protected %x lo=%x pc=%x\n",
vaddr, lo, env->pc));
match = 0;
@@ -329,8 +329,7 @@ int cris_mmu_translate(struct cris_mmu_result *res,
old_srs = env->pregs[PR_SRS];
- /* rw == 2 means exec, map the access to the insn mmu. */
- env->pregs[PR_SRS] = rw == 2 ? 1 : 2;
+ env->pregs[PR_SRS] = rw == MMU_INST_FETCH ? 1 : 2;
if (!cris_mmu_enabled(env->sregs[SFR_RW_GC_CFG])) {
res->phy = vaddr;
--
2.26.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] target/cris: Let cris_mmu_translate() use MMUAccessType access_type
2021-01-28 0:32 [PATCH 0/2] target/cris: Pass MMUAccessType to cris_mmu_translate() Philippe Mathieu-Daudé
2021-01-28 0:32 ` [PATCH 1/2] target/cris: Use MMUAccessType enum type when possible Philippe Mathieu-Daudé
@ 2021-01-28 0:32 ` Philippe Mathieu-Daudé
2021-02-04 2:46 ` Richard Henderson
1 sibling, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-28 0:32 UTC (permalink / raw)
To: qemu-devel
Cc: Edgar E. Iglesias, Richard Henderson, Philippe Mathieu-Daudé,
Joe Komlodi
All callers of cris_mmu_translate() provide a MMUAccessType
type. Let the prototype use it as argument, as it is stricter
than an integer. We can remove the documentation as enum
names are self explicit.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
target/cris/mmu.h | 2 +-
target/cris/mmu.c | 24 ++++++++++++------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/target/cris/mmu.h b/target/cris/mmu.h
index 9ab1642b964..d57386ec6cd 100644
--- a/target/cris/mmu.h
+++ b/target/cris/mmu.h
@@ -17,6 +17,6 @@ void cris_mmu_init(CPUCRISState *env);
void cris_mmu_flush_pid(CPUCRISState *env, uint32_t pid);
int cris_mmu_translate(struct cris_mmu_result *res,
CPUCRISState *env, uint32_t vaddr,
- int rw, int mmu_idx, int debug);
+ MMUAccessType access_type, int mmu_idx, int debug);
#endif
diff --git a/target/cris/mmu.c b/target/cris/mmu.c
index 294de7dffd5..b574ec6e5b9 100644
--- a/target/cris/mmu.c
+++ b/target/cris/mmu.c
@@ -129,10 +129,10 @@ static void dump_tlb(CPUCRISState *env, int mmu)
}
#endif
-/* rw 0 = read, 1 = write, 2 = exec. */
static int cris_mmu_translate_page(struct cris_mmu_result *res,
- CPUCRISState *env, uint32_t vaddr,
- int rw, int usermode, int debug)
+ CPUCRISState *env, uint32_t vaddr,
+ MMUAccessType access_type,
+ int usermode, int debug)
{
unsigned int vpage;
unsigned int idx;
@@ -151,7 +151,7 @@ static int cris_mmu_translate_page(struct cris_mmu_result *res,
r_cfg = env->sregs[SFR_RW_MM_CFG];
pid = env->pregs[PR_PID] & 0xff;
- switch (rw) {
+ switch (access_type) {
case MMU_INST_FETCH:
rwcause = CRIS_MMU_ERR_EXEC;
mmu = 0;
@@ -219,13 +219,13 @@ static int cris_mmu_translate_page(struct cris_mmu_result *res,
vaddr, lo, env->pc));
match = 0;
res->bf_vec = vect_base + 2;
- } else if (rw == MMU_DATA_STORE && cfg_w && !tlb_w) {
+ } else if (access_type == MMU_DATA_STORE && cfg_w && !tlb_w) {
D(printf("tlb: write protected %x lo=%x pc=%x\n",
vaddr, lo, env->pc));
match = 0;
/* write accesses never go through the I mmu. */
res->bf_vec = vect_base + 3;
- } else if (rw == MMU_INST_FETCH && cfg_x && !tlb_x) {
+ } else if (access_type == MMU_INST_FETCH && cfg_x && !tlb_x) {
D(printf("tlb: exec protected %x lo=%x pc=%x\n",
vaddr, lo, env->pc));
match = 0;
@@ -272,9 +272,9 @@ static int cris_mmu_translate_page(struct cris_mmu_result *res,
D(printf("refill vaddr=%x pc=%x\n", vaddr, env->pc));
}
- D(printf("%s rw=%d mtch=%d pc=%x va=%x vpn=%x tlbvpn=%x pfn=%x pid=%x"
+ D(printf("%s access=%u mtch=%d pc=%x va=%x vpn=%x tlbvpn=%x pfn=%x pid=%x"
" %x cause=%x sel=%x sp=%x %x %x\n",
- __func__, rw, match, env->pc,
+ __func__, access_type, match, env->pc,
vaddr, vpage,
tlb_vpn, tlb_pfn, tlb_pid,
pid,
@@ -319,8 +319,8 @@ void cris_mmu_flush_pid(CPUCRISState *env, uint32_t pid)
}
int cris_mmu_translate(struct cris_mmu_result *res,
- CPUCRISState *env, uint32_t vaddr,
- int rw, int mmu_idx, int debug)
+ CPUCRISState *env, uint32_t vaddr,
+ MMUAccessType access_type, int mmu_idx, int debug)
{
int seg;
int miss = 0;
@@ -329,7 +329,7 @@ int cris_mmu_translate(struct cris_mmu_result *res,
old_srs = env->pregs[PR_SRS];
- env->pregs[PR_SRS] = rw == MMU_INST_FETCH ? 1 : 2;
+ env->pregs[PR_SRS] = access_type == MMU_INST_FETCH ? 1 : 2;
if (!cris_mmu_enabled(env->sregs[SFR_RW_GC_CFG])) {
res->phy = vaddr;
@@ -346,7 +346,7 @@ int cris_mmu_translate(struct cris_mmu_result *res,
res->phy = base | (0x0fffffff & vaddr);
res->prot = PAGE_BITS;
} else {
- miss = cris_mmu_translate_page(res, env, vaddr, rw,
+ miss = cris_mmu_translate_page(res, env, vaddr, access_type,
is_user, debug);
}
done:
--
2.26.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] target/cris: Use MMUAccessType enum type when possible
2021-01-28 0:32 ` [PATCH 1/2] target/cris: Use MMUAccessType enum type when possible Philippe Mathieu-Daudé
@ 2021-02-04 2:45 ` Richard Henderson
2021-02-04 14:33 ` Edgar E. Iglesias
0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2021-02-04 2:45 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Edgar E. Iglesias, Joe Komlodi
On 1/27/21 2:32 PM, Philippe Mathieu-Daudé wrote:
> Replace the 0/1/2 magic values by the corresponding MMUAccessType.
> We can remove a comment as enum names are self explicit.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> target/cris/helper.c | 4 ++--
> target/cris/mmu.c | 13 ++++++-------
> 2 files changed, 8 insertions(+), 9 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] target/cris: Let cris_mmu_translate() use MMUAccessType access_type
2021-01-28 0:32 ` [PATCH 2/2] target/cris: Let cris_mmu_translate() use MMUAccessType access_type Philippe Mathieu-Daudé
@ 2021-02-04 2:46 ` Richard Henderson
2021-02-04 14:33 ` Edgar E. Iglesias
0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2021-02-04 2:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Edgar E. Iglesias, Joe Komlodi
On 1/27/21 2:32 PM, Philippe Mathieu-Daudé wrote:
> All callers of cris_mmu_translate() provide a MMUAccessType
> type. Let the prototype use it as argument, as it is stricter
> than an integer. We can remove the documentation as enum
> names are self explicit.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> target/cris/mmu.h | 2 +-
> target/cris/mmu.c | 24 ++++++++++++------------
> 2 files changed, 13 insertions(+), 13 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] target/cris: Use MMUAccessType enum type when possible
2021-02-04 2:45 ` Richard Henderson
@ 2021-02-04 14:33 ` Edgar E. Iglesias
0 siblings, 0 replies; 7+ messages in thread
From: Edgar E. Iglesias @ 2021-02-04 14:33 UTC (permalink / raw)
To: Richard Henderson; +Cc: Philippe Mathieu-Daudé, Joe Komlodi, qemu-devel
On Wed, Feb 03, 2021 at 04:45:50PM -1000, Richard Henderson wrote:
> On 1/27/21 2:32 PM, Philippe Mathieu-Daudé wrote:
> > Replace the 0/1/2 magic values by the corresponding MMUAccessType.
> > We can remove a comment as enum names are self explicit.
> >
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > ---
> > target/cris/helper.c | 4 ++--
> > target/cris/mmu.c | 13 ++++++-------
> > 2 files changed, 8 insertions(+), 9 deletions(-)
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Can this go through the trivial tree?
Thanks,
Edgar
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] target/cris: Let cris_mmu_translate() use MMUAccessType access_type
2021-02-04 2:46 ` Richard Henderson
@ 2021-02-04 14:33 ` Edgar E. Iglesias
0 siblings, 0 replies; 7+ messages in thread
From: Edgar E. Iglesias @ 2021-02-04 14:33 UTC (permalink / raw)
To: Richard Henderson; +Cc: Philippe Mathieu-Daudé, Joe Komlodi, qemu-devel
On Wed, Feb 03, 2021 at 04:46:28PM -1000, Richard Henderson wrote:
> On 1/27/21 2:32 PM, Philippe Mathieu-Daudé wrote:
> > All callers of cris_mmu_translate() provide a MMUAccessType
> > type. Let the prototype use it as argument, as it is stricter
> > than an integer. We can remove the documentation as enum
> > names are self explicit.
> >
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > ---
> > target/cris/mmu.h | 2 +-
> > target/cris/mmu.c | 24 ++++++++++++------------
> > 2 files changed, 13 insertions(+), 13 deletions(-)
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-02-04 14:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28 0:32 [PATCH 0/2] target/cris: Pass MMUAccessType to cris_mmu_translate() Philippe Mathieu-Daudé
2021-01-28 0:32 ` [PATCH 1/2] target/cris: Use MMUAccessType enum type when possible Philippe Mathieu-Daudé
2021-02-04 2:45 ` Richard Henderson
2021-02-04 14:33 ` Edgar E. Iglesias
2021-01-28 0:32 ` [PATCH 2/2] target/cris: Let cris_mmu_translate() use MMUAccessType access_type Philippe Mathieu-Daudé
2021-02-04 2:46 ` Richard Henderson
2021-02-04 14:33 ` Edgar E. Iglesias
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.