1 | target-arm queue: mostly smallish stuff. I expect to send | 1 | A big pullreq by number of patches, but most of them are just docs |
---|---|---|---|
2 | out another pullreq at the end of this week, but since this | 2 | updates or MAINTAINERS file fixes. The actual code changes are pretty |
3 | is up to 32 patches already I'd rather send it out now | 3 | minimal bugfixes. |
4 | than accumulate a monster sized patchset. | ||
5 | 4 | ||
6 | thanks | 5 | thanks |
7 | -- PMM | 6 | -- PMM |
8 | 7 | ||
8 | The following changes since commit 8cc30eb1400fc01f2b139cdd3dc524f8b84dbe07: | ||
9 | 9 | ||
10 | The following changes since commit 0ab4c574a55448a37b9f616259b82950742c9427: | 10 | Merge remote-tracking branch 'remotes/mcayland/tags/qemu-sparc-20201122' into staging (2020-11-22 15:02:52 +0000) |
11 | |||
12 | Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180626-pull-request' into staging (2018-06-26 16:44:57 +0100) | ||
13 | 11 | ||
14 | are available in the Git repository at: | 12 | are available in the Git repository at: |
15 | 13 | ||
16 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180626 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201123 |
17 | 15 | ||
18 | for you to fetch changes up to 9b945a9ee36a34eaeca412ef9ef35fbfe33c2c85: | 16 | for you to fetch changes up to c6ff78563ad2971f289168c7cae6ecb0b4359516: |
19 | 17 | ||
20 | aspeed/timer: use the APB frequency from the SCU (2018-06-26 17:50:42 +0100) | 18 | docs/system/pr-manager.rst: Fix minor docs nits (2020-11-23 11:10:04 +0000) |
21 | 19 | ||
22 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
23 | target-arm queue: | 21 | target-arm queue: |
24 | * aspeed: set APB clocks correctly (fixes slowdown on palmetto) | 22 | * incorporate 'orphan' rST docs into manuals |
25 | * smmuv3: cache config data and TLB entries | 23 | * linux-user/arm: Deliver SIGTRAP for UDF patterns used as breakpoints |
26 | * v7m/v8m: support read/write from MPU regions smaller than 1K | 24 | * target/arm: Make SYS_HEAPINFO work with RAM that doesn't start at 0 |
27 | * various: clean up logging/debug messages | 25 | * document raspi boards and tosa |
28 | * xilinx_spips: Make dma transactions as per dma_burst_size | 26 | * docs/system: Deprecate raspi2/raspi3 machine aliases |
27 | * docs/system/arm: Document OpenPOWER Witherspoon BMC model Front LEDs | ||
28 | * MAINTAINERS: add lines for docs files for Arm boards | ||
29 | * hw/intc: fix heap-buffer-overflow in rxicu_realize() | ||
30 | * hw/arm: Fix bad print format specifiers | ||
31 | * target/arm: fix stage 2 page-walks in 32-bit emulation | ||
29 | 32 | ||
30 | ---------------------------------------------------------------- | 33 | ---------------------------------------------------------------- |
31 | Cédric Le Goater (6): | 34 | AlexChen (1): |
32 | aspeed/smc: fix dummy cycles count when in dual IO mode | 35 | hw/arm: Fix bad print format specifiers |
33 | aspeed/smc: fix HW strapping | ||
34 | aspeed/smc: rename aspeed_smc_flash_send_addr() to aspeed_smc_flash_setup() | ||
35 | aspeed/scu: introduce clock frequencies | ||
36 | aspeed: initialize the SCU controller first | ||
37 | aspeed/timer: use the APB frequency from the SCU | ||
38 | 36 | ||
39 | Eric Auger (3): | 37 | Chen Qun (1): |
40 | hw/arm/smmuv3: Cache/invalidate config data | 38 | hw/intc: fix heap-buffer-overflow in rxicu_realize() |
41 | hw/arm/smmuv3: IOTLB emulation | ||
42 | hw/arm/smmuv3: Add notifications on invalidation | ||
43 | 39 | ||
44 | Jia He (1): | 40 | Peter Maydell (11): |
45 | hw/arm/smmuv3: Fix translate error handling | 41 | target/arm: Make SYS_HEAPINFO work with RAM that doesn't start at 0 |
42 | linux-user/arm: Deliver SIGTRAP for UDF patterns used as breakpoints | ||
43 | docs: Move virtio-net-failover.rst into the system manual | ||
44 | docs: Move cpu-hotplug.rst into the system manual | ||
45 | docs: Move virtio-pmem.rst into the system manual | ||
46 | docs/system/virtio-pmem.rst: Fix minor style issues | ||
47 | docs: Split out 'pc' machine model docs into their own file | ||
48 | docs: Move microvm.rst into the system manual | ||
49 | docs: Move pr-manager.rst into the system manual | ||
50 | docs: Split qemu-pr-helper documentation into tools manual | ||
51 | docs/system/pr-manager.rst: Fix minor docs nits | ||
46 | 52 | ||
47 | Joel Stanley (1): | 53 | Philippe Mathieu-Daudé (10): |
48 | MAINTAINERS: Add ASPEED BMCs | 54 | MAINTAINERS: Cover system/arm/cpu-features.rst with ARM TCG CPUs |
55 | MAINTAINERS: Cover system/arm/aspeed.rst with ASPEED BMC machines | ||
56 | MAINTAINERS: Cover system/arm/nuvoton.rst with Nuvoton NPCM7xx | ||
57 | MAINTAINERS: Fix system/arm/orangepi.rst path | ||
58 | MAINTAINERS: Cover system/arm/sbsa.rst with SBSA-REF machine | ||
59 | MAINTAINERS: Cover system/arm/sx1.rst with OMAP machines | ||
60 | docs/system: Deprecate raspi2/raspi3 machine aliases | ||
61 | docs/system/arm: Document the various raspi boards | ||
62 | docs/system/arm: Document OpenPOWER Witherspoon BMC model Front LEDs | ||
63 | docs/system/arm: Document the Sharp Zaurus SL-6000 | ||
49 | 64 | ||
50 | Peter Maydell (3): | 65 | Rémi Denis-Courmont (1): |
51 | tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE | 66 | target/arm: fix stage 2 page-walks in 32-bit emulation |
52 | target/arm: Set page (region) size in get_phys_addr_pmsav7() | ||
53 | target/arm: Handle small regions in get_phys_addr_pmsav8() | ||
54 | 67 | ||
55 | Philippe Mathieu-Daudé (17): | 68 | docs/meson.build | 1 + |
56 | MAINTAINERS: Adopt the Gumstix computers-on-module machines | 69 | docs/system/arm/aspeed.rst | 1 + |
57 | hw/input/pckbd: Use qemu_log_mask(GUEST_ERROR) instead of fprintf | 70 | docs/system/arm/raspi.rst | 43 +++++++++++++++ |
58 | hw/input/tsc2005: Use qemu_log_mask(GUEST_ERROR) instead of fprintf | 71 | docs/system/arm/xscale.rst | 20 ++++--- |
59 | hw/dma/omap_dma: Use qemu_log_mask(UNIMP) instead of printf | 72 | docs/{ => system}/cpu-hotplug.rst | 0 |
60 | hw/dma/omap_dma: Use qemu_log_mask(GUEST_ERROR) instead of fprintf | 73 | docs/system/deprecated.rst | 7 +++ |
61 | hw/ssi/omap_spi: Use qemu_log_mask(GUEST_ERROR) instead of fprintf | 74 | docs/{ => system/i386}/microvm.rst | 5 +- |
62 | hw/sd/omap_mmc: Use qemu_log_mask(UNIMP) instead of printf | 75 | docs/system/i386/pc.rst | 7 +++ |
63 | hw/i2c/omap_i2c: Use qemu_log_mask(UNIMP) instead of fprintf | 76 | docs/system/index.rst | 4 ++ |
64 | hw/arm/omap1: Use qemu_log_mask(GUEST_ERROR) instead of fprintf | 77 | docs/{ => system}/pr-manager.rst | 44 +++------------ |
65 | hw/arm/omap: Use qemu_log_mask(GUEST_ERROR) instead of fprintf | 78 | docs/system/target-arm.rst | 1 + |
66 | hw/arm/stellaris: Use qemu_log_mask(UNIMP) instead of fprintf | 79 | docs/system/target-i386.rst | 19 +++++-- |
67 | hw/net/stellaris_enet: Fix a typo | 80 | docs/{ => system}/virtio-net-failover.rst | 0 |
68 | hw/net/stellaris_enet: Use qemu_log_mask(GUEST_ERROR) instead of hw_error | 81 | docs/system/virtio-pmem.rst | 76 ++++++++++++++++++++++++++ |
69 | hw/net/smc91c111: Use qemu_log_mask(GUEST_ERROR) instead of hw_error | 82 | docs/tools/conf.py | 2 + |
70 | hw/net/smc91c111: Use qemu_log_mask(UNIMP) instead of fprintf | 83 | docs/tools/index.rst | 1 + |
71 | hw/arm/stellaris: Fix gptm_write() error message | 84 | docs/tools/qemu-pr-helper.rst | 90 +++++++++++++++++++++++++++++++ |
72 | hw/arm/stellaris: Use HWADDR_PRIx to display register address | 85 | docs/virtio-pmem.rst | 76 -------------------------- |
86 | hw/arm/pxa2xx.c | 2 +- | ||
87 | hw/arm/spitz.c | 2 +- | ||
88 | hw/arm/tosa.c | 2 +- | ||
89 | hw/intc/rx_icu.c | 18 +++---- | ||
90 | linux-user/arm/cpu_loop.c | 28 ++++++++++ | ||
91 | target/arm/arm-semi.c | 12 +++-- | ||
92 | target/arm/helper.c | 4 +- | ||
93 | MAINTAINERS | 8 ++- | ||
94 | 26 files changed, 326 insertions(+), 147 deletions(-) | ||
95 | create mode 100644 docs/system/arm/raspi.rst | ||
96 | rename docs/{ => system}/cpu-hotplug.rst (100%) | ||
97 | rename docs/{ => system/i386}/microvm.rst (98%) | ||
98 | create mode 100644 docs/system/i386/pc.rst | ||
99 | rename docs/{ => system}/pr-manager.rst (68%) | ||
100 | rename docs/{ => system}/virtio-net-failover.rst (100%) | ||
101 | create mode 100644 docs/system/virtio-pmem.rst | ||
102 | create mode 100644 docs/tools/qemu-pr-helper.rst | ||
103 | delete mode 100644 docs/virtio-pmem.rst | ||
73 | 104 | ||
74 | Sai Pavan Boddu (1): | ||
75 | xilinx_spips: Make dma transactions as per dma_burst_size | ||
76 | |||
77 | accel/tcg/softmmu_template.h | 24 ++- | ||
78 | hw/arm/smmuv3-internal.h | 12 +- | ||
79 | include/exec/cpu-all.h | 5 +- | ||
80 | include/hw/arm/omap.h | 30 +-- | ||
81 | include/hw/arm/smmu-common.h | 24 +++ | ||
82 | include/hw/arm/smmuv3.h | 1 + | ||
83 | include/hw/misc/aspeed_scu.h | 70 ++++++- | ||
84 | include/hw/ssi/xilinx_spips.h | 5 +- | ||
85 | include/hw/timer/aspeed_timer.h | 4 + | ||
86 | accel/tcg/cputlb.c | 131 +++++++++++-- | ||
87 | hw/arm/aspeed_soc.c | 42 ++-- | ||
88 | hw/arm/omap1.c | 18 +- | ||
89 | hw/arm/smmu-common.c | 118 ++++++++++- | ||
90 | hw/arm/smmuv3.c | 420 ++++++++++++++++++++++++++++++++++++---- | ||
91 | hw/arm/stellaris.c | 8 +- | ||
92 | hw/dma/omap_dma.c | 70 ++++--- | ||
93 | hw/i2c/omap_i2c.c | 20 +- | ||
94 | hw/input/pckbd.c | 4 +- | ||
95 | hw/input/tsc2005.c | 13 +- | ||
96 | hw/misc/aspeed_scu.c | 106 ++++++++++ | ||
97 | hw/net/smc91c111.c | 21 +- | ||
98 | hw/net/stellaris_enet.c | 11 +- | ||
99 | hw/sd/omap_mmc.c | 13 +- | ||
100 | hw/ssi/aspeed_smc.c | 48 ++--- | ||
101 | hw/ssi/omap_spi.c | 15 +- | ||
102 | hw/ssi/xilinx_spips.c | 23 ++- | ||
103 | hw/timer/aspeed_timer.c | 19 +- | ||
104 | target/arm/helper.c | 115 +++++++---- | ||
105 | MAINTAINERS | 14 +- | ||
106 | hw/arm/trace-events | 27 ++- | ||
107 | 30 files changed, 1176 insertions(+), 255 deletions(-) | ||
108 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | When configured in dual I/O mode, address and data are sent in dual | ||
4 | mode, including the dummy byte cycles in between. Adapt the count to | ||
5 | the IO setting. | ||
6 | |||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
9 | Message-id: 20180612065716.10587-2-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/ssi/aspeed_smc.c | 9 ++++++++- | ||
13 | 1 file changed, 8 insertions(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/ssi/aspeed_smc.c | ||
18 | +++ b/hw/ssi/aspeed_smc.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | |||
21 | /* CEx Control Register */ | ||
22 | #define R_CTRL0 (0x10 / 4) | ||
23 | +#define CTRL_IO_DUAL_DATA (1 << 29) | ||
24 | +#define CTRL_IO_DUAL_ADDR_DATA (1 << 28) /* Includes dummies */ | ||
25 | #define CTRL_CMD_SHIFT 16 | ||
26 | #define CTRL_CMD_MASK 0xff | ||
27 | #define CTRL_DUMMY_HIGH_SHIFT 14 | ||
28 | @@ -XXX,XX +XXX,XX @@ static int aspeed_smc_flash_dummies(const AspeedSMCFlash *fl) | ||
29 | uint32_t r_ctrl0 = s->regs[s->r_ctrl0 + fl->id]; | ||
30 | uint32_t dummy_high = (r_ctrl0 >> CTRL_DUMMY_HIGH_SHIFT) & 0x1; | ||
31 | uint32_t dummy_low = (r_ctrl0 >> CTRL_DUMMY_LOW_SHIFT) & 0x3; | ||
32 | + uint32_t dummies = ((dummy_high << 2) | dummy_low) * 8; | ||
33 | |||
34 | - return ((dummy_high << 2) | dummy_low) * 8; | ||
35 | + if (r_ctrl0 & CTRL_IO_DUAL_ADDR_DATA) { | ||
36 | + dummies /= 2; | ||
37 | + } | ||
38 | + | ||
39 | + return dummies; | ||
40 | } | ||
41 | |||
42 | static void aspeed_smc_flash_send_addr(AspeedSMCFlash *fl, uint32_t addr) | ||
43 | -- | ||
44 | 2.17.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | Only the flash type is strapped by HW. The 4BYTE mode is set by | ||
4 | firmware when the flash device is detected. | ||
5 | |||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
8 | Message-id: 20180612065716.10587-3-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/ssi/aspeed_smc.c | 8 +------- | ||
12 | 1 file changed, 1 insertion(+), 7 deletions(-) | ||
13 | |||
14 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/ssi/aspeed_smc.c | ||
17 | +++ b/hw/ssi/aspeed_smc.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_reset(DeviceState *d) | ||
19 | aspeed_smc_segment_to_reg(&s->ctrl->segments[i]); | ||
20 | } | ||
21 | |||
22 | - /* HW strapping for AST2500 FMC controllers */ | ||
23 | + /* HW strapping flash type for FMC controllers */ | ||
24 | if (s->ctrl->segments == aspeed_segments_ast2500_fmc) { | ||
25 | /* flash type is fixed to SPI for CE0 and CE1 */ | ||
26 | s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI << CONF_FLASH_TYPE0); | ||
27 | s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI << CONF_FLASH_TYPE1); | ||
28 | - | ||
29 | - /* 4BYTE mode is autodetected for CE0. Let's force it to 1 for | ||
30 | - * now */ | ||
31 | - s->regs[s->r_ce_ctrl] |= (1 << (CTRL_EXTENDED0)); | ||
32 | } | ||
33 | |||
34 | /* HW strapping for AST2400 FMC controllers (SCU70). Let's use the | ||
35 | * configuration of the palmetto-bmc machine */ | ||
36 | if (s->ctrl->segments == aspeed_segments_fmc) { | ||
37 | s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI << CONF_FLASH_TYPE0); | ||
38 | - | ||
39 | - s->regs[s->r_ce_ctrl] |= (1 << (CTRL_EXTENDED0)); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | -- | ||
44 | 2.17.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | Also handle the fake transfers for dummy bytes in this setup | ||
4 | routine. It will be useful when we activate MMIO execution. | ||
5 | |||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
8 | Message-id: 20180612065716.10587-4-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/ssi/aspeed_smc.c | 31 ++++++++++++++++--------------- | ||
12 | 1 file changed, 16 insertions(+), 15 deletions(-) | ||
13 | |||
14 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/ssi/aspeed_smc.c | ||
17 | +++ b/hw/ssi/aspeed_smc.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static int aspeed_smc_flash_dummies(const AspeedSMCFlash *fl) | ||
19 | return dummies; | ||
20 | } | ||
21 | |||
22 | -static void aspeed_smc_flash_send_addr(AspeedSMCFlash *fl, uint32_t addr) | ||
23 | +static void aspeed_smc_flash_setup(AspeedSMCFlash *fl, uint32_t addr) | ||
24 | { | ||
25 | const AspeedSMCState *s = fl->controller; | ||
26 | uint8_t cmd = aspeed_smc_flash_cmd(fl); | ||
27 | + int i; | ||
28 | |||
29 | /* Flash access can not exceed CS segment */ | ||
30 | addr = aspeed_smc_check_segment_addr(fl, addr); | ||
31 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_send_addr(AspeedSMCFlash *fl, uint32_t addr) | ||
32 | ssi_transfer(s->spi, (addr >> 16) & 0xff); | ||
33 | ssi_transfer(s->spi, (addr >> 8) & 0xff); | ||
34 | ssi_transfer(s->spi, (addr & 0xff)); | ||
35 | + | ||
36 | + /* | ||
37 | + * Use fake transfers to model dummy bytes. The value should | ||
38 | + * be configured to some non-zero value in fast read mode and | ||
39 | + * zero in read mode. But, as the HW allows inconsistent | ||
40 | + * settings, let's check for fast read mode. | ||
41 | + */ | ||
42 | + if (aspeed_smc_flash_mode(fl) == CTRL_FREADMODE) { | ||
43 | + for (i = 0; i < aspeed_smc_flash_dummies(fl); i++) { | ||
44 | + ssi_transfer(fl->controller->spi, 0xFF); | ||
45 | + } | ||
46 | + } | ||
47 | } | ||
48 | |||
49 | static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size) | ||
50 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size) | ||
51 | case CTRL_READMODE: | ||
52 | case CTRL_FREADMODE: | ||
53 | aspeed_smc_flash_select(fl); | ||
54 | - aspeed_smc_flash_send_addr(fl, addr); | ||
55 | - | ||
56 | - /* | ||
57 | - * Use fake transfers to model dummy bytes. The value should | ||
58 | - * be configured to some non-zero value in fast read mode and | ||
59 | - * zero in read mode. But, as the HW allows inconsistent | ||
60 | - * settings, let's check for fast read mode. | ||
61 | - */ | ||
62 | - if (aspeed_smc_flash_mode(fl) == CTRL_FREADMODE) { | ||
63 | - for (i = 0; i < aspeed_smc_flash_dummies(fl); i++) { | ||
64 | - ssi_transfer(fl->controller->spi, 0xFF); | ||
65 | - } | ||
66 | - } | ||
67 | + aspeed_smc_flash_setup(fl, addr); | ||
68 | |||
69 | for (i = 0; i < size; i++) { | ||
70 | ret |= ssi_transfer(s->spi, 0x0) << (8 * i); | ||
71 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_write(void *opaque, hwaddr addr, uint64_t data, | ||
72 | break; | ||
73 | case CTRL_WRITEMODE: | ||
74 | aspeed_smc_flash_select(fl); | ||
75 | - aspeed_smc_flash_send_addr(fl, addr); | ||
76 | + aspeed_smc_flash_setup(fl, addr); | ||
77 | |||
78 | for (i = 0; i < size; i++) { | ||
79 | ssi_transfer(s->spi, (data >> (8 * i)) & 0xff); | ||
80 | -- | ||
81 | 2.17.1 | ||
82 | |||
83 | diff view generated by jsdifflib |
1 | Allow ARMv8M to handle small MPU and SAU region sizes, by making | 1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> |
---|---|---|---|
2 | get_phys_add_pmsav8() set the page size to the 1 if the MPU or | ||
3 | SAU region covers less than a TARGET_PAGE_SIZE. | ||
4 | 2 | ||
5 | We choose to use a size of 1 because it makes no difference to | 3 | Using a target unsigned long would limit the Input Address to a LPAE |
6 | the core code, and avoids having to track both the base and | 4 | page-walk to 32 bits on AArch32 and 64 bits on AArch64. This is okay |
7 | limit for SAU and MPU and then convert into an artificially | 5 | for stage 1 or on AArch64, but it is insufficient for stage 2 on |
8 | restricted "page size" that the core code will then ignore. | 6 | AArch32. In that later case, the Input Address can have up to 40 bits. |
9 | 7 | ||
10 | Since the core TCG code can't handle execution from small | 8 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> |
11 | MPU regions, we strip the exec permission from them so that | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | any execution attempts will cause an MPU exception, rather | 10 | Message-id: 20201118150414.18360-1-remi@remlab.net |
13 | than allowing it to end up with a cpu_abort() in | ||
14 | get_page_addr_code(). | ||
15 | |||
16 | (The previous code's intention was to make any small page be | ||
17 | treated as having no permissions, but unfortunately errors | ||
18 | in the implementation meant that it didn't behave that way. | ||
19 | It's possible that some binaries using small regions were | ||
20 | accidentally working with our old behaviour and won't now.) | ||
21 | |||
22 | We also retain an existing bug, where we ignored the possibility | ||
23 | that the SAU region might not cover the entire page, in the | ||
24 | case of executable regions. This is necessary because some | ||
25 | currently-working guest code images rely on being able to | ||
26 | execute from addresses which are covered by a page-sized | ||
27 | MPU region but a smaller SAU region. We can remove this | ||
28 | workaround if we ever support execution from small regions. | ||
29 | |||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
32 | Message-id: 20180620130619.11362-4-peter.maydell@linaro.org | ||
33 | --- | 12 | --- |
34 | target/arm/helper.c | 78 ++++++++++++++++++++++++++++++++------------- | 13 | target/arm/helper.c | 4 ++-- |
35 | 1 file changed, 55 insertions(+), 23 deletions(-) | 14 | 1 file changed, 2 insertions(+), 2 deletions(-) |
36 | 15 | ||
37 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
38 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/helper.c | 18 | --- a/target/arm/helper.c |
40 | +++ b/target/arm/helper.c | 19 | +++ b/target/arm/helper.c |
41 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | 20 | @@ -XXX,XX +XXX,XX @@ |
42 | 21 | ||
43 | /* Security attributes for an address, as returned by v8m_security_lookup. */ | 22 | #ifndef CONFIG_USER_ONLY |
44 | typedef struct V8M_SAttributes { | 23 | |
45 | + bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */ | 24 | -static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, |
46 | bool ns; | 25 | +static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, |
47 | bool nsc; | 26 | MMUAccessType access_type, ARMMMUIdx mmu_idx, |
48 | uint8_t sregion; | 27 | bool s1_is_el0, |
49 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | 28 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, |
50 | int r; | 29 | @@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, |
51 | bool idau_exempt = false, idau_ns = true, idau_nsc = true; | 30 | * @fi: set to fault info if the translation fails |
52 | int idau_region = IREGION_NOTVALID; | 31 | * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes |
53 | + uint32_t addr_page_base = address & TARGET_PAGE_MASK; | 32 | */ |
54 | + uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | 33 | -static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, |
55 | 34 | +static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | |
56 | if (cpu->idau) { | 35 | MMUAccessType access_type, ARMMMUIdx mmu_idx, |
57 | IDAUInterfaceClass *iic = IDAU_INTERFACE_GET_CLASS(cpu->idau); | 36 | bool s1_is_el0, |
58 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | 37 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, |
59 | uint32_t limit = env->sau.rlar[r] | 0x1f; | ||
60 | |||
61 | if (base <= address && limit >= address) { | ||
62 | + if (base > addr_page_base || limit < addr_page_limit) { | ||
63 | + sattrs->subpage = true; | ||
64 | + } | ||
65 | if (sattrs->srvalid) { | ||
66 | /* If we hit in more than one region then we must report | ||
67 | * as Secure, not NS-Callable, with no valid region | ||
68 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
69 | static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
70 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
71 | hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
72 | - int *prot, ARMMMUFaultInfo *fi, uint32_t *mregion) | ||
73 | + int *prot, bool *is_subpage, | ||
74 | + ARMMMUFaultInfo *fi, uint32_t *mregion) | ||
75 | { | ||
76 | /* Perform a PMSAv8 MPU lookup (without also doing the SAU check | ||
77 | * that a full phys-to-virt translation does). | ||
78 | * mregion is (if not NULL) set to the region number which matched, | ||
79 | * or -1 if no region number is returned (MPU off, address did not | ||
80 | * hit a region, address hit in multiple regions). | ||
81 | + * We set is_subpage to true if the region hit doesn't cover the | ||
82 | + * entire TARGET_PAGE the address is within. | ||
83 | */ | ||
84 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
85 | bool is_user = regime_is_user(env, mmu_idx); | ||
86 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
87 | int n; | ||
88 | int matchregion = -1; | ||
89 | bool hit = false; | ||
90 | + uint32_t addr_page_base = address & TARGET_PAGE_MASK; | ||
91 | + uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | ||
92 | |||
93 | + *is_subpage = false; | ||
94 | *phys_ptr = address; | ||
95 | *prot = 0; | ||
96 | if (mregion) { | ||
97 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
98 | continue; | ||
99 | } | ||
100 | |||
101 | + if (base > addr_page_base || limit < addr_page_limit) { | ||
102 | + *is_subpage = true; | ||
103 | + } | ||
104 | + | ||
105 | if (hit) { | ||
106 | /* Multiple regions match -- always a failure (unlike | ||
107 | * PMSAv7 where highest-numbered-region wins) | ||
108 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
109 | |||
110 | matchregion = n; | ||
111 | hit = true; | ||
112 | - | ||
113 | - if (base & ~TARGET_PAGE_MASK) { | ||
114 | - qemu_log_mask(LOG_UNIMP, | ||
115 | - "MPU_RBAR[%d]: No support for MPU region base" | ||
116 | - "address of 0x%" PRIx32 ". Minimum alignment is " | ||
117 | - "%d\n", | ||
118 | - n, base, TARGET_PAGE_BITS); | ||
119 | - continue; | ||
120 | - } | ||
121 | - if ((limit + 1) & ~TARGET_PAGE_MASK) { | ||
122 | - qemu_log_mask(LOG_UNIMP, | ||
123 | - "MPU_RBAR[%d]: No support for MPU region limit" | ||
124 | - "address of 0x%" PRIx32 ". Minimum alignment is " | ||
125 | - "%d\n", | ||
126 | - n, limit, TARGET_PAGE_BITS); | ||
127 | - continue; | ||
128 | - } | ||
129 | } | ||
130 | } | ||
131 | |||
132 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
133 | |||
134 | fi->type = ARMFault_Permission; | ||
135 | fi->level = 1; | ||
136 | + /* | ||
137 | + * Core QEMU code can't handle execution from small pages yet, so | ||
138 | + * don't try it. This means any attempted execution will generate | ||
139 | + * an MPU exception, rather than eventually causing QEMU to exit in | ||
140 | + * get_page_addr_code(). | ||
141 | + */ | ||
142 | + if (*is_subpage && (*prot & PAGE_EXEC)) { | ||
143 | + qemu_log_mask(LOG_UNIMP, | ||
144 | + "MPU: No support for execution from regions " | ||
145 | + "smaller than 1K\n"); | ||
146 | + *prot &= ~PAGE_EXEC; | ||
147 | + } | ||
148 | return !(*prot & (1 << access_type)); | ||
149 | } | ||
150 | |||
151 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
152 | static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
153 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
154 | hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
155 | - int *prot, ARMMMUFaultInfo *fi) | ||
156 | + int *prot, target_ulong *page_size, | ||
157 | + ARMMMUFaultInfo *fi) | ||
158 | { | ||
159 | uint32_t secure = regime_is_secure(env, mmu_idx); | ||
160 | V8M_SAttributes sattrs = {}; | ||
161 | + bool ret; | ||
162 | + bool mpu_is_subpage; | ||
163 | |||
164 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
165 | v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs); | ||
166 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
167 | } else { | ||
168 | fi->type = ARMFault_QEMU_SFault; | ||
169 | } | ||
170 | + *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | ||
171 | *phys_ptr = address; | ||
172 | *prot = 0; | ||
173 | return true; | ||
174 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
175 | * for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt(). | ||
176 | */ | ||
177 | fi->type = ARMFault_QEMU_SFault; | ||
178 | + *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | ||
179 | *phys_ptr = address; | ||
180 | *prot = 0; | ||
181 | return true; | ||
182 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
183 | } | ||
184 | } | ||
185 | |||
186 | - return pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, | ||
187 | - txattrs, prot, fi, NULL); | ||
188 | + ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, | ||
189 | + txattrs, prot, &mpu_is_subpage, fi, NULL); | ||
190 | + /* | ||
191 | + * TODO: this is a temporary hack to ignore the fact that the SAU region | ||
192 | + * is smaller than a page if this is an executable region. We never | ||
193 | + * supported small MPU regions, but we did (accidentally) allow small | ||
194 | + * SAU regions, and if we now made small SAU regions not be executable | ||
195 | + * then this would break previously working guest code. We can't | ||
196 | + * remove this until/unless we implement support for execution from | ||
197 | + * small regions. | ||
198 | + */ | ||
199 | + if (*prot & PAGE_EXEC) { | ||
200 | + sattrs.subpage = false; | ||
201 | + } | ||
202 | + *page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | ||
203 | + return ret; | ||
204 | } | ||
205 | |||
206 | static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
207 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
208 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
209 | /* PMSAv8 */ | ||
210 | ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx, | ||
211 | - phys_ptr, attrs, prot, fi); | ||
212 | + phys_ptr, attrs, prot, page_size, fi); | ||
213 | } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
214 | /* PMSAv7 */ | ||
215 | ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | ||
216 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
217 | uint32_t mregion; | ||
218 | bool targetpriv; | ||
219 | bool targetsec = env->v7m.secure; | ||
220 | + bool is_subpage; | ||
221 | |||
222 | /* Work out what the security state and privilege level we're | ||
223 | * interested in is... | ||
224 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
225 | if (arm_current_el(env) != 0 || alt) { | ||
226 | /* We can ignore the return value as prot is always set */ | ||
227 | pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, | ||
228 | - &phys_addr, &attrs, &prot, &fi, &mregion); | ||
229 | + &phys_addr, &attrs, &prot, &is_subpage, | ||
230 | + &fi, &mregion); | ||
231 | if (mregion == -1) { | ||
232 | mrvalid = false; | ||
233 | mregion = 0; | ||
234 | -- | 38 | -- |
235 | 2.17.1 | 39 | 2.20.1 |
236 | 40 | ||
237 | 41 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: AlexChen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | hw_error() finally calls abort(), but there is no need to abort here. | 3 | We should use printf format specifier "%u" instead of "%i" for |
4 | argument of type "unsigned int". | ||
4 | 5 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
6 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
7 | Message-id: 20180624040609.17572-14-f4bug@amsat.org | 8 | Message-id: 5F9FD78B.8000300@huawei.com |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | hw/net/smc91c111.c | 9 +++++++-- | 12 | hw/arm/pxa2xx.c | 2 +- |
11 | 1 file changed, 7 insertions(+), 2 deletions(-) | 13 | hw/arm/spitz.c | 2 +- |
14 | hw/arm/tosa.c | 2 +- | ||
15 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
12 | 16 | ||
13 | diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c | 17 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/net/smc91c111.c | 19 | --- a/hw/arm/pxa2xx.c |
16 | +++ b/hw/net/smc91c111.c | 20 | +++ b/hw/arm/pxa2xx.c |
17 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_ssp_write(void *opaque, hwaddr addr, |
18 | #include "hw/sysbus.h" | 22 | if (value & SSCR0_MOD) |
19 | #include "net/net.h" | 23 | printf("%s: Attempt to use network mode\n", __func__); |
20 | #include "hw/devices.h" | 24 | if (s->enable && SSCR0_DSS(value) < 4) |
21 | +#include "qemu/log.h" | 25 | - printf("%s: Wrong data size: %i bits\n", __func__, |
22 | /* For crc32 */ | 26 | + printf("%s: Wrong data size: %u bits\n", __func__, |
23 | #include <zlib.h> | 27 | SSCR0_DSS(value)); |
24 | 28 | if (!(value & SSCR0_SSE)) { | |
25 | @@ -XXX,XX +XXX,XX @@ static void smc91c111_writeb(void *opaque, hwaddr offset, | 29 | s->sssr = 0; |
26 | } | 30 | diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c |
27 | break; | 31 | index XXXXXXX..XXXXXXX 100644 |
28 | } | 32 | --- a/hw/arm/spitz.c |
29 | - hw_error("smc91c111_write: Bad reg %d:%x\n", s->bank, (int)offset); | 33 | +++ b/hw/arm/spitz.c |
30 | + qemu_log_mask(LOG_GUEST_ERROR, "smc91c111_write(bank:%d) Illegal register" | 34 | @@ -XXX,XX +XXX,XX @@ struct SpitzLCDTG { |
31 | + " 0x%" HWADDR_PRIx " = 0x%x\n", | 35 | static void spitz_bl_update(SpitzLCDTG *s) |
32 | + s->bank, offset, value); | 36 | { |
37 | if (s->bl_power && s->bl_intensity) | ||
38 | - zaurus_printf("LCD Backlight now at %i/63\n", s->bl_intensity); | ||
39 | + zaurus_printf("LCD Backlight now at %u/63\n", s->bl_intensity); | ||
40 | else | ||
41 | zaurus_printf("LCD Backlight now off\n"); | ||
33 | } | 42 | } |
34 | 43 | diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c | |
35 | static uint32_t smc91c111_readb(void *opaque, hwaddr offset) | 44 | index XXXXXXX..XXXXXXX 100644 |
36 | @@ -XXX,XX +XXX,XX @@ static uint32_t smc91c111_readb(void *opaque, hwaddr offset) | 45 | --- a/hw/arm/tosa.c |
37 | } | 46 | +++ b/hw/arm/tosa.c |
38 | break; | 47 | @@ -XXX,XX +XXX,XX @@ static void tosa_gpio_setup(PXA2xxState *cpu, |
39 | } | 48 | |
40 | - hw_error("smc91c111_read: Bad reg %d:%x\n", s->bank, (int)offset); | 49 | static uint32_t tosa_ssp_tansfer(SSISlave *dev, uint32_t value) |
41 | + qemu_log_mask(LOG_GUEST_ERROR, "smc91c111_read(bank:%d) Illegal register" | 50 | { |
42 | + " 0x%" HWADDR_PRIx "\n", | 51 | - fprintf(stderr, "TG: %d %02x\n", value >> 5, value & 0x1f); |
43 | + s->bank, offset); | 52 | + fprintf(stderr, "TG: %u %02x\n", value >> 5, value & 0x1f); |
44 | return 0; | 53 | return 0; |
45 | } | 54 | } |
46 | 55 | ||
47 | -- | 56 | -- |
48 | 2.17.1 | 57 | 2.20.1 |
49 | 58 | ||
50 | 59 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Chen Qun <kuhn.chenqun@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | We emulate a TLB cache of size SMMU_IOTLB_MAX_SIZE=256. | 3 | When 'j = icu->nr_sense – 1', the 'j < icu->nr_sense' condition is true, |
4 | It is implemented as a hash table whose key is a combination | 4 | then 'j = icu->nr_sense', the'icu->init_sense[j]' has out-of-bounds access. |
5 | of the 16b asid and 48b IOVA (Jenkins hash). | ||
6 | 5 | ||
7 | Entries are invalidated on TLB invalidation commands, either | 6 | The asan showed stack: |
8 | globally, or per asid, or per asid/iova. | 7 | ERROR: AddressSanitizer: heap-buffer-overflow on address 0x604000004d7d at pc 0x55852cd26a76 bp 0x7ffe39f26200 sp 0x7ffe39f261f0 |
8 | READ of size 1 at 0x604000004d7d thread T0 | ||
9 | #0 0x55852cd26a75 in rxicu_realize ../hw/intc/rx_icu.c:311 | ||
10 | #1 0x55852cf075f7 in device_set_realized ../hw/core/qdev.c:886 | ||
11 | #2 0x55852cd4a32f in property_set_bool ../qom/object.c:2251 | ||
12 | #3 0x55852cd4f9bb in object_property_set ../qom/object.c:1398 | ||
13 | #4 0x55852cd54f3f in object_property_set_qobject ../qom/qom-qobject.c:28 | ||
14 | #5 0x55852cd4fc3f in object_property_set_bool ../qom/object.c:1465 | ||
15 | #6 0x55852cbf0b27 in register_icu ../hw/rx/rx62n.c:156 | ||
16 | #7 0x55852cbf12a6 in rx62n_realize ../hw/rx/rx62n.c:261 | ||
17 | #8 0x55852cf075f7 in device_set_realized ../hw/core/qdev.c:886 | ||
18 | #9 0x55852cd4a32f in property_set_bool ../qom/object.c:2251 | ||
19 | #10 0x55852cd4f9bb in object_property_set ../qom/object.c:1398 | ||
20 | #11 0x55852cd54f3f in object_property_set_qobject ../qom/qom-qobject.c:28 | ||
21 | #12 0x55852cd4fc3f in object_property_set_bool ../qom/object.c:1465 | ||
22 | #13 0x55852cbf1a85 in rx_gdbsim_init ../hw/rx/rx-gdbsim.c:109 | ||
23 | #14 0x55852cd22de0 in qemu_init ../softmmu/vl.c:4380 | ||
24 | #15 0x55852ca57088 in main ../softmmu/main.c:49 | ||
25 | #16 0x7feefafa5d42 in __libc_start_main (/lib64/libc.so.6+0x26d42) | ||
9 | 26 | ||
10 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 27 | Add the 'ice->src[i].sense' initialize to the default value, and then |
11 | Message-id: 1529653501-15358-4-git-send-email-eric.auger@redhat.com | 28 | process init_sense array to identify which irqs should be level-triggered. |
29 | |||
30 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
31 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
32 | Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 33 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
34 | Message-id: 20201111141733.2358800-1-kuhn.chenqun@huawei.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 36 | --- |
15 | include/hw/arm/smmu-common.h | 13 +++++ | 37 | hw/intc/rx_icu.c | 18 ++++++++---------- |
16 | hw/arm/smmu-common.c | 60 ++++++++++++++++++++++ | 38 | 1 file changed, 8 insertions(+), 10 deletions(-) |
17 | hw/arm/smmuv3.c | 98 ++++++++++++++++++++++++++++++++++-- | ||
18 | hw/arm/trace-events | 9 ++++ | ||
19 | 4 files changed, 176 insertions(+), 4 deletions(-) | ||
20 | 39 | ||
21 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | 40 | diff --git a/hw/intc/rx_icu.c b/hw/intc/rx_icu.c |
22 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/arm/smmu-common.h | 42 | --- a/hw/intc/rx_icu.c |
24 | +++ b/include/hw/arm/smmu-common.h | 43 | +++ b/hw/intc/rx_icu.c |
25 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUTransCfg { | 44 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps icu_ops = { |
26 | uint8_t tbi; /* Top Byte Ignore */ | 45 | static void rxicu_realize(DeviceState *dev, Error **errp) |
27 | uint16_t asid; | ||
28 | SMMUTransTableInfo tt[2]; | ||
29 | + uint32_t iotlb_hits; /* counts IOTLB hits for this asid */ | ||
30 | + uint32_t iotlb_misses; /* counts IOTLB misses for this asid */ | ||
31 | } SMMUTransCfg; | ||
32 | |||
33 | typedef struct SMMUDevice { | ||
34 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUPciBus { | ||
35 | SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */ | ||
36 | } SMMUPciBus; | ||
37 | |||
38 | +typedef struct SMMUIOTLBKey { | ||
39 | + uint64_t iova; | ||
40 | + uint16_t asid; | ||
41 | +} SMMUIOTLBKey; | ||
42 | + | ||
43 | typedef struct SMMUState { | ||
44 | /* <private> */ | ||
45 | SysBusDevice dev; | ||
46 | @@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova); | ||
47 | /* Return the iommu mr associated to @sid, or NULL if none */ | ||
48 | IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid); | ||
49 | |||
50 | +#define SMMU_IOTLB_MAX_SIZE 256 | ||
51 | + | ||
52 | +void smmu_iotlb_inv_all(SMMUState *s); | ||
53 | +void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid); | ||
54 | +void smmu_iotlb_inv_iova(SMMUState *s, uint16_t asid, dma_addr_t iova); | ||
55 | + | ||
56 | #endif /* HW_ARM_SMMU_COMMON */ | ||
57 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/arm/smmu-common.c | ||
60 | +++ b/hw/arm/smmu-common.c | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | #include "qom/cpu.h" | ||
63 | #include "hw/qdev-properties.h" | ||
64 | #include "qapi/error.h" | ||
65 | +#include "qemu/jhash.h" | ||
66 | |||
67 | #include "qemu/error-report.h" | ||
68 | #include "hw/arm/smmu-common.h" | ||
69 | #include "smmu-internal.h" | ||
70 | |||
71 | +/* IOTLB Management */ | ||
72 | + | ||
73 | +inline void smmu_iotlb_inv_all(SMMUState *s) | ||
74 | +{ | ||
75 | + trace_smmu_iotlb_inv_all(); | ||
76 | + g_hash_table_remove_all(s->iotlb); | ||
77 | +} | ||
78 | + | ||
79 | +static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value, | ||
80 | + gpointer user_data) | ||
81 | +{ | ||
82 | + uint16_t asid = *(uint16_t *)user_data; | ||
83 | + SMMUIOTLBKey *iotlb_key = (SMMUIOTLBKey *)key; | ||
84 | + | ||
85 | + return iotlb_key->asid == asid; | ||
86 | +} | ||
87 | + | ||
88 | +inline void smmu_iotlb_inv_iova(SMMUState *s, uint16_t asid, dma_addr_t iova) | ||
89 | +{ | ||
90 | + SMMUIOTLBKey key = {.asid = asid, .iova = iova}; | ||
91 | + | ||
92 | + trace_smmu_iotlb_inv_iova(asid, iova); | ||
93 | + g_hash_table_remove(s->iotlb, &key); | ||
94 | +} | ||
95 | + | ||
96 | +inline void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) | ||
97 | +{ | ||
98 | + trace_smmu_iotlb_inv_asid(asid); | ||
99 | + g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid, &asid); | ||
100 | +} | ||
101 | + | ||
102 | /* VMSAv8-64 Translation */ | ||
103 | |||
104 | /** | ||
105 | @@ -XXX,XX +XXX,XX @@ IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid) | ||
106 | return NULL; | ||
107 | } | ||
108 | |||
109 | +static guint smmu_iotlb_key_hash(gconstpointer v) | ||
110 | +{ | ||
111 | + SMMUIOTLBKey *key = (SMMUIOTLBKey *)v; | ||
112 | + uint32_t a, b, c; | ||
113 | + | ||
114 | + /* Jenkins hash */ | ||
115 | + a = b = c = JHASH_INITVAL + sizeof(*key); | ||
116 | + a += key->asid; | ||
117 | + b += extract64(key->iova, 0, 32); | ||
118 | + c += extract64(key->iova, 32, 32); | ||
119 | + | ||
120 | + __jhash_mix(a, b, c); | ||
121 | + __jhash_final(a, b, c); | ||
122 | + | ||
123 | + return c; | ||
124 | +} | ||
125 | + | ||
126 | +static gboolean smmu_iotlb_key_equal(gconstpointer v1, gconstpointer v2) | ||
127 | +{ | ||
128 | + const SMMUIOTLBKey *k1 = v1; | ||
129 | + const SMMUIOTLBKey *k2 = v2; | ||
130 | + | ||
131 | + return (k1->asid == k2->asid) && (k1->iova == k2->iova); | ||
132 | +} | ||
133 | + | ||
134 | static void smmu_base_realize(DeviceState *dev, Error **errp) | ||
135 | { | 46 | { |
136 | SMMUState *s = ARM_SMMU(dev); | 47 | RXICUState *icu = RX_ICU(dev); |
137 | @@ -XXX,XX +XXX,XX @@ static void smmu_base_realize(DeviceState *dev, Error **errp) | 48 | - int i, j; |
49 | + int i; | ||
50 | |||
51 | if (icu->init_sense == NULL) { | ||
52 | qemu_log_mask(LOG_GUEST_ERROR, | ||
53 | "rx_icu: trigger-level property must be set."); | ||
138 | return; | 54 | return; |
139 | } | 55 | } |
140 | s->configs = g_hash_table_new_full(NULL, NULL, NULL, g_free); | 56 | - for (i = j = 0; i < NR_IRQS; i++) { |
141 | + s->iotlb = g_hash_table_new_full(smmu_iotlb_key_hash, smmu_iotlb_key_equal, | 57 | - if (icu->init_sense[j] == i) { |
142 | + g_free, g_free); | 58 | - icu->src[i].sense = TRG_LEVEL; |
143 | s->smmu_pcibus_by_busptr = g_hash_table_new(NULL, NULL); | 59 | - if (j < icu->nr_sense) { |
144 | 60 | - j++; | |
145 | if (s->primary_bus) { | 61 | - } |
146 | @@ -XXX,XX +XXX,XX @@ static void smmu_base_reset(DeviceState *dev) | 62 | - } else { |
147 | SMMUState *s = ARM_SMMU(dev); | 63 | - icu->src[i].sense = TRG_PEDGE; |
148 | 64 | - } | |
149 | g_hash_table_remove_all(s->configs); | 65 | + |
150 | + g_hash_table_remove_all(s->iotlb); | 66 | + for (i = 0; i < NR_IRQS; i++) { |
67 | + icu->src[i].sense = TRG_PEDGE; | ||
68 | + } | ||
69 | + for (i = 0; i < icu->nr_sense; i++) { | ||
70 | + uint8_t irqno = icu->init_sense[i]; | ||
71 | + icu->src[irqno].sense = TRG_LEVEL; | ||
72 | } | ||
73 | icu->req_irq = -1; | ||
151 | } | 74 | } |
152 | |||
153 | static Property smmu_dev_properties[] = { | ||
154 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
155 | index XXXXXXX..XXXXXXX 100644 | ||
156 | --- a/hw/arm/smmuv3.c | ||
157 | +++ b/hw/arm/smmuv3.c | ||
158 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
159 | SMMUEventInfo event = {.type = SMMU_EVT_NONE, .sid = sid}; | ||
160 | SMMUPTWEventInfo ptw_info = {}; | ||
161 | SMMUTranslationStatus status; | ||
162 | + SMMUState *bs = ARM_SMMU(s); | ||
163 | + uint64_t page_mask, aligned_addr; | ||
164 | + IOMMUTLBEntry *cached_entry = NULL; | ||
165 | + SMMUTransTableInfo *tt; | ||
166 | SMMUTransCfg *cfg = NULL; | ||
167 | IOMMUTLBEntry entry = { | ||
168 | .target_as = &address_space_memory, | ||
169 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
170 | .addr_mask = ~(hwaddr)0, | ||
171 | .perm = IOMMU_NONE, | ||
172 | }; | ||
173 | + SMMUIOTLBKey key, *new_key; | ||
174 | |||
175 | qemu_mutex_lock(&s->mutex); | ||
176 | |||
177 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
178 | goto epilogue; | ||
179 | } | ||
180 | |||
181 | - if (smmu_ptw(cfg, addr, flag, &entry, &ptw_info)) { | ||
182 | + tt = select_tt(cfg, addr); | ||
183 | + if (!tt) { | ||
184 | + if (event.record_trans_faults) { | ||
185 | + event.type = SMMU_EVT_F_TRANSLATION; | ||
186 | + event.u.f_translation.addr = addr; | ||
187 | + event.u.f_translation.rnw = flag & 0x1; | ||
188 | + } | ||
189 | + status = SMMU_TRANS_ERROR; | ||
190 | + goto epilogue; | ||
191 | + } | ||
192 | + | ||
193 | + page_mask = (1ULL << (tt->granule_sz)) - 1; | ||
194 | + aligned_addr = addr & ~page_mask; | ||
195 | + | ||
196 | + key.asid = cfg->asid; | ||
197 | + key.iova = aligned_addr; | ||
198 | + | ||
199 | + cached_entry = g_hash_table_lookup(bs->iotlb, &key); | ||
200 | + if (cached_entry) { | ||
201 | + cfg->iotlb_hits++; | ||
202 | + trace_smmu_iotlb_cache_hit(cfg->asid, aligned_addr, | ||
203 | + cfg->iotlb_hits, cfg->iotlb_misses, | ||
204 | + 100 * cfg->iotlb_hits / | ||
205 | + (cfg->iotlb_hits + cfg->iotlb_misses)); | ||
206 | + if ((flag & IOMMU_WO) && !(cached_entry->perm & IOMMU_WO)) { | ||
207 | + status = SMMU_TRANS_ERROR; | ||
208 | + if (event.record_trans_faults) { | ||
209 | + event.type = SMMU_EVT_F_PERMISSION; | ||
210 | + event.u.f_permission.addr = addr; | ||
211 | + event.u.f_permission.rnw = flag & 0x1; | ||
212 | + } | ||
213 | + } else { | ||
214 | + status = SMMU_TRANS_SUCCESS; | ||
215 | + } | ||
216 | + goto epilogue; | ||
217 | + } | ||
218 | + | ||
219 | + cfg->iotlb_misses++; | ||
220 | + trace_smmu_iotlb_cache_miss(cfg->asid, addr & ~page_mask, | ||
221 | + cfg->iotlb_hits, cfg->iotlb_misses, | ||
222 | + 100 * cfg->iotlb_hits / | ||
223 | + (cfg->iotlb_hits + cfg->iotlb_misses)); | ||
224 | + | ||
225 | + if (g_hash_table_size(bs->iotlb) >= SMMU_IOTLB_MAX_SIZE) { | ||
226 | + smmu_iotlb_inv_all(bs); | ||
227 | + } | ||
228 | + | ||
229 | + cached_entry = g_new0(IOMMUTLBEntry, 1); | ||
230 | + | ||
231 | + if (smmu_ptw(cfg, aligned_addr, flag, cached_entry, &ptw_info)) { | ||
232 | + g_free(cached_entry); | ||
233 | switch (ptw_info.type) { | ||
234 | case SMMU_PTW_ERR_WALK_EABT: | ||
235 | event.type = SMMU_EVT_F_WALK_EABT; | ||
236 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
237 | } | ||
238 | status = SMMU_TRANS_ERROR; | ||
239 | } else { | ||
240 | + new_key = g_new0(SMMUIOTLBKey, 1); | ||
241 | + new_key->asid = cfg->asid; | ||
242 | + new_key->iova = aligned_addr; | ||
243 | + g_hash_table_insert(bs->iotlb, new_key, cached_entry); | ||
244 | status = SMMU_TRANS_SUCCESS; | ||
245 | } | ||
246 | |||
247 | @@ -XXX,XX +XXX,XX @@ epilogue: | ||
248 | switch (status) { | ||
249 | case SMMU_TRANS_SUCCESS: | ||
250 | entry.perm = flag; | ||
251 | + entry.translated_addr = cached_entry->translated_addr + | ||
252 | + (addr & page_mask); | ||
253 | + entry.addr_mask = cached_entry->addr_mask; | ||
254 | trace_smmuv3_translate_success(mr->parent_obj.name, sid, addr, | ||
255 | entry.translated_addr, entry.perm); | ||
256 | break; | ||
257 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
258 | smmuv3_flush_config(sdev); | ||
259 | break; | ||
260 | } | ||
261 | - case SMMU_CMD_TLBI_NH_ALL: | ||
262 | case SMMU_CMD_TLBI_NH_ASID: | ||
263 | - case SMMU_CMD_TLBI_NH_VA: | ||
264 | + { | ||
265 | + uint16_t asid = CMD_ASID(&cmd); | ||
266 | + | ||
267 | + trace_smmuv3_cmdq_tlbi_nh_asid(asid); | ||
268 | + smmu_iotlb_inv_asid(bs, asid); | ||
269 | + break; | ||
270 | + } | ||
271 | + case SMMU_CMD_TLBI_NH_ALL: | ||
272 | + case SMMU_CMD_TLBI_NSNH_ALL: | ||
273 | + trace_smmuv3_cmdq_tlbi_nh(); | ||
274 | + smmu_iotlb_inv_all(bs); | ||
275 | + break; | ||
276 | case SMMU_CMD_TLBI_NH_VAA: | ||
277 | + { | ||
278 | + dma_addr_t addr = CMD_ADDR(&cmd); | ||
279 | + uint16_t vmid = CMD_VMID(&cmd); | ||
280 | + | ||
281 | + trace_smmuv3_cmdq_tlbi_nh_vaa(vmid, addr); | ||
282 | + smmu_iotlb_inv_all(bs); | ||
283 | + break; | ||
284 | + } | ||
285 | + case SMMU_CMD_TLBI_NH_VA: | ||
286 | + { | ||
287 | + uint16_t asid = CMD_ASID(&cmd); | ||
288 | + uint16_t vmid = CMD_VMID(&cmd); | ||
289 | + dma_addr_t addr = CMD_ADDR(&cmd); | ||
290 | + bool leaf = CMD_LEAF(&cmd); | ||
291 | + | ||
292 | + trace_smmuv3_cmdq_tlbi_nh_va(vmid, asid, addr, leaf); | ||
293 | + smmu_iotlb_inv_iova(bs, asid, addr); | ||
294 | + break; | ||
295 | + } | ||
296 | case SMMU_CMD_TLBI_EL3_ALL: | ||
297 | case SMMU_CMD_TLBI_EL3_VA: | ||
298 | case SMMU_CMD_TLBI_EL2_ALL: | ||
299 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
300 | case SMMU_CMD_TLBI_EL2_VAA: | ||
301 | case SMMU_CMD_TLBI_S12_VMALL: | ||
302 | case SMMU_CMD_TLBI_S2_IPA: | ||
303 | - case SMMU_CMD_TLBI_NSNH_ALL: | ||
304 | case SMMU_CMD_ATC_INV: | ||
305 | case SMMU_CMD_PRI_RESP: | ||
306 | case SMMU_CMD_RESUME: | ||
307 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
308 | index XXXXXXX..XXXXXXX 100644 | ||
309 | --- a/hw/arm/trace-events | ||
310 | +++ b/hw/arm/trace-events | ||
311 | @@ -XXX,XX +XXX,XX @@ smmu_ptw_invalid_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, | ||
312 | smmu_ptw_page_pte(int stage, int level, uint64_t iova, uint64_t baseaddr, uint64_t pteaddr, uint64_t pte, uint64_t address) "stage=%d level=%d iova=0x%"PRIx64" base@=0x%"PRIx64" pte@=0x%"PRIx64" pte=0x%"PRIx64" page address = 0x%"PRIx64 | ||
313 | smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, uint64_t pte, uint64_t iova, uint64_t gpa, int bsize_mb) "stage=%d level=%d base@=0x%"PRIx64" pte@=0x%"PRIx64" pte=0x%"PRIx64" iova=0x%"PRIx64" block address = 0x%"PRIx64" block size = %d MiB" | ||
314 | smmu_get_pte(uint64_t baseaddr, int index, uint64_t pteaddr, uint64_t pte) "baseaddr=0x%"PRIx64" index=0x%x, pteaddr=0x%"PRIx64", pte=0x%"PRIx64 | ||
315 | +smmu_iotlb_cache_hit(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" | ||
316 | +smmu_iotlb_cache_miss(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache MISS asid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" | ||
317 | +smmu_iotlb_inv_all(void) "IOTLB invalidate all" | ||
318 | +smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d" | ||
319 | +smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64 | ||
320 | |||
321 | #hw/arm/smmuv3.c | ||
322 | smmuv3_read_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)" | ||
323 | @@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%d - end=0x%d" | ||
324 | smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d" | ||
325 | smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)" | ||
326 | smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)" | ||
327 | +smmuv3_cmdq_tlbi_nh_va(int vmid, int asid, uint64_t addr, bool leaf) "vmid =%d asid =%d addr=0x%"PRIx64" leaf=%d" | ||
328 | +smmuv3_cmdq_tlbi_nh_vaa(int vmid, uint64_t addr) "vmid =%d addr=0x%"PRIx64 | ||
329 | +smmuv3_cmdq_tlbi_nh(void) "" | ||
330 | +smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" | ||
331 | smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d" | ||
332 | -- | 75 | -- |
333 | 2.17.1 | 76 | 2.20.1 |
334 | 77 | ||
335 | 78 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Suggested-by: Thomas Huth <thuth@redhat.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | Message-id: 20180624040609.17572-17-f4bug@amsat.org | 4 | Message-id: 20201120154545.2504625-2-f4bug@amsat.org |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 7 | --- |
9 | hw/arm/stellaris.c | 6 ++++-- | 8 | MAINTAINERS | 1 + |
10 | 1 file changed, 4 insertions(+), 2 deletions(-) | 9 | 1 file changed, 1 insertion(+) |
11 | 10 | ||
12 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 11 | diff --git a/MAINTAINERS b/MAINTAINERS |
13 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/stellaris.c | 13 | --- a/MAINTAINERS |
15 | +++ b/hw/arm/stellaris.c | 14 | +++ b/MAINTAINERS |
16 | @@ -XXX,XX +XXX,XX @@ static uint64_t gptm_read(void *opaque, hwaddr offset, | 15 | @@ -XXX,XX +XXX,XX @@ F: disas/arm.c |
17 | return 0; | 16 | F: disas/arm-a64.cc |
18 | default: | 17 | F: disas/libvixl/ |
19 | qemu_log_mask(LOG_GUEST_ERROR, | 18 | F: docs/system/target-arm.rst |
20 | - "GPTM: read at bad offset 0x%x\n", (int)offset); | 19 | +F: docs/system/arm/cpu-features.rst |
21 | + "GPTM: read at bad offset 0x02%" HWADDR_PRIx "\n", | 20 | |
22 | + offset); | 21 | ARM SMMU |
23 | return 0; | 22 | M: Eric Auger <eric.auger@redhat.com> |
24 | } | ||
25 | } | ||
26 | @@ -XXX,XX +XXX,XX @@ static void gptm_write(void *opaque, hwaddr offset, | ||
27 | break; | ||
28 | default: | ||
29 | qemu_log_mask(LOG_GUEST_ERROR, | ||
30 | - "GPTM: write at bad offset 0x%x\n", (int)offset); | ||
31 | + "GPTM: write at bad offset 0x02%" HWADDR_PRIx "\n", | ||
32 | + offset); | ||
33 | } | ||
34 | gptm_update_irq(s); | ||
35 | } | ||
36 | -- | 23 | -- |
37 | 2.17.1 | 24 | 2.20.1 |
38 | 25 | ||
39 | 26 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
5 | Message-id: 20180624040609.17572-10-f4bug@amsat.org | 5 | Message-id: 20201120154545.2504625-3-f4bug@amsat.org |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 8 | --- |
8 | include/hw/arm/omap.h | 12 ++++++------ | 9 | MAINTAINERS | 1 + |
9 | 1 file changed, 6 insertions(+), 6 deletions(-) | 10 | 1 file changed, 1 insertion(+) |
10 | 11 | ||
11 | diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h | 12 | diff --git a/MAINTAINERS b/MAINTAINERS |
12 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/hw/arm/omap.h | 14 | --- a/MAINTAINERS |
14 | +++ b/include/hw/arm/omap.h | 15 | +++ b/MAINTAINERS |
15 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ F: include/hw/*/*aspeed* |
16 | # define hw_omap_h "omap.h" | 17 | F: include/hw/misc/pca9552*.h |
17 | #include "hw/irq.h" | 18 | F: hw/net/ftgmac100.c |
18 | #include "target/arm/cpu-qom.h" | 19 | F: include/hw/net/ftgmac100.h |
19 | +#include "qemu/log.h" | 20 | +F: docs/system/arm/aspeed.rst |
20 | 21 | ||
21 | # define OMAP_EMIFS_BASE 0x00000000 | 22 | NRF51 |
22 | # define OMAP2_Q0_BASE 0x00000000 | 23 | M: Joel Stanley <joel@jms.id.au> |
23 | @@ -XXX,XX +XXX,XX @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem, | ||
24 | unsigned long sdram_size, | ||
25 | const char *core); | ||
26 | |||
27 | -#define OMAP_FMT_plx "%#08" HWADDR_PRIx | ||
28 | - | ||
29 | uint32_t omap_badwidth_read8(void *opaque, hwaddr addr); | ||
30 | void omap_badwidth_write8(void *opaque, hwaddr addr, | ||
31 | uint32_t value); | ||
32 | @@ -XXX,XX +XXX,XX @@ void omap_badwidth_write32(void *opaque, hwaddr addr, | ||
33 | void omap_mpu_wakeup(void *opaque, int irq, int req); | ||
34 | |||
35 | # define OMAP_BAD_REG(paddr) \ | ||
36 | - fprintf(stderr, "%s: Bad register " OMAP_FMT_plx "\n", \ | ||
37 | - __func__, paddr) | ||
38 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad register %#08"HWADDR_PRIx"\n", \ | ||
39 | + __func__, paddr) | ||
40 | # define OMAP_RO_REG(paddr) \ | ||
41 | - fprintf(stderr, "%s: Read-only register " OMAP_FMT_plx "\n", \ | ||
42 | - __func__, paddr) | ||
43 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Read-only register %#08" \ | ||
44 | + HWADDR_PRIx "\n", \ | ||
45 | + __func__, paddr) | ||
46 | |||
47 | /* OMAP-specific Linux bootloader tags for the ATAG_BOARD area | ||
48 | (Board-specifc tags are not here) */ | ||
49 | -- | 24 | -- |
50 | 2.17.1 | 25 | 2.20.1 |
51 | 26 | ||
52 | 27 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 4 | Message-id: 20201120154545.2504625-4-f4bug@amsat.org |
5 | Message-id: 20180624040609.17572-11-f4bug@amsat.org | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 7 | --- |
8 | hw/arm/stellaris.c | 2 +- | 8 | MAINTAINERS | 1 + |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 9 | 1 file changed, 1 insertion(+) |
10 | 10 | ||
11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 11 | diff --git a/MAINTAINERS b/MAINTAINERS |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/stellaris.c | 13 | --- a/MAINTAINERS |
14 | +++ b/hw/arm/stellaris.c | 14 | +++ b/MAINTAINERS |
15 | @@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset, | 15 | @@ -XXX,XX +XXX,XX @@ F: include/hw/*/npcm7xx* |
16 | case 0x040: /* SRCR0 */ | 16 | F: tests/qtest/npcm7xx* |
17 | case 0x044: /* SRCR1 */ | 17 | F: pc-bios/npcm7xx_bootrom.bin |
18 | case 0x048: /* SRCR2 */ | 18 | F: roms/vbootrom |
19 | - fprintf(stderr, "Peripheral reset not implemented\n"); | 19 | +F: docs/system/arm/nuvoton.rst |
20 | + qemu_log_mask(LOG_UNIMP, "Peripheral reset not implemented\n"); | 20 | |
21 | break; | 21 | nSeries |
22 | case 0x054: /* IMC */ | 22 | M: Andrzej Zaborowski <balrogg@gmail.com> |
23 | s->int_mask = value & 0x7f; | ||
24 | -- | 23 | -- |
25 | 2.17.1 | 24 | 2.20.1 |
26 | 25 | ||
27 | 26 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Missed in df3692e04b2. | 3 | Fixes: 0553ef42571 ("docs: add Orange Pi PC document") |
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Message-id: 20180624040609.17572-16-f4bug@amsat.org | 5 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> |
6 | Message-id: 20201120154545.2504625-5-f4bug@amsat.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | hw/arm/stellaris.c | 2 +- | 10 | MAINTAINERS | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 12 | ||
13 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 13 | diff --git a/MAINTAINERS b/MAINTAINERS |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/stellaris.c | 15 | --- a/MAINTAINERS |
16 | +++ b/hw/arm/stellaris.c | 16 | +++ b/MAINTAINERS |
17 | @@ -XXX,XX +XXX,XX @@ static void gptm_write(void *opaque, hwaddr offset, | 17 | @@ -XXX,XX +XXX,XX @@ S: Maintained |
18 | break; | 18 | F: hw/*/allwinner-h3* |
19 | default: | 19 | F: include/hw/*/allwinner-h3* |
20 | qemu_log_mask(LOG_GUEST_ERROR, | 20 | F: hw/arm/orangepi.c |
21 | - "GPTM: read at bad offset 0x%x\n", (int)offset); | 21 | -F: docs/system/orangepi.rst |
22 | + "GPTM: write at bad offset 0x%x\n", (int)offset); | 22 | +F: docs/system/arm/orangepi.rst |
23 | } | 23 | |
24 | gptm_update_irq(s); | 24 | ARM PrimeCell and CMSDK devices |
25 | } | 25 | M: Peter Maydell <peter.maydell@linaro.org> |
26 | -- | 26 | -- |
27 | 2.17.1 | 27 | 2.20.1 |
28 | 28 | ||
29 | 29 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 4 | Message-id: 20201120154545.2504625-6-f4bug@amsat.org |
5 | Message-id: 20180624040609.17572-8-f4bug@amsat.org | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 7 | --- |
8 | hw/i2c/omap_i2c.c | 20 ++++++++++++-------- | 8 | MAINTAINERS | 1 + |
9 | 1 file changed, 12 insertions(+), 8 deletions(-) | 9 | 1 file changed, 1 insertion(+) |
10 | 10 | ||
11 | diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c | 11 | diff --git a/MAINTAINERS b/MAINTAINERS |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/i2c/omap_i2c.c | 13 | --- a/MAINTAINERS |
14 | +++ b/hw/i2c/omap_i2c.c | 14 | +++ b/MAINTAINERS |
15 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ R: Leif Lindholm <leif@nuviainc.com> |
16 | * with this program; if not, see <http://www.gnu.org/licenses/>. | 16 | L: qemu-arm@nongnu.org |
17 | */ | 17 | S: Maintained |
18 | #include "qemu/osdep.h" | 18 | F: hw/arm/sbsa-ref.c |
19 | +#include "qemu/log.h" | 19 | +F: docs/system/arm/sbsa.rst |
20 | #include "hw/hw.h" | 20 | |
21 | #include "hw/i2c/i2c.h" | 21 | Sharp SL-5500 (Collie) PDA |
22 | #include "hw/arm/omap.h" | 22 | M: Peter Maydell <peter.maydell@linaro.org> |
23 | @@ -XXX,XX +XXX,XX @@ static void omap_i2c_write(void *opaque, hwaddr addr, | ||
24 | } | ||
25 | break; | ||
26 | } | ||
27 | - if ((value & (1 << 15)) && !(value & (1 << 10))) { /* MST */ | ||
28 | - fprintf(stderr, "%s: I^2C slave mode not supported\n", | ||
29 | - __func__); | ||
30 | + if ((value & (1 << 15)) && !(value & (1 << 10))) { /* MST */ | ||
31 | + qemu_log_mask(LOG_UNIMP, "%s: I^2C slave mode not supported\n", | ||
32 | + __func__); | ||
33 | break; | ||
34 | } | ||
35 | - if ((value & (1 << 15)) && value & (1 << 8)) { /* XA */ | ||
36 | - fprintf(stderr, "%s: 10-bit addressing mode not supported\n", | ||
37 | - __func__); | ||
38 | + if ((value & (1 << 15)) && value & (1 << 8)) { /* XA */ | ||
39 | + qemu_log_mask(LOG_UNIMP, | ||
40 | + "%s: 10-bit addressing mode not supported\n", | ||
41 | + __func__); | ||
42 | break; | ||
43 | } | ||
44 | if ((value & (1 << 15)) && value & (1 << 0)) { /* STT */ | ||
45 | @@ -XXX,XX +XXX,XX @@ static void omap_i2c_write(void *opaque, hwaddr addr, | ||
46 | s->stat |= 0x3f; | ||
47 | omap_i2c_interrupts_update(s); | ||
48 | } | ||
49 | - if (value & (1 << 15)) /* ST_EN */ | ||
50 | - fprintf(stderr, "%s: System Test not supported\n", __func__); | ||
51 | + if (value & (1 << 15)) { /* ST_EN */ | ||
52 | + qemu_log_mask(LOG_UNIMP, | ||
53 | + "%s: System Test not supported\n", __func__); | ||
54 | + } | ||
55 | break; | ||
56 | |||
57 | default: | ||
58 | -- | 23 | -- |
59 | 2.17.1 | 24 | 2.20.1 |
60 | 25 | ||
61 | 26 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | This adds Cedric as the maintainer, with Andrew and I as reviewers, for | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | the ASPEED boards and the peripherals we have developed. | 4 | Message-id: 20201120154545.2504625-7-f4bug@amsat.org |
5 | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
8 | Acked-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
10 | Message-id: 20180625140055.32223-1-joel@jms.id.au | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | MAINTAINERS | 11 +++++++++++ | 8 | MAINTAINERS | 1 + |
14 | 1 file changed, 11 insertions(+) | 9 | 1 file changed, 1 insertion(+) |
15 | 10 | ||
16 | diff --git a/MAINTAINERS b/MAINTAINERS | 11 | diff --git a/MAINTAINERS b/MAINTAINERS |
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/MAINTAINERS | 13 | --- a/MAINTAINERS |
19 | +++ b/MAINTAINERS | 14 | +++ b/MAINTAINERS |
20 | @@ -XXX,XX +XXX,XX @@ M: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 15 | @@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org |
21 | S: Maintained | 16 | S: Maintained |
22 | F: hw/arm/msf2-som.c | 17 | F: hw/*/omap* |
23 | 18 | F: include/hw/arm/omap.h | |
24 | +ASPEED BMCs | 19 | +F: docs/system/arm/sx1.rst |
25 | +M: Cédric Le Goater <clg@kaod.org> | 20 | |
26 | +R: Andrew Jeffery <andrew@aj.id.au> | 21 | IPack |
27 | +R: Joel Stanley <joel@jms.id.au> | 22 | M: Alberto Garcia <berto@igalia.com> |
28 | +L: qemu-arm@nongnu.org | ||
29 | +S: Maintained | ||
30 | +F: hw/*/*aspeed* | ||
31 | +F: include/hw/*/*aspeed* | ||
32 | +F: hw/net/ftgmac100.c | ||
33 | +F: include/hw/net/ftgmac100.h | ||
34 | + | ||
35 | CRIS Machines | ||
36 | ------------- | ||
37 | Axis Dev88 | ||
38 | -- | 23 | -- |
39 | 2.17.1 | 24 | 2.20.1 |
40 | 25 | ||
41 | 26 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | TCMI_VERBOSE is no more used, drop the OMAP_8/16/32B_REG macros. | 3 | Since commit aa35ec2213b ("hw/arm/raspi: Use more specific |
4 | machine names") the raspi2/raspi3 machines have been renamed | ||
5 | as raspi2b/raspi3b. | ||
4 | 6 | ||
5 | Suggested-by: Thomas Huth <thuth@redhat.com> | 7 | Note, rather than the raspi3b, the raspi3ap introduced in |
8 | commit 5be94252d34 ("hw/arm/raspi: Add the Raspberry Pi 3 | ||
9 | model A+") is a closer match to what QEMU models, but only | ||
10 | provides 512 MB of RAM. | ||
11 | |||
12 | As more Raspberry Pi 2/3 models are emulated, in order | ||
13 | to avoid confusion, deprecate the raspi2/raspi3 machine | ||
14 | aliases. | ||
15 | |||
16 | ACKed-by: Peter Krempa <pkrempa@redhat.com> | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 18 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 19 | Message-id: 20201120173953.2539469-2-f4bug@amsat.org |
8 | Message-id: 20180624040609.17572-9-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 21 | --- |
11 | include/hw/arm/omap.h | 18 ------------------ | 22 | docs/system/deprecated.rst | 7 +++++++ |
12 | hw/arm/omap1.c | 18 ++++++++++++------ | 23 | 1 file changed, 7 insertions(+) |
13 | 2 files changed, 12 insertions(+), 24 deletions(-) | ||
14 | 24 | ||
15 | diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h | 25 | diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/omap.h | 27 | --- a/docs/system/deprecated.rst |
18 | +++ b/include/hw/arm/omap.h | 28 | +++ b/docs/system/deprecated.rst |
19 | @@ -XXX,XX +XXX,XX @@ enum { | 29 | @@ -XXX,XX +XXX,XX @@ This machine has been renamed ``fuloong2e``. |
20 | #define OMAP_GPIOSW_INVERTED 0x0001 | 30 | These machine types are very old and likely can not be used for live migration |
21 | #define OMAP_GPIOSW_OUTPUT 0x0002 | 31 | from old QEMU versions anymore. A newer machine type should be used instead. |
22 | 32 | ||
23 | -# define TCMI_VERBOSE 1 | 33 | +Raspberry Pi ``raspi2`` and ``raspi3`` machines (since 5.2) |
24 | - | 34 | +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
25 | -# ifdef TCMI_VERBOSE | ||
26 | -# define OMAP_8B_REG(paddr) \ | ||
27 | - fprintf(stderr, "%s: 8-bit register " OMAP_FMT_plx "\n", \ | ||
28 | - __func__, paddr) | ||
29 | -# define OMAP_16B_REG(paddr) \ | ||
30 | - fprintf(stderr, "%s: 16-bit register " OMAP_FMT_plx "\n", \ | ||
31 | - __func__, paddr) | ||
32 | -# define OMAP_32B_REG(paddr) \ | ||
33 | - fprintf(stderr, "%s: 32-bit register " OMAP_FMT_plx "\n", \ | ||
34 | - __func__, paddr) | ||
35 | -# else | ||
36 | -# define OMAP_8B_REG(paddr) | ||
37 | -# define OMAP_16B_REG(paddr) | ||
38 | -# define OMAP_32B_REG(paddr) | ||
39 | -# endif | ||
40 | - | ||
41 | # define OMAP_MPUI_REG_MASK 0x000007ff | ||
42 | |||
43 | #endif /* hw_omap_h */ | ||
44 | diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/omap1.c | ||
47 | +++ b/hw/arm/omap1.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | #include "qemu/cutils.h" | ||
50 | #include "qemu/bcd.h" | ||
51 | |||
52 | +static inline void omap_log_badwidth(const char *funcname, hwaddr addr, int sz) | ||
53 | +{ | ||
54 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: %d-bit register %#08" HWADDR_PRIx "\n", | ||
55 | + funcname, 8 * sz, addr); | ||
56 | +} | ||
57 | + | 35 | + |
58 | /* Should signal the TCMI/GPMC */ | 36 | +The Raspberry Pi machines come in various models (A, A+, B, B+). To be able |
59 | uint32_t omap_badwidth_read8(void *opaque, hwaddr addr) | 37 | +to distinguish which model QEMU is implementing, the ``raspi2`` and ``raspi3`` |
60 | { | 38 | +machines have been renamed ``raspi2b`` and ``raspi3b``. |
61 | uint8_t ret; | 39 | + |
62 | 40 | Device options | |
63 | - OMAP_8B_REG(addr); | 41 | -------------- |
64 | + omap_log_badwidth(__func__, addr, 1); | ||
65 | cpu_physical_memory_read(addr, &ret, 1); | ||
66 | return ret; | ||
67 | } | ||
68 | @@ -XXX,XX +XXX,XX @@ void omap_badwidth_write8(void *opaque, hwaddr addr, | ||
69 | { | ||
70 | uint8_t val8 = value; | ||
71 | |||
72 | - OMAP_8B_REG(addr); | ||
73 | + omap_log_badwidth(__func__, addr, 1); | ||
74 | cpu_physical_memory_write(addr, &val8, 1); | ||
75 | } | ||
76 | |||
77 | @@ -XXX,XX +XXX,XX @@ uint32_t omap_badwidth_read16(void *opaque, hwaddr addr) | ||
78 | { | ||
79 | uint16_t ret; | ||
80 | |||
81 | - OMAP_16B_REG(addr); | ||
82 | + omap_log_badwidth(__func__, addr, 2); | ||
83 | cpu_physical_memory_read(addr, &ret, 2); | ||
84 | return ret; | ||
85 | } | ||
86 | @@ -XXX,XX +XXX,XX @@ void omap_badwidth_write16(void *opaque, hwaddr addr, | ||
87 | { | ||
88 | uint16_t val16 = value; | ||
89 | |||
90 | - OMAP_16B_REG(addr); | ||
91 | + omap_log_badwidth(__func__, addr, 2); | ||
92 | cpu_physical_memory_write(addr, &val16, 2); | ||
93 | } | ||
94 | |||
95 | @@ -XXX,XX +XXX,XX @@ uint32_t omap_badwidth_read32(void *opaque, hwaddr addr) | ||
96 | { | ||
97 | uint32_t ret; | ||
98 | |||
99 | - OMAP_32B_REG(addr); | ||
100 | + omap_log_badwidth(__func__, addr, 4); | ||
101 | cpu_physical_memory_read(addr, &ret, 4); | ||
102 | return ret; | ||
103 | } | ||
104 | @@ -XXX,XX +XXX,XX @@ uint32_t omap_badwidth_read32(void *opaque, hwaddr addr) | ||
105 | void omap_badwidth_write32(void *opaque, hwaddr addr, | ||
106 | uint32_t value) | ||
107 | { | ||
108 | - OMAP_32B_REG(addr); | ||
109 | + omap_log_badwidth(__func__, addr, 4); | ||
110 | cpu_physical_memory_write(addr, &value, 4); | ||
111 | } | ||
112 | 42 | ||
113 | -- | 43 | -- |
114 | 2.17.1 | 44 | 2.20.1 |
115 | 45 | ||
116 | 46 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | These COMs are hard to find, and the companie dropped the support | 3 | Document the following Raspberry Pi models: |
4 | few years ago. | ||
5 | 4 | ||
6 | Per the "Gumstix Product Changes, Known Issues, and EOL" pdf: | 5 | - raspi0 Raspberry Pi Zero (revision 1.2) |
6 | - raspi1ap Raspberry Pi A+ (revision 1.1) | ||
7 | - raspi2b Raspberry Pi 2B (revision 1.1) | ||
8 | - raspi3ap Raspberry Pi 3A+ (revision 1.0) | ||
9 | - raspi3b Raspberry Pi 3B (revision 1.2) | ||
7 | 10 | ||
8 | - Phasing out: PXA270-based Verdex product line | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | September 2012 | ||
10 | |||
11 | - Phasing out: PXA255-based Basix & Connex | ||
12 | September 2009 | ||
13 | |||
14 | However there are still booting SD card image availables, very | ||
15 | convenient to stress test the QEMU SD card implementation. | ||
16 | Therefore I volunteer to keep an eye on this file, while it | ||
17 | is useful for testing. | ||
18 | |||
19 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
20 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 13 | Message-id: 20201120173953.2539469-3-f4bug@amsat.org |
21 | Message-id: 20180606144706.29732-1-f4bug@amsat.org | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | --- | 15 | --- |
24 | MAINTAINERS | 3 ++- | 16 | docs/system/arm/raspi.rst | 43 ++++++++++++++++++++++++++++++++++++++ |
25 | 1 file changed, 2 insertions(+), 1 deletion(-) | 17 | docs/system/target-arm.rst | 1 + |
18 | MAINTAINERS | 1 + | ||
19 | 3 files changed, 45 insertions(+) | ||
20 | create mode 100644 docs/system/arm/raspi.rst | ||
26 | 21 | ||
22 | diff --git a/docs/system/arm/raspi.rst b/docs/system/arm/raspi.rst | ||
23 | new file mode 100644 | ||
24 | index XXXXXXX..XXXXXXX | ||
25 | --- /dev/null | ||
26 | +++ b/docs/system/arm/raspi.rst | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | +Raspberry Pi boards (``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b``) | ||
29 | +====================================================================================== | ||
30 | + | ||
31 | + | ||
32 | +QEMU provides models of the following Raspberry Pi boards: | ||
33 | + | ||
34 | +``raspi0`` and ``raspi1ap`` | ||
35 | + ARM1176JZF-S core, 512 MiB of RAM | ||
36 | +``raspi2b`` | ||
37 | + Cortex-A7 (4 cores), 1 GiB of RAM | ||
38 | +``raspi3ap`` | ||
39 | + Cortex-A53 (4 cores), 512 MiB of RAM | ||
40 | +``raspi3b`` | ||
41 | + Cortex-A53 (4 cores), 1 GiB of RAM | ||
42 | + | ||
43 | + | ||
44 | +Implemented devices | ||
45 | +------------------- | ||
46 | + | ||
47 | + * ARM1176JZF-S, Cortex-A7 or Cortex-A53 CPU | ||
48 | + * Interrupt controller | ||
49 | + * DMA controller | ||
50 | + * Clock and reset controller (CPRMAN) | ||
51 | + * System Timer | ||
52 | + * GPIO controller | ||
53 | + * Serial ports (BCM2835 AUX - 16550 based - and PL011) | ||
54 | + * Random Number Generator (RNG) | ||
55 | + * Frame Buffer | ||
56 | + * USB host (USBH) | ||
57 | + * GPIO controller | ||
58 | + * SD/MMC host controller | ||
59 | + * SoC thermal sensor | ||
60 | + * USB2 host controller (DWC2 and MPHI) | ||
61 | + * MailBox controller (MBOX) | ||
62 | + * VideoCore firmware (property) | ||
63 | + | ||
64 | + | ||
65 | +Missing devices | ||
66 | +--------------- | ||
67 | + | ||
68 | + * Peripheral SPI controller (SPI) | ||
69 | + * Analog to Digital Converter (ADC) | ||
70 | + * Pulse Width Modulation (PWM) | ||
71 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/docs/system/target-arm.rst | ||
74 | +++ b/docs/system/target-arm.rst | ||
75 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | ||
76 | arm/nuvoton | ||
77 | arm/orangepi | ||
78 | arm/palm | ||
79 | + arm/raspi | ||
80 | arm/xscale | ||
81 | arm/collie | ||
82 | arm/sx1 | ||
27 | diff --git a/MAINTAINERS b/MAINTAINERS | 83 | diff --git a/MAINTAINERS b/MAINTAINERS |
28 | index XXXXXXX..XXXXXXX 100644 | 84 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/MAINTAINERS | 85 | --- a/MAINTAINERS |
30 | +++ b/MAINTAINERS | 86 | +++ b/MAINTAINERS |
31 | @@ -XXX,XX +XXX,XX @@ F: include/hw/arm/digic.h | 87 | @@ -XXX,XX +XXX,XX @@ F: hw/arm/raspi_platform.h |
32 | F: hw/*/digic* | 88 | F: hw/*/bcm283* |
33 | 89 | F: include/hw/arm/raspi* | |
34 | Gumstix | 90 | F: include/hw/*/bcm283* |
35 | +M: Philippe Mathieu-Daudé <f4bug@amsat.org> | 91 | +F: docs/system/arm/raspi.rst |
36 | L: qemu-devel@nongnu.org | 92 | |
37 | L: qemu-arm@nongnu.org | 93 | Real View |
38 | -S: Orphan | 94 | M: Peter Maydell <peter.maydell@linaro.org> |
39 | +S: Odd Fixes | ||
40 | F: hw/arm/gumstix.c | ||
41 | |||
42 | i.MX31 | ||
43 | -- | 95 | -- |
44 | 2.17.1 | 96 | 2.20.1 |
45 | 97 | ||
46 | 98 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sai Pavan Boddu <saipava@xilinx.com> | ||
2 | 1 | ||
3 | Qspi dma has a burst length of 64 bytes, So limit the transactions w.r.t | ||
4 | dma-burst-size property. | ||
5 | |||
6 | Signed-off-by: Sai Pavan Boddu <saipava@xilinx.com> | ||
7 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
8 | Message-id: 1529660880-30376-1-git-send-email-sai.pavan.boddu@xilinx.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/ssi/xilinx_spips.h | 5 ++++- | ||
12 | hw/ssi/xilinx_spips.c | 23 ++++++++++++++++++++--- | ||
13 | 2 files changed, 24 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/ssi/xilinx_spips.h b/include/hw/ssi/xilinx_spips.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/ssi/xilinx_spips.h | ||
18 | +++ b/include/hw/ssi/xilinx_spips.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct XilinxSPIPS XilinxSPIPS; | ||
20 | /* Bite off 4k chunks at a time */ | ||
21 | #define LQSPI_CACHE_SIZE 1024 | ||
22 | |||
23 | +#define QSPI_DMA_MAX_BURST_SIZE 2048 | ||
24 | + | ||
25 | typedef enum { | ||
26 | READ = 0x3, READ_4 = 0x13, | ||
27 | FAST_READ = 0xb, FAST_READ_4 = 0x0c, | ||
28 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
29 | XilinxQSPIPS parent_obj; | ||
30 | |||
31 | StreamSlave *dma; | ||
32 | - uint8_t dma_buf[4]; | ||
33 | int gqspi_irqline; | ||
34 | |||
35 | uint32_t regs[XLNX_ZYNQMP_SPIPS_R_MAX]; | ||
36 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
37 | uint8_t rx_fifo_g_align; | ||
38 | uint8_t tx_fifo_g_align; | ||
39 | bool man_start_com_g; | ||
40 | + uint32_t dma_burst_size; | ||
41 | + uint8_t dma_buf[QSPI_DMA_MAX_BURST_SIZE]; | ||
42 | } XlnxZynqMPQSPIPS; | ||
43 | |||
44 | typedef struct XilinxSPIPSClass { | ||
45 | diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/ssi/xilinx_spips.c | ||
48 | +++ b/hw/ssi/xilinx_spips.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_notify(void *opaque) | ||
50 | { | ||
51 | size_t ret; | ||
52 | uint32_t num; | ||
53 | - const void *rxd = pop_buf(recv_fifo, 4, &num); | ||
54 | + const void *rxd; | ||
55 | + int len; | ||
56 | + | ||
57 | + len = recv_fifo->num >= rq->dma_burst_size ? rq->dma_burst_size : | ||
58 | + recv_fifo->num; | ||
59 | + rxd = pop_buf(recv_fifo, len, &num); | ||
60 | |||
61 | memcpy(rq->dma_buf, rxd, num); | ||
62 | |||
63 | - ret = stream_push(rq->dma, rq->dma_buf, 4); | ||
64 | - assert(ret == 4); | ||
65 | + ret = stream_push(rq->dma, rq->dma_buf, num); | ||
66 | + assert(ret == num); | ||
67 | xlnx_zynqmp_qspips_check_flush(rq); | ||
68 | } | ||
69 | } | ||
70 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_realize(DeviceState *dev, Error **errp) | ||
71 | XlnxZynqMPQSPIPS *s = XLNX_ZYNQMP_QSPIPS(dev); | ||
72 | XilinxSPIPSClass *xsc = XILINX_SPIPS_GET_CLASS(s); | ||
73 | |||
74 | + if (s->dma_burst_size > QSPI_DMA_MAX_BURST_SIZE) { | ||
75 | + error_setg(errp, | ||
76 | + "qspi dma burst size %u exceeds maximum limit %d", | ||
77 | + s->dma_burst_size, QSPI_DMA_MAX_BURST_SIZE); | ||
78 | + return; | ||
79 | + } | ||
80 | xilinx_qspips_realize(dev, errp); | ||
81 | fifo8_create(&s->rx_fifo_g, xsc->rx_fifo_size); | ||
82 | fifo8_create(&s->tx_fifo_g, xsc->tx_fifo_size); | ||
83 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_xlnx_zynqmp_qspips = { | ||
84 | } | ||
85 | }; | ||
86 | |||
87 | +static Property xilinx_zynqmp_qspips_properties[] = { | ||
88 | + DEFINE_PROP_UINT32("dma-burst-size", XlnxZynqMPQSPIPS, dma_burst_size, 64), | ||
89 | + DEFINE_PROP_END_OF_LIST(), | ||
90 | +}; | ||
91 | + | ||
92 | static Property xilinx_qspips_properties[] = { | ||
93 | /* We had to turn this off for 2.10 as it is not compatible with migration. | ||
94 | * It can be enabled but will prevent the device to be migrated. | ||
95 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_class_init(ObjectClass *klass, void * data) | ||
96 | dc->realize = xlnx_zynqmp_qspips_realize; | ||
97 | dc->reset = xlnx_zynqmp_qspips_reset; | ||
98 | dc->vmsd = &vmstate_xlnx_zynqmp_qspips; | ||
99 | + dc->props = xilinx_zynqmp_qspips_properties; | ||
100 | xsc->reg_ops = &xlnx_zynqmp_qspips_ops; | ||
101 | xsc->rx_fifo_size = RXFF_A_Q; | ||
102 | xsc->tx_fifo_size = TXFF_A_Q; | ||
103 | -- | ||
104 | 2.17.1 | ||
105 | |||
106 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | Message-id: 20180624040609.17572-2-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/input/pckbd.c | 4 +++- | ||
9 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/input/pckbd.c | ||
14 | +++ b/hw/input/pckbd.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | * THE SOFTWARE. | ||
17 | */ | ||
18 | #include "qemu/osdep.h" | ||
19 | +#include "qemu/log.h" | ||
20 | #include "hw/hw.h" | ||
21 | #include "hw/isa/isa.h" | ||
22 | #include "hw/i386/pc.h" | ||
23 | @@ -XXX,XX +XXX,XX @@ static void kbd_write_command(void *opaque, hwaddr addr, | ||
24 | /* ignore that */ | ||
25 | break; | ||
26 | default: | ||
27 | - fprintf(stderr, "qemu: unsupported keyboard cmd=0x%02x\n", (int)val); | ||
28 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
29 | + "unsupported keyboard cmd=0x%02" PRIx64 "\n", val); | ||
30 | break; | ||
31 | } | ||
32 | } | ||
33 | -- | ||
34 | 2.17.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | Message-id: 20180624040609.17572-3-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/input/tsc2005.c | 13 ++++++++----- | ||
9 | 1 file changed, 8 insertions(+), 5 deletions(-) | ||
10 | |||
11 | diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/input/tsc2005.c | ||
14 | +++ b/hw/input/tsc2005.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | */ | ||
17 | |||
18 | #include "qemu/osdep.h" | ||
19 | +#include "qemu/log.h" | ||
20 | #include "hw/hw.h" | ||
21 | #include "qemu/timer.h" | ||
22 | #include "ui/console.h" | ||
23 | @@ -XXX,XX +XXX,XX @@ static void tsc2005_write(TSC2005State *s, int reg, uint16_t data) | ||
24 | } | ||
25 | s->nextprecision = (data >> 13) & 1; | ||
26 | s->timing[0] = data & 0x1fff; | ||
27 | - if ((s->timing[0] >> 11) == 3) | ||
28 | - fprintf(stderr, "%s: illegal conversion clock setting\n", | ||
29 | - __func__); | ||
30 | + if ((s->timing[0] >> 11) == 3) { | ||
31 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
32 | + "tsc2005_write: illegal conversion clock setting\n"); | ||
33 | + } | ||
34 | break; | ||
35 | case 0xd: /* CFR1 */ | ||
36 | s->timing[1] = data & 0xf07; | ||
37 | @@ -XXX,XX +XXX,XX @@ static void tsc2005_write(TSC2005State *s, int reg, uint16_t data) | ||
38 | break; | ||
39 | |||
40 | default: | ||
41 | - fprintf(stderr, "%s: write into read-only register %x\n", | ||
42 | - __func__, reg); | ||
43 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
44 | + "%s: write into read-only register 0x%x\n", | ||
45 | + __func__, reg); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | -- | ||
50 | 2.17.1 | ||
51 | |||
52 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | Message-id: 20180624040609.17572-4-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/dma/omap_dma.c | 6 ++++-- | ||
9 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/hw/dma/omap_dma.c b/hw/dma/omap_dma.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/dma/omap_dma.c | ||
14 | +++ b/hw/dma/omap_dma.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | #include "qemu/osdep.h" | ||
19 | +#include "qemu/log.h" | ||
20 | #include "qemu-common.h" | ||
21 | #include "qemu/timer.h" | ||
22 | #include "hw/arm/omap.h" | ||
23 | @@ -XXX,XX +XXX,XX @@ static int omap_dma_sys_read(struct omap_dma_s *s, int offset, | ||
24 | case 0x480: /* DMA_PCh0_SR */ | ||
25 | case 0x482: /* DMA_PCh1_SR */ | ||
26 | case 0x4c0: /* DMA_PChD_SR_0 */ | ||
27 | - printf("%s: Physical Channel Status Registers not implemented.\n", | ||
28 | - __func__); | ||
29 | + qemu_log_mask(LOG_UNIMP, | ||
30 | + "%s: Physical Channel Status Registers not implemented\n", | ||
31 | + __func__); | ||
32 | *ret = 0xff; | ||
33 | break; | ||
34 | |||
35 | -- | ||
36 | 2.17.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | Message-id: 20180624040609.17572-5-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/dma/omap_dma.c | 64 +++++++++++++++++++++++++++++------------------ | ||
9 | 1 file changed, 40 insertions(+), 24 deletions(-) | ||
10 | |||
11 | diff --git a/hw/dma/omap_dma.c b/hw/dma/omap_dma.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/dma/omap_dma.c | ||
14 | +++ b/hw/dma/omap_dma.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static int omap_dma_ch_reg_write(struct omap_dma_s *s, | ||
16 | ch->burst[0] = (value & 0x0180) >> 7; | ||
17 | ch->pack[0] = (value & 0x0040) >> 6; | ||
18 | ch->port[0] = (enum omap_dma_port) ((value & 0x003c) >> 2); | ||
19 | - if (ch->port[0] >= __omap_dma_port_last) | ||
20 | - printf("%s: invalid DMA port %i\n", __func__, | ||
21 | - ch->port[0]); | ||
22 | - if (ch->port[1] >= __omap_dma_port_last) | ||
23 | - printf("%s: invalid DMA port %i\n", __func__, | ||
24 | - ch->port[1]); | ||
25 | + if (ch->port[0] >= __omap_dma_port_last) { | ||
26 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid DMA port %i\n", | ||
27 | + __func__, ch->port[0]); | ||
28 | + } | ||
29 | + if (ch->port[1] >= __omap_dma_port_last) { | ||
30 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid DMA port %i\n", | ||
31 | + __func__, ch->port[1]); | ||
32 | + } | ||
33 | ch->data_type = 1 << (value & 3); | ||
34 | if ((value & 3) == 3) { | ||
35 | - printf("%s: bad data_type for DMA channel\n", __func__); | ||
36 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
37 | + "%s: bad data_type for DMA channel\n", __func__); | ||
38 | ch->data_type >>= 1; | ||
39 | } | ||
40 | break; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void omap_dma4_write(void *opaque, hwaddr addr, | ||
42 | if (value & 2) /* SOFTRESET */ | ||
43 | omap_dma_reset(s->dma); | ||
44 | s->ocp = value & 0x3321; | ||
45 | - if (((s->ocp >> 12) & 3) == 3) /* MIDLEMODE */ | ||
46 | - fprintf(stderr, "%s: invalid DMA power mode\n", __func__); | ||
47 | + if (((s->ocp >> 12) & 3) == 3) { /* MIDLEMODE */ | ||
48 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid DMA power mode\n", | ||
49 | + __func__); | ||
50 | + } | ||
51 | return; | ||
52 | |||
53 | case 0x78: /* DMA4_GCR */ | ||
54 | s->gcr = value & 0x00ff00ff; | ||
55 | - if ((value & 0xff) == 0x00) /* MAX_CHANNEL_FIFO_DEPTH */ | ||
56 | - fprintf(stderr, "%s: wrong FIFO depth in GCR\n", __func__); | ||
57 | + if ((value & 0xff) == 0x00) { /* MAX_CHANNEL_FIFO_DEPTH */ | ||
58 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: wrong FIFO depth in GCR\n", | ||
59 | + __func__); | ||
60 | + } | ||
61 | return; | ||
62 | |||
63 | case 0x80 ... 0xfff: | ||
64 | @@ -XXX,XX +XXX,XX @@ static void omap_dma4_write(void *opaque, hwaddr addr, | ||
65 | case 0x00: /* DMA4_CCR */ | ||
66 | ch->buf_disable = (value >> 25) & 1; | ||
67 | ch->src_sync = (value >> 24) & 1; /* XXX For CamDMA must be 1 */ | ||
68 | - if (ch->buf_disable && !ch->src_sync) | ||
69 | - fprintf(stderr, "%s: Buffering disable is not allowed in " | ||
70 | - "destination synchronised mode\n", __func__); | ||
71 | + if (ch->buf_disable && !ch->src_sync) { | ||
72 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
73 | + "%s: Buffering disable is not allowed in " | ||
74 | + "destination synchronised mode\n", __func__); | ||
75 | + } | ||
76 | ch->prefetch = (value >> 23) & 1; | ||
77 | ch->bs = (value >> 18) & 1; | ||
78 | ch->transparent_copy = (value >> 17) & 1; | ||
79 | @@ -XXX,XX +XXX,XX @@ static void omap_dma4_write(void *opaque, hwaddr addr, | ||
80 | ch->suspend = (value & 0x0100) >> 8; | ||
81 | ch->priority = (value & 0x0040) >> 6; | ||
82 | ch->fs = (value & 0x0020) >> 5; | ||
83 | - if (ch->fs && ch->bs && ch->mode[0] && ch->mode[1]) | ||
84 | - fprintf(stderr, "%s: For a packet transfer at least one port " | ||
85 | - "must be constant-addressed\n", __func__); | ||
86 | + if (ch->fs && ch->bs && ch->mode[0] && ch->mode[1]) { | ||
87 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
88 | + "%s: For a packet transfer at least one port " | ||
89 | + "must be constant-addressed\n", __func__); | ||
90 | + } | ||
91 | ch->sync = (value & 0x001f) | ((value >> 14) & 0x0060); | ||
92 | /* XXX must be 0x01 for CamDMA */ | ||
93 | |||
94 | @@ -XXX,XX +XXX,XX @@ static void omap_dma4_write(void *opaque, hwaddr addr, | ||
95 | ch->endian_lock[0] =(value >> 20) & 1; | ||
96 | ch->endian[1] =(value >> 19) & 1; | ||
97 | ch->endian_lock[1] =(value >> 18) & 1; | ||
98 | - if (ch->endian[0] != ch->endian[1]) | ||
99 | - fprintf(stderr, "%s: DMA endianness conversion enable attempt\n", | ||
100 | - __func__); | ||
101 | + if (ch->endian[0] != ch->endian[1]) { | ||
102 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
103 | + "%s: DMA endianness conversion enable attempt\n", | ||
104 | + __func__); | ||
105 | + } | ||
106 | ch->write_mode = (value >> 16) & 3; | ||
107 | ch->burst[1] = (value & 0xc000) >> 14; | ||
108 | ch->pack[1] = (value & 0x2000) >> 13; | ||
109 | @@ -XXX,XX +XXX,XX @@ static void omap_dma4_write(void *opaque, hwaddr addr, | ||
110 | ch->burst[0] = (value & 0x0180) >> 7; | ||
111 | ch->pack[0] = (value & 0x0040) >> 6; | ||
112 | ch->translate[0] = (value & 0x003c) >> 2; | ||
113 | - if (ch->translate[0] | ch->translate[1]) | ||
114 | - fprintf(stderr, "%s: bad MReqAddressTranslate sideband signal\n", | ||
115 | - __func__); | ||
116 | + if (ch->translate[0] | ch->translate[1]) { | ||
117 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
118 | + "%s: bad MReqAddressTranslate sideband signal\n", | ||
119 | + __func__); | ||
120 | + } | ||
121 | ch->data_type = 1 << (value & 3); | ||
122 | if ((value & 3) == 3) { | ||
123 | - printf("%s: bad data_type for DMA channel\n", __func__); | ||
124 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
125 | + "%s: bad data_type for DMA channel\n", __func__); | ||
126 | ch->data_type >>= 1; | ||
127 | } | ||
128 | break; | ||
129 | -- | ||
130 | 2.17.1 | ||
131 | |||
132 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Suggested-by: Thomas Huth <thuth@redhat.com> | 3 | Document the 3 front LEDs modeled on the OpenPOWER Witherspoon BMC |
4 | (see commit 7cfbde5ea1c "hw/arm/aspeed: Add the 3 front LEDs drived | ||
5 | by the PCA9552 #1"). | ||
6 | |||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | Message-id: 20180624040609.17572-12-f4bug@amsat.org | 9 | Message-id: 20201120173953.2539469-4-f4bug@amsat.org |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | hw/net/stellaris_enet.c | 2 +- | 12 | docs/system/arm/aspeed.rst | 1 + |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | 1 file changed, 1 insertion(+) |
10 | 14 | ||
11 | diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c | 15 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/net/stellaris_enet.c | 17 | --- a/docs/system/arm/aspeed.rst |
14 | +++ b/hw/net/stellaris_enet.c | 18 | +++ b/docs/system/arm/aspeed.rst |
15 | @@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset, | 19 | @@ -XXX,XX +XXX,XX @@ Supported devices |
16 | return s->np; | 20 | * GPIO Controller (Master only) |
17 | case 0x38: /* TR */ | 21 | * UART |
18 | return 0; | 22 | * Ethernet controllers |
19 | - case 0x3c: /* Undocuented: Timestamp? */ | 23 | + * Front LEDs (PCA9552 on I2C bus) |
20 | + case 0x3c: /* Undocumented: Timestamp? */ | 24 | |
21 | return 0; | 25 | |
22 | default: | 26 | Missing devices |
23 | hw_error("stellaris_enet_read: Bad offset %x\n", (int)offset); | ||
24 | -- | 27 | -- |
25 | 2.17.1 | 28 | 2.20.1 |
26 | 29 | ||
27 | 30 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | hw_error() finally calls abort(), but there is no need to abort here. | 3 | List the 'tosa' machine with the XScale-based PDAs models. |
4 | 4 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Message-id: 20180624040609.17572-13-f4bug@amsat.org | 6 | Message-id: 20201120173953.2539469-5-f4bug@amsat.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | hw/net/stellaris_enet.c | 9 +++++++-- | 10 | docs/system/arm/xscale.rst | 20 +++++++++++++------- |
11 | 1 file changed, 7 insertions(+), 2 deletions(-) | 11 | 1 file changed, 13 insertions(+), 7 deletions(-) |
12 | 12 | ||
13 | diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c | 13 | diff --git a/docs/system/arm/xscale.rst b/docs/system/arm/xscale.rst |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/net/stellaris_enet.c | 15 | --- a/docs/system/arm/xscale.rst |
16 | +++ b/hw/net/stellaris_enet.c | 16 | +++ b/docs/system/arm/xscale.rst |
17 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
18 | #include "qemu/osdep.h" | 18 | -Sharp XScale-based PDA models (``akita``, ``borzoi``, ``spitz``, ``terrier``) |
19 | #include "hw/sysbus.h" | 19 | -============================================================================= |
20 | #include "net/net.h" | 20 | +Sharp XScale-based PDA models (``akita``, ``borzoi``, ``spitz``, ``terrier``, ``tosa``) |
21 | +#include "qemu/log.h" | 21 | +======================================================================================= |
22 | #include <zlib.h> | 22 | |
23 | 23 | -The XScale-based clamshell PDA models (\"Spitz\", \"Akita\", \"Borzoi\" | |
24 | //#define DEBUG_STELLARIS_ENET 1 | 24 | -and \"Terrier\") emulation includes the following peripherals: |
25 | @@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset, | 25 | +The Sharp Zaurus are PDAs based on XScale, able to run Linux ('SL series'). |
26 | case 0x3c: /* Undocumented: Timestamp? */ | 26 | |
27 | return 0; | 27 | -- Intel PXA270 System-on-chip (ARMv5TE core) |
28 | default: | 28 | +The SL-6000 (\"Tosa\"), released in 2005, uses a PXA255 System-on-chip. |
29 | - hw_error("stellaris_enet_read: Bad offset %x\n", (int)offset); | 29 | |
30 | + qemu_log_mask(LOG_GUEST_ERROR, "stellaris_enet_rd%d: Illegal register" | 30 | -- NAND Flash memory |
31 | + " 0x02%" HWADDR_PRIx "\n", | 31 | +The SL-C3000 (\"Spitz\"), SL-C1000 (\"Akita\"), SL-C3100 (\"Borzoi\") and |
32 | + size * 8, offset); | 32 | +SL-C3200 (\"Terrier\") use a PXA270. |
33 | return 0; | 33 | + |
34 | } | 34 | +The clamshell PDA models emulation includes the following peripherals: |
35 | } | 35 | + |
36 | @@ -XXX,XX +XXX,XX @@ static void stellaris_enet_write(void *opaque, hwaddr offset, | 36 | +- Intel PXA255/PXA270 System-on-chip (ARMv5TE core) |
37 | /* Ignored. */ | 37 | + |
38 | break; | 38 | +- NAND Flash memory - not in \"Tosa\" |
39 | default: | 39 | |
40 | - hw_error("stellaris_enet_write: Bad offset %x\n", (int)offset); | 40 | - IBM/Hitachi DSCM microdrive in a PXA PCMCIA slot - not in \"Akita\" |
41 | + qemu_log_mask(LOG_GUEST_ERROR, "stellaris_enet_wr%d: Illegal register " | 41 | |
42 | + "0x02%" HWADDR_PRIx " = 0x%" PRIx64 "\n", | 42 | -- On-chip OHCI USB controller |
43 | + size * 8, offset, value); | 43 | +- On-chip OHCI USB controller - not in \"Tosa\" |
44 | } | 44 | |
45 | } | 45 | - On-chip LCD controller |
46 | 46 | ||
47 | -- | 47 | -- |
48 | 2.17.1 | 48 | 2.20.1 |
49 | 49 | ||
50 | 50 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | The semihosting SYS_HEAPINFO call is supposed to return an array |
---|---|---|---|
2 | of four guest addresses: | ||
3 | * base of heap memory | ||
4 | * limit of heap memory | ||
5 | * base of stack memory | ||
6 | * limit of stack memory | ||
2 | 7 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Some semihosting programs (including those compiled to use the |
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 9 | 'newlib' embedded C library) use this call to work out where they |
5 | Message-id: 20180624040609.17572-15-f4bug@amsat.org | 10 | should initialize themselves to. |
11 | |||
12 | QEMU's implementation when in system emulation mode is very | ||
13 | simplistic: we say that the heap starts halfway into RAM and | ||
14 | continues to the end of RAM, and the stack starts at the top of RAM | ||
15 | and works down to the bottom. Unfortunately the code assumes that | ||
16 | the base address of RAM is at address 0, so on boards like 'virt' | ||
17 | where this is not true the addresses returned will all be wrong and | ||
18 | the guest application will usually crash. | ||
19 | |||
20 | Conveniently since all Arm boards call arm_load_kernel() we have the | ||
21 | base address of the main RAM block in the arm_boot_info struct which | ||
22 | is accessible via the CPU object. Use this to return sensible values | ||
23 | from SYS_HEAPINFO. | ||
24 | |||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
26 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
27 | Message-id: 20201119092346.32356-1-peter.maydell@linaro.org | ||
7 | --- | 28 | --- |
8 | hw/net/smc91c111.c | 12 ++++++++---- | 29 | target/arm/arm-semi.c | 12 ++++++++---- |
9 | 1 file changed, 8 insertions(+), 4 deletions(-) | 30 | 1 file changed, 8 insertions(+), 4 deletions(-) |
10 | 31 | ||
11 | diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c | 32 | diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c |
12 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/net/smc91c111.c | 34 | --- a/target/arm/arm-semi.c |
14 | +++ b/hw/net/smc91c111.c | 35 | +++ b/target/arm/arm-semi.c |
15 | @@ -XXX,XX +XXX,XX @@ static void smc91c111_writeb(void *opaque, hwaddr offset, | 36 | @@ -XXX,XX +XXX,XX @@ |
16 | SET_HIGH(gpr, value); | 37 | #else |
17 | return; | 38 | #include "exec/gdbstub.h" |
18 | case 12: /* Control */ | 39 | #include "qemu/cutils.h" |
19 | - if (value & 1) | 40 | +#include "hw/arm/boot.h" |
20 | - fprintf(stderr, "smc91c111:EEPROM store not implemented\n"); | 41 | #endif |
21 | - if (value & 2) | 42 | |
22 | - fprintf(stderr, "smc91c111:EEPROM reload not implemented\n"); | 43 | #define TARGET_SYS_OPEN 0x01 |
23 | + if (value & 1) { | 44 | @@ -XXX,XX +XXX,XX @@ target_ulong do_arm_semihosting(CPUARMState *env) |
24 | + qemu_log_mask(LOG_UNIMP, | 45 | int i; |
25 | + "smc91c111: EEPROM store not implemented\n"); | 46 | #ifdef CONFIG_USER_ONLY |
26 | + } | 47 | TaskState *ts = cs->opaque; |
27 | + if (value & 2) { | 48 | +#else |
28 | + qemu_log_mask(LOG_UNIMP, | 49 | + const struct arm_boot_info *info = env->boot_info; |
29 | + "smc91c111: EEPROM reload not implemented\n"); | 50 | + target_ulong rambase = info->loader_start; |
30 | + } | 51 | #endif |
31 | value &= ~3; | 52 | |
32 | SET_LOW(ctr, value); | 53 | GET_ARG(0); |
33 | return; | 54 | @@ -XXX,XX +XXX,XX @@ target_ulong do_arm_semihosting(CPUARMState *env) |
55 | #else | ||
56 | limit = ram_size; | ||
57 | /* TODO: Make this use the limit of the loaded application. */ | ||
58 | - retvals[0] = limit / 2; | ||
59 | - retvals[1] = limit; | ||
60 | - retvals[2] = limit; /* Stack base */ | ||
61 | - retvals[3] = 0; /* Stack limit. */ | ||
62 | + retvals[0] = rambase + limit / 2; | ||
63 | + retvals[1] = rambase + limit; | ||
64 | + retvals[2] = rambase + limit; /* Stack base */ | ||
65 | + retvals[3] = rambase; /* Stack limit. */ | ||
66 | #endif | ||
67 | |||
68 | for (i = 0; i < ARRAY_SIZE(retvals); i++) { | ||
34 | -- | 69 | -- |
35 | 2.17.1 | 70 | 2.20.1 |
36 | 71 | ||
37 | 72 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The Linux kernel doesn't use the official bkpt insn for breakpoints; |
---|---|---|---|
2 | instead it uses three instructions in the guaranteed-to-UNDEF space, | ||
3 | and generates SIGTRAP for these rather than the SIGILL that most | ||
4 | UNDEF insns generate: | ||
2 | 5 | ||
3 | All Aspeed SoC clocks are driven by an input source clock which can | 6 | https://elixir.bootlin.com/linux/v5.9.8/source/arch/arm/kernel/ptrace.c#L197 |
4 | have different frequencies : 24MHz or 25MHz, and also, on the Aspeed | ||
5 | AST2400 SoC, 48MHz. The H-PLL (CPU) clock is defined from a | ||
6 | calculation using parameters in the H-PLL Parameter register or from a | ||
7 | predefined set of frequencies if the setting is strapped by hardware | ||
8 | (Aspeed AST2400 SoC). The other clocks of the SoC are then defined | ||
9 | from the H-PLL using dividers. | ||
10 | 7 | ||
11 | We introduce first the APB clock because it should be used to drive | 8 | Make QEMU treat these insns specially too. The main benefit of this |
12 | the Aspeed timer model. | 9 | is that if you're running a debugger on a guest program that runs |
10 | into a GCC __builtin_trap() or LLVM "trap because execution should | ||
11 | never reach here" then you'll get the expected signal rather than a | ||
12 | SIGILL. | ||
13 | 13 | ||
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
16 | Message-id: 20180622075700.5923-2-clg@kaod.org | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20201117155634.6924-1-peter.maydell@linaro.org | ||
18 | --- | 17 | --- |
19 | include/hw/misc/aspeed_scu.h | 70 +++++++++++++++++++++-- | 18 | linux-user/arm/cpu_loop.c | 28 ++++++++++++++++++++++++++++ |
20 | hw/misc/aspeed_scu.c | 106 +++++++++++++++++++++++++++++++++++ | 19 | 1 file changed, 28 insertions(+) |
21 | 2 files changed, 172 insertions(+), 4 deletions(-) | ||
22 | 20 | ||
23 | diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h | 21 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c |
24 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/misc/aspeed_scu.h | 23 | --- a/linux-user/arm/cpu_loop.c |
26 | +++ b/include/hw/misc/aspeed_scu.h | 24 | +++ b/linux-user/arm/cpu_loop.c |
27 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSCUState { | 25 | @@ -XXX,XX +XXX,XX @@ do_kernel_trap(CPUARMState *env) |
28 | uint32_t hw_strap1; | 26 | return 0; |
29 | uint32_t hw_strap2; | ||
30 | uint32_t hw_prot_key; | ||
31 | + | ||
32 | + uint32_t clkin; | ||
33 | + uint32_t hpll; | ||
34 | + uint32_t apb_freq; | ||
35 | } AspeedSCUState; | ||
36 | |||
37 | #define AST2400_A0_SILICON_REV 0x02000303U | ||
38 | @@ -XXX,XX +XXX,XX @@ extern bool is_supported_silicon_rev(uint32_t silicon_rev); | ||
39 | * 1. 2012/12/29 Ryan Chen Create | ||
40 | */ | ||
41 | |||
42 | -/* Hardware Strapping Register definition (for Aspeed AST2400 SOC) | ||
43 | +/* SCU08 Clock Selection Register | ||
44 | + * | ||
45 | + * 31 Enable Video Engine clock dynamic slow down | ||
46 | + * 30:28 Video Engine clock slow down setting | ||
47 | + * 27 2D Engine GCLK clock source selection | ||
48 | + * 26 2D Engine GCLK clock throttling enable | ||
49 | + * 25:23 APB PCLK divider selection | ||
50 | + * 22:20 LPC Host LHCLK divider selection | ||
51 | + * 19 LPC Host LHCLK clock generation/output enable control | ||
52 | + * 18:16 MAC AHB bus clock divider selection | ||
53 | + * 15 SD/SDIO clock running enable | ||
54 | + * 14:12 SD/SDIO divider selection | ||
55 | + * 11 Reserved | ||
56 | + * 10:8 Video port output clock delay control bit | ||
57 | + * 7 ARM CPU/AHB clock slow down enable | ||
58 | + * 6:4 ARM CPU/AHB clock slow down setting | ||
59 | + * 3:2 ECLK clock source selection | ||
60 | + * 1 CPU/AHB clock slow down idle timer | ||
61 | + * 0 CPU/AHB clock dynamic slow down enable (defined in bit[6:4]) | ||
62 | + */ | ||
63 | +#define SCU_CLK_GET_PCLK_DIV(x) (((x) >> 23) & 0x7) | ||
64 | + | ||
65 | +/* SCU24 H-PLL Parameter Register (for Aspeed AST2400 SOC) | ||
66 | + * | ||
67 | + * 18 H-PLL parameter selection | ||
68 | + * 0: Select H-PLL by strapping resistors | ||
69 | + * 1: Select H-PLL by the programmed registers (SCU24[17:0]) | ||
70 | + * 17 Enable H-PLL bypass mode | ||
71 | + * 16 Turn off H-PLL | ||
72 | + * 10:5 H-PLL Numerator | ||
73 | + * 4 H-PLL Output Divider | ||
74 | + * 3:0 H-PLL Denumerator | ||
75 | + * | ||
76 | + * (Output frequency) = 24MHz * (2-OD) * [(Numerator+2) / (Denumerator+1)] | ||
77 | + */ | ||
78 | + | ||
79 | +#define SCU_AST2400_H_PLL_PROGRAMMED (0x1 << 18) | ||
80 | +#define SCU_AST2400_H_PLL_BYPASS_EN (0x1 << 17) | ||
81 | +#define SCU_AST2400_H_PLL_OFF (0x1 << 16) | ||
82 | + | ||
83 | +/* SCU24 H-PLL Parameter Register (for Aspeed AST2500 SOC) | ||
84 | + * | ||
85 | + * 21 Enable H-PLL reset | ||
86 | + * 20 Enable H-PLL bypass mode | ||
87 | + * 19 Turn off H-PLL | ||
88 | + * 18:13 H-PLL Post Divider | ||
89 | + * 12:5 H-PLL Numerator (M) | ||
90 | + * 4:0 H-PLL Denumerator (N) | ||
91 | + * | ||
92 | + * (Output frequency) = CLKIN(24MHz) * [(M+1) / (N+1)] / (P+1) | ||
93 | + * | ||
94 | + * The default frequency is 792Mhz when CLKIN = 24MHz | ||
95 | + */ | ||
96 | + | ||
97 | +#define SCU_H_PLL_BYPASS_EN (0x1 << 20) | ||
98 | +#define SCU_H_PLL_OFF (0x1 << 19) | ||
99 | + | ||
100 | +/* SCU70 Hardware Strapping Register definition (for Aspeed AST2400 SOC) | ||
101 | * | ||
102 | * 31:29 Software defined strapping registers | ||
103 | * 28:27 DRAM size setting (for VGA driver use) | ||
104 | @@ -XXX,XX +XXX,XX @@ extern bool is_supported_silicon_rev(uint32_t silicon_rev); | ||
105 | #define SCU_AST2400_HW_STRAP_GET_CLK_SOURCE(x) (((((x) >> 23) & 0x1) << 1) \ | ||
106 | | (((x) >> 18) & 0x1)) | ||
107 | #define SCU_AST2400_HW_STRAP_CLK_SOURCE_MASK ((0x1 << 23) | (0x1 << 18)) | ||
108 | -#define AST2400_CLK_25M_IN (0x1 << 23) | ||
109 | +#define SCU_HW_STRAP_CLK_25M_IN (0x1 << 23) | ||
110 | #define AST2400_CLK_24M_IN 0 | ||
111 | #define AST2400_CLK_48M_IN 1 | ||
112 | #define AST2400_CLK_25M_IN_24M_USB_CKI 2 | ||
113 | #define AST2400_CLK_25M_IN_48M_USB_CKI 3 | ||
114 | |||
115 | +#define SCU_HW_STRAP_CLK_48M_IN (0x1 << 18) | ||
116 | #define SCU_HW_STRAP_2ND_BOOT_WDT (0x1 << 17) | ||
117 | #define SCU_HW_STRAP_SUPER_IO_CONFIG (0x1 << 16) | ||
118 | #define SCU_HW_STRAP_VGA_CLASS_CODE (0x1 << 15) | ||
119 | @@ -XXX,XX +XXX,XX @@ extern bool is_supported_silicon_rev(uint32_t silicon_rev); | ||
120 | #define AST2400_DIS_BOOT 3 | ||
121 | |||
122 | /* | ||
123 | - * Hardware strapping register definition (for Aspeed AST2500 SoC and | ||
124 | - * higher) | ||
125 | + * SCU70 Hardware strapping register definition (for Aspeed AST2500 | ||
126 | + * SoC and higher) | ||
127 | * | ||
128 | * 31 Enable SPI Flash Strap Auto Fetch Mode | ||
129 | * 30 Enable GPIO Strap Mode | ||
130 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | ||
131 | index XXXXXXX..XXXXXXX 100644 | ||
132 | --- a/hw/misc/aspeed_scu.c | ||
133 | +++ b/hw/misc/aspeed_scu.c | ||
134 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_get_random(void) | ||
135 | return num; | ||
136 | } | 27 | } |
137 | 28 | ||
138 | +static void aspeed_scu_set_apb_freq(AspeedSCUState *s) | 29 | +static bool insn_is_linux_bkpt(uint32_t opcode, bool is_thumb) |
139 | +{ | 30 | +{ |
140 | + uint32_t apb_divider; | 31 | + /* |
141 | + | 32 | + * Return true if this insn is one of the three magic UDF insns |
142 | + switch (s->silicon_rev) { | 33 | + * which the kernel treats as breakpoint insns. |
143 | + case AST2400_A0_SILICON_REV: | 34 | + */ |
144 | + case AST2400_A1_SILICON_REV: | 35 | + if (!is_thumb) { |
145 | + apb_divider = 2; | 36 | + return (opcode & 0x0fffffff) == 0x07f001f0; |
146 | + break; | ||
147 | + case AST2500_A0_SILICON_REV: | ||
148 | + case AST2500_A1_SILICON_REV: | ||
149 | + apb_divider = 4; | ||
150 | + break; | ||
151 | + default: | ||
152 | + g_assert_not_reached(); | ||
153 | + } | ||
154 | + | ||
155 | + s->apb_freq = s->hpll / (SCU_CLK_GET_PCLK_DIV(s->regs[CLK_SEL]) + 1) | ||
156 | + / apb_divider; | ||
157 | +} | ||
158 | + | ||
159 | static uint64_t aspeed_scu_read(void *opaque, hwaddr offset, unsigned size) | ||
160 | { | ||
161 | AspeedSCUState *s = ASPEED_SCU(opaque); | ||
162 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
163 | case PROT_KEY: | ||
164 | s->regs[reg] = (data == ASPEED_SCU_PROT_KEY) ? 1 : 0; | ||
165 | return; | ||
166 | + case CLK_SEL: | ||
167 | + s->regs[reg] = data; | ||
168 | + aspeed_scu_set_apb_freq(s); | ||
169 | + break; | ||
170 | |||
171 | case FREQ_CNTR_EVAL: | ||
172 | case VGA_SCRATCH1 ... VGA_SCRATCH8: | ||
173 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_scu_ops = { | ||
174 | .valid.unaligned = false, | ||
175 | }; | ||
176 | |||
177 | +static uint32_t aspeed_scu_get_clkin(AspeedSCUState *s) | ||
178 | +{ | ||
179 | + if (s->hw_strap1 & SCU_HW_STRAP_CLK_25M_IN) { | ||
180 | + return 25000000; | ||
181 | + } else if (s->hw_strap1 & SCU_HW_STRAP_CLK_48M_IN) { | ||
182 | + return 48000000; | ||
183 | + } else { | 37 | + } else { |
184 | + return 24000000; | 38 | + /* |
39 | + * Note that we get the two halves of the 32-bit T32 insn | ||
40 | + * in the opposite order to the value the kernel uses in | ||
41 | + * its undef_hook struct. | ||
42 | + */ | ||
43 | + return ((opcode & 0xffff) == 0xde01) || (opcode == 0xa000f7f0); | ||
185 | + } | 44 | + } |
186 | +} | 45 | +} |
187 | + | 46 | + |
188 | +/* | 47 | void cpu_loop(CPUARMState *env) |
189 | + * Strapped frequencies for the AST2400 in MHz. They depend on the | 48 | { |
190 | + * clkin frequency. | 49 | CPUState *cs = env_cpu(env); |
191 | + */ | 50 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
192 | +static const uint32_t hpll_ast2400_freqs[][4] = { | 51 | /* FIXME - what to do if get_user() fails? */ |
193 | + { 384, 360, 336, 408 }, /* 24MHz or 48MHz */ | 52 | get_user_code_u32(opcode, env->regs[15], env); |
194 | + { 400, 375, 350, 425 }, /* 25MHz */ | 53 | |
195 | +}; | 54 | + /* |
55 | + * The Linux kernel treats some UDF patterns specially | ||
56 | + * to use as breakpoints (instead of the architectural | ||
57 | + * bkpt insn). These should trigger a SIGTRAP rather | ||
58 | + * than SIGILL. | ||
59 | + */ | ||
60 | + if (insn_is_linux_bkpt(opcode, env->thumb)) { | ||
61 | + goto excp_debug; | ||
62 | + } | ||
196 | + | 63 | + |
197 | +static uint32_t aspeed_scu_calc_hpll_ast2400(AspeedSCUState *s) | 64 | rc = EmulateAll(opcode, &ts->fpa, env); |
198 | +{ | 65 | if (rc == 0) { /* illegal instruction */ |
199 | + uint32_t hpll_reg = s->regs[HPLL_PARAM]; | 66 | info.si_signo = TARGET_SIGILL; |
200 | + uint8_t freq_select; | ||
201 | + bool clk_25m_in; | ||
202 | + | ||
203 | + if (hpll_reg & SCU_AST2400_H_PLL_OFF) { | ||
204 | + return 0; | ||
205 | + } | ||
206 | + | ||
207 | + if (hpll_reg & SCU_AST2400_H_PLL_PROGRAMMED) { | ||
208 | + uint32_t multiplier = 1; | ||
209 | + | ||
210 | + if (!(hpll_reg & SCU_AST2400_H_PLL_BYPASS_EN)) { | ||
211 | + uint32_t n = (hpll_reg >> 5) & 0x3f; | ||
212 | + uint32_t od = (hpll_reg >> 4) & 0x1; | ||
213 | + uint32_t d = hpll_reg & 0xf; | ||
214 | + | ||
215 | + multiplier = (2 - od) * ((n + 2) / (d + 1)); | ||
216 | + } | ||
217 | + | ||
218 | + return s->clkin * multiplier; | ||
219 | + } | ||
220 | + | ||
221 | + /* HW strapping */ | ||
222 | + clk_25m_in = !!(s->hw_strap1 & SCU_HW_STRAP_CLK_25M_IN); | ||
223 | + freq_select = SCU_AST2400_HW_STRAP_GET_H_PLL_CLK(s->hw_strap1); | ||
224 | + | ||
225 | + return hpll_ast2400_freqs[clk_25m_in][freq_select] * 1000000; | ||
226 | +} | ||
227 | + | ||
228 | +static uint32_t aspeed_scu_calc_hpll_ast2500(AspeedSCUState *s) | ||
229 | +{ | ||
230 | + uint32_t hpll_reg = s->regs[HPLL_PARAM]; | ||
231 | + uint32_t multiplier = 1; | ||
232 | + | ||
233 | + if (hpll_reg & SCU_H_PLL_OFF) { | ||
234 | + return 0; | ||
235 | + } | ||
236 | + | ||
237 | + if (!(hpll_reg & SCU_H_PLL_BYPASS_EN)) { | ||
238 | + uint32_t p = (hpll_reg >> 13) & 0x3f; | ||
239 | + uint32_t m = (hpll_reg >> 5) & 0xff; | ||
240 | + uint32_t n = hpll_reg & 0x1f; | ||
241 | + | ||
242 | + multiplier = ((m + 1) / (n + 1)) / (p + 1); | ||
243 | + } | ||
244 | + | ||
245 | + return s->clkin * multiplier; | ||
246 | +} | ||
247 | + | ||
248 | static void aspeed_scu_reset(DeviceState *dev) | ||
249 | { | ||
250 | AspeedSCUState *s = ASPEED_SCU(dev); | ||
251 | const uint32_t *reset; | ||
252 | + uint32_t (*calc_hpll)(AspeedSCUState *s); | ||
253 | |||
254 | switch (s->silicon_rev) { | ||
255 | case AST2400_A0_SILICON_REV: | ||
256 | case AST2400_A1_SILICON_REV: | ||
257 | reset = ast2400_a0_resets; | ||
258 | + calc_hpll = aspeed_scu_calc_hpll_ast2400; | ||
259 | break; | ||
260 | case AST2500_A0_SILICON_REV: | ||
261 | case AST2500_A1_SILICON_REV: | ||
262 | reset = ast2500_a1_resets; | ||
263 | + calc_hpll = aspeed_scu_calc_hpll_ast2500; | ||
264 | break; | ||
265 | default: | ||
266 | g_assert_not_reached(); | ||
267 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_reset(DeviceState *dev) | ||
268 | s->regs[HW_STRAP1] = s->hw_strap1; | ||
269 | s->regs[HW_STRAP2] = s->hw_strap2; | ||
270 | s->regs[PROT_KEY] = s->hw_prot_key; | ||
271 | + | ||
272 | + /* | ||
273 | + * All registers are set. Now compute the frequencies of the main clocks | ||
274 | + */ | ||
275 | + s->clkin = aspeed_scu_get_clkin(s); | ||
276 | + s->hpll = calc_hpll(s); | ||
277 | + aspeed_scu_set_apb_freq(s); | ||
278 | } | ||
279 | |||
280 | static uint32_t aspeed_silicon_revs[] = { | ||
281 | -- | 67 | -- |
282 | 2.17.1 | 68 | 2.20.1 |
283 | 69 | ||
284 | 70 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The virtio-net-failover documentation is currently orphan and |
---|---|---|---|
2 | not included in any manual; move it into the system manual, | ||
3 | immediately following the general network emulation section. | ||
2 | 4 | ||
3 | The timer controller can be driven by either an external 1MHz clock or | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | by the APB clock. Today, the model makes the assumption that the APB | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
5 | frequency is always set to 24MHz but this is incorrect. | 7 | --- |
8 | docs/system/index.rst | 1 + | ||
9 | docs/{ => system}/virtio-net-failover.rst | 0 | ||
10 | 2 files changed, 1 insertion(+) | ||
11 | rename docs/{ => system}/virtio-net-failover.rst (100%) | ||
6 | 12 | ||
7 | The AST2400 SoC on the palmetto machines uses a 48MHz input clock | 13 | diff --git a/docs/system/index.rst b/docs/system/index.rst |
8 | source and the APB can be set to 48MHz. The consequence is a general | ||
9 | system slowdown. The QEMU machines using the AST2500 SoC do not seem | ||
10 | impacted today because the APB frequency is still set to 24MHz. | ||
11 | |||
12 | We fix the timer frequency for all SoCs by linking the Timer model to | ||
13 | the SCU model. The APB frequency driving the timers is now the one | ||
14 | configured for the SoC. | ||
15 | |||
16 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
17 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
18 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
19 | Message-id: 20180622075700.5923-4-clg@kaod.org | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | --- | ||
22 | include/hw/timer/aspeed_timer.h | 4 ++++ | ||
23 | hw/arm/aspeed_soc.c | 2 ++ | ||
24 | hw/timer/aspeed_timer.c | 19 +++++++++++++++---- | ||
25 | 3 files changed, 21 insertions(+), 4 deletions(-) | ||
26 | |||
27 | diff --git a/include/hw/timer/aspeed_timer.h b/include/hw/timer/aspeed_timer.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/include/hw/timer/aspeed_timer.h | 15 | --- a/docs/system/index.rst |
30 | +++ b/include/hw/timer/aspeed_timer.h | 16 | +++ b/docs/system/index.rst |
31 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ Contents: |
32 | 18 | monitor | |
33 | #include "qemu/timer.h" | 19 | images |
34 | 20 | net | |
35 | +typedef struct AspeedSCUState AspeedSCUState; | 21 | + virtio-net-failover |
36 | + | 22 | usb |
37 | #define ASPEED_TIMER(obj) \ | 23 | ivshmem |
38 | OBJECT_CHECK(AspeedTimerCtrlState, (obj), TYPE_ASPEED_TIMER); | 24 | linuxboot |
39 | #define TYPE_ASPEED_TIMER "aspeed.timer" | 25 | diff --git a/docs/virtio-net-failover.rst b/docs/system/virtio-net-failover.rst |
40 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedTimerCtrlState { | 26 | similarity index 100% |
41 | uint32_t ctrl; | 27 | rename from docs/virtio-net-failover.rst |
42 | uint32_t ctrl2; | 28 | rename to docs/system/virtio-net-failover.rst |
43 | AspeedTimer timers[ASPEED_TIMER_NR_TIMERS]; | ||
44 | + | ||
45 | + AspeedSCUState *scu; | ||
46 | } AspeedTimerCtrlState; | ||
47 | |||
48 | #endif /* ASPEED_TIMER_H */ | ||
49 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/arm/aspeed_soc.c | ||
52 | +++ b/hw/arm/aspeed_soc.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
54 | |||
55 | object_initialize(&s->timerctrl, sizeof(s->timerctrl), TYPE_ASPEED_TIMER); | ||
56 | object_property_add_child(obj, "timerctrl", OBJECT(&s->timerctrl), NULL); | ||
57 | + object_property_add_const_link(OBJECT(&s->timerctrl), "scu", | ||
58 | + OBJECT(&s->scu), &error_abort); | ||
59 | qdev_set_parent_bus(DEVICE(&s->timerctrl), sysbus_get_default()); | ||
60 | |||
61 | object_initialize(&s->i2c, sizeof(s->i2c), TYPE_ASPEED_I2C); | ||
62 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/timer/aspeed_timer.c | ||
65 | +++ b/hw/timer/aspeed_timer.c | ||
66 | @@ -XXX,XX +XXX,XX @@ | ||
67 | */ | ||
68 | |||
69 | #include "qemu/osdep.h" | ||
70 | +#include "qapi/error.h" | ||
71 | #include "hw/sysbus.h" | ||
72 | #include "hw/timer/aspeed_timer.h" | ||
73 | +#include "hw/misc/aspeed_scu.h" | ||
74 | #include "qemu-common.h" | ||
75 | #include "qemu/bitops.h" | ||
76 | #include "qemu/timer.h" | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | #define TIMER_CLOCK_USE_EXT true | ||
79 | #define TIMER_CLOCK_EXT_HZ 1000000 | ||
80 | #define TIMER_CLOCK_USE_APB false | ||
81 | -#define TIMER_CLOCK_APB_HZ 24000000 | ||
82 | |||
83 | #define TIMER_REG_STATUS 0 | ||
84 | #define TIMER_REG_RELOAD 1 | ||
85 | @@ -XXX,XX +XXX,XX @@ static inline bool timer_external_clock(AspeedTimer *t) | ||
86 | return timer_ctrl_status(t, op_external_clock); | ||
87 | } | ||
88 | |||
89 | -static uint32_t clock_rates[] = { TIMER_CLOCK_APB_HZ, TIMER_CLOCK_EXT_HZ }; | ||
90 | - | ||
91 | static inline uint32_t calculate_rate(struct AspeedTimer *t) | ||
92 | { | ||
93 | - return clock_rates[timer_external_clock(t)]; | ||
94 | + AspeedTimerCtrlState *s = timer_to_ctrl(t); | ||
95 | + | ||
96 | + return timer_external_clock(t) ? TIMER_CLOCK_EXT_HZ : s->scu->apb_freq; | ||
97 | } | ||
98 | |||
99 | static inline uint32_t calculate_ticks(struct AspeedTimer *t, uint64_t now_ns) | ||
100 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_realize(DeviceState *dev, Error **errp) | ||
101 | int i; | ||
102 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
103 | AspeedTimerCtrlState *s = ASPEED_TIMER(dev); | ||
104 | + Object *obj; | ||
105 | + Error *err = NULL; | ||
106 | + | ||
107 | + obj = object_property_get_link(OBJECT(dev), "scu", &err); | ||
108 | + if (!obj) { | ||
109 | + error_propagate(errp, err); | ||
110 | + error_prepend(errp, "required link 'scu' not found: "); | ||
111 | + return; | ||
112 | + } | ||
113 | + s->scu = ASPEED_SCU(obj); | ||
114 | |||
115 | for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { | ||
116 | aspeed_init_one_timer(s, i); | ||
117 | -- | 29 | -- |
118 | 2.17.1 | 30 | 2.20.1 |
119 | 31 | ||
120 | 32 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The cpu-hotplug.rst documentation is currently orphan and not |
---|---|---|---|
2 | included in any manual; move it into the system manual. | ||
2 | 3 | ||
3 | The System Control Unit should be initialized first as it drives all | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | the configuration of the SoC and other device models. | 5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
6 | --- | ||
7 | docs/{ => system}/cpu-hotplug.rst | 0 | ||
8 | docs/system/index.rst | 1 + | ||
9 | 2 files changed, 1 insertion(+) | ||
10 | rename docs/{ => system}/cpu-hotplug.rst (100%) | ||
5 | 11 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 12 | diff --git a/docs/cpu-hotplug.rst b/docs/system/cpu-hotplug.rst |
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 13 | similarity index 100% |
8 | Acked-by: Andrew Jeffery <andrew@aj.id.au> | 14 | rename from docs/cpu-hotplug.rst |
9 | Message-id: 20180622075700.5923-3-clg@kaod.org | 15 | rename to docs/system/cpu-hotplug.rst |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | diff --git a/docs/system/index.rst b/docs/system/index.rst |
11 | --- | ||
12 | hw/arm/aspeed_soc.c | 40 ++++++++++++++++++++-------------------- | ||
13 | 1 file changed, 20 insertions(+), 20 deletions(-) | ||
14 | |||
15 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/aspeed_soc.c | 18 | --- a/docs/system/index.rst |
18 | +++ b/hw/arm/aspeed_soc.c | 19 | +++ b/docs/system/index.rst |
19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | 20 | @@ -XXX,XX +XXX,XX @@ Contents: |
20 | object_initialize(&s->cpu, sizeof(s->cpu), sc->info->cpu_type); | 21 | tls |
21 | object_property_add_child(obj, "cpu", OBJECT(&s->cpu), NULL); | 22 | gdb |
22 | 23 | managed-startup | |
23 | - object_initialize(&s->vic, sizeof(s->vic), TYPE_ASPEED_VIC); | 24 | + cpu-hotplug |
24 | - object_property_add_child(obj, "vic", OBJECT(&s->vic), NULL); | 25 | targets |
25 | - qdev_set_parent_bus(DEVICE(&s->vic), sysbus_get_default()); | 26 | security |
26 | - | 27 | deprecated |
27 | - object_initialize(&s->timerctrl, sizeof(s->timerctrl), TYPE_ASPEED_TIMER); | ||
28 | - object_property_add_child(obj, "timerctrl", OBJECT(&s->timerctrl), NULL); | ||
29 | - qdev_set_parent_bus(DEVICE(&s->timerctrl), sysbus_get_default()); | ||
30 | - | ||
31 | - object_initialize(&s->i2c, sizeof(s->i2c), TYPE_ASPEED_I2C); | ||
32 | - object_property_add_child(obj, "i2c", OBJECT(&s->i2c), NULL); | ||
33 | - qdev_set_parent_bus(DEVICE(&s->i2c), sysbus_get_default()); | ||
34 | - | ||
35 | object_initialize(&s->scu, sizeof(s->scu), TYPE_ASPEED_SCU); | ||
36 | object_property_add_child(obj, "scu", OBJECT(&s->scu), NULL); | ||
37 | qdev_set_parent_bus(DEVICE(&s->scu), sysbus_get_default()); | ||
38 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
39 | object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu), | ||
40 | "hw-prot-key", &error_abort); | ||
41 | |||
42 | + object_initialize(&s->vic, sizeof(s->vic), TYPE_ASPEED_VIC); | ||
43 | + object_property_add_child(obj, "vic", OBJECT(&s->vic), NULL); | ||
44 | + qdev_set_parent_bus(DEVICE(&s->vic), sysbus_get_default()); | ||
45 | + | ||
46 | + object_initialize(&s->timerctrl, sizeof(s->timerctrl), TYPE_ASPEED_TIMER); | ||
47 | + object_property_add_child(obj, "timerctrl", OBJECT(&s->timerctrl), NULL); | ||
48 | + qdev_set_parent_bus(DEVICE(&s->timerctrl), sysbus_get_default()); | ||
49 | + | ||
50 | + object_initialize(&s->i2c, sizeof(s->i2c), TYPE_ASPEED_I2C); | ||
51 | + object_property_add_child(obj, "i2c", OBJECT(&s->i2c), NULL); | ||
52 | + qdev_set_parent_bus(DEVICE(&s->i2c), sysbus_get_default()); | ||
53 | + | ||
54 | object_initialize(&s->fmc, sizeof(s->fmc), sc->info->fmc_typename); | ||
55 | object_property_add_child(obj, "fmc", OBJECT(&s->fmc), NULL); | ||
56 | qdev_set_parent_bus(DEVICE(&s->fmc), sysbus_get_default()); | ||
57 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
58 | memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE, | ||
59 | &s->sram); | ||
60 | |||
61 | + /* SCU */ | ||
62 | + object_property_set_bool(OBJECT(&s->scu), true, "realized", &err); | ||
63 | + if (err) { | ||
64 | + error_propagate(errp, err); | ||
65 | + return; | ||
66 | + } | ||
67 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, ASPEED_SOC_SCU_BASE); | ||
68 | + | ||
69 | /* VIC */ | ||
70 | object_property_set_bool(OBJECT(&s->vic), true, "realized", &err); | ||
71 | if (err) { | ||
72 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
73 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); | ||
74 | } | ||
75 | |||
76 | - /* SCU */ | ||
77 | - object_property_set_bool(OBJECT(&s->scu), true, "realized", &err); | ||
78 | - if (err) { | ||
79 | - error_propagate(errp, err); | ||
80 | - return; | ||
81 | - } | ||
82 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, ASPEED_SOC_SCU_BASE); | ||
83 | - | ||
84 | /* UART - attach an 8250 to the IO space as our UART5 */ | ||
85 | if (serial_hd(0)) { | ||
86 | qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]); | ||
87 | -- | 28 | -- |
88 | 2.17.1 | 29 | 2.20.1 |
89 | 30 | ||
90 | 31 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
---|---|---|---|
2 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
3 | --- | ||
4 | docs/system/index.rst | 1 + | ||
5 | docs/{ => system}/virtio-pmem.rst | 0 | ||
6 | 2 files changed, 1 insertion(+) | ||
7 | rename docs/{ => system}/virtio-pmem.rst (100%) | ||
2 | 8 | ||
3 | On TLB invalidation commands, let's call registered | 9 | diff --git a/docs/system/index.rst b/docs/system/index.rst |
4 | IOMMU notifiers. Those can only be UNMAP notifiers. | ||
5 | SMMUv3 does not support notification on MAP (VFIO). | ||
6 | |||
7 | This patch allows vhost use case where IOTLB API is notified | ||
8 | on each guest IOTLB invalidation. | ||
9 | |||
10 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 1529653501-15358-5-git-send-email-eric.auger@redhat.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | include/hw/arm/smmu-common.h | 6 +++ | ||
16 | hw/arm/smmu-common.c | 34 +++++++++++++ | ||
17 | hw/arm/smmuv3.c | 99 +++++++++++++++++++++++++++++++++++- | ||
18 | hw/arm/trace-events | 5 ++ | ||
19 | 4 files changed, 142 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/arm/smmu-common.h | 11 | --- a/docs/system/index.rst |
24 | +++ b/include/hw/arm/smmu-common.h | 12 | +++ b/docs/system/index.rst |
25 | @@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_all(SMMUState *s); | 13 | @@ -XXX,XX +XXX,XX @@ Contents: |
26 | void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid); | 14 | gdb |
27 | void smmu_iotlb_inv_iova(SMMUState *s, uint16_t asid, dma_addr_t iova); | 15 | managed-startup |
28 | 16 | cpu-hotplug | |
29 | +/* Unmap the range of all the notifiers registered to any IOMMU mr */ | 17 | + virtio-pmem |
30 | +void smmu_inv_notifiers_all(SMMUState *s); | 18 | targets |
31 | + | 19 | security |
32 | +/* Unmap the range of all the notifiers registered to @mr */ | 20 | deprecated |
33 | +void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr); | 21 | diff --git a/docs/virtio-pmem.rst b/docs/system/virtio-pmem.rst |
34 | + | 22 | similarity index 100% |
35 | #endif /* HW_ARM_SMMU_COMMON */ | 23 | rename from docs/virtio-pmem.rst |
36 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | 24 | rename to docs/system/virtio-pmem.rst |
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/hw/arm/smmu-common.c | ||
39 | +++ b/hw/arm/smmu-common.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static gboolean smmu_iotlb_key_equal(gconstpointer v1, gconstpointer v2) | ||
41 | return (k1->asid == k2->asid) && (k1->iova == k2->iova); | ||
42 | } | ||
43 | |||
44 | +/* Unmap the whole notifier's range */ | ||
45 | +static void smmu_unmap_notifier_range(IOMMUNotifier *n) | ||
46 | +{ | ||
47 | + IOMMUTLBEntry entry; | ||
48 | + | ||
49 | + entry.target_as = &address_space_memory; | ||
50 | + entry.iova = n->start; | ||
51 | + entry.perm = IOMMU_NONE; | ||
52 | + entry.addr_mask = n->end - n->start; | ||
53 | + | ||
54 | + memory_region_notify_one(n, &entry); | ||
55 | +} | ||
56 | + | ||
57 | +/* Unmap all notifiers attached to @mr */ | ||
58 | +inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) | ||
59 | +{ | ||
60 | + IOMMUNotifier *n; | ||
61 | + | ||
62 | + trace_smmu_inv_notifiers_mr(mr->parent_obj.name); | ||
63 | + IOMMU_NOTIFIER_FOREACH(n, mr) { | ||
64 | + smmu_unmap_notifier_range(n); | ||
65 | + } | ||
66 | +} | ||
67 | + | ||
68 | +/* Unmap all notifiers of all mr's */ | ||
69 | +void smmu_inv_notifiers_all(SMMUState *s) | ||
70 | +{ | ||
71 | + SMMUNotifierNode *node; | ||
72 | + | ||
73 | + QLIST_FOREACH(node, &s->notifiers_list, next) { | ||
74 | + smmu_inv_notifiers_mr(&node->sdev->iommu); | ||
75 | + } | ||
76 | +} | ||
77 | + | ||
78 | static void smmu_base_realize(DeviceState *dev, Error **errp) | ||
79 | { | ||
80 | SMMUState *s = ARM_SMMU(dev); | ||
81 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/arm/smmuv3.c | ||
84 | +++ b/hw/arm/smmuv3.c | ||
85 | @@ -XXX,XX +XXX,XX @@ epilogue: | ||
86 | return entry; | ||
87 | } | ||
88 | |||
89 | +/** | ||
90 | + * smmuv3_notify_iova - call the notifier @n for a given | ||
91 | + * @asid and @iova tuple. | ||
92 | + * | ||
93 | + * @mr: IOMMU mr region handle | ||
94 | + * @n: notifier to be called | ||
95 | + * @asid: address space ID or negative value if we don't care | ||
96 | + * @iova: iova | ||
97 | + */ | ||
98 | +static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | ||
99 | + IOMMUNotifier *n, | ||
100 | + int asid, | ||
101 | + dma_addr_t iova) | ||
102 | +{ | ||
103 | + SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu); | ||
104 | + SMMUEventInfo event = {}; | ||
105 | + SMMUTransTableInfo *tt; | ||
106 | + SMMUTransCfg *cfg; | ||
107 | + IOMMUTLBEntry entry; | ||
108 | + | ||
109 | + cfg = smmuv3_get_config(sdev, &event); | ||
110 | + if (!cfg) { | ||
111 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
112 | + "%s error decoding the configuration for iommu mr=%s\n", | ||
113 | + __func__, mr->parent_obj.name); | ||
114 | + return; | ||
115 | + } | ||
116 | + | ||
117 | + if (asid >= 0 && cfg->asid != asid) { | ||
118 | + return; | ||
119 | + } | ||
120 | + | ||
121 | + tt = select_tt(cfg, iova); | ||
122 | + if (!tt) { | ||
123 | + return; | ||
124 | + } | ||
125 | + | ||
126 | + entry.target_as = &address_space_memory; | ||
127 | + entry.iova = iova; | ||
128 | + entry.addr_mask = (1 << tt->granule_sz) - 1; | ||
129 | + entry.perm = IOMMU_NONE; | ||
130 | + | ||
131 | + memory_region_notify_one(n, &entry); | ||
132 | +} | ||
133 | + | ||
134 | +/* invalidate an asid/iova tuple in all mr's */ | ||
135 | +static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova) | ||
136 | +{ | ||
137 | + SMMUNotifierNode *node; | ||
138 | + | ||
139 | + QLIST_FOREACH(node, &s->notifiers_list, next) { | ||
140 | + IOMMUMemoryRegion *mr = &node->sdev->iommu; | ||
141 | + IOMMUNotifier *n; | ||
142 | + | ||
143 | + trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova); | ||
144 | + | ||
145 | + IOMMU_NOTIFIER_FOREACH(n, mr) { | ||
146 | + smmuv3_notify_iova(mr, n, asid, iova); | ||
147 | + } | ||
148 | + } | ||
149 | +} | ||
150 | + | ||
151 | static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
152 | { | ||
153 | SMMUState *bs = ARM_SMMU(s); | ||
154 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
155 | uint16_t asid = CMD_ASID(&cmd); | ||
156 | |||
157 | trace_smmuv3_cmdq_tlbi_nh_asid(asid); | ||
158 | + smmu_inv_notifiers_all(&s->smmu_state); | ||
159 | smmu_iotlb_inv_asid(bs, asid); | ||
160 | break; | ||
161 | } | ||
162 | case SMMU_CMD_TLBI_NH_ALL: | ||
163 | case SMMU_CMD_TLBI_NSNH_ALL: | ||
164 | trace_smmuv3_cmdq_tlbi_nh(); | ||
165 | + smmu_inv_notifiers_all(&s->smmu_state); | ||
166 | smmu_iotlb_inv_all(bs); | ||
167 | break; | ||
168 | case SMMU_CMD_TLBI_NH_VAA: | ||
169 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
170 | uint16_t vmid = CMD_VMID(&cmd); | ||
171 | |||
172 | trace_smmuv3_cmdq_tlbi_nh_vaa(vmid, addr); | ||
173 | + smmuv3_inv_notifiers_iova(bs, -1, addr); | ||
174 | smmu_iotlb_inv_all(bs); | ||
175 | break; | ||
176 | } | ||
177 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
178 | bool leaf = CMD_LEAF(&cmd); | ||
179 | |||
180 | trace_smmuv3_cmdq_tlbi_nh_va(vmid, asid, addr, leaf); | ||
181 | + smmuv3_inv_notifiers_iova(bs, asid, addr); | ||
182 | smmu_iotlb_inv_iova(bs, asid, addr); | ||
183 | break; | ||
184 | } | ||
185 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | ||
186 | IOMMUNotifierFlag old, | ||
187 | IOMMUNotifierFlag new) | ||
188 | { | ||
189 | + SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu); | ||
190 | + SMMUv3State *s3 = sdev->smmu; | ||
191 | + SMMUState *s = &(s3->smmu_state); | ||
192 | + SMMUNotifierNode *node = NULL; | ||
193 | + SMMUNotifierNode *next_node = NULL; | ||
194 | + | ||
195 | + if (new & IOMMU_NOTIFIER_MAP) { | ||
196 | + int bus_num = pci_bus_num(sdev->bus); | ||
197 | + PCIDevice *pcidev = pci_find_device(sdev->bus, bus_num, sdev->devfn); | ||
198 | + | ||
199 | + warn_report("SMMUv3 does not support notification on MAP: " | ||
200 | + "device %s will not function properly", pcidev->name); | ||
201 | + } | ||
202 | + | ||
203 | if (old == IOMMU_NOTIFIER_NONE) { | ||
204 | - warn_report("SMMUV3 does not support vhost/vfio integration yet: " | ||
205 | - "devices of those types will not function properly"); | ||
206 | + trace_smmuv3_notify_flag_add(iommu->parent_obj.name); | ||
207 | + node = g_malloc0(sizeof(*node)); | ||
208 | + node->sdev = sdev; | ||
209 | + QLIST_INSERT_HEAD(&s->notifiers_list, node, next); | ||
210 | + return; | ||
211 | + } | ||
212 | + | ||
213 | + /* update notifier node with new flags */ | ||
214 | + QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) { | ||
215 | + if (node->sdev == sdev) { | ||
216 | + if (new == IOMMU_NOTIFIER_NONE) { | ||
217 | + trace_smmuv3_notify_flag_del(iommu->parent_obj.name); | ||
218 | + QLIST_REMOVE(node, next); | ||
219 | + g_free(node); | ||
220 | + } | ||
221 | + return; | ||
222 | + } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
227 | index XXXXXXX..XXXXXXX 100644 | ||
228 | --- a/hw/arm/trace-events | ||
229 | +++ b/hw/arm/trace-events | ||
230 | @@ -XXX,XX +XXX,XX @@ smmu_iotlb_cache_miss(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, | ||
231 | smmu_iotlb_inv_all(void) "IOTLB invalidate all" | ||
232 | smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d" | ||
233 | smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64 | ||
234 | +smmu_inv_notifiers_mr(const char *name) "iommu mr=%s" | ||
235 | |||
236 | #hw/arm/smmuv3.c | ||
237 | smmuv3_read_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)" | ||
238 | @@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_tlbi_nh_vaa(int vmid, uint64_t addr) "vmid =%d addr=0x%"PRIx64 | ||
239 | smmuv3_cmdq_tlbi_nh(void) "" | ||
240 | smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" | ||
241 | smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d" | ||
242 | +smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s" | ||
243 | +smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s" | ||
244 | +smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova) "iommu mr=%s asid=%d iova=0x%"PRIx64 | ||
245 | + | ||
246 | -- | 25 | -- |
247 | 2.17.1 | 26 | 2.20.1 |
248 | 27 | ||
249 | 28 | diff view generated by jsdifflib |
1 | From: Jia He <hejianet@gmail.com> | 1 | The virtio-pmem documentation has some minor style issues we hadn't |
---|---|---|---|
2 | noticed since we weren't rendering it in our docs: | ||
2 | 3 | ||
3 | In case the STE's config is "Bypass" we currently don't set the | 4 | * Sphinx doesn't complain about overlong title-underlining the |
4 | IOMMUTLBEntry perm flags and the access does not succeed. Also | 5 | way it complains about too-short underlining, but it looks odd; |
5 | if the config is 0b0xx (Aborted/Reserved), decode_ste and | 6 | make the underlines of section headers the right length |
6 | smmuv3_decode_config currently returns -EINVAL and we don't enter | ||
7 | the expected code path: we record an event whereas we should not. | ||
8 | 7 | ||
9 | This patch fixes those bugs and simplifies the error handling. | 8 | * Indent of paragraphs makes them render as blockquotes; |
10 | decode_ste and smmuv3_decode_config now return 0 if aborted or | 9 | remove the indent so they just render as normal text |
11 | bypassed config was found. Only bad config info produces negative | ||
12 | error values. In smmuv3_translate we more clearly differentiate | ||
13 | errors, bypass/smmu disabled, aborted and success cases. Also | ||
14 | trace points are differentiated. | ||
15 | 10 | ||
16 | Fixes: 9bde7f0674fe ("hw/arm/smmuv3: Implement translate callback") | 11 | * Leading 'o' isn't rst markup, so it just renders as a literal |
17 | Reported-by: jia.he@hxt-semitech.com | 12 | "o"; reformat as a subsection heading instead |
18 | Signed-off-by: jia.he@hxt-semitech.com | 13 | |
19 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 14 | * "QEMU" in the document title and section headings are a bit |
20 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | odd and unnecessary since this is the QEMU manual; delete |
21 | Message-id: 1529653501-15358-2-git-send-email-eric.auger@redhat.com | 16 | or rephrase them |
17 | |||
18 | * There's no need to specify what QEMU version the device first | ||
19 | appeared in. | ||
20 | |||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
23 | Reviewed-by: Pankaj Gupta <pankaj.gupta@cloud.ionos.com> | ||
23 | --- | 24 | --- |
24 | hw/arm/smmuv3-internal.h | 12 ++++- | 25 | docs/system/virtio-pmem.rst | 60 ++++++++++++++++++------------------- |
25 | hw/arm/smmuv3.c | 96 +++++++++++++++++++++++++++------------- | 26 | 1 file changed, 30 insertions(+), 30 deletions(-) |
26 | hw/arm/trace-events | 7 +-- | ||
27 | 3 files changed, 80 insertions(+), 35 deletions(-) | ||
28 | 27 | ||
29 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h | 28 | diff --git a/docs/system/virtio-pmem.rst b/docs/system/virtio-pmem.rst |
30 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/arm/smmuv3-internal.h | 30 | --- a/docs/system/virtio-pmem.rst |
32 | +++ b/hw/arm/smmuv3-internal.h | 31 | +++ b/docs/system/virtio-pmem.rst |
33 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ |
34 | 33 | ||
35 | #include "hw/arm/smmu-common.h" | 34 | -======================== |
36 | 35 | -QEMU virtio pmem | |
37 | +typedef enum SMMUTranslationStatus { | 36 | -======================== |
38 | + SMMU_TRANS_DISABLE, | 37 | +=========== |
39 | + SMMU_TRANS_ABORT, | 38 | +virtio pmem |
40 | + SMMU_TRANS_BYPASS, | 39 | +=========== |
41 | + SMMU_TRANS_ERROR, | 40 | |
42 | + SMMU_TRANS_SUCCESS, | 41 | - This document explains the setup and usage of the virtio pmem device |
43 | +} SMMUTranslationStatus; | 42 | - which is available since QEMU v4.1.0. |
43 | - | ||
44 | - The virtio pmem device is a paravirtualized persistent memory device | ||
45 | - on regular (i.e non-NVDIMM) storage. | ||
46 | +This document explains the setup and usage of the virtio pmem device. | ||
47 | +The virtio pmem device is a paravirtualized persistent memory device | ||
48 | +on regular (i.e non-NVDIMM) storage. | ||
49 | |||
50 | Usecase | ||
51 | --------- | ||
52 | +------- | ||
53 | |||
54 | - Virtio pmem allows to bypass the guest page cache and directly use | ||
55 | - host page cache. This reduces guest memory footprint as the host can | ||
56 | - make efficient memory reclaim decisions under memory pressure. | ||
57 | +Virtio pmem allows to bypass the guest page cache and directly use | ||
58 | +host page cache. This reduces guest memory footprint as the host can | ||
59 | +make efficient memory reclaim decisions under memory pressure. | ||
60 | |||
61 | -o How does virtio-pmem compare to the nvdimm emulation supported by QEMU? | ||
62 | +How does virtio-pmem compare to the nvdimm emulation? | ||
63 | +----------------------------------------------------- | ||
64 | |||
65 | - NVDIMM emulation on regular (i.e. non-NVDIMM) host storage does not | ||
66 | - persist the guest writes as there are no defined semantics in the device | ||
67 | - specification. The virtio pmem device provides guest write persistence | ||
68 | - on non-NVDIMM host storage. | ||
69 | +NVDIMM emulation on regular (i.e. non-NVDIMM) host storage does not | ||
70 | +persist the guest writes as there are no defined semantics in the device | ||
71 | +specification. The virtio pmem device provides guest write persistence | ||
72 | +on non-NVDIMM host storage. | ||
73 | |||
74 | virtio pmem usage | ||
75 | ----------------- | ||
76 | |||
77 | - A virtio pmem device backed by a memory-backend-file can be created on | ||
78 | - the QEMU command line as in the following example:: | ||
79 | +A virtio pmem device backed by a memory-backend-file can be created on | ||
80 | +the QEMU command line as in the following example:: | ||
81 | |||
82 | -object memory-backend-file,id=mem1,share,mem-path=./virtio_pmem.img,size=4G | ||
83 | -device virtio-pmem-pci,memdev=mem1,id=nv1 | ||
84 | |||
85 | - where: | ||
86 | +where: | ||
87 | |||
88 | - "object memory-backend-file,id=mem1,share,mem-path=<image>, size=<image size>" | ||
89 | creates a backend file with the specified size. | ||
90 | @@ -XXX,XX +XXX,XX @@ virtio pmem usage | ||
91 | - "device virtio-pmem-pci,id=nvdimm1,memdev=mem1" creates a virtio pmem | ||
92 | pci device whose storage is provided by above memory backend device. | ||
93 | |||
94 | - Multiple virtio pmem devices can be created if multiple pairs of "-object" | ||
95 | - and "-device" are provided. | ||
96 | +Multiple virtio pmem devices can be created if multiple pairs of "-object" | ||
97 | +and "-device" are provided. | ||
98 | |||
99 | Hotplug | ||
100 | ------- | ||
101 | @@ -XXX,XX +XXX,XX @@ the guest:: | ||
102 | Guest Data Persistence | ||
103 | ---------------------- | ||
104 | |||
105 | - Guest data persistence on non-NVDIMM requires guest userspace applications | ||
106 | - to perform fsync/msync. This is different from a real nvdimm backend where | ||
107 | - no additional fsync/msync is required. This is to persist guest writes in | ||
108 | - host backing file which otherwise remains in host page cache and there is | ||
109 | - risk of losing the data in case of power failure. | ||
110 | +Guest data persistence on non-NVDIMM requires guest userspace applications | ||
111 | +to perform fsync/msync. This is different from a real nvdimm backend where | ||
112 | +no additional fsync/msync is required. This is to persist guest writes in | ||
113 | +host backing file which otherwise remains in host page cache and there is | ||
114 | +risk of losing the data in case of power failure. | ||
115 | |||
116 | - With virtio pmem device, MAP_SYNC mmap flag is not supported. This provides | ||
117 | - a hint to application to perform fsync for write persistence. | ||
118 | +With virtio pmem device, MAP_SYNC mmap flag is not supported. This provides | ||
119 | +a hint to application to perform fsync for write persistence. | ||
120 | |||
121 | Limitations | ||
122 | ------------- | ||
123 | +----------- | ||
44 | + | 124 | + |
45 | /* MMIO Registers */ | 125 | - Real nvdimm device backend is not supported. |
46 | 126 | - virtio pmem hotunplug is not supported. | |
47 | REG32(IDR0, 0x0) | 127 | - ACPI NVDIMM features like regions/namespaces are not supported. |
48 | @@ -XXX,XX +XXX,XX @@ enum { /* Command completion notification */ | ||
49 | /* Events */ | ||
50 | |||
51 | typedef enum SMMUEventType { | ||
52 | - SMMU_EVT_OK = 0x00, | ||
53 | + SMMU_EVT_NONE = 0x00, | ||
54 | SMMU_EVT_F_UUT , | ||
55 | SMMU_EVT_C_BAD_STREAMID , | ||
56 | SMMU_EVT_F_STE_FETCH , | ||
57 | @@ -XXX,XX +XXX,XX @@ typedef enum SMMUEventType { | ||
58 | } SMMUEventType; | ||
59 | |||
60 | static const char *event_stringify[] = { | ||
61 | - [SMMU_EVT_OK] = "SMMU_EVT_OK", | ||
62 | + [SMMU_EVT_NONE] = "no recorded event", | ||
63 | [SMMU_EVT_F_UUT] = "SMMU_EVT_F_UUT", | ||
64 | [SMMU_EVT_C_BAD_STREAMID] = "SMMU_EVT_C_BAD_STREAMID", | ||
65 | [SMMU_EVT_F_STE_FETCH] = "SMMU_EVT_F_STE_FETCH", | ||
66 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/arm/smmuv3.c | ||
69 | +++ b/hw/arm/smmuv3.c | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | #include "hw/qdev-core.h" | ||
72 | #include "hw/pci/pci.h" | ||
73 | #include "exec/address-spaces.h" | ||
74 | +#include "cpu.h" | ||
75 | #include "trace.h" | ||
76 | #include "qemu/log.h" | ||
77 | #include "qemu/error-report.h" | ||
78 | @@ -XXX,XX +XXX,XX @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info) | ||
79 | EVT_SET_SID(&evt, info->sid); | ||
80 | |||
81 | switch (info->type) { | ||
82 | - case SMMU_EVT_OK: | ||
83 | + case SMMU_EVT_NONE: | ||
84 | return; | ||
85 | case SMMU_EVT_F_UUT: | ||
86 | EVT_SET_SSID(&evt, info->u.f_uut.ssid); | ||
87 | @@ -XXX,XX +XXX,XX @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid, | ||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | -/* Returns <0 if the caller has no need to continue the translation */ | ||
92 | +/* Returns < 0 in case of invalid STE, 0 otherwise */ | ||
93 | static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, | ||
94 | STE *ste, SMMUEventInfo *event) | ||
95 | { | ||
96 | uint32_t config; | ||
97 | - int ret = -EINVAL; | ||
98 | |||
99 | if (!STE_VALID(ste)) { | ||
100 | goto bad_ste; | ||
101 | @@ -XXX,XX +XXX,XX @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, | ||
102 | config = STE_CONFIG(ste); | ||
103 | |||
104 | if (STE_CFG_ABORT(config)) { | ||
105 | - cfg->aborted = true; /* abort but don't record any event */ | ||
106 | - return ret; | ||
107 | + cfg->aborted = true; | ||
108 | + return 0; | ||
109 | } | ||
110 | |||
111 | if (STE_CFG_BYPASS(config)) { | ||
112 | cfg->bypassed = true; | ||
113 | - return ret; | ||
114 | + return 0; | ||
115 | } | ||
116 | |||
117 | if (STE_CFG_S2_ENABLED(config)) { | ||
118 | @@ -XXX,XX +XXX,XX @@ bad_cd: | ||
119 | * the different configuration decoding steps | ||
120 | * @event: must be zero'ed by the caller | ||
121 | * | ||
122 | - * return < 0 if the translation needs to be aborted (@event is filled | ||
123 | + * return < 0 in case of config decoding error (@event is filled | ||
124 | * accordingly). Return 0 otherwise. | ||
125 | */ | ||
126 | static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg, | ||
127 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg, | ||
128 | SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu); | ||
129 | uint32_t sid = smmu_get_sid(sdev); | ||
130 | SMMUv3State *s = sdev->smmu; | ||
131 | - int ret = -EINVAL; | ||
132 | + int ret; | ||
133 | STE ste; | ||
134 | CD cd; | ||
135 | |||
136 | - if (smmu_find_ste(s, sid, &ste, event)) { | ||
137 | + ret = smmu_find_ste(s, sid, &ste, event); | ||
138 | + if (ret) { | ||
139 | return ret; | ||
140 | } | ||
141 | |||
142 | - if (decode_ste(s, cfg, &ste, event)) { | ||
143 | + ret = decode_ste(s, cfg, &ste, event); | ||
144 | + if (ret) { | ||
145 | return ret; | ||
146 | } | ||
147 | |||
148 | - if (smmu_get_cd(s, &ste, 0 /* ssid */, &cd, event)) { | ||
149 | + if (cfg->aborted || cfg->bypassed) { | ||
150 | + return 0; | ||
151 | + } | ||
152 | + | ||
153 | + ret = smmu_get_cd(s, &ste, 0 /* ssid */, &cd, event); | ||
154 | + if (ret) { | ||
155 | return ret; | ||
156 | } | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
159 | SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu); | ||
160 | SMMUv3State *s = sdev->smmu; | ||
161 | uint32_t sid = smmu_get_sid(sdev); | ||
162 | - SMMUEventInfo event = {.type = SMMU_EVT_OK, .sid = sid}; | ||
163 | + SMMUEventInfo event = {.type = SMMU_EVT_NONE, .sid = sid}; | ||
164 | SMMUPTWEventInfo ptw_info = {}; | ||
165 | + SMMUTranslationStatus status; | ||
166 | SMMUTransCfg cfg = {}; | ||
167 | IOMMUTLBEntry entry = { | ||
168 | .target_as = &address_space_memory, | ||
169 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
170 | .addr_mask = ~(hwaddr)0, | ||
171 | .perm = IOMMU_NONE, | ||
172 | }; | ||
173 | - int ret = 0; | ||
174 | |||
175 | if (!smmu_enabled(s)) { | ||
176 | - goto out; | ||
177 | + status = SMMU_TRANS_DISABLE; | ||
178 | + goto epilogue; | ||
179 | } | ||
180 | |||
181 | - ret = smmuv3_decode_config(mr, &cfg, &event); | ||
182 | - if (ret) { | ||
183 | - goto out; | ||
184 | + if (smmuv3_decode_config(mr, &cfg, &event)) { | ||
185 | + status = SMMU_TRANS_ERROR; | ||
186 | + goto epilogue; | ||
187 | } | ||
188 | |||
189 | if (cfg.aborted) { | ||
190 | - goto out; | ||
191 | + status = SMMU_TRANS_ABORT; | ||
192 | + goto epilogue; | ||
193 | } | ||
194 | |||
195 | - ret = smmu_ptw(&cfg, addr, flag, &entry, &ptw_info); | ||
196 | - if (ret) { | ||
197 | + if (cfg.bypassed) { | ||
198 | + status = SMMU_TRANS_BYPASS; | ||
199 | + goto epilogue; | ||
200 | + } | ||
201 | + | ||
202 | + if (smmu_ptw(&cfg, addr, flag, &entry, &ptw_info)) { | ||
203 | switch (ptw_info.type) { | ||
204 | case SMMU_PTW_ERR_WALK_EABT: | ||
205 | event.type = SMMU_EVT_F_WALK_EABT; | ||
206 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
207 | default: | ||
208 | g_assert_not_reached(); | ||
209 | } | ||
210 | + status = SMMU_TRANS_ERROR; | ||
211 | + } else { | ||
212 | + status = SMMU_TRANS_SUCCESS; | ||
213 | } | ||
214 | -out: | ||
215 | - if (ret) { | ||
216 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
217 | - "%s translation failed for iova=0x%"PRIx64"(%d)\n", | ||
218 | - mr->parent_obj.name, addr, ret); | ||
219 | - entry.perm = IOMMU_NONE; | ||
220 | - smmuv3_record_event(s, &event); | ||
221 | - } else if (!cfg.aborted) { | ||
222 | + | ||
223 | +epilogue: | ||
224 | + switch (status) { | ||
225 | + case SMMU_TRANS_SUCCESS: | ||
226 | entry.perm = flag; | ||
227 | - trace_smmuv3_translate(mr->parent_obj.name, sid, addr, | ||
228 | - entry.translated_addr, entry.perm); | ||
229 | + trace_smmuv3_translate_success(mr->parent_obj.name, sid, addr, | ||
230 | + entry.translated_addr, entry.perm); | ||
231 | + break; | ||
232 | + case SMMU_TRANS_DISABLE: | ||
233 | + entry.perm = flag; | ||
234 | + entry.addr_mask = ~TARGET_PAGE_MASK; | ||
235 | + trace_smmuv3_translate_disable(mr->parent_obj.name, sid, addr, | ||
236 | + entry.perm); | ||
237 | + break; | ||
238 | + case SMMU_TRANS_BYPASS: | ||
239 | + entry.perm = flag; | ||
240 | + entry.addr_mask = ~TARGET_PAGE_MASK; | ||
241 | + trace_smmuv3_translate_bypass(mr->parent_obj.name, sid, addr, | ||
242 | + entry.perm); | ||
243 | + break; | ||
244 | + case SMMU_TRANS_ABORT: | ||
245 | + /* no event is recorded on abort */ | ||
246 | + trace_smmuv3_translate_abort(mr->parent_obj.name, sid, addr, | ||
247 | + entry.perm); | ||
248 | + break; | ||
249 | + case SMMU_TRANS_ERROR: | ||
250 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
251 | + "%s translation failed for iova=0x%"PRIx64"(%s)\n", | ||
252 | + mr->parent_obj.name, addr, smmu_event_string(event.type)); | ||
253 | + smmuv3_record_event(s, &event); | ||
254 | + break; | ||
255 | } | ||
256 | |||
257 | return entry; | ||
258 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
259 | index XXXXXXX..XXXXXXX 100644 | ||
260 | --- a/hw/arm/trace-events | ||
261 | +++ b/hw/arm/trace-events | ||
262 | @@ -XXX,XX +XXX,XX @@ smmuv3_record_event(const char *type, uint32_t sid) "%s sid=%d" | ||
263 | smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "SID:0x%x features:0x%x, sid_split:0x%x" | ||
264 | smmuv3_find_ste_2lvl(uint64_t strtab_base, uint64_t l1ptr, int l1_ste_offset, uint64_t l2ptr, int l2_ste_offset, int max_l2_ste) "strtab_base:0x%"PRIx64" l1ptr:0x%"PRIx64" l1_off:0x%x, l2ptr:0x%"PRIx64" l2_off:0x%x max_l2_ste:%d" | ||
265 | smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64 | ||
266 | -smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d bypass iova:0x%"PRIx64" is_write=%d" | ||
267 | -smmuv3_translate_in(uint16_t sid, int pci_bus_num, uint64_t strtab_base) "SID:0x%x bus:%d strtab_base:0x%"PRIx64 | ||
268 | +smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d" | ||
269 | +smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d STE bypass iova:0x%"PRIx64" is_write=%d" | ||
270 | +smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d abort on iova:0x%"PRIx64" is_write=%d" | ||
271 | +smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=%d iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" | ||
272 | smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64 | ||
273 | -smmuv3_translate(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=%d iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" | ||
274 | smmuv3_decode_cd(uint32_t oas) "oas=%d" | ||
275 | smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d" | ||
276 | -- | 128 | -- |
277 | 2.17.1 | 129 | 2.20.1 |
278 | 130 | ||
279 | 131 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Currently target-i386.rst includes the documentation of the 'pc' |
---|---|---|---|
2 | machine model inline. Split it out into its own file, in a | ||
3 | similar way to target-i386.rst; this gives us a place to put | ||
4 | documentation of other i386 machine models, such as 'microvm'. | ||
2 | 5 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Message-id: 20180624040609.17572-6-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | --- | 8 | --- |
8 | hw/ssi/omap_spi.c | 15 ++++++++++----- | 9 | docs/system/i386/pc.rst | 7 +++++++ |
9 | 1 file changed, 10 insertions(+), 5 deletions(-) | 10 | docs/system/target-i386.rst | 18 +++++++++++++----- |
11 | 2 files changed, 20 insertions(+), 5 deletions(-) | ||
12 | create mode 100644 docs/system/i386/pc.rst | ||
10 | 13 | ||
11 | diff --git a/hw/ssi/omap_spi.c b/hw/ssi/omap_spi.c | 14 | diff --git a/docs/system/i386/pc.rst b/docs/system/i386/pc.rst |
15 | new file mode 100644 | ||
16 | index XXXXXXX..XXXXXXX | ||
17 | --- /dev/null | ||
18 | +++ b/docs/system/i386/pc.rst | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | +i440fx PC (``pc-i440fx``, ``pc``) | ||
21 | +================================= | ||
22 | + | ||
23 | +Peripherals | ||
24 | +~~~~~~~~~~~ | ||
25 | + | ||
26 | +.. include:: ../target-i386-desc.rst.inc | ||
27 | diff --git a/docs/system/target-i386.rst b/docs/system/target-i386.rst | ||
12 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/ssi/omap_spi.c | 29 | --- a/docs/system/target-i386.rst |
14 | +++ b/hw/ssi/omap_spi.c | 30 | +++ b/docs/system/target-i386.rst |
15 | @@ -XXX,XX +XXX,XX @@ | 31 | @@ -XXX,XX +XXX,XX @@ |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 32 | .. _QEMU-PC-System-emulator: |
17 | */ | 33 | |
18 | #include "qemu/osdep.h" | 34 | -x86 (PC) System emulator |
19 | +#include "qemu/log.h" | 35 | ------------------------- |
20 | #include "hw/hw.h" | 36 | +x86 System emulator |
21 | #include "hw/arm/omap.h" | 37 | +------------------- |
22 | 38 | ||
23 | @@ -XXX,XX +XXX,XX @@ static void omap_mcspi_write(void *opaque, hwaddr addr, | 39 | .. _pcsys_005fdevices: |
24 | case 0x2c: /* MCSPI_CHCONF */ | 40 | |
25 | if ((value ^ s->ch[ch].config) & (3 << 14)) /* DMAR | DMAW */ | 41 | -Peripherals |
26 | omap_mcspi_dmarequest_update(s->ch + ch); | 42 | -~~~~~~~~~~~ |
27 | - if (((value >> 12) & 3) == 3) /* TRM */ | 43 | +Board-specific documentation |
28 | - fprintf(stderr, "%s: invalid TRM value (3)\n", __func__); | 44 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
29 | - if (((value >> 7) & 0x1f) < 3) /* WL */ | 45 | |
30 | - fprintf(stderr, "%s: invalid WL value (%" PRIx64 ")\n", | 46 | -.. include:: target-i386-desc.rst.inc |
31 | - __func__, (value >> 7) & 0x1f); | 47 | +.. |
32 | + if (((value >> 12) & 3) == 3) { /* TRM */ | 48 | + This table of contents should be kept sorted alphabetically |
33 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid TRM value (3)\n", | 49 | + by the title text of each file, which isn't the same ordering |
34 | + __func__); | 50 | + as an alphabetical sort by filename. |
35 | + } | 51 | + |
36 | + if (((value >> 7) & 0x1f) < 3) { /* WL */ | 52 | +.. toctree:: |
37 | + qemu_log_mask(LOG_GUEST_ERROR, | 53 | + :maxdepth: 1 |
38 | + "%s: invalid WL value (%" PRIx64 ")\n", | 54 | + |
39 | + __func__, (value >> 7) & 0x1f); | 55 | + i386/pc |
40 | + } | 56 | |
41 | s->ch[ch].config = value & 0x7fffff; | 57 | .. include:: cpu-models-x86.rst.inc |
42 | break; | ||
43 | 58 | ||
44 | -- | 59 | -- |
45 | 2.17.1 | 60 | 2.20.1 |
46 | 61 | ||
47 | 62 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Now that target-i386.rst has a place to list documentation of |
---|---|---|---|
2 | machines other than the 'pc' machine, we have a place we can | ||
3 | move the microvm documentation to. | ||
2 | 4 | ||
3 | Let's cache config data to avoid fetching and parsing STE/CD | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | structures on each translation. We invalidate them on data structure | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
5 | invalidation commands. | 7 | --- |
8 | docs/{ => system/i386}/microvm.rst | 5 ++--- | ||
9 | docs/system/target-i386.rst | 1 + | ||
10 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
11 | rename docs/{ => system/i386}/microvm.rst (98%) | ||
6 | 12 | ||
7 | We put in place a per-smmu mutex to protect the config cache. This | 13 | diff --git a/docs/microvm.rst b/docs/system/i386/microvm.rst |
8 | will be useful too to protect the IOTLB cache. The caches can be | 14 | similarity index 98% |
9 | accessed without BQL, ie. in IO dataplane. The same kind of mutex was | 15 | rename from docs/microvm.rst |
10 | put in place in the intel viommu. | 16 | rename to docs/system/i386/microvm.rst |
11 | |||
12 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Message-id: 1529653501-15358-3-git-send-email-eric.auger@redhat.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | include/hw/arm/smmu-common.h | 5 ++ | ||
18 | include/hw/arm/smmuv3.h | 1 + | ||
19 | hw/arm/smmu-common.c | 24 ++++++- | ||
20 | hw/arm/smmuv3.c | 135 +++++++++++++++++++++++++++++++++-- | ||
21 | hw/arm/trace-events | 6 ++ | ||
22 | 5 files changed, 164 insertions(+), 7 deletions(-) | ||
23 | |||
24 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/arm/smmu-common.h | 18 | --- a/docs/microvm.rst |
27 | +++ b/include/hw/arm/smmu-common.h | 19 | +++ b/docs/system/i386/microvm.rst |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUDevice { | 20 | @@ -XXX,XX +XXX,XX @@ |
29 | int devfn; | 21 | -==================== |
30 | IOMMUMemoryRegion iommu; | 22 | -microvm Machine Type |
31 | AddressSpace as; | 23 | -==================== |
32 | + uint32_t cfg_cache_hits; | 24 | +'microvm' virtual platform (``microvm``) |
33 | + uint32_t cfg_cache_misses; | 25 | +======================================== |
34 | } SMMUDevice; | 26 | |
35 | 27 | ``microvm`` is a machine type inspired by ``Firecracker`` and | |
36 | typedef struct SMMUNotifierNode { | 28 | constructed after its machine model. |
37 | @@ -XXX,XX +XXX,XX @@ int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, | 29 | diff --git a/docs/system/target-i386.rst b/docs/system/target-i386.rst |
38 | */ | ||
39 | SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova); | ||
40 | |||
41 | +/* Return the iommu mr associated to @sid, or NULL if none */ | ||
42 | +IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid); | ||
43 | + | ||
44 | #endif /* HW_ARM_SMMU_COMMON */ | ||
45 | diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/include/hw/arm/smmuv3.h | 31 | --- a/docs/system/target-i386.rst |
48 | +++ b/include/hw/arm/smmuv3.h | 32 | +++ b/docs/system/target-i386.rst |
49 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUv3State { | 33 | @@ -XXX,XX +XXX,XX @@ Board-specific documentation |
50 | SMMUQueue eventq, cmdq; | 34 | .. toctree:: |
51 | 35 | :maxdepth: 1 | |
52 | qemu_irq irq[4]; | 36 | |
53 | + QemuMutex mutex; | 37 | + i386/microvm |
54 | } SMMUv3State; | 38 | i386/pc |
55 | 39 | ||
56 | typedef enum { | 40 | .. include:: cpu-models-x86.rst.inc |
57 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/arm/smmu-common.c | ||
60 | +++ b/hw/arm/smmu-common.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) | ||
62 | return &sdev->as; | ||
63 | } | ||
64 | |||
65 | +IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid) | ||
66 | +{ | ||
67 | + uint8_t bus_n, devfn; | ||
68 | + SMMUPciBus *smmu_bus; | ||
69 | + SMMUDevice *smmu; | ||
70 | + | ||
71 | + bus_n = PCI_BUS_NUM(sid); | ||
72 | + smmu_bus = smmu_find_smmu_pcibus(s, bus_n); | ||
73 | + if (smmu_bus) { | ||
74 | + devfn = sid & 0x7; | ||
75 | + smmu = smmu_bus->pbdev[devfn]; | ||
76 | + if (smmu) { | ||
77 | + return &smmu->iommu; | ||
78 | + } | ||
79 | + } | ||
80 | + return NULL; | ||
81 | +} | ||
82 | + | ||
83 | static void smmu_base_realize(DeviceState *dev, Error **errp) | ||
84 | { | ||
85 | SMMUState *s = ARM_SMMU(dev); | ||
86 | @@ -XXX,XX +XXX,XX @@ static void smmu_base_realize(DeviceState *dev, Error **errp) | ||
87 | error_propagate(errp, local_err); | ||
88 | return; | ||
89 | } | ||
90 | - | ||
91 | + s->configs = g_hash_table_new_full(NULL, NULL, NULL, g_free); | ||
92 | s->smmu_pcibus_by_busptr = g_hash_table_new(NULL, NULL); | ||
93 | |||
94 | if (s->primary_bus) { | ||
95 | @@ -XXX,XX +XXX,XX @@ static void smmu_base_realize(DeviceState *dev, Error **errp) | ||
96 | |||
97 | static void smmu_base_reset(DeviceState *dev) | ||
98 | { | ||
99 | - /* will be filled later on */ | ||
100 | + SMMUState *s = ARM_SMMU(dev); | ||
101 | + | ||
102 | + g_hash_table_remove_all(s->configs); | ||
103 | } | ||
104 | |||
105 | static Property smmu_dev_properties[] = { | ||
106 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/hw/arm/smmuv3.c | ||
109 | +++ b/hw/arm/smmuv3.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg, | ||
111 | return decode_cd(cfg, &cd, event); | ||
112 | } | ||
113 | |||
114 | +/** | ||
115 | + * smmuv3_get_config - Look up for a cached copy of configuration data for | ||
116 | + * @sdev and on cache miss performs a configuration structure decoding from | ||
117 | + * guest RAM. | ||
118 | + * | ||
119 | + * @sdev: SMMUDevice handle | ||
120 | + * @event: output event info | ||
121 | + * | ||
122 | + * The configuration cache contains data resulting from both STE and CD | ||
123 | + * decoding under the form of an SMMUTransCfg struct. The hash table is indexed | ||
124 | + * by the SMMUDevice handle. | ||
125 | + */ | ||
126 | +static SMMUTransCfg *smmuv3_get_config(SMMUDevice *sdev, SMMUEventInfo *event) | ||
127 | +{ | ||
128 | + SMMUv3State *s = sdev->smmu; | ||
129 | + SMMUState *bc = &s->smmu_state; | ||
130 | + SMMUTransCfg *cfg; | ||
131 | + | ||
132 | + cfg = g_hash_table_lookup(bc->configs, sdev); | ||
133 | + if (cfg) { | ||
134 | + sdev->cfg_cache_hits++; | ||
135 | + trace_smmuv3_config_cache_hit(smmu_get_sid(sdev), | ||
136 | + sdev->cfg_cache_hits, sdev->cfg_cache_misses, | ||
137 | + 100 * sdev->cfg_cache_hits / | ||
138 | + (sdev->cfg_cache_hits + sdev->cfg_cache_misses)); | ||
139 | + } else { | ||
140 | + sdev->cfg_cache_misses++; | ||
141 | + trace_smmuv3_config_cache_miss(smmu_get_sid(sdev), | ||
142 | + sdev->cfg_cache_hits, sdev->cfg_cache_misses, | ||
143 | + 100 * sdev->cfg_cache_hits / | ||
144 | + (sdev->cfg_cache_hits + sdev->cfg_cache_misses)); | ||
145 | + cfg = g_new0(SMMUTransCfg, 1); | ||
146 | + | ||
147 | + if (!smmuv3_decode_config(&sdev->iommu, cfg, event)) { | ||
148 | + g_hash_table_insert(bc->configs, sdev, cfg); | ||
149 | + } else { | ||
150 | + g_free(cfg); | ||
151 | + cfg = NULL; | ||
152 | + } | ||
153 | + } | ||
154 | + return cfg; | ||
155 | +} | ||
156 | + | ||
157 | +static void smmuv3_flush_config(SMMUDevice *sdev) | ||
158 | +{ | ||
159 | + SMMUv3State *s = sdev->smmu; | ||
160 | + SMMUState *bc = &s->smmu_state; | ||
161 | + | ||
162 | + trace_smmuv3_config_cache_inv(smmu_get_sid(sdev)); | ||
163 | + g_hash_table_remove(bc->configs, sdev); | ||
164 | +} | ||
165 | + | ||
166 | static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
167 | IOMMUAccessFlags flag, int iommu_idx) | ||
168 | { | ||
169 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
170 | SMMUEventInfo event = {.type = SMMU_EVT_NONE, .sid = sid}; | ||
171 | SMMUPTWEventInfo ptw_info = {}; | ||
172 | SMMUTranslationStatus status; | ||
173 | - SMMUTransCfg cfg = {}; | ||
174 | + SMMUTransCfg *cfg = NULL; | ||
175 | IOMMUTLBEntry entry = { | ||
176 | .target_as = &address_space_memory, | ||
177 | .iova = addr, | ||
178 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
179 | .perm = IOMMU_NONE, | ||
180 | }; | ||
181 | |||
182 | + qemu_mutex_lock(&s->mutex); | ||
183 | + | ||
184 | if (!smmu_enabled(s)) { | ||
185 | status = SMMU_TRANS_DISABLE; | ||
186 | goto epilogue; | ||
187 | } | ||
188 | |||
189 | - if (smmuv3_decode_config(mr, &cfg, &event)) { | ||
190 | + cfg = smmuv3_get_config(sdev, &event); | ||
191 | + if (!cfg) { | ||
192 | status = SMMU_TRANS_ERROR; | ||
193 | goto epilogue; | ||
194 | } | ||
195 | |||
196 | - if (cfg.aborted) { | ||
197 | + if (cfg->aborted) { | ||
198 | status = SMMU_TRANS_ABORT; | ||
199 | goto epilogue; | ||
200 | } | ||
201 | |||
202 | - if (cfg.bypassed) { | ||
203 | + if (cfg->bypassed) { | ||
204 | status = SMMU_TRANS_BYPASS; | ||
205 | goto epilogue; | ||
206 | } | ||
207 | |||
208 | - if (smmu_ptw(&cfg, addr, flag, &entry, &ptw_info)) { | ||
209 | + if (smmu_ptw(cfg, addr, flag, &entry, &ptw_info)) { | ||
210 | switch (ptw_info.type) { | ||
211 | case SMMU_PTW_ERR_WALK_EABT: | ||
212 | event.type = SMMU_EVT_F_WALK_EABT; | ||
213 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
214 | } | ||
215 | |||
216 | epilogue: | ||
217 | + qemu_mutex_unlock(&s->mutex); | ||
218 | switch (status) { | ||
219 | case SMMU_TRANS_SUCCESS: | ||
220 | entry.perm = flag; | ||
221 | @@ -XXX,XX +XXX,XX @@ epilogue: | ||
222 | |||
223 | static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
224 | { | ||
225 | + SMMUState *bs = ARM_SMMU(s); | ||
226 | SMMUCmdError cmd_error = SMMU_CERROR_NONE; | ||
227 | SMMUQueue *q = &s->cmdq; | ||
228 | SMMUCommandType type = 0; | ||
229 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
230 | |||
231 | trace_smmuv3_cmdq_opcode(smmu_cmd_string(type)); | ||
232 | |||
233 | + qemu_mutex_lock(&s->mutex); | ||
234 | switch (type) { | ||
235 | case SMMU_CMD_SYNC: | ||
236 | if (CMD_SYNC_CS(&cmd) & CMD_SYNC_SIG_IRQ) { | ||
237 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
238 | break; | ||
239 | case SMMU_CMD_PREFETCH_CONFIG: | ||
240 | case SMMU_CMD_PREFETCH_ADDR: | ||
241 | + break; | ||
242 | case SMMU_CMD_CFGI_STE: | ||
243 | + { | ||
244 | + uint32_t sid = CMD_SID(&cmd); | ||
245 | + IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid); | ||
246 | + SMMUDevice *sdev; | ||
247 | + | ||
248 | + if (CMD_SSEC(&cmd)) { | ||
249 | + cmd_error = SMMU_CERROR_ILL; | ||
250 | + break; | ||
251 | + } | ||
252 | + | ||
253 | + if (!mr) { | ||
254 | + break; | ||
255 | + } | ||
256 | + | ||
257 | + trace_smmuv3_cmdq_cfgi_ste(sid); | ||
258 | + sdev = container_of(mr, SMMUDevice, iommu); | ||
259 | + smmuv3_flush_config(sdev); | ||
260 | + | ||
261 | + break; | ||
262 | + } | ||
263 | case SMMU_CMD_CFGI_STE_RANGE: /* same as SMMU_CMD_CFGI_ALL */ | ||
264 | + { | ||
265 | + uint32_t start = CMD_SID(&cmd), end, i; | ||
266 | + uint8_t range = CMD_STE_RANGE(&cmd); | ||
267 | + | ||
268 | + if (CMD_SSEC(&cmd)) { | ||
269 | + cmd_error = SMMU_CERROR_ILL; | ||
270 | + break; | ||
271 | + } | ||
272 | + | ||
273 | + end = start + (1 << (range + 1)) - 1; | ||
274 | + trace_smmuv3_cmdq_cfgi_ste_range(start, end); | ||
275 | + | ||
276 | + for (i = start; i <= end; i++) { | ||
277 | + IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, i); | ||
278 | + SMMUDevice *sdev; | ||
279 | + | ||
280 | + if (!mr) { | ||
281 | + continue; | ||
282 | + } | ||
283 | + sdev = container_of(mr, SMMUDevice, iommu); | ||
284 | + smmuv3_flush_config(sdev); | ||
285 | + } | ||
286 | + break; | ||
287 | + } | ||
288 | case SMMU_CMD_CFGI_CD: | ||
289 | case SMMU_CMD_CFGI_CD_ALL: | ||
290 | + { | ||
291 | + uint32_t sid = CMD_SID(&cmd); | ||
292 | + IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid); | ||
293 | + SMMUDevice *sdev; | ||
294 | + | ||
295 | + if (CMD_SSEC(&cmd)) { | ||
296 | + cmd_error = SMMU_CERROR_ILL; | ||
297 | + break; | ||
298 | + } | ||
299 | + | ||
300 | + if (!mr) { | ||
301 | + break; | ||
302 | + } | ||
303 | + | ||
304 | + trace_smmuv3_cmdq_cfgi_cd(sid); | ||
305 | + sdev = container_of(mr, SMMUDevice, iommu); | ||
306 | + smmuv3_flush_config(sdev); | ||
307 | + break; | ||
308 | + } | ||
309 | case SMMU_CMD_TLBI_NH_ALL: | ||
310 | case SMMU_CMD_TLBI_NH_ASID: | ||
311 | case SMMU_CMD_TLBI_NH_VA: | ||
312 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
313 | "Illegal command type: %d\n", CMD_TYPE(&cmd)); | ||
314 | break; | ||
315 | } | ||
316 | + qemu_mutex_unlock(&s->mutex); | ||
317 | if (cmd_error) { | ||
318 | break; | ||
319 | } | ||
320 | @@ -XXX,XX +XXX,XX @@ static void smmu_realize(DeviceState *d, Error **errp) | ||
321 | return; | ||
322 | } | ||
323 | |||
324 | + qemu_mutex_init(&s->mutex); | ||
325 | + | ||
326 | memory_region_init_io(&sys->iomem, OBJECT(s), | ||
327 | &smmu_mem_ops, sys, TYPE_ARM_SMMUV3, 0x20000); | ||
328 | |||
329 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
330 | index XXXXXXX..XXXXXXX 100644 | ||
331 | --- a/hw/arm/trace-events | ||
332 | +++ b/hw/arm/trace-events | ||
333 | @@ -XXX,XX +XXX,XX @@ smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t tr | ||
334 | smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64 | ||
335 | smmuv3_decode_cd(uint32_t oas) "oas=%d" | ||
336 | smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d" | ||
337 | +smmuv3_cmdq_cfgi_ste(int streamid) "streamid =%d" | ||
338 | +smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%d - end=0x%d" | ||
339 | +smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d" | ||
340 | +smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)" | ||
341 | +smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)" | ||
342 | +smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d" | ||
343 | -- | 41 | -- |
344 | 2.17.1 | 42 | 2.20.1 |
345 | 43 | ||
346 | 44 | diff view generated by jsdifflib |
1 | We want to handle small MPU region sizes for ARMv7M. To do this, | 1 | Move the pr-manager documentation into the system manual. |
---|---|---|---|
2 | make get_phys_addr_pmsav7() set the page size to the region | 2 | Some of it (the documentation of the pr-manager-helper tool) |
3 | size if it is less that TARGET_PAGE_SIZE, rather than working | 3 | should be in tools, but we will split it up after moving it. |
4 | only in TARGET_PAGE_SIZE chunks. | ||
5 | |||
6 | Since the core TCG code con't handle execution from small | ||
7 | MPU regions, we strip the exec permission from them so that | ||
8 | any execution attempts will cause an MPU exception, rather | ||
9 | than allowing it to end up with a cpu_abort() in | ||
10 | get_page_addr_code(). | ||
11 | |||
12 | (The previous code's intention was to make any small page be | ||
13 | treated as having no permissions, but unfortunately errors | ||
14 | in the implementation meant that it didn't behave that way. | ||
15 | It's possible that some binaries using small regions were | ||
16 | accidentally working with our old behaviour and won't now.) | ||
17 | 4 | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
20 | Message-id: 20180620130619.11362-3-peter.maydell@linaro.org | ||
21 | --- | 7 | --- |
22 | target/arm/helper.c | 37 ++++++++++++++++++++++++++----------- | 8 | docs/system/index.rst | 1 + |
23 | 1 file changed, 26 insertions(+), 11 deletions(-) | 9 | docs/{ => system}/pr-manager.rst | 0 |
10 | 2 files changed, 1 insertion(+) | ||
11 | rename docs/{ => system}/pr-manager.rst (100%) | ||
24 | 12 | ||
25 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/docs/system/index.rst b/docs/system/index.rst |
26 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.c | 15 | --- a/docs/system/index.rst |
28 | +++ b/target/arm/helper.c | 16 | +++ b/docs/system/index.rst |
29 | @@ -XXX,XX +XXX,XX @@ static inline bool m_is_system_region(CPUARMState *env, uint32_t address) | 17 | @@ -XXX,XX +XXX,XX @@ Contents: |
30 | static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | 18 | managed-startup |
31 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 19 | cpu-hotplug |
32 | hwaddr *phys_ptr, int *prot, | 20 | virtio-pmem |
33 | + target_ulong *page_size, | 21 | + pr-manager |
34 | ARMMMUFaultInfo *fi) | 22 | targets |
35 | { | 23 | security |
36 | ARMCPU *cpu = arm_env_get_cpu(env); | 24 | deprecated |
37 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | 25 | diff --git a/docs/pr-manager.rst b/docs/system/pr-manager.rst |
38 | bool is_user = regime_is_user(env, mmu_idx); | 26 | similarity index 100% |
39 | 27 | rename from docs/pr-manager.rst | |
40 | *phys_ptr = address; | 28 | rename to docs/system/pr-manager.rst |
41 | + *page_size = TARGET_PAGE_SIZE; | ||
42 | *prot = 0; | ||
43 | |||
44 | if (regime_translation_disabled(env, mmu_idx) || | ||
45 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
46 | rsize++; | ||
47 | } | ||
48 | } | ||
49 | - if (rsize < TARGET_PAGE_BITS) { | ||
50 | - qemu_log_mask(LOG_UNIMP, | ||
51 | - "DRSR[%d]: No support for MPU (sub)region size of" | ||
52 | - " %" PRIu32 " bytes. Minimum is %d.\n", | ||
53 | - n, (1 << rsize), TARGET_PAGE_SIZE); | ||
54 | - continue; | ||
55 | - } | ||
56 | if (srdis) { | ||
57 | continue; | ||
58 | } | ||
59 | + if (rsize < TARGET_PAGE_BITS) { | ||
60 | + *page_size = 1 << rsize; | ||
61 | + } | ||
62 | break; | ||
63 | } | ||
64 | |||
65 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
66 | |||
67 | fi->type = ARMFault_Permission; | ||
68 | fi->level = 1; | ||
69 | + /* | ||
70 | + * Core QEMU code can't handle execution from small pages yet, so | ||
71 | + * don't try it. This way we'll get an MPU exception, rather than | ||
72 | + * eventually causing QEMU to exit in get_page_addr_code(). | ||
73 | + */ | ||
74 | + if (*page_size < TARGET_PAGE_SIZE && (*prot & PAGE_EXEC)) { | ||
75 | + qemu_log_mask(LOG_UNIMP, | ||
76 | + "MPU: No support for execution from regions " | ||
77 | + "smaller than 1K\n"); | ||
78 | + *prot &= ~PAGE_EXEC; | ||
79 | + } | ||
80 | return !(*prot & (1 << access_type)); | ||
81 | } | ||
82 | |||
83 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
84 | } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
85 | /* PMSAv7 */ | ||
86 | ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | ||
87 | - phys_ptr, prot, fi); | ||
88 | + phys_ptr, prot, page_size, fi); | ||
89 | } else { | ||
90 | /* Pre-v7 MPU */ | ||
91 | ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, | ||
92 | @@ -XXX,XX +XXX,XX @@ bool arm_tlb_fill(CPUState *cs, vaddr address, | ||
93 | core_to_arm_mmu_idx(env, mmu_idx), &phys_addr, | ||
94 | &attrs, &prot, &page_size, fi, NULL); | ||
95 | if (!ret) { | ||
96 | - /* Map a single [sub]page. */ | ||
97 | - phys_addr &= TARGET_PAGE_MASK; | ||
98 | - address &= TARGET_PAGE_MASK; | ||
99 | + /* | ||
100 | + * Map a single [sub]page. Regions smaller than our declared | ||
101 | + * target page size are handled specially, so for those we | ||
102 | + * pass in the exact addresses. | ||
103 | + */ | ||
104 | + if (page_size >= TARGET_PAGE_SIZE) { | ||
105 | + phys_addr &= TARGET_PAGE_MASK; | ||
106 | + address &= TARGET_PAGE_MASK; | ||
107 | + } | ||
108 | tlb_set_page_with_attrs(cs, address, phys_addr, attrs, | ||
109 | prot, mmu_idx, page_size); | ||
110 | return 0; | ||
111 | -- | 29 | -- |
112 | 2.17.1 | 30 | 2.20.1 |
113 | 31 | ||
114 | 32 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Split the documentation of the qemu-pr-helper binary into the tools |
---|---|---|---|
2 | 2 | manual, and give it a manpage like our other standalone executables. | |
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | |
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | Message-id: 20180624040609.17572-7-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | --- | 6 | --- |
8 | hw/sd/omap_mmc.c | 13 +++++++++---- | 7 | docs/meson.build | 1 + |
9 | 1 file changed, 9 insertions(+), 4 deletions(-) | 8 | docs/system/pr-manager.rst | 38 ++------------- |
10 | 9 | docs/tools/conf.py | 2 + | |
11 | diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c | 10 | docs/tools/index.rst | 1 + |
12 | index XXXXXXX..XXXXXXX 100644 | 11 | docs/tools/qemu-pr-helper.rst | 90 +++++++++++++++++++++++++++++++++++ |
13 | --- a/hw/sd/omap_mmc.c | 12 | 5 files changed, 99 insertions(+), 33 deletions(-) |
14 | +++ b/hw/sd/omap_mmc.c | 13 | create mode 100644 docs/tools/qemu-pr-helper.rst |
14 | |||
15 | diff --git a/docs/meson.build b/docs/meson.build | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/docs/meson.build | ||
18 | +++ b/docs/meson.build | ||
19 | @@ -XXX,XX +XXX,XX @@ if build_docs | ||
20 | 'tools': { | ||
21 | 'qemu-img.1': (have_tools ? 'man1' : ''), | ||
22 | 'qemu-nbd.8': (have_tools ? 'man8' : ''), | ||
23 | + 'qemu-pr-helper.8': (have_tools ? 'man8' : ''), | ||
24 | 'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''), | ||
25 | 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''), | ||
26 | 'virtiofsd.1': (have_virtiofsd ? 'man1' : ''), | ||
27 | diff --git a/docs/system/pr-manager.rst b/docs/system/pr-manager.rst | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/docs/system/pr-manager.rst | ||
30 | +++ b/docs/system/pr-manager.rst | ||
31 | @@ -XXX,XX +XXX,XX @@ Alternatively, using ``-blockdev``:: | ||
32 | -blockdev node-name=hd,driver=raw,file.driver=host_device,file.filename=/dev/sdb,file.pr-manager=helper0 | ||
33 | -device scsi-block,drive=hd | ||
34 | |||
35 | ----------------------------------- | ||
36 | -Invoking :program:`qemu-pr-helper` | ||
37 | ----------------------------------- | ||
38 | - | ||
39 | -QEMU provides an implementation of the persistent reservation helper, | ||
40 | -called :program:`qemu-pr-helper`. The helper should be started as a | ||
41 | -system service and supports the following option: | ||
42 | - | ||
43 | --d, --daemon run in the background | ||
44 | --q, --quiet decrease verbosity | ||
45 | --v, --verbose increase verbosity | ||
46 | --f, --pidfile=path PID file when running as a daemon | ||
47 | --k, --socket=path path to the socket | ||
48 | --T, --trace=trace-opts tracing options | ||
49 | - | ||
50 | -By default, the socket and PID file are placed in the runtime state | ||
51 | -directory, for example :file:`/var/run/qemu-pr-helper.sock` and | ||
52 | -:file:`/var/run/qemu-pr-helper.pid`. The PID file is not created | ||
53 | -unless :option:`-d` is passed too. | ||
54 | - | ||
55 | -:program:`qemu-pr-helper` can also use the systemd socket activation | ||
56 | -protocol. In this case, the systemd socket unit should specify a | ||
57 | -Unix stream socket, like this:: | ||
58 | - | ||
59 | - [Socket] | ||
60 | - ListenStream=/var/run/qemu-pr-helper.sock | ||
61 | - | ||
62 | -After connecting to the socket, :program:`qemu-pr-helper`` can optionally drop | ||
63 | -root privileges, except for those capabilities that are needed for | ||
64 | -its operation. To do this, add the following options: | ||
65 | - | ||
66 | --u, --user=user user to drop privileges to | ||
67 | --g, --group=group group to drop privileges to | ||
68 | +You will also need to ensure that the helper program | ||
69 | +:command:`qemu-pr-helper` is running, and that it has been | ||
70 | +set up to use the same socket filename as your QEMU commandline | ||
71 | +specifies. See the qemu-pr-helper documentation or manpage for | ||
72 | +further details. | ||
73 | |||
74 | --------------------------------------------- | ||
75 | Multipath devices and persistent reservations | ||
76 | diff --git a/docs/tools/conf.py b/docs/tools/conf.py | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/docs/tools/conf.py | ||
79 | +++ b/docs/tools/conf.py | ||
80 | @@ -XXX,XX +XXX,XX @@ man_pages = [ | ||
81 | ['Fabrice Bellard'], 1), | ||
82 | ('qemu-nbd', 'qemu-nbd', u'QEMU Disk Network Block Device Server', | ||
83 | ['Anthony Liguori <anthony@codemonkey.ws>'], 8), | ||
84 | + ('qemu-pr-helper', 'qemu-pr-helper', 'QEMU persistent reservation helper', | ||
85 | + [], 8), | ||
86 | ('qemu-trace-stap', 'qemu-trace-stap', u'QEMU SystemTap trace tool', | ||
87 | [], 1), | ||
88 | ('virtfs-proxy-helper', 'virtfs-proxy-helper', | ||
89 | diff --git a/docs/tools/index.rst b/docs/tools/index.rst | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/docs/tools/index.rst | ||
92 | +++ b/docs/tools/index.rst | ||
93 | @@ -XXX,XX +XXX,XX @@ Contents: | ||
94 | |||
95 | qemu-img | ||
96 | qemu-nbd | ||
97 | + qemu-pr-helper | ||
98 | qemu-trace-stap | ||
99 | virtfs-proxy-helper | ||
100 | virtiofsd | ||
101 | diff --git a/docs/tools/qemu-pr-helper.rst b/docs/tools/qemu-pr-helper.rst | ||
102 | new file mode 100644 | ||
103 | index XXXXXXX..XXXXXXX | ||
104 | --- /dev/null | ||
105 | +++ b/docs/tools/qemu-pr-helper.rst | ||
15 | @@ -XXX,XX +XXX,XX @@ | 106 | @@ -XXX,XX +XXX,XX @@ |
16 | * with this program; if not, see <http://www.gnu.org/licenses/>. | 107 | +QEMU persistent reservation helper |
17 | */ | 108 | +================================== |
18 | #include "qemu/osdep.h" | 109 | + |
19 | +#include "qemu/log.h" | 110 | +Synopsis |
20 | #include "hw/hw.h" | 111 | +-------- |
21 | #include "hw/arm/omap.h" | 112 | + |
22 | #include "hw/sd/sd.h" | 113 | +**qemu-pr-helper** [*OPTION*] |
23 | @@ -XXX,XX +XXX,XX @@ static void omap_mmc_write(void *opaque, hwaddr offset, | 114 | + |
24 | s->enable = (value >> 11) & 1; | 115 | +Description |
25 | s->be = (value >> 10) & 1; | 116 | +----------- |
26 | s->clkdiv = (value >> 0) & (s->rev >= 2 ? 0x3ff : 0xff); | 117 | + |
27 | - if (s->mode != 0) | 118 | +Implements the persistent reservation helper for QEMU. |
28 | - printf("SD mode %i unimplemented!\n", s->mode); | 119 | + |
29 | - if (s->be != 0) | 120 | +SCSI persistent reservations allow restricting access to block devices |
30 | - printf("SD FIFO byte sex unimplemented!\n"); | 121 | +to specific initiators in a shared storage setup. When implementing |
31 | + if (s->mode != 0) { | 122 | +clustering of virtual machines, it is a common requirement for virtual |
32 | + qemu_log_mask(LOG_UNIMP, | 123 | +machines to send persistent reservation SCSI commands. However, |
33 | + "omap_mmc_wr: mode #%i unimplemented\n", s->mode); | 124 | +the operating system restricts sending these commands to unprivileged |
34 | + } | 125 | +programs because incorrect usage can disrupt regular operation of the |
35 | + if (s->be != 0) { | 126 | +storage fabric. QEMU's SCSI passthrough devices ``scsi-block`` |
36 | + qemu_log_mask(LOG_UNIMP, | 127 | +and ``scsi-generic`` support passing guest persistent reservation |
37 | + "omap_mmc_wr: Big Endian not implemented\n"); | 128 | +requests to a privileged external helper program. :program:`qemu-pr-helper` |
38 | + } | 129 | +is that external helper; it creates a socket which QEMU can |
39 | if (s->dw != 0 && s->lines < 4) | 130 | +connect to to communicate with it. |
40 | printf("4-bit SD bus enabled\n"); | 131 | + |
41 | if (!s->enable) | 132 | +If you want to run VMs in a setup like this, this helper should be |
133 | +started as a system service, and you should read the QEMU manual | ||
134 | +section on "persistent reservation managers" to find out how to | ||
135 | +configure QEMU to connect to the socket created by | ||
136 | +:program:`qemu-pr-helper`. | ||
137 | + | ||
138 | +After connecting to the socket, :program:`qemu-pr-helper` can | ||
139 | +optionally drop root privileges, except for those capabilities that | ||
140 | +are needed for its operation. | ||
141 | + | ||
142 | +:program:`qemu-pr-helper` can also use the systemd socket activation | ||
143 | +protocol. In this case, the systemd socket unit should specify a | ||
144 | +Unix stream socket, like this:: | ||
145 | + | ||
146 | + [Socket] | ||
147 | + ListenStream=/var/run/qemu-pr-helper.sock | ||
148 | + | ||
149 | +Options | ||
150 | +------- | ||
151 | + | ||
152 | +.. program:: qemu-pr-helper | ||
153 | + | ||
154 | +.. option:: -d, --daemon | ||
155 | + | ||
156 | + run in the background (and create a PID file) | ||
157 | + | ||
158 | +.. option:: -q, --quiet | ||
159 | + | ||
160 | + decrease verbosity | ||
161 | + | ||
162 | +.. option:: -v, --verbose | ||
163 | + | ||
164 | + increase verbosity | ||
165 | + | ||
166 | +.. option:: -f, --pidfile=PATH | ||
167 | + | ||
168 | + PID file when running as a daemon. By default the PID file | ||
169 | + is created in the system runtime state directory, for example | ||
170 | + :file:`/var/run/qemu-pr-helper.pid`. | ||
171 | + | ||
172 | +.. option:: -k, --socket=PATH | ||
173 | + | ||
174 | + path to the socket. By default the socket is created in | ||
175 | + the system runtime state directory, for example | ||
176 | + :file:`/var/run/qemu-pr-helper.sock`. | ||
177 | + | ||
178 | +.. option:: -T, --trace [[enable=]PATTERN][,events=FILE][,file=FILE] | ||
179 | + | ||
180 | + .. include:: ../qemu-option-trace.rst.inc | ||
181 | + | ||
182 | +.. option:: -u, --user=USER | ||
183 | + | ||
184 | + user to drop privileges to | ||
185 | + | ||
186 | +.. option:: -g, --group=GROUP | ||
187 | + | ||
188 | + group to drop privileges to | ||
189 | + | ||
190 | +.. option:: -h, --help | ||
191 | + | ||
192 | + Display a help message and exit. | ||
193 | + | ||
194 | +.. option:: -V, --version | ||
195 | + | ||
196 | + Display version information and exit. | ||
42 | -- | 197 | -- |
43 | 2.17.1 | 198 | 2.20.1 |
44 | 199 | ||
45 | 200 | diff view generated by jsdifflib |
1 | Add support for MMU protection regions that are smaller than | 1 | Fix a couple of nits in pr-manager.rst: |
---|---|---|---|
2 | TARGET_PAGE_SIZE. We do this by marking the TLB entry for those | 2 | * the title marker for the top level heading is overlength |
3 | pages with a flag TLB_RECHECK. This flag causes us to always | 3 | * stray capital 'R' in the middle of a sentence |
4 | take the slow-path for accesses. In the slow path we can then | ||
5 | special case them to always call tlb_fill() again, so we have | ||
6 | the correct information for the exact address being accessed. | ||
7 | |||
8 | This change allows us to handle reading and writing from small | ||
9 | regions; we cannot deal with execution from the small region. | ||
10 | 4 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
13 | Message-id: 20180620130619.11362-2-peter.maydell@linaro.org | ||
14 | --- | 7 | --- |
15 | accel/tcg/softmmu_template.h | 24 ++++--- | 8 | docs/system/pr-manager.rst | 6 +++--- |
16 | include/exec/cpu-all.h | 5 +- | 9 | 1 file changed, 3 insertions(+), 3 deletions(-) |
17 | accel/tcg/cputlb.c | 131 +++++++++++++++++++++++++++++------ | ||
18 | 3 files changed, 130 insertions(+), 30 deletions(-) | ||
19 | 10 | ||
20 | diff --git a/accel/tcg/softmmu_template.h b/accel/tcg/softmmu_template.h | 11 | diff --git a/docs/system/pr-manager.rst b/docs/system/pr-manager.rst |
21 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/accel/tcg/softmmu_template.h | 13 | --- a/docs/system/pr-manager.rst |
23 | +++ b/accel/tcg/softmmu_template.h | 14 | +++ b/docs/system/pr-manager.rst |
24 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ |
25 | static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, | 16 | -====================================== |
26 | size_t mmu_idx, size_t index, | 17 | +=============================== |
27 | target_ulong addr, | 18 | Persistent reservation managers |
28 | - uintptr_t retaddr) | 19 | -====================================== |
29 | + uintptr_t retaddr, | 20 | +=============================== |
30 | + bool recheck) | 21 | |
31 | { | 22 | -SCSI persistent Reservations allow restricting access to block devices |
32 | CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; | 23 | +SCSI persistent reservations allow restricting access to block devices |
33 | - return io_readx(env, iotlbentry, mmu_idx, addr, retaddr, DATA_SIZE); | 24 | to specific initiators in a shared storage setup. When implementing |
34 | + return io_readx(env, iotlbentry, mmu_idx, addr, retaddr, recheck, | 25 | clustering of virtual machines, it is a common requirement for virtual |
35 | + DATA_SIZE); | 26 | machines to send persistent reservation SCSI commands. However, |
36 | } | ||
37 | #endif | ||
38 | |||
39 | @@ -XXX,XX +XXX,XX @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr, | ||
40 | |||
41 | /* ??? Note that the io helpers always read data in the target | ||
42 | byte ordering. We should push the LE/BE request down into io. */ | ||
43 | - res = glue(io_read, SUFFIX)(env, mmu_idx, index, addr, retaddr); | ||
44 | + res = glue(io_read, SUFFIX)(env, mmu_idx, index, addr, retaddr, | ||
45 | + tlb_addr & TLB_RECHECK); | ||
46 | res = TGT_LE(res); | ||
47 | return res; | ||
48 | } | ||
49 | @@ -XXX,XX +XXX,XX @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr, | ||
50 | |||
51 | /* ??? Note that the io helpers always read data in the target | ||
52 | byte ordering. We should push the LE/BE request down into io. */ | ||
53 | - res = glue(io_read, SUFFIX)(env, mmu_idx, index, addr, retaddr); | ||
54 | + res = glue(io_read, SUFFIX)(env, mmu_idx, index, addr, retaddr, | ||
55 | + tlb_addr & TLB_RECHECK); | ||
56 | res = TGT_BE(res); | ||
57 | return res; | ||
58 | } | ||
59 | @@ -XXX,XX +XXX,XX @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env, | ||
60 | size_t mmu_idx, size_t index, | ||
61 | DATA_TYPE val, | ||
62 | target_ulong addr, | ||
63 | - uintptr_t retaddr) | ||
64 | + uintptr_t retaddr, | ||
65 | + bool recheck) | ||
66 | { | ||
67 | CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; | ||
68 | - return io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, DATA_SIZE); | ||
69 | + return io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, | ||
70 | + recheck, DATA_SIZE); | ||
71 | } | ||
72 | |||
73 | void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, | ||
74 | @@ -XXX,XX +XXX,XX @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, | ||
75 | /* ??? Note that the io helpers always read data in the target | ||
76 | byte ordering. We should push the LE/BE request down into io. */ | ||
77 | val = TGT_LE(val); | ||
78 | - glue(io_write, SUFFIX)(env, mmu_idx, index, val, addr, retaddr); | ||
79 | + glue(io_write, SUFFIX)(env, mmu_idx, index, val, addr, | ||
80 | + retaddr, tlb_addr & TLB_RECHECK); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | @@ -XXX,XX +XXX,XX @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, | ||
85 | /* ??? Note that the io helpers always read data in the target | ||
86 | byte ordering. We should push the LE/BE request down into io. */ | ||
87 | val = TGT_BE(val); | ||
88 | - glue(io_write, SUFFIX)(env, mmu_idx, index, val, addr, retaddr); | ||
89 | + glue(io_write, SUFFIX)(env, mmu_idx, index, val, addr, retaddr, | ||
90 | + tlb_addr & TLB_RECHECK); | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h | ||
95 | index XXXXXXX..XXXXXXX 100644 | ||
96 | --- a/include/exec/cpu-all.h | ||
97 | +++ b/include/exec/cpu-all.h | ||
98 | @@ -XXX,XX +XXX,XX @@ CPUArchState *cpu_copy(CPUArchState *env); | ||
99 | #define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS - 2)) | ||
100 | /* Set if TLB entry is an IO callback. */ | ||
101 | #define TLB_MMIO (1 << (TARGET_PAGE_BITS - 3)) | ||
102 | +/* Set if TLB entry must have MMU lookup repeated for every access */ | ||
103 | +#define TLB_RECHECK (1 << (TARGET_PAGE_BITS - 4)) | ||
104 | |||
105 | /* Use this mask to check interception with an alignment mask | ||
106 | * in a TCG backend. | ||
107 | */ | ||
108 | -#define TLB_FLAGS_MASK (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO) | ||
109 | +#define TLB_FLAGS_MASK (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO \ | ||
110 | + | TLB_RECHECK) | ||
111 | |||
112 | void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); | ||
113 | void dump_opcount_info(FILE *f, fprintf_function cpu_fprintf); | ||
114 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
115 | index XXXXXXX..XXXXXXX 100644 | ||
116 | --- a/accel/tcg/cputlb.c | ||
117 | +++ b/accel/tcg/cputlb.c | ||
118 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
119 | target_ulong code_address; | ||
120 | uintptr_t addend; | ||
121 | CPUTLBEntry *te, *tv, tn; | ||
122 | - hwaddr iotlb, xlat, sz; | ||
123 | + hwaddr iotlb, xlat, sz, paddr_page; | ||
124 | + target_ulong vaddr_page; | ||
125 | unsigned vidx = env->vtlb_index++ % CPU_VTLB_SIZE; | ||
126 | int asidx = cpu_asidx_from_attrs(cpu, attrs); | ||
127 | |||
128 | assert_cpu_is_self(cpu); | ||
129 | - assert(size >= TARGET_PAGE_SIZE); | ||
130 | - if (size != TARGET_PAGE_SIZE) { | ||
131 | - tlb_add_large_page(env, vaddr, size); | ||
132 | - } | ||
133 | |||
134 | - sz = size; | ||
135 | - section = address_space_translate_for_iotlb(cpu, asidx, paddr, &xlat, &sz, | ||
136 | - attrs, &prot); | ||
137 | + if (size < TARGET_PAGE_SIZE) { | ||
138 | + sz = TARGET_PAGE_SIZE; | ||
139 | + } else { | ||
140 | + if (size > TARGET_PAGE_SIZE) { | ||
141 | + tlb_add_large_page(env, vaddr, size); | ||
142 | + } | ||
143 | + sz = size; | ||
144 | + } | ||
145 | + vaddr_page = vaddr & TARGET_PAGE_MASK; | ||
146 | + paddr_page = paddr & TARGET_PAGE_MASK; | ||
147 | + | ||
148 | + section = address_space_translate_for_iotlb(cpu, asidx, paddr_page, | ||
149 | + &xlat, &sz, attrs, &prot); | ||
150 | assert(sz >= TARGET_PAGE_SIZE); | ||
151 | |||
152 | tlb_debug("vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx | ||
153 | " prot=%x idx=%d\n", | ||
154 | vaddr, paddr, prot, mmu_idx); | ||
155 | |||
156 | - address = vaddr; | ||
157 | - if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) { | ||
158 | + address = vaddr_page; | ||
159 | + if (size < TARGET_PAGE_SIZE) { | ||
160 | + /* | ||
161 | + * Slow-path the TLB entries; we will repeat the MMU check and TLB | ||
162 | + * fill on every access. | ||
163 | + */ | ||
164 | + address |= TLB_RECHECK; | ||
165 | + } | ||
166 | + if (!memory_region_is_ram(section->mr) && | ||
167 | + !memory_region_is_romd(section->mr)) { | ||
168 | /* IO memory case */ | ||
169 | address |= TLB_MMIO; | ||
170 | addend = 0; | ||
171 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
172 | } | ||
173 | |||
174 | code_address = address; | ||
175 | - iotlb = memory_region_section_get_iotlb(cpu, section, vaddr, paddr, xlat, | ||
176 | - prot, &address); | ||
177 | + iotlb = memory_region_section_get_iotlb(cpu, section, vaddr_page, | ||
178 | + paddr_page, xlat, prot, &address); | ||
179 | |||
180 | - index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); | ||
181 | + index = (vaddr_page >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); | ||
182 | te = &env->tlb_table[mmu_idx][index]; | ||
183 | /* do not discard the translation in te, evict it into a victim tlb */ | ||
184 | tv = &env->tlb_v_table[mmu_idx][vidx]; | ||
185 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
186 | * TARGET_PAGE_BITS, and either | ||
187 | * + the ram_addr_t of the page base of the target RAM (if NOTDIRTY or ROM) | ||
188 | * + the offset within section->mr of the page base (otherwise) | ||
189 | - * We subtract the vaddr (which is page aligned and thus won't | ||
190 | + * We subtract the vaddr_page (which is page aligned and thus won't | ||
191 | * disturb the low bits) to give an offset which can be added to the | ||
192 | * (non-page-aligned) vaddr of the eventual memory access to get | ||
193 | * the MemoryRegion offset for the access. Note that the vaddr we | ||
194 | * subtract here is that of the page base, and not the same as the | ||
195 | * vaddr we add back in io_readx()/io_writex()/get_page_addr_code(). | ||
196 | */ | ||
197 | - env->iotlb[mmu_idx][index].addr = iotlb - vaddr; | ||
198 | + env->iotlb[mmu_idx][index].addr = iotlb - vaddr_page; | ||
199 | env->iotlb[mmu_idx][index].attrs = attrs; | ||
200 | |||
201 | /* Now calculate the new entry */ | ||
202 | - tn.addend = addend - vaddr; | ||
203 | + tn.addend = addend - vaddr_page; | ||
204 | if (prot & PAGE_READ) { | ||
205 | tn.addr_read = address; | ||
206 | } else { | ||
207 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
208 | tn.addr_write = address | TLB_MMIO; | ||
209 | } else if (memory_region_is_ram(section->mr) | ||
210 | && cpu_physical_memory_is_clean( | ||
211 | - memory_region_get_ram_addr(section->mr) + xlat)) { | ||
212 | + memory_region_get_ram_addr(section->mr) + xlat)) { | ||
213 | tn.addr_write = address | TLB_NOTDIRTY; | ||
214 | } else { | ||
215 | tn.addr_write = address; | ||
216 | @@ -XXX,XX +XXX,XX @@ static inline ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr) | ||
217 | |||
218 | static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
219 | int mmu_idx, | ||
220 | - target_ulong addr, uintptr_t retaddr, int size) | ||
221 | + target_ulong addr, uintptr_t retaddr, | ||
222 | + bool recheck, int size) | ||
223 | { | ||
224 | CPUState *cpu = ENV_GET_CPU(env); | ||
225 | hwaddr mr_offset; | ||
226 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
227 | bool locked = false; | ||
228 | MemTxResult r; | ||
229 | |||
230 | + if (recheck) { | ||
231 | + /* | ||
232 | + * This is a TLB_RECHECK access, where the MMU protection | ||
233 | + * covers a smaller range than a target page, and we must | ||
234 | + * repeat the MMU check here. This tlb_fill() call might | ||
235 | + * longjump out if this access should cause a guest exception. | ||
236 | + */ | ||
237 | + int index; | ||
238 | + target_ulong tlb_addr; | ||
239 | + | ||
240 | + tlb_fill(cpu, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); | ||
241 | + | ||
242 | + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); | ||
243 | + tlb_addr = env->tlb_table[mmu_idx][index].addr_read; | ||
244 | + if (!(tlb_addr & ~(TARGET_PAGE_MASK | TLB_RECHECK))) { | ||
245 | + /* RAM access */ | ||
246 | + uintptr_t haddr = addr + env->tlb_table[mmu_idx][index].addend; | ||
247 | + | ||
248 | + return ldn_p((void *)haddr, size); | ||
249 | + } | ||
250 | + /* Fall through for handling IO accesses */ | ||
251 | + } | ||
252 | + | ||
253 | section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); | ||
254 | mr = section->mr; | ||
255 | mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; | ||
256 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
257 | static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
258 | int mmu_idx, | ||
259 | uint64_t val, target_ulong addr, | ||
260 | - uintptr_t retaddr, int size) | ||
261 | + uintptr_t retaddr, bool recheck, int size) | ||
262 | { | ||
263 | CPUState *cpu = ENV_GET_CPU(env); | ||
264 | hwaddr mr_offset; | ||
265 | @@ -XXX,XX +XXX,XX @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
266 | bool locked = false; | ||
267 | MemTxResult r; | ||
268 | |||
269 | + if (recheck) { | ||
270 | + /* | ||
271 | + * This is a TLB_RECHECK access, where the MMU protection | ||
272 | + * covers a smaller range than a target page, and we must | ||
273 | + * repeat the MMU check here. This tlb_fill() call might | ||
274 | + * longjump out if this access should cause a guest exception. | ||
275 | + */ | ||
276 | + int index; | ||
277 | + target_ulong tlb_addr; | ||
278 | + | ||
279 | + tlb_fill(cpu, addr, size, MMU_DATA_STORE, mmu_idx, retaddr); | ||
280 | + | ||
281 | + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); | ||
282 | + tlb_addr = env->tlb_table[mmu_idx][index].addr_write; | ||
283 | + if (!(tlb_addr & ~(TARGET_PAGE_MASK | TLB_RECHECK))) { | ||
284 | + /* RAM access */ | ||
285 | + uintptr_t haddr = addr + env->tlb_table[mmu_idx][index].addend; | ||
286 | + | ||
287 | + stn_p((void *)haddr, size, val); | ||
288 | + return; | ||
289 | + } | ||
290 | + /* Fall through for handling IO accesses */ | ||
291 | + } | ||
292 | + | ||
293 | section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); | ||
294 | mr = section->mr; | ||
295 | mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; | ||
296 | @@ -XXX,XX +XXX,XX @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) | ||
297 | tlb_fill(ENV_GET_CPU(env), addr, 0, MMU_INST_FETCH, mmu_idx, 0); | ||
298 | } | ||
299 | } | ||
300 | + | ||
301 | + if (unlikely(env->tlb_table[mmu_idx][index].addr_code & TLB_RECHECK)) { | ||
302 | + /* | ||
303 | + * This is a TLB_RECHECK access, where the MMU protection | ||
304 | + * covers a smaller range than a target page, and we must | ||
305 | + * repeat the MMU check here. This tlb_fill() call might | ||
306 | + * longjump out if this access should cause a guest exception. | ||
307 | + */ | ||
308 | + int index; | ||
309 | + target_ulong tlb_addr; | ||
310 | + | ||
311 | + tlb_fill(cpu, addr, 0, MMU_INST_FETCH, mmu_idx, 0); | ||
312 | + | ||
313 | + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); | ||
314 | + tlb_addr = env->tlb_table[mmu_idx][index].addr_code; | ||
315 | + if (!(tlb_addr & ~(TARGET_PAGE_MASK | TLB_RECHECK))) { | ||
316 | + /* RAM access. We can't handle this, so for now just stop */ | ||
317 | + cpu_abort(cpu, "Unable to handle guest executing from RAM within " | ||
318 | + "a small MPU region at 0x" TARGET_FMT_lx, addr); | ||
319 | + } | ||
320 | + /* | ||
321 | + * Fall through to handle IO accesses (which will almost certainly | ||
322 | + * also result in failure) | ||
323 | + */ | ||
324 | + } | ||
325 | + | ||
326 | iotlbentry = &env->iotlb[mmu_idx][index]; | ||
327 | section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); | ||
328 | mr = section->mr; | ||
329 | @@ -XXX,XX +XXX,XX @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, | ||
330 | tlb_addr = tlbe->addr_write & ~TLB_INVALID_MASK; | ||
331 | } | ||
332 | |||
333 | - /* Notice an IO access */ | ||
334 | - if (unlikely(tlb_addr & TLB_MMIO)) { | ||
335 | + /* Notice an IO access or a needs-MMU-lookup access */ | ||
336 | + if (unlikely(tlb_addr & (TLB_MMIO | TLB_RECHECK))) { | ||
337 | /* There's really nothing that can be done to | ||
338 | support this apart from stop-the-world. */ | ||
339 | goto stop_the_world; | ||
340 | -- | 27 | -- |
341 | 2.17.1 | 28 | 2.20.1 |
342 | 29 | ||
343 | 30 | diff view generated by jsdifflib |