Set AVR TARGET_PAGE_BITS to be 10 instead of 8
cover Set AVR TARGET_PAGE_BITS to be 10 instead of 8
The previous value of TARGET_PAGE_BITS (8) is a bug. Make it 10 I tested it using the following commands
1. ninja test
2. make check-qtest-avr
3. avocado --show=app run -t arch:avr tests/acceptance/
Michael Rolnik (1):
Set TARGET_PAGE_BITS to be 10 instead of 8 bits
target/avr/cpu-param.h | 8 +------- target/avr/helper.c | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/1 Set TARGET_PAGE_BITS to be 10 instead of 8 bits
--- target/avr/cpu-param.h | 8 +------- target/avr/helper.c | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-)
target/avr/cpu-param.h +1 -7
@@ -22,13 +22,7 @@#define AVR_CPU_PARAM_H #define TARGET_LONG_BITS 32 -/* -* TARGET_PAGE_BITS cannot be more than 8 bits because -* 1. all IO registers occupy [0x0000 .. 0x00ff] address range, and they -* should be implemented as a device and not memory -* 2. SRAM starts at the address 0x0100 -*/ -#define TARGET_PAGE_BITS 8 +#define TARGET_PAGE_BITS 10#define TARGET_PHYS_ADDR_SPACE_BITS 24#define TARGET_VIRT_ADDR_SPACE_BITS 24#define NB_MMU_MODES 2
target/avr/helper.c +0 -2
@@ -111,8 +111,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size,MemTxAttrs attrs = {};uint32_t paddr; - address &=TARGET_PAGE_MASK ; -if (mmu_idx ==MMU_CODE_IDX ) {/* access to code in flash */ paddr =OFFSET_CODE + address;
Signature · 1 line
2.25.1
Re: [PATCH 1/1] Set TARGET_PAGE_BITS to be 10 instead of 8 bits
Quoted 11 lines · * Michael Rolnik ([email protected]) wrote:
Signed-off-by Michael Rolnik <[email protected]>--- target/avr/cpu-param.h | 8 +------- target/avr/helper.c | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-)target/avr/cpu-param.h +0
-0
target/avr/cpu-param.h line 29
Quoted 8 lines
target/avr/cpu-param.h +0
-5@@ -22,13 +22,7 @@#define AVR_CPU_PARAM_H #define TARGET_LONG_BITS 32 -/* -* TARGET_PAGE_BITS cannot be more than 8 bits because -* 1. all IO registers occupy [0x0000 .. 0x00ff] address range, and they -* should be implemented as a device and not memory -* 2. SRAM starts at the address 0x0100
I don't know AVR; but that seems to say why you can't make it any larger
- how do you solve that?
Dave
Quoted 21 lines
target/avr/cpu-param.h +1
-1-#define TARGET_PAGE_BITS 8 +#define TARGET_PAGE_BITS 10#define TARGET_PHYS_ADDR_SPACE_BITS 24#define TARGET_VIRT_ADDR_SPACE_BITS 24#define NB_MMU_MODES 2target/avr/helper.c +0
-2@@ -111,8 +111,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size,MemTxAttrs attrs = {};uint32_t paddr; - address &=TARGET_PAGE_MASK ; -if (mmu_idx ==MMU_CODE_IDX ) {/* access to code in flash */ paddr =OFFSET_CODE + address;Signature · 1 line
2.25.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH 1/1] Set TARGET_PAGE_BITS to be 10 instead of 8 bits
how long?
Quoted 53 lines · Dr. David Alan Gilbert
Quoted 11 lines · * Michael Rolnik ([email protected]) wrote:
Signed-off-by Michael Rolnik <[email protected]>--- target/avr/cpu-param.h | 8 +------- target/avr/helper.c | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-)target/avr/cpu-param.h +0
-0target/avr/cpu-param.h line 27
Quoted 6 lines
target/avr/cpu-param.h +0
-3@@ -22,13 +22,7 @@#define AVR_CPU_PARAM_H #define TARGET_LONG_BITS 32 -/* -* TARGET_PAGE_BITS cannot be more than 8 bits because -* 1. all IO registers occupy [0x0000 .. 0x00ff] address range, and they
target/avr/cpu-param.h line 29
Quoted 2 lines
target/avr/cpu-param.h +0
-2-* should be implemented as a device and not memory -* 2. SRAM starts at the address 0x0100 I don't know AVR; but that seems to say why you can't make it any larger
- how do you solve that?Dave
target/avr/helper.c bool avr_cpu_tlb_fill(CPUState *cs, vaddr address,
Quoted 10 lines
target/avr/cpu-param.h +1
-1-#define TARGET_PAGE_BITS 8 +#define TARGET_PAGE_BITS 10#define TARGET_PHYS_ADDR_SPACE_BITS 24#define TARGET_VIRT_ADDR_SPACE_BITS 24#define NB_MMU_MODES 2target/avr/helper.c +0
-0@@ -111,8 +111,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address,int size,
Quoted 11 lines
target/avr/helper.c +0
-3MemTxAttrs attrs = {};uint32_t paddr; - address &=TARGET_PAGE_MASK ; -if (mmu_idx ==MMU_CODE_IDX ) {/* access to code in flash */ paddr =OFFSET_CODE + address; --2.25.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Best Regards, Michael Rolnik
Re: [PATCH 1/1] Set TARGET_PAGE_BITS to be 10 instead of 8 bits
If I set TARGET_PAGE_BITS to 12 this *assert assert(v_l2_levels >= 0);* will fail (page_table_config_init function) because TARGET_PHYS_ADDR_SPACE_BITS is 24 bits, because AVR has 24 is the longest pointer AVR has. I can set TARGET_PHYS_ADDR_SPACE_BITS to 32 and TARGET_PAGE_BITS to 12 and everything will work fine.
What do you think?
btw, wrote the original comment, you David referred to, when I did not know that QEMU could map several regions to the same page, which is not true. That's why I could change 8 to 10.
Quoted 63 lines · Michael Rolnik
how long?
Quoted 49 lines · Dr. David Alan Gilbert
Quoted 11 lines · * Michael Rolnik ([email protected]) wrote:
Signed-off-by Michael Rolnik <[email protected]>--- target/avr/cpu-param.h | 8 +------- target/avr/helper.c | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-)target/avr/cpu-param.h +0
-0target/avr/cpu-param.h line 27
Quoted 6 lines
target/avr/cpu-param.h +0
-3@@ -22,13 +22,7 @@#define AVR_CPU_PARAM_H #define TARGET_LONG_BITS 32 -/* -* TARGET_PAGE_BITS cannot be more than 8 bits because -* 1. all IO registers occupy [0x0000 .. 0x00ff] address range, and they
target/avr/cpu-param.h line 29
Quoted 2 lines
target/avr/cpu-param.h +0
-2-* should be implemented as a device and not memory -* 2. SRAM starts at the address 0x0100 I don't know AVR; but that seems to say why you can't make it any larger
- how do you solve that?Dave
target/avr/helper.c bool avr_cpu_tlb_fill(CPUState *cs, vaddr address,
Quoted 10 lines
target/avr/cpu-param.h +1
-1-#define TARGET_PAGE_BITS 8 +#define TARGET_PAGE_BITS 10#define TARGET_PHYS_ADDR_SPACE_BITS 24#define TARGET_VIRT_ADDR_SPACE_BITS 24#define NB_MMU_MODES 2target/avr/helper.c +0
-0@@ -111,8 +111,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address,int size,
Quoted 11 lines
target/avr/helper.c +0
-3MemTxAttrs attrs = {};uint32_t paddr; - address &=TARGET_PAGE_MASK ; -if (mmu_idx ==MMU_CODE_IDX ) {/* access to code in flash */ paddr =OFFSET_CODE + address; --2.25.1
Quoted 4 lines
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK--
Best Regards,
Michael Rolnik
Signature · 2 lines
Best Regards, Michael Rolnik
Re: [PATCH 1/1] Set TARGET_PAGE_BITS to be 10 instead of 8 bits
Please review.
Quoted 82 lines · Michael Rolnik
If I set
TARGET_PAGE_BITSto 12 this *assertassert(v_l2_levels >= 0);* will fail (page_table_config_initfunction) becauseTARGET_PHYS_ADDR_SPACE_BITSis 24 bits, because AVR has 24 is the longest pointer AVR has. I can setTARGET_PHYS_ADDR_SPACE_BITSto 32 andTARGET_PAGE_BITSto 12 and everything will work fine.
What do you think?btw, wrote the original comment, you David referred to, when I did not know that QEMU could map several regions to the same page, which is not true. That's why I could change 8 to 10.
Quoted 54 lines · Michael Rolnik
how long?
Quoted 49 lines · Dr. David Alan Gilbert
Quoted 11 lines · * Michael Rolnik ([email protected]) wrote:
Signed-off-by Michael Rolnik <[email protected]>--- target/avr/cpu-param.h | 8 +------- target/avr/helper.c | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-)target/avr/cpu-param.h +0
-0target/avr/cpu-param.h line 27
Quoted 6 lines
target/avr/cpu-param.h +0
-3@@ -22,13 +22,7 @@#define AVR_CPU_PARAM_H #define TARGET_LONG_BITS 32 -/* -* TARGET_PAGE_BITS cannot be more than 8 bits because -* 1. all IO registers occupy [0x0000 .. 0x00ff] address range, and they
target/avr/cpu-param.h line 29
Quoted 2 lines
target/avr/cpu-param.h +0
-2-* should be implemented as a device and not memory -* 2. SRAM starts at the address 0x0100 I don't know AVR; but that seems to say why you can't make it any larger
- how do you solve that?Dave
target/avr/helper.c bool avr_cpu_tlb_fill(CPUState *cs, vaddr address,
Quoted 10 lines
target/avr/cpu-param.h +1
-1-#define TARGET_PAGE_BITS 8 +#define TARGET_PAGE_BITS 10#define TARGET_PHYS_ADDR_SPACE_BITS 24#define TARGET_VIRT_ADDR_SPACE_BITS 24#define NB_MMU_MODES 2target/avr/helper.c +0
-0@@ -111,8 +111,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address,int size,
Quoted 11 lines
target/avr/helper.c +0
-3MemTxAttrs attrs = {};uint32_t paddr; - address &=TARGET_PAGE_MASK ; -if (mmu_idx ==MMU_CODE_IDX ) {/* access to code in flash */ paddr =OFFSET_CODE + address; --2.25.1
Quoted 9 lines
Quoted 4 lines
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK--
Best Regards,
Michael Rolnik--
Best Regards,
Michael Rolnik
Signature · 2 lines
Best Regards, Michael Rolnik
Re: [PATCH 1/1] Set TARGET_PAGE_BITS to be 10 instead of 8 bits
Quoted 1 line · Michael Rolnik
Please review.
The first 256b is i/o, the next 768b are ram. But having changed the page size, it should mean that the first 1k are now treated as i/o.
We do have a path by which instructions in i/o pages can be executed. This happens on some ARM board setups during cold boot. But we do not save those translations, so they run much much slower than it should.
But perhaps in the case of AVR, "much much slower" really isn't visible?
In general, I think changing the page size is wrong. I also assume that migration is largely irrelevant to this target.
r~
Quoted 94 lines · On Tue, Mar 23, 2021 at 10:28 PM Michael Rolnik <[email protected]…
If I set
TARGET_PAGE_BITSto 12 this *assert assert(v_l2_levels >= 0);* will fail (page_table_config_initfunction) becauseTARGET_PHYS_ADDR_SPACE_BITSis 24 bits, because AVR has 24 is the longest pointer AVR has. I can setTARGET_PHYS_ADDR_SPACE_BITSto 32 andTARGET_PAGE_BITSto 12 and everything will work fine.
What do you think?btw, wrote the original comment, you David referred to, when I did not know that QEMU could map several regions to the same page, which is not true. That's why I could change 8 to 10.
On Tue, Mar 23, 2021 at 10:11 PM Michael Rolnik <[email protected] <mailto:[email protected]>> wrote:
how long?
On Tue, Mar 23, 2021 at 2:46 PM Dr. David Alan Gilbert <[email protected] <mailto:[email protected]>> wrote:
* Michael Rolnik ([email protected] <mailto:[email protected]>) wrote:
> Signed-off-by: Michael Rolnik <[email protected]
<mailto:[email protected]>>
> ---
>target/avr/cpu-param.h| 8 +-------
> target/avr/helper.c | 2 --
> 2 files changed, 1 insertion(+), 9 deletions(-)
>
> diff --gita/target/avr/cpu-param.hb/target/avr/cpu-param.h> index7ef4e7c679..9765a9d0db100644
> ---a/target/avr/cpu-param.h
> +++b/target/avr/cpu-param.h
> @@ -22,13 +22,7 @@
> #defineAVR_CPU_PARAM_H
>
> #defineTARGET_LONG_BITS32
> -/*
> - *TARGET_PAGE_BITScannot be more than 8 bits because > - * 1. all IO registers occupy [0x0000..0x00ff] address
range, and they
> - * should be implemented as a device and not memory > - * 2. SRAM starts at the address0x0100I don't know AVR; but that seems to say why you can't make it any larger
- how do you solve that?Dave
> -#define
TARGET_PAGE_BITS8
> +#defineTARGET_PAGE_BITS10
> #defineTARGET_PHYS_ADDR_SPACE_BITS24
> #defineTARGET_VIRT_ADDR_SPACE_BITS24
> #defineNB_MMU_MODES2
> diff --gita/target/avr/helper.cb/target/avr/helper.c> index35e1019594..da658afed3100644
> ---a/target/avr/helper.c
> +++b/target/avr/helper.c
> @@ -111,8 +111,6 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr
address, int size,
> MemTxAttrs attrs = {};
>uint32_tpaddr;
>
> - address &=TARGET_PAGE_MASK;
> -
> if (mmu_idx==MMU_CODE_IDX) {
> /* access to code in flash */
> paddr =OFFSET_CODE+ address;
> --
> 2.25.1
>
--
Dr. David Alan Gilbert / [email protected] <mailto:[email protected]> / Manchester, UK--
Best Regards,
Michael Rolnik--
Best Regards,
Michael RolnikSignature · 2 lines
Best Regards, Michael Rolnik
Re: [PATCH 1/1] Set TARGET_PAGE_BITS to be 10 instead of 8 bits
Quoted 8 lines · Richard Henderson
Quoted 1 line · Michael Rolnik
Please review.
The first 256b is i/o, the next 768b are ram. But having changed the page size, it should mean that the first 1k are now treated as i/o.
Quoted 8 lines
We do have a path by which instructions in i/o pages can be executed. This happens on some ARM board setups during cold boot. But we do not save those translations, so they run much much slower than it should.
But perhaps in the case of AVR, "much much slower" really isn't visible?
In general, I think changing the page size is wrong. I also assume that migration is largely irrelevant to this target.
Migration is irrelevant, but every target benefits from snapshot save-and-restore, and I think that uses the same codepaths ?
-- PMM
Re: [PATCH 1/1] Set TARGET_PAGE_BITS to be 10 instead of 8 bits
Quoted 14 lines · * Peter Maydell ([email protected]) wrote:
Quoted 12 lines · Richard Henderson
Quoted 1 line · Michael Rolnik
Please review.
The first 256b is i/o, the next 768b are ram. But having changed the page size, it should mean that the first 1k are now treated as i/o.
We do have a path by which instructions in i/o pages can be executed. This happens on some ARM board setups during cold boot. But we do not save those translations, so they run much much slower than it should.
Quoted 7 lines
Quoted 4 lines
But perhaps in the case of AVR, "much much slower" really isn't visible?
In general, I think changing the page size is wrong. I also assume that migration is largely irrelevant to this target.
Migration is irrelevant, but every target benefits from snapshot save-and-restore, and I think that uses the same codepaths ?
Yes it does.
My main problem for wanting this fixed is that I really wanted to add an assert to stop us tripping over the page size/migration bits clash.
Dave
Quoted 2 lines
-- PMM
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK