1 | Latest run of arm patches -- most of these are Philippe's SD card | 1 | Big pullreq this week, since it's got RTH's PAN/UAO/ATS1E1 |
---|---|---|---|
2 | cleanups. I have more in my queue to review, but 32 is enough | 2 | implementation in it, and also Philippe's raspi board model |
3 | patches to warrant sending out. | 3 | cleanup patchset, as well as a scattering of smaller stuff. |
4 | 4 | ||
5 | thanks | ||
6 | -- PMM | 5 | -- PMM |
7 | 6 | ||
8 | The following changes since commit ff8689611a1d954897d857b28f7ef404e11cfa2c: | ||
9 | 7 | ||
10 | Merge remote-tracking branch 'remotes/mcayland/tags/qemu-openbios-signed' into staging (2018-02-22 11:37:05 +0000) | 8 | The following changes since commit 7ce9ce89930ce260af839fb3e3e5f9101f5c69a0: |
9 | |||
10 | Merge remote-tracking branch 'remotes/kraxel/tags/ui-20200212-pull-request' into staging (2020-02-13 11:06:32 +0000) | ||
11 | 11 | ||
12 | are available in the Git repository at: | 12 | are available in the Git repository at: |
13 | 13 | ||
14 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180222 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200213 |
15 | 15 | ||
16 | for you to fetch changes up to 4e5cc6756586e967993187657dfcdde4e00288d9: | 16 | for you to fetch changes up to dc7a88d0810ad272bdcd2e0869359af78fdd9114: |
17 | 17 | ||
18 | sdcard: simplify SD_SEND_OP_COND (ACMD41) (2018-02-22 15:12:54 +0000) | 18 | target/arm: Implement ARMv8.1-VMID16 extension (2020-02-13 14:30:51 +0000) |
19 | 19 | ||
20 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
21 | * New "raspi3" machine emulating RaspberryPi 3 | 21 | target-arm queue: |
22 | * Fix bad register definitions for VMIDR and VMPIDR (which caused | 22 | * i.MX: Fix inverted sense of register bits in watchdog timer |
23 | assertions for 64-bit guest CPUs with EL2 on big-endian hosts) | 23 | * i.MX: Add support for WDT on i.MX6 |
24 | * hw/char/stm32f2xx_usart: fix TXE/TC bit handling | 24 | * arm/virt: cleanups to ACPI tables |
25 | * Fix ast2500 protection register emulation | 25 | * Implement ARMv8.1-VMID16 extension |
26 | * Lots of SD card emulation cleanups and bugfixes | 26 | * Implement ARMv8.1-PAN |
27 | * Implement ARMv8.2-UAO | ||
28 | * Implement ARMv8.2-ATS1E1 | ||
29 | * ast2400/2500/2600: Wire up EHCI controllers | ||
30 | * hw/char/exynos4210_uart: Fix memleaks in exynos4210_uart_init | ||
31 | * hw/arm/raspi: Clean up the board code | ||
27 | 32 | ||
28 | ---------------------------------------------------------------- | 33 | ---------------------------------------------------------------- |
29 | Hugo Landau (1): | 34 | Chen Qun (1): |
30 | Fix ast2500 protection register emulation | 35 | hw/char/exynos4210_uart: Fix memleaks in exynos4210_uart_init |
31 | 36 | ||
32 | Pekka Enberg (1): | 37 | Guenter Roeck (2): |
33 | raspi: Add "raspi3" machine type | 38 | hw/arm: ast2400/ast2500: Wire up EHCI controllers |
39 | hw/arm: ast2600: Wire up EHCI controllers | ||
40 | |||
41 | Heyi Guo (7): | ||
42 | bios-tables-test: prepare to change ARM virt ACPI DSDT | ||
43 | arm/virt/acpi: remove meaningless sub device "RP0" from PCI0 | ||
44 | arm/virt/acpi: remove _ADR from devices identified by _HID | ||
45 | arm/acpi: fix PCI _PRT definition | ||
46 | arm/acpi: fix duplicated _UID of PCI interrupt link devices | ||
47 | arm/acpi: simplify the description of PCI _CRS | ||
48 | virt/acpi: update golden masters for DSDT update | ||
34 | 49 | ||
35 | Peter Maydell (1): | 50 | Peter Maydell (1): |
36 | target/arm: Fix register definitions for VMIDR and VMPIDR | 51 | target/arm: Implement ARMv8.1-VMID16 extension |
37 | 52 | ||
38 | Philippe Mathieu-Daudé (28): | 53 | Philippe Mathieu-Daudé (13): |
39 | hw/sd/milkymist-memcard: use qemu_log_mask() | 54 | hw/arm/raspi: Use BCM2708 machine type with pre Device Tree kernels |
40 | hw/sd/milkymist-memcard: split realize() out of SysBusDevice init() | 55 | hw/arm/raspi: Correct the board descriptions |
41 | hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it | 56 | hw/arm/raspi: Extract the version from the board revision |
42 | hw/sd/ssi-sd: use the SDBus API, connect the SDCard to the bus | 57 | hw/arm/raspi: Extract the RAM size from the board revision |
43 | sdcard: reorder SDState struct members | 58 | hw/arm/raspi: Extract the processor type from the board revision |
44 | sdcard: replace DPRINTF() by trace events | 59 | hw/arm/raspi: Trivial code movement |
45 | sdcard: add a trace event for command responses | 60 | hw/arm/raspi: Make machines children of abstract RaspiMachineClass |
46 | sdcard: replace fprintf() by qemu_hexdump() | 61 | hw/arm/raspi: Make board_rev a field of RaspiMachineClass |
47 | sdcard: add more trace events | 62 | hw/arm/raspi: Let class_init() directly call raspi_machine_init() |
48 | sdcard: define SDMMC_CMD_MAX instead of using the magic '64' | 63 | hw/arm/raspi: Set default RAM size to size encoded in board revision |
49 | sdcard: use G_BYTE from cutils | 64 | hw/arm/raspi: Extract the board model from the board revision |
50 | sdcard: use the registerfields API to access the OCR register | 65 | hw/arm/raspi: Use a unique raspi_machine_class_init() method |
51 | sdcard: Don't always set the high capacity bit | 66 | hw/arm/raspi: Extract the cores count from the board revision |
52 | sdcard: update the CSD CRC register regardless the CSD structure version | ||
53 | sdcard: fix the 'maximum data transfer rate' to 25MHz | ||
54 | sdcard: clean the SCR register and add few comments | ||
55 | sdcard: remove commands from unsupported old MMC specification | ||
56 | sdcard: simplify using the ldst API | ||
57 | sdcard: use the correct masked OCR in the R3 reply | ||
58 | sdcard: use the registerfields API for the CARD_STATUS register masks | ||
59 | sdcard: handle CMD54 (SDIO) | ||
60 | sdcard: handle the Security Specification commands | ||
61 | sdcard: use a more descriptive label 'unimplemented_spi_cmd' | ||
62 | sdcard: handles more commands in SPI mode | ||
63 | sdcard: check the card is in correct state for APP CMD (CMD55) | ||
64 | sdcard: warn if host uses an incorrect address for APP CMD (CMD55) | ||
65 | sdcard: simplify SEND_IF_COND (CMD8) | ||
66 | sdcard: simplify SD_SEND_OP_COND (ACMD41) | ||
67 | 67 | ||
68 | Richard Braun (1): | 68 | Richard Henderson (20): |
69 | hw/char/stm32f2xx_usart: fix TXE/TC bit handling | 69 | target/arm: Add arm_mmu_idx_is_stage1_of_2 |
70 | target/arm: Add mmu_idx for EL1 and EL2 w/ PAN enabled | ||
71 | target/arm: Add isar_feature tests for PAN + ATS1E1 | ||
72 | target/arm: Move LOR regdefs to file scope | ||
73 | target/arm: Split out aarch32_cpsr_valid_mask | ||
74 | target/arm: Mask CPSR_J when Jazelle is not enabled | ||
75 | target/arm: Replace CPSR_ERET_MASK with aarch32_cpsr_valid_mask | ||
76 | target/arm: Use aarch32_cpsr_valid_mask in helper_exception_return | ||
77 | target/arm: Remove CPSR_RESERVED | ||
78 | target/arm: Introduce aarch64_pstate_valid_mask | ||
79 | target/arm: Update MSR access for PAN | ||
80 | target/arm: Update arm_mmu_idx_el for PAN | ||
81 | target/arm: Enforce PAN semantics in get_S1prot | ||
82 | target/arm: Set PAN bit as required on exception entry | ||
83 | target/arm: Implement ATS1E1 system registers | ||
84 | target/arm: Enable ARMv8.2-ATS1E1 in -cpu max | ||
85 | target/arm: Add ID_AA64MMFR2_EL1 | ||
86 | target/arm: Update MSR access to UAO | ||
87 | target/arm: Implement UAO semantics | ||
88 | target/arm: Enable ARMv8.2-UAO in -cpu max | ||
70 | 89 | ||
71 | hw/sd/sdmmc-internal.h | 15 ++ | 90 | Roman Kapl (2): |
72 | include/hw/char/stm32f2xx_usart.h | 7 +- | 91 | i.MX: Fix inverted register bits in wdt code. |
73 | include/hw/sd/sd.h | 1 - | 92 | i.MX: Add support for WDT on i.MX6 |
74 | hw/arm/raspi.c | 23 ++ | ||
75 | hw/char/stm32f2xx_usart.c | 12 +- | ||
76 | hw/misc/aspeed_scu.c | 6 +- | ||
77 | hw/misc/aspeed_sdmc.c | 8 +- | ||
78 | hw/sd/milkymist-memcard.c | 87 +++---- | ||
79 | hw/sd/sd.c | 467 +++++++++++++++++++++++--------------- | ||
80 | hw/sd/ssi-sd.c | 32 +-- | ||
81 | target/arm/helper.c | 8 +- | ||
82 | hw/sd/trace-events | 20 ++ | ||
83 | 12 files changed, 446 insertions(+), 240 deletions(-) | ||
84 | create mode 100644 hw/sd/sdmmc-internal.h | ||
85 | 93 | ||
94 | include/hw/arm/aspeed_soc.h | 6 + | ||
95 | include/hw/arm/fsl-imx6.h | 3 + | ||
96 | target/arm/cpu-param.h | 2 +- | ||
97 | target/arm/cpu.h | 95 ++++++++--- | ||
98 | target/arm/internals.h | 85 ++++++++++ | ||
99 | hw/arm/aspeed_ast2600.c | 23 +++ | ||
100 | hw/arm/aspeed_soc.c | 25 +++ | ||
101 | hw/arm/fsl-imx6.c | 21 +++ | ||
102 | hw/arm/raspi.c | 190 ++++++++++++++++------ | ||
103 | hw/arm/virt-acpi-build.c | 25 +-- | ||
104 | hw/char/exynos4210_uart.c | 5 +- | ||
105 | hw/misc/imx2_wdt.c | 2 +- | ||
106 | target/arm/cpu.c | 4 + | ||
107 | target/arm/cpu64.c | 10 ++ | ||
108 | target/arm/helper-a64.c | 6 +- | ||
109 | target/arm/helper.c | 327 +++++++++++++++++++++++++++++--------- | ||
110 | target/arm/kvm64.c | 2 + | ||
111 | target/arm/op_helper.c | 14 +- | ||
112 | target/arm/translate-a64.c | 31 ++++ | ||
113 | target/arm/translate.c | 42 +++-- | ||
114 | tests/data/acpi/virt/DSDT | Bin 18462 -> 5307 bytes | ||
115 | tests/data/acpi/virt/DSDT.memhp | Bin 19799 -> 6644 bytes | ||
116 | tests/data/acpi/virt/DSDT.numamem | Bin 18462 -> 5307 bytes | ||
117 | 23 files changed, 731 insertions(+), 187 deletions(-) | ||
118 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Roman Kapl <rka@sysgo.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Documentation says for WDA '0: Assert WDOG output.' and for SRS |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | '0: Assert system reset signal.'. |
5 | Acked-by: Michael Walle <michael@walle.cc> | 5 | |
6 | Message-id: 20180216022933.10945-2-f4bug@amsat.org | 6 | Signed-off-by: Roman Kapl <rka@sysgo.com> |
7 | Message-id: 20200207095409.11227-1-rka@sysgo.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | hw/sd/milkymist-memcard.c | 17 ++++++++++------- | 11 | hw/misc/imx2_wdt.c | 2 +- |
10 | 1 file changed, 10 insertions(+), 7 deletions(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | 13 | ||
12 | diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c | 14 | diff --git a/hw/misc/imx2_wdt.c b/hw/misc/imx2_wdt.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/sd/milkymist-memcard.c | 16 | --- a/hw/misc/imx2_wdt.c |
15 | +++ b/hw/sd/milkymist-memcard.c | 17 | +++ b/hw/misc/imx2_wdt.c |
16 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void imx2_wdt_write(void *opaque, hwaddr addr, |
17 | */ | 19 | uint64_t value, unsigned int size) |
18 | 20 | { | |
19 | #include "qemu/osdep.h" | 21 | if (addr == IMX2_WDT_WCR && |
20 | +#include "qemu/log.h" | 22 | - (value & (IMX2_WDT_WCR_WDA | IMX2_WDT_WCR_SRS))) { |
21 | #include "hw/hw.h" | 23 | + (~value & (IMX2_WDT_WCR_WDA | IMX2_WDT_WCR_SRS))) { |
22 | #include "hw/sysbus.h" | 24 | watchdog_perform_action(); |
23 | #include "sysemu/sysemu.h" | ||
24 | #include "trace.h" | ||
25 | -#include "qemu/error-report.h" | ||
26 | +#include "include/qapi/error.h" | ||
27 | #include "sysemu/block-backend.h" | ||
28 | #include "sysemu/blockdev.h" | ||
29 | #include "hw/sd/sd.h" | ||
30 | @@ -XXX,XX +XXX,XX @@ static uint64_t memcard_read(void *opaque, hwaddr addr, | ||
31 | } else { | ||
32 | r = s->response[s->response_read_ptr++]; | ||
33 | if (s->response_read_ptr > s->response_len) { | ||
34 | - error_report("milkymist_memcard: " | ||
35 | - "read more cmd bytes than available. Clipping."); | ||
36 | + qemu_log_mask(LOG_GUEST_ERROR, "milkymist_memcard: " | ||
37 | + "read more cmd bytes than available. Clipping."); | ||
38 | s->response_read_ptr = 0; | ||
39 | } | ||
40 | } | ||
41 | @@ -XXX,XX +XXX,XX @@ static uint64_t memcard_read(void *opaque, hwaddr addr, | ||
42 | break; | ||
43 | |||
44 | default: | ||
45 | - error_report("milkymist_memcard: read access to unknown register 0x" | ||
46 | - TARGET_FMT_plx, addr << 2); | ||
47 | + qemu_log_mask(LOG_UNIMP, "milkymist_memcard: " | ||
48 | + "read access to unknown register 0x%" HWADDR_PRIx "\n", | ||
49 | + addr << 2); | ||
50 | break; | ||
51 | } | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static void memcard_write(void *opaque, hwaddr addr, uint64_t value, | ||
54 | break; | ||
55 | |||
56 | default: | ||
57 | - error_report("milkymist_memcard: write access to unknown register 0x" | ||
58 | - TARGET_FMT_plx, addr << 2); | ||
59 | + qemu_log_mask(LOG_UNIMP, "milkymist_memcard: " | ||
60 | + "write access to unknown register 0x%" HWADDR_PRIx " " | ||
61 | + "(value 0x%" PRIx64 ")\n", addr << 2, value); | ||
62 | break; | ||
63 | } | 25 | } |
64 | } | 26 | } |
65 | -- | 27 | -- |
66 | 2.16.1 | 28 | 2.20.1 |
67 | 29 | ||
68 | 30 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Roman Kapl <rka@sysgo.com> | ||
1 | 2 | ||
3 | Uses the i.MX2 rudimentary watchdog driver. | ||
4 | |||
5 | Signed-off-by: Roman Kapl <rka@sysgo.com> | ||
6 | Message-id: 20200207095529.11309-1-rka@sysgo.com | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | [PMM: removed accidental duplicate #include line] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/fsl-imx6.h | 3 +++ | ||
12 | hw/arm/fsl-imx6.c | 21 +++++++++++++++++++++ | ||
13 | 2 files changed, 24 insertions(+) | ||
14 | |||
15 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/arm/fsl-imx6.h | ||
18 | +++ b/include/hw/arm/fsl-imx6.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "hw/cpu/a9mpcore.h" | ||
21 | #include "hw/misc/imx6_ccm.h" | ||
22 | #include "hw/misc/imx6_src.h" | ||
23 | +#include "hw/misc/imx2_wdt.h" | ||
24 | #include "hw/char/imx_serial.h" | ||
25 | #include "hw/timer/imx_gpt.h" | ||
26 | #include "hw/timer/imx_epit.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | #define FSL_IMX6_NUM_GPIOS 7 | ||
29 | #define FSL_IMX6_NUM_ESDHCS 4 | ||
30 | #define FSL_IMX6_NUM_ECSPIS 5 | ||
31 | +#define FSL_IMX6_NUM_WDTS 2 | ||
32 | |||
33 | typedef struct FslIMX6State { | ||
34 | /*< private >*/ | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State { | ||
36 | IMXGPIOState gpio[FSL_IMX6_NUM_GPIOS]; | ||
37 | SDHCIState esdhc[FSL_IMX6_NUM_ESDHCS]; | ||
38 | IMXSPIState spi[FSL_IMX6_NUM_ECSPIS]; | ||
39 | + IMX2WdtState wdt[FSL_IMX6_NUM_WDTS]; | ||
40 | IMXFECState eth; | ||
41 | MemoryRegion rom; | ||
42 | MemoryRegion caam; | ||
43 | diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/arm/fsl-imx6.c | ||
46 | +++ b/hw/arm/fsl-imx6.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_init(Object *obj) | ||
48 | sysbus_init_child_obj(obj, name, &s->spi[i], sizeof(s->spi[i]), | ||
49 | TYPE_IMX_SPI); | ||
50 | } | ||
51 | + for (i = 0; i < FSL_IMX6_NUM_WDTS; i++) { | ||
52 | + snprintf(name, NAME_SIZE, "wdt%d", i); | ||
53 | + sysbus_init_child_obj(obj, name, &s->wdt[i], sizeof(s->wdt[i]), | ||
54 | + TYPE_IMX2_WDT); | ||
55 | + } | ||
56 | + | ||
57 | |||
58 | sysbus_init_child_obj(obj, "eth", &s->eth, sizeof(s->eth), TYPE_IMX_ENET); | ||
59 | } | ||
60 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
61 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
62 | FSL_IMX6_ENET_MAC_1588_IRQ)); | ||
63 | |||
64 | + /* | ||
65 | + * Watchdog | ||
66 | + */ | ||
67 | + for (i = 0; i < FSL_IMX6_NUM_WDTS; i++) { | ||
68 | + static const hwaddr FSL_IMX6_WDOGn_ADDR[FSL_IMX6_NUM_WDTS] = { | ||
69 | + FSL_IMX6_WDOG1_ADDR, | ||
70 | + FSL_IMX6_WDOG2_ADDR, | ||
71 | + }; | ||
72 | + | ||
73 | + object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized", | ||
74 | + &error_abort); | ||
75 | + | ||
76 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, FSL_IMX6_WDOGn_ADDR[i]); | ||
77 | + } | ||
78 | + | ||
79 | /* ROM memory */ | ||
80 | memory_region_init_rom(&s->rom, NULL, "imx6.rom", | ||
81 | FSL_IMX6_ROM_SIZE, &err); | ||
82 | -- | ||
83 | 2.20.1 | ||
84 | |||
85 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Heyi Guo <guoheyi@huawei.com> | ||
1 | 2 | ||
3 | We are going to change ARM virt ACPI DSDT table, which will cause make | ||
4 | check to fail, so temporarily add related golden masters to ignore | ||
5 | list. | ||
6 | |||
7 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
8 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
9 | Message-id: 20200204014325.16279-2-guoheyi@huawei.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ | ||
13 | 1 file changed, 3 insertions(+) | ||
14 | |||
15 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | ||
18 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | ||
19 | @@ -1 +1,4 @@ | ||
20 | /* List of comma-separated changed AML files to ignore */ | ||
21 | +"tests/data/acpi/virt/DSDT", | ||
22 | +"tests/data/acpi/virt/DSDT.memhp", | ||
23 | +"tests/data/acpi/virt/DSDT.numamem", | ||
24 | -- | ||
25 | 2.20.1 | ||
26 | |||
27 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Heyi Guo <guoheyi@huawei.com> | ||
1 | 2 | ||
3 | The sub device "RP0" under PCI0 in ACPI/DSDT does not contain any | ||
4 | method or property other than "_ADR", so it is safe to remove it. | ||
5 | |||
6 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
7 | Acked-by: "Michael S. Tsirkin" <mst@redhat.com> | ||
8 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
9 | Message-id: 20200204014325.16279-3-guoheyi@huawei.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/virt-acpi-build.c | 4 ---- | ||
13 | 1 file changed, 4 deletions(-) | ||
14 | |||
15 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/virt-acpi-build.c | ||
18 | +++ b/hw/arm/virt-acpi-build.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
20 | aml_append(method, aml_return(buf)); | ||
21 | aml_append(dev, method); | ||
22 | |||
23 | - Aml *dev_rp0 = aml_device("%s", "RP0"); | ||
24 | - aml_append(dev_rp0, aml_name_decl("_ADR", aml_int(0))); | ||
25 | - aml_append(dev, dev_rp0); | ||
26 | - | ||
27 | Aml *dev_res0 = aml_device("%s", "RES0"); | ||
28 | aml_append(dev_res0, aml_name_decl("_HID", aml_string("PNP0C02"))); | ||
29 | crs = aml_resource_template(); | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Heyi Guo <guoheyi@huawei.com> | ||
1 | 2 | ||
3 | According to ACPI spec, _ADR should be used for device on a bus that | ||
4 | has a standard enumeration algorithm, but not for device which is on | ||
5 | system bus and must be enumerated by OSPM. And it is not recommended | ||
6 | to contain both _HID and _ADR in a single device. | ||
7 | |||
8 | See ACPI 6.3, section 6.1, top of page 343: | ||
9 | |||
10 | A device object must contain either an _HID object or an _ADR object, | ||
11 | but should not contain both. | ||
12 | |||
13 | (https://uefi.org/sites/default/files/resources/ACPI_6_3_May16.pdf) | ||
14 | |||
15 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
16 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
17 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
18 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
19 | Message-id: 20200204014325.16279-4-guoheyi@huawei.com | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | --- | ||
22 | hw/arm/virt-acpi-build.c | 8 -------- | ||
23 | 1 file changed, 8 deletions(-) | ||
24 | |||
25 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/arm/virt-acpi-build.c | ||
28 | +++ b/hw/arm/virt-acpi-build.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, | ||
30 | AML_EXCLUSIVE, &uart_irq, 1)); | ||
31 | aml_append(dev, aml_name_decl("_CRS", crs)); | ||
32 | |||
33 | - /* The _ADR entry is used to link this device to the UART described | ||
34 | - * in the SPCR table, i.e. SPCR.base_address.address == _ADR. | ||
35 | - */ | ||
36 | - aml_append(dev, aml_name_decl("_ADR", aml_int(uart_memmap->base))); | ||
37 | - | ||
38 | aml_append(scope, dev); | ||
39 | } | ||
40 | |||
41 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
42 | aml_append(dev, aml_name_decl("_CID", aml_string("PNP0A03"))); | ||
43 | aml_append(dev, aml_name_decl("_SEG", aml_int(0))); | ||
44 | aml_append(dev, aml_name_decl("_BBN", aml_int(0))); | ||
45 | - aml_append(dev, aml_name_decl("_ADR", aml_int(0))); | ||
46 | aml_append(dev, aml_name_decl("_UID", aml_string("PCI0"))); | ||
47 | aml_append(dev, aml_name_decl("_STR", aml_unicode("PCIe 0 Device"))); | ||
48 | aml_append(dev, aml_name_decl("_CCA", aml_int(1))); | ||
49 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, | ||
50 | { | ||
51 | Aml *dev = aml_device("GPO0"); | ||
52 | aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0061"))); | ||
53 | - aml_append(dev, aml_name_decl("_ADR", aml_int(0))); | ||
54 | aml_append(dev, aml_name_decl("_UID", aml_int(0))); | ||
55 | |||
56 | Aml *crs = aml_resource_template(); | ||
57 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_power_button(Aml *scope) | ||
58 | { | ||
59 | Aml *dev = aml_device(ACPI_POWER_BUTTON_DEVICE); | ||
60 | aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); | ||
61 | - aml_append(dev, aml_name_decl("_ADR", aml_int(0))); | ||
62 | aml_append(dev, aml_name_decl("_UID", aml_int(0))); | ||
63 | aml_append(scope, dev); | ||
64 | } | ||
65 | -- | ||
66 | 2.20.1 | ||
67 | |||
68 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Heyi Guo <guoheyi@huawei.com> | ||
1 | 2 | ||
3 | The address field in each _PRT mapping package should be constructed | ||
4 | with high word for device# and low word for function#, so it is wrong | ||
5 | to use bus_no as the high word. The existing code adds a bunch useless | ||
6 | entries with device #s above 31. Enumerate all possible slots | ||
7 | (i.e. PCI_SLOT_MAX) instead. | ||
8 | |||
9 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
10 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
11 | Message-id: 20200204014325.16279-5-guoheyi@huawei.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/virt-acpi-build.c | 10 +++++----- | ||
15 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/virt-acpi-build.c | ||
20 | +++ b/hw/arm/virt-acpi-build.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
22 | { | ||
23 | int ecam_id = VIRT_ECAM_ID(highmem_ecam); | ||
24 | Aml *method, *crs, *ifctx, *UUID, *ifctx1, *elsectx, *buf; | ||
25 | - int i, bus_no; | ||
26 | + int i, slot_no; | ||
27 | hwaddr base_mmio = memmap[VIRT_PCIE_MMIO].base; | ||
28 | hwaddr size_mmio = memmap[VIRT_PCIE_MMIO].size; | ||
29 | hwaddr base_pio = memmap[VIRT_PCIE_PIO].base; | ||
30 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
31 | aml_append(dev, aml_name_decl("_CCA", aml_int(1))); | ||
32 | |||
33 | /* Declare the PCI Routing Table. */ | ||
34 | - Aml *rt_pkg = aml_varpackage(nr_pcie_buses * PCI_NUM_PINS); | ||
35 | - for (bus_no = 0; bus_no < nr_pcie_buses; bus_no++) { | ||
36 | + Aml *rt_pkg = aml_varpackage(PCI_SLOT_MAX * PCI_NUM_PINS); | ||
37 | + for (slot_no = 0; slot_no < PCI_SLOT_MAX; slot_no++) { | ||
38 | for (i = 0; i < PCI_NUM_PINS; i++) { | ||
39 | - int gsi = (i + bus_no) % PCI_NUM_PINS; | ||
40 | + int gsi = (i + slot_no) % PCI_NUM_PINS; | ||
41 | Aml *pkg = aml_package(4); | ||
42 | - aml_append(pkg, aml_int((bus_no << 16) | 0xFFFF)); | ||
43 | + aml_append(pkg, aml_int((slot_no << 16) | 0xFFFF)); | ||
44 | aml_append(pkg, aml_int(i)); | ||
45 | aml_append(pkg, aml_name("GSI%d", gsi)); | ||
46 | aml_append(pkg, aml_int(0)); | ||
47 | -- | ||
48 | 2.20.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Heyi Guo <guoheyi@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | To comply with Spec v1.10 (and 2.00, 3.01): | 3 | Using _UID of 0 for all PCI interrupt link devices absolutely violates |
4 | the spec. Simply increase one by one. | ||
4 | 5 | ||
5 | . TRAN_SPEED | 6 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> |
6 | 7 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | |
7 | for current SD Memory Cards that field must be always 0_0110_010b (032h) which is | 8 | Message-id: 20200204014325.16279-6-guoheyi@huawei.com |
8 | equal to 25MHz - the mandatory maximum operating frequency of SD Memory Card. | ||
9 | |||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
12 | Message-id: 20180215221325.7611-4-f4bug@amsat.org | ||
13 | [PMM: fixed comment indent] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 10 | --- |
16 | hw/sd/sd.c | 2 +- | 11 | hw/arm/virt-acpi-build.c | 2 +- |
17 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
18 | 13 | ||
19 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 14 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c |
20 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/sd/sd.c | 16 | --- a/hw/arm/virt-acpi-build.c |
22 | +++ b/hw/sd/sd.c | 17 | +++ b/hw/arm/virt-acpi-build.c |
23 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | 18 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, |
24 | sd->csd[0] = 0x00; /* CSD structure */ | 19 | uint32_t irqs = irq + i; |
25 | sd->csd[1] = 0x26; /* Data read access-time-1 */ | 20 | Aml *dev_gsi = aml_device("GSI%d", i); |
26 | sd->csd[2] = 0x00; /* Data read access-time-2 */ | 21 | aml_append(dev_gsi, aml_name_decl("_HID", aml_string("PNP0C0F"))); |
27 | - sd->csd[3] = 0x5a; /* Max. data transfer rate */ | 22 | - aml_append(dev_gsi, aml_name_decl("_UID", aml_int(0))); |
28 | + sd->csd[3] = 0x32; /* Max. data transfer rate: 25 MHz */ | 23 | + aml_append(dev_gsi, aml_name_decl("_UID", aml_int(i))); |
29 | sd->csd[4] = 0x5f; /* Card Command Classes */ | 24 | crs = aml_resource_template(); |
30 | sd->csd[5] = 0x50 | /* Max. read data block length */ | 25 | aml_append(crs, |
31 | HWBLOCK_SHIFT; | 26 | aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, |
32 | -- | 27 | -- |
33 | 2.16.1 | 28 | 2.20.1 |
34 | 29 | ||
35 | 30 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Heyi Guo <guoheyi@huawei.com> | ||
1 | 2 | ||
3 | The original code defines a named object for the resource template but | ||
4 | then returns the resource template object itself; the resulted output | ||
5 | is like below: | ||
6 | |||
7 | Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings | ||
8 | { | ||
9 | Name (RBUF, ResourceTemplate () | ||
10 | { | ||
11 | WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
12 | 0x0000, // Granularity | ||
13 | 0x0000, // Range Minimum | ||
14 | 0x00FF, // Range Maximum | ||
15 | 0x0000, // Translation Offset | ||
16 | 0x0100, // Length | ||
17 | ,, ) | ||
18 | ...... | ||
19 | }) | ||
20 | Return (ResourceTemplate () | ||
21 | { | ||
22 | WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
23 | 0x0000, // Granularity | ||
24 | 0x0000, // Range Minimum | ||
25 | 0x00FF, // Range Maximum | ||
26 | 0x0000, // Translation Offset | ||
27 | 0x0100, // Length | ||
28 | ,, ) | ||
29 | ...... | ||
30 | }) | ||
31 | } | ||
32 | |||
33 | So the named object "RBUF" is actually useless. The more natural way | ||
34 | is to return RBUF instead, or simply drop RBUF definition. | ||
35 | |||
36 | Choose the latter one to simplify the code. | ||
37 | |||
38 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
39 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
40 | Message-id: 20200204014325.16279-7-guoheyi@huawei.com | ||
41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
42 | --- | ||
43 | hw/arm/virt-acpi-build.c | 1 - | ||
44 | 1 file changed, 1 deletion(-) | ||
45 | |||
46 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/virt-acpi-build.c | ||
49 | +++ b/hw/arm/virt-acpi-build.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
51 | size_mmio_high)); | ||
52 | } | ||
53 | |||
54 | - aml_append(method, aml_name_decl("RBUF", rbuf)); | ||
55 | aml_append(method, aml_return(rbuf)); | ||
56 | aml_append(dev, method); | ||
57 | |||
58 | -- | ||
59 | 2.20.1 | ||
60 | |||
61 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Heyi Guo <guoheyi@huawei.com> | |
2 | |||
3 | Differences between disassembled ASL files: | ||
4 | |||
5 | @@ -XXX,XX +XXX,XX @@ | ||
6 | * | ||
7 | * Disassembling to symbolic ASL+ operators | ||
8 | * | ||
9 | - * Disassembly of DSDT, Thu Jan 23 16:00:04 2020 | ||
10 | + * Disassembly of DSDT.new, Thu Jan 23 16:47:12 2020 | ||
11 | * | ||
12 | * Original Table Header: | ||
13 | * Signature "DSDT" | ||
14 | - * Length 0x0000481E (18462) | ||
15 | + * Length 0x000014BB (5307) | ||
16 | * Revision 0x02 | ||
17 | - * Checksum 0x60 | ||
18 | + * Checksum 0xD1 | ||
19 | * OEM ID "BOCHS " | ||
20 | * OEM Table ID "BXPCDSDT" | ||
21 | * OEM Revision 0x00000001 (1) | ||
22 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
23 | 0x00000021, | ||
24 | } | ||
25 | }) | ||
26 | - Name (_ADR, 0x09000000) // _ADR: Address | ||
27 | } | ||
28 | |||
29 | Device (FLS0) | ||
30 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
31 | Name (_CID, "PNP0A03" /* PCI Bus */) // _CID: Compatible ID | ||
32 | Name (_SEG, Zero) // _SEG: PCI Segment | ||
33 | Name (_BBN, Zero) // _BBN: BIOS Bus Number | ||
34 | - Name (_ADR, Zero) // _ADR: Address | ||
35 | Name (_UID, "PCI0") // _UID: Unique ID | ||
36 | Name (_STR, Unicode ("PCIe 0 Device")) // _STR: Description String | ||
37 | Name (_CCA, One) // _CCA: Cache Coherency Attribute | ||
38 | - Name (_PRT, Package (0x0400) // _PRT: PCI Routing Table | ||
39 | + Name (_PRT, Package (0x80) // _PRT: PCI Routing Table | ||
40 | { | ||
41 | Package (0x04) | ||
42 | { | ||
43 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
44 | 0x03, | ||
45 | GSI2, | ||
46 | Zero | ||
47 | - }, | ||
48 | - | ||
49 | - Package (0x04) | ||
50 | - { | ||
51 | - 0x0020FFFF, | ||
52 | - Zero, | ||
53 | - GSI0, | ||
54 | - Zero | ||
55 | - }, | ||
56 | - | ||
57 | - *Omit the other (4 * (256 - 32) - 2) packages* | ||
58 | - | ||
59 | - Package (0x04) | ||
60 | - { | ||
61 | - 0x00FFFFFF, | ||
62 | - 0x03, | ||
63 | - GSI2, | ||
64 | - Zero | ||
65 | } | ||
66 | }) | ||
67 | Device (GSI0) | ||
68 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
69 | Device (GSI1) | ||
70 | { | ||
71 | Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */) // _HID: Hardware ID | ||
72 | - Name (_UID, Zero) // _UID: Unique ID | ||
73 | + Name (_UID, One) // _UID: Unique ID | ||
74 | Name (_PRS, ResourceTemplate () // _PRS: Possible Resource Settings | ||
75 | { | ||
76 | Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) | ||
77 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
78 | Device (GSI2) | ||
79 | { | ||
80 | Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */) // _HID: Hardware ID | ||
81 | - Name (_UID, Zero) // _UID: Unique ID | ||
82 | + Name (_UID, 0x02) // _UID: Unique ID | ||
83 | Name (_PRS, ResourceTemplate () // _PRS: Possible Resource Settings | ||
84 | { | ||
85 | Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) | ||
86 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
87 | Device (GSI3) | ||
88 | { | ||
89 | Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */) // _HID: Hardware ID | ||
90 | - Name (_UID, Zero) // _UID: Unique ID | ||
91 | + Name (_UID, 0x03) // _UID: Unique ID | ||
92 | Name (_PRS, ResourceTemplate () // _PRS: Possible Resource Settings | ||
93 | { | ||
94 | Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) | ||
95 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
96 | |||
97 | Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings | ||
98 | { | ||
99 | - Name (RBUF, ResourceTemplate () | ||
100 | - { | ||
101 | - WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
102 | - 0x0000, // Granularity | ||
103 | - 0x0000, // Range Minimum | ||
104 | - 0x00FF, // Range Maximum | ||
105 | - 0x0000, // Translation Offset | ||
106 | - 0x0100, // Length | ||
107 | - ,, ) | ||
108 | - DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, | ||
109 | - 0x00000000, // Granularity | ||
110 | - 0x10000000, // Range Minimum | ||
111 | - 0x3EFEFFFF, // Range Maximum | ||
112 | - 0x00000000, // Translation Offset | ||
113 | - 0x2EFF0000, // Length | ||
114 | - ,, , AddressRangeMemory, TypeStatic) | ||
115 | - DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, | ||
116 | - 0x00000000, // Granularity | ||
117 | - 0x00000000, // Range Minimum | ||
118 | - 0x0000FFFF, // Range Maximum | ||
119 | - 0x3EFF0000, // Translation Offset | ||
120 | - 0x00010000, // Length | ||
121 | - ,, , TypeStatic, DenseTranslation) | ||
122 | - QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, | ||
123 | - 0x0000000000000000, // Granularity | ||
124 | - 0x0000008000000000, // Range Minimum | ||
125 | - 0x000000FFFFFFFFFF, // Range Maximum | ||
126 | - 0x0000000000000000, // Translation Offset | ||
127 | - 0x0000008000000000, // Length | ||
128 | - ,, , AddressRangeMemory, TypeStatic) | ||
129 | - }) | ||
130 | Return (ResourceTemplate () | ||
131 | { | ||
132 | WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
133 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
134 | }) | ||
135 | } | ||
136 | |||
137 | - Device (RP0) | ||
138 | - { | ||
139 | - Name (_ADR, Zero) // _ADR: Address | ||
140 | - } | ||
141 | - | ||
142 | Device (RES0) | ||
143 | { | ||
144 | Name (_HID, "PNP0C02" /* PNP Motherboard Resources */) // _HID: Hardware ID | ||
145 | @@ -XXX,XX +XXX,XX @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPCDSDT", 0x00000001) | ||
146 | Device (PWRB) | ||
147 | { | ||
148 | Name (_HID, "PNP0C0C" /* Power Button Device */) // _HID: Hardware ID | ||
149 | - Name (_ADR, Zero) // _ADR: Address | ||
150 | Name (_UID, Zero) // _UID: Unique ID | ||
151 | } | ||
152 | } | ||
153 | |||
154 | The differences between the two versions of DSDT.memhp are almost the | ||
155 | same as the above, except for total length and checksum. | ||
156 | |||
157 | DSDT.numamem binary is just the same with DSDT on virt machine, so we | ||
158 | don't show the differences again. | ||
159 | |||
160 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
161 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
162 | Message-id: 20200204014325.16279-8-guoheyi@huawei.com | ||
163 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
164 | --- | ||
165 | tests/qtest/bios-tables-test-allowed-diff.h | 3 --- | ||
166 | tests/data/acpi/virt/DSDT | Bin 18462 -> 5307 bytes | ||
167 | tests/data/acpi/virt/DSDT.memhp | Bin 19799 -> 6644 bytes | ||
168 | tests/data/acpi/virt/DSDT.numamem | Bin 18462 -> 5307 bytes | ||
169 | 4 files changed, 3 deletions(-) | ||
170 | |||
171 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
172 | index XXXXXXX..XXXXXXX 100644 | ||
173 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | ||
174 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | ||
175 | @@ -1,4 +1 @@ | ||
176 | /* List of comma-separated changed AML files to ignore */ | ||
177 | -"tests/data/acpi/virt/DSDT", | ||
178 | -"tests/data/acpi/virt/DSDT.memhp", | ||
179 | -"tests/data/acpi/virt/DSDT.numamem", | ||
180 | diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/virt/DSDT | ||
181 | index XXXXXXX..XXXXXXX 100644 | ||
182 | GIT binary patch | ||
183 | delta 156 | ||
184 | zcmbO?fpNDcmrJlq$Zin^2BwP>xulufJQ*iyC^K43^tIeLL4lLWeZ}O>oO+X=b6T<Z | ||
185 | z6mvCfR_C%{pDgc^#>hCi&BajKi^V<I(}*M9!_$Q~z%RhS*}#o~BR<sAg^OwOMVP!X | ||
186 | lHhJdBGOmtnjvVpMLBX3Jy81CrwsAkqC^^YPgaxRb0RT`TDiQzy | ||
187 | |||
188 | literal 18462 | ||
189 | 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 | ||
265 | A00000 | ||
266 | |||
267 | diff --git a/tests/data/acpi/virt/DSDT.memhp b/tests/data/acpi/virt/DSDT.memhp | ||
268 | index XXXXXXX..XXXXXXX 100644 | ||
269 | GIT binary patch | ||
270 | delta 173 | ||
271 | zcmcaUi}8ywmrJlq$QMZl2ByY|T++<_a~LOTC^K43^tIeLL4lLWeZ}O>oO+X=b6T<Z | ||
272 | z6mvCfR_C%{pDgc^#>hCi&BajKi^V<I(}*M9!_$Q~z%RhS*}#o~BR<sAg^OwOMVP!X | ||
273 | pHhJdBGOmtnjvVpMLBX3Jy81D0wsHT%Dk&Kd9^{0q-Wg&Z0|3#tFC_o~ | ||
274 | |||
275 | literal 19799 | ||
276 | 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 | ||
365 | DDbP3` | ||
366 | |||
367 | diff --git a/tests/data/acpi/virt/DSDT.numamem b/tests/data/acpi/virt/DSDT.numamem | ||
368 | index XXXXXXX..XXXXXXX 100644 | ||
369 | GIT binary patch | ||
370 | delta 156 | ||
371 | zcmbO?fpNDcmrJlq$Zin^2BwP>xulufJQ*iyC^K43^tIeLL4lLWeZ}O>oO+X=b6T<Z | ||
372 | z6mvCfR_C%{pDgc^#>hCi&BajKi^V<I(}*M9!_$Q~z%RhS*}#o~BR<sAg^OwOMVP!X | ||
373 | lHhJdBGOmtnjvVpMLBX3Jy81CrwsAkqC^^YPgaxRb0RT`TDiQzy | ||
374 | |||
375 | literal 18462 | ||
376 | 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 | ||
452 | A00000 | ||
453 | |||
454 | -- | ||
455 | 2.20.1 | ||
456 | |||
457 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Use a common predicate for querying stage1-ness. |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | |
5 | Message-id: 20180215221325.7611-13-f4bug@amsat.org | 5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200208125816.14954-2-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | hw/sd/sd.c | 29 ++++++++++++++++++++++++++--- | 11 | target/arm/internals.h | 18 ++++++++++++++++++ |
9 | 1 file changed, 26 insertions(+), 3 deletions(-) | 12 | target/arm/helper.c | 8 +++----- |
13 | 2 files changed, 21 insertions(+), 5 deletions(-) | ||
10 | 14 | ||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 15 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sd.c | 17 | --- a/target/arm/internals.h |
14 | +++ b/hw/sd/sd.c | 18 | +++ b/target/arm/internals.h |
15 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 19 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) |
16 | 20 | ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env); | |
17 | /* Application specific commands (Class 8) */ | 21 | #endif |
18 | case 55: /* CMD55: APP_CMD */ | 22 | |
19 | - if (sd->rca != rca) | 23 | +/** |
20 | - return sd_r0; | 24 | + * arm_mmu_idx_is_stage1_of_2: |
21 | - | 25 | + * @mmu_idx: The ARMMMUIdx to test |
22 | + if (!sd->spi) { | 26 | + * |
23 | + if (sd->rca != rca) { | 27 | + * Return true if @mmu_idx is a NOTLB mmu_idx that is the |
24 | + return sd_r0; | 28 | + * first stage of a two stage regime. |
25 | + } | 29 | + */ |
26 | + } | 30 | +static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx) |
27 | sd->expecting_acmd = true; | 31 | +{ |
28 | sd->card_status |= APP_CMD; | 32 | + switch (mmu_idx) { |
29 | return sd_r1; | 33 | + case ARMMMUIdx_Stage1_E0: |
30 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 34 | + case ARMMMUIdx_Stage1_E1: |
35 | + return true; | ||
36 | + default: | ||
37 | + return false; | ||
38 | + } | ||
39 | +} | ||
40 | + | ||
41 | /* | ||
42 | * Parameters of a given virtual address, as extracted from the | ||
43 | * translation control register (TCR) for a given regime. | ||
44 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/helper.c | ||
47 | +++ b/target/arm/helper.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | ||
49 | bool take_exc = false; | ||
50 | |||
51 | if (fi.s1ptw && current_el == 1 && !arm_is_secure(env) | ||
52 | - && (mmu_idx == ARMMMUIdx_Stage1_E1 || | ||
53 | - mmu_idx == ARMMMUIdx_Stage1_E0)) { | ||
54 | + && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { | ||
55 | /* | ||
56 | * Synchronous stage 2 fault on an access made as part of the | ||
57 | * translation table walk for AT S1E0* or AT S1E1* insn | ||
58 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env, | ||
31 | } | 59 | } |
32 | break; | ||
33 | |||
34 | + case 58: /* CMD58: READ_OCR (SPI) */ | ||
35 | + if (!sd->spi) { | ||
36 | + goto bad_cmd; | ||
37 | + } | ||
38 | + return sd_r3; | ||
39 | + | ||
40 | + case 59: /* CMD59: CRC_ON_OFF (SPI) */ | ||
41 | + if (!sd->spi) { | ||
42 | + goto bad_cmd; | ||
43 | + } | ||
44 | + goto unimplemented_spi_cmd; | ||
45 | + | ||
46 | default: | ||
47 | bad_cmd: | ||
48 | qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); | ||
49 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | ||
50 | sd->card_status |= APP_CMD; | ||
51 | switch (req.cmd) { | ||
52 | case 6: /* ACMD6: SET_BUS_WIDTH */ | ||
53 | + if (sd->spi) { | ||
54 | + goto unimplemented_spi_cmd; | ||
55 | + } | ||
56 | switch (sd->state) { | ||
57 | case sd_transfer_state: | ||
58 | sd->sd_status[0] &= 0x3f; | ||
59 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | ||
60 | default: | ||
61 | /* Fall back to standard commands. */ | ||
62 | return sd_normal_command(sd, req); | ||
63 | + | ||
64 | + unimplemented_spi_cmd: | ||
65 | + /* Commands that are recognised but not yet implemented in SPI mode. */ | ||
66 | + qemu_log_mask(LOG_UNIMP, "SD: CMD%i not implemented in SPI mode\n", | ||
67 | + req.cmd); | ||
68 | + return sd_illegal; | ||
69 | } | 60 | } |
70 | 61 | ||
71 | qemu_log_mask(LOG_GUEST_ERROR, "SD: ACMD%i in a wrong state\n", req.cmd); | 62 | - if ((env->cp15.hcr_el2 & HCR_DC) && |
63 | - (mmu_idx == ARMMMUIdx_Stage1_E0 || mmu_idx == ARMMMUIdx_Stage1_E1)) { | ||
64 | + if ((env->cp15.hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { | ||
65 | /* HCR.DC means SCTLR_EL1.M behaves as 0 */ | ||
66 | return true; | ||
67 | } | ||
68 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
69 | hwaddr addr, MemTxAttrs txattrs, | ||
70 | ARMMMUFaultInfo *fi) | ||
71 | { | ||
72 | - if ((mmu_idx == ARMMMUIdx_Stage1_E0 || mmu_idx == ARMMMUIdx_Stage1_E1) && | ||
73 | + if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && | ||
74 | !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { | ||
75 | target_ulong s2size; | ||
76 | hwaddr s2pa; | ||
72 | -- | 77 | -- |
73 | 2.16.1 | 78 | 2.20.1 |
74 | 79 | ||
75 | 80 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Richard Henderson <richard.henderson@linaro.org> | |
2 | |||
3 | To implement PAN, we will want to swap, for short periods | ||
4 | of time, to a different privileged mmu_idx. In addition, | ||
5 | we cannot do this with flushing alone, because the AT* | ||
6 | instructions have both PAN and PAN-less versions. | ||
7 | |||
8 | Add the ARMMMUIdx*_PAN constants where necessary next to | ||
9 | the corresponding ARMMMUIdx* constant. | ||
10 | |||
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20200208125816.14954-3-richard.henderson@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/cpu-param.h | 2 +- | ||
18 | target/arm/cpu.h | 33 ++++++++++++++------- | ||
19 | target/arm/internals.h | 9 ++++++ | ||
20 | target/arm/helper.c | 60 +++++++++++++++++++++++++++++++------- | ||
21 | target/arm/translate-a64.c | 3 ++ | ||
22 | target/arm/translate.c | 2 ++ | ||
23 | 6 files changed, 87 insertions(+), 22 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/cpu-param.h | ||
28 | +++ b/target/arm/cpu-param.h | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | # define TARGET_PAGE_BITS_MIN 10 | ||
31 | #endif | ||
32 | |||
33 | -#define NB_MMU_MODES 9 | ||
34 | +#define NB_MMU_MODES 12 | ||
35 | |||
36 | #endif | ||
37 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/cpu.h | ||
40 | +++ b/target/arm/cpu.h | ||
41 | @@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); | ||
42 | * 5. we want to be able to use the TLB for accesses done as part of a | ||
43 | * stage1 page table walk, rather than having to walk the stage2 page | ||
44 | * table over and over. | ||
45 | + * 6. we need separate EL1/EL2 mmu_idx for handling the Privileged Access | ||
46 | + * Never (PAN) bit within PSTATE. | ||
47 | * | ||
48 | * This gives us the following list of cases: | ||
49 | * | ||
50 | * NS EL0 EL1&0 stage 1+2 (aka NS PL0) | ||
51 | * NS EL1 EL1&0 stage 1+2 (aka NS PL1) | ||
52 | + * NS EL1 EL1&0 stage 1+2 +PAN | ||
53 | * NS EL0 EL2&0 | ||
54 | - * NS EL2 EL2&0 | ||
55 | + * NS EL2 EL2&0 +PAN | ||
56 | * NS EL2 (aka NS PL2) | ||
57 | * S EL0 EL1&0 (aka S PL0) | ||
58 | * S EL1 EL1&0 (not used if EL3 is 32 bit) | ||
59 | + * S EL1 EL1&0 +PAN | ||
60 | * S EL3 (aka S PL1) | ||
61 | * NS EL1&0 stage 2 | ||
62 | * | ||
63 | - * for a total of 9 different mmu_idx. | ||
64 | + * for a total of 12 different mmu_idx. | ||
65 | * | ||
66 | * R profile CPUs have an MPU, but can use the same set of MMU indexes | ||
67 | * as A profile. They only need to distinguish NS EL0 and NS EL1 (and | ||
68 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx { | ||
69 | /* | ||
70 | * A-profile. | ||
71 | */ | ||
72 | - ARMMMUIdx_E10_0 = 0 | ARM_MMU_IDX_A, | ||
73 | - ARMMMUIdx_E20_0 = 1 | ARM_MMU_IDX_A, | ||
74 | + ARMMMUIdx_E10_0 = 0 | ARM_MMU_IDX_A, | ||
75 | + ARMMMUIdx_E20_0 = 1 | ARM_MMU_IDX_A, | ||
76 | |||
77 | - ARMMMUIdx_E10_1 = 2 | ARM_MMU_IDX_A, | ||
78 | + ARMMMUIdx_E10_1 = 2 | ARM_MMU_IDX_A, | ||
79 | + ARMMMUIdx_E10_1_PAN = 3 | ARM_MMU_IDX_A, | ||
80 | |||
81 | - ARMMMUIdx_E2 = 3 | ARM_MMU_IDX_A, | ||
82 | - ARMMMUIdx_E20_2 = 4 | ARM_MMU_IDX_A, | ||
83 | + ARMMMUIdx_E2 = 4 | ARM_MMU_IDX_A, | ||
84 | + ARMMMUIdx_E20_2 = 5 | ARM_MMU_IDX_A, | ||
85 | + ARMMMUIdx_E20_2_PAN = 6 | ARM_MMU_IDX_A, | ||
86 | |||
87 | - ARMMMUIdx_SE10_0 = 5 | ARM_MMU_IDX_A, | ||
88 | - ARMMMUIdx_SE10_1 = 6 | ARM_MMU_IDX_A, | ||
89 | - ARMMMUIdx_SE3 = 7 | ARM_MMU_IDX_A, | ||
90 | + ARMMMUIdx_SE10_0 = 7 | ARM_MMU_IDX_A, | ||
91 | + ARMMMUIdx_SE10_1 = 8 | ARM_MMU_IDX_A, | ||
92 | + ARMMMUIdx_SE10_1_PAN = 9 | ARM_MMU_IDX_A, | ||
93 | + ARMMMUIdx_SE3 = 10 | ARM_MMU_IDX_A, | ||
94 | |||
95 | - ARMMMUIdx_Stage2 = 8 | ARM_MMU_IDX_A, | ||
96 | + ARMMMUIdx_Stage2 = 11 | ARM_MMU_IDX_A, | ||
97 | |||
98 | /* | ||
99 | * These are not allocated TLBs and are used only for AT system | ||
100 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx { | ||
101 | */ | ||
102 | ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB, | ||
103 | ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB, | ||
104 | + ARMMMUIdx_Stage1_E1_PAN = 2 | ARM_MMU_IDX_NOTLB, | ||
105 | |||
106 | /* | ||
107 | * M-profile. | ||
108 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdxBit { | ||
109 | TO_CORE_BIT(E10_0), | ||
110 | TO_CORE_BIT(E20_0), | ||
111 | TO_CORE_BIT(E10_1), | ||
112 | + TO_CORE_BIT(E10_1_PAN), | ||
113 | TO_CORE_BIT(E2), | ||
114 | TO_CORE_BIT(E20_2), | ||
115 | + TO_CORE_BIT(E20_2_PAN), | ||
116 | TO_CORE_BIT(SE10_0), | ||
117 | TO_CORE_BIT(SE10_1), | ||
118 | + TO_CORE_BIT(SE10_1_PAN), | ||
119 | TO_CORE_BIT(SE3), | ||
120 | TO_CORE_BIT(Stage2), | ||
121 | |||
122 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/target/arm/internals.h | ||
125 | +++ b/target/arm/internals.h | ||
126 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx) | ||
127 | switch (mmu_idx) { | ||
128 | case ARMMMUIdx_Stage1_E0: | ||
129 | case ARMMMUIdx_Stage1_E1: | ||
130 | + case ARMMMUIdx_Stage1_E1_PAN: | ||
131 | case ARMMMUIdx_E10_0: | ||
132 | case ARMMMUIdx_E10_1: | ||
133 | + case ARMMMUIdx_E10_1_PAN: | ||
134 | case ARMMMUIdx_E20_0: | ||
135 | case ARMMMUIdx_E20_2: | ||
136 | + case ARMMMUIdx_E20_2_PAN: | ||
137 | case ARMMMUIdx_SE10_0: | ||
138 | case ARMMMUIdx_SE10_1: | ||
139 | + case ARMMMUIdx_SE10_1_PAN: | ||
140 | return true; | ||
141 | default: | ||
142 | return false; | ||
143 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
144 | switch (mmu_idx) { | ||
145 | case ARMMMUIdx_E10_0: | ||
146 | case ARMMMUIdx_E10_1: | ||
147 | + case ARMMMUIdx_E10_1_PAN: | ||
148 | case ARMMMUIdx_E20_0: | ||
149 | case ARMMMUIdx_E20_2: | ||
150 | + case ARMMMUIdx_E20_2_PAN: | ||
151 | case ARMMMUIdx_Stage1_E0: | ||
152 | case ARMMMUIdx_Stage1_E1: | ||
153 | + case ARMMMUIdx_Stage1_E1_PAN: | ||
154 | case ARMMMUIdx_E2: | ||
155 | case ARMMMUIdx_Stage2: | ||
156 | case ARMMMUIdx_MPrivNegPri: | ||
157 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
158 | case ARMMMUIdx_SE3: | ||
159 | case ARMMMUIdx_SE10_0: | ||
160 | case ARMMMUIdx_SE10_1: | ||
161 | + case ARMMMUIdx_SE10_1_PAN: | ||
162 | case ARMMMUIdx_MSPrivNegPri: | ||
163 | case ARMMMUIdx_MSUserNegPri: | ||
164 | case ARMMMUIdx_MSPriv: | ||
165 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx) | ||
166 | switch (mmu_idx) { | ||
167 | case ARMMMUIdx_Stage1_E0: | ||
168 | case ARMMMUIdx_Stage1_E1: | ||
169 | + case ARMMMUIdx_Stage1_E1_PAN: | ||
170 | return true; | ||
171 | default: | ||
172 | return false; | ||
173 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/target/arm/helper.c | ||
176 | +++ b/target/arm/helper.c | ||
177 | @@ -XXX,XX +XXX,XX @@ static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
178 | |||
179 | tlb_flush_by_mmuidx(cs, | ||
180 | ARMMMUIdxBit_E10_1 | | ||
181 | + ARMMMUIdxBit_E10_1_PAN | | ||
182 | ARMMMUIdxBit_E10_0 | | ||
183 | ARMMMUIdxBit_Stage2); | ||
184 | } | ||
185 | @@ -XXX,XX +XXX,XX @@ static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
186 | |||
187 | tlb_flush_by_mmuidx_all_cpus_synced(cs, | ||
188 | ARMMMUIdxBit_E10_1 | | ||
189 | + ARMMMUIdxBit_E10_1_PAN | | ||
190 | ARMMMUIdxBit_E10_0 | | ||
191 | ARMMMUIdxBit_Stage2); | ||
192 | } | ||
193 | @@ -XXX,XX +XXX,XX @@ static int gt_phys_redir_timeridx(CPUARMState *env) | ||
194 | switch (arm_mmu_idx(env)) { | ||
195 | case ARMMMUIdx_E20_0: | ||
196 | case ARMMMUIdx_E20_2: | ||
197 | + case ARMMMUIdx_E20_2_PAN: | ||
198 | return GTIMER_HYP; | ||
199 | default: | ||
200 | return GTIMER_PHYS; | ||
201 | @@ -XXX,XX +XXX,XX @@ static int gt_virt_redir_timeridx(CPUARMState *env) | ||
202 | switch (arm_mmu_idx(env)) { | ||
203 | case ARMMMUIdx_E20_0: | ||
204 | case ARMMMUIdx_E20_2: | ||
205 | + case ARMMMUIdx_E20_2_PAN: | ||
206 | return GTIMER_HYPVIRT; | ||
207 | default: | ||
208 | return GTIMER_VIRT; | ||
209 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | ||
210 | format64 = arm_s1_regime_using_lpae_format(env, mmu_idx); | ||
211 | |||
212 | if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
213 | - if (mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_E10_1) { | ||
214 | + if (mmu_idx == ARMMMUIdx_E10_0 || | ||
215 | + mmu_idx == ARMMMUIdx_E10_1 || | ||
216 | + mmu_idx == ARMMMUIdx_E10_1_PAN) { | ||
217 | format64 |= env->cp15.hcr_el2 & (HCR_VM | HCR_DC); | ||
218 | } else { | ||
219 | format64 |= arm_current_el(env) == 2; | ||
220 | @@ -XXX,XX +XXX,XX @@ static void vmsa_tcr_ttbr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
221 | if (extract64(raw_read(env, ri) ^ value, 48, 16) && | ||
222 | (arm_hcr_el2_eff(env) & HCR_E2H)) { | ||
223 | tlb_flush_by_mmuidx(env_cpu(env), | ||
224 | - ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_0); | ||
225 | + ARMMMUIdxBit_E20_2 | | ||
226 | + ARMMMUIdxBit_E20_2_PAN | | ||
227 | + ARMMMUIdxBit_E20_0); | ||
228 | } | ||
229 | raw_write(env, ri, value); | ||
230 | } | ||
231 | @@ -XXX,XX +XXX,XX @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
232 | if (raw_read(env, ri) != value) { | ||
233 | tlb_flush_by_mmuidx(cs, | ||
234 | ARMMMUIdxBit_E10_1 | | ||
235 | + ARMMMUIdxBit_E10_1_PAN | | ||
236 | ARMMMUIdxBit_E10_0 | | ||
237 | ARMMMUIdxBit_Stage2); | ||
238 | raw_write(env, ri, value); | ||
239 | @@ -XXX,XX +XXX,XX @@ static int vae1_tlbmask(CPUARMState *env) | ||
240 | { | ||
241 | /* Since we exclude secure first, we may read HCR_EL2 directly. */ | ||
242 | if (arm_is_secure_below_el3(env)) { | ||
243 | - return ARMMMUIdxBit_SE10_1 | ARMMMUIdxBit_SE10_0; | ||
244 | + return ARMMMUIdxBit_SE10_1 | | ||
245 | + ARMMMUIdxBit_SE10_1_PAN | | ||
246 | + ARMMMUIdxBit_SE10_0; | ||
247 | } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) | ||
248 | == (HCR_E2H | HCR_TGE)) { | ||
249 | - return ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_0; | ||
250 | + return ARMMMUIdxBit_E20_2 | | ||
251 | + ARMMMUIdxBit_E20_2_PAN | | ||
252 | + ARMMMUIdxBit_E20_0; | ||
253 | } else { | ||
254 | - return ARMMMUIdxBit_E10_1 | ARMMMUIdxBit_E10_0; | ||
255 | + return ARMMMUIdxBit_E10_1 | | ||
256 | + ARMMMUIdxBit_E10_1_PAN | | ||
257 | + ARMMMUIdxBit_E10_0; | ||
258 | } | ||
259 | } | ||
260 | |||
261 | @@ -XXX,XX +XXX,XX @@ static int alle1_tlbmask(CPUARMState *env) | ||
262 | * stage 1 translations. | ||
263 | */ | ||
264 | if (arm_is_secure_below_el3(env)) { | ||
265 | - return ARMMMUIdxBit_SE10_1 | ARMMMUIdxBit_SE10_0; | ||
266 | + return ARMMMUIdxBit_SE10_1 | | ||
267 | + ARMMMUIdxBit_SE10_1_PAN | | ||
268 | + ARMMMUIdxBit_SE10_0; | ||
269 | } else if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
270 | - return ARMMMUIdxBit_E10_1 | ARMMMUIdxBit_E10_0 | ARMMMUIdxBit_Stage2; | ||
271 | + return ARMMMUIdxBit_E10_1 | | ||
272 | + ARMMMUIdxBit_E10_1_PAN | | ||
273 | + ARMMMUIdxBit_E10_0 | | ||
274 | + ARMMMUIdxBit_Stage2; | ||
275 | } else { | ||
276 | - return ARMMMUIdxBit_E10_1 | ARMMMUIdxBit_E10_0; | ||
277 | + return ARMMMUIdxBit_E10_1 | | ||
278 | + ARMMMUIdxBit_E10_1_PAN | | ||
279 | + ARMMMUIdxBit_E10_0; | ||
280 | } | ||
281 | } | ||
282 | |||
283 | static int e2_tlbmask(CPUARMState *env) | ||
284 | { | ||
285 | /* TODO: ARMv8.4-SecEL2 */ | ||
286 | - return ARMMMUIdxBit_E20_0 | ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E2; | ||
287 | + return ARMMMUIdxBit_E20_0 | | ||
288 | + ARMMMUIdxBit_E20_2 | | ||
289 | + ARMMMUIdxBit_E20_2_PAN | | ||
290 | + ARMMMUIdxBit_E2; | ||
291 | } | ||
292 | |||
293 | static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
294 | @@ -XXX,XX +XXX,XX @@ static uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
295 | switch (mmu_idx) { | ||
296 | case ARMMMUIdx_E20_0: | ||
297 | case ARMMMUIdx_E20_2: | ||
298 | + case ARMMMUIdx_E20_2_PAN: | ||
299 | case ARMMMUIdx_Stage2: | ||
300 | case ARMMMUIdx_E2: | ||
301 | return 2; | ||
302 | @@ -XXX,XX +XXX,XX @@ static uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
303 | case ARMMMUIdx_SE10_0: | ||
304 | return arm_el_is_aa64(env, 3) ? 1 : 3; | ||
305 | case ARMMMUIdx_SE10_1: | ||
306 | + case ARMMMUIdx_SE10_1_PAN: | ||
307 | case ARMMMUIdx_Stage1_E0: | ||
308 | case ARMMMUIdx_Stage1_E1: | ||
309 | + case ARMMMUIdx_Stage1_E1_PAN: | ||
310 | case ARMMMUIdx_E10_0: | ||
311 | case ARMMMUIdx_E10_1: | ||
312 | + case ARMMMUIdx_E10_1_PAN: | ||
313 | case ARMMMUIdx_MPrivNegPri: | ||
314 | case ARMMMUIdx_MUserNegPri: | ||
315 | case ARMMMUIdx_MPriv: | ||
316 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) | ||
317 | return ARMMMUIdx_Stage1_E0; | ||
318 | case ARMMMUIdx_E10_1: | ||
319 | return ARMMMUIdx_Stage1_E1; | ||
320 | + case ARMMMUIdx_E10_1_PAN: | ||
321 | + return ARMMMUIdx_Stage1_E1_PAN; | ||
322 | default: | ||
323 | return mmu_idx; | ||
324 | } | ||
325 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
326 | return false; | ||
327 | case ARMMMUIdx_E10_0: | ||
328 | case ARMMMUIdx_E10_1: | ||
329 | + case ARMMMUIdx_E10_1_PAN: | ||
330 | g_assert_not_reached(); | ||
331 | } | ||
332 | } | ||
333 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
334 | target_ulong *page_size, | ||
335 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
336 | { | ||
337 | - if (mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_E10_1) { | ||
338 | + if (mmu_idx == ARMMMUIdx_E10_0 || | ||
339 | + mmu_idx == ARMMMUIdx_E10_1 || | ||
340 | + mmu_idx == ARMMMUIdx_E10_1_PAN) { | ||
341 | /* Call ourselves recursively to do the stage 1 and then stage 2 | ||
342 | * translations. | ||
343 | */ | ||
344 | @@ -XXX,XX +XXX,XX @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) | ||
345 | case ARMMMUIdx_SE10_0: | ||
346 | return 0; | ||
347 | case ARMMMUIdx_E10_1: | ||
348 | + case ARMMMUIdx_E10_1_PAN: | ||
349 | case ARMMMUIdx_SE10_1: | ||
350 | + case ARMMMUIdx_SE10_1_PAN: | ||
351 | return 1; | ||
352 | case ARMMMUIdx_E2: | ||
353 | case ARMMMUIdx_E20_2: | ||
354 | + case ARMMMUIdx_E20_2_PAN: | ||
355 | return 2; | ||
356 | case ARMMMUIdx_SE3: | ||
357 | return 3; | ||
358 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
359 | /* TODO: ARMv8.2-UAO */ | ||
360 | switch (mmu_idx) { | ||
361 | case ARMMMUIdx_E10_1: | ||
362 | + case ARMMMUIdx_E10_1_PAN: | ||
363 | case ARMMMUIdx_SE10_1: | ||
364 | + case ARMMMUIdx_SE10_1_PAN: | ||
365 | /* TODO: ARMv8.3-NV */ | ||
366 | flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); | ||
367 | break; | ||
368 | case ARMMMUIdx_E20_2: | ||
369 | + case ARMMMUIdx_E20_2_PAN: | ||
370 | /* TODO: ARMv8.4-SecEL2 */ | ||
371 | /* | ||
372 | * Note that E20_2 is gated by HCR_EL2.E2H == 1, but E20_0 is | ||
373 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
374 | index XXXXXXX..XXXXXXX 100644 | ||
375 | --- a/target/arm/translate-a64.c | ||
376 | +++ b/target/arm/translate-a64.c | ||
377 | @@ -XXX,XX +XXX,XX @@ static int get_a64_user_mem_index(DisasContext *s) | ||
378 | */ | ||
379 | switch (useridx) { | ||
380 | case ARMMMUIdx_E10_1: | ||
381 | + case ARMMMUIdx_E10_1_PAN: | ||
382 | useridx = ARMMMUIdx_E10_0; | ||
383 | break; | ||
384 | case ARMMMUIdx_E20_2: | ||
385 | + case ARMMMUIdx_E20_2_PAN: | ||
386 | useridx = ARMMMUIdx_E20_0; | ||
387 | break; | ||
388 | case ARMMMUIdx_SE10_1: | ||
389 | + case ARMMMUIdx_SE10_1_PAN: | ||
390 | useridx = ARMMMUIdx_SE10_0; | ||
391 | break; | ||
392 | default: | ||
393 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
394 | index XXXXXXX..XXXXXXX 100644 | ||
395 | --- a/target/arm/translate.c | ||
396 | +++ b/target/arm/translate.c | ||
397 | @@ -XXX,XX +XXX,XX @@ static inline int get_a32_user_mem_index(DisasContext *s) | ||
398 | case ARMMMUIdx_E2: /* this one is UNPREDICTABLE */ | ||
399 | case ARMMMUIdx_E10_0: | ||
400 | case ARMMMUIdx_E10_1: | ||
401 | + case ARMMMUIdx_E10_1_PAN: | ||
402 | return arm_to_core_mmu_idx(ARMMMUIdx_E10_0); | ||
403 | case ARMMMUIdx_SE3: | ||
404 | case ARMMMUIdx_SE10_0: | ||
405 | case ARMMMUIdx_SE10_1: | ||
406 | + case ARMMMUIdx_SE10_1_PAN: | ||
407 | return arm_to_core_mmu_idx(ARMMMUIdx_SE10_0); | ||
408 | case ARMMMUIdx_MUser: | ||
409 | case ARMMMUIdx_MPriv: | ||
410 | -- | ||
411 | 2.20.1 | ||
412 | |||
413 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Don't set the high capacity bit by default as it will be set if required | 3 | Include definitions for all of the bits in ID_MMFR3. |
4 | in the sd_set_csd() function. | 4 | We already have a definition for ID_AA64MMFR1.PAN. |
5 | 5 | ||
6 | [based on a patch from Alistair Francis <alistair.francis@xilinx.com> | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
7 | and Peter Ogden <ogden@xilinx.com> from qemu/xilinx tag xilinx-v2015.4] | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 9 | Message-id: 20200208125816.14954-4-richard.henderson@linaro.org |
10 | Message-id: 20180215221325.7611-2-f4bug@amsat.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/sd/sd.c | 5 ++++- | 12 | target/arm/cpu.h | 29 +++++++++++++++++++++++++++++ |
14 | 1 file changed, 4 insertions(+), 1 deletion(-) | 13 | 1 file changed, 29 insertions(+) |
15 | 14 | ||
16 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/sd/sd.c | 17 | --- a/target/arm/cpu.h |
19 | +++ b/hw/sd/sd.c | 18 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque) | 19 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_ISAR6, FHM, 8, 4) |
21 | 20 | FIELD(ID_ISAR6, SB, 12, 4) | |
22 | /* card power-up OK */ | 21 | FIELD(ID_ISAR6, SPECRES, 16, 4) |
23 | sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_POWER_UP, 1); | 22 | |
23 | +FIELD(ID_MMFR3, CMAINTVA, 0, 4) | ||
24 | +FIELD(ID_MMFR3, CMAINTSW, 4, 4) | ||
25 | +FIELD(ID_MMFR3, BPMAINT, 8, 4) | ||
26 | +FIELD(ID_MMFR3, MAINTBCST, 12, 4) | ||
27 | +FIELD(ID_MMFR3, PAN, 16, 4) | ||
28 | +FIELD(ID_MMFR3, COHWALK, 20, 4) | ||
29 | +FIELD(ID_MMFR3, CMEMSZ, 24, 4) | ||
30 | +FIELD(ID_MMFR3, SUPERSEC, 28, 4) | ||
24 | + | 31 | + |
25 | + if (sd->size > 1 * G_BYTE) { | 32 | FIELD(ID_MMFR4, SPECSEI, 0, 4) |
26 | + sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_CAPACITY, 1); | 33 | FIELD(ID_MMFR4, AC2, 4, 4) |
27 | + } | 34 | FIELD(ID_MMFR4, XNX, 8, 4) |
35 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id) | ||
36 | return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 4; | ||
28 | } | 37 | } |
29 | 38 | ||
30 | static void sd_set_scr(SDState *sd) | 39 | +static inline bool isar_feature_aa32_pan(const ARMISARegisters *id) |
31 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | 40 | +{ |
32 | sd->csd[13] = 0x40; | 41 | + return FIELD_EX64(id->mvfr0, ID_MMFR3, PAN) != 0; |
33 | sd->csd[14] = 0x00; | 42 | +} |
34 | sd->csd[15] = 0x00; | 43 | + |
35 | - sd->ocr |= 1 << 30; /* High Capacity SD Memory Card */ | 44 | +static inline bool isar_feature_aa32_ats1e1(const ARMISARegisters *id) |
36 | } | 45 | +{ |
46 | + return FIELD_EX64(id->mvfr0, ID_MMFR3, PAN) >= 2; | ||
47 | +} | ||
48 | + | ||
49 | /* | ||
50 | * 64-bit feature tests via id registers. | ||
51 | */ | ||
52 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) | ||
53 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) != 0; | ||
37 | } | 54 | } |
38 | 55 | ||
56 | +static inline bool isar_feature_aa64_pan(const ARMISARegisters *id) | ||
57 | +{ | ||
58 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) != 0; | ||
59 | +} | ||
60 | + | ||
61 | +static inline bool isar_feature_aa64_ats1e1(const ARMISARegisters *id) | ||
62 | +{ | ||
63 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 2; | ||
64 | +} | ||
65 | + | ||
66 | static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) | ||
67 | { | ||
68 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; | ||
39 | -- | 69 | -- |
40 | 2.16.1 | 70 | 2.20.1 |
41 | 71 | ||
42 | 72 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | For static const regdefs, file scope is preferred. |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | |
5 | Message-id: 20180215220540.6556-12-f4bug@amsat.org | 5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200208125816.14954-5-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | include/hw/sd/sd.h | 1 - | 10 | target/arm/helper.c | 57 +++++++++++++++++++++++---------------------- |
9 | hw/sd/sd.c | 21 +++++++++++++-------- | 11 | 1 file changed, 29 insertions(+), 28 deletions(-) |
10 | 2 files changed, 13 insertions(+), 9 deletions(-) | ||
11 | 12 | ||
12 | diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/sd/sd.h | 15 | --- a/target/arm/helper.c |
15 | +++ b/include/hw/sd/sd.h | 16 | +++ b/target/arm/helper.c |
16 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_other(CPUARMState *env, |
17 | #define READY_FOR_DATA (1 << 8) | 18 | return access_lor_ns(env); |
18 | #define APP_CMD (1 << 5) | ||
19 | #define AKE_SEQ_ERROR (1 << 3) | ||
20 | -#define OCR_CCS_BITN 30 | ||
21 | |||
22 | typedef enum { | ||
23 | SD_VOLTAGE_0_4V = 400, /* currently not supported */ | ||
24 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/sd/sd.c | ||
27 | +++ b/hw/sd/sd.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | #include "qemu/osdep.h" | ||
30 | #include "hw/qdev.h" | ||
31 | #include "hw/hw.h" | ||
32 | +#include "hw/registerfields.h" | ||
33 | #include "sysemu/block-backend.h" | ||
34 | #include "hw/sd/sd.h" | ||
35 | #include "qapi/error.h" | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | //#define DEBUG_SD 1 | ||
38 | |||
39 | #define ACMD41_ENQUIRY_MASK 0x00ffffff | ||
40 | -#define OCR_POWER_UP 0x80000000 | ||
41 | -#define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ | ||
42 | |||
43 | typedef enum { | ||
44 | sd_r0 = 0, /* no response */ | ||
45 | @@ -XXX,XX +XXX,XX @@ static uint16_t sd_crc16(void *message, size_t width) | ||
46 | return shift_reg; | ||
47 | } | 19 | } |
48 | 20 | ||
49 | +#define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ | 21 | +/* |
22 | + * A trivial implementation of ARMv8.1-LOR leaves all of these | ||
23 | + * registers fixed at 0, which indicates that there are zero | ||
24 | + * supported Limited Ordering regions. | ||
25 | + */ | ||
26 | +static const ARMCPRegInfo lor_reginfo[] = { | ||
27 | + { .name = "LORSA_EL1", .state = ARM_CP_STATE_AA64, | ||
28 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 0, | ||
29 | + .access = PL1_RW, .accessfn = access_lor_other, | ||
30 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
31 | + { .name = "LOREA_EL1", .state = ARM_CP_STATE_AA64, | ||
32 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 1, | ||
33 | + .access = PL1_RW, .accessfn = access_lor_other, | ||
34 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
35 | + { .name = "LORN_EL1", .state = ARM_CP_STATE_AA64, | ||
36 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 2, | ||
37 | + .access = PL1_RW, .accessfn = access_lor_other, | ||
38 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
39 | + { .name = "LORC_EL1", .state = ARM_CP_STATE_AA64, | ||
40 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 3, | ||
41 | + .access = PL1_RW, .accessfn = access_lor_other, | ||
42 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
43 | + { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, | ||
44 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | ||
45 | + .access = PL1_R, .accessfn = access_lorid, | ||
46 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
47 | + REGINFO_SENTINEL | ||
48 | +}; | ||
50 | + | 49 | + |
51 | +FIELD(OCR, CARD_CAPACITY, 30, 1) /* 0:SDSC, 1:SDHC/SDXC */ | 50 | #ifdef TARGET_AARCH64 |
52 | +FIELD(OCR, CARD_POWER_UP, 31, 1) | 51 | static CPAccessResult access_pauth(CPUARMState *env, const ARMCPRegInfo *ri, |
53 | + | 52 | bool isread) |
54 | static void sd_set_ocr(SDState *sd) | 53 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
55 | { | ||
56 | /* All voltages OK, Standard Capacity SD Memory Card, not yet powered up */ | ||
57 | @@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque) | ||
58 | SDState *sd = opaque; | ||
59 | |||
60 | trace_sdcard_powerup(); | ||
61 | - /* Set powered up bit in OCR */ | ||
62 | - assert(!(sd->ocr & OCR_POWER_UP)); | ||
63 | - sd->ocr |= OCR_POWER_UP; | ||
64 | + assert(!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)); | ||
65 | + | ||
66 | + /* card power-up OK */ | ||
67 | + sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_POWER_UP, 1); | ||
68 | } | ||
69 | |||
70 | static void sd_set_scr(SDState *sd) | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool sd_ocr_vmstate_needed(void *opaque) | ||
72 | SDState *sd = opaque; | ||
73 | |||
74 | /* Include the OCR state (and timer) if it is not yet powered up */ | ||
75 | - return !(sd->ocr & OCR_POWER_UP); | ||
76 | + return !FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP); | ||
77 | } | ||
78 | |||
79 | static const VMStateDescription sd_ocr_vmstate = { | ||
80 | @@ -XXX,XX +XXX,XX @@ static void sd_erase(SDState *sd) | ||
81 | return; | ||
82 | } | 54 | } |
83 | 55 | ||
84 | - if (extract32(sd->ocr, OCR_CCS_BITN, 1)) { | 56 | if (cpu_isar_feature(aa64_lor, cpu)) { |
85 | + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { | 57 | - /* |
86 | /* High capacity memory card: erase units are 512 byte blocks */ | 58 | - * A trivial implementation of ARMv8.1-LOR leaves all of these |
87 | erase_start *= 512; | 59 | - * registers fixed at 0, which indicates that there are zero |
88 | erase_end *= 512; | 60 | - * supported Limited Ordering regions. |
89 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | 61 | - */ |
90 | * UEFI, which sends an initial enquiry ACMD41, but | 62 | - static const ARMCPRegInfo lor_reginfo[] = { |
91 | * assumes that the card is in ready state as soon as it | 63 | - { .name = "LORSA_EL1", .state = ARM_CP_STATE_AA64, |
92 | * sees the power up bit set. */ | 64 | - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 0, |
93 | - if (!(sd->ocr & OCR_POWER_UP)) { | 65 | - .access = PL1_RW, .accessfn = access_lor_other, |
94 | + if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { | 66 | - .type = ARM_CP_CONST, .resetvalue = 0 }, |
95 | if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { | 67 | - { .name = "LOREA_EL1", .state = ARM_CP_STATE_AA64, |
96 | timer_del(sd->ocr_power_timer); | 68 | - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 1, |
97 | sd_ocr_powerup(sd); | 69 | - .access = PL1_RW, .accessfn = access_lor_other, |
70 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
71 | - { .name = "LORN_EL1", .state = ARM_CP_STATE_AA64, | ||
72 | - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 2, | ||
73 | - .access = PL1_RW, .accessfn = access_lor_other, | ||
74 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
75 | - { .name = "LORC_EL1", .state = ARM_CP_STATE_AA64, | ||
76 | - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 3, | ||
77 | - .access = PL1_RW, .accessfn = access_lor_other, | ||
78 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | - { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, | ||
80 | - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | ||
81 | - .access = PL1_R, .accessfn = access_lorid, | ||
82 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
83 | - REGINFO_SENTINEL | ||
84 | - }; | ||
85 | define_arm_cp_regs(cpu, lor_reginfo); | ||
86 | } | ||
87 | |||
98 | -- | 88 | -- |
99 | 2.16.1 | 89 | 2.20.1 |
100 | 90 | ||
101 | 91 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | On reset the bus will reset the card, | 3 | Split this helper out of msr_mask in translate.c. At the same time, |
4 | we can now drop the device_reset() call. | 4 | transform the negative reductive logic to positive accumulative logic. |
5 | It will be usable along the exception paths. | ||
5 | 6 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | While touching msr_mask, fix up formatting. |
7 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 8 | |
8 | Message-id: 20180216022933.10945-5-f4bug@amsat.org | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20200208125816.14954-6-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | hw/sd/ssi-sd.c | 32 +++++++++++++++++++------------- | 14 | target/arm/internals.h | 21 +++++++++++++++++++++ |
12 | 1 file changed, 19 insertions(+), 13 deletions(-) | 15 | target/arm/translate.c | 40 +++++++++++++++++----------------------- |
16 | 2 files changed, 38 insertions(+), 23 deletions(-) | ||
13 | 17 | ||
14 | diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c | 18 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/sd/ssi-sd.c | 20 | --- a/target/arm/internals.h |
17 | +++ b/hw/sd/ssi-sd.c | 21 | +++ b/target/arm/internals.h |
18 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 22 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx) |
19 | int32_t arglen; | ||
20 | int32_t response_pos; | ||
21 | int32_t stopping; | ||
22 | - SDState *sd; | ||
23 | + SDBus sdbus; | ||
24 | } ssi_sd_state; | ||
25 | |||
26 | #define TYPE_SSI_SD "ssi-sd" | ||
27 | @@ -XXX,XX +XXX,XX @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val) | ||
28 | request.arg = (s->cmdarg[0] << 24) | (s->cmdarg[1] << 16) | ||
29 | | (s->cmdarg[2] << 8) | s->cmdarg[3]; | ||
30 | DPRINTF("CMD%d arg 0x%08x\n", s->cmd, request.arg); | ||
31 | - s->arglen = sd_do_command(s->sd, &request, longresp); | ||
32 | + s->arglen = sdbus_do_command(&s->sdbus, &request, longresp); | ||
33 | if (s->arglen <= 0) { | ||
34 | s->arglen = 1; | ||
35 | s->response[0] = 4; | ||
36 | @@ -XXX,XX +XXX,XX @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val) | ||
37 | DPRINTF("Response 0x%02x\n", s->response[s->response_pos]); | ||
38 | return s->response[s->response_pos++]; | ||
39 | } | ||
40 | - if (sd_data_ready(s->sd)) { | ||
41 | + if (sdbus_data_ready(&s->sdbus)) { | ||
42 | DPRINTF("Data read\n"); | ||
43 | s->mode = SSI_SD_DATA_START; | ||
44 | } else { | ||
45 | @@ -XXX,XX +XXX,XX @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val) | ||
46 | s->mode = SSI_SD_DATA_READ; | ||
47 | return 0xfe; | ||
48 | case SSI_SD_DATA_READ: | ||
49 | - val = sd_read_data(s->sd); | ||
50 | - if (!sd_data_ready(s->sd)) { | ||
51 | + val = sdbus_read_data(&s->sdbus); | ||
52 | + if (!sdbus_data_ready(&s->sdbus)) { | ||
53 | DPRINTF("Data read end\n"); | ||
54 | s->mode = SSI_SD_CMD; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_ssi_sd = { | ||
57 | static void ssi_sd_realize(SSISlave *d, Error **errp) | ||
58 | { | ||
59 | ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d); | ||
60 | + DeviceState *carddev; | ||
61 | DriveInfo *dinfo; | ||
62 | + Error *err = NULL; | ||
63 | |||
64 | + qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS, | ||
65 | + DEVICE(d), "sd-bus"); | ||
66 | + | ||
67 | + /* Create and plug in the sd card */ | ||
68 | /* FIXME use a qdev drive property instead of drive_get_next() */ | ||
69 | dinfo = drive_get_next(IF_SD); | ||
70 | - s->sd = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, true); | ||
71 | - if (s->sd == NULL) { | ||
72 | - error_setg(errp, "Device initialization failed."); | ||
73 | + carddev = qdev_create(&s->sdbus.qbus, TYPE_SD_CARD); | ||
74 | + if (dinfo) { | ||
75 | + qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err); | ||
76 | + } | ||
77 | + object_property_set_bool(OBJECT(carddev), true, "spi", &err); | ||
78 | + object_property_set_bool(OBJECT(carddev), true, "realized", &err); | ||
79 | + if (err) { | ||
80 | + error_setg(errp, "failed to init SD card: %s", error_get_pretty(err)); | ||
81 | return; | ||
82 | } | 23 | } |
83 | } | 24 | } |
84 | @@ -XXX,XX +XXX,XX @@ static void ssi_sd_reset(DeviceState *dev) | 25 | |
85 | s->arglen = 0; | 26 | +static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, |
86 | s->response_pos = 0; | 27 | + const ARMISARegisters *id) |
87 | s->stopping = 0; | 28 | +{ |
88 | - | 29 | + uint32_t valid = CPSR_M | CPSR_AIF | CPSR_IL | CPSR_NZCV | CPSR_J; |
89 | - /* Since we're still using the legacy SD API the card is not plugged | 30 | + |
90 | - * into any bus, and we must reset it manually. | 31 | + if ((features >> ARM_FEATURE_V4T) & 1) { |
91 | - */ | 32 | + valid |= CPSR_T; |
92 | - device_reset(DEVICE(s->sd)); | 33 | + } |
34 | + if ((features >> ARM_FEATURE_V5) & 1) { | ||
35 | + valid |= CPSR_Q; /* V5TE in reality*/ | ||
36 | + } | ||
37 | + if ((features >> ARM_FEATURE_V6) & 1) { | ||
38 | + valid |= CPSR_E | CPSR_GE; | ||
39 | + } | ||
40 | + if ((features >> ARM_FEATURE_THUMB2) & 1) { | ||
41 | + valid |= CPSR_IT; | ||
42 | + } | ||
43 | + | ||
44 | + return valid; | ||
45 | +} | ||
46 | + | ||
47 | /* | ||
48 | * Parameters of a given virtual address, as extracted from the | ||
49 | * translation control register (TCR) for a given regime. | ||
50 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/translate.c | ||
53 | +++ b/target/arm/translate.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline void gen_mulxy(TCGv_i32 t0, TCGv_i32 t1, int x, int y) | ||
55 | /* Return the mask of PSR bits set by a MSR instruction. */ | ||
56 | static uint32_t msr_mask(DisasContext *s, int flags, int spsr) | ||
57 | { | ||
58 | - uint32_t mask; | ||
59 | + uint32_t mask = 0; | ||
60 | |||
61 | - mask = 0; | ||
62 | - if (flags & (1 << 0)) | ||
63 | + if (flags & (1 << 0)) { | ||
64 | mask |= 0xff; | ||
65 | - if (flags & (1 << 1)) | ||
66 | + } | ||
67 | + if (flags & (1 << 1)) { | ||
68 | mask |= 0xff00; | ||
69 | - if (flags & (1 << 2)) | ||
70 | + } | ||
71 | + if (flags & (1 << 2)) { | ||
72 | mask |= 0xff0000; | ||
73 | - if (flags & (1 << 3)) | ||
74 | + } | ||
75 | + if (flags & (1 << 3)) { | ||
76 | mask |= 0xff000000; | ||
77 | + } | ||
78 | |||
79 | - /* Mask out undefined bits. */ | ||
80 | - mask &= ~CPSR_RESERVED; | ||
81 | - if (!arm_dc_feature(s, ARM_FEATURE_V4T)) { | ||
82 | - mask &= ~CPSR_T; | ||
83 | - } | ||
84 | - if (!arm_dc_feature(s, ARM_FEATURE_V5)) { | ||
85 | - mask &= ~CPSR_Q; /* V5TE in reality*/ | ||
86 | - } | ||
87 | - if (!arm_dc_feature(s, ARM_FEATURE_V6)) { | ||
88 | - mask &= ~(CPSR_E | CPSR_GE); | ||
89 | - } | ||
90 | - if (!arm_dc_feature(s, ARM_FEATURE_THUMB2)) { | ||
91 | - mask &= ~CPSR_IT; | ||
92 | - } | ||
93 | - /* Mask out execution state and reserved bits. */ | ||
94 | + /* Mask out undefined and reserved bits. */ | ||
95 | + mask &= aarch32_cpsr_valid_mask(s->features, s->isar); | ||
96 | + | ||
97 | + /* Mask out execution state. */ | ||
98 | if (!spsr) { | ||
99 | - mask &= ~(CPSR_EXEC | CPSR_RESERVED); | ||
100 | + mask &= ~CPSR_EXEC; | ||
101 | } | ||
102 | + | ||
103 | /* Mask out privileged bits. */ | ||
104 | - if (IS_USER(s)) | ||
105 | + if (IS_USER(s)) { | ||
106 | mask &= CPSR_USER; | ||
107 | + } | ||
108 | return mask; | ||
93 | } | 109 | } |
94 | 110 | ||
95 | static void ssi_sd_class_init(ObjectClass *klass, void *data) | ||
96 | -- | 111 | -- |
97 | 2.16.1 | 112 | 2.20.1 |
98 | 113 | ||
99 | 114 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | The J bit signals Jazelle mode, and so of course is RES0 | ||
4 | when the feature is not enabled. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20200208125816.14954-7-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/internals.h | 5 ++++- | ||
12 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/internals.h | ||
17 | +++ b/target/arm/internals.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx) | ||
19 | static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, | ||
20 | const ARMISARegisters *id) | ||
21 | { | ||
22 | - uint32_t valid = CPSR_M | CPSR_AIF | CPSR_IL | CPSR_NZCV | CPSR_J; | ||
23 | + uint32_t valid = CPSR_M | CPSR_AIF | CPSR_IL | CPSR_NZCV; | ||
24 | |||
25 | if ((features >> ARM_FEATURE_V4T) & 1) { | ||
26 | valid |= CPSR_T; | ||
27 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, | ||
28 | if ((features >> ARM_FEATURE_THUMB2) & 1) { | ||
29 | valid |= CPSR_IT; | ||
30 | } | ||
31 | + if (isar_feature_jazelle(id)) { | ||
32 | + valid |= CPSR_J; | ||
33 | + } | ||
34 | |||
35 | return valid; | ||
36 | } | ||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | CPSR_ERET_MASK was a useless renaming of CPSR_RESERVED. | ||
4 | The function also takes into account bits that the cpu | ||
5 | does not support. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200208125816.14954-8-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 2 -- | ||
13 | target/arm/op_helper.c | 5 ++++- | ||
14 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
21 | #define CPSR_USER (CPSR_NZCV | CPSR_Q | CPSR_GE) | ||
22 | /* Execution state bits. MRS read as zero, MSR writes ignored. */ | ||
23 | #define CPSR_EXEC (CPSR_T | CPSR_IT | CPSR_J | CPSR_IL) | ||
24 | -/* Mask of bits which may be set by exception return copying them from SPSR */ | ||
25 | -#define CPSR_ERET_MASK (~CPSR_RESERVED) | ||
26 | |||
27 | /* Bit definitions for M profile XPSR. Most are the same as CPSR. */ | ||
28 | #define XPSR_EXCP 0x1ffU | ||
29 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/op_helper.c | ||
32 | +++ b/target/arm/op_helper.c | ||
33 | @@ -XXX,XX +XXX,XX @@ void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask) | ||
34 | /* Write the CPSR for a 32-bit exception return */ | ||
35 | void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val) | ||
36 | { | ||
37 | + uint32_t mask; | ||
38 | + | ||
39 | qemu_mutex_lock_iothread(); | ||
40 | arm_call_pre_el_change_hook(env_archcpu(env)); | ||
41 | qemu_mutex_unlock_iothread(); | ||
42 | |||
43 | - cpsr_write(env, val, CPSR_ERET_MASK, CPSRWriteExceptionReturn); | ||
44 | + mask = aarch32_cpsr_valid_mask(env->features, &env_archcpu(env)->isar); | ||
45 | + cpsr_write(env, val, mask, CPSRWriteExceptionReturn); | ||
46 | |||
47 | /* Generated code has already stored the new PC value, but | ||
48 | * without masking out its low bits, because which bits need | ||
49 | -- | ||
50 | 2.20.1 | ||
51 | |||
52 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Using ~0 as the mask on the aarch64->aarch32 exception return |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | was not even as correct as the CPSR_ERET_MASK that we had used |
5 | Message-id: 20180215221325.7611-15-f4bug@amsat.org | 5 | on the aarch32->aarch32 exception return. |
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200208125816.14954-9-richard.henderson@linaro.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/sd/sd.c | 5 +++++ | 12 | target/arm/helper-a64.c | 5 +++-- |
9 | 1 file changed, 5 insertions(+) | 13 | 1 file changed, 3 insertions(+), 2 deletions(-) |
10 | 14 | ||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 15 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sd.c | 17 | --- a/target/arm/helper-a64.c |
14 | +++ b/hw/sd/sd.c | 18 | +++ b/target/arm/helper-a64.c |
15 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 19 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) |
16 | case sd_identification_state: | 20 | { |
17 | case sd_inactive_state: | 21 | int cur_el = arm_current_el(env); |
18 | return sd_illegal; | 22 | unsigned int spsr_idx = aarch64_banked_spsr_index(cur_el); |
19 | + case sd_idle_state: | 23 | - uint32_t spsr = env->banked_spsr[spsr_idx]; |
20 | + if (rca) { | 24 | + uint32_t mask, spsr = env->banked_spsr[spsr_idx]; |
21 | + qemu_log_mask(LOG_GUEST_ERROR, | 25 | int new_el; |
22 | + "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); | 26 | bool return_to_aa64 = (spsr & PSTATE_nRW) == 0; |
23 | + } | 27 | |
24 | default: | 28 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) |
25 | break; | 29 | * will sort the register banks out for us, and we've already |
30 | * caught all the bad-mode cases in el_from_spsr(). | ||
31 | */ | ||
32 | - cpsr_write(env, spsr, ~0, CPSRWriteRaw); | ||
33 | + mask = aarch32_cpsr_valid_mask(env->features, &env_archcpu(env)->isar); | ||
34 | + cpsr_write(env, spsr, mask, CPSRWriteRaw); | ||
35 | if (!arm_singlestep_active(env)) { | ||
36 | env->uncached_cpsr &= ~PSTATE_SS; | ||
26 | } | 37 | } |
27 | -- | 38 | -- |
28 | 2.16.1 | 39 | 2.20.1 |
29 | 40 | ||
30 | 41 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | The only remaining use was in op_helper.c. Use PSTATE_SS | ||
4 | directly, and move the commentary so that it is more obvious | ||
5 | what is going on. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20200208125816.14954-10-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 6 ------ | ||
13 | target/arm/op_helper.c | 9 ++++++++- | ||
14 | 2 files changed, 8 insertions(+), 7 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
21 | #define CPSR_IT_2_7 (0xfc00U) | ||
22 | #define CPSR_GE (0xfU << 16) | ||
23 | #define CPSR_IL (1U << 20) | ||
24 | -/* Note that the RESERVED bits include bit 21, which is PSTATE_SS in | ||
25 | - * an AArch64 SPSR but RES0 in AArch32 SPSR and CPSR. In QEMU we use | ||
26 | - * env->uncached_cpsr bit 21 to store PSTATE.SS when executing in AArch32, | ||
27 | - * where it is live state but not accessible to the AArch32 code. | ||
28 | - */ | ||
29 | -#define CPSR_RESERVED (0x7U << 21) | ||
30 | #define CPSR_J (1U << 24) | ||
31 | #define CPSR_IT_0_1 (3U << 25) | ||
32 | #define CPSR_Q (1U << 27) | ||
33 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/op_helper.c | ||
36 | +++ b/target/arm/op_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome) | ||
38 | |||
39 | uint32_t HELPER(cpsr_read)(CPUARMState *env) | ||
40 | { | ||
41 | - return cpsr_read(env) & ~(CPSR_EXEC | CPSR_RESERVED); | ||
42 | + /* | ||
43 | + * We store the ARMv8 PSTATE.SS bit in env->uncached_cpsr. | ||
44 | + * This is convenient for populating SPSR_ELx, but must be | ||
45 | + * hidden from aarch32 mode, where it is not visible. | ||
46 | + * | ||
47 | + * TODO: ARMv8.4-DIT -- need to move SS somewhere else. | ||
48 | + */ | ||
49 | + return cpsr_read(env) & ~(CPSR_EXEC | PSTATE_SS); | ||
50 | } | ||
51 | |||
52 | void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask) | ||
53 | -- | ||
54 | 2.20.1 | ||
55 | |||
56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Use this along the exception return path, where we previously | ||
4 | accepted any values. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200208125816.14954-11-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/internals.h | 12 ++++++++++++ | ||
12 | target/arm/helper-a64.c | 1 + | ||
13 | 2 files changed, 13 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/internals.h | ||
18 | +++ b/target/arm/internals.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, | ||
20 | return valid; | ||
21 | } | ||
22 | |||
23 | +static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) | ||
24 | +{ | ||
25 | + uint32_t valid; | ||
26 | + | ||
27 | + valid = PSTATE_M | PSTATE_DAIF | PSTATE_IL | PSTATE_SS | PSTATE_NZCV; | ||
28 | + if (isar_feature_aa64_bti(id)) { | ||
29 | + valid |= PSTATE_BTYPE; | ||
30 | + } | ||
31 | + | ||
32 | + return valid; | ||
33 | +} | ||
34 | + | ||
35 | /* | ||
36 | * Parameters of a given virtual address, as extracted from the | ||
37 | * translation control register (TCR) for a given regime. | ||
38 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/helper-a64.c | ||
41 | +++ b/target/arm/helper-a64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | ||
43 | cur_el, new_el, env->regs[15]); | ||
44 | } else { | ||
45 | env->aarch64 = 1; | ||
46 | + spsr &= aarch64_pstate_valid_mask(&env_archcpu(env)->isar); | ||
47 | pstate_write(env, spsr); | ||
48 | if (!arm_singlestep_active(env)) { | ||
49 | env->pstate &= ~PSTATE_SS; | ||
50 | -- | ||
51 | 2.20.1 | ||
52 | |||
53 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | returning sd_illegal, since they are not implemented. | 3 | For aarch64, there's a dedicated msr (imm, reg) insn. |
4 | For aarch32, this is done via msr to cpsr. Writes from el0 | ||
5 | are ignored, which is already handled by the CPSR_USER mask. | ||
4 | 6 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180215221325.7611-11-f4bug@amsat.org | 9 | Message-id: 20200208125816.14954-12-richard.henderson@linaro.org |
8 | [PMM: tweak multiline comment format] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | hw/sd/sd.c | 12 ++++++++++++ | 12 | target/arm/cpu.h | 2 ++ |
12 | 1 file changed, 12 insertions(+) | 13 | target/arm/internals.h | 6 ++++++ |
14 | target/arm/helper.c | 21 +++++++++++++++++++++ | ||
15 | target/arm/translate-a64.c | 14 ++++++++++++++ | ||
16 | 4 files changed, 43 insertions(+) | ||
13 | 17 | ||
14 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/sd/sd.c | 20 | --- a/target/arm/cpu.h |
17 | +++ b/hw/sd/sd.c | 21 | +++ b/target/arm/cpu.h |
18 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | 22 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); |
19 | } | 23 | #define CPSR_IT_2_7 (0xfc00U) |
24 | #define CPSR_GE (0xfU << 16) | ||
25 | #define CPSR_IL (1U << 20) | ||
26 | +#define CPSR_PAN (1U << 22) | ||
27 | #define CPSR_J (1U << 24) | ||
28 | #define CPSR_IT_0_1 (3U << 25) | ||
29 | #define CPSR_Q (1U << 27) | ||
30 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
31 | #define PSTATE_BTYPE (3U << 10) | ||
32 | #define PSTATE_IL (1U << 20) | ||
33 | #define PSTATE_SS (1U << 21) | ||
34 | +#define PSTATE_PAN (1U << 22) | ||
35 | #define PSTATE_V (1U << 28) | ||
36 | #define PSTATE_C (1U << 29) | ||
37 | #define PSTATE_Z (1U << 30) | ||
38 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/internals.h | ||
41 | +++ b/target/arm/internals.h | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, | ||
43 | if (isar_feature_jazelle(id)) { | ||
44 | valid |= CPSR_J; | ||
45 | } | ||
46 | + if (isar_feature_aa32_pan(id)) { | ||
47 | + valid |= CPSR_PAN; | ||
48 | + } | ||
49 | |||
50 | return valid; | ||
51 | } | ||
52 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) | ||
53 | if (isar_feature_aa64_bti(id)) { | ||
54 | valid |= PSTATE_BTYPE; | ||
55 | } | ||
56 | + if (isar_feature_aa64_pan(id)) { | ||
57 | + valid |= PSTATE_PAN; | ||
58 | + } | ||
59 | |||
60 | return valid; | ||
61 | } | ||
62 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/arm/helper.c | ||
65 | +++ b/target/arm/helper.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static void aa64_daif_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
67 | env->daif = value & PSTATE_DAIF; | ||
68 | } | ||
69 | |||
70 | +static uint64_t aa64_pan_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
71 | +{ | ||
72 | + return env->pstate & PSTATE_PAN; | ||
73 | +} | ||
74 | + | ||
75 | +static void aa64_pan_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
76 | + uint64_t value) | ||
77 | +{ | ||
78 | + env->pstate = (env->pstate & ~PSTATE_PAN) | (value & PSTATE_PAN); | ||
79 | +} | ||
80 | + | ||
81 | +static const ARMCPRegInfo pan_reginfo = { | ||
82 | + .name = "PAN", .state = ARM_CP_STATE_AA64, | ||
83 | + .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 2, .opc2 = 3, | ||
84 | + .type = ARM_CP_NO_RAW, .access = PL1_RW, | ||
85 | + .readfn = aa64_pan_read, .writefn = aa64_pan_write | ||
86 | +}; | ||
87 | + | ||
88 | static CPAccessResult aa64_cacheop_access(CPUARMState *env, | ||
89 | const ARMCPRegInfo *ri, | ||
90 | bool isread) | ||
91 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
92 | if (cpu_isar_feature(aa64_lor, cpu)) { | ||
93 | define_arm_cp_regs(cpu, lor_reginfo); | ||
94 | } | ||
95 | + if (cpu_isar_feature(aa64_pan, cpu)) { | ||
96 | + define_one_arm_cp_reg(cpu, &pan_reginfo); | ||
97 | + } | ||
98 | |||
99 | if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { | ||
100 | define_arm_cp_regs(cpu, vhe_reginfo); | ||
101 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/arm/translate-a64.c | ||
104 | +++ b/target/arm/translate-a64.c | ||
105 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
106 | s->base.is_jmp = DISAS_NEXT; | ||
20 | break; | 107 | break; |
21 | 108 | ||
22 | + case 18: /* Reserved for SD security applications */ | 109 | + case 0x04: /* PAN */ |
23 | + case 25: | 110 | + if (!dc_isar_feature(aa64_pan, s) || s->current_el == 0) { |
24 | + case 26: | 111 | + goto do_unallocated; |
25 | + case 38: | 112 | + } |
26 | + case 43 ... 49: | 113 | + if (crm & 1) { |
27 | + /* Refer to the "SD Specifications Part3 Security Specification" for | 114 | + set_pstate_bits(PSTATE_PAN); |
28 | + * information about the SD Security Features. | 115 | + } else { |
29 | + */ | 116 | + clear_pstate_bits(PSTATE_PAN); |
30 | + qemu_log_mask(LOG_UNIMP, "SD: CMD%i Security not implemented\n", | 117 | + } |
31 | + req.cmd); | 118 | + t1 = tcg_const_i32(s->current_el); |
32 | + return sd_illegal; | 119 | + gen_helper_rebuild_hflags_a64(cpu_env, t1); |
120 | + tcg_temp_free_i32(t1); | ||
121 | + break; | ||
33 | + | 122 | + |
34 | default: | 123 | case 0x05: /* SPSel */ |
35 | /* Fall back to standard commands. */ | 124 | if (s->current_el == 0) { |
36 | return sd_normal_command(sd, req); | 125 | goto do_unallocated; |
37 | -- | 126 | -- |
38 | 2.16.1 | 127 | 2.20.1 |
39 | 128 | ||
40 | 129 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Examine the PAN bit for EL1, EL2, and Secure EL1 to | ||
4 | determine if it applies. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200208125816.14954-13-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper.c | 9 +++++++++ | ||
13 | 1 file changed, 9 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper.c | ||
18 | +++ b/target/arm/helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el) | ||
20 | return ARMMMUIdx_E10_0; | ||
21 | case 1: | ||
22 | if (arm_is_secure_below_el3(env)) { | ||
23 | + if (env->pstate & PSTATE_PAN) { | ||
24 | + return ARMMMUIdx_SE10_1_PAN; | ||
25 | + } | ||
26 | return ARMMMUIdx_SE10_1; | ||
27 | } | ||
28 | + if (env->pstate & PSTATE_PAN) { | ||
29 | + return ARMMMUIdx_E10_1_PAN; | ||
30 | + } | ||
31 | return ARMMMUIdx_E10_1; | ||
32 | case 2: | ||
33 | /* TODO: ARMv8.4-SecEL2 */ | ||
34 | /* Note that TGE does not apply at EL2. */ | ||
35 | if ((env->cp15.hcr_el2 & HCR_E2H) && arm_el_is_aa64(env, 2)) { | ||
36 | + if (env->pstate & PSTATE_PAN) { | ||
37 | + return ARMMMUIdx_E20_2_PAN; | ||
38 | + } | ||
39 | return ARMMMUIdx_E20_2; | ||
40 | } | ||
41 | return ARMMMUIdx_E2; | ||
42 | -- | ||
43 | 2.20.1 | ||
44 | |||
45 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | If we have a PAN-enforcing mmu_idx, set prot == 0 if user_rw != 0. |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | |
5 | Message-id: 20180215220540.6556-8-f4bug@amsat.org | 5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200208125816.14954-14-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | hw/sd/sdmmc-internal.h | 15 +++++++++++++++ | 11 | target/arm/internals.h | 13 +++++++++++++ |
9 | hw/sd/sd.c | 22 ++++++++++++++++------ | 12 | target/arm/helper.c | 3 +++ |
10 | 2 files changed, 31 insertions(+), 6 deletions(-) | 13 | 2 files changed, 16 insertions(+) |
11 | create mode 100644 hw/sd/sdmmc-internal.h | ||
12 | 14 | ||
13 | diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h | 15 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
14 | new file mode 100644 | ||
15 | index XXXXXXX..XXXXXXX | ||
16 | --- /dev/null | ||
17 | +++ b/hw/sd/sdmmc-internal.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | +/* | ||
20 | + * SD/MMC cards common | ||
21 | + * | ||
22 | + * Copyright (c) 2018 Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
23 | + * | ||
24 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
25 | + * See the COPYING file in the top-level directory. | ||
26 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
27 | + */ | ||
28 | +#ifndef SD_INTERNAL_H | ||
29 | +#define SD_INTERNAL_H | ||
30 | + | ||
31 | +#define SDMMC_CMD_MAX 64 | ||
32 | + | ||
33 | +#endif | ||
34 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/hw/sd/sd.c | 17 | --- a/target/arm/internals.h |
37 | +++ b/hw/sd/sd.c | 18 | +++ b/target/arm/internals.h |
38 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) |
39 | #include "qemu/error-report.h" | ||
40 | #include "qemu/timer.h" | ||
41 | #include "qemu/log.h" | ||
42 | +#include "sdmmc-internal.h" | ||
43 | #include "trace.h" | ||
44 | |||
45 | //#define DEBUG_SD 1 | ||
46 | @@ -XXX,XX +XXX,XX @@ static void sd_set_mode(SDState *sd) | ||
47 | } | 20 | } |
48 | } | 21 | } |
49 | 22 | ||
50 | -static const sd_cmd_type_t sd_cmd_type[64] = { | 23 | +static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx) |
51 | +static const sd_cmd_type_t sd_cmd_type[SDMMC_CMD_MAX] = { | 24 | +{ |
52 | sd_bc, sd_none, sd_bcr, sd_bcr, sd_none, sd_none, sd_none, sd_ac, | 25 | + switch (mmu_idx) { |
53 | sd_bcr, sd_ac, sd_ac, sd_adtc, sd_ac, sd_ac, sd_none, sd_ac, | 26 | + case ARMMMUIdx_Stage1_E1_PAN: |
54 | + /* 16 */ | 27 | + case ARMMMUIdx_E10_1_PAN: |
55 | sd_ac, sd_adtc, sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, | 28 | + case ARMMMUIdx_E20_2_PAN: |
56 | sd_adtc, sd_adtc, sd_adtc, sd_adtc, sd_ac, sd_ac, sd_adtc, sd_none, | 29 | + case ARMMMUIdx_SE10_1_PAN: |
57 | + /* 32 */ | 30 | + return true; |
58 | sd_ac, sd_ac, sd_none, sd_none, sd_none, sd_none, sd_ac, sd_none, | 31 | + default: |
59 | sd_none, sd_none, sd_bc, sd_none, sd_none, sd_none, sd_none, sd_none, | 32 | + return false; |
60 | + /* 48 */ | 33 | + } |
61 | sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_ac, | 34 | +} |
62 | sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, | 35 | + |
63 | }; | 36 | /* Return the FSR value for a debug exception (watchpoint, hardware |
64 | 37 | * breakpoint or BKPT insn) targeting the specified exception level. | |
65 | -static const int sd_cmd_class[64] = { | 38 | */ |
66 | +static const int sd_cmd_class[SDMMC_CMD_MAX] = { | 39 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
67 | 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 1, 0, 0, 0, 0, | 40 | index XXXXXXX..XXXXXXX 100644 |
68 | 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, | 41 | --- a/target/arm/helper.c |
69 | 5, 5, 10, 10, 10, 10, 5, 9, 9, 9, 7, 7, 7, 7, 7, 7, | 42 | +++ b/target/arm/helper.c |
70 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 43 | @@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, |
71 | /* Not interpreting this as an app command */ | 44 | if (is_user) { |
72 | sd->card_status &= ~APP_CMD; | 45 | prot_rw = user_rw; |
73 | 46 | } else { | |
74 | - if (sd_cmd_type[req.cmd & 0x3F] == sd_ac | 47 | + if (user_rw && regime_is_pan(env, mmu_idx)) { |
75 | - || sd_cmd_type[req.cmd & 0x3F] == sd_adtc) { | 48 | + return 0; |
76 | + if (sd_cmd_type[req.cmd] == sd_ac | 49 | + } |
77 | + || sd_cmd_type[req.cmd] == sd_adtc) { | 50 | prot_rw = simple_ap_to_rw_prot_is_user(ap, false); |
78 | rca = req.arg >> 16; | ||
79 | } | 51 | } |
80 | 52 | ||
81 | @@ -XXX,XX +XXX,XX @@ static int cmd_valid_while_locked(SDState *sd, SDRequest *req) | ||
82 | if (req->cmd == 16 || req->cmd == 55) { | ||
83 | return 1; | ||
84 | } | ||
85 | - return sd_cmd_class[req->cmd & 0x3F] == 0 | ||
86 | - || sd_cmd_class[req->cmd & 0x3F] == 7; | ||
87 | + return sd_cmd_class[req->cmd] == 0 | ||
88 | + || sd_cmd_class[req->cmd] == 7; | ||
89 | } | ||
90 | |||
91 | int sd_do_command(SDState *sd, SDRequest *req, | ||
92 | @@ -XXX,XX +XXX,XX @@ int sd_do_command(SDState *sd, SDRequest *req, | ||
93 | goto send_response; | ||
94 | } | ||
95 | |||
96 | + if (req->cmd >= SDMMC_CMD_MAX) { | ||
97 | + qemu_log_mask(LOG_GUEST_ERROR, "SD: incorrect command 0x%02x\n", | ||
98 | + req->cmd); | ||
99 | + req->cmd &= 0x3f; | ||
100 | + } | ||
101 | + | ||
102 | if (sd->card_status & CARD_IS_LOCKED) { | ||
103 | if (!cmd_valid_while_locked(sd, req)) { | ||
104 | sd->card_status |= ILLEGAL_COMMAND; | ||
105 | -- | 53 | -- |
106 | 2.16.1 | 54 | 2.20.1 |
107 | 55 | ||
108 | 56 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | replace switch(single case) -> if() | 3 | The PAN bit is preserved, or set as per SCTLR_ELx.SPAN, |
4 | plus several other conditions listed in the ARM ARM. | ||
4 | 5 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20180215221325.7611-17-f4bug@amsat.org | 8 | Message-id: 20200208125816.14954-15-richard.henderson@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | hw/sd/sd.c | 56 ++++++++++++++++++++++++++------------------------------ | 11 | target/arm/helper.c | 53 ++++++++++++++++++++++++++++++++++++++++++--- |
11 | 1 file changed, 26 insertions(+), 30 deletions(-) | 12 | 1 file changed, 50 insertions(+), 3 deletions(-) |
12 | 13 | ||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sd.c | 16 | --- a/target/arm/helper.c |
16 | +++ b/hw/sd/sd.c | 17 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | 18 | @@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, |
18 | sd->state = sd_transfer_state; | 19 | uint32_t mask, uint32_t offset, |
19 | return sd_r1; | 20 | uint32_t newpc) |
20 | } | 21 | { |
21 | - switch (sd->state) { | 22 | + int new_el; |
22 | - case sd_idle_state: | 23 | + |
23 | - /* If it's the first ACMD41 since reset, we need to decide | 24 | /* Change the CPU state so as to actually take the exception. */ |
24 | - * whether to power up. If this is not an enquiry ACMD41, | 25 | switch_mode(env, new_mode); |
25 | - * we immediately report power on and proceed below to the | 26 | + new_el = arm_current_el(env); |
26 | - * ready state, but if it is, we set a timer to model a | 27 | + |
27 | - * delay for power up. This works around a bug in EDK2 | 28 | /* |
28 | - * UEFI, which sends an initial enquiry ACMD41, but | 29 | * For exceptions taken to AArch32 we must clear the SS bit in both |
29 | - * assumes that the card is in ready state as soon as it | 30 | * PSTATE and in the old-state value we save to SPSR_<mode>, so zero it now. |
30 | - * sees the power up bit set. */ | 31 | @@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, |
31 | - if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { | 32 | env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode; |
32 | - if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { | 33 | /* Set new mode endianness */ |
33 | - timer_del(sd->ocr_power_timer); | 34 | env->uncached_cpsr &= ~CPSR_E; |
34 | - sd_ocr_powerup(sd); | 35 | - if (env->cp15.sctlr_el[arm_current_el(env)] & SCTLR_EE) { |
35 | - } else { | 36 | + if (env->cp15.sctlr_el[new_el] & SCTLR_EE) { |
36 | - trace_sdcard_inquiry_cmd41(); | 37 | env->uncached_cpsr |= CPSR_E; |
37 | - if (!timer_pending(sd->ocr_power_timer)) { | 38 | } |
38 | - timer_mod_ns(sd->ocr_power_timer, | 39 | /* J and IL must always be cleared for exception entry */ |
39 | - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) | 40 | @@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, |
40 | - + OCR_POWER_DELAY_NS)); | 41 | env->thumb = (env->cp15.sctlr_el[2] & SCTLR_TE) != 0; |
41 | - } | 42 | env->elr_el[2] = env->regs[15]; |
42 | + if (sd->state != sd_idle_state) { | 43 | } else { |
44 | + /* CPSR.PAN is normally preserved preserved unless... */ | ||
45 | + if (cpu_isar_feature(aa64_pan, env_archcpu(env))) { | ||
46 | + switch (new_el) { | ||
47 | + case 3: | ||
48 | + if (!arm_is_secure_below_el3(env)) { | ||
49 | + /* ... the target is EL3, from non-secure state. */ | ||
50 | + env->uncached_cpsr &= ~CPSR_PAN; | ||
51 | + break; | ||
52 | + } | ||
53 | + /* ... the target is EL3, from secure state ... */ | ||
54 | + /* fall through */ | ||
55 | + case 1: | ||
56 | + /* ... the target is EL1 and SCTLR.SPAN is 0. */ | ||
57 | + if (!(env->cp15.sctlr_el[new_el] & SCTLR_SPAN)) { | ||
58 | + env->uncached_cpsr |= CPSR_PAN; | ||
59 | + } | ||
60 | + break; | ||
61 | + } | ||
62 | + } | ||
63 | /* | ||
64 | * this is a lie, as there was no c1_sys on V4T/V5, but who cares | ||
65 | * and we should just guard the thumb mode on V4 | ||
66 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
67 | unsigned int new_el = env->exception.target_el; | ||
68 | target_ulong addr = env->cp15.vbar_el[new_el]; | ||
69 | unsigned int new_mode = aarch64_pstate_mode(new_el, true); | ||
70 | + unsigned int old_mode; | ||
71 | unsigned int cur_el = arm_current_el(env); | ||
72 | |||
73 | /* | ||
74 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
75 | } | ||
76 | |||
77 | if (is_a64(env)) { | ||
78 | - env->banked_spsr[aarch64_banked_spsr_index(new_el)] = pstate_read(env); | ||
79 | + old_mode = pstate_read(env); | ||
80 | aarch64_save_sp(env, arm_current_el(env)); | ||
81 | env->elr_el[new_el] = env->pc; | ||
82 | } else { | ||
83 | - env->banked_spsr[aarch64_banked_spsr_index(new_el)] = cpsr_read(env); | ||
84 | + old_mode = cpsr_read(env); | ||
85 | env->elr_el[new_el] = env->regs[15]; | ||
86 | |||
87 | aarch64_sync_32_to_64(env); | ||
88 | |||
89 | env->condexec_bits = 0; | ||
90 | } | ||
91 | + env->banked_spsr[aarch64_banked_spsr_index(new_el)] = old_mode; | ||
92 | + | ||
93 | qemu_log_mask(CPU_LOG_INT, "...with ELR 0x%" PRIx64 "\n", | ||
94 | env->elr_el[new_el]); | ||
95 | |||
96 | + if (cpu_isar_feature(aa64_pan, cpu)) { | ||
97 | + /* The value of PSTATE.PAN is normally preserved, except when ... */ | ||
98 | + new_mode |= old_mode & PSTATE_PAN; | ||
99 | + switch (new_el) { | ||
100 | + case 2: | ||
101 | + /* ... the target is EL2 with HCR_EL2.{E2H,TGE} == '11' ... */ | ||
102 | + if ((arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) | ||
103 | + != (HCR_E2H | HCR_TGE)) { | ||
104 | + break; | ||
105 | + } | ||
106 | + /* fall through */ | ||
107 | + case 1: | ||
108 | + /* ... the target is EL1 ... */ | ||
109 | + /* ... and SCTLR_ELx.SPAN == 0, then set to 1. */ | ||
110 | + if ((env->cp15.sctlr_el[new_el] & SCTLR_SPAN) == 0) { | ||
111 | + new_mode |= PSTATE_PAN; | ||
112 | + } | ||
43 | + break; | 113 | + break; |
44 | + } | 114 | + } |
45 | + /* If it's the first ACMD41 since reset, we need to decide | 115 | + } |
46 | + * whether to power up. If this is not an enquiry ACMD41, | ||
47 | + * we immediately report power on and proceed below to the | ||
48 | + * ready state, but if it is, we set a timer to model a | ||
49 | + * delay for power up. This works around a bug in EDK2 | ||
50 | + * UEFI, which sends an initial enquiry ACMD41, but | ||
51 | + * assumes that the card is in ready state as soon as it | ||
52 | + * sees the power up bit set. */ | ||
53 | + if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { | ||
54 | + if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { | ||
55 | + timer_del(sd->ocr_power_timer); | ||
56 | + sd_ocr_powerup(sd); | ||
57 | + } else { | ||
58 | + trace_sdcard_inquiry_cmd41(); | ||
59 | + if (!timer_pending(sd->ocr_power_timer)) { | ||
60 | + timer_mod_ns(sd->ocr_power_timer, | ||
61 | + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) | ||
62 | + + OCR_POWER_DELAY_NS)); | ||
63 | } | ||
64 | } | ||
65 | + } | ||
66 | |||
67 | + if (FIELD_EX32(sd->ocr & req.arg, OCR, VDD_VOLTAGE_WINDOW)) { | ||
68 | /* We accept any voltage. 10000 V is nothing. | ||
69 | * | ||
70 | * Once we're powered up, we advance straight to ready state | ||
71 | * unless it's an enquiry ACMD41 (bits 23:0 == 0). | ||
72 | */ | ||
73 | - if (req.arg & ACMD41_ENQUIRY_MASK) { | ||
74 | - sd->state = sd_ready_state; | ||
75 | - } | ||
76 | - | ||
77 | - return sd_r3; | ||
78 | - | ||
79 | - default: | ||
80 | - break; | ||
81 | + sd->state = sd_ready_state; | ||
82 | } | ||
83 | - break; | ||
84 | + | 116 | + |
85 | + return sd_r3; | 117 | pstate_write(env, PSTATE_DAIF | new_mode); |
86 | 118 | env->aarch64 = 1; | |
87 | case 42: /* ACMD42: SET_CLR_CARD_DETECT */ | 119 | aarch64_restore_sp(env, new_el); |
88 | switch (sd->state) { | ||
89 | -- | 120 | -- |
90 | 2.16.1 | 121 | 2.20.1 |
91 | 122 | ||
92 | 123 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | This is a minor enhancement over ARMv8.1-PAN. |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | The *_PAN mmu_idx are used with the existing do_ats_write. |
5 | Message-id: 20180215221325.7611-14-f4bug@amsat.org | 5 | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200208125816.14954-16-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | hw/sd/sd.c | 8 ++++++++ | 11 | target/arm/helper.c | 56 ++++++++++++++++++++++++++++++++++++++++----- |
9 | 1 file changed, 8 insertions(+) | 12 | 1 file changed, 50 insertions(+), 6 deletions(-) |
10 | 13 | ||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sd.c | 16 | --- a/target/arm/helper.c |
14 | +++ b/hw/sd/sd.c | 17 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 18 | @@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
16 | 19 | ||
17 | /* Application specific commands (Class 8) */ | 20 | switch (ri->opc2 & 6) { |
18 | case 55: /* CMD55: APP_CMD */ | 21 | case 0: |
19 | + switch (sd->state) { | 22 | - /* stage 1 current state PL1: ATS1CPR, ATS1CPW */ |
20 | + case sd_ready_state: | 23 | + /* stage 1 current state PL1: ATS1CPR, ATS1CPW, ATS1CPRP, ATS1CPWP */ |
21 | + case sd_identification_state: | 24 | switch (el) { |
22 | + case sd_inactive_state: | 25 | case 3: |
23 | + return sd_illegal; | 26 | mmu_idx = ARMMMUIdx_SE3; |
24 | + default: | 27 | break; |
25 | + break; | 28 | case 2: |
26 | + } | 29 | - mmu_idx = ARMMMUIdx_Stage1_E1; |
27 | if (!sd->spi) { | 30 | - break; |
28 | if (sd->rca != rca) { | 31 | + g_assert(!secure); /* TODO: ARMv8.4-SecEL2 */ |
29 | return sd_r0; | 32 | + /* fall through */ |
33 | case 1: | ||
34 | - mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1; | ||
35 | + if (ri->crm == 9 && (env->uncached_cpsr & CPSR_PAN)) { | ||
36 | + mmu_idx = (secure ? ARMMMUIdx_SE10_1_PAN | ||
37 | + : ARMMMUIdx_Stage1_E1_PAN); | ||
38 | + } else { | ||
39 | + mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1; | ||
40 | + } | ||
41 | break; | ||
42 | default: | ||
43 | g_assert_not_reached(); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, | ||
45 | switch (ri->opc2 & 6) { | ||
46 | case 0: | ||
47 | switch (ri->opc1) { | ||
48 | - case 0: /* AT S1E1R, AT S1E1W */ | ||
49 | - mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1; | ||
50 | + case 0: /* AT S1E1R, AT S1E1W, AT S1E1RP, AT S1E1WP */ | ||
51 | + if (ri->crm == 9 && (env->pstate & PSTATE_PAN)) { | ||
52 | + mmu_idx = (secure ? ARMMMUIdx_SE10_1_PAN | ||
53 | + : ARMMMUIdx_Stage1_E1_PAN); | ||
54 | + } else { | ||
55 | + mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1; | ||
56 | + } | ||
57 | break; | ||
58 | case 4: /* AT S1E2R, AT S1E2W */ | ||
59 | mmu_idx = ARMMMUIdx_E2; | ||
60 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { | ||
61 | REGINFO_SENTINEL | ||
62 | }; | ||
63 | |||
64 | +#ifndef CONFIG_USER_ONLY | ||
65 | +static const ARMCPRegInfo ats1e1_reginfo[] = { | ||
66 | + { .name = "AT_S1E1R", .state = ARM_CP_STATE_AA64, | ||
67 | + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0, | ||
68 | + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
69 | + .writefn = ats_write64 }, | ||
70 | + { .name = "AT_S1E1W", .state = ARM_CP_STATE_AA64, | ||
71 | + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
72 | + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
73 | + .writefn = ats_write64 }, | ||
74 | + REGINFO_SENTINEL | ||
75 | +}; | ||
76 | + | ||
77 | +static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
78 | + { .name = "ATS1CPRP", | ||
79 | + .cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0, | ||
80 | + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
81 | + .writefn = ats_write }, | ||
82 | + { .name = "ATS1CPWP", | ||
83 | + .cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
84 | + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
85 | + .writefn = ats_write }, | ||
86 | + REGINFO_SENTINEL | ||
87 | +}; | ||
88 | +#endif | ||
89 | + | ||
90 | void register_cp_regs_for_features(ARMCPU *cpu) | ||
91 | { | ||
92 | /* Register all the coprocessor registers based on feature bits */ | ||
93 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
94 | if (cpu_isar_feature(aa64_pan, cpu)) { | ||
95 | define_one_arm_cp_reg(cpu, &pan_reginfo); | ||
96 | } | ||
97 | +#ifndef CONFIG_USER_ONLY | ||
98 | + if (cpu_isar_feature(aa64_ats1e1, cpu)) { | ||
99 | + define_arm_cp_regs(cpu, ats1e1_reginfo); | ||
100 | + } | ||
101 | + if (cpu_isar_feature(aa32_ats1e1, cpu)) { | ||
102 | + define_arm_cp_regs(cpu, ats1cp_reginfo); | ||
103 | + } | ||
104 | +#endif | ||
105 | |||
106 | if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { | ||
107 | define_arm_cp_regs(cpu, vhe_reginfo); | ||
30 | -- | 108 | -- |
31 | 2.16.1 | 109 | 2.20.1 |
32 | 110 | ||
33 | 111 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Suggested-by: Alistair Francis <alistair.francis@xilinx.com> | 3 | This includes enablement of ARMv8.1-PAN. |
4 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | |
5 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Message-id: 20180215221325.7611-12-f4bug@amsat.org | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200208125816.14954-17-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 9 | --- |
9 | hw/sd/sd.c | 22 +++++++++++++--------- | 10 | target/arm/cpu.c | 4 ++++ |
10 | 1 file changed, 13 insertions(+), 9 deletions(-) | 11 | target/arm/cpu64.c | 5 +++++ |
12 | 2 files changed, 9 insertions(+) | ||
11 | 13 | ||
12 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/sd/sd.c | 16 | --- a/target/arm/cpu.c |
15 | +++ b/hw/sd/sd.c | 17 | +++ b/target/arm/cpu.c |
16 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) |
17 | 19 | t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | |
18 | /* Block write commands (Class 4) */ | 20 | cpu->isar.mvfr2 = t; |
19 | case 24: /* CMD24: WRITE_SINGLE_BLOCK */ | 21 | |
20 | - if (sd->spi) | 22 | + t = cpu->id_mmfr3; |
21 | - goto unimplemented_cmd; | 23 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ |
22 | + if (sd->spi) { | 24 | + cpu->id_mmfr3 = t; |
23 | + goto unimplemented_spi_cmd; | 25 | + |
24 | + } | 26 | t = cpu->id_mmfr4; |
25 | switch (sd->state) { | 27 | t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ |
26 | case sd_transfer_state: | 28 | cpu->id_mmfr4 = t; |
27 | /* Writing in SPI mode not implemented. */ | 29 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
28 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 30 | index XXXXXXX..XXXXXXX 100644 |
29 | break; | 31 | --- a/target/arm/cpu64.c |
30 | 32 | +++ b/target/arm/cpu64.c | |
31 | case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ | 33 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
32 | - if (sd->spi) | 34 | t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ |
33 | - goto unimplemented_cmd; | 35 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); |
34 | + if (sd->spi) { | 36 | t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); |
35 | + goto unimplemented_spi_cmd; | 37 | + t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ |
36 | + } | 38 | cpu->isar.id_aa64mmfr1 = t; |
37 | switch (sd->state) { | 39 | |
38 | case sd_transfer_state: | 40 | /* Replicate the same data to the 32-bit id registers. */ |
39 | /* Writing in SPI mode not implemented. */ | 41 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
40 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 42 | u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); |
41 | break; | 43 | cpu->isar.id_isar6 = u; |
42 | 44 | ||
43 | case 27: /* CMD27: PROGRAM_CSD */ | 45 | + u = cpu->id_mmfr3; |
44 | - if (sd->spi) | 46 | + u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ |
45 | - goto unimplemented_cmd; | 47 | + cpu->id_mmfr3 = u; |
46 | + if (sd->spi) { | 48 | + |
47 | + goto unimplemented_spi_cmd; | 49 | /* |
48 | + } | 50 | * FIXME: We do not yet support ARMv8.2-fp16 for AArch32 yet, |
49 | switch (sd->state) { | 51 | * so do not set MVFR1.FPHP. Strictly speaking this is not legal, |
50 | case sd_transfer_state: | ||
51 | sd->state = sd_receivingdata_state; | ||
52 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
53 | |||
54 | /* Lock card commands (Class 7) */ | ||
55 | case 42: /* CMD42: LOCK_UNLOCK */ | ||
56 | - if (sd->spi) | ||
57 | - goto unimplemented_cmd; | ||
58 | + if (sd->spi) { | ||
59 | + goto unimplemented_spi_cmd; | ||
60 | + } | ||
61 | switch (sd->state) { | ||
62 | case sd_transfer_state: | ||
63 | sd->state = sd_receivingdata_state; | ||
64 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
65 | qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); | ||
66 | return sd_illegal; | ||
67 | |||
68 | - unimplemented_cmd: | ||
69 | + unimplemented_spi_cmd: | ||
70 | /* Commands that are recognised but not yet implemented in SPI mode. */ | ||
71 | qemu_log_mask(LOG_UNIMP, "SD: CMD%i not implemented in SPI mode\n", | ||
72 | req.cmd); | ||
73 | -- | 52 | -- |
74 | 2.16.1 | 53 | 2.20.1 |
75 | 54 | ||
76 | 55 | diff view generated by jsdifflib |
1 | The register definitions for VMIDR and VMPIDR have separate | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | reginfo structs for the AArch32 and AArch64 registers. However | ||
3 | the 32-bit versions are wrong: | ||
4 | * they use offsetof instead of offsetoflow32 to mark where | ||
5 | the 32-bit value lives in the uint64_t CPU state field | ||
6 | * they don't mark themselves as ARM_CP_ALIAS | ||
7 | 2 | ||
8 | In particular this means that if you try to use an Arm guest CPU | 3 | Add definitions for all of the fields, up to ARMv8.5. |
9 | which enables EL2 on a big-endian host it will assert at reset: | 4 | Convert the existing RESERVED register to a full register. |
10 | target/arm/cpu.c:114: cp_reg_check_reset: Assertion `oldvalue == newvalue' failed. | 5 | Query KVM for the value of the register for the host. |
11 | 6 | ||
12 | because the reset of the 32-bit register writes to the top | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | half of the uint64_t. | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20200208125816.14954-18-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 17 +++++++++++++++++ | ||
13 | target/arm/helper.c | 4 ++-- | ||
14 | target/arm/kvm64.c | 2 ++ | ||
15 | 3 files changed, 21 insertions(+), 2 deletions(-) | ||
14 | 16 | ||
15 | Correct the errors in the structures. | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | 18 | index XXXXXXX..XXXXXXX 100644 | |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | --- a/target/arm/cpu.h |
18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 20 | +++ b/target/arm/cpu.h |
19 | --- | 21 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
20 | This is necessary for 'make check' to pass on big endian | 22 | uint64_t id_aa64pfr1; |
21 | systems with the 'raspi3' board enabled, which is the | 23 | uint64_t id_aa64mmfr0; |
22 | first board which has an EL2-enabled-by-default CPU. | 24 | uint64_t id_aa64mmfr1; |
23 | --- | 25 | + uint64_t id_aa64mmfr2; |
24 | target/arm/helper.c | 8 ++++---- | 26 | } isar; |
25 | 1 file changed, 4 insertions(+), 4 deletions(-) | 27 | uint32_t midr; |
26 | 28 | uint32_t revidr; | |
29 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64MMFR1, PAN, 20, 4) | ||
30 | FIELD(ID_AA64MMFR1, SPECSEI, 24, 4) | ||
31 | FIELD(ID_AA64MMFR1, XNX, 28, 4) | ||
32 | |||
33 | +FIELD(ID_AA64MMFR2, CNP, 0, 4) | ||
34 | +FIELD(ID_AA64MMFR2, UAO, 4, 4) | ||
35 | +FIELD(ID_AA64MMFR2, LSM, 8, 4) | ||
36 | +FIELD(ID_AA64MMFR2, IESB, 12, 4) | ||
37 | +FIELD(ID_AA64MMFR2, VARANGE, 16, 4) | ||
38 | +FIELD(ID_AA64MMFR2, CCIDX, 20, 4) | ||
39 | +FIELD(ID_AA64MMFR2, NV, 24, 4) | ||
40 | +FIELD(ID_AA64MMFR2, ST, 28, 4) | ||
41 | +FIELD(ID_AA64MMFR2, AT, 32, 4) | ||
42 | +FIELD(ID_AA64MMFR2, IDS, 36, 4) | ||
43 | +FIELD(ID_AA64MMFR2, FWB, 40, 4) | ||
44 | +FIELD(ID_AA64MMFR2, TTL, 48, 4) | ||
45 | +FIELD(ID_AA64MMFR2, BBM, 52, 4) | ||
46 | +FIELD(ID_AA64MMFR2, EVT, 56, 4) | ||
47 | +FIELD(ID_AA64MMFR2, E0PD, 60, 4) | ||
48 | + | ||
49 | FIELD(ID_DFR0, COPDBG, 0, 4) | ||
50 | FIELD(ID_DFR0, COPSDBG, 4, 4) | ||
51 | FIELD(ID_DFR0, MMAPDBG, 8, 4) | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 52 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
28 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/helper.c | 54 | --- a/target/arm/helper.c |
30 | +++ b/target/arm/helper.c | 55 | +++ b/target/arm/helper.c |
31 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 56 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
32 | { .name = "VPIDR", .state = ARM_CP_STATE_AA32, | 57 | .access = PL1_R, .type = ARM_CP_CONST, |
33 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | 58 | .accessfn = access_aa64_tid3, |
34 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | 59 | .resetvalue = cpu->isar.id_aa64mmfr1 }, |
35 | - .resetvalue = cpu->midr, | 60 | - { .name = "ID_AA64MMFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, |
36 | - .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, | 61 | + { .name = "ID_AA64MMFR2_EL1", .state = ARM_CP_STATE_AA64, |
37 | + .resetvalue = cpu->midr, .type = ARM_CP_ALIAS, | 62 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 2, |
38 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.vpidr_el2) }, | 63 | .access = PL1_R, .type = ARM_CP_CONST, |
39 | { .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64, | 64 | .accessfn = access_aa64_tid3, |
40 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | 65 | - .resetvalue = 0 }, |
41 | .access = PL2_RW, .resetvalue = cpu->midr, | 66 | + .resetvalue = cpu->isar.id_aa64mmfr2 }, |
42 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 67 | { .name = "ID_AA64MMFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, |
43 | { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, | 68 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 3, |
44 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | 69 | .access = PL1_R, .type = ARM_CP_CONST, |
45 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | 70 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c |
46 | - .resetvalue = vmpidr_def, | 71 | index XXXXXXX..XXXXXXX 100644 |
47 | - .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | 72 | --- a/target/arm/kvm64.c |
48 | + .resetvalue = vmpidr_def, .type = ARM_CP_ALIAS, | 73 | +++ b/target/arm/kvm64.c |
49 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.vmpidr_el2) }, | 74 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
50 | { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64, | 75 | ARM64_SYS_REG(3, 0, 0, 7, 0)); |
51 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | 76 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, |
52 | .access = PL2_RW, | 77 | ARM64_SYS_REG(3, 0, 0, 7, 1)); |
78 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, | ||
79 | + ARM64_SYS_REG(3, 0, 0, 7, 2)); | ||
80 | |||
81 | /* | ||
82 | * Note that if AArch32 support is not present in the host, | ||
53 | -- | 83 | -- |
54 | 2.16.1 | 84 | 2.20.1 |
55 | 85 | ||
56 | 86 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Create the SDCard in the realize() function. | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | |
5 | Suggested-by: Michael Walle <michael@walle.cc> | 5 | Message-id: 20200208125816.14954-19-richard.henderson@linaro.org |
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
8 | Acked-by: Michael Walle <michael@walle.cc> | ||
9 | Message-id: 20180216022933.10945-3-f4bug@amsat.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 7 | --- |
12 | hw/sd/milkymist-memcard.c | 28 ++++++++++++++++------------ | 8 | target/arm/cpu.h | 6 ++++++ |
13 | 1 file changed, 16 insertions(+), 12 deletions(-) | 9 | target/arm/internals.h | 3 +++ |
10 | target/arm/helper.c | 21 +++++++++++++++++++++ | ||
11 | target/arm/translate-a64.c | 14 ++++++++++++++ | ||
12 | 4 files changed, 44 insertions(+) | ||
14 | 13 | ||
15 | diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c | 14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/sd/milkymist-memcard.c | 16 | --- a/target/arm/cpu.h |
18 | +++ b/hw/sd/milkymist-memcard.c | 17 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ static void milkymist_memcard_reset(DeviceState *d) | 18 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); |
20 | device_reset(DEVICE(s->card)); | 19 | #define PSTATE_IL (1U << 20) |
20 | #define PSTATE_SS (1U << 21) | ||
21 | #define PSTATE_PAN (1U << 22) | ||
22 | +#define PSTATE_UAO (1U << 23) | ||
23 | #define PSTATE_V (1U << 28) | ||
24 | #define PSTATE_C (1U << 29) | ||
25 | #define PSTATE_Z (1U << 30) | ||
26 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ats1e1(const ARMISARegisters *id) | ||
27 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 2; | ||
21 | } | 28 | } |
22 | 29 | ||
23 | -static int milkymist_memcard_init(SysBusDevice *dev) | 30 | +static inline bool isar_feature_aa64_uao(const ARMISARegisters *id) |
24 | +static void milkymist_memcard_init(Object *obj) | ||
25 | +{ | 31 | +{ |
26 | + MilkymistMemcardState *s = MILKYMIST_MEMCARD(obj); | 32 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, UAO) != 0; |
27 | + SysBusDevice *dev = SYS_BUS_DEVICE(obj); | ||
28 | + | ||
29 | + memory_region_init_io(&s->regs_region, OBJECT(s), &memcard_mmio_ops, s, | ||
30 | + "milkymist-memcard", R_MAX * 4); | ||
31 | + sysbus_init_mmio(dev, &s->regs_region); | ||
32 | +} | 33 | +} |
33 | + | 34 | + |
34 | +static void milkymist_memcard_realize(DeviceState *dev, Error **errp) | 35 | static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) |
35 | { | 36 | { |
36 | MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev); | 37 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; |
37 | - DriveInfo *dinfo; | 38 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
38 | BlockBackend *blk; | 39 | index XXXXXXX..XXXXXXX 100644 |
39 | + DriveInfo *dinfo; | 40 | --- a/target/arm/internals.h |
40 | 41 | +++ b/target/arm/internals.h | |
41 | /* FIXME use a qdev drive property instead of drive_get_next() */ | 42 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) |
42 | dinfo = drive_get_next(IF_SD); | 43 | if (isar_feature_aa64_pan(id)) { |
43 | blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; | 44 | valid |= PSTATE_PAN; |
44 | s->card = sd_init(blk, false); | ||
45 | if (s->card == NULL) { | ||
46 | - return -1; | ||
47 | + error_setg(errp, "failed to init SD card"); | ||
48 | + return; | ||
49 | } | 45 | } |
50 | - | 46 | + if (isar_feature_aa64_uao(id)) { |
51 | s->enabled = blk && blk_is_inserted(blk); | 47 | + valid |= PSTATE_UAO; |
52 | - | 48 | + } |
53 | - memory_region_init_io(&s->regs_region, OBJECT(s), &memcard_mmio_ops, s, | 49 | |
54 | - "milkymist-memcard", R_MAX * 4); | 50 | return valid; |
55 | - sysbus_init_mmio(dev, &s->regs_region); | ||
56 | - | ||
57 | - return 0; | ||
58 | } | 51 | } |
59 | 52 | diff --git a/target/arm/helper.c b/target/arm/helper.c | |
60 | static const VMStateDescription vmstate_milkymist_memcard = { | 53 | index XXXXXXX..XXXXXXX 100644 |
61 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_milkymist_memcard = { | 54 | --- a/target/arm/helper.c |
62 | static void milkymist_memcard_class_init(ObjectClass *klass, void *data) | 55 | +++ b/target/arm/helper.c |
63 | { | 56 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pan_reginfo = { |
64 | DeviceClass *dc = DEVICE_CLASS(klass); | 57 | .readfn = aa64_pan_read, .writefn = aa64_pan_write |
65 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
66 | |||
67 | - k->init = milkymist_memcard_init; | ||
68 | + dc->realize = milkymist_memcard_realize; | ||
69 | dc->reset = milkymist_memcard_reset; | ||
70 | dc->vmsd = &vmstate_milkymist_memcard; | ||
71 | /* Reason: init() method uses drive_get_next() */ | ||
72 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo milkymist_memcard_info = { | ||
73 | .name = TYPE_MILKYMIST_MEMCARD, | ||
74 | .parent = TYPE_SYS_BUS_DEVICE, | ||
75 | .instance_size = sizeof(MilkymistMemcardState), | ||
76 | + .instance_init = milkymist_memcard_init, | ||
77 | .class_init = milkymist_memcard_class_init, | ||
78 | }; | 58 | }; |
79 | 59 | ||
60 | +static uint64_t aa64_uao_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
61 | +{ | ||
62 | + return env->pstate & PSTATE_UAO; | ||
63 | +} | ||
64 | + | ||
65 | +static void aa64_uao_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
66 | + uint64_t value) | ||
67 | +{ | ||
68 | + env->pstate = (env->pstate & ~PSTATE_UAO) | (value & PSTATE_UAO); | ||
69 | +} | ||
70 | + | ||
71 | +static const ARMCPRegInfo uao_reginfo = { | ||
72 | + .name = "UAO", .state = ARM_CP_STATE_AA64, | ||
73 | + .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 2, .opc2 = 4, | ||
74 | + .type = ARM_CP_NO_RAW, .access = PL1_RW, | ||
75 | + .readfn = aa64_uao_read, .writefn = aa64_uao_write | ||
76 | +}; | ||
77 | + | ||
78 | static CPAccessResult aa64_cacheop_access(CPUARMState *env, | ||
79 | const ARMCPRegInfo *ri, | ||
80 | bool isread) | ||
81 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
82 | define_arm_cp_regs(cpu, ats1cp_reginfo); | ||
83 | } | ||
84 | #endif | ||
85 | + if (cpu_isar_feature(aa64_uao, cpu)) { | ||
86 | + define_one_arm_cp_reg(cpu, &uao_reginfo); | ||
87 | + } | ||
88 | |||
89 | if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { | ||
90 | define_arm_cp_regs(cpu, vhe_reginfo); | ||
91 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/target/arm/translate-a64.c | ||
94 | +++ b/target/arm/translate-a64.c | ||
95 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
96 | s->base.is_jmp = DISAS_NEXT; | ||
97 | break; | ||
98 | |||
99 | + case 0x03: /* UAO */ | ||
100 | + if (!dc_isar_feature(aa64_uao, s) || s->current_el == 0) { | ||
101 | + goto do_unallocated; | ||
102 | + } | ||
103 | + if (crm & 1) { | ||
104 | + set_pstate_bits(PSTATE_UAO); | ||
105 | + } else { | ||
106 | + clear_pstate_bits(PSTATE_UAO); | ||
107 | + } | ||
108 | + t1 = tcg_const_i32(s->current_el); | ||
109 | + gen_helper_rebuild_hflags_a64(cpu_env, t1); | ||
110 | + tcg_temp_free_i32(t1); | ||
111 | + break; | ||
112 | + | ||
113 | case 0x04: /* PAN */ | ||
114 | if (!dc_isar_feature(aa64_pan, s) || s->current_el == 0) { | ||
115 | goto do_unallocated; | ||
80 | -- | 116 | -- |
81 | 2.16.1 | 117 | 2.20.1 |
82 | 118 | ||
83 | 119 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | replace switch(single case) -> if() | 3 | We need only override the current condition under which |
4 | TBFLAG_A64.UNPRIV is set. | ||
4 | 5 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180215221325.7611-16-f4bug@amsat.org | 8 | Message-id: 20200208125816.14954-20-richard.henderson@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | hw/sd/sd.c | 26 +++++++++++--------------- | 11 | target/arm/helper.c | 41 +++++++++++++++++++++-------------------- |
11 | 1 file changed, 11 insertions(+), 15 deletions(-) | 12 | 1 file changed, 21 insertions(+), 20 deletions(-) |
12 | 13 | ||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sd.c | 16 | --- a/target/arm/helper.c |
16 | +++ b/hw/sd/sd.c | 17 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 18 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, |
18 | 19 | } | |
19 | case 8: /* CMD8: SEND_IF_COND */ | 20 | |
20 | /* Physical Layer Specification Version 2.00 command */ | 21 | /* Compute the condition for using AccType_UNPRIV for LDTR et al. */ |
21 | - switch (sd->state) { | 22 | - /* TODO: ARMv8.2-UAO */ |
22 | - case sd_idle_state: | 23 | - switch (mmu_idx) { |
23 | - sd->vhs = 0; | 24 | - case ARMMMUIdx_E10_1: |
24 | - | 25 | - case ARMMMUIdx_E10_1_PAN: |
25 | - /* No response if not exactly one VHS bit is set. */ | 26 | - case ARMMMUIdx_SE10_1: |
26 | - if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { | 27 | - case ARMMMUIdx_SE10_1_PAN: |
27 | - return sd->spi ? sd_r7 : sd_r0; | 28 | - /* TODO: ARMv8.3-NV */ |
28 | - } | 29 | - flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); |
29 | - | 30 | - break; |
30 | - /* Accept. */ | 31 | - case ARMMMUIdx_E20_2: |
31 | - sd->vhs = req.arg; | 32 | - case ARMMMUIdx_E20_2_PAN: |
32 | - return sd_r7; | 33 | - /* TODO: ARMv8.4-SecEL2 */ |
33 | - | 34 | - /* |
34 | - default: | 35 | - * Note that E20_2 is gated by HCR_EL2.E2H == 1, but E20_0 is |
35 | + if (sd->state != sd_idle_state) { | 36 | - * gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR. |
36 | break; | 37 | - */ |
38 | - if (env->cp15.hcr_el2 & HCR_TGE) { | ||
39 | + if (!(env->pstate & PSTATE_UAO)) { | ||
40 | + switch (mmu_idx) { | ||
41 | + case ARMMMUIdx_E10_1: | ||
42 | + case ARMMMUIdx_E10_1_PAN: | ||
43 | + case ARMMMUIdx_SE10_1: | ||
44 | + case ARMMMUIdx_SE10_1_PAN: | ||
45 | + /* TODO: ARMv8.3-NV */ | ||
46 | flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); | ||
47 | + break; | ||
48 | + case ARMMMUIdx_E20_2: | ||
49 | + case ARMMMUIdx_E20_2_PAN: | ||
50 | + /* TODO: ARMv8.4-SecEL2 */ | ||
51 | + /* | ||
52 | + * Note that EL20_2 is gated by HCR_EL2.E2H == 1, but EL20_0 is | ||
53 | + * gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR. | ||
54 | + */ | ||
55 | + if (env->cp15.hcr_el2 & HCR_TGE) { | ||
56 | + flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); | ||
57 | + } | ||
58 | + break; | ||
59 | + default: | ||
60 | + break; | ||
37 | } | 61 | } |
38 | - break; | 62 | - break; |
39 | + sd->vhs = 0; | 63 | - default: |
40 | + | 64 | - break; |
41 | + /* No response if not exactly one VHS bit is set. */ | 65 | } |
42 | + if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { | 66 | |
43 | + return sd->spi ? sd_r7 : sd_r0; | 67 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); |
44 | + } | ||
45 | + | ||
46 | + /* Accept. */ | ||
47 | + sd->vhs = req.arg; | ||
48 | + return sd_r7; | ||
49 | |||
50 | case 9: /* CMD9: SEND_CSD */ | ||
51 | switch (sd->state) { | ||
52 | -- | 68 | -- |
53 | 2.16.1 | 69 | 2.20.1 |
54 | 70 | ||
55 | 71 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20180215221325.7611-5-f4bug@amsat.org | 5 | Message-id: 20200208125816.14954-21-richard.henderson@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/sd/sd.c | 9 ++++++--- | 8 | target/arm/cpu64.c | 4 ++++ |
9 | 1 file changed, 6 insertions(+), 3 deletions(-) | 9 | 1 file changed, 4 insertions(+) |
10 | 10 | ||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 11 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sd.c | 13 | --- a/target/arm/cpu64.c |
14 | +++ b/hw/sd/sd.c | 14 | +++ b/target/arm/cpu64.c |
15 | @@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque) | 15 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
16 | 16 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ | |
17 | static void sd_set_scr(SDState *sd) | 17 | cpu->isar.id_aa64mmfr1 = t; |
18 | { | 18 | |
19 | - sd->scr[0] = 0x00; /* SCR Structure */ | 19 | + t = cpu->isar.id_aa64mmfr2; |
20 | - sd->scr[1] = 0x2f; /* SD Security Support */ | 20 | + t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); |
21 | - sd->scr[2] = 0x00; | 21 | + cpu->isar.id_aa64mmfr2 = t; |
22 | + sd->scr[0] = (0 << 4) /* SCR version 1.0 */ | 22 | + |
23 | + | 0; /* Spec Versions 1.0 and 1.01 */ | 23 | /* Replicate the same data to the 32-bit id registers. */ |
24 | + sd->scr[1] = (2 << 4) /* SDSC Card (Security Version 1.01) */ | 24 | u = cpu->isar.id_isar5; |
25 | + | 0b0101; /* 1-bit or 4-bit width bus modes */ | 25 | u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */ |
26 | + sd->scr[2] = 0x00; /* Extended Security is not supported. */ | ||
27 | sd->scr[3] = 0x00; | ||
28 | + /* reserved for manufacturer usage */ | ||
29 | sd->scr[4] = 0x00; | ||
30 | sd->scr[5] = 0x00; | ||
31 | sd->scr[6] = 0x00; | ||
32 | -- | 26 | -- |
33 | 2.16.1 | 27 | 2.20.1 |
34 | 28 | ||
35 | 29 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Initialize EHCI controllers on AST2400 and AST2500 using the existing |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | TYPE_PLATFORM_EHCI. After this change, booting ast2500-evb into Linux |
5 | Message-id: 20180215220540.6556-5-f4bug@amsat.org | 5 | successfully instantiates a USB interface. |
6 | |||
7 | ehci-platform 1e6a3000.usb: EHCI Host Controller | ||
8 | ehci-platform 1e6a3000.usb: new USB bus registered, assigned bus number 1 | ||
9 | ehci-platform 1e6a3000.usb: irq 21, io mem 0x1e6a3000 | ||
10 | ehci-platform 1e6a3000.usb: USB 2.0 started, EHCI 1.00 | ||
11 | usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.05 | ||
12 | usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | ||
13 | usb usb1: Product: EHCI Host Controller | ||
14 | |||
15 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
16 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
17 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
19 | Message-id: 20200206183437.3979-1-linux@roeck-us.net | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 21 | --- |
8 | hw/sd/sd.c | 16 +--------------- | 22 | include/hw/arm/aspeed_soc.h | 6 ++++++ |
9 | 1 file changed, 1 insertion(+), 15 deletions(-) | 23 | hw/arm/aspeed_soc.c | 25 +++++++++++++++++++++++++ |
24 | 2 files changed, 31 insertions(+) | ||
10 | 25 | ||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 26 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
12 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sd.c | 28 | --- a/include/hw/arm/aspeed_soc.h |
14 | +++ b/hw/sd/sd.c | 29 | +++ b/include/hw/arm/aspeed_soc.h |
15 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ |
16 | 31 | #include "target/arm/cpu.h" | |
17 | //#define DEBUG_SD 1 | 32 | #include "hw/gpio/aspeed_gpio.h" |
18 | 33 | #include "hw/sd/aspeed_sdhci.h" | |
19 | -#ifdef DEBUG_SD | 34 | +#include "hw/usb/hcd-ehci.h" |
20 | -#define DPRINTF(fmt, ...) \ | 35 | |
21 | -do { fprintf(stderr, "SD: " fmt , ## __VA_ARGS__); } while (0) | 36 | #define ASPEED_SPIS_NUM 2 |
22 | -#else | 37 | +#define ASPEED_EHCIS_NUM 2 |
23 | -#define DPRINTF(fmt, ...) do {} while(0) | 38 | #define ASPEED_WDTS_NUM 4 |
24 | -#endif | 39 | #define ASPEED_CPUS_NUM 2 |
25 | - | 40 | #define ASPEED_MACS_NUM 4 |
26 | #define ACMD41_ENQUIRY_MASK 0x00ffffff | 41 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { |
27 | #define OCR_POWER_UP 0x80000000 | 42 | AspeedXDMAState xdma; |
28 | #define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ | 43 | AspeedSMCState fmc; |
29 | @@ -XXX,XX +XXX,XX @@ send_response: | 44 | AspeedSMCState spi[ASPEED_SPIS_NUM]; |
45 | + EHCISysBusState ehci[ASPEED_EHCIS_NUM]; | ||
46 | AspeedSDMCState sdmc; | ||
47 | AspeedWDTState wdt[ASPEED_WDTS_NUM]; | ||
48 | FTGMAC100State ftgmac100[ASPEED_MACS_NUM]; | ||
49 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCClass { | ||
50 | uint32_t silicon_rev; | ||
51 | uint64_t sram_size; | ||
52 | int spis_num; | ||
53 | + int ehcis_num; | ||
54 | int wdts_num; | ||
55 | int macs_num; | ||
56 | const int *irqmap; | ||
57 | @@ -XXX,XX +XXX,XX @@ enum { | ||
58 | ASPEED_FMC, | ||
59 | ASPEED_SPI1, | ||
60 | ASPEED_SPI2, | ||
61 | + ASPEED_EHCI1, | ||
62 | + ASPEED_EHCI2, | ||
63 | ASPEED_VIC, | ||
64 | ASPEED_SDMC, | ||
65 | ASPEED_SCU, | ||
66 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/arm/aspeed_soc.c | ||
69 | +++ b/hw/arm/aspeed_soc.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2400_memmap[] = { | ||
71 | [ASPEED_IOMEM] = 0x1E600000, | ||
72 | [ASPEED_FMC] = 0x1E620000, | ||
73 | [ASPEED_SPI1] = 0x1E630000, | ||
74 | + [ASPEED_EHCI1] = 0x1E6A1000, | ||
75 | [ASPEED_VIC] = 0x1E6C0000, | ||
76 | [ASPEED_SDMC] = 0x1E6E0000, | ||
77 | [ASPEED_SCU] = 0x1E6E2000, | ||
78 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2500_memmap[] = { | ||
79 | [ASPEED_FMC] = 0x1E620000, | ||
80 | [ASPEED_SPI1] = 0x1E630000, | ||
81 | [ASPEED_SPI2] = 0x1E631000, | ||
82 | + [ASPEED_EHCI1] = 0x1E6A1000, | ||
83 | + [ASPEED_EHCI2] = 0x1E6A3000, | ||
84 | [ASPEED_VIC] = 0x1E6C0000, | ||
85 | [ASPEED_SDMC] = 0x1E6E0000, | ||
86 | [ASPEED_SCU] = 0x1E6E2000, | ||
87 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { | ||
88 | [ASPEED_UART5] = 10, | ||
89 | [ASPEED_VUART] = 8, | ||
90 | [ASPEED_FMC] = 19, | ||
91 | + [ASPEED_EHCI1] = 5, | ||
92 | + [ASPEED_EHCI2] = 13, | ||
93 | [ASPEED_SDMC] = 0, | ||
94 | [ASPEED_SCU] = 21, | ||
95 | [ASPEED_ADC] = 31, | ||
96 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
97 | sizeof(s->spi[i]), typename); | ||
30 | } | 98 | } |
31 | 99 | ||
32 | #ifdef DEBUG_SD | 100 | + for (i = 0; i < sc->ehcis_num; i++) { |
33 | - if (rsplen) { | 101 | + sysbus_init_child_obj(obj, "ehci[*]", OBJECT(&s->ehci[i]), |
34 | - int i; | 102 | + sizeof(s->ehci[i]), TYPE_PLATFORM_EHCI); |
35 | - DPRINTF("Response:"); | 103 | + } |
36 | - for (i = 0; i < rsplen; i++) { | 104 | + |
37 | - DPRINTF(" %02x", response[i]); | 105 | snprintf(typename, sizeof(typename), "aspeed.sdmc-%s", socname); |
38 | - } | 106 | sysbus_init_child_obj(obj, "sdmc", OBJECT(&s->sdmc), sizeof(s->sdmc), |
39 | - DPRINTF(" state %d\n", sd->state); | 107 | typename); |
40 | - } | 108 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
41 | + qemu_hexdump((const char *)response, stderr, "Response", rsplen); | 109 | s->spi[i].ctrl->flash_window_base); |
42 | #endif | 110 | } |
43 | 111 | ||
44 | return rsplen; | 112 | + /* EHCI */ |
113 | + for (i = 0; i < sc->ehcis_num; i++) { | ||
114 | + object_property_set_bool(OBJECT(&s->ehci[i]), true, "realized", &err); | ||
115 | + if (err) { | ||
116 | + error_propagate(errp, err); | ||
117 | + return; | ||
118 | + } | ||
119 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, | ||
120 | + sc->memmap[ASPEED_EHCI1 + i]); | ||
121 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, | ||
122 | + aspeed_soc_get_irq(s, ASPEED_EHCI1 + i)); | ||
123 | + } | ||
124 | + | ||
125 | /* SDMC - SDRAM Memory Controller */ | ||
126 | object_property_set_bool(OBJECT(&s->sdmc), true, "realized", &err); | ||
127 | if (err) { | ||
128 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data) | ||
129 | sc->silicon_rev = AST2400_A1_SILICON_REV; | ||
130 | sc->sram_size = 0x8000; | ||
131 | sc->spis_num = 1; | ||
132 | + sc->ehcis_num = 1; | ||
133 | sc->wdts_num = 2; | ||
134 | sc->macs_num = 2; | ||
135 | sc->irqmap = aspeed_soc_ast2400_irqmap; | ||
136 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data) | ||
137 | sc->silicon_rev = AST2500_A1_SILICON_REV; | ||
138 | sc->sram_size = 0x9000; | ||
139 | sc->spis_num = 2; | ||
140 | + sc->ehcis_num = 2; | ||
141 | sc->wdts_num = 3; | ||
142 | sc->macs_num = 2; | ||
143 | sc->irqmap = aspeed_soc_ast2500_irqmap; | ||
45 | -- | 144 | -- |
46 | 2.16.1 | 145 | 2.20.1 |
47 | 146 | ||
48 | 147 | diff view generated by jsdifflib |
1 | From: Hugo Landau <hlandau@devever.net> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | Some register blocks of the ast2500 are protected by protection key | 3 | Initialize EHCI controllers on AST2600 using the existing |
4 | registers which require the right magic value to be written to those | 4 | TYPE_PLATFORM_EHCI. After this change, booting ast2600-evb |
5 | registers to allow those registers to be mutated. | 5 | into Linux successfully instantiates a USB interface after |
6 | the necessary changes are made to its devicetree files. | ||
6 | 7 | ||
7 | Register manuals indicate that writing the correct magic value to these | 8 | ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver |
8 | registers should cause subsequent reads from those values to return 1, | 9 | ehci-platform: EHCI generic platform driver |
9 | and writing any other value should cause subsequent reads to return 0. | 10 | ehci-platform 1e6a3000.usb: EHCI Host Controller |
11 | ehci-platform 1e6a3000.usb: new USB bus registered, assigned bus number 1 | ||
12 | ehci-platform 1e6a3000.usb: irq 25, io mem 0x1e6a3000 | ||
13 | ehci-platform 1e6a3000.usb: USB 2.0 started, EHCI 1.00 | ||
14 | usb usb1: Manufacturer: Linux 5.5.0-09825-ga0802f2d0ef5-dirty ehci_hcd | ||
15 | usb 1-1: new high-speed USB device number 2 using ehci-platform | ||
10 | 16 | ||
11 | Previously, qemu implemented these registers incorrectly: the registers | ||
12 | were handled as simple memory, meaning that writing some value x to a | ||
13 | protection key register would result in subsequent reads from that | ||
14 | register returning the same value x. The protection was implemented by | ||
15 | ensuring that the current value of that register equaled the magic | ||
16 | value. | ||
17 | |||
18 | This modifies qemu to have the correct behaviour: attempts to write to a | ||
19 | ast2500 protection register results in a transition to 1 or 0 depending | ||
20 | on whether the written value is the correct magic. The protection logic | ||
21 | is updated to ensure that the value of the register is nonzero. | ||
22 | |||
23 | This bug caused deadlocks with u-boot HEAD: when u-boot is done with a | ||
24 | protectable register block, it attempts to lock it by writing the | ||
25 | bitwise inverse of the correct magic value, and then spinning forever | ||
26 | until the register reads as zero. Since qemu implemented writes to these | ||
27 | registers as ordinary memory writes, writing the inverse of the magic | ||
28 | value resulted in subsequent reads returning that value, leading to | ||
29 | u-boot spinning forever. | ||
30 | |||
31 | Signed-off-by: Hugo Landau <hlandau@devever.net> | ||
32 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 17 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
33 | Acked-by: Andrew Jeffery <andrew@aj.id.au> | 18 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> |
34 | Message-id: 20180220132627.4163-1-hlandau@devever.net | 19 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> |
35 | [PMM: fixed incorrect code indentation] | 20 | Message-id: 20200207174548.9087-1-linux@roeck-us.net |
36 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
37 | --- | 22 | --- |
38 | hw/misc/aspeed_scu.c | 6 +++++- | 23 | hw/arm/aspeed_ast2600.c | 23 +++++++++++++++++++++++ |
39 | hw/misc/aspeed_sdmc.c | 8 +++++++- | 24 | 1 file changed, 23 insertions(+) |
40 | 2 files changed, 12 insertions(+), 2 deletions(-) | ||
41 | 25 | ||
42 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | 26 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c |
43 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/hw/misc/aspeed_scu.c | 28 | --- a/hw/arm/aspeed_ast2600.c |
45 | +++ b/hw/misc/aspeed_scu.c | 29 | +++ b/hw/arm/aspeed_ast2600.c |
46 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | 30 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { |
31 | [ASPEED_FMC] = 0x1E620000, | ||
32 | [ASPEED_SPI1] = 0x1E630000, | ||
33 | [ASPEED_SPI2] = 0x1E641000, | ||
34 | + [ASPEED_EHCI1] = 0x1E6A1000, | ||
35 | + [ASPEED_EHCI2] = 0x1E6A3000, | ||
36 | [ASPEED_MII1] = 0x1E650000, | ||
37 | [ASPEED_MII2] = 0x1E650008, | ||
38 | [ASPEED_MII3] = 0x1E650010, | ||
39 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = { | ||
40 | [ASPEED_ADC] = 78, | ||
41 | [ASPEED_XDMA] = 6, | ||
42 | [ASPEED_SDHCI] = 43, | ||
43 | + [ASPEED_EHCI1] = 5, | ||
44 | + [ASPEED_EHCI2] = 9, | ||
45 | [ASPEED_EMMC] = 15, | ||
46 | [ASPEED_GPIO] = 40, | ||
47 | [ASPEED_GPIO_1_8V] = 11, | ||
48 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
49 | sizeof(s->spi[i]), typename); | ||
47 | } | 50 | } |
48 | 51 | ||
49 | if (reg > PROT_KEY && reg < CPU2_BASE_SEG1 && | 52 | + for (i = 0; i < sc->ehcis_num; i++) { |
50 | - s->regs[PROT_KEY] != ASPEED_SCU_PROT_KEY) { | 53 | + sysbus_init_child_obj(obj, "ehci[*]", OBJECT(&s->ehci[i]), |
51 | + !s->regs[PROT_KEY]) { | 54 | + sizeof(s->ehci[i]), TYPE_PLATFORM_EHCI); |
52 | qemu_log_mask(LOG_GUEST_ERROR, "%s: SCU is locked!\n", __func__); | ||
53 | return; | ||
54 | } | ||
55 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
56 | trace_aspeed_scu_write(offset, size, data); | ||
57 | |||
58 | switch (reg) { | ||
59 | + case PROT_KEY: | ||
60 | + s->regs[reg] = (data == ASPEED_SCU_PROT_KEY) ? 1 : 0; | ||
61 | + return; | ||
62 | + | ||
63 | case FREQ_CNTR_EVAL: | ||
64 | case VGA_SCRATCH1 ... VGA_SCRATCH8: | ||
65 | case RNG_DATA: | ||
66 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/misc/aspeed_sdmc.c | ||
69 | +++ b/hw/misc/aspeed_sdmc.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data, | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | - if (addr != R_PROT && s->regs[R_PROT] != PROT_KEY_UNLOCK) { | ||
75 | + if (addr == R_PROT) { | ||
76 | + s->regs[addr] = (data == PROT_KEY_UNLOCK) ? 1 : 0; | ||
77 | + return; | ||
78 | + } | 55 | + } |
79 | + | 56 | + |
80 | + if (!s->regs[R_PROT]) { | 57 | snprintf(typename, sizeof(typename), "aspeed.sdmc-%s", socname); |
81 | qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__); | 58 | sysbus_init_child_obj(obj, "sdmc", OBJECT(&s->sdmc), sizeof(s->sdmc), |
82 | return; | 59 | typename); |
60 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
61 | s->spi[i].ctrl->flash_window_base); | ||
83 | } | 62 | } |
84 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data, | 63 | |
85 | data &= ~ASPEED_SDMC_READONLY_MASK; | 64 | + /* EHCI */ |
86 | break; | 65 | + for (i = 0; i < sc->ehcis_num; i++) { |
87 | case AST2500_A0_SILICON_REV: | 66 | + object_property_set_bool(OBJECT(&s->ehci[i]), true, "realized", &err); |
88 | + case AST2500_A1_SILICON_REV: | 67 | + if (err) { |
89 | data &= ~ASPEED_SDMC_AST2500_READONLY_MASK; | 68 | + error_propagate(errp, err); |
90 | break; | 69 | + return; |
91 | default: | 70 | + } |
71 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, | ||
72 | + sc->memmap[ASPEED_EHCI1 + i]); | ||
73 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, | ||
74 | + aspeed_soc_get_irq(s, ASPEED_EHCI1 + i)); | ||
75 | + } | ||
76 | + | ||
77 | /* SDMC - SDRAM Memory Controller */ | ||
78 | object_property_set_bool(OBJECT(&s->sdmc), true, "realized", &err); | ||
79 | if (err) { | ||
80 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) | ||
81 | sc->silicon_rev = AST2600_A0_SILICON_REV; | ||
82 | sc->sram_size = 0x10000; | ||
83 | sc->spis_num = 2; | ||
84 | + sc->ehcis_num = 2; | ||
85 | sc->wdts_num = 4; | ||
86 | sc->macs_num = 4; | ||
87 | sc->irqmap = aspeed_soc_ast2600_irqmap; | ||
92 | -- | 88 | -- |
93 | 2.16.1 | 89 | 2.20.1 |
94 | 90 | ||
95 | 91 | diff view generated by jsdifflib |
1 | From: Richard Braun <rbraun@sceen.net> | 1 | From: Chen Qun <kuhn.chenqun@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | I/O currently being synchronous, there is no reason to ever clear the | 3 | It's easy to reproduce as follow: |
4 | SR_TXE bit. However the SR_TC bit may be cleared by software writing | 4 | virsh qemu-monitor-command vm1 --pretty '{"execute": "device-list-properties", |
5 | to the SR register, so set it on each write. | 5 | "arguments":{"typename":"exynos4210.uart"}}' |
6 | 6 | ||
7 | In addition, fix the reset value of the USART status register. | 7 | ASAN shows memory leak stack: |
8 | #1 0xfffd896d71cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) | ||
9 | #2 0xaaad270beee3 in timer_new_full /qemu/include/qemu/timer.h:530 | ||
10 | #3 0xaaad270beee3 in timer_new /qemu/include/qemu/timer.h:551 | ||
11 | #4 0xaaad270beee3 in timer_new_ns /qemu/include/qemu/timer.h:569 | ||
12 | #5 0xaaad270beee3 in exynos4210_uart_init /qemu/hw/char/exynos4210_uart.c:677 | ||
13 | #6 0xaaad275c8f4f in object_initialize_with_type /qemu/qom/object.c:516 | ||
14 | #7 0xaaad275c91bb in object_new_with_type /qemu/qom/object.c:684 | ||
15 | #8 0xaaad2755df2f in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:152 | ||
8 | 16 | ||
9 | Signed-off-by: Richard Braun <rbraun@sceen.net> | 17 | Reported-by: Euler Robot <euler.robot@huawei.com> |
10 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 18 | Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com> |
11 | [PMM: removed XXX tag from comment, since it isn't something | 19 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
12 | we need to come back and fix in QEMU] | 20 | Message-id: 20200213025603.149432-1-kuhn.chenqun@huawei.com |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 22 | --- |
15 | include/hw/char/stm32f2xx_usart.h | 7 ++++++- | 23 | hw/char/exynos4210_uart.c | 5 +++-- |
16 | hw/char/stm32f2xx_usart.c | 12 ++++++++---- | 24 | 1 file changed, 3 insertions(+), 2 deletions(-) |
17 | 2 files changed, 14 insertions(+), 5 deletions(-) | ||
18 | 25 | ||
19 | diff --git a/include/hw/char/stm32f2xx_usart.h b/include/hw/char/stm32f2xx_usart.h | 26 | diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c |
20 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/hw/char/stm32f2xx_usart.h | 28 | --- a/hw/char/exynos4210_uart.c |
22 | +++ b/include/hw/char/stm32f2xx_usart.h | 29 | +++ b/hw/char/exynos4210_uart.c |
23 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_uart_init(Object *obj) |
24 | #define USART_CR3 0x14 | 31 | SysBusDevice *dev = SYS_BUS_DEVICE(obj); |
25 | #define USART_GTPR 0x18 | 32 | Exynos4210UartState *s = EXYNOS4210_UART(dev); |
26 | 33 | ||
27 | -#define USART_SR_RESET 0x00C00000 | 34 | - s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, |
28 | +/* | 35 | - exynos4210_uart_timeout_int, s); |
29 | + * NB: The reset value mentioned in "24.6.1 Status register" seems bogus. | 36 | s->wordtime = NANOSECONDS_PER_SECOND * 10 / 9600; |
30 | + * Looking at "Table 98 USART register map and reset values", it seems it | 37 | |
31 | + * should be 0xc0, and that's how real hardware behaves. | 38 | /* memory mapping */ |
32 | + */ | 39 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_uart_realize(DeviceState *dev, Error **errp) |
33 | +#define USART_SR_RESET (USART_SR_TXE | USART_SR_TC) | 40 | { |
34 | 41 | Exynos4210UartState *s = EXYNOS4210_UART(dev); | |
35 | #define USART_SR_TXE (1 << 7) | 42 | |
36 | #define USART_SR_TC (1 << 6) | 43 | + s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, |
37 | diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c | 44 | + exynos4210_uart_timeout_int, s); |
38 | index XXXXXXX..XXXXXXX 100644 | 45 | + |
39 | --- a/hw/char/stm32f2xx_usart.c | 46 | qemu_chr_fe_set_handlers(&s->chr, exynos4210_uart_can_receive, |
40 | +++ b/hw/char/stm32f2xx_usart.c | 47 | exynos4210_uart_receive, exynos4210_uart_event, |
41 | @@ -XXX,XX +XXX,XX @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr, | 48 | NULL, s, NULL, true); |
42 | switch (addr) { | ||
43 | case USART_SR: | ||
44 | retvalue = s->usart_sr; | ||
45 | - s->usart_sr &= ~USART_SR_TC; | ||
46 | qemu_chr_fe_accept_input(&s->chr); | ||
47 | return retvalue; | ||
48 | case USART_DR: | ||
49 | DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr); | ||
50 | - s->usart_sr |= USART_SR_TXE; | ||
51 | s->usart_sr &= ~USART_SR_RXNE; | ||
52 | qemu_chr_fe_accept_input(&s->chr); | ||
53 | qemu_set_irq(s->irq, 0); | ||
54 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_usart_write(void *opaque, hwaddr addr, | ||
55 | switch (addr) { | ||
56 | case USART_SR: | ||
57 | if (value <= 0x3FF) { | ||
58 | - s->usart_sr = value; | ||
59 | + /* I/O being synchronous, TXE is always set. In addition, it may | ||
60 | + only be set by hardware, so keep it set here. */ | ||
61 | + s->usart_sr = value | USART_SR_TXE; | ||
62 | } else { | ||
63 | s->usart_sr &= value; | ||
64 | } | ||
65 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_usart_write(void *opaque, hwaddr addr, | ||
66 | /* XXX this blocks entire thread. Rewrite to use | ||
67 | * qemu_chr_fe_write and background I/O callbacks */ | ||
68 | qemu_chr_fe_write_all(&s->chr, &ch, 1); | ||
69 | + /* XXX I/O are currently synchronous, making it impossible for | ||
70 | + software to observe transient states where TXE or TC aren't | ||
71 | + set. Unlike TXE however, which is read-only, software may | ||
72 | + clear TC by writing 0 to the SR register, so set it again | ||
73 | + on each write. */ | ||
74 | s->usart_sr |= USART_SR_TC; | ||
75 | - s->usart_sr &= ~USART_SR_TXE; | ||
76 | } | ||
77 | return; | ||
78 | case USART_BRR: | ||
79 | -- | 49 | -- |
80 | 2.16.1 | 50 | 2.20.1 |
81 | 51 | ||
82 | 52 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | code is now easier to read. | 3 | When booting without device tree, the Linux kernels uses the $R1 |
4 | register to determine the machine type. The list of values is | ||
5 | registered at [1]. | ||
4 | 6 | ||
7 | There are two entries for the Raspberry Pi: | ||
8 | |||
9 | - https://www.arm.linux.org.uk/developer/machines/list.php?mid=3138 | ||
10 | name: MACH_TYPE_BCM2708 | ||
11 | value: 0xc42 (3138) | ||
12 | status: Active, not mainlined | ||
13 | date: 15 Oct 2010 | ||
14 | |||
15 | - https://www.arm.linux.org.uk/developer/machines/list.php?mid=4828 | ||
16 | name: MACH_TYPE_BCM2835 | ||
17 | value: 4828 | ||
18 | status: Active, mainlined | ||
19 | date: 6 Dec 2013 | ||
20 | |||
21 | QEMU always used the non-mainlined type MACH_TYPE_BCM2708. | ||
22 | The value 0xc43 is registered to 'MX51_GGC' (processor i.MX51), and | ||
23 | 0xc44 to 'Western Digital Sharespace NAS' (processor Marvell 88F5182). | ||
24 | |||
25 | The Raspberry Pi foundation bootloader only sets the BCM2708 machine | ||
26 | type, see [2] or [3]: | ||
27 | |||
28 | 133 9: | ||
29 | 134 mov r0, #0 | ||
30 | 135 ldr r1, =3138 @ BCM2708 machine id | ||
31 | 136 ldr r2, atags @ ATAGS | ||
32 | 137 bx r4 | ||
33 | |||
34 | U-Boot only uses MACH_TYPE_BCM2708 (see [4]): | ||
35 | |||
36 | 25 /* | ||
37 | 26 * 2835 is a SKU in a series for which the 2708 is the first or primary SoC, | ||
38 | 27 * so 2708 has historically been used rather than a dedicated 2835 ID. | ||
39 | 28 * | ||
40 | 29 * We don't define a machine type for bcm2709/bcm2836 since the RPi Foundation | ||
41 | 30 * chose to use someone else's previously registered machine ID (3139, MX51_GGC) | ||
42 | 31 * rather than obtaining a valid ID:-/ | ||
43 | 32 * | ||
44 | 33 * For the bcm2837, hopefully a machine type is not needed, since everything | ||
45 | 34 * is DT. | ||
46 | 35 */ | ||
47 | |||
48 | While the definition MACH_BCM2709 with value 0xc43 was introduced in | ||
49 | a commit described "Add 2709 platform for Raspberry Pi 2" out of the | ||
50 | mainline Linux kernel, it does not seem used, and the platform is | ||
51 | introduced with Device Tree support anyway (see [5] and [6]). | ||
52 | |||
53 | Remove the unused values (0xc43 introduced in commit 1df7d1f9303aef | ||
54 | "raspi: add raspberry pi 2 machine" and 0xc44 in commit bade58166f4 | ||
55 | "raspi: Raspberry Pi 3 support"), keeping only MACH_TYPE_BCM2708. | ||
56 | |||
57 | [1] https://www.arm.linux.org.uk/developer/machines/ | ||
58 | [2] https://github.com/raspberrypi/tools/blob/920c7ed2e/armstubs/armstub7.S#L135 | ||
59 | [3] https://github.com/raspberrypi/tools/blob/49719d554/armstubs/armstub7.S#L64 | ||
60 | [4] https://gitlab.denx.de/u-boot/u-boot/blob/v2015.04/include/configs/rpi-common.h#L18 | ||
61 | [5] https://github.com/raspberrypi/linux/commit/d9fac63adac#diff-6722037d79570df5b392a49e0e006573R526 | ||
62 | [6] http://lists.infradead.org/pipermail/linux-rpi-kernel/2015-February/001268.html | ||
63 | |||
64 | Cc: Zoltán Baldaszti <bztemail@gmail.com> | ||
65 | Cc: Pekka Enberg <penberg@iki.fi> | ||
66 | Cc: Stephen Warren <swarren@nvidia.com> | ||
67 | Cc: Kshitij Soni <kshitij.soni@broadcom.com> | ||
68 | Cc: Michael Chan <michael.chan@broadcom.com> | ||
69 | Cc: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
70 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 71 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 72 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> |
7 | Message-id: 20180215220540.6556-11-f4bug@amsat.org | 73 | Message-id: 20200208165645.15657-2-f4bug@amsat.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 74 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 75 | --- |
10 | hw/sd/sd.c | 3 ++- | 76 | hw/arm/raspi.c | 6 +++--- |
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | 77 | 1 file changed, 3 insertions(+), 3 deletions(-) |
12 | 78 | ||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 79 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
14 | index XXXXXXX..XXXXXXX 100644 | 80 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sd.c | 81 | --- a/hw/arm/raspi.c |
16 | +++ b/hw/sd/sd.c | 82 | +++ b/hw/arm/raspi.c |
17 | @@ -XXX,XX +XXX,XX @@ | 83 | @@ -XXX,XX +XXX,XX @@ |
18 | #include "hw/sd/sd.h" | 84 | #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ |
19 | #include "qapi/error.h" | 85 | #define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */ |
20 | #include "qemu/bitmap.h" | 86 | |
21 | +#include "qemu/cutils.h" | 87 | -/* Table of Linux board IDs for different Pi versions */ |
22 | #include "hw/qdev-properties.h" | 88 | -static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; |
23 | #include "qemu/error-report.h" | 89 | +/* Registered machine type (matches RPi Foundation bootloader and U-Boot) */ |
24 | #include "qemu/timer.h" | 90 | +#define MACH_TYPE_BCM2708 3138 |
25 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | 91 | |
26 | uint32_t sectsize = (1 << (SECTOR_SHIFT + 1)) - 1; | 92 | typedef struct RasPiState { |
27 | uint32_t wpsize = (1 << (WPGROUP_SHIFT + 1)) - 1; | 93 | BCM283XState soc; |
28 | 94 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | |
29 | - if (size <= 0x40000000) { /* Standard Capacity SD */ | 95 | static struct arm_boot_info binfo; |
30 | + if (size <= 1 * G_BYTE) { /* Standard Capacity SD */ | 96 | int r; |
31 | sd->csd[0] = 0x00; /* CSD structure */ | 97 | |
32 | sd->csd[1] = 0x26; /* Data read access-time-1 */ | 98 | - binfo.board_id = raspi_boardid[version]; |
33 | sd->csd[2] = 0x00; /* Data read access-time-2 */ | 99 | + binfo.board_id = MACH_TYPE_BCM2708; |
100 | binfo.ram_size = ram_size; | ||
101 | binfo.nb_cpus = machine->smp.cpus; | ||
102 | |||
34 | -- | 103 | -- |
35 | 2.16.1 | 104 | 2.20.1 |
36 | 105 | ||
37 | 106 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | place card registers first, this will ease further code movements. | 3 | We hardcode the board revision as 0xa21041 for the raspi2, and |
4 | 0xa02082 for the raspi3: | ||
5 | |||
6 | 166 static void raspi_init(MachineState *machine, int version) | ||
7 | 167 { | ||
8 | ... | ||
9 | 194 int board_rev = version == 3 ? 0xa02082 : 0xa21041; | ||
10 | |||
11 | These revision codes are for the 2B and 3B models, see: | ||
12 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md | ||
13 | |||
14 | Correct the board description. | ||
4 | 15 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 16 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 17 | Message-id: 20200208165645.15657-3-f4bug@amsat.org |
7 | Message-id: 20180215220540.6556-2-f4bug@amsat.org | 18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 20 | --- |
10 | hw/sd/sd.c | 16 +++++++++------- | 21 | hw/arm/raspi.c | 4 ++-- |
11 | 1 file changed, 9 insertions(+), 7 deletions(-) | 22 | 1 file changed, 2 insertions(+), 2 deletions(-) |
12 | 23 | ||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 24 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
14 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sd.c | 26 | --- a/hw/arm/raspi.c |
16 | +++ b/hw/sd/sd.c | 27 | +++ b/hw/arm/raspi.c |
17 | @@ -XXX,XX +XXX,XX @@ enum SDCardStates { | 28 | @@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine) |
18 | struct SDState { | 29 | |
19 | DeviceState parent_obj; | 30 | static void raspi2_machine_init(MachineClass *mc) |
20 | 31 | { | |
21 | - uint32_t mode; /* current card mode, one of SDCardModes */ | 32 | - mc->desc = "Raspberry Pi 2"; |
22 | - int32_t state; /* current card state, one of SDCardStates */ | 33 | + mc->desc = "Raspberry Pi 2B"; |
23 | + /* SD Memory Card Registers */ | 34 | mc->init = raspi2_init; |
24 | uint32_t ocr; | 35 | mc->block_default_type = IF_SD; |
25 | - QEMUTimer *ocr_power_timer; | 36 | mc->no_parallel = 1; |
26 | uint8_t scr[8]; | 37 | @@ -XXX,XX +XXX,XX @@ static void raspi3_init(MachineState *machine) |
27 | uint8_t cid[16]; | 38 | |
28 | uint8_t csd[16]; | 39 | static void raspi3_machine_init(MachineClass *mc) |
29 | uint16_t rca; | 40 | { |
30 | uint32_t card_status; | 41 | - mc->desc = "Raspberry Pi 3"; |
31 | uint8_t sd_status[64]; | 42 | + mc->desc = "Raspberry Pi 3B"; |
32 | + | 43 | mc->init = raspi3_init; |
33 | + /* Configurable properties */ | 44 | mc->block_default_type = IF_SD; |
34 | + BlockBackend *blk; | 45 | mc->no_parallel = 1; |
35 | + bool spi; | ||
36 | + | ||
37 | + uint32_t mode; /* current card mode, one of SDCardModes */ | ||
38 | + int32_t state; /* current card state, one of SDCardStates */ | ||
39 | uint32_t vhs; | ||
40 | bool wp_switch; | ||
41 | unsigned long *wp_groups; | ||
42 | @@ -XXX,XX +XXX,XX @@ struct SDState { | ||
43 | uint8_t pwd[16]; | ||
44 | uint32_t pwd_len; | ||
45 | uint8_t function_group[6]; | ||
46 | - | ||
47 | - bool spi; | ||
48 | uint8_t current_cmd; | ||
49 | /* True if we will handle the next command as an ACMD. Note that this does | ||
50 | * *not* track the APP_CMD status bit! | ||
51 | @@ -XXX,XX +XXX,XX @@ struct SDState { | ||
52 | uint8_t data[512]; | ||
53 | qemu_irq readonly_cb; | ||
54 | qemu_irq inserted_cb; | ||
55 | - BlockBackend *blk; | ||
56 | - | ||
57 | + QEMUTimer *ocr_power_timer; | ||
58 | bool enable; | ||
59 | uint8_t dat_lines; | ||
60 | bool cmd_line; | ||
61 | -- | 46 | -- |
62 | 2.16.1 | 47 | 2.20.1 |
63 | 48 | ||
64 | 49 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | the code is easier to review/refactor. | 3 | The board revision encode the board version. Add a helper |
4 | to extract the version, and use it. | ||
4 | 5 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 7 | Message-id: 20200208165645.15657-4-f4bug@amsat.org |
7 | Message-id: 20180215221325.7611-7-f4bug@amsat.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | hw/sd/sd.c | 38 +++++++++----------------------------- | 11 | hw/arm/raspi.c | 31 +++++++++++++++++++++++++++---- |
12 | 1 file changed, 9 insertions(+), 29 deletions(-) | 12 | 1 file changed, 27 insertions(+), 4 deletions(-) |
13 | 13 | ||
14 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/sd/sd.c | 16 | --- a/hw/arm/raspi.c |
17 | +++ b/hw/sd/sd.c | 17 | +++ b/hw/arm/raspi.c |
18 | @@ -XXX,XX +XXX,XX @@ static int sd_req_crc_validate(SDRequest *req) | 18 | @@ -XXX,XX +XXX,XX @@ |
19 | #include "qapi/error.h" | ||
20 | #include "cpu.h" | ||
21 | #include "hw/arm/bcm2836.h" | ||
22 | +#include "hw/registerfields.h" | ||
23 | #include "qemu/error-report.h" | ||
24 | #include "hw/boards.h" | ||
25 | #include "hw/loader.h" | ||
26 | @@ -XXX,XX +XXX,XX @@ typedef struct RasPiState { | ||
27 | MemoryRegion ram; | ||
28 | } RasPiState; | ||
29 | |||
30 | +/* | ||
31 | + * Board revision codes: | ||
32 | + * www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/ | ||
33 | + */ | ||
34 | +FIELD(REV_CODE, REVISION, 0, 4); | ||
35 | +FIELD(REV_CODE, TYPE, 4, 8); | ||
36 | +FIELD(REV_CODE, PROCESSOR, 12, 4); | ||
37 | +FIELD(REV_CODE, MANUFACTURER, 16, 4); | ||
38 | +FIELD(REV_CODE, MEMORY_SIZE, 20, 3); | ||
39 | +FIELD(REV_CODE, STYLE, 23, 1); | ||
40 | + | ||
41 | +static int board_processor_id(uint32_t board_rev) | ||
42 | +{ | ||
43 | + assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ | ||
44 | + return FIELD_EX32(board_rev, REV_CODE, PROCESSOR); | ||
45 | +} | ||
46 | + | ||
47 | +static int board_version(uint32_t board_rev) | ||
48 | +{ | ||
49 | + return board_processor_id(board_rev) + 1; | ||
50 | +} | ||
51 | + | ||
52 | static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) | ||
19 | { | 53 | { |
20 | uint8_t buffer[5]; | 54 | static const uint32_t smpboot[] = { |
21 | buffer[0] = 0x40 | req->cmd; | 55 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
22 | - buffer[1] = (req->arg >> 24) & 0xff; | 56 | arm_load_kernel(ARM_CPU(first_cpu), machine, &binfo); |
23 | - buffer[2] = (req->arg >> 16) & 0xff; | ||
24 | - buffer[3] = (req->arg >> 8) & 0xff; | ||
25 | - buffer[4] = (req->arg >> 0) & 0xff; | ||
26 | + stl_be_p(&buffer[1], req->arg); | ||
27 | return 0; | ||
28 | return sd_crc7(buffer, 5) != req->crc; /* TODO */ | ||
29 | } | 57 | } |
30 | 58 | ||
31 | static void sd_response_r1_make(SDState *sd, uint8_t *response) | 59 | -static void raspi_init(MachineState *machine, int version) |
60 | +static void raspi_init(MachineState *machine, uint32_t board_rev) | ||
32 | { | 61 | { |
33 | - uint32_t status = sd->card_status; | 62 | RasPiState *s = g_new0(RasPiState, 1); |
34 | + stl_be_p(response, sd->card_status); | 63 | + int version = board_version(board_rev); |
35 | + | 64 | uint32_t vcram_size; |
36 | /* Clear the "clear on read" status bits */ | 65 | DriveInfo *di; |
37 | sd->card_status &= ~CARD_STATUS_C; | 66 | BlockBackend *blk; |
38 | - | 67 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) |
39 | - response[0] = (status >> 24) & 0xff; | 68 | /* Setup the SOC */ |
40 | - response[1] = (status >> 16) & 0xff; | 69 | object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), |
41 | - response[2] = (status >> 8) & 0xff; | 70 | &error_abort); |
42 | - response[3] = (status >> 0) & 0xff; | 71 | - int board_rev = version == 3 ? 0xa02082 : 0xa21041; |
72 | object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev", | ||
73 | &error_abort); | ||
74 | object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abort); | ||
75 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | ||
76 | |||
77 | static void raspi2_init(MachineState *machine) | ||
78 | { | ||
79 | - raspi_init(machine, 2); | ||
80 | + raspi_init(machine, 0xa21041); | ||
43 | } | 81 | } |
44 | 82 | ||
45 | static void sd_response_r3_make(SDState *sd, uint8_t *response) | 83 | static void raspi2_machine_init(MachineClass *mc) |
84 | @@ -XXX,XX +XXX,XX @@ DEFINE_MACHINE("raspi2", raspi2_machine_init) | ||
85 | #ifdef TARGET_AARCH64 | ||
86 | static void raspi3_init(MachineState *machine) | ||
46 | { | 87 | { |
47 | - response[0] = (sd->ocr >> 24) & 0xff; | 88 | - raspi_init(machine, 3); |
48 | - response[1] = (sd->ocr >> 16) & 0xff; | 89 | + raspi_init(machine, 0xa02082); |
49 | - response[2] = (sd->ocr >> 8) & 0xff; | ||
50 | - response[3] = (sd->ocr >> 0) & 0xff; | ||
51 | + stl_be_p(response, sd->ocr); | ||
52 | } | 90 | } |
53 | 91 | ||
54 | static void sd_response_r6_make(SDState *sd, uint8_t *response) | 92 | static void raspi3_machine_init(MachineClass *mc) |
55 | { | ||
56 | - uint16_t arg; | ||
57 | uint16_t status; | ||
58 | |||
59 | - arg = sd->rca; | ||
60 | status = ((sd->card_status >> 8) & 0xc000) | | ||
61 | ((sd->card_status >> 6) & 0x2000) | | ||
62 | (sd->card_status & 0x1fff); | ||
63 | sd->card_status &= ~(CARD_STATUS_C & 0xc81fff); | ||
64 | - | ||
65 | - response[0] = (arg >> 8) & 0xff; | ||
66 | - response[1] = arg & 0xff; | ||
67 | - response[2] = (status >> 8) & 0xff; | ||
68 | - response[3] = status & 0xff; | ||
69 | + stw_be_p(response + 0, sd->rca); | ||
70 | + stw_be_p(response + 2, status); | ||
71 | } | ||
72 | |||
73 | static void sd_response_r7_make(SDState *sd, uint8_t *response) | ||
74 | { | ||
75 | - response[0] = (sd->vhs >> 24) & 0xff; | ||
76 | - response[1] = (sd->vhs >> 16) & 0xff; | ||
77 | - response[2] = (sd->vhs >> 8) & 0xff; | ||
78 | - response[3] = (sd->vhs >> 0) & 0xff; | ||
79 | + stl_be_p(response, sd->vhs); | ||
80 | } | ||
81 | |||
82 | static inline uint64_t sd_addr_to_wpnum(uint64_t addr) | ||
83 | @@ -XXX,XX +XXX,XX @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr) | ||
84 | |||
85 | static void sd_function_switch(SDState *sd, uint32_t arg) | ||
86 | { | ||
87 | - int i, mode, new_func, crc; | ||
88 | + int i, mode, new_func; | ||
89 | mode = !!(arg & 0x80000000); | ||
90 | |||
91 | sd->data[0] = 0x00; /* Maximum current consumption */ | ||
92 | @@ -XXX,XX +XXX,XX @@ static void sd_function_switch(SDState *sd, uint32_t arg) | ||
93 | sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4); | ||
94 | } | ||
95 | memset(&sd->data[17], 0, 47); | ||
96 | - crc = sd_crc16(sd->data, 64); | ||
97 | - sd->data[65] = crc >> 8; | ||
98 | - sd->data[66] = crc & 0xff; | ||
99 | + stw_be_p(sd->data + 65, sd_crc16(sd->data, 64)); | ||
100 | } | ||
101 | |||
102 | static inline bool sd_wp_addr(SDState *sd, uint64_t addr) | ||
103 | -- | 93 | -- |
104 | 2.16.1 | 94 | 2.20.1 |
105 | 95 | ||
106 | 96 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The board revision encode the amount of RAM. Add a helper | ||
4 | to extract the RAM size, and use it. | ||
5 | Since the amount of RAM is fixed (it is impossible to physically | ||
6 | modify to have more or less RAM), do not allow sizes different | ||
7 | than the one anounced by the manufacturer. | ||
8 | |||
9 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 11 | Message-id: 20200208165645.15657-5-f4bug@amsat.org |
5 | Message-id: 20180215220540.6556-3-f4bug@amsat.org | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 14 | --- |
8 | hw/sd/sd.c | 32 ++++++++++++++++++++++++++------ | 15 | hw/arm/raspi.c | 15 ++++++++++++--- |
9 | hw/sd/trace-events | 6 ++++++ | 16 | 1 file changed, 12 insertions(+), 3 deletions(-) |
10 | 2 files changed, 32 insertions(+), 6 deletions(-) | ||
11 | 17 | ||
12 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 18 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
13 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/sd/sd.c | 20 | --- a/hw/arm/raspi.c |
15 | +++ b/hw/sd/sd.c | 21 | +++ b/hw/arm/raspi.c |
16 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ |
17 | #include "qemu/error-report.h" | 23 | |
18 | #include "qemu/timer.h" | 24 | #include "qemu/osdep.h" |
19 | #include "qemu/log.h" | 25 | #include "qemu/units.h" |
20 | +#include "trace.h" | 26 | +#include "qemu/cutils.h" |
21 | 27 | #include "qapi/error.h" | |
22 | //#define DEBUG_SD 1 | 28 | #include "cpu.h" |
23 | 29 | #include "hw/arm/bcm2836.h" | |
24 | @@ -XXX,XX +XXX,XX @@ struct SDState { | 30 | @@ -XXX,XX +XXX,XX @@ FIELD(REV_CODE, MANUFACTURER, 16, 4); |
25 | bool cmd_line; | 31 | FIELD(REV_CODE, MEMORY_SIZE, 20, 3); |
26 | }; | 32 | FIELD(REV_CODE, STYLE, 23, 1); |
27 | 33 | ||
28 | +static const char *sd_state_name(enum SDCardStates state) | 34 | +static uint64_t board_ram_size(uint32_t board_rev) |
29 | +{ | 35 | +{ |
30 | + static const char *state_name[] = { | 36 | + assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ |
31 | + [sd_idle_state] = "idle", | 37 | + return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE); |
32 | + [sd_ready_state] = "ready", | ||
33 | + [sd_identification_state] = "identification", | ||
34 | + [sd_standby_state] = "standby", | ||
35 | + [sd_transfer_state] = "transfer", | ||
36 | + [sd_sendingdata_state] = "sendingdata", | ||
37 | + [sd_receivingdata_state] = "receivingdata", | ||
38 | + [sd_programming_state] = "programming", | ||
39 | + [sd_disconnect_state] = "disconnect", | ||
40 | + }; | ||
41 | + if (state == sd_inactive_state) { | ||
42 | + return "inactive"; | ||
43 | + } | ||
44 | + assert(state <= ARRAY_SIZE(state_name)); | ||
45 | + return state_name[state]; | ||
46 | +} | 38 | +} |
47 | + | 39 | + |
48 | static uint8_t sd_get_dat_lines(SDState *sd) | 40 | static int board_processor_id(uint32_t board_rev) |
49 | { | 41 | { |
50 | return sd->enable ? sd->dat_lines : 0; | 42 | assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ |
51 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 43 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, uint32_t board_rev) |
52 | uint32_t rca = 0x0000; | 44 | { |
53 | uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; | 45 | RasPiState *s = g_new0(RasPiState, 1); |
54 | 46 | int version = board_version(board_rev); | |
55 | + trace_sdcard_normal_command(req.cmd, req.arg, sd_state_name(sd->state)); | 47 | + uint64_t ram_size = board_ram_size(board_rev); |
56 | + | 48 | uint32_t vcram_size; |
57 | /* Not interpreting this as an app command */ | 49 | DriveInfo *di; |
58 | sd->card_status &= ~APP_CMD; | 50 | BlockBackend *blk; |
59 | 51 | BusState *bus; | |
60 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 52 | DeviceState *carddev; |
61 | sd->multi_blk_cnt = 0; | 53 | |
54 | - if (machine->ram_size > 1 * GiB) { | ||
55 | - error_report("Requested ram size is too large for this machine: " | ||
56 | - "maximum is 1GB"); | ||
57 | + if (machine->ram_size != ram_size) { | ||
58 | + char *size_str = size_to_str(ram_size); | ||
59 | + error_report("Invalid RAM size, should be %s", size_str); | ||
60 | + g_free(size_str); | ||
61 | exit(1); | ||
62 | } | 62 | } |
63 | 63 | ||
64 | - DPRINTF("CMD%d 0x%08x state %d\n", req.cmd, req.arg, sd->state); | ||
65 | switch (req.cmd) { | ||
66 | /* Basic commands (Class 0 and Class 1) */ | ||
67 | case 0: /* CMD0: GO_IDLE_STATE */ | ||
68 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
69 | return sd_r1; | ||
70 | |||
71 | case 56: /* CMD56: GEN_CMD */ | ||
72 | - fprintf(stderr, "SD: GEN_CMD 0x%08x\n", req.arg); | ||
73 | - | ||
74 | switch (sd->state) { | ||
75 | case sd_transfer_state: | ||
76 | sd->data_offset = 0; | ||
77 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
78 | static sd_rsp_type_t sd_app_command(SDState *sd, | ||
79 | SDRequest req) | ||
80 | { | ||
81 | - DPRINTF("ACMD%d 0x%08x\n", req.cmd, req.arg); | ||
82 | + trace_sdcard_app_command(req.cmd, req.arg); | ||
83 | sd->card_status |= APP_CMD; | ||
84 | switch (req.cmd) { | ||
85 | case 6: /* ACMD6: SET_BUS_WIDTH */ | ||
86 | @@ -XXX,XX +XXX,XX @@ send_response: | ||
87 | |||
88 | static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) | ||
89 | { | ||
90 | - DPRINTF("sd_blk_read: addr = 0x%08llx, len = %d\n", | ||
91 | - (unsigned long long) addr, len); | ||
92 | + trace_sdcard_read_block(addr, len); | ||
93 | if (!sd->blk || blk_pread(sd->blk, addr, sd->data, len) < 0) { | ||
94 | fprintf(stderr, "sd_blk_read: read error on host side\n"); | ||
95 | } | ||
96 | @@ -XXX,XX +XXX,XX @@ static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) | ||
97 | |||
98 | static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) | ||
99 | { | ||
100 | + trace_sdcard_write_block(addr, len); | ||
101 | if (!sd->blk || blk_pwrite(sd->blk, addr, sd->data, len, 0) < 0) { | ||
102 | fprintf(stderr, "sd_blk_write: write error on host side\n"); | ||
103 | } | ||
104 | diff --git a/hw/sd/trace-events b/hw/sd/trace-events | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | --- a/hw/sd/trace-events | ||
107 | +++ b/hw/sd/trace-events | ||
108 | @@ -XXX,XX +XXX,XX @@ sdhci_read_dataport(uint16_t data_count) "all %u bytes of data have been read fr | ||
109 | sdhci_write_dataport(uint16_t data_count) "write buffer filled with %u bytes of data" | ||
110 | sdhci_capareg(const char *desc, uint16_t val) "%s: %u" | ||
111 | |||
112 | +# hw/sd/sd.c | ||
113 | +sdcard_normal_command(uint8_t cmd, uint32_t arg, const char *state) "CMD%d arg 0x%08x (state %s)" | ||
114 | +sdcard_app_command(uint8_t acmd, uint32_t arg) "ACMD%d arg 0x%08x" | ||
115 | +sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
116 | +sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
117 | + | ||
118 | # hw/sd/milkymist-memcard.c | ||
119 | milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
120 | milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
121 | -- | 64 | -- |
122 | 2.16.1 | 65 | 2.20.1 |
123 | 66 | ||
124 | 67 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The board revision encode the processor type. Add a helper | ||
4 | to extract the type, and use it. | ||
5 | |||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Acked-by: Alistair Francis <alistair.francis@xilinx.com> | 7 | Message-id: 20200208165645.15657-6-f4bug@amsat.org |
5 | Message-id: 20180215220540.6556-6-f4bug@amsat.org | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | hw/sd/sd.c | 32 ++++++++++++++++++++++++++------ | 11 | hw/arm/raspi.c | 18 ++++++++++++++++-- |
10 | hw/sd/trace-events | 13 +++++++++++++ | 12 | 1 file changed, 16 insertions(+), 2 deletions(-) |
11 | 2 files changed, 39 insertions(+), 6 deletions(-) | ||
12 | 13 | ||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sd.c | 16 | --- a/hw/arm/raspi.c |
16 | +++ b/hw/sd/sd.c | 17 | +++ b/hw/arm/raspi.c |
17 | @@ -XXX,XX +XXX,XX @@ static bool sd_get_cmd_line(SDState *sd) | 18 | @@ -XXX,XX +XXX,XX @@ static int board_version(uint32_t board_rev) |
18 | 19 | return board_processor_id(board_rev) + 1; | |
19 | static void sd_set_voltage(SDState *sd, uint16_t millivolts) | 20 | } |
21 | |||
22 | +static const char *board_soc_type(uint32_t board_rev) | ||
23 | +{ | ||
24 | + static const char *soc_types[] = { | ||
25 | + NULL, TYPE_BCM2836, TYPE_BCM2837, | ||
26 | + }; | ||
27 | + int proc_id = board_processor_id(board_rev); | ||
28 | + | ||
29 | + if (proc_id >= ARRAY_SIZE(soc_types) || !soc_types[proc_id]) { | ||
30 | + error_report("Unsupported processor id '%d' (board revision: 0x%x)", | ||
31 | + proc_id, board_rev); | ||
32 | + exit(1); | ||
33 | + } | ||
34 | + return soc_types[proc_id]; | ||
35 | +} | ||
36 | + | ||
37 | static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) | ||
20 | { | 38 | { |
21 | + trace_sdcard_set_voltage(millivolts); | 39 | static const uint32_t smpboot[] = { |
22 | + | 40 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, uint32_t board_rev) |
23 | switch (millivolts) { | ||
24 | case 3001 ... 3600: /* SD_VOLTAGE_3_3V */ | ||
25 | case 2001 ... 3000: /* SD_VOLTAGE_3_0V */ | ||
26 | @@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque) | ||
27 | { | ||
28 | SDState *sd = opaque; | ||
29 | |||
30 | + trace_sdcard_powerup(); | ||
31 | /* Set powered up bit in OCR */ | ||
32 | assert(!(sd->ocr & OCR_POWER_UP)); | ||
33 | sd->ocr |= OCR_POWER_UP; | ||
34 | @@ -XXX,XX +XXX,XX @@ static void sd_reset(DeviceState *dev) | ||
35 | uint64_t size; | ||
36 | uint64_t sect; | ||
37 | |||
38 | + trace_sdcard_reset(); | ||
39 | if (sd->blk) { | ||
40 | blk_get_geometry(sd->blk, §); | ||
41 | } else { | ||
42 | @@ -XXX,XX +XXX,XX @@ static void sd_cardchange(void *opaque, bool load, Error **errp) | ||
43 | bool readonly = sd_get_readonly(sd); | ||
44 | |||
45 | if (inserted) { | ||
46 | + trace_sdcard_inserted(readonly); | ||
47 | sd_reset(dev); | ||
48 | + } else { | ||
49 | + trace_sdcard_ejected(); | ||
50 | } | 41 | } |
51 | 42 | ||
52 | /* The IRQ notification is for legacy non-QOM SD controller devices; | 43 | object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), |
53 | @@ -XXX,XX +XXX,XX @@ static void sd_erase(SDState *sd) | 44 | - version == 3 ? TYPE_BCM2837 : TYPE_BCM2836, |
54 | uint64_t erase_start = sd->erase_start; | 45 | - &error_abort, NULL); |
55 | uint64_t erase_end = sd->erase_end; | 46 | + board_soc_type(board_rev), &error_abort, NULL); |
56 | 47 | ||
57 | + trace_sdcard_erase(); | 48 | /* Allocate and map RAM */ |
58 | if (!sd->erase_start || !sd->erase_end) { | 49 | memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram", |
59 | sd->card_status |= ERASE_SEQ_ERROR; | ||
60 | return; | ||
61 | @@ -XXX,XX +XXX,XX @@ static void sd_lock_command(SDState *sd) | ||
62 | else | ||
63 | pwd_len = 0; | ||
64 | |||
65 | + if (lock) { | ||
66 | + trace_sdcard_lock(); | ||
67 | + } else { | ||
68 | + trace_sdcard_unlock(); | ||
69 | + } | ||
70 | if (erase) { | ||
71 | if (!(sd->card_status & CARD_IS_LOCKED) || sd->blk_len > 1 || | ||
72 | set_pwd || clr_pwd || lock || sd->wp_switch || | ||
73 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
74 | case 16: /* CMD16: SET_BLOCKLEN */ | ||
75 | switch (sd->state) { | ||
76 | case sd_transfer_state: | ||
77 | - if (req.arg > (1 << HWBLOCK_SHIFT)) | ||
78 | + if (req.arg > (1 << HWBLOCK_SHIFT)) { | ||
79 | sd->card_status |= BLOCK_LEN_ERROR; | ||
80 | - else | ||
81 | + } else { | ||
82 | + trace_sdcard_set_blocklen(req.arg); | ||
83 | sd->blk_len = req.arg; | ||
84 | + } | ||
85 | |||
86 | return sd_r1; | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | ||
89 | if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { | ||
90 | timer_del(sd->ocr_power_timer); | ||
91 | sd_ocr_powerup(sd); | ||
92 | - } else if (!timer_pending(sd->ocr_power_timer)) { | ||
93 | - timer_mod_ns(sd->ocr_power_timer, | ||
94 | - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) | ||
95 | - + OCR_POWER_DELAY_NS)); | ||
96 | + } else { | ||
97 | + trace_sdcard_inquiry_cmd41(); | ||
98 | + if (!timer_pending(sd->ocr_power_timer)) { | ||
99 | + timer_mod_ns(sd->ocr_power_timer, | ||
100 | + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) | ||
101 | + + OCR_POWER_DELAY_NS)); | ||
102 | + } | ||
103 | } | ||
104 | } | ||
105 | |||
106 | @@ -XXX,XX +XXX,XX @@ void sd_write_data(SDState *sd, uint8_t value) | ||
107 | if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) | ||
108 | return; | ||
109 | |||
110 | + trace_sdcard_write_data(sd->current_cmd, value); | ||
111 | switch (sd->current_cmd) { | ||
112 | case 24: /* CMD24: WRITE_SINGLE_BLOCK */ | ||
113 | sd->data[sd->data_offset ++] = value; | ||
114 | @@ -XXX,XX +XXX,XX @@ uint8_t sd_read_data(SDState *sd) | ||
115 | |||
116 | io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; | ||
117 | |||
118 | + trace_sdcard_read_data(sd->current_cmd, io_len); | ||
119 | switch (sd->current_cmd) { | ||
120 | case 6: /* CMD6: SWITCH_FUNCTION */ | ||
121 | ret = sd->data[sd->data_offset ++]; | ||
122 | diff --git a/hw/sd/trace-events b/hw/sd/trace-events | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/hw/sd/trace-events | ||
125 | +++ b/hw/sd/trace-events | ||
126 | @@ -XXX,XX +XXX,XX @@ sdhci_capareg(const char *desc, uint16_t val) "%s: %u" | ||
127 | sdcard_normal_command(uint8_t cmd, uint32_t arg, const char *state) "CMD%d arg 0x%08x (state %s)" | ||
128 | sdcard_app_command(uint8_t acmd, uint32_t arg) "ACMD%d arg 0x%08x" | ||
129 | sdcard_response(const char *rspdesc, int rsplen) "%s (sz:%d)" | ||
130 | +sdcard_powerup(void) "" | ||
131 | +sdcard_inquiry_cmd41(void) "" | ||
132 | +sdcard_set_enable(bool current_state, bool new_state) "%u -> %u" | ||
133 | +sdcard_reset(void) "" | ||
134 | +sdcard_set_blocklen(uint16_t length) "0x%04x" | ||
135 | +sdcard_inserted(bool readonly) "read_only: %u" | ||
136 | +sdcard_ejected(void) "" | ||
137 | +sdcard_erase(void) "" | ||
138 | +sdcard_lock(void) "" | ||
139 | +sdcard_unlock(void) "" | ||
140 | sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
141 | sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
142 | +sdcard_write_data(uint8_t cmd, uint8_t value) "CMD%02d value 0x%02x" | ||
143 | +sdcard_read_data(uint8_t cmd, int length) "CMD%02d len %d" | ||
144 | +sdcard_set_voltage(uint16_t millivolts) "%u mV" | ||
145 | |||
146 | # hw/sd/milkymist-memcard.c | ||
147 | milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
148 | -- | 50 | -- |
149 | 2.16.1 | 51 | 2.20.1 |
150 | 52 | ||
151 | 53 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Linux uses it to poll the bus before polling for a card. | 3 | There is no point in creating the SoC object before allocating the RAM. |
4 | Move the call to keep all the SoC-related calls together. | ||
4 | 5 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 7 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
7 | Message-id: 20180215221325.7611-10-f4bug@amsat.org | 8 | Message-id: 20200208165645.15657-7-f4bug@amsat.org |
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/sd/sd.c | 5 ++--- | 12 | hw/arm/raspi.c | 5 ++--- |
11 | 1 file changed, 2 insertions(+), 3 deletions(-) | 13 | 1 file changed, 2 insertions(+), 3 deletions(-) |
12 | 14 | ||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 15 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sd.c | 17 | --- a/hw/arm/raspi.c |
16 | +++ b/hw/sd/sd.c | 18 | +++ b/hw/arm/raspi.c |
17 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 19 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, uint32_t board_rev) |
18 | } | 20 | exit(1); |
19 | break; | 21 | } |
20 | 22 | ||
21 | - case 52: | 23 | - object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), |
22 | - case 53: | 24 | - board_soc_type(board_rev), &error_abort, NULL); |
23 | - /* CMD52, CMD53: reserved for SDIO cards | 25 | - |
24 | + case 52 ... 54: | 26 | /* Allocate and map RAM */ |
25 | + /* CMD52, CMD53, CMD54: reserved for SDIO cards | 27 | memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram", |
26 | * (see the SDIO Simplified Specification V2.0) | 28 | machine->ram_size); |
27 | * Handle as illegal command but do not complain | 29 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, uint32_t board_rev) |
28 | * on stderr, as some OSes may use these in their | 30 | memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0); |
31 | |||
32 | /* Setup the SOC */ | ||
33 | + object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), | ||
34 | + board_soc_type(board_rev), &error_abort, NULL); | ||
35 | object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), | ||
36 | &error_abort); | ||
37 | object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev", | ||
29 | -- | 38 | -- |
30 | 2.16.1 | 39 | 2.20.1 |
31 | 40 | ||
32 | 41 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | QOM'ify RaspiMachineState. Now machines inherit of RaspiMachineClass. | ||
4 | |||
5 | Cc: Igor Mammedov <imammedo@redhat.com> | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Acked-by: Alistair Francis <alistair.francis@xilinx.com> | 7 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
5 | Message-id: 20180215221325.7611-9-f4bug@amsat.org | 8 | Message-id: 20200208165645.15657-8-f4bug@amsat.org |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 11 | --- |
9 | hw/sd/sd.c | 48 +++++++++++++++++++++++++++++++++++++++++++++--- | 12 | hw/arm/raspi.c | 56 +++++++++++++++++++++++++++++++++++++++++++------- |
10 | 1 file changed, 45 insertions(+), 3 deletions(-) | 13 | 1 file changed, 49 insertions(+), 7 deletions(-) |
11 | 14 | ||
12 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 15 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/sd/sd.c | 17 | --- a/hw/arm/raspi.c |
15 | +++ b/hw/sd/sd.c | 18 | +++ b/hw/arm/raspi.c |
16 | @@ -XXX,XX +XXX,XX @@ static void sd_set_rca(SDState *sd) | 19 | @@ -XXX,XX +XXX,XX @@ |
17 | sd->rca += 0x4567; | 20 | /* Registered machine type (matches RPi Foundation bootloader and U-Boot) */ |
21 | #define MACH_TYPE_BCM2708 3138 | ||
22 | |||
23 | -typedef struct RasPiState { | ||
24 | +typedef struct RaspiMachineState { | ||
25 | + /*< private >*/ | ||
26 | + MachineState parent_obj; | ||
27 | + /*< public >*/ | ||
28 | BCM283XState soc; | ||
29 | MemoryRegion ram; | ||
30 | -} RasPiState; | ||
31 | +} RaspiMachineState; | ||
32 | + | ||
33 | +typedef struct RaspiMachineClass { | ||
34 | + /*< private >*/ | ||
35 | + MachineClass parent_obj; | ||
36 | + /*< public >*/ | ||
37 | +} RaspiMachineClass; | ||
38 | + | ||
39 | +#define TYPE_RASPI_MACHINE MACHINE_TYPE_NAME("raspi-common") | ||
40 | +#define RASPI_MACHINE(obj) \ | ||
41 | + OBJECT_CHECK(RaspiMachineState, (obj), TYPE_RASPI_MACHINE) | ||
42 | + | ||
43 | +#define RASPI_MACHINE_CLASS(klass) \ | ||
44 | + OBJECT_CLASS_CHECK(RaspiMachineClass, (klass), TYPE_RASPI_MACHINE) | ||
45 | +#define RASPI_MACHINE_GET_CLASS(obj) \ | ||
46 | + OBJECT_GET_CLASS(RaspiMachineClass, (obj), TYPE_RASPI_MACHINE) | ||
47 | |||
48 | /* | ||
49 | * Board revision codes: | ||
50 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
51 | |||
52 | static void raspi_init(MachineState *machine, uint32_t board_rev) | ||
53 | { | ||
54 | - RasPiState *s = g_new0(RasPiState, 1); | ||
55 | + RaspiMachineState *s = RASPI_MACHINE(machine); | ||
56 | int version = board_version(board_rev); | ||
57 | uint64_t ram_size = board_ram_size(board_rev); | ||
58 | uint32_t vcram_size; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine) | ||
60 | raspi_init(machine, 0xa21041); | ||
18 | } | 61 | } |
19 | 62 | ||
20 | +FIELD(CSR, AKE_SEQ_ERROR, 3, 1) | 63 | -static void raspi2_machine_init(MachineClass *mc) |
21 | +FIELD(CSR, APP_CMD, 5, 1) | 64 | +static void raspi2_machine_class_init(ObjectClass *oc, void *data) |
22 | +FIELD(CSR, FX_EVENT, 6, 1) | 65 | { |
23 | +FIELD(CSR, READY_FOR_DATA, 8, 1) | 66 | + MachineClass *mc = MACHINE_CLASS(oc); |
24 | +FIELD(CSR, CURRENT_STATE, 9, 4) | ||
25 | +FIELD(CSR, ERASE_RESET, 13, 1) | ||
26 | +FIELD(CSR, CARD_ECC_DISABLED, 14, 1) | ||
27 | +FIELD(CSR, WP_ERASE_SKIP, 15, 1) | ||
28 | +FIELD(CSR, CSD_OVERWRITE, 16, 1) | ||
29 | +FIELD(CSR, DEFERRED_RESPONSE, 17, 1) | ||
30 | +FIELD(CSR, ERROR, 19, 1) | ||
31 | +FIELD(CSR, CC_ERROR, 20, 1) | ||
32 | +FIELD(CSR, CARD_ECC_FAILED, 21, 1) | ||
33 | +FIELD(CSR, ILLEGAL_COMMAND, 22, 1) | ||
34 | +FIELD(CSR, COM_CRC_ERROR, 23, 1) | ||
35 | +FIELD(CSR, LOCK_UNLOCK_FAILED, 24, 1) | ||
36 | +FIELD(CSR, CARD_IS_LOCKED, 25, 1) | ||
37 | +FIELD(CSR, WP_VIOLATION, 26, 1) | ||
38 | +FIELD(CSR, ERASE_PARAM, 27, 1) | ||
39 | +FIELD(CSR, ERASE_SEQ_ERROR, 28, 1) | ||
40 | +FIELD(CSR, BLOCK_LEN_ERROR, 29, 1) | ||
41 | +FIELD(CSR, ADDRESS_ERROR, 30, 1) | ||
42 | +FIELD(CSR, OUT_OF_RANGE, 31, 1) | ||
43 | + | 67 | + |
44 | /* Card status bits, split by clear condition: | 68 | mc->desc = "Raspberry Pi 2B"; |
45 | * A : According to the card current state | 69 | mc->init = raspi2_init; |
46 | * B : Always related to the previous command | 70 | mc->block_default_type = IF_SD; |
47 | * C : Cleared by read | 71 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) |
48 | */ | 72 | mc->default_ram_size = 1 * GiB; |
49 | -#define CARD_STATUS_A 0x02004100 | 73 | mc->ignore_memory_transaction_failures = true; |
50 | -#define CARD_STATUS_B 0x00c01e00 | 74 | }; |
51 | -#define CARD_STATUS_C 0xfd39a028 | 75 | -DEFINE_MACHINE("raspi2", raspi2_machine_init) |
52 | +#define CARD_STATUS_A (R_CSR_READY_FOR_DATA_MASK \ | 76 | |
53 | + | R_CSR_CARD_ECC_DISABLED_MASK \ | 77 | #ifdef TARGET_AARCH64 |
54 | + | R_CSR_CARD_IS_LOCKED_MASK) | 78 | static void raspi3_init(MachineState *machine) |
55 | +#define CARD_STATUS_B (R_CSR_CURRENT_STATE_MASK \ | 79 | @@ -XXX,XX +XXX,XX @@ static void raspi3_init(MachineState *machine) |
56 | + | R_CSR_ILLEGAL_COMMAND_MASK \ | 80 | raspi_init(machine, 0xa02082); |
57 | + | R_CSR_COM_CRC_ERROR_MASK) | 81 | } |
58 | +#define CARD_STATUS_C (R_CSR_AKE_SEQ_ERROR_MASK \ | 82 | |
59 | + | R_CSR_APP_CMD_MASK \ | 83 | -static void raspi3_machine_init(MachineClass *mc) |
60 | + | R_CSR_ERASE_RESET_MASK \ | 84 | +static void raspi3_machine_class_init(ObjectClass *oc, void *data) |
61 | + | R_CSR_WP_ERASE_SKIP_MASK \ | ||
62 | + | R_CSR_CSD_OVERWRITE_MASK \ | ||
63 | + | R_CSR_ERROR_MASK \ | ||
64 | + | R_CSR_CC_ERROR_MASK \ | ||
65 | + | R_CSR_CARD_ECC_FAILED_MASK \ | ||
66 | + | R_CSR_LOCK_UNLOCK_FAILED_MASK \ | ||
67 | + | R_CSR_WP_VIOLATION_MASK \ | ||
68 | + | R_CSR_ERASE_PARAM_MASK \ | ||
69 | + | R_CSR_ERASE_SEQ_ERROR_MASK \ | ||
70 | + | R_CSR_BLOCK_LEN_ERROR_MASK \ | ||
71 | + | R_CSR_ADDRESS_ERROR_MASK \ | ||
72 | + | R_CSR_OUT_OF_RANGE_MASK) | ||
73 | |||
74 | static void sd_set_cardstatus(SDState *sd) | ||
75 | { | 85 | { |
86 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
87 | + | ||
88 | mc->desc = "Raspberry Pi 3B"; | ||
89 | mc->init = raspi3_init; | ||
90 | mc->block_default_type = IF_SD; | ||
91 | @@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc) | ||
92 | mc->default_cpus = BCM283X_NCPUS; | ||
93 | mc->default_ram_size = 1 * GiB; | ||
94 | } | ||
95 | -DEFINE_MACHINE("raspi3", raspi3_machine_init) | ||
96 | #endif | ||
97 | + | ||
98 | +static const TypeInfo raspi_machine_types[] = { | ||
99 | + { | ||
100 | + .name = MACHINE_TYPE_NAME("raspi2"), | ||
101 | + .parent = TYPE_RASPI_MACHINE, | ||
102 | + .class_init = raspi2_machine_class_init, | ||
103 | +#ifdef TARGET_AARCH64 | ||
104 | + }, { | ||
105 | + .name = MACHINE_TYPE_NAME("raspi3"), | ||
106 | + .parent = TYPE_RASPI_MACHINE, | ||
107 | + .class_init = raspi3_machine_class_init, | ||
108 | +#endif | ||
109 | + }, { | ||
110 | + .name = TYPE_RASPI_MACHINE, | ||
111 | + .parent = TYPE_MACHINE, | ||
112 | + .instance_size = sizeof(RaspiMachineState), | ||
113 | + .class_size = sizeof(RaspiMachineClass), | ||
114 | + .abstract = true, | ||
115 | + } | ||
116 | +}; | ||
117 | + | ||
118 | +DEFINE_TYPES(raspi_machine_types) | ||
76 | -- | 119 | -- |
77 | 2.16.1 | 120 | 2.20.1 |
78 | 121 | ||
79 | 122 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | use the registerfields API to access the OCR register | 3 | We want to have a common class_init(). The only value that |
4 | matters (and changes) is the board revision. | ||
5 | Pass the board_rev as class_data to class_init(). | ||
4 | 6 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 8 | Message-id: 20200208165645.15657-9-f4bug@amsat.org |
7 | Message-id: 20180215221325.7611-8-f4bug@amsat.org | 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/sd/sd.c | 21 ++++++++++++++++----- | 12 | hw/arm/raspi.c | 17 ++++++++++++++--- |
11 | 1 file changed, 16 insertions(+), 5 deletions(-) | 13 | 1 file changed, 14 insertions(+), 3 deletions(-) |
12 | 14 | ||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 15 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sd.c | 17 | --- a/hw/arm/raspi.c |
16 | +++ b/hw/sd/sd.c | 18 | +++ b/hw/arm/raspi.c |
17 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct RaspiMachineClass { |
18 | 20 | /*< private >*/ | |
19 | //#define DEBUG_SD 1 | 21 | MachineClass parent_obj; |
20 | 22 | /*< public >*/ | |
21 | -#define ACMD41_ENQUIRY_MASK 0x00ffffff | 23 | + uint32_t board_rev; |
22 | - | 24 | } RaspiMachineClass; |
23 | typedef enum { | 25 | |
24 | sd_r0 = 0, /* no response */ | 26 | #define TYPE_RASPI_MACHINE MACHINE_TYPE_NAME("raspi-common") |
25 | sd_r1, /* normal response command */ | 27 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
26 | @@ -XXX,XX +XXX,XX @@ static uint16_t sd_crc16(void *message, size_t width) | 28 | arm_load_kernel(ARM_CPU(first_cpu), machine, &binfo); |
27 | 29 | } | |
28 | #define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ | 30 | |
29 | 31 | -static void raspi_init(MachineState *machine, uint32_t board_rev) | |
30 | +FIELD(OCR, VDD_VOLTAGE_WINDOW, 0, 24) | 32 | +static void raspi_init(MachineState *machine) |
31 | +FIELD(OCR, VDD_VOLTAGE_WIN_LO, 0, 8) | ||
32 | +FIELD(OCR, DUAL_VOLTAGE_CARD, 7, 1) | ||
33 | +FIELD(OCR, VDD_VOLTAGE_WIN_HI, 8, 16) | ||
34 | +FIELD(OCR, ACCEPT_SWITCH_1V8, 24, 1) /* Only UHS-I */ | ||
35 | +FIELD(OCR, UHS_II_CARD, 29, 1) /* Only UHS-II */ | ||
36 | FIELD(OCR, CARD_CAPACITY, 30, 1) /* 0:SDSC, 1:SDHC/SDXC */ | ||
37 | FIELD(OCR, CARD_POWER_UP, 31, 1) | ||
38 | |||
39 | +#define ACMD41_ENQUIRY_MASK 0x00ffffff | ||
40 | +#define ACMD41_R3_MASK (R_OCR_VDD_VOLTAGE_WIN_HI_MASK \ | ||
41 | + | R_OCR_ACCEPT_SWITCH_1V8_MASK \ | ||
42 | + | R_OCR_UHS_II_CARD_MASK \ | ||
43 | + | R_OCR_CARD_CAPACITY_MASK \ | ||
44 | + | R_OCR_CARD_POWER_UP_MASK) | ||
45 | + | ||
46 | static void sd_set_ocr(SDState *sd) | ||
47 | { | 33 | { |
48 | - /* All voltages OK, Standard Capacity SD Memory Card, not yet powered up */ | 34 | + RaspiMachineClass *mc = RASPI_MACHINE_GET_CLASS(machine); |
49 | - sd->ocr = 0x00ffff00; | 35 | RaspiMachineState *s = RASPI_MACHINE(machine); |
50 | + /* All voltages OK */ | 36 | + uint32_t board_rev = mc->board_rev; |
51 | + sd->ocr = R_OCR_VDD_VOLTAGE_WIN_HI_MASK; | 37 | int version = board_version(board_rev); |
38 | uint64_t ram_size = board_ram_size(board_rev); | ||
39 | uint32_t vcram_size; | ||
40 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, uint32_t board_rev) | ||
41 | |||
42 | static void raspi2_init(MachineState *machine) | ||
43 | { | ||
44 | - raspi_init(machine, 0xa21041); | ||
45 | + raspi_init(machine); | ||
52 | } | 46 | } |
53 | 47 | ||
54 | static void sd_ocr_powerup(void *opaque) | 48 | static void raspi2_machine_class_init(ObjectClass *oc, void *data) |
55 | @@ -XXX,XX +XXX,XX @@ static void sd_response_r1_make(SDState *sd, uint8_t *response) | ||
56 | |||
57 | static void sd_response_r3_make(SDState *sd, uint8_t *response) | ||
58 | { | 49 | { |
59 | - stl_be_p(response, sd->ocr); | 50 | MachineClass *mc = MACHINE_CLASS(oc); |
60 | + stl_be_p(response, sd->ocr & ACMD41_R3_MASK); | 51 | + RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); |
52 | + uint32_t board_rev = (uint32_t)(uintptr_t)data; | ||
53 | |||
54 | + rmc->board_rev = board_rev; | ||
55 | mc->desc = "Raspberry Pi 2B"; | ||
56 | mc->init = raspi2_init; | ||
57 | mc->block_default_type = IF_SD; | ||
58 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_class_init(ObjectClass *oc, void *data) | ||
59 | #ifdef TARGET_AARCH64 | ||
60 | static void raspi3_init(MachineState *machine) | ||
61 | { | ||
62 | - raspi_init(machine, 0xa02082); | ||
63 | + raspi_init(machine); | ||
61 | } | 64 | } |
62 | 65 | ||
63 | static void sd_response_r6_make(SDState *sd, uint8_t *response) | 66 | static void raspi3_machine_class_init(ObjectClass *oc, void *data) |
67 | { | ||
68 | MachineClass *mc = MACHINE_CLASS(oc); | ||
69 | + RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
70 | + uint32_t board_rev = (uint32_t)(uintptr_t)data; | ||
71 | |||
72 | + rmc->board_rev = board_rev; | ||
73 | mc->desc = "Raspberry Pi 3B"; | ||
74 | mc->init = raspi3_init; | ||
75 | mc->block_default_type = IF_SD; | ||
76 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo raspi_machine_types[] = { | ||
77 | .name = MACHINE_TYPE_NAME("raspi2"), | ||
78 | .parent = TYPE_RASPI_MACHINE, | ||
79 | .class_init = raspi2_machine_class_init, | ||
80 | + .class_data = (void *)0xa21041, | ||
81 | #ifdef TARGET_AARCH64 | ||
82 | }, { | ||
83 | .name = MACHINE_TYPE_NAME("raspi3"), | ||
84 | .parent = TYPE_RASPI_MACHINE, | ||
85 | .class_init = raspi3_machine_class_init, | ||
86 | + .class_data = (void *)0xa02082, | ||
87 | #endif | ||
88 | }, { | ||
89 | .name = TYPE_RASPI_MACHINE, | ||
64 | -- | 90 | -- |
65 | 2.16.1 | 91 | 2.20.1 |
66 | 92 | ||
67 | 93 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | using the sdbus_*() API. | 3 | raspi_machine_init() access to board_rev via RaspiMachineClass. |
4 | raspi2_init() and raspi3_init() do nothing. Call raspi_machine_init | ||
5 | directly. | ||
4 | 6 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 8 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> |
7 | Acked-by: Michael Walle <michael@walle.cc> | 9 | Message-id: 20200208165645.15657-10-f4bug@amsat.org |
8 | Message-id: 20180216022933.10945-4-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | hw/sd/milkymist-memcard.c | 38 +++++++++++++++++++++----------------- | 12 | hw/arm/raspi.c | 16 +++------------- |
12 | 1 file changed, 21 insertions(+), 17 deletions(-) | 13 | 1 file changed, 3 insertions(+), 13 deletions(-) |
13 | 14 | ||
14 | diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c | 15 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/sd/milkymist-memcard.c | 17 | --- a/hw/arm/raspi.c |
17 | +++ b/hw/sd/milkymist-memcard.c | 18 | +++ b/hw/arm/raspi.c |
18 | @@ -XXX,XX +XXX,XX @@ struct MilkymistMemcardState { | 19 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
19 | SysBusDevice parent_obj; | 20 | arm_load_kernel(ARM_CPU(first_cpu), machine, &binfo); |
20 | |||
21 | MemoryRegion regs_region; | ||
22 | - SDState *card; | ||
23 | + SDBus sdbus; | ||
24 | |||
25 | int command_write_ptr; | ||
26 | int response_read_ptr; | ||
27 | @@ -XXX,XX +XXX,XX @@ static void memcard_sd_command(MilkymistMemcardState *s) | ||
28 | req.crc = s->command[5]; | ||
29 | |||
30 | s->response[0] = req.cmd; | ||
31 | - s->response_len = sd_do_command(s->card, &req, s->response+1); | ||
32 | + s->response_len = sdbus_do_command(&s->sdbus, &req, s->response + 1); | ||
33 | s->response_read_ptr = 0; | ||
34 | |||
35 | if (s->response_len == 16) { | ||
36 | @@ -XXX,XX +XXX,XX @@ static uint64_t memcard_read(void *opaque, hwaddr addr, | ||
37 | r = 0xffffffff; | ||
38 | } else { | ||
39 | r = 0; | ||
40 | - r |= sd_read_data(s->card) << 24; | ||
41 | - r |= sd_read_data(s->card) << 16; | ||
42 | - r |= sd_read_data(s->card) << 8; | ||
43 | - r |= sd_read_data(s->card); | ||
44 | + r |= sdbus_read_data(&s->sdbus) << 24; | ||
45 | + r |= sdbus_read_data(&s->sdbus) << 16; | ||
46 | + r |= sdbus_read_data(&s->sdbus) << 8; | ||
47 | + r |= sdbus_read_data(&s->sdbus); | ||
48 | } | ||
49 | break; | ||
50 | case R_CLK2XDIV: | ||
51 | @@ -XXX,XX +XXX,XX @@ static void memcard_write(void *opaque, hwaddr addr, uint64_t value, | ||
52 | if (!s->enabled) { | ||
53 | break; | ||
54 | } | ||
55 | - sd_write_data(s->card, (value >> 24) & 0xff); | ||
56 | - sd_write_data(s->card, (value >> 16) & 0xff); | ||
57 | - sd_write_data(s->card, (value >> 8) & 0xff); | ||
58 | - sd_write_data(s->card, value & 0xff); | ||
59 | + sdbus_write_data(&s->sdbus, (value >> 24) & 0xff); | ||
60 | + sdbus_write_data(&s->sdbus, (value >> 16) & 0xff); | ||
61 | + sdbus_write_data(&s->sdbus, (value >> 8) & 0xff); | ||
62 | + sdbus_write_data(&s->sdbus, value & 0xff); | ||
63 | break; | ||
64 | case R_ENABLE: | ||
65 | s->regs[addr] = value; | ||
66 | @@ -XXX,XX +XXX,XX @@ static void milkymist_memcard_reset(DeviceState *d) | ||
67 | for (i = 0; i < R_MAX; i++) { | ||
68 | s->regs[i] = 0; | ||
69 | } | ||
70 | - /* Since we're still using the legacy SD API the card is not plugged | ||
71 | - * into any bus, and we must reset it manually. | ||
72 | - */ | ||
73 | - device_reset(DEVICE(s->card)); | ||
74 | } | 21 | } |
75 | 22 | ||
76 | static void milkymist_memcard_init(Object *obj) | 23 | -static void raspi_init(MachineState *machine) |
77 | @@ -XXX,XX +XXX,XX @@ static void milkymist_memcard_init(Object *obj) | 24 | +static void raspi_machine_init(MachineState *machine) |
78 | static void milkymist_memcard_realize(DeviceState *dev, Error **errp) | ||
79 | { | 25 | { |
80 | MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev); | 26 | RaspiMachineClass *mc = RASPI_MACHINE_GET_CLASS(machine); |
81 | + DeviceState *carddev; | 27 | RaspiMachineState *s = RASPI_MACHINE(machine); |
82 | BlockBackend *blk; | 28 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine) |
83 | DriveInfo *dinfo; | 29 | setup_boot(machine, version, machine->ram_size - vcram_size); |
84 | + Error *err = NULL; | 30 | } |
85 | 31 | ||
86 | + qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS, | 32 | -static void raspi2_init(MachineState *machine) |
87 | + dev, "sd-bus"); | 33 | -{ |
88 | + | 34 | - raspi_init(machine); |
89 | + /* Create and plug in the sd card */ | 35 | -} |
90 | /* FIXME use a qdev drive property instead of drive_get_next() */ | 36 | - |
91 | dinfo = drive_get_next(IF_SD); | 37 | static void raspi2_machine_class_init(ObjectClass *oc, void *data) |
92 | blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; | 38 | { |
93 | - s->card = sd_init(blk, false); | 39 | MachineClass *mc = MACHINE_CLASS(oc); |
94 | - if (s->card == NULL) { | 40 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_class_init(ObjectClass *oc, void *data) |
95 | - error_setg(errp, "failed to init SD card"); | 41 | |
96 | + carddev = qdev_create(&s->sdbus.qbus, TYPE_SD_CARD); | 42 | rmc->board_rev = board_rev; |
97 | + qdev_prop_set_drive(carddev, "drive", blk, &err); | 43 | mc->desc = "Raspberry Pi 2B"; |
98 | + object_property_set_bool(OBJECT(carddev), true, "realized", &err); | 44 | - mc->init = raspi2_init; |
99 | + if (err) { | 45 | + mc->init = raspi_machine_init; |
100 | + error_setg(errp, "failed to init SD card: %s", error_get_pretty(err)); | 46 | mc->block_default_type = IF_SD; |
101 | return; | 47 | mc->no_parallel = 1; |
102 | } | 48 | mc->no_floppy = 1; |
103 | s->enabled = blk && blk_is_inserted(blk); | 49 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_class_init(ObjectClass *oc, void *data) |
50 | }; | ||
51 | |||
52 | #ifdef TARGET_AARCH64 | ||
53 | -static void raspi3_init(MachineState *machine) | ||
54 | -{ | ||
55 | - raspi_init(machine); | ||
56 | -} | ||
57 | - | ||
58 | static void raspi3_machine_class_init(ObjectClass *oc, void *data) | ||
59 | { | ||
60 | MachineClass *mc = MACHINE_CLASS(oc); | ||
61 | @@ -XXX,XX +XXX,XX @@ static void raspi3_machine_class_init(ObjectClass *oc, void *data) | ||
62 | |||
63 | rmc->board_rev = board_rev; | ||
64 | mc->desc = "Raspberry Pi 3B"; | ||
65 | - mc->init = raspi3_init; | ||
66 | + mc->init = raspi_machine_init; | ||
67 | mc->block_default_type = IF_SD; | ||
68 | mc->no_parallel = 1; | ||
69 | mc->no_floppy = 1; | ||
104 | -- | 70 | -- |
105 | 2.16.1 | 71 | 2.20.1 |
106 | 72 | ||
107 | 73 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | This device does not model MMCA Specification previous to v4.2 | 3 | We added a helper to extract the RAM size from the board |
4 | revision, and made board_rev a field of RaspiMachineClass. | ||
5 | The class_init() can now use the helper to extract from the | ||
6 | board revision the board-specific amount of RAM. | ||
4 | 7 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 9 | Message-id: 20200208165645.15657-11-f4bug@amsat.org |
7 | Message-id: 20180215221325.7611-6-f4bug@amsat.org | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | hw/sd/sd.c | 33 --------------------------------- | 13 | hw/arm/raspi.c | 4 ++-- |
11 | 1 file changed, 33 deletions(-) | 14 | 1 file changed, 2 insertions(+), 2 deletions(-) |
12 | 15 | ||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/sd/sd.c | 18 | --- a/hw/arm/raspi.c |
16 | +++ b/hw/sd/sd.c | 19 | +++ b/hw/arm/raspi.c |
17 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | 20 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_class_init(ObjectClass *oc, void *data) |
18 | } | 21 | mc->max_cpus = BCM283X_NCPUS; |
19 | break; | 22 | mc->min_cpus = BCM283X_NCPUS; |
20 | 23 | mc->default_cpus = BCM283X_NCPUS; | |
21 | - case 11: /* CMD11: READ_DAT_UNTIL_STOP */ | 24 | - mc->default_ram_size = 1 * GiB; |
22 | - if (sd->spi) | 25 | + mc->default_ram_size = board_ram_size(board_rev); |
23 | - goto bad_cmd; | 26 | mc->ignore_memory_transaction_failures = true; |
24 | - switch (sd->state) { | 27 | }; |
25 | - case sd_transfer_state: | 28 | |
26 | - sd->state = sd_sendingdata_state; | 29 | @@ -XXX,XX +XXX,XX @@ static void raspi3_machine_class_init(ObjectClass *oc, void *data) |
27 | - sd->data_start = req.arg; | 30 | mc->max_cpus = BCM283X_NCPUS; |
28 | - sd->data_offset = 0; | 31 | mc->min_cpus = BCM283X_NCPUS; |
29 | - | 32 | mc->default_cpus = BCM283X_NCPUS; |
30 | - if (sd->data_start + sd->blk_len > sd->size) | 33 | - mc->default_ram_size = 1 * GiB; |
31 | - sd->card_status |= ADDRESS_ERROR; | 34 | + mc->default_ram_size = board_ram_size(board_rev); |
32 | - return sd_r0; | 35 | } |
33 | - | 36 | #endif |
34 | - default: | ||
35 | - break; | ||
36 | - } | ||
37 | - break; | ||
38 | - | ||
39 | case 12: /* CMD12: STOP_TRANSMISSION */ | ||
40 | switch (sd->state) { | ||
41 | case sd_sendingdata_state: | ||
42 | @@ -XXX,XX +XXX,XX @@ uint8_t sd_read_data(SDState *sd) | ||
43 | sd->state = sd_transfer_state; | ||
44 | break; | ||
45 | |||
46 | - case 11: /* CMD11: READ_DAT_UNTIL_STOP */ | ||
47 | - if (sd->data_offset == 0) | ||
48 | - BLK_READ_BLOCK(sd->data_start, io_len); | ||
49 | - ret = sd->data[sd->data_offset ++]; | ||
50 | - | ||
51 | - if (sd->data_offset >= io_len) { | ||
52 | - sd->data_start += io_len; | ||
53 | - sd->data_offset = 0; | ||
54 | - if (sd->data_start + io_len > sd->size) { | ||
55 | - sd->card_status |= ADDRESS_ERROR; | ||
56 | - break; | ||
57 | - } | ||
58 | - } | ||
59 | - break; | ||
60 | - | ||
61 | case 13: /* ACMD13: SD_STATUS */ | ||
62 | ret = sd->sd_status[sd->data_offset ++]; | ||
63 | 37 | ||
64 | -- | 38 | -- |
65 | 2.16.1 | 39 | 2.20.1 |
66 | 40 | ||
67 | 41 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The board revision encode the model type. Add a helper | ||
4 | to extract the model, and use it. | ||
5 | |||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Message-id: 20180215220540.6556-4-f4bug@amsat.org | 7 | Message-id: 20200208165645.15657-12-f4bug@amsat.org |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | hw/sd/sd.c | 27 ++++++++++++++++++++++++--- | 11 | hw/arm/raspi.c | 18 ++++++++++++++++-- |
9 | hw/sd/trace-events | 1 + | 12 | 1 file changed, 16 insertions(+), 2 deletions(-) |
10 | 2 files changed, 25 insertions(+), 3 deletions(-) | ||
11 | 13 | ||
12 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/sd/sd.c | 16 | --- a/hw/arm/raspi.c |
15 | +++ b/hw/sd/sd.c | 17 | +++ b/hw/arm/raspi.c |
16 | @@ -XXX,XX +XXX,XX @@ static const char *sd_state_name(enum SDCardStates state) | 18 | @@ -XXX,XX +XXX,XX @@ static const char *board_soc_type(uint32_t board_rev) |
17 | return state_name[state]; | 19 | return soc_types[proc_id]; |
18 | } | 20 | } |
19 | 21 | ||
20 | +static const char *sd_response_name(sd_rsp_type_t rsp) | 22 | +static const char *board_type(uint32_t board_rev) |
21 | +{ | 23 | +{ |
22 | + static const char *response_name[] = { | 24 | + static const char *types[] = { |
23 | + [sd_r0] = "RESP#0 (no response)", | 25 | + "A", "B", "A+", "B+", "2B", "Alpha", "CM1", NULL, "3B", "Zero", |
24 | + [sd_r1] = "RESP#1 (normal cmd)", | 26 | + "CM3", NULL, "Zero W", "3B+", "3A+", NULL, "CM3+", "4B", |
25 | + [sd_r2_i] = "RESP#2 (CID reg)", | ||
26 | + [sd_r2_s] = "RESP#2 (CSD reg)", | ||
27 | + [sd_r3] = "RESP#3 (OCR reg)", | ||
28 | + [sd_r6] = "RESP#6 (RCA)", | ||
29 | + [sd_r7] = "RESP#7 (operating voltage)", | ||
30 | + }; | 27 | + }; |
31 | + if (rsp == sd_illegal) { | 28 | + assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ |
32 | + return "ILLEGAL RESP"; | 29 | + int bt = FIELD_EX32(board_rev, REV_CODE, TYPE); |
30 | + if (bt >= ARRAY_SIZE(types) || !types[bt]) { | ||
31 | + return "Unknown"; | ||
33 | + } | 32 | + } |
34 | + if (rsp == sd_r1b) { | 33 | + return types[bt]; |
35 | + rsp = sd_r1; | ||
36 | + } | ||
37 | + assert(rsp <= ARRAY_SIZE(response_name)); | ||
38 | + return response_name[rsp]; | ||
39 | +} | 34 | +} |
40 | + | 35 | + |
41 | static uint8_t sd_get_dat_lines(SDState *sd) | 36 | static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) |
42 | { | 37 | { |
43 | return sd->enable ? sd->dat_lines : 0; | 38 | static const uint32_t smpboot[] = { |
44 | @@ -XXX,XX +XXX,XX @@ send_response: | 39 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_class_init(ObjectClass *oc, void *data) |
45 | 40 | uint32_t board_rev = (uint32_t)(uintptr_t)data; | |
46 | case sd_r0: | 41 | |
47 | case sd_illegal: | 42 | rmc->board_rev = board_rev; |
48 | - default: | 43 | - mc->desc = "Raspberry Pi 2B"; |
49 | rsplen = 0; | 44 | + mc->desc = g_strdup_printf("Raspberry Pi %s", board_type(board_rev)); |
50 | break; | 45 | mc->init = raspi_machine_init; |
51 | + default: | 46 | mc->block_default_type = IF_SD; |
52 | + g_assert_not_reached(); | 47 | mc->no_parallel = 1; |
53 | } | 48 | @@ -XXX,XX +XXX,XX @@ static void raspi3_machine_class_init(ObjectClass *oc, void *data) |
54 | + trace_sdcard_response(sd_response_name(rtype), rsplen); | 49 | uint32_t board_rev = (uint32_t)(uintptr_t)data; |
55 | 50 | ||
56 | if (rtype != sd_illegal) { | 51 | rmc->board_rev = board_rev; |
57 | /* Clear the "clear on valid command" status bits now we've | 52 | - mc->desc = "Raspberry Pi 3B"; |
58 | @@ -XXX,XX +XXX,XX @@ send_response: | 53 | + mc->desc = g_strdup_printf("Raspberry Pi %s", board_type(board_rev)); |
59 | DPRINTF(" %02x", response[i]); | 54 | mc->init = raspi_machine_init; |
60 | } | 55 | mc->block_default_type = IF_SD; |
61 | DPRINTF(" state %d\n", sd->state); | 56 | mc->no_parallel = 1; |
62 | - } else { | ||
63 | - DPRINTF("No response %d\n", sd->state); | ||
64 | } | ||
65 | #endif | ||
66 | |||
67 | diff --git a/hw/sd/trace-events b/hw/sd/trace-events | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/hw/sd/trace-events | ||
70 | +++ b/hw/sd/trace-events | ||
71 | @@ -XXX,XX +XXX,XX @@ sdhci_capareg(const char *desc, uint16_t val) "%s: %u" | ||
72 | # hw/sd/sd.c | ||
73 | sdcard_normal_command(uint8_t cmd, uint32_t arg, const char *state) "CMD%d arg 0x%08x (state %s)" | ||
74 | sdcard_app_command(uint8_t acmd, uint32_t arg) "ACMD%d arg 0x%08x" | ||
75 | +sdcard_response(const char *rspdesc, int rsplen) "%s (sz:%d)" | ||
76 | sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
77 | sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
78 | |||
79 | -- | 57 | -- |
80 | 2.16.1 | 58 | 2.20.1 |
81 | 59 | ||
82 | 60 | 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 | With the exception of the ignore_memory_transaction_failures |
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | flag set for the raspi2, both machine_class_init() methods |
5 | Message-id: 20180215221325.7611-3-f4bug@amsat.org | 5 | are now identical. Merge them to keep a unique method. |
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
9 | Message-id: 20200208165645.15657-13-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/sd/sd.c | 3 +-- | 12 | hw/arm/raspi.c | 31 ++++++------------------------- |
9 | 1 file changed, 1 insertion(+), 2 deletions(-) | 13 | 1 file changed, 6 insertions(+), 25 deletions(-) |
10 | 14 | ||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 15 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/sd/sd.c | 17 | --- a/hw/arm/raspi.c |
14 | +++ b/hw/sd/sd.c | 18 | +++ b/hw/arm/raspi.c |
15 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | 19 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) |
16 | sd->csd[13] = 0x20 | /* Max. write data block length */ | 20 | setup_boot(machine, version, machine->ram_size - vcram_size); |
17 | ((HWBLOCK_SHIFT << 6) & 0xc0); | ||
18 | sd->csd[14] = 0x00; /* File format group */ | ||
19 | - sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1; | ||
20 | } else { /* SDHC */ | ||
21 | size /= 512 * 1024; | ||
22 | size -= 1; | ||
23 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | ||
24 | sd->csd[12] = 0x0a; | ||
25 | sd->csd[13] = 0x40; | ||
26 | sd->csd[14] = 0x00; | ||
27 | - sd->csd[15] = 0x00; | ||
28 | } | ||
29 | + sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1; | ||
30 | } | 21 | } |
31 | 22 | ||
32 | static void sd_set_rca(SDState *sd) | 23 | -static void raspi2_machine_class_init(ObjectClass *oc, void *data) |
24 | +static void raspi_machine_class_init(ObjectClass *oc, void *data) | ||
25 | { | ||
26 | MachineClass *mc = MACHINE_CLASS(oc); | ||
27 | RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
28 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_class_init(ObjectClass *oc, void *data) | ||
29 | mc->min_cpus = BCM283X_NCPUS; | ||
30 | mc->default_cpus = BCM283X_NCPUS; | ||
31 | mc->default_ram_size = board_ram_size(board_rev); | ||
32 | - mc->ignore_memory_transaction_failures = true; | ||
33 | + if (board_version(board_rev) == 2) { | ||
34 | + mc->ignore_memory_transaction_failures = true; | ||
35 | + } | ||
36 | }; | ||
37 | |||
38 | -#ifdef TARGET_AARCH64 | ||
39 | -static void raspi3_machine_class_init(ObjectClass *oc, void *data) | ||
40 | -{ | ||
41 | - MachineClass *mc = MACHINE_CLASS(oc); | ||
42 | - RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
43 | - uint32_t board_rev = (uint32_t)(uintptr_t)data; | ||
44 | - | ||
45 | - rmc->board_rev = board_rev; | ||
46 | - mc->desc = g_strdup_printf("Raspberry Pi %s", board_type(board_rev)); | ||
47 | - mc->init = raspi_machine_init; | ||
48 | - mc->block_default_type = IF_SD; | ||
49 | - mc->no_parallel = 1; | ||
50 | - mc->no_floppy = 1; | ||
51 | - mc->no_cdrom = 1; | ||
52 | - mc->max_cpus = BCM283X_NCPUS; | ||
53 | - mc->min_cpus = BCM283X_NCPUS; | ||
54 | - mc->default_cpus = BCM283X_NCPUS; | ||
55 | - mc->default_ram_size = board_ram_size(board_rev); | ||
56 | -} | ||
57 | -#endif | ||
58 | - | ||
59 | static const TypeInfo raspi_machine_types[] = { | ||
60 | { | ||
61 | .name = MACHINE_TYPE_NAME("raspi2"), | ||
62 | .parent = TYPE_RASPI_MACHINE, | ||
63 | - .class_init = raspi2_machine_class_init, | ||
64 | + .class_init = raspi_machine_class_init, | ||
65 | .class_data = (void *)0xa21041, | ||
66 | #ifdef TARGET_AARCH64 | ||
67 | }, { | ||
68 | .name = MACHINE_TYPE_NAME("raspi3"), | ||
69 | .parent = TYPE_RASPI_MACHINE, | ||
70 | - .class_init = raspi3_machine_class_init, | ||
71 | + .class_init = raspi_machine_class_init, | ||
72 | .class_data = (void *)0xa02082, | ||
73 | #endif | ||
74 | }, { | ||
33 | -- | 75 | -- |
34 | 2.16.1 | 76 | 2.20.1 |
35 | 77 | ||
36 | 78 | diff view generated by jsdifflib |
1 | From: Pekka Enberg <penberg@iki.fi> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds a "raspi3" machine type, which can now be selected as | 3 | The count of ARM cores is encoded in the board revision. Add a |
4 | the machine to run on by users via the "-M" command line option to QEMU. | 4 | helper to extract the number of cores, and use it. This will be |
5 | helpful when we add the Raspi0/1 that have a single core. | ||
5 | 6 | ||
6 | The machine type does *not* ignore memory transaction failures so we | 7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | likely need to add some dummy devices later when people run something | 8 | Message-id: 20200208165645.15657-14-f4bug@amsat.org |
8 | more complicated than what I'm using for testing. | ||
9 | |||
10 | Signed-off-by: Pekka Enberg <penberg@iki.fi> | ||
11 | [PMM: added #ifdef TARGET_AARCH64 so we don't provide the 64-bit | ||
12 | board in the 32-bit only arm-softmmu build.] | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 10 | [PMM: tweaked commit message as suggested by Igor] |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 12 | --- |
17 | hw/arm/raspi.c | 23 +++++++++++++++++++++++ | 13 | hw/arm/raspi.c | 19 ++++++++++++++++--- |
18 | 1 file changed, 23 insertions(+) | 14 | 1 file changed, 16 insertions(+), 3 deletions(-) |
19 | 15 | ||
20 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/raspi.c | 18 | --- a/hw/arm/raspi.c |
23 | +++ b/hw/arm/raspi.c | 19 | +++ b/hw/arm/raspi.c |
24 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) | 20 | @@ -XXX,XX +XXX,XX @@ static const char *board_soc_type(uint32_t board_rev) |
25 | mc->ignore_memory_transaction_failures = true; | 21 | return soc_types[proc_id]; |
26 | }; | 22 | } |
27 | DEFINE_MACHINE("raspi2", raspi2_machine_init) | 23 | |
24 | +static int cores_count(uint32_t board_rev) | ||
25 | +{ | ||
26 | + static const int soc_cores_count[] = { | ||
27 | + 0, BCM283X_NCPUS, BCM283X_NCPUS, | ||
28 | + }; | ||
29 | + int proc_id = board_processor_id(board_rev); | ||
28 | + | 30 | + |
29 | +#ifdef TARGET_AARCH64 | 31 | + if (proc_id >= ARRAY_SIZE(soc_cores_count) || !soc_cores_count[proc_id]) { |
30 | +static void raspi3_init(MachineState *machine) | 32 | + error_report("Unsupported processor id '%d' (board revision: 0x%x)", |
31 | +{ | 33 | + proc_id, board_rev); |
32 | + raspi_init(machine, 3); | 34 | + exit(1); |
35 | + } | ||
36 | + return soc_cores_count[proc_id]; | ||
33 | +} | 37 | +} |
34 | + | 38 | + |
35 | +static void raspi3_machine_init(MachineClass *mc) | 39 | static const char *board_type(uint32_t board_rev) |
36 | +{ | 40 | { |
37 | + mc->desc = "Raspberry Pi 3"; | 41 | static const char *types[] = { |
38 | + mc->init = raspi3_init; | 42 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data) |
39 | + mc->block_default_type = IF_SD; | 43 | mc->no_parallel = 1; |
40 | + mc->no_parallel = 1; | 44 | mc->no_floppy = 1; |
41 | + mc->no_floppy = 1; | 45 | mc->no_cdrom = 1; |
42 | + mc->no_cdrom = 1; | 46 | - mc->max_cpus = BCM283X_NCPUS; |
43 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); | 47 | - mc->min_cpus = BCM283X_NCPUS; |
44 | + mc->max_cpus = BCM2836_NCPUS; | 48 | - mc->default_cpus = BCM283X_NCPUS; |
45 | + mc->min_cpus = BCM2836_NCPUS; | 49 | + mc->default_cpus = mc->min_cpus = mc->max_cpus = cores_count(board_rev); |
46 | + mc->default_cpus = BCM2836_NCPUS; | 50 | mc->default_ram_size = board_ram_size(board_rev); |
47 | + mc->default_ram_size = 1024 * 1024 * 1024; | 51 | if (board_version(board_rev) == 2) { |
48 | +} | 52 | mc->ignore_memory_transaction_failures = true; |
49 | +DEFINE_MACHINE("raspi3", raspi3_machine_init) | ||
50 | +#endif | ||
51 | -- | 53 | -- |
52 | 2.16.1 | 54 | 2.20.1 |
53 | 55 | ||
54 | 56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The ARMv8.1-VMID16 extension extends the VMID from 8 bits to 16 bits: | ||
1 | 2 | ||
3 | * the ID_AA64MMFR1_EL1.VMIDBits field specifies whether the VMID is | ||
4 | 8 or 16 bits | ||
5 | * the VMID field in VTTBR_EL2 is extended to 16 bits | ||
6 | * VTCR_EL2.VS lets the guest specify whether to use the full 16 bits, | ||
7 | or use the backwards-compatible 8 bits | ||
8 | |||
9 | For QEMU implementing this is trivial: | ||
10 | * we do not track VMIDs in TLB entries, so we never use the VMID field | ||
11 | * we treat any write to VTTBR_EL2, not just a change to the VMID field | ||
12 | bits, as a "possible VMID change" that causes us to throw away TLB | ||
13 | entries, so that code doesn't need changing | ||
14 | * we allow the guest to read/write the VTCR_EL2.VS bit already | ||
15 | |||
16 | So all that's missing is the ID register part: report that we support | ||
17 | VMID16 in our 'max' CPU. | ||
18 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
22 | Message-id: 20200210120146.17631-1-peter.maydell@linaro.org | ||
23 | --- | ||
24 | target/arm/cpu64.c | 1 + | ||
25 | 1 file changed, 1 insertion(+) | ||
26 | |||
27 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/cpu64.c | ||
30 | +++ b/target/arm/cpu64.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
32 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); | ||
33 | t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); | ||
34 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ | ||
35 | + t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */ | ||
36 | cpu->isar.id_aa64mmfr1 = t; | ||
37 | |||
38 | t = cpu->isar.id_aa64mmfr2; | ||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |