1 | Probably the last arm pullreq before softfreeze... | 1 | A largish pullreq but it's almost all docs fixes. |
---|---|---|---|
2 | 2 | ||
3 | The following changes since commit 58560ad254fbda71d4daa6622d71683190070ee2: | 3 | -- PMM |
4 | 4 | ||
5 | Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-4.2-20191024' into staging (2019-10-24 16:22:58 +0100) | 5 | The following changes since commit 10a3c4a4b3e14208cfed274514d1911e5230935f: |
6 | |||
7 | Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging (2021-08-02 09:47:07 +0100) | ||
6 | 8 | ||
7 | are available in the Git repository at: | 9 | are available in the Git repository at: |
8 | 10 | ||
9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20191024 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210802 |
10 | 12 | ||
11 | for you to fetch changes up to a01a4a3e85ae8f6fe21adbedc80f7013faabdcf4: | 13 | for you to fetch changes up to 4a64939db76b10d8d41d2af3c6aad8142da55450: |
12 | 14 | ||
13 | hw/arm/highbank: Use AddressSpace when using write_secondary_boot() (2019-10-24 17:16:30 +0100) | 15 | docs: Move user-facing barrier docs into system manual (2021-08-02 12:55:51 +0100) |
14 | 16 | ||
15 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
16 | target-arm queue: | 18 | target-arm queue: |
17 | * raspi boards: some cleanup | 19 | * Add documentation of Arm 'mainstone', 'kzm', 'imx25-pdk' boards |
18 | * raspi: implement the bcm2835 system timer device | 20 | * MAINTAINERS: Don't list Andrzej Zaborowski for various components |
19 | * raspi: implement a dummy thermal sensor | 21 | * docs: Remove stale TODO comments about license and version |
20 | * KVM: support providing SVE to the guest | 22 | * docs: Move licence/copyright from HTML output to rST comments |
21 | * misc devices: switch to ptimer transaction API | 23 | * docs: Format literal text correctly |
22 | * cache TB flag state to improve performance of cpu_get_tb_cpu_state | 24 | * hw/arm/boot: Report error if there is no fw_cfg device in the machine |
23 | * aspeed: Add an AST2600 eval board | 25 | * docs: rSTify barrier.txt and bootindex.txt |
24 | 26 | ||
25 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
26 | Andrew Jones (9): | 28 | Peter Maydell (21): |
27 | target/arm/monitor: Introduce qmp_query_cpu_model_expansion | 29 | docs: Add documentation of Arm 'mainstone' board |
28 | tests: arm: Introduce cpu feature tests | 30 | docs: Add documentation of Arm 'kzm' board |
29 | target/arm: Allow SVE to be disabled via a CPU property | 31 | docs: Add documentation of Arm 'imx25-pdk' board |
30 | target/arm/cpu64: max cpu: Introduce sve<N> properties | 32 | MAINTAINERS: Don't list Andrzej Zaborowski for various components |
31 | target/arm/kvm64: Add kvm_arch_get/put_sve | 33 | docs: Remove stale TODO comments about license and version |
32 | target/arm/kvm64: max cpu: Enable SVE when available | 34 | docs: Move licence/copyright from HTML output to rST comments |
33 | target/arm/kvm: scratch vcpu: Preserve input kvm_vcpu_init features | 35 | docs/devel/build-system.rst: Format literals correctly |
34 | target/arm/cpu64: max cpu: Support sve properties with KVM | 36 | docs/devel/build-system.rst: Correct typo in example code |
35 | target/arm/kvm: host cpu: Add support for sve<N> properties | 37 | docs/devel/ebpf_rss.rst: Format literals correctly |
38 | docs/devel/migration.rst: Format literals correctly | ||
39 | docs/devel: Format literals correctly | ||
40 | docs/system/s390x/protvirt.rst: Format literals correctly | ||
41 | docs/system/arm/cpu-features.rst: Format literals correctly | ||
42 | docs: Format literals correctly | ||
43 | docs/about/removed-features: Fix markup error | ||
44 | docs/tools/virtiofsd.rst: Delete stray backtick | ||
45 | hw/arm/boot: Report error if there is no fw_cfg device in the machine | ||
46 | docs: Move bootindex.txt into system section and rstify | ||
47 | docs: Move the protocol part of barrier.txt into interop | ||
48 | ui/input-barrier: Move TODOs from barrier.txt to a comment | ||
49 | docs: Move user-facing barrier docs into system manual | ||
36 | 50 | ||
37 | Cédric Le Goater (2): | 51 | docs/about/index.rst | 2 +- |
38 | hw/gpio: Fix property accessors of the AST2600 GPIO 1.8V model | 52 | docs/about/removed-features.rst | 2 +- |
39 | aspeed: Add an AST2600 eval board | 53 | docs/barrier.txt | 370 ----------------------- |
54 | docs/bootindex.txt | 52 ---- | ||
55 | docs/devel/build-system.rst | 160 +++++----- | ||
56 | docs/devel/ebpf_rss.rst | 18 +- | ||
57 | docs/devel/migration.rst | 36 +-- | ||
58 | docs/devel/qgraph.rst | 8 +- | ||
59 | docs/devel/tcg-plugins.rst | 14 +- | ||
60 | docs/devel/testing.rst | 8 +- | ||
61 | docs/interop/barrier.rst | 426 +++++++++++++++++++++++++++ | ||
62 | docs/interop/index.rst | 1 + | ||
63 | docs/interop/live-block-operations.rst | 2 +- | ||
64 | docs/interop/qemu-ga-ref.rst | 9 - | ||
65 | docs/interop/qemu-qmp-ref.rst | 9 - | ||
66 | docs/interop/qemu-storage-daemon-qmp-ref.rst | 9 - | ||
67 | docs/interop/vhost-user-gpu.rst | 7 +- | ||
68 | docs/interop/vhost-user.rst | 12 +- | ||
69 | docs/system/arm/cpu-features.rst | 116 ++++---- | ||
70 | docs/system/arm/imx25-pdk.rst | 19 ++ | ||
71 | docs/system/arm/kzm.rst | 18 ++ | ||
72 | docs/system/arm/mainstone.rst | 25 ++ | ||
73 | docs/system/arm/nuvoton.rst | 2 +- | ||
74 | docs/system/arm/sbsa.rst | 4 +- | ||
75 | docs/system/arm/virt.rst | 2 +- | ||
76 | docs/system/barrier.rst | 44 +++ | ||
77 | docs/system/bootindex.rst | 76 +++++ | ||
78 | docs/system/cpu-hotplug.rst | 2 +- | ||
79 | docs/system/generic-loader.rst | 4 +- | ||
80 | docs/system/guest-loader.rst | 6 +- | ||
81 | docs/system/index.rst | 2 + | ||
82 | docs/system/ppc/powernv.rst | 8 +- | ||
83 | docs/system/riscv/microchip-icicle-kit.rst | 2 +- | ||
84 | docs/system/riscv/virt.rst | 2 +- | ||
85 | docs/system/s390x/protvirt.rst | 12 +- | ||
86 | docs/system/target-arm.rst | 3 + | ||
87 | docs/tools/virtiofsd.rst | 2 +- | ||
88 | hw/arm/boot.c | 9 + | ||
89 | hw/arm/sbsa-ref.c | 7 - | ||
90 | ui/input-barrier.c | 5 + | ||
91 | MAINTAINERS | 8 +- | ||
92 | 41 files changed, 849 insertions(+), 674 deletions(-) | ||
93 | delete mode 100644 docs/barrier.txt | ||
94 | delete mode 100644 docs/bootindex.txt | ||
95 | create mode 100644 docs/interop/barrier.rst | ||
96 | create mode 100644 docs/system/arm/imx25-pdk.rst | ||
97 | create mode 100644 docs/system/arm/kzm.rst | ||
98 | create mode 100644 docs/system/arm/mainstone.rst | ||
99 | create mode 100644 docs/system/barrier.rst | ||
100 | create mode 100644 docs/system/bootindex.rst | ||
40 | 101 | ||
41 | Peter Maydell (8): | ||
42 | hw/net/fsl_etsec/etsec.c: Switch to transaction-based ptimer API | ||
43 | hw/timer/xilinx_timer.c: Switch to transaction-based ptimer API | ||
44 | hw/dma/xilinx_axidma.c: Switch to transaction-based ptimer API | ||
45 | hw/timer/slavio_timer: Remove useless check for NULL t->timer | ||
46 | hw/timer/slavio_timer.c: Switch to transaction-based ptimer API | ||
47 | hw/timer/grlib_gptimer.c: Switch to transaction-based ptimer API | ||
48 | hw/m68k/mcf5206.c: Switch to transaction-based ptimer API | ||
49 | hw/watchdog/milkymist-sysctl.c: Switch to transaction-based ptimer API | ||
50 | |||
51 | Philippe Mathieu-Daudé (8): | ||
52 | hw/misc/bcm2835_thermal: Add a dummy BCM2835 thermal sensor | ||
53 | hw/arm/bcm2835_peripherals: Use the thermal sensor block | ||
54 | hw/timer/bcm2835: Add the BCM2835 SYS_timer | ||
55 | hw/arm/bcm2835_peripherals: Use the SYS_timer | ||
56 | hw/arm/bcm2836: Make the SoC code modular | ||
57 | hw/arm/bcm2836: Rename cpus[] as cpu[].core | ||
58 | hw/arm/raspi: Use AddressSpace when using arm_boot::write_secondary_boot | ||
59 | hw/arm/highbank: Use AddressSpace when using write_secondary_boot() | ||
60 | |||
61 | Richard Henderson (24): | ||
62 | target/arm: Split out rebuild_hflags_common | ||
63 | target/arm: Split out rebuild_hflags_a64 | ||
64 | target/arm: Split out rebuild_hflags_common_32 | ||
65 | target/arm: Split arm_cpu_data_is_big_endian | ||
66 | target/arm: Split out rebuild_hflags_m32 | ||
67 | target/arm: Reduce tests vs M-profile in cpu_get_tb_cpu_state | ||
68 | target/arm: Split out rebuild_hflags_a32 | ||
69 | target/arm: Split out rebuild_hflags_aprofile | ||
70 | target/arm: Hoist XSCALE_CPAR, VECLEN, VECSTRIDE in cpu_get_tb_cpu_state | ||
71 | target/arm: Simplify set of PSTATE_SS in cpu_get_tb_cpu_state | ||
72 | target/arm: Hoist computation of TBFLAG_A32.VFPEN | ||
73 | target/arm: Add arm_rebuild_hflags | ||
74 | target/arm: Split out arm_mmu_idx_el | ||
75 | target/arm: Hoist store to cs_base in cpu_get_tb_cpu_state | ||
76 | target/arm: Add HELPER(rebuild_hflags_{a32, a64, m32}) | ||
77 | target/arm: Rebuild hflags at EL changes | ||
78 | target/arm: Rebuild hflags at MSR writes | ||
79 | target/arm: Rebuild hflags at CPSR writes | ||
80 | target/arm: Rebuild hflags at Xscale SCTLR writes | ||
81 | target/arm: Rebuild hflags for M-profile | ||
82 | target/arm: Rebuild hflags for M-profile NVIC | ||
83 | linux-user/aarch64: Rebuild hflags for TARGET_WORDS_BIGENDIAN | ||
84 | linux-user/arm: Rebuild hflags for TARGET_WORDS_BIGENDIAN | ||
85 | target/arm: Rely on hflags correct in cpu_get_tb_cpu_state | ||
86 | |||
87 | hw/misc/Makefile.objs | 1 + | ||
88 | hw/timer/Makefile.objs | 1 + | ||
89 | tests/Makefile.include | 5 +- | ||
90 | qapi/machine-target.json | 6 +- | ||
91 | hw/net/fsl_etsec/etsec.h | 1 - | ||
92 | include/hw/arm/aspeed.h | 1 + | ||
93 | include/hw/arm/bcm2835_peripherals.h | 5 +- | ||
94 | include/hw/arm/bcm2836.h | 4 +- | ||
95 | include/hw/arm/raspi_platform.h | 1 + | ||
96 | include/hw/misc/bcm2835_thermal.h | 27 ++ | ||
97 | include/hw/timer/bcm2835_systmr.h | 33 +++ | ||
98 | include/qemu/bitops.h | 1 + | ||
99 | target/arm/cpu.h | 105 +++++-- | ||
100 | target/arm/helper.h | 4 + | ||
101 | target/arm/internals.h | 9 + | ||
102 | target/arm/kvm_arm.h | 39 +++ | ||
103 | hw/arm/aspeed.c | 23 ++ | ||
104 | hw/arm/bcm2835_peripherals.c | 30 +- | ||
105 | hw/arm/bcm2836.c | 44 +-- | ||
106 | hw/arm/highbank.c | 3 +- | ||
107 | hw/arm/raspi.c | 14 +- | ||
108 | hw/dma/xilinx_axidma.c | 9 +- | ||
109 | hw/gpio/aspeed_gpio.c | 8 +- | ||
110 | hw/intc/armv7m_nvic.c | 22 +- | ||
111 | hw/m68k/mcf5206.c | 15 +- | ||
112 | hw/misc/bcm2835_thermal.c | 135 +++++++++ | ||
113 | hw/net/fsl_etsec/etsec.c | 9 +- | ||
114 | hw/timer/bcm2835_systmr.c | 163 +++++++++++ | ||
115 | hw/timer/grlib_gptimer.c | 28 +- | ||
116 | hw/timer/milkymist-sysctl.c | 25 +- | ||
117 | hw/timer/slavio_timer.c | 32 ++- | ||
118 | hw/timer/xilinx_timer.c | 13 +- | ||
119 | linux-user/aarch64/cpu_loop.c | 1 + | ||
120 | linux-user/arm/cpu_loop.c | 1 + | ||
121 | linux-user/syscall.c | 1 + | ||
122 | target/arm/cpu.c | 26 +- | ||
123 | target/arm/cpu64.c | 364 +++++++++++++++++++++-- | ||
124 | target/arm/helper-a64.c | 3 + | ||
125 | target/arm/helper.c | 403 +++++++++++++++++--------- | ||
126 | target/arm/kvm.c | 25 +- | ||
127 | target/arm/kvm32.c | 6 +- | ||
128 | target/arm/kvm64.c | 325 ++++++++++++++++++--- | ||
129 | target/arm/m_helper.c | 6 + | ||
130 | target/arm/machine.c | 1 + | ||
131 | target/arm/monitor.c | 158 ++++++++++ | ||
132 | target/arm/op_helper.c | 4 + | ||
133 | target/arm/translate-a64.c | 13 +- | ||
134 | target/arm/translate.c | 33 ++- | ||
135 | tests/arm-cpu-features.c | 540 +++++++++++++++++++++++++++++++++++ | ||
136 | docs/arm-cpu-features.rst | 317 ++++++++++++++++++++ | ||
137 | hw/timer/trace-events | 5 + | ||
138 | 51 files changed, 2725 insertions(+), 323 deletions(-) | ||
139 | create mode 100644 include/hw/misc/bcm2835_thermal.h | ||
140 | create mode 100644 include/hw/timer/bcm2835_systmr.h | ||
141 | create mode 100644 hw/misc/bcm2835_thermal.c | ||
142 | create mode 100644 hw/timer/bcm2835_systmr.c | ||
143 | create mode 100644 tests/arm-cpu-features.c | ||
144 | create mode 100644 docs/arm-cpu-features.rst | ||
145 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The property names of AST2600 GPIO 1.8V model are one character bigger | ||
4 | than the names of the other ASPEED GPIO model. Increase the string | ||
5 | buffer size by one and be more strict on the expected pattern of the | ||
6 | property name. | ||
7 | |||
8 | This fixes the QOM test of the ast2600-evb machine under : | ||
9 | |||
10 | Apple LLVM version 10.0.0 (clang-1000.10.44.4) | ||
11 | Target: x86_64-apple-darwin17.7.0 | ||
12 | Thread model: posix | ||
13 | InstalledDir: /Library/Developer/CommandLineTools/usr/bin | ||
14 | |||
15 | Cc: Rashmica Gupta <rashmica.g@gmail.com> | ||
16 | Fixes: 36d737ee82b2 ("hw/gpio: Add in AST2600 specific implementation") | ||
17 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
18 | Message-id: 20191023130455.1347-2-clg@kaod.org | ||
19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | --- | ||
22 | hw/gpio/aspeed_gpio.c | 8 ++++---- | ||
23 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
24 | |||
25 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/gpio/aspeed_gpio.c | ||
28 | +++ b/hw/gpio/aspeed_gpio.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name, | ||
30 | { | ||
31 | int pin = 0xfff; | ||
32 | bool level = true; | ||
33 | - char group[3]; | ||
34 | + char group[4]; | ||
35 | AspeedGPIOState *s = ASPEED_GPIO(obj); | ||
36 | int set_idx, group_idx = 0; | ||
37 | |||
38 | if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { | ||
39 | /* 1.8V gpio */ | ||
40 | - if (sscanf(name, "gpio%3s%1d", group, &pin) != 2) { | ||
41 | + if (sscanf(name, "gpio%3[18A-E]%1d", group, &pin) != 2) { | ||
42 | error_setg(errp, "%s: error reading %s", __func__, name); | ||
43 | return; | ||
44 | } | ||
45 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name, | ||
46 | Error *local_err = NULL; | ||
47 | bool level; | ||
48 | int pin = 0xfff; | ||
49 | - char group[3]; | ||
50 | + char group[4]; | ||
51 | AspeedGPIOState *s = ASPEED_GPIO(obj); | ||
52 | int set_idx, group_idx = 0; | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name, | ||
55 | } | ||
56 | if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { | ||
57 | /* 1.8V gpio */ | ||
58 | - if (sscanf(name, "gpio%3s%1d", group, &pin) != 2) { | ||
59 | + if (sscanf(name, "gpio%3[18A-E]%1d", group, &pin) != 2) { | ||
60 | error_setg(errp, "%s: error reading %s", __func__, name); | ||
61 | return; | ||
62 | } | ||
63 | -- | ||
64 | 2.20.1 | ||
65 | |||
66 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
4 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
5 | Message-id: 20191023130455.1347-3-clg@kaod.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/arm/aspeed.h | 1 + | ||
9 | hw/arm/aspeed.c | 23 +++++++++++++++++++++++ | ||
10 | 2 files changed, 24 insertions(+) | ||
11 | |||
12 | diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/arm/aspeed.h | ||
15 | +++ b/include/hw/arm/aspeed.h | ||
16 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedBoardConfig { | ||
17 | const char *desc; | ||
18 | const char *soc_name; | ||
19 | uint32_t hw_strap1; | ||
20 | + uint32_t hw_strap2; | ||
21 | const char *fmc_model; | ||
22 | const char *spi_model; | ||
23 | uint32_t num_cs; | ||
24 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/arm/aspeed.c | ||
27 | +++ b/hw/arm/aspeed.c | ||
28 | @@ -XXX,XX +XXX,XX @@ struct AspeedBoardState { | ||
29 | /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */ | ||
30 | #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1 | ||
31 | |||
32 | +/* AST2600 evb hardware value */ | ||
33 | +#define AST2600_EVB_HW_STRAP1 0x000000C0 | ||
34 | +#define AST2600_EVB_HW_STRAP2 0x00000003 | ||
35 | + | ||
36 | /* | ||
37 | * The max ram region is for firmwares that scan the address space | ||
38 | * with load/store to guess how much RAM the SoC has. | ||
39 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
40 | &error_abort); | ||
41 | object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1", | ||
42 | &error_abort); | ||
43 | + object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap2, "hw-strap2", | ||
44 | + &error_abort); | ||
45 | object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", | ||
46 | &error_abort); | ||
47 | object_property_set_int(OBJECT(&bmc->soc), machine->smp.cpus, "num-cpus", | ||
48 | @@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) | ||
49 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); | ||
50 | } | ||
51 | |||
52 | +static void ast2600_evb_i2c_init(AspeedBoardState *bmc) | ||
53 | +{ | ||
54 | + /* Start with some devices on our I2C busses */ | ||
55 | + ast2500_evb_i2c_init(bmc); | ||
56 | +} | ||
57 | + | ||
58 | static void romulus_bmc_i2c_init(AspeedBoardState *bmc) | ||
59 | { | ||
60 | AspeedSoCState *soc = &bmc->soc; | ||
61 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | ||
62 | .num_cs = 2, | ||
63 | .i2c_init = witherspoon_bmc_i2c_init, | ||
64 | .ram = 512 * MiB, | ||
65 | + }, { | ||
66 | + .name = MACHINE_TYPE_NAME("ast2600-evb"), | ||
67 | + .desc = "Aspeed AST2600 EVB (Cortex A7)", | ||
68 | + .soc_name = "ast2600-a0", | ||
69 | + .hw_strap1 = AST2600_EVB_HW_STRAP1, | ||
70 | + .hw_strap2 = AST2600_EVB_HW_STRAP2, | ||
71 | + .fmc_model = "w25q512jv", | ||
72 | + .spi_model = "mx66u51235f", | ||
73 | + .num_cs = 1, | ||
74 | + .i2c_init = ast2600_evb_i2c_init, | ||
75 | + .ram = 1 * GiB, | ||
76 | }, | ||
77 | }; | ||
78 | |||
79 | -- | ||
80 | 2.20.1 | ||
81 | |||
82 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Create a function to compute the values of the TBFLAG_ANY bits | ||
4 | that will be cached. For now, the env->hflags variable is not | ||
5 | used, and the results are fed back to cpu_get_tb_cpu_state. | ||
6 | |||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20191023150057.25731-2-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 29 ++++++++++++++++++----------- | ||
13 | target/arm/helper.c | 26 +++++++++++++++++++------- | ||
14 | 2 files changed, 37 insertions(+), 18 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 @@ typedef struct CPUARMState { | ||
21 | uint32_t pstate; | ||
22 | uint32_t aarch64; /* 1 if CPU is in aarch64 state; inverse of PSTATE.nRW */ | ||
23 | |||
24 | + /* Cached TBFLAGS state. See below for which bits are included. */ | ||
25 | + uint32_t hflags; | ||
26 | + | ||
27 | /* Frequently accessed CPSR bits are stored separately for efficiency. | ||
28 | This contains all the other bits. Use cpsr_{read,write} to access | ||
29 | the whole CPSR. */ | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | ||
31 | |||
32 | #include "exec/cpu-all.h" | ||
33 | |||
34 | -/* Bit usage in the TB flags field: bit 31 indicates whether we are | ||
35 | +/* | ||
36 | + * Bit usage in the TB flags field: bit 31 indicates whether we are | ||
37 | * in 32 or 64 bit mode. The meaning of the other bits depends on that. | ||
38 | * We put flags which are shared between 32 and 64 bit mode at the top | ||
39 | * of the word, and flags which apply to only one mode at the bottom. | ||
40 | + * | ||
41 | + * Unless otherwise noted, these bits are cached in env->hflags. | ||
42 | */ | ||
43 | FIELD(TBFLAG_ANY, AARCH64_STATE, 31, 1) | ||
44 | FIELD(TBFLAG_ANY, MMUIDX, 28, 3) | ||
45 | FIELD(TBFLAG_ANY, SS_ACTIVE, 27, 1) | ||
46 | -FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) | ||
47 | +FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) /* Not cached. */ | ||
48 | /* Target EL if we take a floating-point-disabled exception */ | ||
49 | FIELD(TBFLAG_ANY, FPEXC_EL, 24, 2) | ||
50 | FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | ||
51 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | ||
52 | FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 21, 2) | ||
53 | |||
54 | /* Bit usage when in AArch32 state: */ | ||
55 | -FIELD(TBFLAG_A32, THUMB, 0, 1) | ||
56 | -FIELD(TBFLAG_A32, VECLEN, 1, 3) | ||
57 | -FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) | ||
58 | +FIELD(TBFLAG_A32, THUMB, 0, 1) /* Not cached. */ | ||
59 | +FIELD(TBFLAG_A32, VECLEN, 1, 3) /* Not cached. */ | ||
60 | +FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) /* Not cached. */ | ||
61 | /* | ||
62 | * We store the bottom two bits of the CPAR as TB flags and handle | ||
63 | * checks on the other bits at runtime. This shares the same bits as | ||
64 | * VECSTRIDE, which is OK as no XScale CPU has VFP. | ||
65 | + * Not cached, because VECLEN+VECSTRIDE are not cached. | ||
66 | */ | ||
67 | FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) | ||
68 | /* | ||
69 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) | ||
70 | * the same thing as the current security state of the processor! | ||
71 | */ | ||
72 | FIELD(TBFLAG_A32, NS, 6, 1) | ||
73 | -FIELD(TBFLAG_A32, VFPEN, 7, 1) | ||
74 | -FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | ||
75 | +FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Not cached. */ | ||
76 | +FIELD(TBFLAG_A32, CONDEXEC, 8, 8) /* Not cached. */ | ||
77 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
78 | /* For M profile only, set if FPCCR.LSPACT is set */ | ||
79 | -FIELD(TBFLAG_A32, LSPACT, 18, 1) | ||
80 | +FIELD(TBFLAG_A32, LSPACT, 18, 1) /* Not cached. */ | ||
81 | /* For M profile only, set if we must create a new FP context */ | ||
82 | -FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) | ||
83 | +FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) /* Not cached. */ | ||
84 | /* For M profile only, set if FPCCR.S does not match current security state */ | ||
85 | -FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) | ||
86 | +FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) /* Not cached. */ | ||
87 | /* For M profile only, Handler (ie not Thread) mode */ | ||
88 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | ||
89 | /* For M profile only, whether we should generate stack-limit checks */ | ||
90 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) | ||
91 | FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) | ||
92 | FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) | ||
93 | FIELD(TBFLAG_A64, BT, 9, 1) | ||
94 | -FIELD(TBFLAG_A64, BTYPE, 10, 2) | ||
95 | +FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */ | ||
96 | FIELD(TBFLAG_A64, TBID, 12, 2) | ||
97 | |||
98 | static inline bool bswap_code(bool sctlr_b) | ||
99 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/arm/helper.c | ||
102 | +++ b/target/arm/helper.c | ||
103 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | ||
104 | } | ||
105 | #endif | ||
106 | |||
107 | +static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
108 | + ARMMMUIdx mmu_idx, uint32_t flags) | ||
109 | +{ | ||
110 | + flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); | ||
111 | + flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, | ||
112 | + arm_to_core_mmu_idx(mmu_idx)); | ||
113 | + | ||
114 | + if (arm_cpu_data_is_big_endian(env)) { | ||
115 | + flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | ||
116 | + } | ||
117 | + if (arm_singlestep_active(env)) { | ||
118 | + flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); | ||
119 | + } | ||
120 | + return flags; | ||
121 | +} | ||
122 | + | ||
123 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
124 | target_ulong *cs_base, uint32_t *pflags) | ||
125 | { | ||
126 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
127 | } | ||
128 | } | ||
129 | |||
130 | - flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); | ||
131 | + flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
132 | |||
133 | /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine | ||
134 | * states defined in the ARM ARM for software singlestep: | ||
135 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
136 | * 0 x Inactive (the TB flag for SS is always 0) | ||
137 | * 1 0 Active-pending | ||
138 | * 1 1 Active-not-pending | ||
139 | + * SS_ACTIVE is set in hflags; PSTATE_SS is computed every TB. | ||
140 | */ | ||
141 | - if (arm_singlestep_active(env)) { | ||
142 | - flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); | ||
143 | + if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE)) { | ||
144 | if (is_a64(env)) { | ||
145 | if (env->pstate & PSTATE_SS) { | ||
146 | flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); | ||
147 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | - if (arm_cpu_data_is_big_endian(env)) { | ||
152 | - flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | ||
153 | - } | ||
154 | - flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); | ||
155 | |||
156 | if (arm_v7m_is_handler_mode(env)) { | ||
157 | flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1); | ||
158 | -- | ||
159 | 2.20.1 | ||
160 | |||
161 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Create a function to compute the values of the TBFLAG_A64 bits | ||
4 | that will be cached. For now, the env->hflags variable is not | ||
5 | used, and the results are fed back to cpu_get_tb_cpu_state. | ||
6 | |||
7 | Note that not all BTI related flags are cached, so we have to | ||
8 | test the BTI feature twice -- once for those bits moved out to | ||
9 | rebuild_hflags_a64 and once for those bits that remain in | ||
10 | cpu_get_tb_cpu_state. | ||
11 | |||
12 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20191023150057.25731-3-richard.henderson@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/helper.c | 131 +++++++++++++++++++++++--------------------- | ||
18 | 1 file changed, 69 insertions(+), 62 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/helper.c | ||
23 | +++ b/target/arm/helper.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
25 | return flags; | ||
26 | } | ||
27 | |||
28 | +static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
29 | + ARMMMUIdx mmu_idx) | ||
30 | +{ | ||
31 | + ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); | ||
32 | + ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); | ||
33 | + uint32_t flags = 0; | ||
34 | + uint64_t sctlr; | ||
35 | + int tbii, tbid; | ||
36 | + | ||
37 | + flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); | ||
38 | + | ||
39 | + /* FIXME: ARMv8.1-VHE S2 translation regime. */ | ||
40 | + if (regime_el(env, stage1) < 2) { | ||
41 | + ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); | ||
42 | + tbid = (p1.tbi << 1) | p0.tbi; | ||
43 | + tbii = tbid & ~((p1.tbid << 1) | p0.tbid); | ||
44 | + } else { | ||
45 | + tbid = p0.tbi; | ||
46 | + tbii = tbid & !p0.tbid; | ||
47 | + } | ||
48 | + | ||
49 | + flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); | ||
50 | + flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); | ||
51 | + | ||
52 | + if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
53 | + int sve_el = sve_exception_el(env, el); | ||
54 | + uint32_t zcr_len; | ||
55 | + | ||
56 | + /* | ||
57 | + * If SVE is disabled, but FP is enabled, | ||
58 | + * then the effective len is 0. | ||
59 | + */ | ||
60 | + if (sve_el != 0 && fp_el == 0) { | ||
61 | + zcr_len = 0; | ||
62 | + } else { | ||
63 | + zcr_len = sve_zcr_len_for_el(env, el); | ||
64 | + } | ||
65 | + flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); | ||
66 | + flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); | ||
67 | + } | ||
68 | + | ||
69 | + sctlr = arm_sctlr(env, el); | ||
70 | + | ||
71 | + if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) { | ||
72 | + /* | ||
73 | + * In order to save space in flags, we record only whether | ||
74 | + * pauth is "inactive", meaning all insns are implemented as | ||
75 | + * a nop, or "active" when some action must be performed. | ||
76 | + * The decision of which action to take is left to a helper. | ||
77 | + */ | ||
78 | + if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { | ||
79 | + flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | ||
84 | + /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ | ||
85 | + if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { | ||
86 | + flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); | ||
87 | + } | ||
88 | + } | ||
89 | + | ||
90 | + return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
91 | +} | ||
92 | + | ||
93 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
94 | target_ulong *cs_base, uint32_t *pflags) | ||
95 | { | ||
96 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
97 | uint32_t flags = 0; | ||
98 | |||
99 | if (is_a64(env)) { | ||
100 | - ARMCPU *cpu = env_archcpu(env); | ||
101 | - uint64_t sctlr; | ||
102 | - | ||
103 | *pc = env->pc; | ||
104 | - flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); | ||
105 | - | ||
106 | - /* Get control bits for tagged addresses. */ | ||
107 | - { | ||
108 | - ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); | ||
109 | - ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); | ||
110 | - int tbii, tbid; | ||
111 | - | ||
112 | - /* FIXME: ARMv8.1-VHE S2 translation regime. */ | ||
113 | - if (regime_el(env, stage1) < 2) { | ||
114 | - ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); | ||
115 | - tbid = (p1.tbi << 1) | p0.tbi; | ||
116 | - tbii = tbid & ~((p1.tbid << 1) | p0.tbid); | ||
117 | - } else { | ||
118 | - tbid = p0.tbi; | ||
119 | - tbii = tbid & !p0.tbid; | ||
120 | - } | ||
121 | - | ||
122 | - flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); | ||
123 | - flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); | ||
124 | - } | ||
125 | - | ||
126 | - if (cpu_isar_feature(aa64_sve, cpu)) { | ||
127 | - int sve_el = sve_exception_el(env, current_el); | ||
128 | - uint32_t zcr_len; | ||
129 | - | ||
130 | - /* If SVE is disabled, but FP is enabled, | ||
131 | - * then the effective len is 0. | ||
132 | - */ | ||
133 | - if (sve_el != 0 && fp_el == 0) { | ||
134 | - zcr_len = 0; | ||
135 | - } else { | ||
136 | - zcr_len = sve_zcr_len_for_el(env, current_el); | ||
137 | - } | ||
138 | - flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); | ||
139 | - flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); | ||
140 | - } | ||
141 | - | ||
142 | - sctlr = arm_sctlr(env, current_el); | ||
143 | - | ||
144 | - if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
145 | - /* | ||
146 | - * In order to save space in flags, we record only whether | ||
147 | - * pauth is "inactive", meaning all insns are implemented as | ||
148 | - * a nop, or "active" when some action must be performed. | ||
149 | - * The decision of which action to take is left to a helper. | ||
150 | - */ | ||
151 | - if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { | ||
152 | - flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); | ||
153 | - } | ||
154 | - } | ||
155 | - | ||
156 | - if (cpu_isar_feature(aa64_bti, cpu)) { | ||
157 | - /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ | ||
158 | - if (sctlr & (current_el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { | ||
159 | - flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); | ||
160 | - } | ||
161 | + flags = rebuild_hflags_a64(env, current_el, fp_el, mmu_idx); | ||
162 | + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | ||
163 | flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); | ||
164 | } | ||
165 | } else { | ||
166 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
167 | flags = FIELD_DP32(flags, TBFLAG_A32, | ||
168 | XSCALE_CPAR, env->cp15.c15_cpar); | ||
169 | } | ||
170 | - } | ||
171 | |||
172 | - flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
173 | + flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
174 | + } | ||
175 | |||
176 | /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine | ||
177 | * states defined in the ARM ARM for software singlestep: | ||
178 | -- | ||
179 | 2.20.1 | ||
180 | |||
181 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Create a function to compute the values of the TBFLAG_A32 bits | ||
4 | that will be cached, and are used by all profiles. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20191023150057.25731-4-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.c | 16 +++++++++++----- | ||
12 | 1 file changed, 11 insertions(+), 5 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper.c | ||
17 | +++ b/target/arm/helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
19 | return flags; | ||
20 | } | ||
21 | |||
22 | +static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | ||
23 | + ARMMMUIdx mmu_idx, uint32_t flags) | ||
24 | +{ | ||
25 | + flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); | ||
26 | + flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); | ||
27 | + | ||
28 | + return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
29 | +} | ||
30 | + | ||
31 | static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
32 | ARMMMUIdx mmu_idx) | ||
33 | { | ||
34 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
35 | ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
36 | int current_el = arm_current_el(env); | ||
37 | int fp_el = fp_exception_el(env, current_el); | ||
38 | - uint32_t flags = 0; | ||
39 | + uint32_t flags; | ||
40 | |||
41 | if (is_a64(env)) { | ||
42 | *pc = env->pc; | ||
43 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
44 | } | ||
45 | } else { | ||
46 | *pc = env->regs[15]; | ||
47 | + flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); | ||
48 | flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); | ||
49 | flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, env->vfp.vec_len); | ||
50 | flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, env->vfp.vec_stride); | ||
51 | flags = FIELD_DP32(flags, TBFLAG_A32, CONDEXEC, env->condexec_bits); | ||
52 | - flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); | ||
53 | - flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); | ||
54 | if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) | ||
55 | || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | ||
56 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
57 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
58 | flags = FIELD_DP32(flags, TBFLAG_A32, | ||
59 | XSCALE_CPAR, env->cp15.c15_cpar); | ||
60 | } | ||
61 | - | ||
62 | - flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
63 | } | ||
64 | |||
65 | /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine | ||
66 | -- | ||
67 | 2.20.1 | ||
68 | |||
69 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Set TBFLAG_ANY.BE_DATA in rebuild_hflags_common_32 and | ||
4 | rebuild_hflags_a64 instead of rebuild_hflags_common, where we do | ||
5 | not need to re-test is_a64() nor re-compute the various inputs. | ||
6 | |||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20191023150057.25731-5-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 49 +++++++++++++++++++++++++++------------------ | ||
13 | target/arm/helper.c | 16 +++++++++++---- | ||
14 | 2 files changed, 42 insertions(+), 23 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 @@ static inline uint64_t arm_sctlr(CPUARMState *env, int el) | ||
21 | } | ||
22 | } | ||
23 | |||
24 | +static inline bool arm_cpu_data_is_big_endian_a32(CPUARMState *env, | ||
25 | + bool sctlr_b) | ||
26 | +{ | ||
27 | +#ifdef CONFIG_USER_ONLY | ||
28 | + /* | ||
29 | + * In system mode, BE32 is modelled in line with the | ||
30 | + * architecture (as word-invariant big-endianness), where loads | ||
31 | + * and stores are done little endian but from addresses which | ||
32 | + * are adjusted by XORing with the appropriate constant. So the | ||
33 | + * endianness to use for the raw data access is not affected by | ||
34 | + * SCTLR.B. | ||
35 | + * In user mode, however, we model BE32 as byte-invariant | ||
36 | + * big-endianness (because user-only code cannot tell the | ||
37 | + * difference), and so we need to use a data access endianness | ||
38 | + * that depends on SCTLR.B. | ||
39 | + */ | ||
40 | + if (sctlr_b) { | ||
41 | + return true; | ||
42 | + } | ||
43 | +#endif | ||
44 | + /* In 32bit endianness is determined by looking at CPSR's E bit */ | ||
45 | + return env->uncached_cpsr & CPSR_E; | ||
46 | +} | ||
47 | + | ||
48 | +static inline bool arm_cpu_data_is_big_endian_a64(int el, uint64_t sctlr) | ||
49 | +{ | ||
50 | + return sctlr & (el ? SCTLR_EE : SCTLR_E0E); | ||
51 | +} | ||
52 | |||
53 | /* Return true if the processor is in big-endian mode. */ | ||
54 | static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) | ||
55 | { | ||
56 | - /* In 32bit endianness is determined by looking at CPSR's E bit */ | ||
57 | if (!is_a64(env)) { | ||
58 | - return | ||
59 | -#ifdef CONFIG_USER_ONLY | ||
60 | - /* In system mode, BE32 is modelled in line with the | ||
61 | - * architecture (as word-invariant big-endianness), where loads | ||
62 | - * and stores are done little endian but from addresses which | ||
63 | - * are adjusted by XORing with the appropriate constant. So the | ||
64 | - * endianness to use for the raw data access is not affected by | ||
65 | - * SCTLR.B. | ||
66 | - * In user mode, however, we model BE32 as byte-invariant | ||
67 | - * big-endianness (because user-only code cannot tell the | ||
68 | - * difference), and so we need to use a data access endianness | ||
69 | - * that depends on SCTLR.B. | ||
70 | - */ | ||
71 | - arm_sctlr_b(env) || | ||
72 | -#endif | ||
73 | - ((env->uncached_cpsr & CPSR_E) ? 1 : 0); | ||
74 | + return arm_cpu_data_is_big_endian_a32(env, arm_sctlr_b(env)); | ||
75 | } else { | ||
76 | int cur_el = arm_current_el(env); | ||
77 | uint64_t sctlr = arm_sctlr(env, cur_el); | ||
78 | - | ||
79 | - return (sctlr & (cur_el ? SCTLR_EE : SCTLR_E0E)) != 0; | ||
80 | + return arm_cpu_data_is_big_endian_a64(cur_el, sctlr); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/target/arm/helper.c | ||
87 | +++ b/target/arm/helper.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
89 | flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, | ||
90 | arm_to_core_mmu_idx(mmu_idx)); | ||
91 | |||
92 | - if (arm_cpu_data_is_big_endian(env)) { | ||
93 | - flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | ||
94 | - } | ||
95 | if (arm_singlestep_active(env)) { | ||
96 | flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); | ||
97 | } | ||
98 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
99 | static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | ||
100 | ARMMMUIdx mmu_idx, uint32_t flags) | ||
101 | { | ||
102 | - flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); | ||
103 | + bool sctlr_b = arm_sctlr_b(env); | ||
104 | + | ||
105 | + if (sctlr_b) { | ||
106 | + flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, 1); | ||
107 | + } | ||
108 | + if (arm_cpu_data_is_big_endian_a32(env, sctlr_b)) { | ||
109 | + flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | ||
110 | + } | ||
111 | flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); | ||
112 | |||
113 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
114 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
115 | |||
116 | sctlr = arm_sctlr(env, el); | ||
117 | |||
118 | + if (arm_cpu_data_is_big_endian_a64(el, sctlr)) { | ||
119 | + flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | ||
120 | + } | ||
121 | + | ||
122 | if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) { | ||
123 | /* | ||
124 | * In order to save space in flags, we record only whether | ||
125 | -- | ||
126 | 2.20.1 | ||
127 | |||
128 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Add brief documentation of the Arm 'mainstone' board. |
---|---|---|---|
2 | 2 | ||
3 | write_secondary_boot() is used in SMP configurations where the | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | CPU address space might not be the main System Bus. | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | The rom_add_blob_fixed_as() function allow us to specify an | 5 | Message-id: 20210722175229.29065-2-peter.maydell@linaro.org |
6 | address space. Use it to write each boot blob in the corresponding | 6 | --- |
7 | CPU address space. | 7 | docs/system/arm/mainstone.rst | 25 +++++++++++++++++++++++++ |
8 | docs/system/target-arm.rst | 1 + | ||
9 | MAINTAINERS | 1 + | ||
10 | 3 files changed, 27 insertions(+) | ||
11 | create mode 100644 docs/system/arm/mainstone.rst | ||
8 | 12 | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | diff --git a/docs/system/arm/mainstone.rst b/docs/system/arm/mainstone.rst |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 14 | new file mode 100644 |
11 | Message-id: 20191019234715.25750-15-f4bug@amsat.org | 15 | index XXXXXXX..XXXXXXX |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | --- /dev/null |
13 | --- | 17 | +++ b/docs/system/arm/mainstone.rst |
14 | hw/arm/highbank.c | 3 ++- | 18 | @@ -XXX,XX +XXX,XX @@ |
15 | 1 file changed, 2 insertions(+), 1 deletion(-) | 19 | +Intel Mainstone II board (``mainstone``) |
16 | 20 | +======================================== | |
17 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c | 21 | + |
22 | +The ``mainstone`` board emulates the Intel Mainstone II development | ||
23 | +board, which uses a PXA270 CPU. | ||
24 | + | ||
25 | +Emulated devices: | ||
26 | + | ||
27 | +- Flash memory | ||
28 | +- Keypad | ||
29 | +- MMC controller | ||
30 | +- 91C111 ethernet | ||
31 | +- PIC | ||
32 | +- Timer | ||
33 | +- DMA | ||
34 | +- GPIO | ||
35 | +- FIR | ||
36 | +- Serial | ||
37 | +- LCD controller | ||
38 | +- SSP | ||
39 | +- USB controller | ||
40 | +- RTC | ||
41 | +- PCMCIA | ||
42 | +- I2C | ||
43 | +- I2S | ||
44 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
18 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/highbank.c | 46 | --- a/docs/system/target-arm.rst |
20 | +++ b/hw/arm/highbank.c | 47 | +++ b/docs/system/target-arm.rst |
21 | @@ -XXX,XX +XXX,XX @@ static void hb_write_secondary(ARMCPU *cpu, const struct arm_boot_info *info) | 48 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running |
22 | for (n = 0; n < ARRAY_SIZE(smpboot); n++) { | 49 | arm/highbank |
23 | smpboot[n] = tswap32(smpboot[n]); | 50 | arm/musicpal |
24 | } | 51 | arm/gumstix |
25 | - rom_add_blob_fixed("smpboot", smpboot, sizeof(smpboot), SMP_BOOT_ADDR); | 52 | + arm/mainstone |
26 | + rom_add_blob_fixed_as("smpboot", smpboot, sizeof(smpboot), SMP_BOOT_ADDR, | 53 | arm/nrf |
27 | + arm_boot_address_space(cpu, info)); | 54 | arm/nseries |
28 | } | 55 | arm/nuvoton |
29 | 56 | diff --git a/MAINTAINERS b/MAINTAINERS | |
30 | static void hb_reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) | 57 | index XXXXXXX..XXXXXXX 100644 |
58 | --- a/MAINTAINERS | ||
59 | +++ b/MAINTAINERS | ||
60 | @@ -XXX,XX +XXX,XX @@ F: include/hw/arm/pxa.h | ||
61 | F: include/hw/arm/sharpsl.h | ||
62 | F: include/hw/display/tc6393xb.h | ||
63 | F: docs/system/arm/xscale.rst | ||
64 | +F: docs/system/arm/mainstone.rst | ||
65 | |||
66 | SABRELITE / i.MX6 | ||
67 | M: Peter Maydell <peter.maydell@linaro.org> | ||
31 | -- | 68 | -- |
32 | 2.20.1 | 69 | 2.20.1 |
33 | 70 | ||
34 | 71 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Add brief documentation of the Arm 'kzm' board. |
---|---|---|---|
2 | 2 | ||
3 | write_secondary_boot() is used in SMP configurations where the | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | CPU address space might not be the main System Bus. | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | The rom_add_blob_fixed_as() function allow us to specify an | 5 | Message-id: 20210722175229.29065-3-peter.maydell@linaro.org |
6 | address space. Use it to write each boot blob in the corresponding | 6 | --- |
7 | CPU address space. | 7 | docs/system/arm/kzm.rst | 18 ++++++++++++++++++ |
8 | docs/system/target-arm.rst | 1 + | ||
9 | MAINTAINERS | 1 + | ||
10 | 3 files changed, 20 insertions(+) | ||
11 | create mode 100644 docs/system/arm/kzm.rst | ||
8 | 12 | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | diff --git a/docs/system/arm/kzm.rst b/docs/system/arm/kzm.rst |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 14 | new file mode 100644 |
11 | Message-id: 20191019234715.25750-11-f4bug@amsat.org | 15 | index XXXXXXX..XXXXXXX |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | --- /dev/null |
13 | --- | 17 | +++ b/docs/system/arm/kzm.rst |
14 | hw/arm/raspi.c | 14 ++++++++------ | 18 | @@ -XXX,XX +XXX,XX @@ |
15 | 1 file changed, 8 insertions(+), 6 deletions(-) | 19 | +Kyoto Microcomputer KZM-ARM11-01 (``kzm``) |
16 | 20 | +========================================== | |
17 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 21 | + |
22 | +The ``kzm`` board emulates the Kyoto Microcomputer KZM-ARM11-01 | ||
23 | +evaluation board, which is based on an NXP i.MX32 SoC | ||
24 | +which uses an ARM1136 CPU. | ||
25 | + | ||
26 | +Emulated devices: | ||
27 | + | ||
28 | +- UARTs | ||
29 | +- LAN9118 ethernet | ||
30 | +- AVIC | ||
31 | +- CCM | ||
32 | +- GPT | ||
33 | +- EPIT timers | ||
34 | +- I2C | ||
35 | +- GPIO controllers | ||
36 | +- Watchdog timer | ||
37 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
18 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/raspi.c | 39 | --- a/docs/system/target-arm.rst |
20 | +++ b/hw/arm/raspi.c | 40 | +++ b/docs/system/target-arm.rst |
21 | @@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) | 41 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running |
22 | QEMU_BUILD_BUG_ON((BOARDSETUP_ADDR & 0xf) != 0 | 42 | arm/musicpal |
23 | || (BOARDSETUP_ADDR >> 4) >= 0x100); | 43 | arm/gumstix |
24 | 44 | arm/mainstone | |
25 | - rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot), | 45 | + arm/kzm |
26 | - info->smp_loader_start); | 46 | arm/nrf |
27 | + rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot), | 47 | arm/nseries |
28 | + info->smp_loader_start, | 48 | arm/nuvoton |
29 | + arm_boot_address_space(cpu, info)); | 49 | diff --git a/MAINTAINERS b/MAINTAINERS |
30 | } | 50 | index XXXXXXX..XXXXXXX 100644 |
31 | 51 | --- a/MAINTAINERS | |
32 | static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) | 52 | +++ b/MAINTAINERS |
33 | { | 53 | @@ -XXX,XX +XXX,XX @@ F: hw/*/imx_* |
34 | + AddressSpace *as = arm_boot_address_space(cpu, info); | 54 | F: hw/*/*imx31* |
35 | /* Unlike the AArch32 version we don't need to call the board setup hook. | 55 | F: include/hw/*/imx_* |
36 | * The mechanism for doing the spin-table is also entirely different. | 56 | F: include/hw/*/*imx31* |
37 | * We must have four 64-bit fields at absolute addresses | 57 | +F: docs/system/arm/kzm.rst |
38 | @@ -XXX,XX +XXX,XX @@ static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) | 58 | |
39 | 0, 0, 0, 0 | 59 | Integrator CP |
40 | }; | 60 | M: Peter Maydell <peter.maydell@linaro.org> |
41 | |||
42 | - rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot), | ||
43 | - info->smp_loader_start); | ||
44 | - rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables), | ||
45 | - SPINTABLE_ADDR); | ||
46 | + rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot), | ||
47 | + info->smp_loader_start, as); | ||
48 | + rom_add_blob_fixed_as("raspi_spintables", spintables, sizeof(spintables), | ||
49 | + SPINTABLE_ADDR, as); | ||
50 | } | ||
51 | |||
52 | static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info) | ||
53 | -- | 61 | -- |
54 | 2.20.1 | 62 | 2.20.1 |
55 | 63 | ||
56 | 64 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Add brief documentation of the Arm 'imx25-pdk' board. |
---|---|---|---|
2 | 2 | ||
3 | Add the 64-bit free running timer. Do not model the COMPARE register | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | (no IRQ generated). | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | This timer is used by Linux kernel and recently U-Boot: | 5 | Message-id: 20210722175229.29065-4-peter.maydell@linaro.org |
6 | https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/bcm2835_timer.c?h=v3.7 | 6 | --- |
7 | https://github.com/u-boot/u-boot/blob/v2019.07/include/configs/rpi.h#L19 | 7 | docs/system/arm/imx25-pdk.rst | 19 +++++++++++++++++++ |
8 | docs/system/target-arm.rst | 1 + | ||
9 | MAINTAINERS | 1 + | ||
10 | 3 files changed, 21 insertions(+) | ||
11 | create mode 100644 docs/system/arm/imx25-pdk.rst | ||
8 | 12 | ||
9 | Datasheet used: | 13 | diff --git a/docs/system/arm/imx25-pdk.rst b/docs/system/arm/imx25-pdk.rst |
10 | https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf | ||
11 | |||
12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Message-id: 20191019234715.25750-4-f4bug@amsat.org | ||
15 | [PMM: squashed in switch to using memset in reset] | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/timer/Makefile.objs | 1 + | ||
19 | include/hw/timer/bcm2835_systmr.h | 33 ++++++ | ||
20 | hw/timer/bcm2835_systmr.c | 163 ++++++++++++++++++++++++++++++ | ||
21 | hw/timer/trace-events | 5 + | ||
22 | 4 files changed, 202 insertions(+) | ||
23 | create mode 100644 include/hw/timer/bcm2835_systmr.h | ||
24 | create mode 100644 hw/timer/bcm2835_systmr.c | ||
25 | |||
26 | diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/timer/Makefile.objs | ||
29 | +++ b/hw/timer/Makefile.objs | ||
30 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o | ||
31 | common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o | ||
32 | common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o | ||
33 | common-obj-$(CONFIG_MSF2) += mss-timer.o | ||
34 | +common-obj-$(CONFIG_RASPI) += bcm2835_systmr.o | ||
35 | diff --git a/include/hw/timer/bcm2835_systmr.h b/include/hw/timer/bcm2835_systmr.h | ||
36 | new file mode 100644 | 14 | new file mode 100644 |
37 | index XXXXXXX..XXXXXXX | 15 | index XXXXXXX..XXXXXXX |
38 | --- /dev/null | 16 | --- /dev/null |
39 | +++ b/include/hw/timer/bcm2835_systmr.h | 17 | +++ b/docs/system/arm/imx25-pdk.rst |
40 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ |
41 | +/* | 19 | +NXP i.MX25 PDK board (``imx25-pdk``) |
42 | + * BCM2835 SYS timer emulation | 20 | +==================================== |
43 | + * | ||
44 | + * Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
45 | + * | ||
46 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
47 | + */ | ||
48 | + | 21 | + |
49 | +#ifndef BCM2835_SYSTIMER_H | 22 | +The ``imx25-pdk`` board emulates the NXP i.MX25 Product Development Kit |
50 | +#define BCM2835_SYSTIMER_H | 23 | +board, which is based on an i.MX25 SoC which uses an ARM926 CPU. |
51 | + | 24 | + |
52 | +#include "hw/sysbus.h" | 25 | +Emulated devices: |
53 | +#include "hw/irq.h" | ||
54 | + | 26 | + |
55 | +#define TYPE_BCM2835_SYSTIMER "bcm2835-sys-timer" | 27 | +- SD controller |
56 | +#define BCM2835_SYSTIMER(obj) \ | 28 | +- AVIC |
57 | + OBJECT_CHECK(BCM2835SystemTimerState, (obj), TYPE_BCM2835_SYSTIMER) | 29 | +- CCM |
58 | + | 30 | +- GPT |
59 | +typedef struct { | 31 | +- EPIT timers |
60 | + /*< private >*/ | 32 | +- FEC |
61 | + SysBusDevice parent_obj; | 33 | +- RNGC |
62 | + | 34 | +- I2C |
63 | + /*< public >*/ | 35 | +- GPIO controllers |
64 | + MemoryRegion iomem; | 36 | +- Watchdog timer |
65 | + qemu_irq irq; | 37 | +- USB controllers |
66 | + | 38 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst |
67 | + struct { | ||
68 | + uint32_t status; | ||
69 | + uint32_t compare[4]; | ||
70 | + } reg; | ||
71 | +} BCM2835SystemTimerState; | ||
72 | + | ||
73 | +#endif | ||
74 | diff --git a/hw/timer/bcm2835_systmr.c b/hw/timer/bcm2835_systmr.c | ||
75 | new file mode 100644 | ||
76 | index XXXXXXX..XXXXXXX | ||
77 | --- /dev/null | ||
78 | +++ b/hw/timer/bcm2835_systmr.c | ||
79 | @@ -XXX,XX +XXX,XX @@ | ||
80 | +/* | ||
81 | + * BCM2835 SYS timer emulation | ||
82 | + * | ||
83 | + * Copyright (C) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
84 | + * | ||
85 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
86 | + * | ||
87 | + * Datasheet: BCM2835 ARM Peripherals (C6357-M-1398) | ||
88 | + * https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf | ||
89 | + * | ||
90 | + * Only the free running 64-bit counter is implemented. | ||
91 | + * The 4 COMPARE registers and the interruption are not implemented. | ||
92 | + */ | ||
93 | + | ||
94 | +#include "qemu/osdep.h" | ||
95 | +#include "qemu/log.h" | ||
96 | +#include "qemu/timer.h" | ||
97 | +#include "hw/timer/bcm2835_systmr.h" | ||
98 | +#include "hw/registerfields.h" | ||
99 | +#include "migration/vmstate.h" | ||
100 | +#include "trace.h" | ||
101 | + | ||
102 | +REG32(CTRL_STATUS, 0x00) | ||
103 | +REG32(COUNTER_LOW, 0x04) | ||
104 | +REG32(COUNTER_HIGH, 0x08) | ||
105 | +REG32(COMPARE0, 0x0c) | ||
106 | +REG32(COMPARE1, 0x10) | ||
107 | +REG32(COMPARE2, 0x14) | ||
108 | +REG32(COMPARE3, 0x18) | ||
109 | + | ||
110 | +static void bcm2835_systmr_update_irq(BCM2835SystemTimerState *s) | ||
111 | +{ | ||
112 | + bool enable = !!s->reg.status; | ||
113 | + | ||
114 | + trace_bcm2835_systmr_irq(enable); | ||
115 | + qemu_set_irq(s->irq, enable); | ||
116 | +} | ||
117 | + | ||
118 | +static void bcm2835_systmr_update_compare(BCM2835SystemTimerState *s, | ||
119 | + unsigned timer_index) | ||
120 | +{ | ||
121 | + /* TODO fow now, since neither Linux nor U-boot use these timers. */ | ||
122 | + qemu_log_mask(LOG_UNIMP, "COMPARE register %u not implemented\n", | ||
123 | + timer_index); | ||
124 | +} | ||
125 | + | ||
126 | +static uint64_t bcm2835_systmr_read(void *opaque, hwaddr offset, | ||
127 | + unsigned size) | ||
128 | +{ | ||
129 | + BCM2835SystemTimerState *s = BCM2835_SYSTIMER(opaque); | ||
130 | + uint64_t r = 0; | ||
131 | + | ||
132 | + switch (offset) { | ||
133 | + case A_CTRL_STATUS: | ||
134 | + r = s->reg.status; | ||
135 | + break; | ||
136 | + case A_COMPARE0 ... A_COMPARE3: | ||
137 | + r = s->reg.compare[(offset - A_COMPARE0) >> 2]; | ||
138 | + break; | ||
139 | + case A_COUNTER_LOW: | ||
140 | + case A_COUNTER_HIGH: | ||
141 | + /* Free running counter at 1MHz */ | ||
142 | + r = qemu_clock_get_us(QEMU_CLOCK_VIRTUAL); | ||
143 | + r >>= 8 * (offset - A_COUNTER_LOW); | ||
144 | + r &= UINT32_MAX; | ||
145 | + break; | ||
146 | + default: | ||
147 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad offset 0x%" HWADDR_PRIx "\n", | ||
148 | + __func__, offset); | ||
149 | + break; | ||
150 | + } | ||
151 | + trace_bcm2835_systmr_read(offset, r); | ||
152 | + | ||
153 | + return r; | ||
154 | +} | ||
155 | + | ||
156 | +static void bcm2835_systmr_write(void *opaque, hwaddr offset, | ||
157 | + uint64_t value, unsigned size) | ||
158 | +{ | ||
159 | + BCM2835SystemTimerState *s = BCM2835_SYSTIMER(opaque); | ||
160 | + | ||
161 | + trace_bcm2835_systmr_write(offset, value); | ||
162 | + switch (offset) { | ||
163 | + case A_CTRL_STATUS: | ||
164 | + s->reg.status &= ~value; /* Ack */ | ||
165 | + bcm2835_systmr_update_irq(s); | ||
166 | + break; | ||
167 | + case A_COMPARE0 ... A_COMPARE3: | ||
168 | + s->reg.compare[(offset - A_COMPARE0) >> 2] = value; | ||
169 | + bcm2835_systmr_update_compare(s, (offset - A_COMPARE0) >> 2); | ||
170 | + break; | ||
171 | + case A_COUNTER_LOW: | ||
172 | + case A_COUNTER_HIGH: | ||
173 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: read-only ofs 0x%" HWADDR_PRIx "\n", | ||
174 | + __func__, offset); | ||
175 | + break; | ||
176 | + default: | ||
177 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad offset 0x%" HWADDR_PRIx "\n", | ||
178 | + __func__, offset); | ||
179 | + break; | ||
180 | + } | ||
181 | +} | ||
182 | + | ||
183 | +static const MemoryRegionOps bcm2835_systmr_ops = { | ||
184 | + .read = bcm2835_systmr_read, | ||
185 | + .write = bcm2835_systmr_write, | ||
186 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
187 | + .impl = { | ||
188 | + .min_access_size = 4, | ||
189 | + .max_access_size = 4, | ||
190 | + }, | ||
191 | +}; | ||
192 | + | ||
193 | +static void bcm2835_systmr_reset(DeviceState *dev) | ||
194 | +{ | ||
195 | + BCM2835SystemTimerState *s = BCM2835_SYSTIMER(dev); | ||
196 | + | ||
197 | + memset(&s->reg, 0, sizeof(s->reg)); | ||
198 | +} | ||
199 | + | ||
200 | +static void bcm2835_systmr_realize(DeviceState *dev, Error **errp) | ||
201 | +{ | ||
202 | + BCM2835SystemTimerState *s = BCM2835_SYSTIMER(dev); | ||
203 | + | ||
204 | + memory_region_init_io(&s->iomem, OBJECT(dev), &bcm2835_systmr_ops, | ||
205 | + s, "bcm2835-sys-timer", 0x20); | ||
206 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
207 | + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); | ||
208 | +} | ||
209 | + | ||
210 | +static const VMStateDescription bcm2835_systmr_vmstate = { | ||
211 | + .name = "bcm2835_sys_timer", | ||
212 | + .version_id = 1, | ||
213 | + .minimum_version_id = 1, | ||
214 | + .fields = (VMStateField[]) { | ||
215 | + VMSTATE_UINT32(reg.status, BCM2835SystemTimerState), | ||
216 | + VMSTATE_UINT32_ARRAY(reg.compare, BCM2835SystemTimerState, 4), | ||
217 | + VMSTATE_END_OF_LIST() | ||
218 | + } | ||
219 | +}; | ||
220 | + | ||
221 | +static void bcm2835_systmr_class_init(ObjectClass *klass, void *data) | ||
222 | +{ | ||
223 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
224 | + | ||
225 | + dc->realize = bcm2835_systmr_realize; | ||
226 | + dc->reset = bcm2835_systmr_reset; | ||
227 | + dc->vmsd = &bcm2835_systmr_vmstate; | ||
228 | +} | ||
229 | + | ||
230 | +static const TypeInfo bcm2835_systmr_info = { | ||
231 | + .name = TYPE_BCM2835_SYSTIMER, | ||
232 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
233 | + .instance_size = sizeof(BCM2835SystemTimerState), | ||
234 | + .class_init = bcm2835_systmr_class_init, | ||
235 | +}; | ||
236 | + | ||
237 | +static void bcm2835_systmr_register_types(void) | ||
238 | +{ | ||
239 | + type_register_static(&bcm2835_systmr_info); | ||
240 | +} | ||
241 | + | ||
242 | +type_init(bcm2835_systmr_register_types); | ||
243 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events | ||
244 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
245 | --- a/hw/timer/trace-events | 40 | --- a/docs/system/target-arm.rst |
246 | +++ b/hw/timer/trace-events | 41 | +++ b/docs/system/target-arm.rst |
247 | @@ -XXX,XX +XXX,XX @@ pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | 42 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running |
248 | pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | 43 | arm/nrf |
249 | pl031_alarm_raised(void) "alarm raised" | 44 | arm/nseries |
250 | pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks" | 45 | arm/nuvoton |
251 | + | 46 | + arm/imx25-pdk |
252 | +# bcm2835_systmr.c | 47 | arm/orangepi |
253 | +bcm2835_systmr_irq(bool enable) "timer irq state %u" | 48 | arm/palm |
254 | +bcm2835_systmr_read(uint64_t offset, uint64_t data) "timer read: offset 0x%" PRIx64 " data 0x%" PRIx64 | 49 | arm/raspi |
255 | +bcm2835_systmr_write(uint64_t offset, uint64_t data) "timer write: offset 0x%" PRIx64 " data 0x%" PRIx64 | 50 | diff --git a/MAINTAINERS b/MAINTAINERS |
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/MAINTAINERS | ||
53 | +++ b/MAINTAINERS | ||
54 | @@ -XXX,XX +XXX,XX @@ F: hw/watchdog/wdt_imx2.c | ||
55 | F: include/hw/arm/fsl-imx25.h | ||
56 | F: include/hw/misc/imx25_ccm.h | ||
57 | F: include/hw/watchdog/wdt_imx2.h | ||
58 | +F: docs/system/arm/imx25-pdk.rst | ||
59 | |||
60 | i.MX31 (kzm) | ||
61 | M: Peter Maydell <peter.maydell@linaro.org> | ||
256 | -- | 62 | -- |
257 | 2.20.1 | 63 | 2.20.1 |
258 | 64 | ||
259 | 65 | diff view generated by jsdifflib |
1 | Switch the milkymist-sysctl code away from bottom-half based | 1 | Andrzej Zaborowski is listed as an "Odd Fixes" maintainer for the |
---|---|---|---|
2 | ptimers to the new transaction-based ptimer API. This just requires | 2 | nSeries, Palm and PXA2XX boards, as well as the "Maintained" status |
3 | adding begin/commit calls around the various places that modify the | 3 | Arm 32-bit TCG backend. |
4 | ptimer state, and using the new ptimer_init() function to create the | 4 | |
5 | timer. | 5 | Andrzej's last email to qemu-devel was back in 2017, and the email |
6 | before that was all the way back in 2013. We don't really need to | ||
7 | fill his email up with CCs on QEMU patches any more... | ||
8 | |||
9 | Remove Andrzej from the various boards sections (leaving them still | ||
10 | Odd Fixes with me as the backup patch reviewer). Add Richard | ||
11 | Henderson as the maintainer for the Arm TCG backend, since removing | ||
12 | Andrzej would otherwise leave that section with no M: line at all. | ||
6 | 13 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20191021141040.11007-1-peter.maydell@linaro.org | 16 | Message-id: 20210722180951.29802-1-peter.maydell@linaro.org |
10 | --- | 17 | --- |
11 | hw/timer/milkymist-sysctl.c | 25 ++++++++++++++++++------- | 18 | MAINTAINERS | 5 +---- |
12 | 1 file changed, 18 insertions(+), 7 deletions(-) | 19 | 1 file changed, 1 insertion(+), 4 deletions(-) |
13 | 20 | ||
14 | diff --git a/hw/timer/milkymist-sysctl.c b/hw/timer/milkymist-sysctl.c | 21 | diff --git a/MAINTAINERS b/MAINTAINERS |
15 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/timer/milkymist-sysctl.c | 23 | --- a/MAINTAINERS |
17 | +++ b/hw/timer/milkymist-sysctl.c | 24 | +++ b/MAINTAINERS |
18 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ F: roms/vbootrom |
19 | #include "hw/ptimer.h" | 26 | F: docs/system/arm/nuvoton.rst |
20 | #include "hw/qdev-properties.h" | 27 | |
21 | #include "qemu/error-report.h" | 28 | nSeries |
22 | -#include "qemu/main-loop.h" | 29 | -M: Andrzej Zaborowski <balrogg@gmail.com> |
23 | #include "qemu/module.h" | 30 | M: Peter Maydell <peter.maydell@linaro.org> |
24 | 31 | L: qemu-arm@nongnu.org | |
25 | enum { | 32 | S: Odd Fixes |
26 | @@ -XXX,XX +XXX,XX @@ struct MilkymistSysctlState { | 33 | @@ -XXX,XX +XXX,XX @@ F: tests/acceptance/machine_arm_n8x0.py |
27 | 34 | F: docs/system/arm/nseries.rst | |
28 | MemoryRegion regs_region; | 35 | |
29 | 36 | Palm | |
30 | - QEMUBH *bh0; | 37 | -M: Andrzej Zaborowski <balrogg@gmail.com> |
31 | - QEMUBH *bh1; | 38 | M: Peter Maydell <peter.maydell@linaro.org> |
32 | ptimer_state *ptimer0; | 39 | L: qemu-arm@nongnu.org |
33 | ptimer_state *ptimer1; | 40 | S: Odd Fixes |
34 | 41 | @@ -XXX,XX +XXX,XX @@ F: include/hw/intc/realview_gic.h | |
35 | @@ -XXX,XX +XXX,XX @@ static void sysctl_write(void *opaque, hwaddr addr, uint64_t value, | 42 | F: docs/system/arm/realview.rst |
36 | s->regs[addr] = value; | 43 | |
37 | break; | 44 | PXA2XX |
38 | case R_TIMER0_COMPARE: | 45 | -M: Andrzej Zaborowski <balrogg@gmail.com> |
39 | + ptimer_transaction_begin(s->ptimer0); | 46 | M: Peter Maydell <peter.maydell@linaro.org> |
40 | ptimer_set_limit(s->ptimer0, value, 0); | 47 | L: qemu-arm@nongnu.org |
41 | s->regs[addr] = value; | 48 | S: Odd Fixes |
42 | + ptimer_transaction_commit(s->ptimer0); | 49 | @@ -XXX,XX +XXX,XX @@ F: disas/arm-a64.cc |
43 | break; | 50 | F: disas/libvixl/ |
44 | case R_TIMER1_COMPARE: | 51 | |
45 | + ptimer_transaction_begin(s->ptimer1); | 52 | ARM TCG target |
46 | ptimer_set_limit(s->ptimer1, value, 0); | 53 | -M: Andrzej Zaborowski <balrogg@gmail.com> |
47 | s->regs[addr] = value; | 54 | +M: Richard Henderson <richard.henderson@linaro.org> |
48 | + ptimer_transaction_commit(s->ptimer1); | 55 | S: Maintained |
49 | break; | 56 | L: qemu-arm@nongnu.org |
50 | case R_TIMER0_CONTROL: | 57 | F: tcg/arm/ |
51 | + ptimer_transaction_begin(s->ptimer0); | ||
52 | s->regs[addr] = value; | ||
53 | if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) { | ||
54 | trace_milkymist_sysctl_start_timer0(); | ||
55 | @@ -XXX,XX +XXX,XX @@ static void sysctl_write(void *opaque, hwaddr addr, uint64_t value, | ||
56 | trace_milkymist_sysctl_stop_timer0(); | ||
57 | ptimer_stop(s->ptimer0); | ||
58 | } | ||
59 | + ptimer_transaction_commit(s->ptimer0); | ||
60 | break; | ||
61 | case R_TIMER1_CONTROL: | ||
62 | + ptimer_transaction_begin(s->ptimer1); | ||
63 | s->regs[addr] = value; | ||
64 | if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) { | ||
65 | trace_milkymist_sysctl_start_timer1(); | ||
66 | @@ -XXX,XX +XXX,XX @@ static void sysctl_write(void *opaque, hwaddr addr, uint64_t value, | ||
67 | trace_milkymist_sysctl_stop_timer1(); | ||
68 | ptimer_stop(s->ptimer1); | ||
69 | } | ||
70 | + ptimer_transaction_commit(s->ptimer1); | ||
71 | break; | ||
72 | case R_ICAP: | ||
73 | sysctl_icap_write(s, value); | ||
74 | @@ -XXX,XX +XXX,XX @@ static void milkymist_sysctl_reset(DeviceState *d) | ||
75 | s->regs[i] = 0; | ||
76 | } | ||
77 | |||
78 | + ptimer_transaction_begin(s->ptimer0); | ||
79 | ptimer_stop(s->ptimer0); | ||
80 | + ptimer_transaction_commit(s->ptimer0); | ||
81 | + ptimer_transaction_begin(s->ptimer1); | ||
82 | ptimer_stop(s->ptimer1); | ||
83 | + ptimer_transaction_commit(s->ptimer1); | ||
84 | |||
85 | /* defaults */ | ||
86 | s->regs[R_ICAP] = ICAP_READY; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void milkymist_sysctl_realize(DeviceState *dev, Error **errp) | ||
88 | { | ||
89 | MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev); | ||
90 | |||
91 | - s->bh0 = qemu_bh_new(timer0_hit, s); | ||
92 | - s->bh1 = qemu_bh_new(timer1_hit, s); | ||
93 | - s->ptimer0 = ptimer_init_with_bh(s->bh0, PTIMER_POLICY_DEFAULT); | ||
94 | - s->ptimer1 = ptimer_init_with_bh(s->bh1, PTIMER_POLICY_DEFAULT); | ||
95 | + s->ptimer0 = ptimer_init(timer0_hit, s, PTIMER_POLICY_DEFAULT); | ||
96 | + s->ptimer1 = ptimer_init(timer1_hit, s, PTIMER_POLICY_DEFAULT); | ||
97 | |||
98 | + ptimer_transaction_begin(s->ptimer0); | ||
99 | ptimer_set_freq(s->ptimer0, s->freq_hz); | ||
100 | + ptimer_transaction_commit(s->ptimer0); | ||
101 | + ptimer_transaction_begin(s->ptimer1); | ||
102 | ptimer_set_freq(s->ptimer1, s->freq_hz); | ||
103 | + ptimer_transaction_commit(s->ptimer1); | ||
104 | } | ||
105 | |||
106 | static const VMStateDescription vmstate_milkymist_sysctl = { | ||
107 | -- | 58 | -- |
108 | 2.20.1 | 59 | 2.20.1 |
109 | 60 | ||
110 | 61 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Since commits 13f934e79fa and 3a50c8f3067aaf, our HTML docs include a |
---|---|---|---|
2 | footer to all pages stating the license and version. We can | ||
3 | therefore delete the TODO comments suggesting we should do that from | ||
4 | our .rst files. | ||
2 | 5 | ||
3 | Allow cpu 'host' to enable SVE when it's available, unless the | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | user chooses to disable it with the added 'sve=off' cpu property. | 7 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> |
5 | Also give the user the ability to select vector lengths with the | 8 | Reviewed-by: Cleber Rosa <crosa@redhat.com> |
6 | sve<N> properties. We don't adopt 'max' cpu's other sve property, | 9 | Reviewed-by: Markus Armbruster <armbru@redhat.com> |
7 | sve-max-vq, because that property is difficult to use with KVM. | 10 | Message-id: 20210722192016.24915-2-peter.maydell@linaro.org |
8 | That property assumes all vector lengths in the range from 1 up | 11 | --- |
9 | to and including the specified maximum length are supported, but | 12 | docs/interop/qemu-ga-ref.rst | 9 --------- |
10 | there may be optional lengths not supported by the host in that | 13 | docs/interop/qemu-qmp-ref.rst | 9 --------- |
11 | range. With KVM one must be more specific when enabling vector | 14 | docs/interop/qemu-storage-daemon-qmp-ref.rst | 9 --------- |
12 | lengths. | 15 | 3 files changed, 27 deletions(-) |
13 | 16 | ||
14 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 17 | diff --git a/docs/interop/qemu-ga-ref.rst b/docs/interop/qemu-ga-ref.rst |
15 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | ||
18 | Message-id: 20191024121808.9612-10-drjones@redhat.com | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | target/arm/cpu.h | 2 ++ | ||
22 | target/arm/cpu.c | 3 +++ | ||
23 | target/arm/cpu64.c | 33 +++++++++++++++++---------------- | ||
24 | target/arm/kvm64.c | 14 +++++++++++++- | ||
25 | tests/arm-cpu-features.c | 23 +++++++++++------------ | ||
26 | docs/arm-cpu-features.rst | 19 ++++++++++++------- | ||
27 | 6 files changed, 58 insertions(+), 36 deletions(-) | ||
28 | |||
29 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/cpu.h | 19 | --- a/docs/interop/qemu-ga-ref.rst |
32 | +++ b/target/arm/cpu.h | 20 | +++ b/docs/interop/qemu-ga-ref.rst |
33 | @@ -XXX,XX +XXX,XX @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | 21 | @@ -XXX,XX +XXX,XX @@ |
34 | void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); | 22 | QEMU Guest Agent Protocol Reference |
35 | void aarch64_sve_change_el(CPUARMState *env, int old_el, | 23 | =================================== |
36 | int new_el, bool el0_a64); | 24 | |
37 | +void aarch64_add_sve_properties(Object *obj); | 25 | -.. |
38 | #else | 26 | - TODO: the old Texinfo manual used to note that this manual |
39 | static inline void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) { } | 27 | - is GPL-v2-or-later. We should make that reader-visible |
40 | static inline void aarch64_sve_change_el(CPUARMState *env, int o, | 28 | - both here and in our Sphinx manuals more generally. |
41 | int n, bool a) | 29 | - |
42 | { } | 30 | -.. |
43 | +static inline void aarch64_add_sve_properties(Object *obj) { } | 31 | - TODO: display the QEMU version, both here and in our Sphinx manuals |
44 | #endif | 32 | - more generally. |
45 | 33 | - | |
46 | #if !defined(CONFIG_TCG) | 34 | .. contents:: |
47 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 35 | :depth: 3 |
36 | |||
37 | diff --git a/docs/interop/qemu-qmp-ref.rst b/docs/interop/qemu-qmp-ref.rst | ||
48 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/target/arm/cpu.c | 39 | --- a/docs/interop/qemu-qmp-ref.rst |
50 | +++ b/target/arm/cpu.c | 40 | +++ b/docs/interop/qemu-qmp-ref.rst |
51 | @@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj) | 41 | @@ -XXX,XX +XXX,XX @@ |
52 | ARMCPU *cpu = ARM_CPU(obj); | 42 | QEMU QMP Reference Manual |
53 | 43 | ========================= | |
54 | kvm_arm_set_cpu_features_from_host(cpu); | 44 | |
55 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | 45 | -.. |
56 | + aarch64_add_sve_properties(obj); | 46 | - TODO: the old Texinfo manual used to note that this manual |
57 | + } | 47 | - is GPL-v2-or-later. We should make that reader-visible |
58 | arm_cpu_post_init(obj); | 48 | - both here and in our Sphinx manuals more generally. |
59 | } | 49 | - |
60 | 50 | -.. | |
61 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 51 | - TODO: display the QEMU version, both here and in our Sphinx manuals |
52 | - more generally. | ||
53 | - | ||
54 | .. contents:: | ||
55 | :depth: 3 | ||
56 | |||
57 | diff --git a/docs/interop/qemu-storage-daemon-qmp-ref.rst b/docs/interop/qemu-storage-daemon-qmp-ref.rst | ||
62 | index XXXXXXX..XXXXXXX 100644 | 58 | index XXXXXXX..XXXXXXX 100644 |
63 | --- a/target/arm/cpu64.c | 59 | --- a/docs/interop/qemu-storage-daemon-qmp-ref.rst |
64 | +++ b/target/arm/cpu64.c | 60 | +++ b/docs/interop/qemu-storage-daemon-qmp-ref.rst |
65 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, | 61 | @@ -XXX,XX +XXX,XX @@ |
66 | cpu->isar.id_aa64pfr0 = t; | 62 | QEMU Storage Daemon QMP Reference Manual |
67 | } | 63 | ======================================== |
68 | 64 | ||
69 | +void aarch64_add_sve_properties(Object *obj) | 65 | -.. |
70 | +{ | 66 | - TODO: the old Texinfo manual used to note that this manual |
71 | + uint32_t vq; | 67 | - is GPL-v2-or-later. We should make that reader-visible |
72 | + | 68 | - both here and in our Sphinx manuals more generally. |
73 | + object_property_add(obj, "sve", "bool", cpu_arm_get_sve, | ||
74 | + cpu_arm_set_sve, NULL, NULL, &error_fatal); | ||
75 | + | ||
76 | + for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
77 | + char name[8]; | ||
78 | + sprintf(name, "sve%d", vq * 128); | ||
79 | + object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
80 | + cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); | ||
81 | + } | ||
82 | +} | ||
83 | + | ||
84 | /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); | ||
85 | * otherwise, a CPU with as many features enabled as our emulation supports. | ||
86 | * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, | ||
88 | static void aarch64_max_initfn(Object *obj) | ||
89 | { | ||
90 | ARMCPU *cpu = ARM_CPU(obj); | ||
91 | - uint32_t vq; | ||
92 | - uint64_t t; | ||
93 | |||
94 | if (kvm_enabled()) { | ||
95 | kvm_arm_set_cpu_features_from_host(cpu); | ||
96 | - if (kvm_arm_sve_supported(CPU(cpu))) { | ||
97 | - t = cpu->isar.id_aa64pfr0; | ||
98 | - t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
99 | - cpu->isar.id_aa64pfr0 = t; | ||
100 | - } | ||
101 | } else { | ||
102 | + uint64_t t; | ||
103 | uint32_t u; | ||
104 | aarch64_a57_initfn(obj); | ||
105 | |||
106 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
107 | #endif | ||
108 | } | ||
109 | |||
110 | - object_property_add(obj, "sve", "bool", cpu_arm_get_sve, | ||
111 | - cpu_arm_set_sve, NULL, NULL, &error_fatal); | ||
112 | + aarch64_add_sve_properties(obj); | ||
113 | object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | ||
114 | cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); | ||
115 | - | 69 | - |
116 | - for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | 70 | -.. |
117 | - char name[8]; | 71 | - TODO: display the QEMU version, both here and in our Sphinx manuals |
118 | - sprintf(name, "sve%d", vq * 128); | 72 | - more generally. |
119 | - object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
120 | - cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); | ||
121 | - } | ||
122 | } | ||
123 | |||
124 | struct ARMCPUInfo { | ||
125 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/target/arm/kvm64.c | ||
128 | +++ b/target/arm/kvm64.c | ||
129 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
130 | * and then query that CPU for the relevant ID registers. | ||
131 | */ | ||
132 | int fdarray[3]; | ||
133 | + bool sve_supported; | ||
134 | uint64_t features = 0; | ||
135 | + uint64_t t; | ||
136 | int err; | ||
137 | |||
138 | /* Old kernels may not know about the PREFERRED_TARGET ioctl: however | ||
139 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
140 | ARM64_SYS_REG(3, 0, 0, 3, 2)); | ||
141 | } | ||
142 | |||
143 | + sve_supported = ioctl(fdarray[0], KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE) > 0; | ||
144 | + | ||
145 | kvm_arm_destroy_scratch_host_vcpu(fdarray); | ||
146 | |||
147 | if (err < 0) { | ||
148 | return false; | ||
149 | } | ||
150 | |||
151 | - /* We can assume any KVM supporting CPU is at least a v8 | ||
152 | + /* Add feature bits that can't appear until after VCPU init. */ | ||
153 | + if (sve_supported) { | ||
154 | + t = ahcf->isar.id_aa64pfr0; | ||
155 | + t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
156 | + ahcf->isar.id_aa64pfr0 = t; | ||
157 | + } | ||
158 | + | ||
159 | + /* | ||
160 | + * We can assume any KVM supporting CPU is at least a v8 | ||
161 | * with VFPv4+Neon; this in turn implies most of the other | ||
162 | * feature bits. | ||
163 | */ | ||
164 | diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c | ||
165 | index XXXXXXX..XXXXXXX 100644 | ||
166 | --- a/tests/arm-cpu-features.c | ||
167 | +++ b/tests/arm-cpu-features.c | ||
168 | @@ -XXX,XX +XXX,XX @@ static void sve_tests_sve_off_kvm(const void *data) | ||
169 | { | ||
170 | QTestState *qts; | ||
171 | |||
172 | - qts = qtest_init(MACHINE "-accel kvm -cpu max,sve=off"); | ||
173 | + qts = qtest_init(MACHINE "-accel kvm -cpu host,sve=off"); | ||
174 | |||
175 | /* | ||
176 | * We don't know if this host supports SVE so we don't | ||
177 | @@ -XXX,XX +XXX,XX @@ static void sve_tests_sve_off_kvm(const void *data) | ||
178 | * and that using sve<N>=off to explicitly disable vector | ||
179 | * lengths is OK too. | ||
180 | */ | ||
181 | - assert_sve_vls(qts, "max", 0, NULL); | ||
182 | - assert_sve_vls(qts, "max", 0, "{ 'sve128': false }"); | ||
183 | + assert_sve_vls(qts, "host", 0, NULL); | ||
184 | + assert_sve_vls(qts, "host", 0, "{ 'sve128': false }"); | ||
185 | |||
186 | qtest_quit(qts); | ||
187 | } | ||
188 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
189 | "We cannot guarantee the CPU type 'cortex-a15' works " | ||
190 | "with KVM on this host", NULL); | ||
191 | |||
192 | - assert_has_feature(qts, "max", "sve"); | ||
193 | - resp = do_query_no_props(qts, "max"); | ||
194 | + assert_has_feature(qts, "host", "sve"); | ||
195 | + resp = do_query_no_props(qts, "host"); | ||
196 | kvm_supports_sve = resp_get_feature(resp, "sve"); | ||
197 | vls = resp_get_sve_vls(resp); | ||
198 | qobject_unref(resp); | ||
199 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
200 | sprintf(max_name, "sve%d", max_vq * 128); | ||
201 | |||
202 | /* Enabling a supported length is of course fine. */ | ||
203 | - assert_sve_vls(qts, "max", vls, "{ %s: true }", max_name); | ||
204 | + assert_sve_vls(qts, "host", vls, "{ %s: true }", max_name); | ||
205 | |||
206 | /* Get the next supported length smaller than max-vq. */ | ||
207 | vq = 64 - __builtin_clzll(vls & ~BIT_ULL(max_vq - 1)); | ||
208 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
209 | * We have at least one length smaller than max-vq, | ||
210 | * so we can disable max-vq. | ||
211 | */ | ||
212 | - assert_sve_vls(qts, "max", (vls & ~BIT_ULL(max_vq - 1)), | ||
213 | + assert_sve_vls(qts, "host", (vls & ~BIT_ULL(max_vq - 1)), | ||
214 | "{ %s: false }", max_name); | ||
215 | |||
216 | /* | ||
217 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
218 | */ | ||
219 | sprintf(name, "sve%d", vq * 128); | ||
220 | error = g_strdup_printf("cannot disable %s", name); | ||
221 | - assert_error(qts, "max", error, | ||
222 | + assert_error(qts, "host", error, | ||
223 | "{ %s: true, %s: false }", | ||
224 | max_name, name); | ||
225 | g_free(error); | ||
226 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
227 | vq = __builtin_ffsll(vls); | ||
228 | sprintf(name, "sve%d", vq * 128); | ||
229 | error = g_strdup_printf("cannot disable %s", name); | ||
230 | - assert_error(qts, "max", error, "{ %s: false }", name); | ||
231 | + assert_error(qts, "host", error, "{ %s: false }", name); | ||
232 | g_free(error); | ||
233 | |||
234 | /* Get an unsupported length. */ | ||
235 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
236 | if (vq <= SVE_MAX_VQ) { | ||
237 | sprintf(name, "sve%d", vq * 128); | ||
238 | error = g_strdup_printf("cannot enable %s", name); | ||
239 | - assert_error(qts, "max", error, "{ %s: true }", name); | ||
240 | + assert_error(qts, "host", error, "{ %s: true }", name); | ||
241 | g_free(error); | ||
242 | } | ||
243 | } else { | ||
244 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
245 | } else { | ||
246 | assert_has_not_feature(qts, "host", "aarch64"); | ||
247 | assert_has_not_feature(qts, "host", "pmu"); | ||
248 | - | 73 | - |
249 | - assert_has_not_feature(qts, "max", "sve"); | 74 | .. contents:: |
250 | + assert_has_not_feature(qts, "host", "sve"); | 75 | :depth: 3 |
251 | } | ||
252 | |||
253 | qtest_quit(qts); | ||
254 | diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst | ||
255 | index XXXXXXX..XXXXXXX 100644 | ||
256 | --- a/docs/arm-cpu-features.rst | ||
257 | +++ b/docs/arm-cpu-features.rst | ||
258 | @@ -XXX,XX +XXX,XX @@ SVE CPU Property Examples | ||
259 | |||
260 | $ qemu-system-aarch64 -M virt -cpu max | ||
261 | |||
262 | - 3) Only enable the 128-bit vector length:: | ||
263 | + 3) When KVM is enabled, implicitly enable all host CPU supported vector | ||
264 | + lengths with the `host` CPU type:: | ||
265 | + | ||
266 | + $ qemu-system-aarch64 -M virt,accel=kvm -cpu host | ||
267 | + | ||
268 | + 4) Only enable the 128-bit vector length:: | ||
269 | |||
270 | $ qemu-system-aarch64 -M virt -cpu max,sve128=on | ||
271 | |||
272 | - 4) Disable the 512-bit vector length and all larger vector lengths, | ||
273 | + 5) Disable the 512-bit vector length and all larger vector lengths, | ||
274 | since 512 is a power-of-two. This results in all the smaller, | ||
275 | uninitialized lengths (128, 256, and 384) defaulting to enabled:: | ||
276 | |||
277 | $ qemu-system-aarch64 -M virt -cpu max,sve512=off | ||
278 | |||
279 | - 5) Enable the 128-bit, 256-bit, and 512-bit vector lengths:: | ||
280 | + 6) Enable the 128-bit, 256-bit, and 512-bit vector lengths:: | ||
281 | |||
282 | $ qemu-system-aarch64 -M virt -cpu max,sve128=on,sve256=on,sve512=on | ||
283 | |||
284 | - 6) The same as (5), but since the 128-bit and 256-bit vector | ||
285 | + 7) The same as (6), but since the 128-bit and 256-bit vector | ||
286 | lengths are required for the 512-bit vector length to be enabled, | ||
287 | then allow them to be auto-enabled:: | ||
288 | |||
289 | $ qemu-system-aarch64 -M virt -cpu max,sve512=on | ||
290 | |||
291 | - 7) Do the same as (6), but by first disabling SVE and then re-enabling it:: | ||
292 | + 8) Do the same as (7), but by first disabling SVE and then re-enabling it:: | ||
293 | |||
294 | $ qemu-system-aarch64 -M virt -cpu max,sve=off,sve512=on,sve=on | ||
295 | |||
296 | - 8) Force errors regarding the last vector length:: | ||
297 | + 9) Force errors regarding the last vector length:: | ||
298 | |||
299 | $ qemu-system-aarch64 -M virt -cpu max,sve128=off | ||
300 | $ qemu-system-aarch64 -M virt -cpu max,sve=off,sve128=off,sve=on | ||
301 | @@ -XXX,XX +XXX,XX @@ The examples in "SVE CPU Property Examples" exhibit many ways to select | ||
302 | vector lengths which developers may find useful in order to avoid overly | ||
303 | verbose command lines. However, the recommended way to select vector | ||
304 | lengths is to explicitly enable each desired length. Therefore only | ||
305 | -example's (1), (3), and (5) exhibit recommended uses of the properties. | ||
306 | +example's (1), (4), and (6) exhibit recommended uses of the properties. | ||
307 | 76 | ||
308 | -- | 77 | -- |
309 | 2.20.1 | 78 | 2.20.1 |
310 | 79 | ||
311 | 80 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Our built HTML documentation now has a standard footer which |
---|---|---|---|
2 | gives the license for QEMU (and its documentation as a whole). | ||
3 | In almost all pages, we either don't bother to state the | ||
4 | copyright/license for the individual rST sources, or we put | ||
5 | it in an rST comment. There are just three pages which render | ||
6 | copyright or license information into the user-visible HTML. | ||
2 | 7 | ||
3 | As we are going to add more core-specific fields, add a 'cpu' | 8 | Quoting a specific (different) license for an individual HTML |
4 | structure and move the ARMCPU field there as 'core'. | 9 | page within the manual is confusing. Downgrade the license |
10 | and copyright info to a comment within the rST source, bringing | ||
11 | these pages in line with the rest of our documents. | ||
5 | 12 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | Suggested-by: Markus Armbruster <armbru@redhat.com> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20191019234715.25750-7-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
16 | Reviewed-by: Cleber Rosa <crosa@redhat.com> | ||
17 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
18 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
19 | Message-id: 20210722192016.24915-3-peter.maydell@linaro.org | ||
10 | --- | 20 | --- |
11 | include/hw/arm/bcm2836.h | 4 +++- | 21 | docs/interop/vhost-user-gpu.rst | 7 ++++--- |
12 | hw/arm/bcm2836.c | 26 ++++++++++++++------------ | 22 | docs/interop/vhost-user.rst | 12 +++++++----- |
13 | 2 files changed, 17 insertions(+), 13 deletions(-) | 23 | docs/system/generic-loader.rst | 4 ++-- |
24 | 3 files changed, 13 insertions(+), 10 deletions(-) | ||
14 | 25 | ||
15 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 26 | diff --git a/docs/interop/vhost-user-gpu.rst b/docs/interop/vhost-user-gpu.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/bcm2836.h | 28 | --- a/docs/interop/vhost-user-gpu.rst |
18 | +++ b/include/hw/arm/bcm2836.h | 29 | +++ b/docs/interop/vhost-user-gpu.rst |
19 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM283XState { | 30 | @@ -XXX,XX +XXX,XX @@ |
20 | char *cpu_type; | 31 | Vhost-user-gpu Protocol |
21 | uint32_t enabled_cpus; | 32 | ======================= |
22 | 33 | ||
23 | - ARMCPU cpus[BCM283X_NCPUS]; | 34 | -:Licence: This work is licensed under the terms of the GNU GPL, |
24 | + struct { | 35 | - version 2 or later. See the COPYING file in the top-level |
25 | + ARMCPU core; | 36 | - directory. |
26 | + } cpu[BCM283X_NCPUS]; | 37 | +.. |
27 | BCM2836ControlState control; | 38 | + Licence: This work is licensed under the terms of the GNU GPL, |
28 | BCM2835PeripheralState peripherals; | 39 | + version 2 or later. See the COPYING file in the top-level |
29 | } BCM283XState; | 40 | + directory. |
30 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 41 | |
42 | .. contents:: Table of Contents | ||
43 | |||
44 | diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst | ||
31 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/arm/bcm2836.c | 46 | --- a/docs/interop/vhost-user.rst |
33 | +++ b/hw/arm/bcm2836.c | 47 | +++ b/docs/interop/vhost-user.rst |
34 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | 48 | @@ -XXX,XX +XXX,XX @@ |
35 | int n; | 49 | =================== |
36 | 50 | Vhost-user Protocol | |
37 | for (n = 0; n < BCM283X_NCPUS; n++) { | 51 | =================== |
38 | - object_initialize_child(obj, "cpu[*]", &s->cpus[n], sizeof(s->cpus[n]), | 52 | -:Copyright: 2014 Virtual Open Systems Sarl. |
39 | - info->cpu_type, &error_abort, NULL); | 53 | -:Copyright: 2019 Intel Corporation |
40 | + object_initialize_child(obj, "cpu[*]", &s->cpu[n].core, | 54 | -:Licence: This work is licensed under the terms of the GNU GPL, |
41 | + sizeof(s->cpu[n].core), info->cpu_type, | 55 | - version 2 or later. See the COPYING file in the top-level |
42 | + &error_abort, NULL); | 56 | - directory. |
43 | } | 57 | + |
44 | 58 | +.. | |
45 | sysbus_init_child_obj(obj, "control", &s->control, sizeof(s->control), | 59 | + Copyright 2014 Virtual Open Systems Sarl. |
46 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | 60 | + Copyright 2019 Intel Corporation |
47 | 61 | + Licence: This work is licensed under the terms of the GNU GPL, | |
48 | for (n = 0; n < BCM283X_NCPUS; n++) { | 62 | + version 2 or later. See the COPYING file in the top-level |
49 | /* TODO: this should be converted to a property of ARM_CPU */ | 63 | + directory. |
50 | - s->cpus[n].mp_affinity = (info->clusterid << 8) | n; | 64 | |
51 | + s->cpu[n].core.mp_affinity = (info->clusterid << 8) | n; | 65 | .. contents:: Table of Contents |
52 | 66 | ||
53 | /* set periphbase/CBAR value for CPU-local registers */ | 67 | diff --git a/docs/system/generic-loader.rst b/docs/system/generic-loader.rst |
54 | - object_property_set_int(OBJECT(&s->cpus[n]), | 68 | index XXXXXXX..XXXXXXX 100644 |
55 | + object_property_set_int(OBJECT(&s->cpu[n].core), | 69 | --- a/docs/system/generic-loader.rst |
56 | info->peri_base, | 70 | +++ b/docs/system/generic-loader.rst |
57 | "reset-cbar", &err); | 71 | @@ -XXX,XX +XXX,XX @@ |
58 | if (err) { | 72 | .. |
59 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | 73 | Copyright (c) 2016, Xilinx Inc. |
60 | } | 74 | |
61 | 75 | -This work is licensed under the terms of the GNU GPL, version 2 or later. See | |
62 | /* start powered off if not enabled */ | 76 | -the COPYING file in the top-level directory. |
63 | - object_property_set_bool(OBJECT(&s->cpus[n]), n >= s->enabled_cpus, | 77 | + This work is licensed under the terms of the GNU GPL, version 2 or later. See |
64 | + object_property_set_bool(OBJECT(&s->cpu[n].core), n >= s->enabled_cpus, | 78 | + the COPYING file in the top-level directory. |
65 | "start-powered-off", &err); | 79 | |
66 | if (err) { | 80 | Generic Loader |
67 | error_propagate(errp, err); | 81 | -------------- |
68 | return; | ||
69 | } | ||
70 | |||
71 | - object_property_set_bool(OBJECT(&s->cpus[n]), true, "realized", &err); | ||
72 | + object_property_set_bool(OBJECT(&s->cpu[n].core), true, | ||
73 | + "realized", &err); | ||
74 | if (err) { | ||
75 | error_propagate(errp, err); | ||
76 | return; | ||
77 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
78 | |||
79 | /* Connect irq/fiq outputs from the interrupt controller. */ | ||
80 | qdev_connect_gpio_out_named(DEVICE(&s->control), "irq", n, | ||
81 | - qdev_get_gpio_in(DEVICE(&s->cpus[n]), ARM_CPU_IRQ)); | ||
82 | + qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_IRQ)); | ||
83 | qdev_connect_gpio_out_named(DEVICE(&s->control), "fiq", n, | ||
84 | - qdev_get_gpio_in(DEVICE(&s->cpus[n]), ARM_CPU_FIQ)); | ||
85 | + qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_FIQ)); | ||
86 | |||
87 | /* Connect timers from the CPU to the interrupt controller */ | ||
88 | - qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_PHYS, | ||
89 | + qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_PHYS, | ||
90 | qdev_get_gpio_in_named(DEVICE(&s->control), "cntpnsirq", n)); | ||
91 | - qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_VIRT, | ||
92 | + qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_VIRT, | ||
93 | qdev_get_gpio_in_named(DEVICE(&s->control), "cntvirq", n)); | ||
94 | - qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_HYP, | ||
95 | + qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_HYP, | ||
96 | qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq", n)); | ||
97 | - qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_SEC, | ||
98 | + qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_SEC, | ||
99 | qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n)); | ||
100 | } | ||
101 | } | ||
102 | -- | 82 | -- |
103 | 2.20.1 | 83 | 2.20.1 |
104 | 84 | ||
105 | 85 | diff view generated by jsdifflib |
1 | Switch the slavio_timer code away from bottom-half based ptimers to | 1 | In rST markup, single backticks `like this` represent "interpreted |
---|---|---|---|
2 | the new transaction-based ptimer API. This just requires adding | 2 | text", which can be handled as a bunch of different things if tagged |
3 | begin/commit calls around the various places that modify the ptimer | 3 | with a specific "role": |
4 | state, and using the new ptimer_init() function to create the timer. | 4 | https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#interpreted-text |
5 | (the most common one for us is "reference to a URL, which gets | ||
6 | hyperlinked"). | ||
7 | |||
8 | The default "role" if none is specified is "title_reference", | ||
9 | intended for references to book or article titles, and it renders | ||
10 | into the HTML as <cite>...</cite> (usually comes out as italics). | ||
11 | |||
12 | build-system.rst seems to have been written under the mistaken | ||
13 | assumption that single-backticks mark up literal text (function | ||
14 | names, etc) which should be rendered in a fixed-width font. | ||
15 | The rST markup for this is ``double backticks``. | ||
16 | |||
17 | Update all the markup. | ||
5 | 18 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20191021134357.14266-4-peter.maydell@linaro.org | 21 | Message-id: 20210726142338.31872-2-peter.maydell@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | 22 | --- |
12 | hw/timer/slavio_timer.c | 20 ++++++++++++++++---- | 23 | docs/devel/build-system.rst | 156 ++++++++++++++++++------------------ |
13 | 1 file changed, 16 insertions(+), 4 deletions(-) | 24 | 1 file changed, 78 insertions(+), 78 deletions(-) |
14 | 25 | ||
15 | diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c | 26 | diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/timer/slavio_timer.c | 28 | --- a/docs/devel/build-system.rst |
18 | +++ b/hw/timer/slavio_timer.c | 29 | +++ b/docs/devel/build-system.rst |
19 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ following tasks: |
20 | #include "hw/sysbus.h" | 31 | - Add a Meson build option to meson_options.txt. |
21 | #include "migration/vmstate.h" | 32 | |
22 | #include "trace.h" | 33 | - Add support to the command line arg parser to handle any new |
23 | -#include "qemu/main-loop.h" | 34 | - `--enable-XXX`/`--disable-XXX` flags required by the feature. |
24 | #include "qemu/module.h" | 35 | + ``--enable-XXX``/``--disable-XXX`` flags required by the feature. |
25 | 36 | ||
26 | /* | 37 | - Add information to the help output message to report on the new |
27 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, | 38 | feature flag. |
28 | saddr = addr >> 2; | 39 | |
29 | switch (saddr) { | 40 | - Add code to perform the actual feature check. |
30 | case TIMER_LIMIT: | 41 | |
31 | + ptimer_transaction_begin(t->timer); | 42 | - - Add code to include the feature status in `config-host.h` |
32 | if (slavio_timer_is_user(tc)) { | 43 | + - Add code to include the feature status in ``config-host.h`` |
33 | uint64_t count; | 44 | |
34 | 45 | - Add code to print out the feature status in the configure summary | |
35 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, | 46 | upon completion. |
36 | ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 1); | 47 | @@ -XXX,XX +XXX,XX @@ Helper functions |
37 | } | 48 | The configure script provides a variety of helper functions to assist |
38 | } | 49 | developers in checking for system features: |
39 | + ptimer_transaction_commit(t->timer); | 50 | |
40 | break; | 51 | -`do_cc $ARGS...` |
41 | case TIMER_COUNTER: | 52 | +``do_cc $ARGS...`` |
42 | if (slavio_timer_is_user(tc)) { | 53 | Attempt to run the system C compiler passing it $ARGS... |
43 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, | 54 | |
44 | t->reached = 0; | 55 | -`do_cxx $ARGS...` |
45 | count = ((uint64_t)t->counthigh) << 32 | t->count; | 56 | +``do_cxx $ARGS...`` |
46 | trace_slavio_timer_mem_writel_limit(timer_index, count); | 57 | Attempt to run the system C++ compiler passing it $ARGS... |
47 | + ptimer_transaction_begin(t->timer); | 58 | |
48 | ptimer_set_count(t->timer, LIMIT_TO_PERIODS(t->limit - count)); | 59 | -`compile_object $CFLAGS` |
49 | + ptimer_transaction_commit(t->timer); | 60 | +``compile_object $CFLAGS`` |
50 | } else { | 61 | Attempt to compile a test program with the system C compiler using |
51 | trace_slavio_timer_mem_writel_counter_invalid(); | 62 | $CFLAGS. The test program must have been previously written to a file |
52 | } | 63 | - called $TMPC. The replacement in Meson is the compiler object `cc`, |
53 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, | 64 | - which has methods such as `cc.compiles()`, |
54 | case TIMER_COUNTER_NORST: | 65 | - `cc.check_header()`, `cc.has_function()`. |
55 | // set limit without resetting counter | 66 | + called $TMPC. The replacement in Meson is the compiler object ``cc``, |
56 | t->limit = val & TIMER_MAX_COUNT32; | 67 | + which has methods such as ``cc.compiles()``, |
57 | + ptimer_transaction_begin(t->timer); | 68 | + ``cc.check_header()``, ``cc.has_function()``. |
58 | if (t->limit == 0) { /* free-run */ | 69 | |
59 | ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0); | 70 | -`compile_prog $CFLAGS $LDFLAGS` |
60 | } else { | 71 | +``compile_prog $CFLAGS $LDFLAGS`` |
61 | ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 0); | 72 | Attempt to compile a test program with the system C compiler using |
62 | } | 73 | $CFLAGS and link it with the system linker using $LDFLAGS. The test |
63 | + ptimer_transaction_commit(t->timer); | 74 | program must have been previously written to a file called $TMPC. |
64 | break; | 75 | - The replacement in Meson is `cc.find_library()` and `cc.links()`. |
65 | case TIMER_STATUS: | 76 | + The replacement in Meson is ``cc.find_library()`` and ``cc.links()``. |
66 | + ptimer_transaction_begin(t->timer); | 77 | |
67 | if (slavio_timer_is_user(tc)) { | 78 | -`has $COMMAND` |
68 | // start/stop user counter | 79 | +``has $COMMAND`` |
69 | if (val & 1) { | 80 | Determine if $COMMAND exists in the current environment, either as a |
70 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, | 81 | shell builtin, or executable binary, returning 0 on success. The |
71 | } | 82 | - replacement in Meson is `find_program()`. |
72 | } | 83 | + replacement in Meson is ``find_program()``. |
73 | t->run = val & 1; | 84 | |
74 | + ptimer_transaction_commit(t->timer); | 85 | -`check_define $NAME` |
75 | break; | 86 | +``check_define $NAME`` |
76 | case TIMER_MODE: | 87 | Determine if the macro $NAME is defined by the system C compiler |
77 | if (timer_index == 0) { | 88 | |
78 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, | 89 | -`check_include $NAME` |
79 | unsigned int processor = 1 << i; | 90 | +``check_include $NAME`` |
80 | CPUTimerState *curr_timer = &s->cputimer[i + 1]; | 91 | Determine if the include $NAME file is available to the system C |
81 | 92 | - compiler. The replacement in Meson is `cc.has_header()`. | |
82 | + ptimer_transaction_begin(curr_timer->timer); | 93 | + compiler. The replacement in Meson is ``cc.has_header()``. |
83 | // check for a change in timer mode for this processor | 94 | |
84 | if ((val & processor) != (s->cputimer_mode & processor)) { | 95 | -`write_c_skeleton` |
85 | if (val & processor) { // counter -> user timer | 96 | +``write_c_skeleton`` |
86 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, | 97 | Write a minimal C program main() function to the temporary file |
87 | trace_slavio_timer_mem_writel_mode_counter(timer_index); | 98 | indicated by $TMPC |
88 | } | 99 | |
89 | } | 100 | -`feature_not_found $NAME $REMEDY` |
90 | + ptimer_transaction_commit(curr_timer->timer); | 101 | +``feature_not_found $NAME $REMEDY`` |
91 | } | 102 | Print a message to stderr that the feature $NAME was not available |
92 | } else { | 103 | on the system, suggesting the user try $REMEDY to address the |
93 | trace_slavio_timer_mem_writel_mode_invalid(); | 104 | problem. |
94 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_reset(DeviceState *d) | 105 | |
95 | curr_timer->count = 0; | 106 | -`error_exit $MESSAGE $MORE...` |
96 | curr_timer->reached = 0; | 107 | +``error_exit $MESSAGE $MORE...`` |
97 | if (i <= s->num_cpus) { | 108 | Print $MESSAGE to stderr, followed by $MORE... and then exit from the |
98 | + ptimer_transaction_begin(curr_timer->timer); | 109 | configure script with non-zero status |
99 | ptimer_set_limit(curr_timer->timer, | 110 | |
100 | LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); | 111 | -`query_pkg_config $ARGS...` |
101 | ptimer_run(curr_timer->timer, 0); | 112 | +``query_pkg_config $ARGS...`` |
102 | curr_timer->run = 1; | 113 | Run pkg-config passing it $ARGS. If QEMU is doing a static build, |
103 | + ptimer_transaction_commit(curr_timer->timer); | 114 | then --static will be automatically added to $ARGS |
104 | } | 115 | |
105 | } | 116 | @@ -XXX,XX +XXX,XX @@ process for: |
106 | s->cputimer_mode = 0; | 117 | |
107 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_init(Object *obj) | 118 | 4) other data files, such as icons or desktop files |
108 | { | 119 | |
109 | SLAVIO_TIMERState *s = SLAVIO_TIMER(obj); | 120 | -All executables are built by default, except for some `contrib/` |
110 | SysBusDevice *dev = SYS_BUS_DEVICE(obj); | 121 | +All executables are built by default, except for some ``contrib/`` |
111 | - QEMUBH *bh; | 122 | binaries that are known to fail to build on some platforms (for example |
112 | unsigned int i; | 123 | 32-bit or big-endian platforms). Tests are also built by default, |
113 | TimerContext *tc; | 124 | though that might change in the future. |
114 | 125 | @@ -XXX,XX +XXX,XX @@ though that might change in the future. | |
115 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_init(Object *obj) | 126 | The source code is highly modularized, split across many files to |
116 | tc->s = s; | 127 | facilitate building of all of these components with as little duplicated |
117 | tc->timer_index = i; | 128 | compilation as possible. Using the Meson "sourceset" functionality, |
118 | 129 | -`meson.build` files group the source files in rules that are | |
119 | - bh = qemu_bh_new(slavio_timer_irq, tc); | 130 | +``meson.build`` files group the source files in rules that are |
120 | - s->cputimer[i].timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT); | 131 | enabled according to the available system libraries and to various |
121 | + s->cputimer[i].timer = ptimer_init(slavio_timer_irq, tc, | 132 | configuration symbols. Sourcesets belong to one of four groups: |
122 | + PTIMER_POLICY_DEFAULT); | 133 | |
123 | + ptimer_transaction_begin(s->cputimer[i].timer); | 134 | Subsystem sourcesets: |
124 | ptimer_set_period(s->cputimer[i].timer, TIMER_PERIOD); | 135 | Various subsystems that are common to both tools and emulators have |
125 | + ptimer_transaction_commit(s->cputimer[i].timer); | 136 | - their own sourceset, for example `block_ss` for the block device subsystem, |
126 | 137 | - `chardev_ss` for the character device subsystem, etc. These sourcesets | |
127 | size = i == 0 ? SYS_TIMER_SIZE : CPU_TIMER_SIZE; | 138 | + their own sourceset, for example ``block_ss`` for the block device subsystem, |
128 | snprintf(timer_name, sizeof(timer_name), "timer-%i", i); | 139 | + ``chardev_ss`` for the character device subsystem, etc. These sourcesets |
140 | are then turned into static libraries as follows:: | ||
141 | |||
142 | libchardev = static_library('chardev', chardev_ss.sources(), | ||
143 | @@ -XXX,XX +XXX,XX @@ Subsystem sourcesets: | ||
144 | |||
145 | chardev = declare_dependency(link_whole: libchardev) | ||
146 | |||
147 | - As of Meson 0.55.1, the special `.fa` suffix should be used for everything | ||
148 | - that is used with `link_whole`, to ensure that the link flags are placed | ||
149 | + As of Meson 0.55.1, the special ``.fa`` suffix should be used for everything | ||
150 | + that is used with ``link_whole``, to ensure that the link flags are placed | ||
151 | correctly in the command line. | ||
152 | |||
153 | Target-independent emulator sourcesets: | ||
154 | @@ -XXX,XX +XXX,XX @@ Target-independent emulator sourcesets: | ||
155 | This includes error handling infrastructure, standard data structures, | ||
156 | platform portability wrapper functions, etc. | ||
157 | |||
158 | - Target-independent code lives in the `common_ss`, `softmmu_ss` and | ||
159 | - `user_ss` sourcesets. `common_ss` is linked into all emulators, | ||
160 | - `softmmu_ss` only in system emulators, `user_ss` only in user-mode | ||
161 | + Target-independent code lives in the ``common_ss``, ``softmmu_ss`` and | ||
162 | + ``user_ss`` sourcesets. ``common_ss`` is linked into all emulators, | ||
163 | + ``softmmu_ss`` only in system emulators, ``user_ss`` only in user-mode | ||
164 | emulators. | ||
165 | |||
166 | Target-independent sourcesets must exercise particular care when using | ||
167 | - `if_false` rules. The `if_false` rule will be used correctly when linking | ||
168 | + ``if_false`` rules. The ``if_false`` rule will be used correctly when linking | ||
169 | emulator binaries; however, when *compiling* target-independent files | ||
170 | - into .o files, Meson may need to pick *both* the `if_true` and | ||
171 | - `if_false` sides to cater for targets that want either side. To | ||
172 | + into .o files, Meson may need to pick *both* the ``if_true`` and | ||
173 | + ``if_false`` sides to cater for targets that want either side. To | ||
174 | achieve that, you can add a special rule using the ``CONFIG_ALL`` | ||
175 | symbol:: | ||
176 | |||
177 | @@ -XXX,XX +XXX,XX @@ Target-dependent emulator sourcesets: | ||
178 | In the target-dependent set lives CPU emulation, some device emulation and | ||
179 | much glue code. This sometimes also has to be compiled multiple times, | ||
180 | once for each target being built. Target-dependent files are included | ||
181 | - in the `specific_ss` sourceset. | ||
182 | + in the ``specific_ss`` sourceset. | ||
183 | |||
184 | - Each emulator also includes sources for files in the `hw/` and `target/` | ||
185 | + Each emulator also includes sources for files in the ``hw/`` and ``target/`` | ||
186 | subdirectories. The subdirectory used for each emulator comes | ||
187 | from the target's definition of ``TARGET_BASE_ARCH`` or (if missing) | ||
188 | - ``TARGET_ARCH``, as found in `default-configs/targets/*.mak`. | ||
189 | + ``TARGET_ARCH``, as found in ``default-configs/targets/*.mak``. | ||
190 | |||
191 | - Each subdirectory in `hw/` adds one sourceset to the `hw_arch` dictionary, | ||
192 | + Each subdirectory in ``hw/`` adds one sourceset to the ``hw_arch`` dictionary, | ||
193 | for example:: | ||
194 | |||
195 | arm_ss = ss.source_set() | ||
196 | @@ -XXX,XX +XXX,XX @@ Target-dependent emulator sourcesets: | ||
197 | |||
198 | The sourceset is only used for system emulators. | ||
199 | |||
200 | - Each subdirectory in `target/` instead should add one sourceset to each | ||
201 | - of the `target_arch` and `target_softmmu_arch`, which are used respectively | ||
202 | + Each subdirectory in ``target/`` instead should add one sourceset to each | ||
203 | + of the ``target_arch`` and ``target_softmmu_arch``, which are used respectively | ||
204 | for all emulators and for system emulators only. For example:: | ||
205 | |||
206 | arm_ss = ss.source_set() | ||
207 | @@ -XXX,XX +XXX,XX @@ Target-dependent emulator sourcesets: | ||
208 | target_softmmu_arch += {'arm': arm_softmmu_ss} | ||
209 | |||
210 | Module sourcesets: | ||
211 | - There are two dictionaries for modules: `modules` is used for | ||
212 | - target-independent modules and `target_modules` is used for | ||
213 | - target-dependent modules. When modules are disabled the `module` | ||
214 | - source sets are added to `softmmu_ss` and the `target_modules` | ||
215 | - source sets are added to `specific_ss`. | ||
216 | + There are two dictionaries for modules: ``modules`` is used for | ||
217 | + target-independent modules and ``target_modules`` is used for | ||
218 | + target-dependent modules. When modules are disabled the ``module`` | ||
219 | + source sets are added to ``softmmu_ss`` and the ``target_modules`` | ||
220 | + source sets are added to ``specific_ss``. | ||
221 | |||
222 | Both dictionaries are nested. One dictionary is created per | ||
223 | subdirectory, and these per-subdirectory dictionaries are added to | ||
224 | @@ -XXX,XX +XXX,XX @@ Module sourcesets: | ||
225 | modules += { 'hw-display': hw_display_modules } | ||
226 | |||
227 | Utility sourcesets: | ||
228 | - All binaries link with a static library `libqemuutil.a`. This library | ||
229 | + All binaries link with a static library ``libqemuutil.a``. This library | ||
230 | is built from several sourcesets; most of them however host generated | ||
231 | - code, and the only two of general interest are `util_ss` and `stub_ss`. | ||
232 | + code, and the only two of general interest are ``util_ss`` and ``stub_ss``. | ||
233 | |||
234 | The separation between these two is purely for documentation purposes. | ||
235 | - `util_ss` contains generic utility files. Even though this code is only | ||
236 | + ``util_ss`` contains generic utility files. Even though this code is only | ||
237 | linked in some binaries, sometimes it requires hooks only in some of | ||
238 | these and depend on other functions that are not fully implemented by | ||
239 | - all QEMU binaries. `stub_ss` links dummy stubs that will only be linked | ||
240 | + all QEMU binaries. ``stub_ss`` links dummy stubs that will only be linked | ||
241 | into the binary if the real implementation is not present. In a way, | ||
242 | the stubs can be thought of as a portable implementation of the weak | ||
243 | symbols concept. | ||
244 | @@ -XXX,XX +XXX,XX @@ Utility sourcesets: | ||
245 | The following files concur in the definition of which files are linked | ||
246 | into each emulator: | ||
247 | |||
248 | -`default-configs/devices/*.mak` | ||
249 | - The files under `default-configs/devices/` control the boards and devices | ||
250 | +``default-configs/devices/*.mak`` | ||
251 | + The files under ``default-configs/devices/`` control the boards and devices | ||
252 | that are built into each QEMU system emulation targets. They merely contain | ||
253 | a list of config variable definitions such as:: | ||
254 | |||
255 | @@ -XXX,XX +XXX,XX @@ into each emulator: | ||
256 | CONFIG_XLNX_ZYNQMP_ARM=y | ||
257 | CONFIG_XLNX_VERSAL=y | ||
258 | |||
259 | -`*/Kconfig` | ||
260 | - These files are processed together with `default-configs/devices/*.mak` and | ||
261 | +``*/Kconfig`` | ||
262 | + These files are processed together with ``default-configs/devices/*.mak`` and | ||
263 | describe the dependencies between various features, subsystems and | ||
264 | device models. They are described in :ref:`kconfig` | ||
265 | |||
266 | -`default-configs/targets/*.mak` | ||
267 | - These files mostly define symbols that appear in the `*-config-target.h` | ||
268 | +``default-configs/targets/*.mak`` | ||
269 | + These files mostly define symbols that appear in the ``*-config-target.h`` | ||
270 | file for each emulator [#cfgtarget]_. However, the ``TARGET_ARCH`` | ||
271 | - and ``TARGET_BASE_ARCH`` will also be used to select the `hw/` and | ||
272 | - `target/` subdirectories that are compiled into each target. | ||
273 | + and ``TARGET_BASE_ARCH`` will also be used to select the ``hw/`` and | ||
274 | + ``target/`` subdirectories that are compiled into each target. | ||
275 | |||
276 | -.. [#cfgtarget] This header is included by `qemu/osdep.h` when | ||
277 | +.. [#cfgtarget] This header is included by ``qemu/osdep.h`` when | ||
278 | compiling files from the target-specific sourcesets. | ||
279 | |||
280 | These files rarely need changing unless you are adding a completely | ||
281 | @@ -XXX,XX +XXX,XX @@ Support scripts | ||
282 | --------------- | ||
283 | |||
284 | Meson has a special convention for invoking Python scripts: if their | ||
285 | -first line is `#! /usr/bin/env python3` and the file is *not* executable, | ||
286 | +first line is ``#! /usr/bin/env python3`` and the file is *not* executable, | ||
287 | find_program() arranges to invoke the script under the same Python | ||
288 | interpreter that was used to invoke Meson. This is the most common | ||
289 | and preferred way to invoke support scripts from Meson build files, | ||
290 | because it automatically uses the value of configure's --python= option. | ||
291 | |||
292 | -In case the script is not written in Python, use a `#! /usr/bin/env ...` | ||
293 | +In case the script is not written in Python, use a ``#! /usr/bin/env ...`` | ||
294 | line and make the script executable. | ||
295 | |||
296 | Scripts written in Python, where it is desirable to make the script | ||
297 | executable (for example for test scripts that developers may want to | ||
298 | invoke from the command line, such as tests/qapi-schema/test-qapi.py), | ||
299 | -should be invoked through the `python` variable in meson.build. For | ||
300 | +should be invoked through the ``python`` variable in meson.build. For | ||
301 | example:: | ||
302 | |||
303 | test('QAPI schema regression tests', python, | ||
304 | @@ -XXX,XX +XXX,XX @@ rules and wraps them so that e.g. submodules are built before QEMU. | ||
305 | The resulting build system is largely non-recursive in nature, in | ||
306 | contrast to common practices seen with automake. | ||
307 | |||
308 | -Tests are also ran by the Makefile with the traditional `make check` | ||
309 | -phony target, while benchmarks are run with `make bench`. Meson test | ||
310 | -suites such as `unit` can be ran with `make check-unit` too. It is also | ||
311 | -possible to run tests defined in meson.build with `meson test`. | ||
312 | +Tests are also ran by the Makefile with the traditional ``make check`` | ||
313 | +phony target, while benchmarks are run with ``make bench``. Meson test | ||
314 | +suites such as ``unit`` can be ran with ``make check-unit`` too. It is also | ||
315 | +possible to run tests defined in meson.build with ``meson test``. | ||
316 | |||
317 | Important files for the build system | ||
318 | ==================================== | ||
319 | @@ -XXX,XX +XXX,XX @@ The following key files are statically defined in the source tree, with | ||
320 | the rules needed to build QEMU. Their behaviour is influenced by a | ||
321 | number of dynamically created files listed later. | ||
322 | |||
323 | -`Makefile` | ||
324 | +``Makefile`` | ||
325 | The main entry point used when invoking make to build all the components | ||
326 | of QEMU. The default 'all' target will naturally result in the build of | ||
327 | every component. Makefile takes care of recursively building submodules | ||
328 | directly via a non-recursive set of rules. | ||
329 | |||
330 | -`*/meson.build` | ||
331 | +``*/meson.build`` | ||
332 | The meson.build file in the root directory is the main entry point for the | ||
333 | Meson build system, and it coordinates the configuration and build of all | ||
334 | executables. Build rules for various subdirectories are included in | ||
335 | other meson.build files spread throughout the QEMU source tree. | ||
336 | |||
337 | -`tests/Makefile.include` | ||
338 | +``tests/Makefile.include`` | ||
339 | Rules for external test harnesses. These include the TCG tests, | ||
340 | - `qemu-iotests` and the Avocado-based acceptance tests. | ||
341 | + ``qemu-iotests`` and the Avocado-based acceptance tests. | ||
342 | |||
343 | -`tests/docker/Makefile.include` | ||
344 | +``tests/docker/Makefile.include`` | ||
345 | Rules for Docker tests. Like tests/Makefile, this file is included | ||
346 | directly by the top level Makefile, anything defined in this file will | ||
347 | influence the entire build system. | ||
348 | |||
349 | -`tests/vm/Makefile.include` | ||
350 | +``tests/vm/Makefile.include`` | ||
351 | Rules for VM-based tests. Like tests/Makefile, this file is included | ||
352 | directly by the top level Makefile, anything defined in this file will | ||
353 | influence the entire build system. | ||
354 | @@ -XXX,XX +XXX,XX @@ Makefile. | ||
355 | |||
356 | Built by configure: | ||
357 | |||
358 | -`config-host.mak` | ||
359 | +``config-host.mak`` | ||
360 | When configure has determined the characteristics of the build host it | ||
361 | will write a long list of variables to config-host.mak file. This | ||
362 | provides the various install directories, compiler / linker flags and a | ||
363 | - variety of `CONFIG_*` variables related to optionally enabled features. | ||
364 | + variety of ``CONFIG_*`` variables related to optionally enabled features. | ||
365 | This is imported by the top level Makefile and meson.build in order to | ||
366 | tailor the build output. | ||
367 | |||
368 | @@ -XXX,XX +XXX,XX @@ Built by configure: | ||
369 | |||
370 | Built by Meson: | ||
371 | |||
372 | -`${TARGET-NAME}-config-devices.mak` | ||
373 | +``${TARGET-NAME}-config-devices.mak`` | ||
374 | TARGET-NAME is again the name of a system or userspace emulator. The | ||
375 | config-devices.mak file is automatically generated by make using the | ||
376 | scripts/make_device_config.sh program, feeding it the | ||
377 | default-configs/$TARGET-NAME file as input. | ||
378 | |||
379 | -`config-host.h`, `$TARGET-NAME/config-target.h`, `$TARGET-NAME/config-devices.h` | ||
380 | +``config-host.h``, ``$TARGET-NAME/config-target.h``, ``$TARGET-NAME/config-devices.h`` | ||
381 | These files are used by source code to determine what features | ||
382 | are enabled. They are generated from the contents of the corresponding | ||
383 | - `*.h` files using the scripts/create_config program. This extracts | ||
384 | + ``*.h`` files using the scripts/create_config program. This extracts | ||
385 | relevant variables and formats them as C preprocessor macros. | ||
386 | |||
387 | -`build.ninja` | ||
388 | +``build.ninja`` | ||
389 | The build rules. | ||
390 | |||
391 | |||
392 | Built by Makefile: | ||
393 | |||
394 | -`Makefile.ninja` | ||
395 | +``Makefile.ninja`` | ||
396 | A Makefile include that bridges to ninja for the actual build. The | ||
397 | Makefile is mostly a list of targets that Meson included in build.ninja. | ||
398 | |||
399 | -`Makefile.mtest` | ||
400 | +``Makefile.mtest`` | ||
401 | The Makefile definitions that let "make check" run tests defined in | ||
402 | meson.build. The rules are produced from Meson's JSON description of | ||
403 | tests (obtained with "meson introspect --tests") through the script | ||
404 | @@ -XXX,XX +XXX,XX @@ Built by Makefile: | ||
405 | Useful make targets | ||
406 | ------------------- | ||
407 | |||
408 | -`help` | ||
409 | +``help`` | ||
410 | Print a help message for the most common build targets. | ||
411 | |||
412 | -`print-VAR` | ||
413 | +``print-VAR`` | ||
414 | Print the value of the variable VAR. Useful for debugging the build | ||
415 | system. | ||
129 | -- | 416 | -- |
130 | 2.20.1 | 417 | 2.20.1 |
131 | 418 | ||
132 | 419 | diff view generated by jsdifflib |
1 | Switch the grlib_gptimer code away from bottom-half based ptimers to | 1 | One of the example meson.build fragments incorrectly quotes some |
---|---|---|---|
2 | the new transaction-based ptimer API. This just requires adding | 2 | symbols as 'CONFIG_FOO`; the correct syntax here is 'CONFIG_FOO'. |
3 | begin/commit calls around the various places that modify the ptimer | 3 | (This isn't a rST formatting mistake because the example is displayed |
4 | state, and using the new ptimer_init() function to create the timer. | 4 | literally; it's just the wrong kind of quote.) |
5 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Message-id: 20191021134357.14266-3-peter.maydell@linaro.org | 9 | Message-id: 20210726142338.31872-3-peter.maydell@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | 10 | --- |
12 | hw/timer/grlib_gptimer.c | 28 ++++++++++++++++++++++++---- | 11 | docs/devel/build-system.rst | 4 ++-- |
13 | 1 file changed, 24 insertions(+), 4 deletions(-) | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
14 | 13 | ||
15 | diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c | 14 | diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/timer/grlib_gptimer.c | 16 | --- a/docs/devel/build-system.rst |
18 | +++ b/hw/timer/grlib_gptimer.c | 17 | +++ b/docs/devel/build-system.rst |
19 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ Target-independent emulator sourcesets: |
20 | #include "hw/irq.h" | 19 | symbol:: |
21 | #include "hw/ptimer.h" | 20 | |
22 | #include "hw/qdev-properties.h" | 21 | # Some targets have CONFIG_ACPI, some don't, so this is not enough |
23 | -#include "qemu/main-loop.h" | 22 | - softmmu_ss.add(when: 'CONFIG_ACPI`, if_true: files('acpi.c'), |
24 | #include "qemu/module.h" | 23 | + softmmu_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi.c'), |
25 | 24 | if_false: files('acpi-stub.c')) | |
26 | #include "trace.h" | 25 | |
27 | @@ -XXX,XX +XXX,XX @@ typedef struct GPTimer GPTimer; | 26 | # This is required as well: |
28 | typedef struct GPTimerUnit GPTimerUnit; | 27 | - softmmu_ss.add(when: 'CONFIG_ALL`, if_true: files('acpi-stub.c')) |
29 | 28 | + softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c')) | |
30 | struct GPTimer { | 29 | |
31 | - QEMUBH *bh; | 30 | Target-dependent emulator sourcesets: |
32 | struct ptimer_state *ptimer; | 31 | In the target-dependent set lives CPU emulation, some device emulation and |
33 | |||
34 | qemu_irq irq; | ||
35 | @@ -XXX,XX +XXX,XX @@ struct GPTimerUnit { | ||
36 | uint32_t config; | ||
37 | }; | ||
38 | |||
39 | +static void grlib_gptimer_tx_begin(GPTimer *timer) | ||
40 | +{ | ||
41 | + ptimer_transaction_begin(timer->ptimer); | ||
42 | +} | ||
43 | + | ||
44 | +static void grlib_gptimer_tx_commit(GPTimer *timer) | ||
45 | +{ | ||
46 | + ptimer_transaction_commit(timer->ptimer); | ||
47 | +} | ||
48 | + | ||
49 | +/* Must be called within grlib_gptimer_tx_begin/commit block */ | ||
50 | static void grlib_gptimer_enable(GPTimer *timer) | ||
51 | { | ||
52 | assert(timer != NULL); | ||
53 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_enable(GPTimer *timer) | ||
54 | ptimer_run(timer->ptimer, 1); | ||
55 | } | ||
56 | |||
57 | +/* Must be called within grlib_gptimer_tx_begin/commit block */ | ||
58 | static void grlib_gptimer_restart(GPTimer *timer) | ||
59 | { | ||
60 | assert(timer != NULL); | ||
61 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_set_scaler(GPTimerUnit *unit, uint32_t scaler) | ||
62 | trace_grlib_gptimer_set_scaler(scaler, value); | ||
63 | |||
64 | for (i = 0; i < unit->nr_timers; i++) { | ||
65 | + ptimer_transaction_begin(unit->timers[i].ptimer); | ||
66 | ptimer_set_freq(unit->timers[i].ptimer, value); | ||
67 | + ptimer_transaction_commit(unit->timers[i].ptimer); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, | ||
72 | switch (timer_addr) { | ||
73 | case COUNTER_OFFSET: | ||
74 | trace_grlib_gptimer_writel(id, addr, value); | ||
75 | + grlib_gptimer_tx_begin(&unit->timers[id]); | ||
76 | unit->timers[id].counter = value; | ||
77 | grlib_gptimer_enable(&unit->timers[id]); | ||
78 | + grlib_gptimer_tx_commit(&unit->timers[id]); | ||
79 | return; | ||
80 | |||
81 | case COUNTER_RELOAD_OFFSET: | ||
82 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, | ||
83 | /* gptimer_restart calls gptimer_enable, so if "enable" and "load" | ||
84 | bits are present, we just have to call restart. */ | ||
85 | |||
86 | + grlib_gptimer_tx_begin(&unit->timers[id]); | ||
87 | if (value & GPTIMER_LOAD) { | ||
88 | grlib_gptimer_restart(&unit->timers[id]); | ||
89 | } else if (value & GPTIMER_ENABLE) { | ||
90 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, | ||
91 | value &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT); | ||
92 | |||
93 | unit->timers[id].config = value; | ||
94 | + grlib_gptimer_tx_commit(&unit->timers[id]); | ||
95 | return; | ||
96 | |||
97 | default: | ||
98 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_reset(DeviceState *d) | ||
99 | timer->counter = 0; | ||
100 | timer->reload = 0; | ||
101 | timer->config = 0; | ||
102 | + ptimer_transaction_begin(timer->ptimer); | ||
103 | ptimer_stop(timer->ptimer); | ||
104 | ptimer_set_count(timer->ptimer, 0); | ||
105 | ptimer_set_freq(timer->ptimer, unit->freq_hz); | ||
106 | + ptimer_transaction_commit(timer->ptimer); | ||
107 | } | ||
108 | } | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static void grlib_gptimer_realize(DeviceState *dev, Error **errp) | ||
111 | GPTimer *timer = &unit->timers[i]; | ||
112 | |||
113 | timer->unit = unit; | ||
114 | - timer->bh = qemu_bh_new(grlib_gptimer_hit, timer); | ||
115 | - timer->ptimer = ptimer_init_with_bh(timer->bh, PTIMER_POLICY_DEFAULT); | ||
116 | + timer->ptimer = ptimer_init(grlib_gptimer_hit, timer, | ||
117 | + PTIMER_POLICY_DEFAULT); | ||
118 | timer->id = i; | ||
119 | |||
120 | /* One IRQ line for each timer */ | ||
121 | sysbus_init_irq(sbd, &timer->irq); | ||
122 | |||
123 | + ptimer_transaction_begin(timer->ptimer); | ||
124 | ptimer_set_freq(timer->ptimer, unit->freq_hz); | ||
125 | + ptimer_transaction_commit(timer->ptimer); | ||
126 | } | ||
127 | |||
128 | memory_region_init_io(&unit->iomem, OBJECT(unit), &grlib_gptimer_ops, | ||
129 | -- | 32 | -- |
130 | 2.20.1 | 33 | 2.20.1 |
131 | 34 | ||
132 | 35 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | In rST markup, single backticks `like this` represent "interpreted |
---|---|---|---|
2 | text", which can be handled as a bunch of different things if tagged | ||
3 | with a specific "role": | ||
4 | https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#interpreted-text | ||
5 | (the most common one for us is "reference to a URL, which gets | ||
6 | hyperlinked"). | ||
2 | 7 | ||
3 | This file creates the BCM2836/BCM2837 blocks. | 8 | The default "role" if none is specified is "title_reference", |
4 | The biggest differences with the BCM2838 we are going to add, are | 9 | intended for references to book or article titles, and it renders |
5 | the base addresses of the interrupt controller and the peripherals. | 10 | into the HTML as <cite>...</cite> (usually comes out as italics). |
6 | Add these addresses in the BCM283XInfo structure to make this | ||
7 | block more modular. Remove the MCORE_OFFSET offset as it is | ||
8 | not useful and rather confusing. | ||
9 | 11 | ||
10 | Reviewed-by: Esteban Bosse <estebanbosse@gmail.com> | 12 | To format a literal (generally rendered as fixed-width font), |
11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | double-backticks are required. |
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 14 | |
13 | Message-id: 20191019234715.25750-6-f4bug@amsat.org | 15 | ebpf_rss.rst gets this wrong in a few places; correct them. |
16 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
20 | Message-id: 20210726142338.31872-4-peter.maydell@linaro.org | ||
15 | --- | 21 | --- |
16 | hw/arm/bcm2836.c | 18 +++++++++--------- | 22 | docs/devel/ebpf_rss.rst | 18 +++++++++--------- |
17 | 1 file changed, 9 insertions(+), 9 deletions(-) | 23 | 1 file changed, 9 insertions(+), 9 deletions(-) |
18 | 24 | ||
19 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 25 | diff --git a/docs/devel/ebpf_rss.rst b/docs/devel/ebpf_rss.rst |
20 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/bcm2836.c | 27 | --- a/docs/devel/ebpf_rss.rst |
22 | +++ b/hw/arm/bcm2836.c | 28 | +++ b/docs/devel/ebpf_rss.rst |
23 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ eBPF RSS implementation |
24 | #include "hw/arm/raspi_platform.h" | 30 | |
25 | #include "hw/sysbus.h" | 31 | eBPF RSS loading functionality located in ebpf/ebpf_rss.c and ebpf/ebpf_rss.h. |
26 | 32 | ||
27 | -/* Peripheral base address seen by the CPU */ | 33 | -The `struct EBPFRSSContext` structure that holds 4 file descriptors: |
28 | -#define BCM2836_PERI_BASE 0x3F000000 | 34 | +The ``struct EBPFRSSContext`` structure that holds 4 file descriptors: |
29 | - | 35 | |
30 | -/* "QA7" (Pi2) interrupt controller and mailboxes etc. */ | 36 | - ctx - pointer of the libbpf context. |
31 | -#define BCM2836_CONTROL_BASE 0x40000000 | 37 | - program_fd - file descriptor of the eBPF RSS program. |
32 | - | 38 | @@ -XXX,XX +XXX,XX @@ The `struct EBPFRSSContext` structure that holds 4 file descriptors: |
33 | struct BCM283XInfo { | 39 | - map_toeplitz_key - file descriptor of the 'Toeplitz key' map. One element of the 40byte key prepared for the hashing algorithm. |
34 | const char *name; | 40 | - map_indirections_table - 128 elements of queue indexes. |
35 | const char *cpu_type; | 41 | |
36 | + hwaddr peri_base; /* Peripheral base address seen by the CPU */ | 42 | -`struct EBPFRSSConfig` fields: |
37 | + hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */ | 43 | +``struct EBPFRSSConfig`` fields: |
38 | int clusterid; | 44 | |
39 | }; | 45 | -- redirect - "boolean" value, should the hash be calculated, on false - `default_queue` would be used as the final decision. |
40 | 46 | +- redirect - "boolean" value, should the hash be calculated, on false - ``default_queue`` would be used as the final decision. | |
41 | @@ -XXX,XX +XXX,XX @@ static const BCM283XInfo bcm283x_socs[] = { | 47 | - populate_hash - for now, not used. eBPF RSS doesn't support hash reporting. |
42 | { | 48 | -- hash_types - binary mask of different hash types. See `VIRTIO_NET_RSS_HASH_TYPE_*` defines. If for packet hash should not be calculated - `default_queue` would be used. |
43 | .name = TYPE_BCM2836, | 49 | +- hash_types - binary mask of different hash types. See ``VIRTIO_NET_RSS_HASH_TYPE_*`` defines. If for packet hash should not be calculated - ``default_queue`` would be used. |
44 | .cpu_type = ARM_CPU_TYPE_NAME("cortex-a7"), | 50 | - indirections_len - length of the indirections table, maximum 128. |
45 | + .peri_base = 0x3f000000, | 51 | - default_queue - the queue index that used for packet that shouldn't be hashed. For some packets, the hash can't be calculated(g.e ARP). |
46 | + .ctrl_base = 0x40000000, | 52 | |
47 | .clusterid = 0xf, | 53 | Functions: |
48 | }, | 54 | |
49 | #ifdef TARGET_AARCH64 | 55 | -- `ebpf_rss_init()` - sets ctx to NULL, which indicates that EBPFRSSContext is not loaded. |
50 | { | 56 | -- `ebpf_rss_load()` - creates 3 maps and loads eBPF program from the rss.bpf.skeleton.h. Returns 'true' on success. After that, program_fd can be used to set steering for TAP. |
51 | .name = TYPE_BCM2837, | 57 | -- `ebpf_rss_set_all()` - sets values for eBPF maps. `indirections_table` length is in EBPFRSSConfig. `toeplitz_key` is VIRTIO_NET_RSS_MAX_KEY_SIZE aka 40 bytes array. |
52 | .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"), | 58 | -- `ebpf_rss_unload()` - close all file descriptors and set ctx to NULL. |
53 | + .peri_base = 0x3f000000, | 59 | +- ``ebpf_rss_init()`` - sets ctx to NULL, which indicates that EBPFRSSContext is not loaded. |
54 | + .ctrl_base = 0x40000000, | 60 | +- ``ebpf_rss_load()`` - creates 3 maps and loads eBPF program from the rss.bpf.skeleton.h. Returns 'true' on success. After that, program_fd can be used to set steering for TAP. |
55 | .clusterid = 0x0, | 61 | +- ``ebpf_rss_set_all()`` - sets values for eBPF maps. ``indirections_table`` length is in EBPFRSSConfig. ``toeplitz_key`` is VIRTIO_NET_RSS_MAX_KEY_SIZE aka 40 bytes array. |
56 | }, | 62 | +- ``ebpf_rss_unload()`` - close all file descriptors and set ctx to NULL. |
57 | #endif | 63 | |
58 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | 64 | Simplified eBPF RSS workflow: |
59 | } | 65 | |
60 | 66 | @@ -XXX,XX +XXX,XX @@ Simplified eBPF RSS workflow: | |
61 | sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, | 67 | NetClientState SetSteeringEBPF() |
62 | - BCM2836_PERI_BASE, 1); | 68 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
63 | + info->peri_base, 1); | 69 | |
64 | 70 | -For now, `set_steering_ebpf()` method supported by Linux TAP NetClientState. The method requires an eBPF program file descriptor as an argument. | |
65 | /* bcm2836 interrupt controller (and mailboxes, etc.) */ | 71 | +For now, ``set_steering_ebpf()`` method supported by Linux TAP NetClientState. The method requires an eBPF program file descriptor as an argument. |
66 | object_property_set_bool(OBJECT(&s->control), true, "realized", &err); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, BCM2836_CONTROL_BASE); | ||
72 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, info->ctrl_base); | ||
73 | |||
74 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, | ||
75 | qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0)); | ||
76 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
77 | |||
78 | /* set periphbase/CBAR value for CPU-local registers */ | ||
79 | object_property_set_int(OBJECT(&s->cpus[n]), | ||
80 | - BCM2836_PERI_BASE + MSYNC_OFFSET, | ||
81 | + info->peri_base, | ||
82 | "reset-cbar", &err); | ||
83 | if (err) { | ||
84 | error_propagate(errp, err); | ||
85 | -- | 72 | -- |
86 | 2.20.1 | 73 | 2.20.1 |
87 | 74 | ||
88 | 75 | diff view generated by jsdifflib |
1 | In the slavio timer devcie, the ptimer TimerContext::timer is | 1 | In rST markup, single backticks `like this` represent "interpreted |
---|---|---|---|
2 | always created by slavio_timer_init(), so there's no need to | 2 | text", which can be handled as a bunch of different things if tagged |
3 | check it for NULL; remove the single unneeded NULL check. | 3 | with a specific "role": |
4 | https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#interpreted-text | ||
5 | (the most common one for us is "reference to a URL, which gets | ||
6 | hyperlinked"). | ||
4 | 7 | ||
5 | This will be useful to avoid compiler/Coverity errors when | 8 | The default "role" if none is specified is "title_reference", |
6 | a subsequent change adds a use of t->timer before the location | 9 | intended for references to book or article titles, and it renders |
7 | we currently do the NULL check. | 10 | into the HTML as <cite>...</cite> (usually comes out as italics). |
11 | |||
12 | To format a literal (generally rendered as fixed-width font), | ||
13 | double-backticks are required. | ||
14 | |||
15 | Mostly migration.rst gets this right, but some places incorrectly use | ||
16 | single backticks where double backticks were intended; correct them. | ||
8 | 17 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 21 | Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com> |
12 | Message-id: 20191021134357.14266-2-peter.maydell@linaro.org | 22 | Message-id: 20210726142338.31872-5-peter.maydell@linaro.org |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | 23 | --- |
15 | hw/timer/slavio_timer.c | 12 +++++------- | 24 | docs/devel/migration.rst | 36 ++++++++++++++++++------------------ |
16 | 1 file changed, 5 insertions(+), 7 deletions(-) | 25 | 1 file changed, 18 insertions(+), 18 deletions(-) |
17 | 26 | ||
18 | diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c | 27 | diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst |
19 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/timer/slavio_timer.c | 29 | --- a/docs/devel/migration.rst |
21 | +++ b/hw/timer/slavio_timer.c | 30 | +++ b/docs/devel/migration.rst |
22 | @@ -XXX,XX +XXX,XX @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, | 31 | @@ -XXX,XX +XXX,XX @@ savevm/loadvm functionality. |
23 | // set limit, reset counter | 32 | Debugging |
24 | qemu_irq_lower(t->irq); | 33 | ========= |
25 | t->limit = val & TIMER_MAX_COUNT32; | 34 | |
26 | - if (t->timer) { | 35 | -The migration stream can be analyzed thanks to `scripts/analyze-migration.py`. |
27 | - if (t->limit == 0) { /* free-run */ | 36 | +The migration stream can be analyzed thanks to ``scripts/analyze-migration.py``. |
28 | - ptimer_set_limit(t->timer, | 37 | |
29 | - LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); | 38 | Example usage: |
30 | - } else { | 39 | |
31 | - ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 1); | 40 | @@ -XXX,XX +XXX,XX @@ Common infrastructure |
32 | - } | 41 | ===================== |
33 | + if (t->limit == 0) { /* free-run */ | 42 | |
34 | + ptimer_set_limit(t->timer, | 43 | The files, sockets or fd's that carry the migration stream are abstracted by |
35 | + LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); | 44 | -the ``QEMUFile`` type (see `migration/qemu-file.h`). In most cases this |
36 | + } else { | 45 | -is connected to a subtype of ``QIOChannel`` (see `io/`). |
37 | + ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 1); | 46 | +the ``QEMUFile`` type (see ``migration/qemu-file.h``). In most cases this |
38 | } | 47 | +is connected to a subtype of ``QIOChannel`` (see ``io/``). |
39 | } | 48 | |
40 | break; | 49 | |
50 | Saving the state of one device | ||
51 | @@ -XXX,XX +XXX,XX @@ An example (from hw/input/pckbd.c) | ||
52 | }; | ||
53 | |||
54 | We are declaring the state with name "pckbd". | ||
55 | -The `version_id` is 3, and the fields are 4 uint8_t in a KBDState structure. | ||
56 | +The ``version_id`` is 3, and the fields are 4 uint8_t in a KBDState structure. | ||
57 | We registered this with: | ||
58 | |||
59 | .. code:: c | ||
60 | |||
61 | vmstate_register(NULL, 0, &vmstate_kbd, s); | ||
62 | |||
63 | -For devices that are `qdev` based, we can register the device in the class | ||
64 | +For devices that are ``qdev`` based, we can register the device in the class | ||
65 | init function: | ||
66 | |||
67 | .. code:: c | ||
68 | @@ -XXX,XX +XXX,XX @@ another to load the state back. | ||
69 | SaveVMHandlers *ops, | ||
70 | void *opaque); | ||
71 | |||
72 | -Two functions in the ``ops`` structure are the `save_state` | ||
73 | -and `load_state` functions. Notice that `load_state` receives a version_id | ||
74 | -parameter to know what state format is receiving. `save_state` doesn't | ||
75 | +Two functions in the ``ops`` structure are the ``save_state`` | ||
76 | +and ``load_state`` functions. Notice that ``load_state`` receives a version_id | ||
77 | +parameter to know what state format is receiving. ``save_state`` doesn't | ||
78 | have a version_id parameter because it always uses the latest version. | ||
79 | |||
80 | Note that because the VMState macros still save the data in a raw | ||
81 | @@ -XXX,XX +XXX,XX @@ migration of a device, and using them breaks backward-migration | ||
82 | compatibility; in general most changes can be made by adding Subsections | ||
83 | (see above) or _TEST macros (see above) which won't break compatibility. | ||
84 | |||
85 | -Each version is associated with a series of fields saved. The `save_state` always saves | ||
86 | -the state as the newer version. But `load_state` sometimes is able to | ||
87 | +Each version is associated with a series of fields saved. The ``save_state`` always saves | ||
88 | +the state as the newer version. But ``load_state`` sometimes is able to | ||
89 | load state from an older version. | ||
90 | |||
91 | You can see that there are several version fields: | ||
92 | |||
93 | -- `version_id`: the maximum version_id supported by VMState for that device. | ||
94 | -- `minimum_version_id`: the minimum version_id that VMState is able to understand | ||
95 | +- ``version_id``: the maximum version_id supported by VMState for that device. | ||
96 | +- ``minimum_version_id``: the minimum version_id that VMState is able to understand | ||
97 | for that device. | ||
98 | -- `minimum_version_id_old`: For devices that were not able to port to vmstate, we can | ||
99 | +- ``minimum_version_id_old``: For devices that were not able to port to vmstate, we can | ||
100 | assign a function that knows how to read this old state. This field is | ||
101 | - ignored if there is no `load_state_old` handler. | ||
102 | + ignored if there is no ``load_state_old`` handler. | ||
103 | |||
104 | VMState is able to read versions from minimum_version_id to | ||
105 | version_id. And the function ``load_state_old()`` (if present) is able to | ||
106 | @@ -XXX,XX +XXX,XX @@ data and then transferred to the main structure. | ||
107 | |||
108 | If you use memory API functions that update memory layout outside | ||
109 | initialization (i.e., in response to a guest action), this is a strong | ||
110 | -indication that you need to call these functions in a `post_load` callback. | ||
111 | +indication that you need to call these functions in a ``post_load`` callback. | ||
112 | Examples of such memory API functions are: | ||
113 | |||
114 | - memory_region_add_subregion() | ||
115 | @@ -XXX,XX +XXX,XX @@ Postcopy migration with shared memory needs explicit support from the other | ||
116 | processes that share memory and from QEMU. There are restrictions on the type of | ||
117 | memory that userfault can support shared. | ||
118 | |||
119 | -The Linux kernel userfault support works on `/dev/shm` memory and on `hugetlbfs` | ||
120 | -(although the kernel doesn't provide an equivalent to `madvise(MADV_DONTNEED)` | ||
121 | +The Linux kernel userfault support works on ``/dev/shm`` memory and on ``hugetlbfs`` | ||
122 | +(although the kernel doesn't provide an equivalent to ``madvise(MADV_DONTNEED)`` | ||
123 | for hugetlbfs which may be a problem in some configurations). | ||
124 | |||
125 | The vhost-user code in QEMU supports clients that have Postcopy support, | ||
126 | -and the `vhost-user-bridge` (in `tests/`) and the DPDK package have changes | ||
127 | +and the ``vhost-user-bridge`` (in ``tests/``) and the DPDK package have changes | ||
128 | to support postcopy. | ||
129 | |||
130 | The client needs to open a userfaultfd and register the areas | ||
41 | -- | 131 | -- |
42 | 2.20.1 | 132 | 2.20.1 |
43 | 133 | ||
44 | 134 | diff view generated by jsdifflib |
1 | Switch the xilinx_timer code away from bottom-half based ptimers to | 1 | In rST markup, single backticks `like this` represent "interpreted |
---|---|---|---|
2 | the new transaction-based ptimer API. This just requires adding | 2 | text", which can be handled as a bunch of different things if tagged |
3 | begin/commit calls around the various places that modify the ptimer | 3 | with a specific "role": |
4 | state, and using the new ptimer_init() function to create the timer. | 4 | https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#interpreted-text |
5 | (the most common one for us is "reference to a URL, which gets | ||
6 | hyperlinked"). | ||
7 | |||
8 | The default "role" if none is specified is "title_reference", | ||
9 | intended for references to book or article titles, and it renders | ||
10 | into the HTML as <cite>...</cite> (usually comes out as italics). | ||
11 | |||
12 | Fix various places in the devel section of the manual which were | ||
13 | using single backticks when double backticks (for literal text) | ||
14 | were intended. | ||
5 | 15 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 19 | Message-id: 20210726142338.31872-6-peter.maydell@linaro.org |
10 | Message-id: 20191017132122.4402-3-peter.maydell@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | 20 | --- |
13 | hw/timer/xilinx_timer.c | 13 ++++++++----- | 21 | docs/devel/qgraph.rst | 8 ++++---- |
14 | 1 file changed, 8 insertions(+), 5 deletions(-) | 22 | docs/devel/tcg-plugins.rst | 14 +++++++------- |
23 | docs/devel/testing.rst | 8 ++++---- | ||
24 | 3 files changed, 15 insertions(+), 15 deletions(-) | ||
15 | 25 | ||
16 | diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c | 26 | diff --git a/docs/devel/qgraph.rst b/docs/devel/qgraph.rst |
17 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/timer/xilinx_timer.c | 28 | --- a/docs/devel/qgraph.rst |
19 | +++ b/hw/timer/xilinx_timer.c | 29 | +++ b/docs/devel/qgraph.rst |
20 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ Notes for the nodes: |
21 | #include "hw/ptimer.h" | 31 | Edges |
22 | #include "hw/qdev-properties.h" | 32 | ^^^^^^ |
23 | #include "qemu/log.h" | 33 | |
24 | -#include "qemu/main-loop.h" | 34 | -An edge relation between two nodes (drivers or machines) `X` and `Y` can be: |
25 | #include "qemu/module.h" | 35 | +An edge relation between two nodes (drivers or machines) ``X`` and ``Y`` can be: |
26 | 36 | ||
27 | #define D(x) | 37 | -- ``X CONSUMES Y``: `Y` can be plugged into `X` |
28 | @@ -XXX,XX +XXX,XX @@ | 38 | -- ``X PRODUCES Y``: `X` provides the interface `Y` |
29 | 39 | -- ``X CONTAINS Y``: `Y` is part of `X` component | |
30 | struct xlx_timer | 40 | +- ``X CONSUMES Y``: ``Y`` can be plugged into ``X`` |
31 | { | 41 | +- ``X PRODUCES Y``: ``X`` provides the interface ``Y`` |
32 | - QEMUBH *bh; | 42 | +- ``X CONTAINS Y``: ``Y`` is part of ``X`` component |
33 | ptimer_state *ptimer; | 43 | |
34 | void *parent; | 44 | Execution steps |
35 | int nr; /* for debug. */ | 45 | ^^^^^^^^^^^^^^^ |
36 | @@ -XXX,XX +XXX,XX @@ timer_read(void *opaque, hwaddr addr, unsigned int size) | 46 | diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst |
37 | return r; | 47 | index XXXXXXX..XXXXXXX 100644 |
38 | } | 48 | --- a/docs/devel/tcg-plugins.rst |
39 | 49 | +++ b/docs/devel/tcg-plugins.rst | |
40 | +/* Must be called inside ptimer transaction block */ | 50 | @@ -XXX,XX +XXX,XX @@ version they were built against. This can be done simply by:: |
41 | static void timer_enable(struct xlx_timer *xt) | 51 | QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; |
42 | { | 52 | |
43 | uint64_t count; | 53 | The core code will refuse to load a plugin that doesn't export a |
44 | @@ -XXX,XX +XXX,XX @@ timer_write(void *opaque, hwaddr addr, | 54 | -`qemu_plugin_version` symbol or if plugin version is outside of QEMU's |
45 | value &= ~TCSR_TINT; | 55 | +``qemu_plugin_version`` symbol or if plugin version is outside of QEMU's |
46 | 56 | supported range of API versions. | |
47 | xt->regs[addr] = value & 0x7ff; | 57 | |
48 | - if (value & TCSR_ENT) | 58 | -Additionally the `qemu_info_t` structure which is passed to the |
49 | + if (value & TCSR_ENT) { | 59 | -`qemu_plugin_install` method of a plugin will detail the minimum and |
50 | + ptimer_transaction_begin(xt->ptimer); | 60 | +Additionally the ``qemu_info_t`` structure which is passed to the |
51 | timer_enable(xt); | 61 | +``qemu_plugin_install`` method of a plugin will detail the minimum and |
52 | + ptimer_transaction_commit(xt->ptimer); | 62 | current API versions supported by QEMU. The API version will be |
53 | + } | 63 | incremented if new APIs are added. The minimum API version will be |
54 | break; | 64 | incremented if existing APIs are changed or removed. |
55 | 65 | @@ -XXX,XX +XXX,XX @@ Example Plugins | |
56 | default: | 66 | |
57 | @@ -XXX,XX +XXX,XX @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp) | 67 | There are a number of plugins included with QEMU and you are |
58 | 68 | encouraged to contribute your own plugins plugins upstream. There is a | |
59 | xt->parent = t; | 69 | -`contrib/plugins` directory where they can go. |
60 | xt->nr = i; | 70 | +``contrib/plugins`` directory where they can go. |
61 | - xt->bh = qemu_bh_new(timer_hit, xt); | 71 | |
62 | - xt->ptimer = ptimer_init_with_bh(xt->bh, PTIMER_POLICY_DEFAULT); | 72 | - tests/plugins |
63 | + xt->ptimer = ptimer_init(timer_hit, xt, PTIMER_POLICY_DEFAULT); | 73 | |
64 | + ptimer_transaction_begin(xt->ptimer); | 74 | These are some basic plugins that are used to test and exercise the |
65 | ptimer_set_freq(xt->ptimer, t->freq_hz); | 75 | -API during the `make check-tcg` target. |
66 | + ptimer_transaction_commit(xt->ptimer); | 76 | +API during the ``make check-tcg`` target. |
67 | } | 77 | |
68 | 78 | - contrib/plugins/hotblocks.c | |
69 | memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, "xlnx.xps-timer", | 79 | |
80 | @@ -XXX,XX +XXX,XX @@ with linux-user execution as system emulation tends to generate | ||
81 | re-translations as blocks from different programs get swapped in and | ||
82 | out of system memory. | ||
83 | |||
84 | -If your program is single-threaded you can use the `inline` option for | ||
85 | +If your program is single-threaded you can use the ``inline`` option for | ||
86 | slightly faster (but not thread safe) counters. | ||
87 | |||
88 | Example:: | ||
89 | @@ -XXX,XX +XXX,XX @@ which will lead to a sorted list after the class breakdown:: | ||
90 | ... | ||
91 | |||
92 | To find the argument shorthand for the class you need to examine the | ||
93 | -source code of the plugin at the moment, specifically the `*opt` | ||
94 | +source code of the plugin at the moment, specifically the ``*opt`` | ||
95 | argument in the InsnClassExecCount tables. | ||
96 | |||
97 | - contrib/plugins/lockstep.c | ||
98 | diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/docs/devel/testing.rst | ||
101 | +++ b/docs/devel/testing.rst | ||
102 | @@ -XXX,XX +XXX,XX @@ The base test class has also support for tests with more than one | ||
103 | QEMUMachine. The way to get machines is through the ``self.get_vm()`` | ||
104 | method which will return a QEMUMachine instance. The ``self.get_vm()`` | ||
105 | method accepts arguments that will be passed to the QEMUMachine creation | ||
106 | -and also an optional `name` attribute so you can identify a specific | ||
107 | +and also an optional ``name`` attribute so you can identify a specific | ||
108 | machine and get it more than once through the tests methods. A simple | ||
109 | and hypothetical example follows: | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ Here is a list of the most used variables: | ||
112 | AVOCADO_ALLOW_LARGE_STORAGE | ||
113 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
114 | Tests which are going to fetch or produce assets considered *large* are not | ||
115 | -going to run unless that `AVOCADO_ALLOW_LARGE_STORAGE=1` is exported on | ||
116 | +going to run unless that ``AVOCADO_ALLOW_LARGE_STORAGE=1`` is exported on | ||
117 | the environment. | ||
118 | |||
119 | The definition of *large* is a bit arbitrary here, but it usually means an | ||
120 | @@ -XXX,XX +XXX,XX @@ skipped by default. The definition of *not safe* is also arbitrary but | ||
121 | usually it means a blob which either its source or build process aren't | ||
122 | public available. | ||
123 | |||
124 | -You should export `AVOCADO_ALLOW_UNTRUSTED_CODE=1` on the environment in | ||
125 | +You should export ``AVOCADO_ALLOW_UNTRUSTED_CODE=1`` on the environment in | ||
126 | order to allow tests which make use of those kind of assets. | ||
127 | |||
128 | AVOCADO_TIMEOUT_EXPECTED | ||
129 | @@ -XXX,XX +XXX,XX @@ property defined in the test class, for further details:: | ||
130 | Even though the timeout can be set by the test developer, there are some tests | ||
131 | that may not have a well-defined limit of time to finish under certain | ||
132 | conditions. For example, tests that take longer to execute when QEMU is | ||
133 | -compiled with debug flags. Therefore, the `AVOCADO_TIMEOUT_EXPECTED` variable | ||
134 | +compiled with debug flags. Therefore, the ``AVOCADO_TIMEOUT_EXPECTED`` variable | ||
135 | has been used to determine whether those tests should run or not. | ||
136 | |||
137 | GITLAB_CI | ||
70 | -- | 138 | -- |
71 | 2.20.1 | 139 | 2.20.1 |
72 | 140 | ||
73 | 141 | diff view generated by jsdifflib |
1 | Switch the fsl_etsec code away from bottom-half based ptimers to | 1 | In rST markup, single backticks `like this` represent "interpreted |
---|---|---|---|
2 | the new transaction-based ptimer API. This just requires adding | 2 | text", which can be handled as a bunch of different things if tagged |
3 | begin/commit calls around the various places that modify the ptimer | 3 | with a specific "role": |
4 | state, and using the new ptimer_init() function to create the timer. | 4 | https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#interpreted-text |
5 | (the most common one for us is "reference to a URL, which gets | ||
6 | hyperlinked"). | ||
7 | |||
8 | The default "role" if none is specified is "title_reference", | ||
9 | intended for references to book or article titles, and it renders | ||
10 | into the HTML as <cite>...</cite> (usually comes out as italics). | ||
11 | |||
12 | To format a literal (generally rendered as fixed-width font), | ||
13 | double-backticks are required. | ||
14 | |||
15 | protvirt.rst consistently uses single backticks when double backticks | ||
16 | are required; correct it. | ||
5 | 17 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 21 | Acked-by: Cornelia Huck <cohuck@redhat.com> |
10 | Message-id: 20191017132122.4402-2-peter.maydell@linaro.org | 22 | Message-id: 20210726142338.31872-7-peter.maydell@linaro.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | 23 | --- |
13 | hw/net/fsl_etsec/etsec.h | 1 - | 24 | docs/system/s390x/protvirt.rst | 12 ++++++------ |
14 | hw/net/fsl_etsec/etsec.c | 9 +++++---- | 25 | 1 file changed, 6 insertions(+), 6 deletions(-) |
15 | 2 files changed, 5 insertions(+), 5 deletions(-) | ||
16 | 26 | ||
17 | diff --git a/hw/net/fsl_etsec/etsec.h b/hw/net/fsl_etsec/etsec.h | 27 | diff --git a/docs/system/s390x/protvirt.rst b/docs/system/s390x/protvirt.rst |
18 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/net/fsl_etsec/etsec.h | 29 | --- a/docs/system/s390x/protvirt.rst |
20 | +++ b/hw/net/fsl_etsec/etsec.h | 30 | +++ b/docs/system/s390x/protvirt.rst |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct eTSEC { | 31 | @@ -XXX,XX +XXX,XX @@ Prerequisites |
22 | uint16_t phy_control; | 32 | To run PVMs, a machine with the Protected Virtualization feature, as |
23 | 33 | indicated by the Ultravisor Call facility (stfle bit 158), is | |
24 | /* Polling */ | 34 | required. The Ultravisor needs to be initialized at boot by setting |
25 | - QEMUBH *bh; | 35 | -`prot_virt=1` on the host's kernel command line. |
26 | struct ptimer_state *ptimer; | 36 | +``prot_virt=1`` on the host's kernel command line. |
27 | 37 | ||
28 | /* Whether we should flush the rx queue when buffer becomes available. */ | 38 | Running PVMs requires using the KVM hypervisor. |
29 | diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c | 39 | |
30 | index XXXXXXX..XXXXXXX 100644 | 40 | -If those requirements are met, the capability `KVM_CAP_S390_PROTECTED` |
31 | --- a/hw/net/fsl_etsec/etsec.c | 41 | +If those requirements are met, the capability ``KVM_CAP_S390_PROTECTED`` |
32 | +++ b/hw/net/fsl_etsec/etsec.c | 42 | will indicate that KVM can support PVMs on that LPAR. |
33 | @@ -XXX,XX +XXX,XX @@ | 43 | |
34 | #include "etsec.h" | 44 | |
35 | #include "registers.h" | 45 | @@ -XXX,XX +XXX,XX @@ Running a Protected Virtual Machine |
36 | #include "qemu/log.h" | 46 | ----------------------------------- |
37 | -#include "qemu/main-loop.h" | 47 | |
38 | #include "qemu/module.h" | 48 | To run a PVM you will need to select a CPU model which includes the |
39 | 49 | -`Unpack facility` (stfle bit 161 represented by the feature | |
40 | /* #define HEX_DUMP */ | 50 | -`unpack`/`S390_FEAT_UNPACK`), and add these options to the command line:: |
41 | @@ -XXX,XX +XXX,XX @@ static void write_dmactrl(eTSEC *etsec, | 51 | +``Unpack facility`` (stfle bit 161 represented by the feature |
42 | 52 | +``unpack``/``S390_FEAT_UNPACK``), and add these options to the command line:: | |
43 | if (!(value & DMACTRL_WOP)) { | 53 | |
44 | /* Start polling */ | 54 | -object s390-pv-guest,id=pv0 \ |
45 | + ptimer_transaction_begin(etsec->ptimer); | 55 | -machine confidential-guest-support=pv0 |
46 | ptimer_stop(etsec->ptimer); | 56 | |
47 | ptimer_set_count(etsec->ptimer, 1); | 57 | Adding these options will: |
48 | ptimer_run(etsec->ptimer, 1); | 58 | |
49 | + ptimer_transaction_commit(etsec->ptimer); | 59 | -* Ensure the `unpack` facility is available |
50 | } | 60 | +* Ensure the ``unpack`` facility is available |
51 | } | 61 | * Enable the IOMMU by default for all I/O devices |
52 | 62 | * Initialize the PV mechanism | |
53 | @@ -XXX,XX +XXX,XX @@ static void etsec_realize(DeviceState *dev, Error **errp) | 63 | |
54 | object_get_typename(OBJECT(dev)), dev->id, etsec); | 64 | @@ -XXX,XX +XXX,XX @@ from the disk boot. This memory layout includes the encrypted |
55 | qemu_format_nic_info_str(qemu_get_queue(etsec->nic), etsec->conf.macaddr.a); | 65 | components (kernel, initrd, cmdline), the stage3a loader and |
56 | 66 | metadata. In case this boot method is used, the command line | |
57 | - | 67 | options -initrd and -cmdline are ineffective. The preparation of a PVM |
58 | - etsec->bh = qemu_bh_new(etsec_timer_hit, etsec); | 68 | -image is done via the `genprotimg` tool from the s390-tools |
59 | - etsec->ptimer = ptimer_init_with_bh(etsec->bh, PTIMER_POLICY_DEFAULT); | 69 | +image is done via the ``genprotimg`` tool from the s390-tools |
60 | + etsec->ptimer = ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_DEFAULT); | 70 | collection. |
61 | + ptimer_transaction_begin(etsec->ptimer); | ||
62 | ptimer_set_freq(etsec->ptimer, 100); | ||
63 | + ptimer_transaction_commit(etsec->ptimer); | ||
64 | } | ||
65 | |||
66 | static void etsec_instance_init(Object *obj) | ||
67 | -- | 71 | -- |
68 | 2.20.1 | 72 | 2.20.1 |
69 | 73 | ||
70 | 74 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | In rST markup, single backticks `like this` represent "interpreted |
---|---|---|---|
2 | 2 | text", which can be handled as a bunch of different things if tagged | |
3 | Introduce cpu properties to give fine control over SVE vector lengths. | 3 | with a specific "role": |
4 | We introduce a property for each valid length up to the current | 4 | https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#interpreted-text |
5 | maximum supported, which is 2048-bits. The properties are named, e.g. | 5 | (the most common one for us is "reference to a URL, which gets |
6 | sve128, sve256, sve384, sve512, ..., where the number is the number of | 6 | hyperlinked"). |
7 | bits. See the updates to docs/arm-cpu-features.rst for a description | 7 | |
8 | of the semantics and for example uses. | 8 | The default "role" if none is specified is "title_reference", |
9 | 9 | intended for references to book or article titles, and it renders | |
10 | Note, as sve-max-vq is still present and we'd like to be able to | 10 | into the HTML as <cite>...</cite> (usually comes out as italics). |
11 | support qmp_query_cpu_model_expansion with guests launched with e.g. | 11 | |
12 | -cpu max,sve-max-vq=8 on their command lines, then we do allow | 12 | To format a literal (generally rendered as fixed-width font), |
13 | sve-max-vq and sve<N> properties to be provided at the same time, but | 13 | double-backticks are required. |
14 | this is not recommended, and is why sve-max-vq is not mentioned in the | 14 | |
15 | document. If sve-max-vq is provided then it enables all lengths smaller | 15 | cpu-features.rst consistently uses single backticks when double backticks |
16 | than and including the max and disables all lengths larger. It also has | 16 | are required; correct it. |
17 | the side-effect that no larger lengths may be enabled and that the max | 17 | |
18 | itself cannot be disabled. Smaller non-power-of-two lengths may, | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | however, be disabled, e.g. -cpu max,sve-max-vq=4,sve384=off provides a | ||
20 | guest the vector lengths 128, 256, and 512 bits. | ||
21 | |||
22 | This patch has been co-authored with Richard Henderson, who reworked | ||
23 | the target/arm/cpu64.c changes in order to push all the validation and | ||
24 | auto-enabling/disabling steps into the finalizer, resulting in a nice | ||
25 | LOC reduction. | ||
26 | |||
27 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
28 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
29 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
30 | Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | 21 | Message-id: 20210726142338.31872-8-peter.maydell@linaro.org |
31 | Reviewed-by: Beata Michalska <beata.michalska@linaro.org> | ||
32 | Message-id: 20191024121808.9612-5-drjones@redhat.com | ||
33 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
34 | --- | 22 | --- |
35 | include/qemu/bitops.h | 1 + | 23 | docs/system/arm/cpu-features.rst | 116 +++++++++++++++---------------- |
36 | target/arm/cpu.h | 19 ++++ | 24 | 1 file changed, 58 insertions(+), 58 deletions(-) |
37 | target/arm/cpu.c | 19 ++++ | 25 | |
38 | target/arm/cpu64.c | 192 ++++++++++++++++++++++++++++++++++++- | 26 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst |
39 | target/arm/helper.c | 10 +- | ||
40 | target/arm/monitor.c | 12 +++ | ||
41 | tests/arm-cpu-features.c | 194 ++++++++++++++++++++++++++++++++++++++ | ||
42 | docs/arm-cpu-features.rst | 168 +++++++++++++++++++++++++++++++-- | ||
43 | 8 files changed, 606 insertions(+), 9 deletions(-) | ||
44 | |||
45 | diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/include/qemu/bitops.h | 28 | --- a/docs/system/arm/cpu-features.rst |
48 | +++ b/include/qemu/bitops.h | 29 | +++ b/docs/system/arm/cpu-features.rst |
49 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ is the Performance Monitoring Unit (PMU). CPU types such as the |
50 | #define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) | 31 | Cortex-A15 and the Cortex-A57, which respectively implement Arm |
51 | 32 | architecture reference manuals ARMv7-A and ARMv8-A, may both optionally | |
52 | #define BIT(nr) (1UL << (nr)) | 33 | implement PMUs. For example, if a user wants to use a Cortex-A15 without |
53 | +#define BIT_ULL(nr) (1ULL << (nr)) | 34 | -a PMU, then the `-cpu` parameter should contain `pmu=off` on the QEMU |
54 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | 35 | -command line, i.e. `-cpu cortex-a15,pmu=off`. |
55 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) | 36 | +a PMU, then the ``-cpu`` parameter should contain ``pmu=off`` on the QEMU |
56 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) | 37 | +command line, i.e. ``-cpu cortex-a15,pmu=off``. |
57 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 38 | |
58 | index XXXXXXX..XXXXXXX 100644 | 39 | As not all CPU types support all optional CPU features, then whether or |
59 | --- a/target/arm/cpu.h | 40 | not a CPU property exists depends on the CPU type. For example, CPUs |
60 | +++ b/target/arm/cpu.h | 41 | that implement the ARMv8-A architecture reference manual may optionally |
61 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 42 | support the AArch32 CPU feature, which may be enabled by disabling the |
62 | 43 | -`aarch64` CPU property. A CPU type such as the Cortex-A15, which does | |
63 | #ifdef TARGET_AARCH64 | 44 | -not implement ARMv8-A, will not have the `aarch64` CPU property. |
64 | # define ARM_MAX_VQ 16 | 45 | +``aarch64`` CPU property. A CPU type such as the Cortex-A15, which does |
65 | +void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | 46 | +not implement ARMv8-A, will not have the ``aarch64`` CPU property. |
66 | +uint32_t arm_cpu_vq_map_next_smaller(ARMCPU *cpu, uint32_t vq); | 47 | |
67 | #else | 48 | QEMU's support may be limited for some CPU features, only partially |
68 | # define ARM_MAX_VQ 1 | 49 | supporting the feature or only supporting the feature under certain |
69 | +static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { } | 50 | -configurations. For example, the `aarch64` CPU feature, which, when |
70 | +static inline uint32_t arm_cpu_vq_map_next_smaller(ARMCPU *cpu, uint32_t vq) | 51 | +configurations. For example, the ``aarch64`` CPU feature, which, when |
71 | +{ return 0; } | 52 | disabled, enables the optional AArch32 CPU feature, is only supported |
72 | #endif | 53 | when using the KVM accelerator and when running on a host CPU type that |
73 | 54 | -supports the feature. While `aarch64` currently only works with KVM, | |
74 | typedef struct ARMVectorReg { | 55 | +supports the feature. While ``aarch64`` currently only works with KVM, |
75 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 56 | it could work with TCG. CPU features that are specific to KVM are |
76 | 57 | prefixed with "kvm-" and are described in "KVM VCPU Features". | |
77 | /* Used to set the maximum vector length the cpu will support. */ | 58 | |
78 | uint32_t sve_max_vq; | 59 | @@ -XXX,XX +XXX,XX @@ CPU Feature Probing |
79 | + | 60 | =================== |
80 | + /* | 61 | |
81 | + * In sve_vq_map each set bit is a supported vector length of | 62 | Determining which CPU features are available and functional for a given |
82 | + * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector | 63 | -CPU type is possible with the `query-cpu-model-expansion` QMP command. |
83 | + * length in quadwords. | 64 | -Below are some examples where `scripts/qmp/qmp-shell` (see the top comment |
84 | + * | 65 | +CPU type is possible with the ``query-cpu-model-expansion`` QMP command. |
85 | + * While processing properties during initialization, corresponding | 66 | +Below are some examples where ``scripts/qmp/qmp-shell`` (see the top comment |
86 | + * sve_vq_init bits are set for bits in sve_vq_map that have been | 67 | block in the script for usage) is used to issue the QMP commands. |
87 | + * set by properties. | 68 | |
88 | + */ | 69 | -1. Determine which CPU features are available for the `max` CPU type |
89 | + DECLARE_BITMAP(sve_vq_map, ARM_MAX_VQ); | 70 | - (Note, we started QEMU with qemu-system-aarch64, so `max` is |
90 | + DECLARE_BITMAP(sve_vq_init, ARM_MAX_VQ); | 71 | +1. Determine which CPU features are available for the ``max`` CPU type |
91 | }; | 72 | + (Note, we started QEMU with qemu-system-aarch64, so ``max`` is |
92 | 73 | implementing the ARMv8-A reference manual in this case):: | |
93 | void arm_cpu_post_init(Object *obj); | 74 | |
94 | @@ -XXX,XX +XXX,XX @@ static inline int arm_feature(CPUARMState *env, int feature) | 75 | (QEMU) query-cpu-model-expansion type=full model={"name":"max"} |
95 | return (env->features & (1ULL << feature)) != 0; | ||
96 | } | ||
97 | |||
98 | +void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); | ||
99 | + | ||
100 | #if !defined(CONFIG_USER_ONLY) | ||
101 | /* Return true if exception levels below EL3 are in secure state, | ||
102 | * or would be following an exception return to that level. | ||
103 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/cpu.c | ||
106 | +++ b/target/arm/cpu.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj) | ||
108 | #endif | ||
109 | } | ||
110 | |||
111 | +void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | ||
112 | +{ | ||
113 | + Error *local_err = NULL; | ||
114 | + | ||
115 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
116 | + arm_cpu_sve_finalize(cpu, &local_err); | ||
117 | + if (local_err != NULL) { | ||
118 | + error_propagate(errp, local_err); | ||
119 | + return; | ||
120 | + } | ||
121 | + } | ||
122 | +} | ||
123 | + | ||
124 | static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
125 | { | ||
126 | CPUState *cs = CPU(dev); | ||
127 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
128 | return; | ||
129 | } | ||
130 | |||
131 | + arm_cpu_finalize_features(cpu, &local_err); | ||
132 | + if (local_err != NULL) { | ||
133 | + error_propagate(errp, local_err); | ||
134 | + return; | ||
135 | + } | ||
136 | + | ||
137 | if (arm_feature(env, ARM_FEATURE_AARCH64) && | ||
138 | cpu->has_vfp != cpu->has_neon) { | ||
139 | /* | ||
140 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/target/arm/cpu64.c | ||
143 | +++ b/target/arm/cpu64.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
145 | define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
146 | } | ||
147 | |||
148 | +void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
149 | +{ | ||
150 | + /* | ||
151 | + * If any vector lengths are explicitly enabled with sve<N> properties, | ||
152 | + * then all other lengths are implicitly disabled. If sve-max-vq is | ||
153 | + * specified then it is the same as explicitly enabling all lengths | ||
154 | + * up to and including the specified maximum, which means all larger | ||
155 | + * lengths will be implicitly disabled. If no sve<N> properties | ||
156 | + * are enabled and sve-max-vq is not specified, then all lengths not | ||
157 | + * explicitly disabled will be enabled. Additionally, all power-of-two | ||
158 | + * vector lengths less than the maximum enabled length will be | ||
159 | + * automatically enabled and all vector lengths larger than the largest | ||
160 | + * disabled power-of-two vector length will be automatically disabled. | ||
161 | + * Errors are generated if the user provided input that interferes with | ||
162 | + * any of the above. Finally, if SVE is not disabled, then at least one | ||
163 | + * vector length must be enabled. | ||
164 | + */ | ||
165 | + DECLARE_BITMAP(tmp, ARM_MAX_VQ); | ||
166 | + uint32_t vq, max_vq = 0; | ||
167 | + | ||
168 | + /* | ||
169 | + * Process explicit sve<N> properties. | ||
170 | + * From the properties, sve_vq_map<N> implies sve_vq_init<N>. | ||
171 | + * Check first for any sve<N> enabled. | ||
172 | + */ | ||
173 | + if (!bitmap_empty(cpu->sve_vq_map, ARM_MAX_VQ)) { | ||
174 | + max_vq = find_last_bit(cpu->sve_vq_map, ARM_MAX_VQ) + 1; | ||
175 | + | ||
176 | + if (cpu->sve_max_vq && max_vq > cpu->sve_max_vq) { | ||
177 | + error_setg(errp, "cannot enable sve%d", max_vq * 128); | ||
178 | + error_append_hint(errp, "sve%d is larger than the maximum vector " | ||
179 | + "length, sve-max-vq=%d (%d bits)\n", | ||
180 | + max_vq * 128, cpu->sve_max_vq, | ||
181 | + cpu->sve_max_vq * 128); | ||
182 | + return; | ||
183 | + } | ||
184 | + | ||
185 | + /* Propagate enabled bits down through required powers-of-two. */ | ||
186 | + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
187 | + if (!test_bit(vq - 1, cpu->sve_vq_init)) { | ||
188 | + set_bit(vq - 1, cpu->sve_vq_map); | ||
189 | + } | ||
190 | + } | ||
191 | + } else if (cpu->sve_max_vq == 0) { | ||
192 | + /* | ||
193 | + * No explicit bits enabled, and no implicit bits from sve-max-vq. | ||
194 | + */ | ||
195 | + if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
196 | + /* SVE is disabled and so are all vector lengths. Good. */ | ||
197 | + return; | ||
198 | + } | ||
199 | + | ||
200 | + /* Disabling a power-of-two disables all larger lengths. */ | ||
201 | + if (test_bit(0, cpu->sve_vq_init)) { | ||
202 | + error_setg(errp, "cannot disable sve128"); | ||
203 | + error_append_hint(errp, "Disabling sve128 results in all vector " | ||
204 | + "lengths being disabled.\n"); | ||
205 | + error_append_hint(errp, "With SVE enabled, at least one vector " | ||
206 | + "length must be enabled.\n"); | ||
207 | + return; | ||
208 | + } | ||
209 | + for (vq = 2; vq <= ARM_MAX_VQ; vq <<= 1) { | ||
210 | + if (test_bit(vq - 1, cpu->sve_vq_init)) { | ||
211 | + break; | ||
212 | + } | ||
213 | + } | ||
214 | + max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | ||
215 | + | ||
216 | + bitmap_complement(cpu->sve_vq_map, cpu->sve_vq_init, max_vq); | ||
217 | + max_vq = find_last_bit(cpu->sve_vq_map, max_vq) + 1; | ||
218 | + } | ||
219 | + | ||
220 | + /* | ||
221 | + * Process the sve-max-vq property. | ||
222 | + * Note that we know from the above that no bit above | ||
223 | + * sve-max-vq is currently set. | ||
224 | + */ | ||
225 | + if (cpu->sve_max_vq != 0) { | ||
226 | + max_vq = cpu->sve_max_vq; | ||
227 | + | ||
228 | + if (!test_bit(max_vq - 1, cpu->sve_vq_map) && | ||
229 | + test_bit(max_vq - 1, cpu->sve_vq_init)) { | ||
230 | + error_setg(errp, "cannot disable sve%d", max_vq * 128); | ||
231 | + error_append_hint(errp, "The maximum vector length must be " | ||
232 | + "enabled, sve-max-vq=%d (%d bits)\n", | ||
233 | + max_vq, max_vq * 128); | ||
234 | + return; | ||
235 | + } | ||
236 | + | ||
237 | + /* Set all bits not explicitly set within sve-max-vq. */ | ||
238 | + bitmap_complement(tmp, cpu->sve_vq_init, max_vq); | ||
239 | + bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); | ||
240 | + } | ||
241 | + | ||
242 | + /* | ||
243 | + * We should know what max-vq is now. Also, as we're done | ||
244 | + * manipulating sve-vq-map, we ensure any bits above max-vq | ||
245 | + * are clear, just in case anybody looks. | ||
246 | + */ | ||
247 | + assert(max_vq != 0); | ||
248 | + bitmap_clear(cpu->sve_vq_map, max_vq, ARM_MAX_VQ - max_vq); | ||
249 | + | ||
250 | + /* Ensure all required powers-of-two are enabled. */ | ||
251 | + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
252 | + if (!test_bit(vq - 1, cpu->sve_vq_map)) { | ||
253 | + error_setg(errp, "cannot disable sve%d", vq * 128); | ||
254 | + error_append_hint(errp, "sve%d is required as it " | ||
255 | + "is a power-of-two length smaller than " | ||
256 | + "the maximum, sve%d\n", | ||
257 | + vq * 128, max_vq * 128); | ||
258 | + return; | ||
259 | + } | ||
260 | + } | ||
261 | + | ||
262 | + /* | ||
263 | + * Now that we validated all our vector lengths, the only question | ||
264 | + * left to answer is if we even want SVE at all. | ||
265 | + */ | ||
266 | + if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
267 | + error_setg(errp, "cannot enable sve%d", max_vq * 128); | ||
268 | + error_append_hint(errp, "SVE must be enabled to enable vector " | ||
269 | + "lengths.\n"); | ||
270 | + error_append_hint(errp, "Add sve=on to the CPU property list.\n"); | ||
271 | + return; | ||
272 | + } | ||
273 | + | ||
274 | + /* From now on sve_max_vq is the actual maximum supported length. */ | ||
275 | + cpu->sve_max_vq = max_vq; | ||
276 | +} | ||
277 | + | ||
278 | +uint32_t arm_cpu_vq_map_next_smaller(ARMCPU *cpu, uint32_t vq) | ||
279 | +{ | ||
280 | + uint32_t bitnum; | ||
281 | + | ||
282 | + /* | ||
283 | + * We allow vq == ARM_MAX_VQ + 1 to be input because the caller may want | ||
284 | + * to find the maximum vq enabled, which may be ARM_MAX_VQ, but this | ||
285 | + * function always returns the next smaller than the input. | ||
286 | + */ | ||
287 | + assert(vq && vq <= ARM_MAX_VQ + 1); | ||
288 | + | ||
289 | + bitnum = find_last_bit(cpu->sve_vq_map, vq - 1); | ||
290 | + return bitnum == vq - 1 ? 0 : bitnum + 1; | ||
291 | +} | ||
292 | + | ||
293 | static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
294 | void *opaque, Error **errp) | ||
295 | { | ||
296 | @@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
297 | error_propagate(errp, err); | ||
298 | } | ||
299 | |||
300 | +static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
301 | + void *opaque, Error **errp) | ||
302 | +{ | ||
303 | + ARMCPU *cpu = ARM_CPU(obj); | ||
304 | + uint32_t vq = atoi(&name[3]) / 128; | ||
305 | + bool value; | ||
306 | + | ||
307 | + /* All vector lengths are disabled when SVE is off. */ | ||
308 | + if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
309 | + value = false; | ||
310 | + } else { | ||
311 | + value = test_bit(vq - 1, cpu->sve_vq_map); | ||
312 | + } | ||
313 | + visit_type_bool(v, name, &value, errp); | ||
314 | +} | ||
315 | + | ||
316 | +static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
317 | + void *opaque, Error **errp) | ||
318 | +{ | ||
319 | + ARMCPU *cpu = ARM_CPU(obj); | ||
320 | + uint32_t vq = atoi(&name[3]) / 128; | ||
321 | + Error *err = NULL; | ||
322 | + bool value; | ||
323 | + | ||
324 | + visit_type_bool(v, name, &value, &err); | ||
325 | + if (err) { | ||
326 | + error_propagate(errp, err); | ||
327 | + return; | ||
328 | + } | ||
329 | + | ||
330 | + if (value) { | ||
331 | + set_bit(vq - 1, cpu->sve_vq_map); | ||
332 | + } else { | ||
333 | + clear_bit(vq - 1, cpu->sve_vq_map); | ||
334 | + } | ||
335 | + set_bit(vq - 1, cpu->sve_vq_init); | ||
336 | +} | ||
337 | + | ||
338 | static void cpu_arm_get_sve(Object *obj, Visitor *v, const char *name, | ||
339 | void *opaque, Error **errp) | ||
340 | { | ||
341 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, | ||
342 | static void aarch64_max_initfn(Object *obj) | ||
343 | { | ||
344 | ARMCPU *cpu = ARM_CPU(obj); | ||
345 | + uint32_t vq; | ||
346 | |||
347 | if (kvm_enabled()) { | ||
348 | kvm_arm_set_cpu_features_from_host(cpu); | ||
349 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
350 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
351 | #endif | ||
352 | |||
353 | - cpu->sve_max_vq = ARM_MAX_VQ; | ||
354 | object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | ||
355 | cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); | ||
356 | object_property_add(obj, "sve", "bool", cpu_arm_get_sve, | ||
357 | cpu_arm_set_sve, NULL, NULL, &error_fatal); | ||
358 | + | ||
359 | + for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
360 | + char name[8]; | ||
361 | + sprintf(name, "sve%d", vq * 128); | ||
362 | + object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
363 | + cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); | ||
364 | + } | ||
365 | } | ||
366 | } | ||
367 | |||
368 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
369 | index XXXXXXX..XXXXXXX 100644 | ||
370 | --- a/target/arm/helper.c | ||
371 | +++ b/target/arm/helper.c | ||
372 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | +static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | ||
377 | +{ | ||
378 | + uint32_t start_vq = (start_len & 0xf) + 1; | ||
379 | + | ||
380 | + return arm_cpu_vq_map_next_smaller(cpu, start_vq + 1) - 1; | ||
381 | +} | ||
382 | + | ||
383 | /* | ||
384 | * Given that SVE is enabled, return the vector length for EL. | ||
385 | */ | ||
386 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) | ||
387 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
388 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | ||
389 | } | ||
390 | - return zcr_len; | ||
391 | + | ||
392 | + return sve_zcr_get_valid_len(cpu, zcr_len); | ||
393 | } | ||
394 | |||
395 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
396 | diff --git a/target/arm/monitor.c b/target/arm/monitor.c | ||
397 | index XXXXXXX..XXXXXXX 100644 | ||
398 | --- a/target/arm/monitor.c | ||
399 | +++ b/target/arm/monitor.c | ||
400 | @@ -XXX,XX +XXX,XX @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp) | ||
401 | return head; | ||
402 | } | ||
403 | |||
404 | +QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16); | ||
405 | + | ||
406 | /* | ||
407 | * These are cpu model features we want to advertise. The order here | ||
408 | * matters as this is the order in which qmp_query_cpu_model_expansion | ||
409 | @@ -XXX,XX +XXX,XX @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp) | ||
410 | */ | ||
411 | static const char *cpu_model_advertised_features[] = { | ||
412 | "aarch64", "pmu", "sve", | ||
413 | + "sve128", "sve256", "sve384", "sve512", | ||
414 | + "sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280", | ||
415 | + "sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048", | ||
416 | NULL | ||
417 | }; | ||
418 | |||
419 | @@ -XXX,XX +XXX,XX @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, | ||
420 | if (!err) { | ||
421 | visit_check_struct(visitor, &err); | ||
422 | } | ||
423 | + if (!err) { | ||
424 | + arm_cpu_finalize_features(ARM_CPU(obj), &err); | ||
425 | + } | ||
426 | visit_end_struct(visitor, NULL); | ||
427 | visit_free(visitor); | ||
428 | if (err) { | ||
429 | @@ -XXX,XX +XXX,XX @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, | ||
430 | error_propagate(errp, err); | ||
431 | return NULL; | ||
432 | } | ||
433 | + } else { | ||
434 | + Error *err = NULL; | ||
435 | + arm_cpu_finalize_features(ARM_CPU(obj), &err); | ||
436 | + assert(err == NULL); | ||
437 | } | ||
438 | |||
439 | expansion_info = g_new0(CpuModelExpansionInfo, 1); | ||
440 | diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c | ||
441 | index XXXXXXX..XXXXXXX 100644 | ||
442 | --- a/tests/arm-cpu-features.c | ||
443 | +++ b/tests/arm-cpu-features.c | ||
444 | @@ -XXX,XX +XXX,XX @@ | ||
445 | * See the COPYING file in the top-level directory. | ||
446 | */ | ||
447 | #include "qemu/osdep.h" | ||
448 | +#include "qemu/bitops.h" | ||
449 | #include "libqtest.h" | ||
450 | #include "qapi/qmp/qdict.h" | ||
451 | #include "qapi/qmp/qjson.h" | ||
452 | |||
453 | +/* | ||
454 | + * We expect the SVE max-vq to be 16. Also it must be <= 64 | ||
455 | + * for our test code, otherwise 'vls' can't just be a uint64_t. | ||
456 | + */ | ||
457 | +#define SVE_MAX_VQ 16 | ||
458 | + | ||
459 | #define MACHINE "-machine virt,gic-version=max " | ||
460 | #define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ | ||
461 | "'arguments': { 'type': 'full', " | ||
462 | @@ -XXX,XX +XXX,XX @@ static void assert_bad_props(QTestState *qts, const char *cpu_type) | ||
463 | qobject_unref(resp); | ||
464 | } | ||
465 | |||
466 | +static uint64_t resp_get_sve_vls(QDict *resp) | ||
467 | +{ | ||
468 | + QDict *props; | ||
469 | + const QDictEntry *e; | ||
470 | + uint64_t vls = 0; | ||
471 | + int n = 0; | ||
472 | + | ||
473 | + g_assert(resp); | ||
474 | + g_assert(resp_has_props(resp)); | ||
475 | + | ||
476 | + props = resp_get_props(resp); | ||
477 | + | ||
478 | + for (e = qdict_first(props); e; e = qdict_next(props, e)) { | ||
479 | + if (strlen(e->key) > 3 && !strncmp(e->key, "sve", 3) && | ||
480 | + g_ascii_isdigit(e->key[3])) { | ||
481 | + char *endptr; | ||
482 | + int bits; | ||
483 | + | ||
484 | + bits = g_ascii_strtoll(&e->key[3], &endptr, 10); | ||
485 | + if (!bits || *endptr != '\0') { | ||
486 | + continue; | ||
487 | + } | ||
488 | + | ||
489 | + if (qdict_get_bool(props, e->key)) { | ||
490 | + vls |= BIT_ULL((bits / 128) - 1); | ||
491 | + } | ||
492 | + ++n; | ||
493 | + } | ||
494 | + } | ||
495 | + | ||
496 | + g_assert(n == SVE_MAX_VQ); | ||
497 | + | ||
498 | + return vls; | ||
499 | +} | ||
500 | + | ||
501 | +#define assert_sve_vls(qts, cpu_type, expected_vls, fmt, ...) \ | ||
502 | +({ \ | ||
503 | + QDict *_resp = do_query(qts, cpu_type, fmt, ##__VA_ARGS__); \ | ||
504 | + g_assert(_resp); \ | ||
505 | + g_assert(resp_has_props(_resp)); \ | ||
506 | + g_assert(resp_get_sve_vls(_resp) == expected_vls); \ | ||
507 | + qobject_unref(_resp); \ | ||
508 | +}) | ||
509 | + | ||
510 | +static void sve_tests_default(QTestState *qts, const char *cpu_type) | ||
511 | +{ | ||
512 | + /* | ||
513 | + * With no sve-max-vq or sve<N> properties on the command line | ||
514 | + * the default is to have all vector lengths enabled. This also | ||
515 | + * tests that 'sve' is 'on' by default. | ||
516 | + */ | ||
517 | + assert_sve_vls(qts, cpu_type, BIT_ULL(SVE_MAX_VQ) - 1, NULL); | ||
518 | + | ||
519 | + /* With SVE off, all vector lengths should also be off. */ | ||
520 | + assert_sve_vls(qts, cpu_type, 0, "{ 'sve': false }"); | ||
521 | + | ||
522 | + /* With SVE on, we must have at least one vector length enabled. */ | ||
523 | + assert_error(qts, cpu_type, "cannot disable sve128", "{ 'sve128': false }"); | ||
524 | + | ||
525 | + /* Basic enable/disable tests. */ | ||
526 | + assert_sve_vls(qts, cpu_type, 0x7, "{ 'sve384': true }"); | ||
527 | + assert_sve_vls(qts, cpu_type, ((BIT_ULL(SVE_MAX_VQ) - 1) & ~BIT_ULL(2)), | ||
528 | + "{ 'sve384': false }"); | ||
529 | + | ||
530 | + /* | ||
531 | + * --------------------------------------------------------------------- | ||
532 | + * power-of-two(vq) all-power- can can | ||
533 | + * of-two(< vq) enable disable | ||
534 | + * --------------------------------------------------------------------- | ||
535 | + * vq < max_vq no MUST* yes yes | ||
536 | + * vq < max_vq yes MUST* yes no | ||
537 | + * --------------------------------------------------------------------- | ||
538 | + * vq == max_vq n/a MUST* yes** yes** | ||
539 | + * --------------------------------------------------------------------- | ||
540 | + * vq > max_vq n/a no no yes | ||
541 | + * vq > max_vq n/a yes yes yes | ||
542 | + * --------------------------------------------------------------------- | ||
543 | + * | ||
544 | + * [*] "MUST" means this requirement must already be satisfied, | ||
545 | + * otherwise 'max_vq' couldn't itself be enabled. | ||
546 | + * | ||
547 | + * [**] Not testable with the QMP interface, only with the command line. | ||
548 | + */ | ||
549 | + | ||
550 | + /* max_vq := 8 */ | ||
551 | + assert_sve_vls(qts, cpu_type, 0x8b, "{ 'sve1024': true }"); | ||
552 | + | ||
553 | + /* max_vq := 8, vq < max_vq, !power-of-two(vq) */ | ||
554 | + assert_sve_vls(qts, cpu_type, 0x8f, | ||
555 | + "{ 'sve1024': true, 'sve384': true }"); | ||
556 | + assert_sve_vls(qts, cpu_type, 0x8b, | ||
557 | + "{ 'sve1024': true, 'sve384': false }"); | ||
558 | + | ||
559 | + /* max_vq := 8, vq < max_vq, power-of-two(vq) */ | ||
560 | + assert_sve_vls(qts, cpu_type, 0x8b, | ||
561 | + "{ 'sve1024': true, 'sve256': true }"); | ||
562 | + assert_error(qts, cpu_type, "cannot disable sve256", | ||
563 | + "{ 'sve1024': true, 'sve256': false }"); | ||
564 | + | ||
565 | + /* max_vq := 3, vq > max_vq, !all-power-of-two(< vq) */ | ||
566 | + assert_error(qts, cpu_type, "cannot disable sve512", | ||
567 | + "{ 'sve384': true, 'sve512': false, 'sve640': true }"); | ||
568 | + | ||
569 | + /* | ||
570 | + * We can disable power-of-two vector lengths when all larger lengths | ||
571 | + * are also disabled. We only need to disable the power-of-two length, | ||
572 | + * as all non-enabled larger lengths will then be auto-disabled. | ||
573 | + */ | ||
574 | + assert_sve_vls(qts, cpu_type, 0x7, "{ 'sve512': false }"); | ||
575 | + | ||
576 | + /* max_vq := 3, vq > max_vq, all-power-of-two(< vq) */ | ||
577 | + assert_sve_vls(qts, cpu_type, 0x1f, | ||
578 | + "{ 'sve384': true, 'sve512': true, 'sve640': true }"); | ||
579 | + assert_sve_vls(qts, cpu_type, 0xf, | ||
580 | + "{ 'sve384': true, 'sve512': true, 'sve640': false }"); | ||
581 | +} | ||
582 | + | ||
583 | +static void sve_tests_sve_max_vq_8(const void *data) | ||
584 | +{ | ||
585 | + QTestState *qts; | ||
586 | + | ||
587 | + qts = qtest_init(MACHINE "-cpu max,sve-max-vq=8"); | ||
588 | + | ||
589 | + assert_sve_vls(qts, "max", BIT_ULL(8) - 1, NULL); | ||
590 | + | ||
591 | + /* | ||
592 | + * Disabling the max-vq set by sve-max-vq is not allowed, but | ||
593 | + * of course enabling it is OK. | ||
594 | + */ | ||
595 | + assert_error(qts, "max", "cannot disable sve1024", "{ 'sve1024': false }"); | ||
596 | + assert_sve_vls(qts, "max", 0xff, "{ 'sve1024': true }"); | ||
597 | + | ||
598 | + /* | ||
599 | + * Enabling anything larger than max-vq set by sve-max-vq is not | ||
600 | + * allowed, but of course disabling everything larger is OK. | ||
601 | + */ | ||
602 | + assert_error(qts, "max", "cannot enable sve1152", "{ 'sve1152': true }"); | ||
603 | + assert_sve_vls(qts, "max", 0xff, "{ 'sve1152': false }"); | ||
604 | + | ||
605 | + /* | ||
606 | + * We can enable/disable non power-of-two lengths smaller than the | ||
607 | + * max-vq set by sve-max-vq, but, while we can enable power-of-two | ||
608 | + * lengths, we can't disable them. | ||
609 | + */ | ||
610 | + assert_sve_vls(qts, "max", 0xff, "{ 'sve384': true }"); | ||
611 | + assert_sve_vls(qts, "max", 0xfb, "{ 'sve384': false }"); | ||
612 | + assert_sve_vls(qts, "max", 0xff, "{ 'sve256': true }"); | ||
613 | + assert_error(qts, "max", "cannot disable sve256", "{ 'sve256': false }"); | ||
614 | + | ||
615 | + qtest_quit(qts); | ||
616 | +} | ||
617 | + | ||
618 | +static void sve_tests_sve_off(const void *data) | ||
619 | +{ | ||
620 | + QTestState *qts; | ||
621 | + | ||
622 | + qts = qtest_init(MACHINE "-cpu max,sve=off"); | ||
623 | + | ||
624 | + /* SVE is off, so the map should be empty. */ | ||
625 | + assert_sve_vls(qts, "max", 0, NULL); | ||
626 | + | ||
627 | + /* The map stays empty even if we turn lengths off. */ | ||
628 | + assert_sve_vls(qts, "max", 0, "{ 'sve128': false }"); | ||
629 | + | ||
630 | + /* It's an error to enable lengths when SVE is off. */ | ||
631 | + assert_error(qts, "max", "cannot enable sve128", "{ 'sve128': true }"); | ||
632 | + | ||
633 | + /* With SVE re-enabled we should get all vector lengths enabled. */ | ||
634 | + assert_sve_vls(qts, "max", BIT_ULL(SVE_MAX_VQ) - 1, "{ 'sve': true }"); | ||
635 | + | ||
636 | + /* Or enable SVE with just specific vector lengths. */ | ||
637 | + assert_sve_vls(qts, "max", 0x3, | ||
638 | + "{ 'sve': true, 'sve128': true, 'sve256': true }"); | ||
639 | + | ||
640 | + qtest_quit(qts); | ||
641 | +} | ||
642 | + | ||
643 | static void test_query_cpu_model_expansion(const void *data) | ||
644 | { | ||
645 | QTestState *qts; | ||
646 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data) | ||
647 | if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
648 | assert_has_feature(qts, "max", "aarch64"); | ||
649 | assert_has_feature(qts, "max", "sve"); | ||
650 | + assert_has_feature(qts, "max", "sve128"); | ||
651 | assert_has_feature(qts, "cortex-a57", "pmu"); | ||
652 | assert_has_feature(qts, "cortex-a57", "aarch64"); | ||
653 | |||
654 | + sve_tests_default(qts, "max"); | ||
655 | + | ||
656 | /* Test that features that depend on KVM generate errors without. */ | ||
657 | assert_error(qts, "max", | ||
658 | "'aarch64' feature cannot be disabled " | ||
659 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
660 | qtest_add_data_func("/arm/query-cpu-model-expansion", | ||
661 | NULL, test_query_cpu_model_expansion); | ||
662 | |||
663 | + if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
664 | + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8", | ||
665 | + NULL, sve_tests_sve_max_vq_8); | ||
666 | + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off", | ||
667 | + NULL, sve_tests_sve_off); | ||
668 | + } | ||
669 | + | ||
670 | if (kvm_available) { | ||
671 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", | ||
672 | NULL, test_query_cpu_model_expansion_kvm); | ||
673 | diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst | ||
674 | index XXXXXXX..XXXXXXX 100644 | ||
675 | --- a/docs/arm-cpu-features.rst | ||
676 | +++ b/docs/arm-cpu-features.rst | ||
677 | @@ -XXX,XX +XXX,XX @@ block in the script for usage) is used to issue the QMP commands. | 76 | @@ -XXX,XX +XXX,XX @@ block in the script for usage) is used to issue the QMP commands. |
678 | (QEMU) query-cpu-model-expansion type=full model={"name":"max"} | 77 | "sve896": true, "sve1280": true, "sve2048": true |
679 | { "return": { | ||
680 | "model": { "name": "max", "props": { | ||
681 | - "pmu": true, "aarch64": true | ||
682 | + "sve1664": true, "pmu": true, "sve1792": true, "sve1920": true, | ||
683 | + "sve128": true, "aarch64": true, "sve1024": true, "sve": true, | ||
684 | + "sve640": true, "sve768": true, "sve1408": true, "sve256": true, | ||
685 | + "sve1152": true, "sve512": true, "sve384": true, "sve1536": true, | ||
686 | + "sve896": true, "sve1280": true, "sve2048": true | ||
687 | }}}} | 78 | }}}} |
688 | 79 | ||
689 | -We see that the `max` CPU type has the `pmu` and `aarch64` CPU features. | 80 | -We see that the `max` CPU type has the `pmu`, `aarch64`, `sve`, and many |
690 | -We also see that the CPU features are enabled, as they are all `true`. | 81 | -`sve<N>` CPU features. We also see that all the CPU features are |
691 | +We see that the `max` CPU type has the `pmu`, `aarch64`, `sve`, and many | 82 | -enabled, as they are all `true`. (The `sve<N>` CPU features are all |
692 | +`sve<N>` CPU features. We also see that all the CPU features are | 83 | +We see that the ``max`` CPU type has the ``pmu``, ``aarch64``, ``sve``, and many |
693 | +enabled, as they are all `true`. (The `sve<N>` CPU features are all | 84 | +``sve<N>`` CPU features. We also see that all the CPU features are |
694 | +optional SVE vector lengths (see "SVE CPU Properties"). While with TCG | 85 | +enabled, as they are all ``true``. (The ``sve<N>`` CPU features are all |
695 | +all SVE vector lengths can be supported, when KVM is in use it's more | 86 | optional SVE vector lengths (see "SVE CPU Properties"). While with TCG |
696 | +likely that only a few lengths will be supported, if SVE is supported at | 87 | all SVE vector lengths can be supported, when KVM is in use it's more |
697 | +all.) | 88 | likely that only a few lengths will be supported, if SVE is supported at |
698 | 89 | @@ -XXX,XX +XXX,XX @@ all.) | |
699 | (2) Let's try to disable the PMU:: | 90 | "sve896": true, "sve1280": true, "sve2048": true |
700 | |||
701 | (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"pmu":false}} | ||
702 | { "return": { | ||
703 | "model": { "name": "max", "props": { | ||
704 | - "pmu": false, "aarch64": true | ||
705 | + "sve1664": true, "pmu": false, "sve1792": true, "sve1920": true, | ||
706 | + "sve128": true, "aarch64": true, "sve1024": true, "sve": true, | ||
707 | + "sve640": true, "sve768": true, "sve1408": true, "sve256": true, | ||
708 | + "sve1152": true, "sve512": true, "sve384": true, "sve1536": true, | ||
709 | + "sve896": true, "sve1280": true, "sve2048": true | ||
710 | }}}} | 91 | }}}} |
711 | 92 | ||
712 | We see it worked, as `pmu` is now `false`. | 93 | -We see it worked, as `pmu` is now `false`. |
94 | +We see it worked, as ``pmu`` is now ``false``. | ||
95 | |||
96 | -(3) Let's try to disable `aarch64`, which enables the AArch32 CPU feature:: | ||
97 | +(3) Let's try to disable ``aarch64``, which enables the AArch32 CPU feature:: | ||
98 | |||
99 | (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"aarch64":false}} | ||
100 | {"error": { | ||
713 | @@ -XXX,XX +XXX,XX @@ We see it worked, as `pmu` is now `false`. | 101 | @@ -XXX,XX +XXX,XX @@ We see it worked, as `pmu` is now `false`. |
714 | It looks like this feature is limited to a configuration we do not | 102 | It looks like this feature is limited to a configuration we do not |
715 | currently have. | 103 | currently have. |
716 | 104 | ||
717 | -(4) Let's try probing CPU features for the Cortex-A15 CPU type:: | 105 | -(4) Let's disable `sve` and see what happens to all the optional SVE |
718 | +(4) Let's disable `sve` and see what happens to all the optional SVE | 106 | +(4) Let's disable ``sve`` and see what happens to all the optional SVE |
719 | + vector lengths:: | 107 | vector lengths:: |
720 | + | 108 | |
721 | + (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"sve":false}} | 109 | (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"sve":false}} |
722 | + { "return": { | 110 | @@ -XXX,XX +XXX,XX @@ currently have. |
723 | + "model": { "name": "max", "props": { | 111 | "sve896": false, "sve1280": false, "sve2048": false |
724 | + "sve1664": false, "pmu": true, "sve1792": false, "sve1920": false, | 112 | }}}} |
725 | + "sve128": false, "aarch64": true, "sve1024": false, "sve": false, | 113 | |
726 | + "sve640": false, "sve768": false, "sve1408": false, "sve256": false, | 114 | -As expected they are now all `false`. |
727 | + "sve1152": false, "sve512": false, "sve384": false, "sve1536": false, | 115 | +As expected they are now all ``false``. |
728 | + "sve896": false, "sve1280": false, "sve2048": false | 116 | |
729 | + }}}} | 117 | (5) Let's try probing CPU features for the Cortex-A15 CPU type:: |
730 | + | ||
731 | +As expected they are now all `false`. | ||
732 | + | ||
733 | +(5) Let's try probing CPU features for the Cortex-A15 CPU type:: | ||
734 | 118 | ||
735 | (QEMU) query-cpu-model-expansion type=full model={"name":"cortex-a15"} | 119 | (QEMU) query-cpu-model-expansion type=full model={"name":"cortex-a15"} |
736 | {"return": {"model": {"name": "cortex-a15", "props": {"pmu": true}}}} | 120 | {"return": {"model": {"name": "cortex-a15", "props": {"pmu": true}}}} |
737 | @@ -XXX,XX +XXX,XX @@ After determining which CPU features are available and supported for a | 121 | |
738 | given CPU type, then they may be selectively enabled or disabled on the | 122 | -Only the `pmu` CPU feature is available. |
739 | QEMU command line with that CPU type:: | 123 | +Only the ``pmu`` CPU feature is available. |
740 | 124 | ||
741 | - $ qemu-system-aarch64 -M virt -cpu max,pmu=off | 125 | A note about CPU feature dependencies |
742 | + $ qemu-system-aarch64 -M virt -cpu max,pmu=off,sve=on,sve128=on,sve256=on | 126 | ------------------------------------- |
743 | 127 | @@ -XXX,XX +XXX,XX @@ A note about CPU models and KVM | |
744 | -The example above disables the PMU for the `max` CPU type. | 128 | ------------------------------- |
745 | +The example above disables the PMU and enables the first two SVE vector | 129 | |
746 | +lengths for the `max` CPU type. Note, the `sve=on` isn't actually | 130 | Named CPU models generally do not work with KVM. There are a few cases |
747 | +necessary, because, as we observed above with our probe of the `max` CPU | 131 | -that do work, e.g. using the named CPU model `cortex-a57` with KVM on a |
748 | +type, `sve` is already on by default. Also, based on our probe of | 132 | -seattle host, but mostly if KVM is enabled the `host` CPU type must be |
749 | +defaults, it would seem we need to disable many SVE vector lengths, rather | 133 | +that do work, e.g. using the named CPU model ``cortex-a57`` with KVM on a |
750 | +than only enabling the two we want. This isn't the case, because, as | 134 | +seattle host, but mostly if KVM is enabled the ``host`` CPU type must be |
751 | +disabling many SVE vector lengths would be quite verbose, the `sve<N>` CPU | 135 | used. This means the guest is provided all the same CPU features as the |
752 | +properties have special semantics (see "SVE CPU Property Parsing | 136 | -host CPU type has. And, for this reason, the `host` CPU type should |
753 | +Semantics"). | 137 | +host CPU type has. And, for this reason, the ``host`` CPU type should |
754 | + | 138 | enable all CPU features that the host has by default. Indeed it's even |
755 | +SVE CPU Properties | 139 | a bit strange to allow disabling CPU features that the host has when using |
756 | +================== | 140 | -the `host` CPU type, but in the absence of CPU models it's the best we can |
757 | + | 141 | +the ``host`` CPU type, but in the absence of CPU models it's the best we can |
758 | +There are two types of SVE CPU properties: `sve` and `sve<N>`. The first | 142 | do if we want to launch guests without all the host's CPU features enabled. |
759 | +is used to enable or disable the entire SVE feature, just as the `pmu` | 143 | |
760 | +CPU property completely enables or disables the PMU. The second type | 144 | -Enabling KVM also affects the `query-cpu-model-expansion` QMP command. The |
761 | +is used to enable or disable specific vector lengths, where `N` is the | 145 | +Enabling KVM also affects the ``query-cpu-model-expansion`` QMP command. The |
762 | +number of bits of the length. The `sve<N>` CPU properties have special | 146 | affect is not only limited to specific features, as pointed out in example |
763 | +dependencies and constraints, see "SVE CPU Property Dependencies and | 147 | (3) of "CPU Feature Probing", but also to which CPU types may be expanded. |
764 | +Constraints" below. Additionally, as we want all supported vector lengths | 148 | -When KVM is enabled, only the `max`, `host`, and current CPU type may be |
765 | +to be enabled by default, then, in order to avoid overly verbose command | 149 | +When KVM is enabled, only the ``max``, ``host``, and current CPU type may be |
766 | +lines (command lines full of `sve<N>=off`, for all `N` not wanted), we | 150 | expanded. This restriction is necessary as it's not possible to know all |
767 | +provide the parsing semantics listed in "SVE CPU Property Parsing | 151 | CPU types that may work with KVM, but it does impose a small risk of users |
768 | +Semantics". | 152 | experiencing unexpected errors. For example on a seattle, as mentioned |
769 | + | 153 | -above, the `cortex-a57` CPU type is also valid when KVM is enabled. |
770 | +SVE CPU Property Dependencies and Constraints | 154 | -Therefore a user could use the `host` CPU type for the current type, but |
771 | +--------------------------------------------- | 155 | -then attempt to query `cortex-a57`, however that query will fail with our |
772 | + | 156 | +above, the ``cortex-a57`` CPU type is also valid when KVM is enabled. |
773 | + 1) At least one vector length must be enabled when `sve` is enabled. | 157 | +Therefore a user could use the ``host`` CPU type for the current type, but |
774 | + | 158 | +then attempt to query ``cortex-a57``, however that query will fail with our |
775 | + 2) If a vector length `N` is enabled, then all power-of-two vector | 159 | restrictions. This shouldn't be an issue though as management layers and |
776 | + lengths smaller than `N` must also be enabled. E.g. if `sve512` | 160 | -users have been preferring the `host` CPU type for use with KVM for quite |
777 | + is enabled, then the 128-bit and 256-bit vector lengths must also | 161 | +users have been preferring the ``host`` CPU type for use with KVM for quite |
778 | + be enabled. | 162 | some time. Additionally, if the KVM-enabled QEMU instance running on a |
779 | + | 163 | -seattle host is using the `cortex-a57` CPU type, then querying `cortex-a57` |
780 | +SVE CPU Property Parsing Semantics | 164 | +seattle host is using the ``cortex-a57`` CPU type, then querying ``cortex-a57`` |
781 | +---------------------------------- | 165 | will work. |
782 | + | 166 | |
783 | + 1) If SVE is disabled (`sve=off`), then which SVE vector lengths | 167 | Using CPU Features |
784 | + are enabled or disabled is irrelevant to the guest, as the entire | 168 | @@ -XXX,XX +XXX,XX @@ QEMU command line with that CPU type:: |
785 | + SVE feature is disabled and that disables all vector lengths for | 169 | $ qemu-system-aarch64 -M virt -cpu max,pmu=off,sve=on,sve128=on,sve256=on |
786 | + the guest. However QEMU will still track any `sve<N>` CPU | 170 | |
787 | + properties provided by the user. If later an `sve=on` is provided, | 171 | The example above disables the PMU and enables the first two SVE vector |
788 | + then the guest will get only the enabled lengths. If no `sve=on` | 172 | -lengths for the `max` CPU type. Note, the `sve=on` isn't actually |
789 | + is provided and there are explicitly enabled vector lengths, then | 173 | -necessary, because, as we observed above with our probe of the `max` CPU |
790 | + an error is generated. | 174 | -type, `sve` is already on by default. Also, based on our probe of |
791 | + | 175 | +lengths for the ``max`` CPU type. Note, the ``sve=on`` isn't actually |
792 | + 2) If SVE is enabled (`sve=on`), but no `sve<N>` CPU properties are | 176 | +necessary, because, as we observed above with our probe of the ``max`` CPU |
793 | + provided, then all supported vector lengths are enabled, including | 177 | +type, ``sve`` is already on by default. Also, based on our probe of |
794 | + the non-power-of-two lengths. | 178 | defaults, it would seem we need to disable many SVE vector lengths, rather |
795 | + | 179 | than only enabling the two we want. This isn't the case, because, as |
796 | + 3) If SVE is enabled, then an error is generated when attempting to | 180 | -disabling many SVE vector lengths would be quite verbose, the `sve<N>` CPU |
797 | + disable the last enabled vector length (see constraint (1) of "SVE | 181 | +disabling many SVE vector lengths would be quite verbose, the ``sve<N>`` CPU |
798 | + CPU Property Dependencies and Constraints"). | 182 | properties have special semantics (see "SVE CPU Property Parsing |
799 | + | 183 | Semantics"). |
800 | + 4) If one or more vector lengths have been explicitly enabled and at | 184 | |
801 | + at least one of the dependency lengths of the maximum enabled length | 185 | @@ -XXX,XX +XXX,XX @@ TCG VCPU Features |
802 | + has been explicitly disabled, then an error is generated (see | 186 | TCG VCPU features are CPU features that are specific to TCG. |
803 | + constraint (2) of "SVE CPU Property Dependencies and Constraints"). | 187 | Below is the list of TCG VCPU features and their descriptions. |
804 | + | 188 | |
805 | + 5) If one or more `sve<N>` CPU properties are set `off`, but no `sve<N>`, | 189 | - pauth Enable or disable `FEAT_Pauth`, pointer |
806 | + CPU properties are set `on`, then the specified vector lengths are | 190 | + pauth Enable or disable ``FEAT_Pauth``, pointer |
807 | + disabled but the default for any unspecified lengths remains enabled. | 191 | authentication. By default, the feature is |
808 | + Disabling a power-of-two vector length also disables all vector | 192 | - enabled with `-cpu max`. |
809 | + lengths larger than the power-of-two length (see constraint (2) of | 193 | + enabled with ``-cpu max``. |
810 | + "SVE CPU Property Dependencies and Constraints"). | 194 | |
811 | + | 195 | - pauth-impdef When `FEAT_Pauth` is enabled, either the |
812 | + 6) If one or more `sve<N>` CPU properties are set to `on`, then they | 196 | + pauth-impdef When ``FEAT_Pauth`` is enabled, either the |
813 | + are enabled and all unspecified lengths default to disabled, except | 197 | *impdef* (Implementation Defined) algorithm |
814 | + for the required lengths per constraint (2) of "SVE CPU Property | 198 | is enabled or the *architected* QARMA algorithm |
815 | + Dependencies and Constraints", which will even be auto-enabled if | 199 | is enabled. By default the impdef algorithm |
816 | + they were not explicitly enabled. | 200 | @@ -XXX,XX +XXX,XX @@ Below is the list of TCG VCPU features and their descriptions. |
817 | + | 201 | SVE CPU Properties |
818 | + 7) If SVE was disabled (`sve=off`), allowing all vector lengths to be | 202 | ================== |
819 | + explicitly disabled (i.e. avoiding the error specified in (3) of | 203 | |
820 | + "SVE CPU Property Parsing Semantics"), then if later an `sve=on` is | 204 | -There are two types of SVE CPU properties: `sve` and `sve<N>`. The first |
821 | + provided an error will be generated. To avoid this error, one must | 205 | -is used to enable or disable the entire SVE feature, just as the `pmu` |
822 | + enable at least one vector length prior to enabling SVE. | 206 | +There are two types of SVE CPU properties: ``sve`` and ``sve<N>``. The first |
823 | + | 207 | +is used to enable or disable the entire SVE feature, just as the ``pmu`` |
824 | +SVE CPU Property Examples | 208 | CPU property completely enables or disables the PMU. The second type |
825 | +------------------------- | 209 | -is used to enable or disable specific vector lengths, where `N` is the |
826 | + | 210 | -number of bits of the length. The `sve<N>` CPU properties have special |
827 | + 1) Disable SVE:: | 211 | +is used to enable or disable specific vector lengths, where ``N`` is the |
828 | + | 212 | +number of bits of the length. The ``sve<N>`` CPU properties have special |
829 | + $ qemu-system-aarch64 -M virt -cpu max,sve=off | 213 | dependencies and constraints, see "SVE CPU Property Dependencies and |
830 | + | 214 | Constraints" below. Additionally, as we want all supported vector lengths |
831 | + 2) Implicitly enable all vector lengths for the `max` CPU type:: | 215 | to be enabled by default, then, in order to avoid overly verbose command |
832 | + | 216 | -lines (command lines full of `sve<N>=off`, for all `N` not wanted), we |
833 | + $ qemu-system-aarch64 -M virt -cpu max | 217 | +lines (command lines full of ``sve<N>=off``, for all ``N`` not wanted), we |
834 | + | 218 | provide the parsing semantics listed in "SVE CPU Property Parsing |
835 | + 3) Only enable the 128-bit vector length:: | 219 | Semantics". |
836 | + | 220 | |
837 | + $ qemu-system-aarch64 -M virt -cpu max,sve128=on | 221 | SVE CPU Property Dependencies and Constraints |
838 | + | 222 | --------------------------------------------- |
839 | + 4) Disable the 512-bit vector length and all larger vector lengths, | 223 | |
840 | + since 512 is a power-of-two. This results in all the smaller, | 224 | - 1) At least one vector length must be enabled when `sve` is enabled. |
841 | + uninitialized lengths (128, 256, and 384) defaulting to enabled:: | 225 | + 1) At least one vector length must be enabled when ``sve`` is enabled. |
842 | + | 226 | |
843 | + $ qemu-system-aarch64 -M virt -cpu max,sve512=off | 227 | - 2) If a vector length `N` is enabled, then, when KVM is enabled, all |
844 | + | 228 | + 2) If a vector length ``N`` is enabled, then, when KVM is enabled, all |
845 | + 5) Enable the 128-bit, 256-bit, and 512-bit vector lengths:: | 229 | smaller, host supported vector lengths must also be enabled. If |
846 | + | 230 | KVM is not enabled, then only all the smaller, power-of-two vector |
847 | + $ qemu-system-aarch64 -M virt -cpu max,sve128=on,sve256=on,sve512=on | 231 | lengths must be enabled. E.g. with KVM if the host supports all |
848 | + | 232 | - vector lengths up to 512-bits (128, 256, 384, 512), then if `sve512` |
849 | + 6) The same as (5), but since the 128-bit and 256-bit vector | 233 | + vector lengths up to 512-bits (128, 256, 384, 512), then if ``sve512`` |
850 | + lengths are required for the 512-bit vector length to be enabled, | 234 | is enabled, the 128-bit vector length, 256-bit vector length, and |
851 | + then allow them to be auto-enabled:: | 235 | 384-bit vector length must also be enabled. Without KVM, the 384-bit |
852 | + | 236 | vector length would not be required. |
853 | + $ qemu-system-aarch64 -M virt -cpu max,sve512=on | 237 | |
854 | + | 238 | 3) If KVM is enabled then only vector lengths that the host CPU type |
855 | + 7) Do the same as (6), but by first disabling SVE and then re-enabling it:: | 239 | support may be enabled. If SVE is not supported by the host, then |
856 | + | 240 | - no `sve*` properties may be enabled. |
857 | + $ qemu-system-aarch64 -M virt -cpu max,sve=off,sve512=on,sve=on | 241 | + no ``sve*`` properties may be enabled. |
858 | + | 242 | |
859 | + 8) Force errors regarding the last vector length:: | 243 | SVE CPU Property Parsing Semantics |
860 | + | 244 | ---------------------------------- |
861 | + $ qemu-system-aarch64 -M virt -cpu max,sve128=off | 245 | |
862 | + $ qemu-system-aarch64 -M virt -cpu max,sve=off,sve128=off,sve=on | 246 | - 1) If SVE is disabled (`sve=off`), then which SVE vector lengths |
863 | + | 247 | + 1) If SVE is disabled (``sve=off``), then which SVE vector lengths |
864 | +SVE CPU Property Recommendations | 248 | are enabled or disabled is irrelevant to the guest, as the entire |
865 | +-------------------------------- | 249 | SVE feature is disabled and that disables all vector lengths for |
866 | + | 250 | - the guest. However QEMU will still track any `sve<N>` CPU |
867 | +The examples in "SVE CPU Property Examples" exhibit many ways to select | 251 | - properties provided by the user. If later an `sve=on` is provided, |
868 | +vector lengths which developers may find useful in order to avoid overly | 252 | - then the guest will get only the enabled lengths. If no `sve=on` |
869 | +verbose command lines. However, the recommended way to select vector | 253 | + the guest. However QEMU will still track any ``sve<N>`` CPU |
870 | +lengths is to explicitly enable each desired length. Therefore only | 254 | + properties provided by the user. If later an ``sve=on`` is provided, |
871 | +example's (1), (3), and (5) exhibit recommended uses of the properties. | 255 | + then the guest will get only the enabled lengths. If no ``sve=on`` |
256 | is provided and there are explicitly enabled vector lengths, then | ||
257 | an error is generated. | ||
258 | |||
259 | - 2) If SVE is enabled (`sve=on`), but no `sve<N>` CPU properties are | ||
260 | + 2) If SVE is enabled (``sve=on``), but no ``sve<N>`` CPU properties are | ||
261 | provided, then all supported vector lengths are enabled, which when | ||
262 | KVM is not in use means including the non-power-of-two lengths, and, | ||
263 | when KVM is in use, it means all vector lengths supported by the host | ||
264 | @@ -XXX,XX +XXX,XX @@ SVE CPU Property Parsing Semantics | ||
265 | constraint (2) of "SVE CPU Property Dependencies and Constraints"). | ||
266 | |||
267 | 5) When KVM is enabled, if the host does not support SVE, then an error | ||
268 | - is generated when attempting to enable any `sve*` properties (see | ||
269 | + is generated when attempting to enable any ``sve*`` properties (see | ||
270 | constraint (3) of "SVE CPU Property Dependencies and Constraints"). | ||
271 | |||
272 | 6) When KVM is enabled, if the host does support SVE, then an error is | ||
273 | @@ -XXX,XX +XXX,XX @@ SVE CPU Property Parsing Semantics | ||
274 | by the host (see constraint (3) of "SVE CPU Property Dependencies and | ||
275 | Constraints"). | ||
276 | |||
277 | - 7) If one or more `sve<N>` CPU properties are set `off`, but no `sve<N>`, | ||
278 | - CPU properties are set `on`, then the specified vector lengths are | ||
279 | + 7) If one or more ``sve<N>`` CPU properties are set ``off``, but no ``sve<N>``, | ||
280 | + CPU properties are set ``on``, then the specified vector lengths are | ||
281 | disabled but the default for any unspecified lengths remains enabled. | ||
282 | When KVM is not enabled, disabling a power-of-two vector length also | ||
283 | disables all vector lengths larger than the power-of-two length. | ||
284 | @@ -XXX,XX +XXX,XX @@ SVE CPU Property Parsing Semantics | ||
285 | disables all larger vector lengths (see constraint (2) of "SVE CPU | ||
286 | Property Dependencies and Constraints"). | ||
287 | |||
288 | - 8) If one or more `sve<N>` CPU properties are set to `on`, then they | ||
289 | + 8) If one or more ``sve<N>`` CPU properties are set to ``on``, then they | ||
290 | are enabled and all unspecified lengths default to disabled, except | ||
291 | for the required lengths per constraint (2) of "SVE CPU Property | ||
292 | Dependencies and Constraints", which will even be auto-enabled if | ||
293 | they were not explicitly enabled. | ||
294 | |||
295 | - 9) If SVE was disabled (`sve=off`), allowing all vector lengths to be | ||
296 | + 9) If SVE was disabled (``sve=off``), allowing all vector lengths to be | ||
297 | explicitly disabled (i.e. avoiding the error specified in (3) of | ||
298 | - "SVE CPU Property Parsing Semantics"), then if later an `sve=on` is | ||
299 | + "SVE CPU Property Parsing Semantics"), then if later an ``sve=on`` is | ||
300 | provided an error will be generated. To avoid this error, one must | ||
301 | enable at least one vector length prior to enabling SVE. | ||
302 | |||
303 | @@ -XXX,XX +XXX,XX @@ SVE CPU Property Examples | ||
304 | |||
305 | $ qemu-system-aarch64 -M virt -cpu max,sve=off | ||
306 | |||
307 | - 2) Implicitly enable all vector lengths for the `max` CPU type:: | ||
308 | + 2) Implicitly enable all vector lengths for the ``max`` CPU type:: | ||
309 | |||
310 | $ qemu-system-aarch64 -M virt -cpu max | ||
311 | |||
312 | 3) When KVM is enabled, implicitly enable all host CPU supported vector | ||
313 | - lengths with the `host` CPU type:: | ||
314 | + lengths with the ``host`` CPU type:: | ||
315 | |||
316 | $ qemu-system-aarch64 -M virt,accel=kvm -cpu host | ||
872 | 317 | ||
873 | -- | 318 | -- |
874 | 2.20.1 | 319 | 2.20.1 |
875 | 320 | ||
876 | 321 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | In rST markup, single backticks `like this` represent "interpreted |
---|---|---|---|
2 | text", which can be handled as a bunch of different things if tagged | ||
3 | with a specific "role": | ||
4 | https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#interpreted-text | ||
5 | (the most common one for us is "reference to a URL, which gets | ||
6 | hyperlinked"). | ||
2 | 7 | ||
3 | Extend the SVE vq map initialization and validation with KVM's | 8 | The default "role" if none is specified is "title_reference", |
4 | supported vector lengths when KVM is enabled. In order to determine | 9 | intended for references to book or article titles, and it renders |
5 | and select supported lengths we add two new KVM functions for getting | 10 | into the HTML as <cite>...</cite> (usually comes out as italics). |
6 | and setting the KVM_REG_ARM64_SVE_VLS pseudo-register. | ||
7 | 11 | ||
8 | This patch has been co-authored with Richard Henderson, who reworked | 12 | This commit fixes various places in the manual which were |
9 | the target/arm/cpu64.c changes in order to push all the validation and | 13 | using single backticks when double backticks (for literal text) |
10 | auto-enabling/disabling steps into the finalizer, resulting in a nice | 14 | were intended, and covers those files where only one or two |
11 | LOC reduction. | 15 | instances of these errors were made. |
12 | 16 | ||
13 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
16 | Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | ||
17 | Message-id: 20191024121808.9612-9-drjones@redhat.com | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | 19 | --- |
20 | target/arm/kvm_arm.h | 12 +++ | 20 | docs/about/index.rst | 2 +- |
21 | target/arm/cpu64.c | 176 ++++++++++++++++++++++++++++---------- | 21 | docs/interop/live-block-operations.rst | 2 +- |
22 | target/arm/kvm64.c | 100 +++++++++++++++++++++- | 22 | docs/system/arm/nuvoton.rst | 2 +- |
23 | tests/arm-cpu-features.c | 106 ++++++++++++++++++++++- | 23 | docs/system/arm/sbsa.rst | 4 ++-- |
24 | docs/arm-cpu-features.rst | 45 +++++++--- | 24 | docs/system/arm/virt.rst | 2 +- |
25 | 5 files changed, 381 insertions(+), 58 deletions(-) | 25 | docs/system/cpu-hotplug.rst | 2 +- |
26 | docs/system/guest-loader.rst | 6 +++--- | ||
27 | docs/system/ppc/powernv.rst | 8 ++++---- | ||
28 | docs/system/riscv/microchip-icicle-kit.rst | 2 +- | ||
29 | docs/system/riscv/virt.rst | 2 +- | ||
30 | 10 files changed, 16 insertions(+), 16 deletions(-) | ||
26 | 31 | ||
27 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 32 | diff --git a/docs/about/index.rst b/docs/about/index.rst |
28 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/kvm_arm.h | 34 | --- a/docs/about/index.rst |
30 | +++ b/target/arm/kvm_arm.h | 35 | +++ b/docs/about/index.rst |
31 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMHostCPUFeatures { | 36 | @@ -XXX,XX +XXX,XX @@ where QEMU can launch processes compiled for one CPU on another CPU. |
32 | */ | 37 | In this mode the CPU is always emulated. |
33 | bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); | 38 | |
34 | 39 | QEMU also provides a number of standalone commandline utilities, | |
35 | +/** | 40 | -such as the `qemu-img` disk image utility that allows you to create, |
36 | + * kvm_arm_sve_get_vls: | 41 | +such as the ``qemu-img`` disk image utility that allows you to create, |
37 | + * @cs: CPUState | 42 | convert and modify disk images. |
38 | + * @map: bitmap to fill in | 43 | |
39 | + * | 44 | .. toctree:: |
40 | + * Get all the SVE vector lengths supported by the KVM host, setting | 45 | diff --git a/docs/interop/live-block-operations.rst b/docs/interop/live-block-operations.rst |
41 | + * the bits corresponding to their length in quadwords minus one | ||
42 | + * (vq - 1) in @map up to ARM_MAX_VQ. | ||
43 | + */ | ||
44 | +void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map); | ||
45 | + | ||
46 | /** | ||
47 | * kvm_arm_set_cpu_features_from_host: | ||
48 | * @cpu: ARMCPU to set the features for | ||
49 | @@ -XXX,XX +XXX,XX @@ static inline int kvm_arm_vgic_probe(void) | ||
50 | static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {} | ||
51 | static inline void kvm_arm_pmu_init(CPUState *cs) {} | ||
52 | |||
53 | +static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {} | ||
54 | #endif | ||
55 | |||
56 | static inline const char *gic_class_name(void) | ||
57 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
59 | --- a/target/arm/cpu64.c | 47 | --- a/docs/interop/live-block-operations.rst |
60 | +++ b/target/arm/cpu64.c | 48 | +++ b/docs/interop/live-block-operations.rst |
61 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | 49 | @@ -XXX,XX +XXX,XX @@ the content of image [D]. |
62 | * any of the above. Finally, if SVE is not disabled, then at least one | ||
63 | * vector length must be enabled. | ||
64 | */ | ||
65 | + DECLARE_BITMAP(kvm_supported, ARM_MAX_VQ); | ||
66 | DECLARE_BITMAP(tmp, ARM_MAX_VQ); | ||
67 | uint32_t vq, max_vq = 0; | ||
68 | |||
69 | + /* Collect the set of vector lengths supported by KVM. */ | ||
70 | + bitmap_zero(kvm_supported, ARM_MAX_VQ); | ||
71 | + if (kvm_enabled() && kvm_arm_sve_supported(CPU(cpu))) { | ||
72 | + kvm_arm_sve_get_vls(CPU(cpu), kvm_supported); | ||
73 | + } else if (kvm_enabled()) { | ||
74 | + assert(!cpu_isar_feature(aa64_sve, cpu)); | ||
75 | + } | ||
76 | + | ||
77 | /* | ||
78 | * Process explicit sve<N> properties. | ||
79 | * From the properties, sve_vq_map<N> implies sve_vq_init<N>. | ||
80 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
81 | return; | ||
82 | } | 50 | } |
83 | 51 | ||
84 | - /* Propagate enabled bits down through required powers-of-two. */ | 52 | (6) [On *destination* QEMU] Finally, resume the guest vCPUs by issuing the |
85 | - for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | 53 | - QMP command `cont`:: |
86 | - if (!test_bit(vq - 1, cpu->sve_vq_init)) { | 54 | + QMP command ``cont``:: |
87 | - set_bit(vq - 1, cpu->sve_vq_map); | 55 | |
88 | + if (kvm_enabled()) { | 56 | (QEMU) cont |
89 | + /* | 57 | { |
90 | + * For KVM we have to automatically enable all supported unitialized | 58 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
91 | + * lengths, even when the smaller lengths are not all powers-of-two. | ||
92 | + */ | ||
93 | + bitmap_andnot(tmp, kvm_supported, cpu->sve_vq_init, max_vq); | ||
94 | + bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); | ||
95 | + } else { | ||
96 | + /* Propagate enabled bits down through required powers-of-two. */ | ||
97 | + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
98 | + if (!test_bit(vq - 1, cpu->sve_vq_init)) { | ||
99 | + set_bit(vq - 1, cpu->sve_vq_map); | ||
100 | + } | ||
101 | } | ||
102 | } | ||
103 | } else if (cpu->sve_max_vq == 0) { | ||
104 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | - /* Disabling a power-of-two disables all larger lengths. */ | ||
109 | - if (test_bit(0, cpu->sve_vq_init)) { | ||
110 | - error_setg(errp, "cannot disable sve128"); | ||
111 | - error_append_hint(errp, "Disabling sve128 results in all vector " | ||
112 | - "lengths being disabled.\n"); | ||
113 | - error_append_hint(errp, "With SVE enabled, at least one vector " | ||
114 | - "length must be enabled.\n"); | ||
115 | - return; | ||
116 | - } | ||
117 | - for (vq = 2; vq <= ARM_MAX_VQ; vq <<= 1) { | ||
118 | - if (test_bit(vq - 1, cpu->sve_vq_init)) { | ||
119 | - break; | ||
120 | + if (kvm_enabled()) { | ||
121 | + /* Disabling a supported length disables all larger lengths. */ | ||
122 | + for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
123 | + if (test_bit(vq - 1, cpu->sve_vq_init) && | ||
124 | + test_bit(vq - 1, kvm_supported)) { | ||
125 | + break; | ||
126 | + } | ||
127 | } | ||
128 | + max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | ||
129 | + bitmap_andnot(cpu->sve_vq_map, kvm_supported, | ||
130 | + cpu->sve_vq_init, max_vq); | ||
131 | + if (max_vq == 0 || bitmap_empty(cpu->sve_vq_map, max_vq)) { | ||
132 | + error_setg(errp, "cannot disable sve%d", vq * 128); | ||
133 | + error_append_hint(errp, "Disabling sve%d results in all " | ||
134 | + "vector lengths being disabled.\n", | ||
135 | + vq * 128); | ||
136 | + error_append_hint(errp, "With SVE enabled, at least one " | ||
137 | + "vector length must be enabled.\n"); | ||
138 | + return; | ||
139 | + } | ||
140 | + } else { | ||
141 | + /* Disabling a power-of-two disables all larger lengths. */ | ||
142 | + if (test_bit(0, cpu->sve_vq_init)) { | ||
143 | + error_setg(errp, "cannot disable sve128"); | ||
144 | + error_append_hint(errp, "Disabling sve128 results in all " | ||
145 | + "vector lengths being disabled.\n"); | ||
146 | + error_append_hint(errp, "With SVE enabled, at least one " | ||
147 | + "vector length must be enabled.\n"); | ||
148 | + return; | ||
149 | + } | ||
150 | + for (vq = 2; vq <= ARM_MAX_VQ; vq <<= 1) { | ||
151 | + if (test_bit(vq - 1, cpu->sve_vq_init)) { | ||
152 | + break; | ||
153 | + } | ||
154 | + } | ||
155 | + max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | ||
156 | + bitmap_complement(cpu->sve_vq_map, cpu->sve_vq_init, max_vq); | ||
157 | } | ||
158 | - max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | ||
159 | |||
160 | - bitmap_complement(cpu->sve_vq_map, cpu->sve_vq_init, max_vq); | ||
161 | max_vq = find_last_bit(cpu->sve_vq_map, max_vq) + 1; | ||
162 | } | ||
163 | |||
164 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
165 | assert(max_vq != 0); | ||
166 | bitmap_clear(cpu->sve_vq_map, max_vq, ARM_MAX_VQ - max_vq); | ||
167 | |||
168 | - /* Ensure all required powers-of-two are enabled. */ | ||
169 | - for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
170 | - if (!test_bit(vq - 1, cpu->sve_vq_map)) { | ||
171 | - error_setg(errp, "cannot disable sve%d", vq * 128); | ||
172 | - error_append_hint(errp, "sve%d is required as it " | ||
173 | - "is a power-of-two length smaller than " | ||
174 | - "the maximum, sve%d\n", | ||
175 | - vq * 128, max_vq * 128); | ||
176 | + if (kvm_enabled()) { | ||
177 | + /* Ensure the set of lengths matches what KVM supports. */ | ||
178 | + bitmap_xor(tmp, cpu->sve_vq_map, kvm_supported, max_vq); | ||
179 | + if (!bitmap_empty(tmp, max_vq)) { | ||
180 | + vq = find_last_bit(tmp, max_vq) + 1; | ||
181 | + if (test_bit(vq - 1, cpu->sve_vq_map)) { | ||
182 | + if (cpu->sve_max_vq) { | ||
183 | + error_setg(errp, "cannot set sve-max-vq=%d", | ||
184 | + cpu->sve_max_vq); | ||
185 | + error_append_hint(errp, "This KVM host does not support " | ||
186 | + "the vector length %d-bits.\n", | ||
187 | + vq * 128); | ||
188 | + error_append_hint(errp, "It may not be possible to use " | ||
189 | + "sve-max-vq with this KVM host. Try " | ||
190 | + "using only sve<N> properties.\n"); | ||
191 | + } else { | ||
192 | + error_setg(errp, "cannot enable sve%d", vq * 128); | ||
193 | + error_append_hint(errp, "This KVM host does not support " | ||
194 | + "the vector length %d-bits.\n", | ||
195 | + vq * 128); | ||
196 | + } | ||
197 | + } else { | ||
198 | + error_setg(errp, "cannot disable sve%d", vq * 128); | ||
199 | + error_append_hint(errp, "The KVM host requires all " | ||
200 | + "supported vector lengths smaller " | ||
201 | + "than %d bits to also be enabled.\n", | ||
202 | + max_vq * 128); | ||
203 | + } | ||
204 | return; | ||
205 | } | ||
206 | + } else { | ||
207 | + /* Ensure all required powers-of-two are enabled. */ | ||
208 | + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
209 | + if (!test_bit(vq - 1, cpu->sve_vq_map)) { | ||
210 | + error_setg(errp, "cannot disable sve%d", vq * 128); | ||
211 | + error_append_hint(errp, "sve%d is required as it " | ||
212 | + "is a power-of-two length smaller than " | ||
213 | + "the maximum, sve%d\n", | ||
214 | + vq * 128, max_vq * 128); | ||
215 | + return; | ||
216 | + } | ||
217 | + } | ||
218 | } | ||
219 | |||
220 | /* | ||
221 | @@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
222 | { | ||
223 | ARMCPU *cpu = ARM_CPU(obj); | ||
224 | Error *err = NULL; | ||
225 | + uint32_t max_vq; | ||
226 | |||
227 | - visit_type_uint32(v, name, &cpu->sve_max_vq, &err); | ||
228 | - | ||
229 | - if (!err && (cpu->sve_max_vq == 0 || cpu->sve_max_vq > ARM_MAX_VQ)) { | ||
230 | - error_setg(&err, "unsupported SVE vector length"); | ||
231 | - error_append_hint(&err, "Valid sve-max-vq in range [1-%d]\n", | ||
232 | - ARM_MAX_VQ); | ||
233 | + visit_type_uint32(v, name, &max_vq, &err); | ||
234 | + if (err) { | ||
235 | + error_propagate(errp, err); | ||
236 | + return; | ||
237 | } | ||
238 | - error_propagate(errp, err); | ||
239 | + | ||
240 | + if (kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { | ||
241 | + error_setg(errp, "cannot set sve-max-vq"); | ||
242 | + error_append_hint(errp, "SVE not supported by KVM on this host\n"); | ||
243 | + return; | ||
244 | + } | ||
245 | + | ||
246 | + if (max_vq == 0 || max_vq > ARM_MAX_VQ) { | ||
247 | + error_setg(errp, "unsupported SVE vector length"); | ||
248 | + error_append_hint(errp, "Valid sve-max-vq in range [1-%d]\n", | ||
249 | + ARM_MAX_VQ); | ||
250 | + return; | ||
251 | + } | ||
252 | + | ||
253 | + cpu->sve_max_vq = max_vq; | ||
254 | } | ||
255 | |||
256 | static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
257 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
258 | return; | ||
259 | } | ||
260 | |||
261 | + if (value && kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { | ||
262 | + error_setg(errp, "cannot enable %s", name); | ||
263 | + error_append_hint(errp, "SVE not supported by KVM on this host\n"); | ||
264 | + return; | ||
265 | + } | ||
266 | + | ||
267 | if (value) { | ||
268 | set_bit(vq - 1, cpu->sve_vq_map); | ||
269 | } else { | ||
270 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
271 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
272 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
273 | #endif | ||
274 | - | ||
275 | - object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | ||
276 | - cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); | ||
277 | - | ||
278 | - for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
279 | - char name[8]; | ||
280 | - sprintf(name, "sve%d", vq * 128); | ||
281 | - object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
282 | - cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); | ||
283 | - } | ||
284 | } | ||
285 | |||
286 | object_property_add(obj, "sve", "bool", cpu_arm_get_sve, | ||
287 | cpu_arm_set_sve, NULL, NULL, &error_fatal); | ||
288 | + object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | ||
289 | + cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); | ||
290 | + | ||
291 | + for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
292 | + char name[8]; | ||
293 | + sprintf(name, "sve%d", vq * 128); | ||
294 | + object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
295 | + cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); | ||
296 | + } | ||
297 | } | ||
298 | |||
299 | struct ARMCPUInfo { | ||
300 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
301 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
302 | --- a/target/arm/kvm64.c | 60 | --- a/docs/system/arm/nuvoton.rst |
303 | +++ b/target/arm/kvm64.c | 61 | +++ b/docs/system/arm/nuvoton.rst |
304 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_sve_supported(CPUState *cpu) | 62 | @@ -XXX,XX +XXX,XX @@ Boot options |
305 | return kvm_check_extension(s, KVM_CAP_ARM_SVE); | 63 | ------------ |
306 | } | 64 | |
307 | 65 | The Nuvoton machines can boot from an OpenBMC firmware image, or directly into | |
308 | +QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1); | 66 | -a kernel using the ``-kernel`` option. OpenBMC images for `quanta-gsj` and |
309 | + | 67 | +a kernel using the ``-kernel`` option. OpenBMC images for ``quanta-gsj`` and |
310 | +void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) | 68 | possibly others can be downloaded from the OpenPOWER jenkins : |
311 | +{ | 69 | |
312 | + /* Only call this function if kvm_arm_sve_supported() returns true. */ | 70 | https://openpower.xyz/ |
313 | + static uint64_t vls[KVM_ARM64_SVE_VLS_WORDS]; | 71 | diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst |
314 | + static bool probed; | ||
315 | + uint32_t vq = 0; | ||
316 | + int i, j; | ||
317 | + | ||
318 | + bitmap_clear(map, 0, ARM_MAX_VQ); | ||
319 | + | ||
320 | + /* | ||
321 | + * KVM ensures all host CPUs support the same set of vector lengths. | ||
322 | + * So we only need to create the scratch VCPUs once and then cache | ||
323 | + * the results. | ||
324 | + */ | ||
325 | + if (!probed) { | ||
326 | + struct kvm_vcpu_init init = { | ||
327 | + .target = -1, | ||
328 | + .features[0] = (1 << KVM_ARM_VCPU_SVE), | ||
329 | + }; | ||
330 | + struct kvm_one_reg reg = { | ||
331 | + .id = KVM_REG_ARM64_SVE_VLS, | ||
332 | + .addr = (uint64_t)&vls[0], | ||
333 | + }; | ||
334 | + int fdarray[3], ret; | ||
335 | + | ||
336 | + probed = true; | ||
337 | + | ||
338 | + if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, &init)) { | ||
339 | + error_report("failed to create scratch VCPU with SVE enabled"); | ||
340 | + abort(); | ||
341 | + } | ||
342 | + ret = ioctl(fdarray[2], KVM_GET_ONE_REG, ®); | ||
343 | + kvm_arm_destroy_scratch_host_vcpu(fdarray); | ||
344 | + if (ret) { | ||
345 | + error_report("failed to get KVM_REG_ARM64_SVE_VLS: %s", | ||
346 | + strerror(errno)); | ||
347 | + abort(); | ||
348 | + } | ||
349 | + | ||
350 | + for (i = KVM_ARM64_SVE_VLS_WORDS - 1; i >= 0; --i) { | ||
351 | + if (vls[i]) { | ||
352 | + vq = 64 - clz64(vls[i]) + i * 64; | ||
353 | + break; | ||
354 | + } | ||
355 | + } | ||
356 | + if (vq > ARM_MAX_VQ) { | ||
357 | + warn_report("KVM supports vector lengths larger than " | ||
358 | + "QEMU can enable"); | ||
359 | + } | ||
360 | + } | ||
361 | + | ||
362 | + for (i = 0; i < KVM_ARM64_SVE_VLS_WORDS; ++i) { | ||
363 | + if (!vls[i]) { | ||
364 | + continue; | ||
365 | + } | ||
366 | + for (j = 1; j <= 64; ++j) { | ||
367 | + vq = j + i * 64; | ||
368 | + if (vq > ARM_MAX_VQ) { | ||
369 | + return; | ||
370 | + } | ||
371 | + if (vls[i] & (1UL << (j - 1))) { | ||
372 | + set_bit(vq - 1, map); | ||
373 | + } | ||
374 | + } | ||
375 | + } | ||
376 | +} | ||
377 | + | ||
378 | +static int kvm_arm_sve_set_vls(CPUState *cs) | ||
379 | +{ | ||
380 | + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = {0}; | ||
381 | + struct kvm_one_reg reg = { | ||
382 | + .id = KVM_REG_ARM64_SVE_VLS, | ||
383 | + .addr = (uint64_t)&vls[0], | ||
384 | + }; | ||
385 | + ARMCPU *cpu = ARM_CPU(cs); | ||
386 | + uint32_t vq; | ||
387 | + int i, j; | ||
388 | + | ||
389 | + assert(cpu->sve_max_vq <= KVM_ARM64_SVE_VQ_MAX); | ||
390 | + | ||
391 | + for (vq = 1; vq <= cpu->sve_max_vq; ++vq) { | ||
392 | + if (test_bit(vq - 1, cpu->sve_vq_map)) { | ||
393 | + i = (vq - 1) / 64; | ||
394 | + j = (vq - 1) % 64; | ||
395 | + vls[i] |= 1UL << j; | ||
396 | + } | ||
397 | + } | ||
398 | + | ||
399 | + return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
400 | +} | ||
401 | + | ||
402 | #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 | ||
403 | |||
404 | int kvm_arch_init_vcpu(CPUState *cs) | ||
405 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
406 | |||
407 | if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE || | ||
408 | !object_dynamic_cast(OBJECT(cpu), TYPE_AARCH64_CPU)) { | ||
409 | - fprintf(stderr, "KVM is not supported for this guest CPU type\n"); | ||
410 | + error_report("KVM is not supported for this guest CPU type"); | ||
411 | return -EINVAL; | ||
412 | } | ||
413 | |||
414 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
415 | } | ||
416 | |||
417 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
418 | + ret = kvm_arm_sve_set_vls(cs); | ||
419 | + if (ret) { | ||
420 | + return ret; | ||
421 | + } | ||
422 | ret = kvm_arm_vcpu_finalize(cs, KVM_ARM_VCPU_SVE); | ||
423 | if (ret) { | ||
424 | return ret; | ||
425 | diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c | ||
426 | index XXXXXXX..XXXXXXX 100644 | 72 | index XXXXXXX..XXXXXXX 100644 |
427 | --- a/tests/arm-cpu-features.c | 73 | --- a/docs/system/arm/sbsa.rst |
428 | +++ b/tests/arm-cpu-features.c | 74 | +++ b/docs/system/arm/sbsa.rst |
429 | @@ -XXX,XX +XXX,XX @@ static QDict *resp_get_props(QDict *resp) | 75 | @@ -XXX,XX +XXX,XX @@ |
430 | return qdict; | 76 | Arm Server Base System Architecture Reference board (``sbsa-ref``) |
431 | } | 77 | ================================================================== |
432 | 78 | ||
433 | +static bool resp_get_feature(QDict *resp, const char *feature) | 79 | -While the `virt` board is a generic board platform that doesn't match |
434 | +{ | 80 | -any real hardware the `sbsa-ref` board intends to look like real |
435 | + QDict *props; | 81 | +While the ``virt`` board is a generic board platform that doesn't match |
436 | + | 82 | +any real hardware the ``sbsa-ref`` board intends to look like real |
437 | + g_assert(resp); | 83 | hardware. The `Server Base System Architecture |
438 | + g_assert(resp_has_props(resp)); | 84 | <https://developer.arm.com/documentation/den0029/latest>`_ defines a |
439 | + props = resp_get_props(resp); | 85 | minimum base line of hardware support and importantly how the firmware |
440 | + g_assert(qdict_get(props, feature)); | 86 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
441 | + return qdict_get_bool(props, feature); | ||
442 | +} | ||
443 | + | ||
444 | #define assert_has_feature(qts, cpu_type, feature) \ | ||
445 | ({ \ | ||
446 | QDict *_resp = do_query_no_props(qts, cpu_type); \ | ||
447 | @@ -XXX,XX +XXX,XX @@ static void sve_tests_sve_off(const void *data) | ||
448 | qtest_quit(qts); | ||
449 | } | ||
450 | |||
451 | +static void sve_tests_sve_off_kvm(const void *data) | ||
452 | +{ | ||
453 | + QTestState *qts; | ||
454 | + | ||
455 | + qts = qtest_init(MACHINE "-accel kvm -cpu max,sve=off"); | ||
456 | + | ||
457 | + /* | ||
458 | + * We don't know if this host supports SVE so we don't | ||
459 | + * attempt to test enabling anything. We only test that | ||
460 | + * everything is disabled (as it should be with sve=off) | ||
461 | + * and that using sve<N>=off to explicitly disable vector | ||
462 | + * lengths is OK too. | ||
463 | + */ | ||
464 | + assert_sve_vls(qts, "max", 0, NULL); | ||
465 | + assert_sve_vls(qts, "max", 0, "{ 'sve128': false }"); | ||
466 | + | ||
467 | + qtest_quit(qts); | ||
468 | +} | ||
469 | + | ||
470 | static void test_query_cpu_model_expansion(const void *data) | ||
471 | { | ||
472 | QTestState *qts; | ||
473 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
474 | qts = qtest_init(MACHINE "-accel kvm -cpu host"); | ||
475 | |||
476 | if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
477 | + bool kvm_supports_sve; | ||
478 | + char max_name[8], name[8]; | ||
479 | + uint32_t max_vq, vq; | ||
480 | + uint64_t vls; | ||
481 | + QDict *resp; | ||
482 | + char *error; | ||
483 | + | ||
484 | assert_has_feature(qts, "host", "aarch64"); | ||
485 | assert_has_feature(qts, "host", "pmu"); | ||
486 | |||
487 | - assert_has_feature(qts, "max", "sve"); | ||
488 | - | ||
489 | assert_error(qts, "cortex-a15", | ||
490 | "We cannot guarantee the CPU type 'cortex-a15' works " | ||
491 | "with KVM on this host", NULL); | ||
492 | + | ||
493 | + assert_has_feature(qts, "max", "sve"); | ||
494 | + resp = do_query_no_props(qts, "max"); | ||
495 | + kvm_supports_sve = resp_get_feature(resp, "sve"); | ||
496 | + vls = resp_get_sve_vls(resp); | ||
497 | + qobject_unref(resp); | ||
498 | + | ||
499 | + if (kvm_supports_sve) { | ||
500 | + g_assert(vls != 0); | ||
501 | + max_vq = 64 - __builtin_clzll(vls); | ||
502 | + sprintf(max_name, "sve%d", max_vq * 128); | ||
503 | + | ||
504 | + /* Enabling a supported length is of course fine. */ | ||
505 | + assert_sve_vls(qts, "max", vls, "{ %s: true }", max_name); | ||
506 | + | ||
507 | + /* Get the next supported length smaller than max-vq. */ | ||
508 | + vq = 64 - __builtin_clzll(vls & ~BIT_ULL(max_vq - 1)); | ||
509 | + if (vq) { | ||
510 | + /* | ||
511 | + * We have at least one length smaller than max-vq, | ||
512 | + * so we can disable max-vq. | ||
513 | + */ | ||
514 | + assert_sve_vls(qts, "max", (vls & ~BIT_ULL(max_vq - 1)), | ||
515 | + "{ %s: false }", max_name); | ||
516 | + | ||
517 | + /* | ||
518 | + * Smaller, supported vector lengths cannot be disabled | ||
519 | + * unless all larger, supported vector lengths are also | ||
520 | + * disabled. | ||
521 | + */ | ||
522 | + sprintf(name, "sve%d", vq * 128); | ||
523 | + error = g_strdup_printf("cannot disable %s", name); | ||
524 | + assert_error(qts, "max", error, | ||
525 | + "{ %s: true, %s: false }", | ||
526 | + max_name, name); | ||
527 | + g_free(error); | ||
528 | + } | ||
529 | + | ||
530 | + /* | ||
531 | + * The smallest, supported vector length is required, because | ||
532 | + * we need at least one vector length enabled. | ||
533 | + */ | ||
534 | + vq = __builtin_ffsll(vls); | ||
535 | + sprintf(name, "sve%d", vq * 128); | ||
536 | + error = g_strdup_printf("cannot disable %s", name); | ||
537 | + assert_error(qts, "max", error, "{ %s: false }", name); | ||
538 | + g_free(error); | ||
539 | + | ||
540 | + /* Get an unsupported length. */ | ||
541 | + for (vq = 1; vq <= max_vq; ++vq) { | ||
542 | + if (!(vls & BIT_ULL(vq - 1))) { | ||
543 | + break; | ||
544 | + } | ||
545 | + } | ||
546 | + if (vq <= SVE_MAX_VQ) { | ||
547 | + sprintf(name, "sve%d", vq * 128); | ||
548 | + error = g_strdup_printf("cannot enable %s", name); | ||
549 | + assert_error(qts, "max", error, "{ %s: true }", name); | ||
550 | + g_free(error); | ||
551 | + } | ||
552 | + } else { | ||
553 | + g_assert(vls == 0); | ||
554 | + } | ||
555 | } else { | ||
556 | assert_has_not_feature(qts, "host", "aarch64"); | ||
557 | assert_has_not_feature(qts, "host", "pmu"); | ||
558 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
559 | if (kvm_available) { | ||
560 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", | ||
561 | NULL, test_query_cpu_model_expansion_kvm); | ||
562 | + if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
563 | + qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off", | ||
564 | + NULL, sve_tests_sve_off_kvm); | ||
565 | + } | ||
566 | } | ||
567 | |||
568 | return g_test_run(); | ||
569 | diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst | ||
570 | index XXXXXXX..XXXXXXX 100644 | 87 | index XXXXXXX..XXXXXXX 100644 |
571 | --- a/docs/arm-cpu-features.rst | 88 | --- a/docs/system/arm/virt.rst |
572 | +++ b/docs/arm-cpu-features.rst | 89 | +++ b/docs/system/arm/virt.rst |
573 | @@ -XXX,XX +XXX,XX @@ SVE CPU Property Dependencies and Constraints | 90 | @@ -XXX,XX +XXX,XX @@ |
574 | 91 | 'virt' generic virtual platform (``virt``) | |
575 | 1) At least one vector length must be enabled when `sve` is enabled. | 92 | ========================================== |
576 | 93 | ||
577 | - 2) If a vector length `N` is enabled, then all power-of-two vector | 94 | -The `virt` board is a platform which does not correspond to any |
578 | - lengths smaller than `N` must also be enabled. E.g. if `sve512` | 95 | +The ``virt`` board is a platform which does not correspond to any |
579 | - is enabled, then the 128-bit and 256-bit vector lengths must also | 96 | real hardware; it is designed for use in virtual machines. |
580 | - be enabled. | 97 | It is the recommended board type if you simply want to run |
581 | + 2) If a vector length `N` is enabled, then, when KVM is enabled, all | 98 | a guest such as Linux and do not care about reproducing the |
582 | + smaller, host supported vector lengths must also be enabled. If | 99 | diff --git a/docs/system/cpu-hotplug.rst b/docs/system/cpu-hotplug.rst |
583 | + KVM is not enabled, then only all the smaller, power-of-two vector | 100 | index XXXXXXX..XXXXXXX 100644 |
584 | + lengths must be enabled. E.g. with KVM if the host supports all | 101 | --- a/docs/system/cpu-hotplug.rst |
585 | + vector lengths up to 512-bits (128, 256, 384, 512), then if `sve512` | 102 | +++ b/docs/system/cpu-hotplug.rst |
586 | + is enabled, the 128-bit vector length, 256-bit vector length, and | 103 | @@ -XXX,XX +XXX,XX @@ vCPU hotplug |
587 | + 384-bit vector length must also be enabled. Without KVM, the 384-bit | 104 | } |
588 | + vector length would not be required. | 105 | (QEMU) |
589 | + | 106 | |
590 | + 3) If KVM is enabled then only vector lengths that the host CPU type | 107 | -(5) Optionally, run QMP `query-cpus-fast` for some details about the |
591 | + support may be enabled. If SVE is not supported by the host, then | 108 | +(5) Optionally, run QMP ``query-cpus-fast`` for some details about the |
592 | + no `sve*` properties may be enabled. | 109 | vCPUs:: |
593 | 110 | ||
594 | SVE CPU Property Parsing Semantics | 111 | (QEMU) query-cpus-fast |
595 | ---------------------------------- | 112 | diff --git a/docs/system/guest-loader.rst b/docs/system/guest-loader.rst |
596 | @@ -XXX,XX +XXX,XX @@ SVE CPU Property Parsing Semantics | 113 | index XXXXXXX..XXXXXXX 100644 |
597 | an error is generated. | 114 | --- a/docs/system/guest-loader.rst |
598 | 115 | +++ b/docs/system/guest-loader.rst | |
599 | 2) If SVE is enabled (`sve=on`), but no `sve<N>` CPU properties are | 116 | @@ -XXX,XX +XXX,XX @@ |
600 | - provided, then all supported vector lengths are enabled, including | 117 | Guest Loader |
601 | - the non-power-of-two lengths. | 118 | ------------ |
602 | + provided, then all supported vector lengths are enabled, which when | 119 | |
603 | + KVM is not in use means including the non-power-of-two lengths, and, | 120 | -The guest loader is similar to the `generic-loader` although it is |
604 | + when KVM is in use, it means all vector lengths supported by the host | 121 | +The guest loader is similar to the ``generic-loader`` although it is |
605 | + processor. | 122 | aimed at a particular use case of loading hypervisor guests. This is |
606 | 123 | useful for debugging hypervisors without having to jump through the | |
607 | 3) If SVE is enabled, then an error is generated when attempting to | 124 | hoops of firmware and boot-loaders. |
608 | disable the last enabled vector length (see constraint (1) of "SVE | 125 | @@ -XXX,XX +XXX,XX @@ multi-boot capability. A typical example would look like: |
609 | @@ -XXX,XX +XXX,XX @@ SVE CPU Property Parsing Semantics | 126 | In the above example the Xen hypervisor is loaded by the -kernel |
610 | has been explicitly disabled, then an error is generated (see | 127 | parameter and passed it's boot arguments via -append. The Dom0 guest |
611 | constraint (2) of "SVE CPU Property Dependencies and Constraints"). | 128 | is loaded into the areas of memory. Each blob will get |
612 | 129 | -`/chosen/module@<addr>` entry in the FDT to indicate it's location and | |
613 | - 5) If one or more `sve<N>` CPU properties are set `off`, but no `sve<N>`, | 130 | +``/chosen/module@<addr>`` entry in the FDT to indicate it's location and |
614 | + 5) When KVM is enabled, if the host does not support SVE, then an error | 131 | size. Additional information can be passed with by using additional |
615 | + is generated when attempting to enable any `sve*` properties (see | 132 | arguments. |
616 | + constraint (3) of "SVE CPU Property Dependencies and Constraints"). | 133 | |
617 | + | 134 | Currently the only supported machines which use FDT data to boot are |
618 | + 6) When KVM is enabled, if the host does support SVE, then an error is | 135 | -the ARM and RiscV `virt` machines. |
619 | + generated when attempting to enable any vector lengths not supported | 136 | +the ARM and RiscV ``virt`` machines. |
620 | + by the host (see constraint (3) of "SVE CPU Property Dependencies and | 137 | |
621 | + Constraints"). | 138 | Arguments |
622 | + | 139 | ^^^^^^^^^ |
623 | + 7) If one or more `sve<N>` CPU properties are set `off`, but no `sve<N>`, | 140 | diff --git a/docs/system/ppc/powernv.rst b/docs/system/ppc/powernv.rst |
624 | CPU properties are set `on`, then the specified vector lengths are | 141 | index XXXXXXX..XXXXXXX 100644 |
625 | disabled but the default for any unspecified lengths remains enabled. | 142 | --- a/docs/system/ppc/powernv.rst |
626 | - Disabling a power-of-two vector length also disables all vector | 143 | +++ b/docs/system/ppc/powernv.rst |
627 | - lengths larger than the power-of-two length (see constraint (2) of | 144 | @@ -XXX,XX +XXX,XX @@ Firmware |
628 | - "SVE CPU Property Dependencies and Constraints"). | 145 | -------- |
629 | + When KVM is not enabled, disabling a power-of-two vector length also | 146 | |
630 | + disables all vector lengths larger than the power-of-two length. | 147 | The OPAL firmware (OpenPower Abstraction Layer) for OpenPower systems |
631 | + When KVM is enabled, then disabling any supported vector length also | 148 | -includes the runtime services `skiboot` and the bootloader kernel and |
632 | + disables all larger vector lengths (see constraint (2) of "SVE CPU | 149 | -initramfs `skiroot`. Source code can be found on GitHub: |
633 | + Property Dependencies and Constraints"). | 150 | +includes the runtime services ``skiboot`` and the bootloader kernel and |
634 | 151 | +initramfs ``skiroot``. Source code can be found on GitHub: | |
635 | - 6) If one or more `sve<N>` CPU properties are set to `on`, then they | 152 | |
636 | + 8) If one or more `sve<N>` CPU properties are set to `on`, then they | 153 | https://github.com/open-power. |
637 | are enabled and all unspecified lengths default to disabled, except | 154 | |
638 | for the required lengths per constraint (2) of "SVE CPU Property | 155 | -Prebuilt images of `skiboot` and `skiboot` are made available on the `OpenPOWER <https://openpower.xyz/job/openpower/job/openpower-op-build/>`__ site. To boot a POWER9 machine, use the `witherspoon <https://openpower.xyz/job/openpower/job/openpower-op-build/label=slave,target=witherspoon/lastSuccessfulBuild/>`__ images. For POWER8, use |
639 | Dependencies and Constraints", which will even be auto-enabled if | 156 | +Prebuilt images of ``skiboot`` and ``skiboot`` are made available on the `OpenPOWER <https://openpower.xyz/job/openpower/job/openpower-op-build/>`__ site. To boot a POWER9 machine, use the `witherspoon <https://openpower.xyz/job/openpower/job/openpower-op-build/label=slave,target=witherspoon/lastSuccessfulBuild/>`__ images. For POWER8, use |
640 | they were not explicitly enabled. | 157 | the `palmetto <https://openpower.xyz/job/openpower/job/openpower-op-build/label=slave,target=palmetto/lastSuccessfulBuild/>`__ images. |
641 | 158 | ||
642 | - 7) If SVE was disabled (`sve=off`), allowing all vector lengths to be | 159 | -QEMU includes a prebuilt image of `skiboot` which is updated when a |
643 | + 9) If SVE was disabled (`sve=off`), allowing all vector lengths to be | 160 | +QEMU includes a prebuilt image of ``skiboot`` which is updated when a |
644 | explicitly disabled (i.e. avoiding the error specified in (3) of | 161 | more recent version is required by the models. |
645 | "SVE CPU Property Parsing Semantics"), then if later an `sve=on` is | 162 | |
646 | provided an error will be generated. To avoid this error, one must | 163 | Boot options |
164 | diff --git a/docs/system/riscv/microchip-icicle-kit.rst b/docs/system/riscv/microchip-icicle-kit.rst | ||
165 | index XXXXXXX..XXXXXXX 100644 | ||
166 | --- a/docs/system/riscv/microchip-icicle-kit.rst | ||
167 | +++ b/docs/system/riscv/microchip-icicle-kit.rst | ||
168 | @@ -XXX,XX +XXX,XX @@ Then we can boot the machine by: | ||
169 | -serial chardev:serial1 | ||
170 | |||
171 | With above command line, current terminal session will be used for the first | ||
172 | -serial port. Open another terminal window, and use `minicom` to connect the | ||
173 | +serial port. Open another terminal window, and use ``minicom`` to connect the | ||
174 | second serial port. | ||
175 | |||
176 | .. code-block:: bash | ||
177 | diff --git a/docs/system/riscv/virt.rst b/docs/system/riscv/virt.rst | ||
178 | index XXXXXXX..XXXXXXX 100644 | ||
179 | --- a/docs/system/riscv/virt.rst | ||
180 | +++ b/docs/system/riscv/virt.rst | ||
181 | @@ -XXX,XX +XXX,XX @@ | ||
182 | 'virt' Generic Virtual Platform (``virt``) | ||
183 | ========================================== | ||
184 | |||
185 | -The `virt` board is a platform which does not correspond to any real hardware; | ||
186 | +The ``virt`` board is a platform which does not correspond to any real hardware; | ||
187 | it is designed for use in virtual machines. It is the recommended board type | ||
188 | if you simply want to run a guest such as Linux and do not care about | ||
189 | reproducing the idiosyncrasies and limitations of a particular bit of | ||
647 | -- | 190 | -- |
648 | 2.20.1 | 191 | 2.20.1 |
649 | 192 | ||
650 | 193 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The section describing the removed feature "-usbdevice ccid" had a |
---|---|---|---|
2 | typo so the markup started with single backtick and ended with double | ||
3 | backtick; fix it. | ||
2 | 4 | ||
3 | By performing this store early, we avoid having to save and restore | ||
4 | the register holding the address around any function calls. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20191023150057.25731-15-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20210726142338.31872-10-peter.maydell@linaro.org | ||
10 | --- | 9 | --- |
11 | target/arm/helper.c | 2 +- | 10 | docs/about/removed-features.rst | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 12 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 15 | --- a/docs/about/removed-features.rst |
17 | +++ b/target/arm/helper.c | 16 | +++ b/docs/about/removed-features.rst |
18 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 17 | @@ -XXX,XX +XXX,XX @@ devices. Drives the board doesn't pick up can no longer be used with |
19 | { | 18 | ''''''''''''''''''''''''''''''''''''' |
20 | uint32_t flags, pstate_for_ss; | 19 | |
21 | 20 | This option was undocumented and not used in the field. | |
22 | + *cs_base = 0; | 21 | -Use `-device usb-ccid`` instead. |
23 | flags = rebuild_hflags_internal(env); | 22 | +Use ``-device usb-ccid`` instead. |
24 | 23 | ||
25 | if (is_a64(env)) { | 24 | RISC-V firmware not booted by default (removed in 5.1) |
26 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 25 | '''''''''''''''''''''''''''''''''''''''''''''''''''''' |
27 | } | ||
28 | |||
29 | *pflags = flags; | ||
30 | - *cs_base = 0; | ||
31 | } | ||
32 | |||
33 | #ifdef TARGET_AARCH64 | ||
34 | -- | 26 | -- |
35 | 2.20.1 | 27 | 2.20.1 |
36 | 28 | ||
37 | 29 | diff view generated by jsdifflib |
1 | Switch the xilinx_axidma code away from bottom-half based ptimers to | 1 | The documentation of the posix_acl option has a stray backtick |
---|---|---|---|
2 | the new transaction-based ptimer API. This just requires adding | 2 | at the end of the text (which is rendered literally into the HTML). |
3 | begin/commit calls around the various places that modify the ptimer | 3 | Delete it. |
4 | state, and using the new ptimer_init() function to create the timer. | ||
5 | 4 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com> |
10 | Message-id: 20191017132122.4402-4-peter.maydell@linaro.org | 9 | Message-id: 20210726142338.31872-11-peter.maydell@linaro.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | 10 | --- |
13 | hw/dma/xilinx_axidma.c | 9 +++++---- | 11 | docs/tools/virtiofsd.rst | 2 +- |
14 | 1 file changed, 5 insertions(+), 4 deletions(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 13 | ||
16 | diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c | 14 | diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/dma/xilinx_axidma.c | 16 | --- a/docs/tools/virtiofsd.rst |
19 | +++ b/hw/dma/xilinx_axidma.c | 17 | +++ b/docs/tools/virtiofsd.rst |
20 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ Options |
21 | #include "hw/ptimer.h" | 19 | default is ``no_xattr``. |
22 | #include "hw/qdev-properties.h" | 20 | |
23 | #include "qemu/log.h" | 21 | * posix_acl|no_posix_acl - |
24 | -#include "qemu/main-loop.h" | 22 | - Enable/disable posix acl support. Posix ACLs are disabled by default`. |
25 | #include "qemu/module.h" | 23 | + Enable/disable posix acl support. Posix ACLs are disabled by default. |
26 | 24 | ||
27 | #include "hw/stream.h" | 25 | .. option:: --socket-path=PATH |
28 | @@ -XXX,XX +XXX,XX @@ enum { | ||
29 | }; | ||
30 | |||
31 | struct Stream { | ||
32 | - QEMUBH *bh; | ||
33 | ptimer_state *ptimer; | ||
34 | qemu_irq irq; | ||
35 | |||
36 | @@ -XXX,XX +XXX,XX @@ static void stream_complete(struct Stream *s) | ||
37 | unsigned int comp_delay; | ||
38 | |||
39 | /* Start the delayed timer. */ | ||
40 | + ptimer_transaction_begin(s->ptimer); | ||
41 | comp_delay = s->regs[R_DMACR] >> 24; | ||
42 | if (comp_delay) { | ||
43 | ptimer_stop(s->ptimer); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void stream_complete(struct Stream *s) | ||
45 | s->regs[R_DMASR] |= DMASR_IOC_IRQ; | ||
46 | stream_reload_complete_cnt(s); | ||
47 | } | ||
48 | + ptimer_transaction_commit(s->ptimer); | ||
49 | } | ||
50 | |||
51 | static void stream_process_mem2s(struct Stream *s, StreamSlave *tx_data_dev, | ||
52 | @@ -XXX,XX +XXX,XX @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp) | ||
53 | struct Stream *st = &s->streams[i]; | ||
54 | |||
55 | st->nr = i; | ||
56 | - st->bh = qemu_bh_new(timer_hit, st); | ||
57 | - st->ptimer = ptimer_init_with_bh(st->bh, PTIMER_POLICY_DEFAULT); | ||
58 | + st->ptimer = ptimer_init(timer_hit, st, PTIMER_POLICY_DEFAULT); | ||
59 | + ptimer_transaction_begin(st->ptimer); | ||
60 | ptimer_set_freq(st->ptimer, s->freqhz); | ||
61 | + ptimer_transaction_commit(st->ptimer); | ||
62 | } | ||
63 | return; | ||
64 | 26 | ||
65 | -- | 27 | -- |
66 | 2.20.1 | 28 | 2.20.1 |
67 | 29 | ||
68 | 30 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | If the user provides both a BIOS/firmware image and also a guest |
---|---|---|---|
2 | kernel filename, arm_setup_firmware_boot() will pass the | ||
3 | kernel image to the firmware via the fw_cfg device. However we | ||
4 | weren't checking whether there really was a fw_cfg device present, | ||
5 | and if there wasn't we would crash. | ||
2 | 6 | ||
3 | Create a function to compute the values of the TBFLAG_A32 bits | 7 | This crash can be provoked with a command line such as |
4 | that will be cached, and are used by M-profile. | 8 | qemu-system-aarch64 -M raspi3 -kernel /dev/null -bios /dev/null -display none |
5 | 9 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 10 | It is currently only possible on the raspi3 machine, because unless |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | the machine sets info->firmware_loaded we won't call |
8 | Message-id: 20191023150057.25731-6-richard.henderson@linaro.org | 12 | arm_setup_firmware_boot(), and the only machines which set that are: |
13 | * virt (has a fw-cfg device) | ||
14 | * sbsa-ref (checks itself for kernel_filename && firmware_loaded) | ||
15 | * raspi3 (crashes) | ||
16 | |||
17 | But this is an unfortunate beartrap to leave for future machine | ||
18 | model implementors, so we should handle this situation in boot.c. | ||
19 | |||
20 | Check in arm_setup_firmware_boot() whether the fw-cfg device exists | ||
21 | before trying to load files into it, and if it doesn't exist then | ||
22 | exit with a hopefully helpful error message. | ||
23 | |||
24 | Because we now handle this check in a machine-agnostic way, we | ||
25 | can remove the check from sbsa-ref. | ||
26 | |||
27 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/503 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
30 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
31 | Message-id: 20210726163351.32086-1-peter.maydell@linaro.org | ||
10 | --- | 32 | --- |
11 | target/arm/helper.c | 45 ++++++++++++++++++++++++++++++--------------- | 33 | hw/arm/boot.c | 9 +++++++++ |
12 | 1 file changed, 30 insertions(+), 15 deletions(-) | 34 | hw/arm/sbsa-ref.c | 7 ------- |
35 | 2 files changed, 9 insertions(+), 7 deletions(-) | ||
13 | 36 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 37 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c |
15 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 39 | --- a/hw/arm/boot.c |
17 | +++ b/target/arm/helper.c | 40 | +++ b/hw/arm/boot.c |
18 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | 41 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_firmware_boot(ARMCPU *cpu, struct arm_boot_info *info) |
19 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | 42 | bool try_decompressing_kernel; |
20 | } | 43 | |
21 | 44 | fw_cfg = fw_cfg_find(); | |
22 | +static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
23 | + ARMMMUIdx mmu_idx) | ||
24 | +{ | ||
25 | + uint32_t flags = 0; | ||
26 | + | 45 | + |
27 | + if (arm_v7m_is_handler_mode(env)) { | 46 | + if (!fw_cfg) { |
28 | + flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1); | 47 | + error_report("This machine type does not support loading both " |
29 | + } | 48 | + "a guest firmware/BIOS image and a guest kernel at " |
30 | + | 49 | + "the same time. You should change your QEMU command " |
31 | + /* | 50 | + "line to specify one or the other, but not both."); |
32 | + * v8M always applies stack limit checks unless CCR.STKOFHFNMIGN | 51 | + exit(1); |
33 | + * is suppressing them because the requested execution priority | ||
34 | + * is less than 0. | ||
35 | + */ | ||
36 | + if (arm_feature(env, ARM_FEATURE_V8) && | ||
37 | + !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && | ||
38 | + (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | ||
39 | + flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1); | ||
40 | + } | ||
41 | + | ||
42 | + return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
43 | +} | ||
44 | + | ||
45 | static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
46 | ARMMMUIdx mmu_idx) | ||
47 | { | ||
48 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
49 | } | ||
50 | } else { | ||
51 | *pc = env->regs[15]; | ||
52 | - flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); | ||
53 | + | ||
54 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
55 | + flags = rebuild_hflags_m32(env, fp_el, mmu_idx); | ||
56 | + } else { | ||
57 | + flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); | ||
58 | + } | 52 | + } |
59 | + | 53 | + |
60 | flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); | 54 | try_decompressing_kernel = arm_feature(&cpu->env, |
61 | flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, env->vfp.vec_len); | 55 | ARM_FEATURE_AARCH64); |
62 | flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, env->vfp.vec_stride); | 56 | |
63 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 57 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
64 | } | 58 | index XXXXXXX..XXXXXXX 100644 |
65 | } | 59 | --- a/hw/arm/sbsa-ref.c |
66 | 60 | +++ b/hw/arm/sbsa-ref.c | |
67 | - if (arm_v7m_is_handler_mode(env)) { | 61 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) |
68 | - flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1); | 62 | |
63 | firmware_loaded = sbsa_firmware_init(sms, sysmem, secure_sysmem); | ||
64 | |||
65 | - if (machine->kernel_filename && firmware_loaded) { | ||
66 | - error_report("sbsa-ref: No fw_cfg device on this machine, " | ||
67 | - "so -kernel option is not supported when firmware loaded, " | ||
68 | - "please load OS from hard disk instead"); | ||
69 | - exit(1); | ||
69 | - } | 70 | - } |
70 | - | 71 | - |
71 | - /* v8M always applies stack limit checks unless CCR.STKOFHFNMIGN is | 72 | /* |
72 | - * suppressing them because the requested execution priority is less than 0. | 73 | * This machine has EL3 enabled, external firmware should supply PSCI |
73 | - */ | 74 | * implementation, so the QEMU's internal PSCI is disabled. |
74 | - if (arm_feature(env, ARM_FEATURE_V8) && | ||
75 | - arm_feature(env, ARM_FEATURE_M) && | ||
76 | - !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && | ||
77 | - (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | ||
78 | - flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1); | ||
79 | - } | ||
80 | - | ||
81 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
82 | FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { | ||
83 | flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | ||
84 | -- | 75 | -- |
85 | 2.20.1 | 76 | 2.20.1 |
86 | 77 | ||
87 | 78 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Hoist the computation of some TBFLAG_A32 bits that only apply to | ||
4 | M-profile under a single test for ARM_FEATURE_M. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20191023150057.25731-7-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.c | 49 +++++++++++++++++++++------------------------ | ||
12 | 1 file changed, 23 insertions(+), 26 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper.c | ||
17 | +++ b/target/arm/helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
19 | |||
20 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
21 | flags = rebuild_hflags_m32(env, fp_el, mmu_idx); | ||
22 | + | ||
23 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
24 | + FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) | ||
25 | + != env->v7m.secure) { | ||
26 | + flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | ||
27 | + } | ||
28 | + | ||
29 | + if ((env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) && | ||
30 | + (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) || | ||
31 | + (env->v7m.secure && | ||
32 | + !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) { | ||
33 | + /* | ||
34 | + * ASPEN is set, but FPCA/SFPA indicate that there is no | ||
35 | + * active FP context; we must create a new FP context before | ||
36 | + * executing any FP insn. | ||
37 | + */ | ||
38 | + flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); | ||
39 | + } | ||
40 | + | ||
41 | + bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
42 | + if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) { | ||
43 | + flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); | ||
44 | + } | ||
45 | } else { | ||
46 | flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); | ||
47 | } | ||
48 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
49 | } | ||
50 | } | ||
51 | |||
52 | - if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
53 | - FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { | ||
54 | - flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | ||
55 | - } | ||
56 | - | ||
57 | - if (arm_feature(env, ARM_FEATURE_M) && | ||
58 | - (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) && | ||
59 | - (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) || | ||
60 | - (env->v7m.secure && | ||
61 | - !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) { | ||
62 | - /* | ||
63 | - * ASPEN is set, but FPCA/SFPA indicate that there is no active | ||
64 | - * FP context; we must create a new FP context before executing | ||
65 | - * any FP insn. | ||
66 | - */ | ||
67 | - flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); | ||
68 | - } | ||
69 | - | ||
70 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
71 | - bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
72 | - | ||
73 | - if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) { | ||
74 | - flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); | ||
75 | - } | ||
76 | - } | ||
77 | - | ||
78 | if (!arm_feature(env, ARM_FEATURE_M)) { | ||
79 | int target_el = arm_debug_target_el(env); | ||
80 | |||
81 | -- | ||
82 | 2.20.1 | ||
83 | |||
84 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Currently a trivial wrapper for rebuild_hflags_common_32. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20191023150057.25731-8-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/helper.c | 8 +++++++- | ||
11 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper.c | ||
16 | +++ b/target/arm/helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
18 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
19 | } | ||
20 | |||
21 | +static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
22 | + ARMMMUIdx mmu_idx) | ||
23 | +{ | ||
24 | + return rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); | ||
25 | +} | ||
26 | + | ||
27 | static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
28 | ARMMMUIdx mmu_idx) | ||
29 | { | ||
30 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
31 | flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); | ||
32 | } | ||
33 | } else { | ||
34 | - flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); | ||
35 | + flags = rebuild_hflags_a32(env, fp_el, mmu_idx); | ||
36 | } | ||
37 | |||
38 | flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); | ||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Create a function to compute the values of the TBFLAG_ANY bits | ||
4 | that will be cached, and are used by A-profile. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20191023150057.25731-9-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.c | 20 ++++++++++++-------- | ||
12 | 1 file changed, 12 insertions(+), 8 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper.c | ||
17 | +++ b/target/arm/helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
19 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
20 | } | ||
21 | |||
22 | +static uint32_t rebuild_hflags_aprofile(CPUARMState *env) | ||
23 | +{ | ||
24 | + int flags = 0; | ||
25 | + | ||
26 | + flags = FIELD_DP32(flags, TBFLAG_ANY, DEBUG_TARGET_EL, | ||
27 | + arm_debug_target_el(env)); | ||
28 | + return flags; | ||
29 | +} | ||
30 | + | ||
31 | static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
32 | ARMMMUIdx mmu_idx) | ||
33 | { | ||
34 | - return rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); | ||
35 | + uint32_t flags = rebuild_hflags_aprofile(env); | ||
36 | + return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
37 | } | ||
38 | |||
39 | static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
40 | ARMMMUIdx mmu_idx) | ||
41 | { | ||
42 | + uint32_t flags = rebuild_hflags_aprofile(env); | ||
43 | ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); | ||
44 | ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); | ||
45 | - uint32_t flags = 0; | ||
46 | uint64_t sctlr; | ||
47 | int tbii, tbid; | ||
48 | |||
49 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
50 | } | ||
51 | } | ||
52 | |||
53 | - if (!arm_feature(env, ARM_FEATURE_M)) { | ||
54 | - int target_el = arm_debug_target_el(env); | ||
55 | - | ||
56 | - flags = FIELD_DP32(flags, TBFLAG_ANY, DEBUG_TARGET_EL, target_el); | ||
57 | - } | ||
58 | - | ||
59 | *pflags = flags; | ||
60 | *cs_base = 0; | ||
61 | } | ||
62 | -- | ||
63 | 2.20.1 | ||
64 | |||
65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | We do not need to compute any of these values for M-profile. | ||
4 | Further, XSCALE_CPAR overlaps VECSTRIDE so obviously the two | ||
5 | sets must be mutually exclusive. | ||
6 | |||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20191023150057.25731-10-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper.c | 21 ++++++++++++++------- | ||
13 | 1 file changed, 14 insertions(+), 7 deletions(-) | ||
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 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
20 | } | ||
21 | } else { | ||
22 | flags = rebuild_hflags_a32(env, fp_el, mmu_idx); | ||
23 | + | ||
24 | + /* | ||
25 | + * Note that XSCALE_CPAR shares bits with VECSTRIDE. | ||
26 | + * Note that VECLEN+VECSTRIDE are RES0 for M-profile. | ||
27 | + */ | ||
28 | + if (arm_feature(env, ARM_FEATURE_XSCALE)) { | ||
29 | + flags = FIELD_DP32(flags, TBFLAG_A32, | ||
30 | + XSCALE_CPAR, env->cp15.c15_cpar); | ||
31 | + } else { | ||
32 | + flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, | ||
33 | + env->vfp.vec_len); | ||
34 | + flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, | ||
35 | + env->vfp.vec_stride); | ||
36 | + } | ||
37 | } | ||
38 | |||
39 | flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); | ||
40 | - flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, env->vfp.vec_len); | ||
41 | - flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, env->vfp.vec_stride); | ||
42 | flags = FIELD_DP32(flags, TBFLAG_A32, CONDEXEC, env->condexec_bits); | ||
43 | if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) | ||
44 | || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | ||
45 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
46 | } | ||
47 | - /* Note that XSCALE_CPAR shares bits with VECSTRIDE */ | ||
48 | - if (arm_feature(env, ARM_FEATURE_XSCALE)) { | ||
49 | - flags = FIELD_DP32(flags, TBFLAG_A32, | ||
50 | - XSCALE_CPAR, env->cp15.c15_cpar); | ||
51 | - } | ||
52 | } | ||
53 | |||
54 | /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine | ||
55 | -- | ||
56 | 2.20.1 | ||
57 | |||
58 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Hoist the variable load for PSTATE into the existing test vs is_a64. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20191023150057.25731-11-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/helper.c | 20 ++++++++------------ | ||
11 | 1 file changed, 8 insertions(+), 12 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper.c | ||
16 | +++ b/target/arm/helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
18 | ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
19 | int current_el = arm_current_el(env); | ||
20 | int fp_el = fp_exception_el(env, current_el); | ||
21 | - uint32_t flags; | ||
22 | + uint32_t flags, pstate_for_ss; | ||
23 | |||
24 | if (is_a64(env)) { | ||
25 | *pc = env->pc; | ||
26 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
27 | if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | ||
28 | flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); | ||
29 | } | ||
30 | + pstate_for_ss = env->pstate; | ||
31 | } else { | ||
32 | *pc = env->regs[15]; | ||
33 | |||
34 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
35 | || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | ||
36 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
37 | } | ||
38 | + pstate_for_ss = env->uncached_cpsr; | ||
39 | } | ||
40 | |||
41 | - /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine | ||
42 | + /* | ||
43 | + * The SS_ACTIVE and PSTATE_SS bits correspond to the state machine | ||
44 | * states defined in the ARM ARM for software singlestep: | ||
45 | * SS_ACTIVE PSTATE.SS State | ||
46 | * 0 x Inactive (the TB flag for SS is always 0) | ||
47 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
48 | * 1 1 Active-not-pending | ||
49 | * SS_ACTIVE is set in hflags; PSTATE_SS is computed every TB. | ||
50 | */ | ||
51 | - if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE)) { | ||
52 | - if (is_a64(env)) { | ||
53 | - if (env->pstate & PSTATE_SS) { | ||
54 | - flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); | ||
55 | - } | ||
56 | - } else { | ||
57 | - if (env->uncached_cpsr & PSTATE_SS) { | ||
58 | - flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); | ||
59 | - } | ||
60 | - } | ||
61 | + if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE) && | ||
62 | + (pstate_for_ss & PSTATE_SS)) { | ||
63 | + flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); | ||
64 | } | ||
65 | |||
66 | *pflags = flags; | ||
67 | -- | ||
68 | 2.20.1 | ||
69 | |||
70 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | There are 3 conditions that each enable this flag. M-profile always | ||
4 | enables; A-profile with EL1 as AA64 always enables. Both of these | ||
5 | conditions can easily be cached. The final condition relies on the | ||
6 | FPEXC register which we are not prepared to cache. | ||
7 | |||
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20191023150057.25731-12-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/cpu.h | 2 +- | ||
14 | target/arm/helper.c | 14 ++++++++++---- | ||
15 | 2 files changed, 11 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) | ||
22 | * the same thing as the current security state of the processor! | ||
23 | */ | ||
24 | FIELD(TBFLAG_A32, NS, 6, 1) | ||
25 | -FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Not cached. */ | ||
26 | +FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Partially cached, minus FPEXC. */ | ||
27 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) /* Not cached. */ | ||
28 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
29 | /* For M profile only, set if FPCCR.LSPACT is set */ | ||
30 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/helper.c | ||
33 | +++ b/target/arm/helper.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
35 | { | ||
36 | uint32_t flags = 0; | ||
37 | |||
38 | + /* v8M always enables the fpu. */ | ||
39 | + flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
40 | + | ||
41 | if (arm_v7m_is_handler_mode(env)) { | ||
42 | flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1); | ||
43 | } | ||
44 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
45 | ARMMMUIdx mmu_idx) | ||
46 | { | ||
47 | uint32_t flags = rebuild_hflags_aprofile(env); | ||
48 | + | ||
49 | + if (arm_el_is_aa64(env, 1)) { | ||
50 | + flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
51 | + } | ||
52 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
53 | } | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
56 | flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, | ||
57 | env->vfp.vec_stride); | ||
58 | } | ||
59 | + if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30)) { | ||
60 | + flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
61 | + } | ||
62 | } | ||
63 | |||
64 | flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); | ||
65 | flags = FIELD_DP32(flags, TBFLAG_A32, CONDEXEC, env->condexec_bits); | ||
66 | - if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) | ||
67 | - || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | ||
68 | - flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
69 | - } | ||
70 | pstate_for_ss = env->uncached_cpsr; | ||
71 | } | ||
72 | |||
73 | -- | ||
74 | 2.20.1 | ||
75 | |||
76 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This function assumes nothing about the current state of the cpu, | ||
4 | and writes the computed value to env->hflags. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20191023150057.25731-13-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 6 ++++++ | ||
12 | target/arm/helper.c | 30 ++++++++++++++++++++++-------- | ||
13 | 2 files changed, 28 insertions(+), 8 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ void arm_register_pre_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, | ||
20 | void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, void | ||
21 | *opaque); | ||
22 | |||
23 | +/** | ||
24 | + * arm_rebuild_hflags: | ||
25 | + * Rebuild the cached TBFLAGS for arbitrary changed processor state. | ||
26 | + */ | ||
27 | +void arm_rebuild_hflags(CPUARMState *env); | ||
28 | + | ||
29 | /** | ||
30 | * aa32_vfp_dreg: | ||
31 | * Return a pointer to the Dn register within env in 32-bit mode. | ||
32 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/helper.c | ||
35 | +++ b/target/arm/helper.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
37 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
38 | } | ||
39 | |||
40 | +static uint32_t rebuild_hflags_internal(CPUARMState *env) | ||
41 | +{ | ||
42 | + int el = arm_current_el(env); | ||
43 | + int fp_el = fp_exception_el(env, el); | ||
44 | + ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
45 | + | ||
46 | + if (is_a64(env)) { | ||
47 | + return rebuild_hflags_a64(env, el, fp_el, mmu_idx); | ||
48 | + } else if (arm_feature(env, ARM_FEATURE_M)) { | ||
49 | + return rebuild_hflags_m32(env, fp_el, mmu_idx); | ||
50 | + } else { | ||
51 | + return rebuild_hflags_a32(env, fp_el, mmu_idx); | ||
52 | + } | ||
53 | +} | ||
54 | + | ||
55 | +void arm_rebuild_hflags(CPUARMState *env) | ||
56 | +{ | ||
57 | + env->hflags = rebuild_hflags_internal(env); | ||
58 | +} | ||
59 | + | ||
60 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
61 | target_ulong *cs_base, uint32_t *pflags) | ||
62 | { | ||
63 | - ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
64 | - int current_el = arm_current_el(env); | ||
65 | - int fp_el = fp_exception_el(env, current_el); | ||
66 | uint32_t flags, pstate_for_ss; | ||
67 | |||
68 | + flags = rebuild_hflags_internal(env); | ||
69 | + | ||
70 | if (is_a64(env)) { | ||
71 | *pc = env->pc; | ||
72 | - flags = rebuild_hflags_a64(env, current_el, fp_el, mmu_idx); | ||
73 | if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | ||
74 | flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); | ||
75 | } | ||
76 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
77 | *pc = env->regs[15]; | ||
78 | |||
79 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
80 | - flags = rebuild_hflags_m32(env, fp_el, mmu_idx); | ||
81 | - | ||
82 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
83 | FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) | ||
84 | != env->v7m.secure) { | ||
85 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
86 | flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); | ||
87 | } | ||
88 | } else { | ||
89 | - flags = rebuild_hflags_a32(env, fp_el, mmu_idx); | ||
90 | - | ||
91 | /* | ||
92 | * Note that XSCALE_CPAR shares bits with VECSTRIDE. | ||
93 | * Note that VECLEN+VECSTRIDE are RES0 for M-profile. | ||
94 | -- | ||
95 | 2.20.1 | ||
96 | |||
97 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Avoid calling arm_current_el() twice. | ||
4 | |||
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: 20191023150057.25731-14-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/internals.h | 9 +++++++++ | ||
12 | target/arm/helper.c | 12 +++++++----- | ||
13 | 2 files changed, 16 insertions(+), 5 deletions(-) | ||
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 @@ void arm_cpu_update_virq(ARMCPU *cpu); | ||
20 | */ | ||
21 | void arm_cpu_update_vfiq(ARMCPU *cpu); | ||
22 | |||
23 | +/** | ||
24 | + * arm_mmu_idx_el: | ||
25 | + * @env: The cpu environment | ||
26 | + * @el: The EL to use. | ||
27 | + * | ||
28 | + * Return the full ARMMMUIdx for the translation regime for EL. | ||
29 | + */ | ||
30 | +ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el); | ||
31 | + | ||
32 | /** | ||
33 | * arm_mmu_idx: | ||
34 | * @env: The cpu environment | ||
35 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/helper.c | ||
38 | +++ b/target/arm/helper.c | ||
39 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
40 | } | ||
41 | #endif | ||
42 | |||
43 | -ARMMMUIdx arm_mmu_idx(CPUARMState *env) | ||
44 | +ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el) | ||
45 | { | ||
46 | - int el; | ||
47 | - | ||
48 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
49 | return arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure); | ||
50 | } | ||
51 | |||
52 | - el = arm_current_el(env); | ||
53 | if (el < 2 && arm_is_secure_below_el3(env)) { | ||
54 | return ARMMMUIdx_S1SE0 + el; | ||
55 | } else { | ||
56 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) | ||
57 | } | ||
58 | } | ||
59 | |||
60 | +ARMMMUIdx arm_mmu_idx(CPUARMState *env) | ||
61 | +{ | ||
62 | + return arm_mmu_idx_el(env, arm_current_el(env)); | ||
63 | +} | ||
64 | + | ||
65 | int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
66 | { | ||
67 | return arm_to_core_mmu_idx(arm_mmu_idx(env)); | ||
68 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_internal(CPUARMState *env) | ||
69 | { | ||
70 | int el = arm_current_el(env); | ||
71 | int fp_el = fp_exception_el(env, el); | ||
72 | - ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
73 | + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); | ||
74 | |||
75 | if (is_a64(env)) { | ||
76 | return rebuild_hflags_a64(env, el, fp_el, mmu_idx); | ||
77 | -- | ||
78 | 2.20.1 | ||
79 | |||
80 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This functions are given the mode and el state of the cpu | ||
4 | and writes the computed value to env->hflags. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20191023150057.25731-16-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.h | 4 ++++ | ||
12 | target/arm/helper.c | 24 ++++++++++++++++++++++++ | ||
13 | 2 files changed, 28 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper.h | ||
18 | +++ b/target/arm/helper.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(msr_banked, void, env, i32, i32, i32) | ||
20 | DEF_HELPER_2(get_user_reg, i32, env, i32) | ||
21 | DEF_HELPER_3(set_user_reg, void, env, i32, i32) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_2(rebuild_hflags_m32, TCG_CALL_NO_RWG, void, env, int) | ||
24 | +DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int) | ||
25 | +DEF_HELPER_FLAGS_2(rebuild_hflags_a64, TCG_CALL_NO_RWG, void, env, int) | ||
26 | + | ||
27 | DEF_HELPER_1(vfp_get_fpscr, i32, env) | ||
28 | DEF_HELPER_2(vfp_set_fpscr, void, env, i32) | ||
29 | |||
30 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/helper.c | ||
33 | +++ b/target/arm/helper.c | ||
34 | @@ -XXX,XX +XXX,XX @@ void arm_rebuild_hflags(CPUARMState *env) | ||
35 | env->hflags = rebuild_hflags_internal(env); | ||
36 | } | ||
37 | |||
38 | +void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el) | ||
39 | +{ | ||
40 | + int fp_el = fp_exception_el(env, el); | ||
41 | + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); | ||
42 | + | ||
43 | + env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx); | ||
44 | +} | ||
45 | + | ||
46 | +void HELPER(rebuild_hflags_a32)(CPUARMState *env, int el) | ||
47 | +{ | ||
48 | + int fp_el = fp_exception_el(env, el); | ||
49 | + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); | ||
50 | + | ||
51 | + env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx); | ||
52 | +} | ||
53 | + | ||
54 | +void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) | ||
55 | +{ | ||
56 | + int fp_el = fp_exception_el(env, el); | ||
57 | + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); | ||
58 | + | ||
59 | + env->hflags = rebuild_hflags_a64(env, el, fp_el, mmu_idx); | ||
60 | +} | ||
61 | + | ||
62 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
63 | target_ulong *cs_base, uint32_t *pflags) | ||
64 | { | ||
65 | -- | ||
66 | 2.20.1 | ||
67 | |||
68 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Begin setting, but not relying upon, env->hflags. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20191023150057.25731-17-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | linux-user/syscall.c | 1 + | ||
11 | target/arm/cpu.c | 1 + | ||
12 | target/arm/helper-a64.c | 3 +++ | ||
13 | target/arm/helper.c | 2 ++ | ||
14 | target/arm/machine.c | 1 + | ||
15 | target/arm/op_helper.c | 1 + | ||
16 | 6 files changed, 9 insertions(+) | ||
17 | |||
18 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/linux-user/syscall.c | ||
21 | +++ b/linux-user/syscall.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, | ||
23 | aarch64_sve_narrow_vq(env, vq); | ||
24 | } | ||
25 | env->vfp.zcr_el[1] = vq - 1; | ||
26 | + arm_rebuild_hflags(env); | ||
27 | ret = vq * 16; | ||
28 | } | ||
29 | return ret; | ||
30 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/cpu.c | ||
33 | +++ b/target/arm/cpu.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
35 | |||
36 | hw_breakpoint_update_all(cpu); | ||
37 | hw_watchpoint_update_all(cpu); | ||
38 | + arm_rebuild_hflags(env); | ||
39 | } | ||
40 | |||
41 | bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
42 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/helper-a64.c | ||
45 | +++ b/target/arm/helper-a64.c | ||
46 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | ||
47 | } else { | ||
48 | env->regs[15] = new_pc & ~0x3; | ||
49 | } | ||
50 | + helper_rebuild_hflags_a32(env, new_el); | ||
51 | qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | ||
52 | "AArch32 EL%d PC 0x%" PRIx32 "\n", | ||
53 | cur_el, new_el, env->regs[15]); | ||
54 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | ||
55 | } | ||
56 | aarch64_restore_sp(env, new_el); | ||
57 | env->pc = new_pc; | ||
58 | + helper_rebuild_hflags_a64(env, new_el); | ||
59 | qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | ||
60 | "AArch64 EL%d PC 0x%" PRIx64 "\n", | ||
61 | cur_el, new_el, env->pc); | ||
62 | } | ||
63 | + | ||
64 | /* | ||
65 | * Note that cur_el can never be 0. If new_el is 0, then | ||
66 | * el0_a64 is return_to_aa64, else el0_a64 is ignored. | ||
67 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/arm/helper.c | ||
70 | +++ b/target/arm/helper.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, | ||
72 | env->regs[14] = env->regs[15] + offset; | ||
73 | } | ||
74 | env->regs[15] = newpc; | ||
75 | + arm_rebuild_hflags(env); | ||
76 | } | ||
77 | |||
78 | static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) | ||
79 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
80 | pstate_write(env, PSTATE_DAIF | new_mode); | ||
81 | env->aarch64 = 1; | ||
82 | aarch64_restore_sp(env, new_el); | ||
83 | + helper_rebuild_hflags_a64(env, new_el); | ||
84 | |||
85 | env->pc = addr; | ||
86 | |||
87 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/target/arm/machine.c | ||
90 | +++ b/target/arm/machine.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) | ||
92 | if (!kvm_enabled()) { | ||
93 | pmu_op_finish(&cpu->env); | ||
94 | } | ||
95 | + arm_rebuild_hflags(&cpu->env); | ||
96 | |||
97 | return 0; | ||
98 | } | ||
99 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/arm/op_helper.c | ||
102 | +++ b/target/arm/op_helper.c | ||
103 | @@ -XXX,XX +XXX,XX @@ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val) | ||
104 | * state. Do the masking now. | ||
105 | */ | ||
106 | env->regs[15] &= (env->thumb ? ~1 : ~3); | ||
107 | + arm_rebuild_hflags(env); | ||
108 | |||
109 | qemu_mutex_lock_iothread(); | ||
110 | arm_call_el_change_hook(env_archcpu(env)); | ||
111 | -- | ||
112 | 2.20.1 | ||
113 | |||
114 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Continue setting, but not relying upon, env->hflags. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20191023150057.25731-18-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate-a64.c | 13 +++++++++++-- | ||
11 | target/arm/translate.c | 28 +++++++++++++++++++++++----- | ||
12 | 2 files changed, 34 insertions(+), 7 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate-a64.c | ||
17 | +++ b/target/arm/translate-a64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
19 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | ||
20 | /* I/O operations must end the TB here (whether read or write) */ | ||
21 | s->base.is_jmp = DISAS_UPDATE; | ||
22 | - } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { | ||
23 | - /* We default to ending the TB on a coprocessor register write, | ||
24 | + } | ||
25 | + if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { | ||
26 | + /* | ||
27 | + * A write to any coprocessor regiser that ends a TB | ||
28 | + * must rebuild the hflags for the next TB. | ||
29 | + */ | ||
30 | + TCGv_i32 tcg_el = tcg_const_i32(s->current_el); | ||
31 | + gen_helper_rebuild_hflags_a64(cpu_env, tcg_el); | ||
32 | + tcg_temp_free_i32(tcg_el); | ||
33 | + /* | ||
34 | + * We default to ending the TB on a coprocessor register write, | ||
35 | * but allow this to be suppressed by the register definition | ||
36 | * (usually only necessary to work around guest bugs). | ||
37 | */ | ||
38 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/translate.c | ||
41 | +++ b/target/arm/translate.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
43 | ri = get_arm_cp_reginfo(s->cp_regs, | ||
44 | ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2)); | ||
45 | if (ri) { | ||
46 | + bool need_exit_tb; | ||
47 | + | ||
48 | /* Check access permissions */ | ||
49 | if (!cp_access_ok(s->current_el, ri, isread)) { | ||
50 | return 1; | ||
51 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
52 | } | ||
53 | } | ||
54 | |||
55 | - if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | ||
56 | - /* I/O operations must end the TB here (whether read or write) */ | ||
57 | - gen_lookup_tb(s); | ||
58 | - } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { | ||
59 | - /* We default to ending the TB on a coprocessor register write, | ||
60 | + /* I/O operations must end the TB here (whether read or write) */ | ||
61 | + need_exit_tb = ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && | ||
62 | + (ri->type & ARM_CP_IO)); | ||
63 | + | ||
64 | + if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { | ||
65 | + /* | ||
66 | + * A write to any coprocessor regiser that ends a TB | ||
67 | + * must rebuild the hflags for the next TB. | ||
68 | + */ | ||
69 | + TCGv_i32 tcg_el = tcg_const_i32(s->current_el); | ||
70 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
71 | + gen_helper_rebuild_hflags_m32(cpu_env, tcg_el); | ||
72 | + } else { | ||
73 | + gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); | ||
74 | + } | ||
75 | + tcg_temp_free_i32(tcg_el); | ||
76 | + /* | ||
77 | + * We default to ending the TB on a coprocessor register write, | ||
78 | * but allow this to be suppressed by the register definition | ||
79 | * (usually only necessary to work around guest bugs). | ||
80 | */ | ||
81 | + need_exit_tb = true; | ||
82 | + } | ||
83 | + if (need_exit_tb) { | ||
84 | gen_lookup_tb(s); | ||
85 | } | ||
86 | |||
87 | -- | ||
88 | 2.20.1 | ||
89 | |||
90 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Continue setting, but not relying upon, env->hflags. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20191023150057.25731-19-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/op_helper.c | 3 +++ | ||
11 | 1 file changed, 3 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/op_helper.c | ||
16 | +++ b/target/arm/op_helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(usat16)(CPUARMState *env, uint32_t x, uint32_t shift) | ||
18 | void HELPER(setend)(CPUARMState *env) | ||
19 | { | ||
20 | env->uncached_cpsr ^= CPSR_E; | ||
21 | + arm_rebuild_hflags(env); | ||
22 | } | ||
23 | |||
24 | /* Function checks whether WFx (WFI/WFE) instructions are set up to be trapped. | ||
25 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(cpsr_read)(CPUARMState *env) | ||
26 | void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask) | ||
27 | { | ||
28 | cpsr_write(env, val, mask, CPSRWriteByInstr); | ||
29 | + /* TODO: Not all cpsr bits are relevant to hflags. */ | ||
30 | + arm_rebuild_hflags(env); | ||
31 | } | ||
32 | |||
33 | /* Write the CPSR for a 32-bit exception return */ | ||
34 | -- | ||
35 | 2.20.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Continue setting, but not relying upon, env->hflags. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20191023150057.25731-20-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | target/arm/helper.c | 10 ++++++++++ | ||
10 | 1 file changed, 10 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper.c | ||
15 | +++ b/target/arm/helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
17 | /* ??? Lots of these bits are not implemented. */ | ||
18 | /* This may enable/disable the MMU, so do a TLB flush. */ | ||
19 | tlb_flush(CPU(cpu)); | ||
20 | + | ||
21 | + if (ri->type & ARM_CP_SUPPRESS_TB_END) { | ||
22 | + /* | ||
23 | + * Normally we would always end the TB on an SCTLR write; see the | ||
24 | + * comment in ARMCPRegInfo sctlr initialization below for why Xscale | ||
25 | + * is special. Setting ARM_CP_SUPPRESS_TB_END also stops the rebuild | ||
26 | + * of hflags from the translator, so do it here. | ||
27 | + */ | ||
28 | + arm_rebuild_hflags(env); | ||
29 | + } | ||
30 | } | ||
31 | |||
32 | static CPAccessResult fpexc32_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Continue setting, but not relying upon, env->hflags. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20191023150057.25731-21-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/m_helper.c | 6 ++++++ | ||
11 | target/arm/translate.c | 5 ++++- | ||
12 | 2 files changed, 10 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/m_helper.c | ||
17 | +++ b/target/arm/m_helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
19 | switch_v7m_security_state(env, dest & 1); | ||
20 | env->thumb = 1; | ||
21 | env->regs[15] = dest & ~1; | ||
22 | + arm_rebuild_hflags(env); | ||
23 | } | ||
24 | |||
25 | void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
26 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
27 | switch_v7m_security_state(env, 0); | ||
28 | env->thumb = 1; | ||
29 | env->regs[15] = dest; | ||
30 | + arm_rebuild_hflags(env); | ||
31 | } | ||
32 | |||
33 | static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, | ||
34 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
35 | env->regs[14] = lr; | ||
36 | env->regs[15] = addr & 0xfffffffe; | ||
37 | env->thumb = addr & 1; | ||
38 | + arm_rebuild_hflags(env); | ||
39 | } | ||
40 | |||
41 | static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | ||
42 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
43 | |||
44 | /* Otherwise, we have a successful exception exit. */ | ||
45 | arm_clear_exclusive(env); | ||
46 | + arm_rebuild_hflags(env); | ||
47 | qemu_log_mask(CPU_LOG_INT, "...successful exception return\n"); | ||
48 | } | ||
49 | |||
50 | @@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu) | ||
51 | xpsr_write(env, 0, XPSR_IT); | ||
52 | env->thumb = newpc & 1; | ||
53 | env->regs[15] = newpc & ~1; | ||
54 | + arm_rebuild_hflags(env); | ||
55 | |||
56 | qemu_log_mask(CPU_LOG_INT, "...function return successful\n"); | ||
57 | return true; | ||
58 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
59 | switch_v7m_security_state(env, true); | ||
60 | xpsr_write(env, 0, XPSR_IT); | ||
61 | env->regs[15] += 4; | ||
62 | + arm_rebuild_hflags(env); | ||
63 | return true; | ||
64 | |||
65 | gen_invep: | ||
66 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/translate.c | ||
69 | +++ b/target/arm/translate.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_MRS_v7m(DisasContext *s, arg_MRS_v7m *a) | ||
71 | |||
72 | static bool trans_MSR_v7m(DisasContext *s, arg_MSR_v7m *a) | ||
73 | { | ||
74 | - TCGv_i32 addr, reg; | ||
75 | + TCGv_i32 addr, reg, el; | ||
76 | |||
77 | if (!arm_dc_feature(s, ARM_FEATURE_M)) { | ||
78 | return false; | ||
79 | @@ -XXX,XX +XXX,XX @@ static bool trans_MSR_v7m(DisasContext *s, arg_MSR_v7m *a) | ||
80 | gen_helper_v7m_msr(cpu_env, addr, reg); | ||
81 | tcg_temp_free_i32(addr); | ||
82 | tcg_temp_free_i32(reg); | ||
83 | + el = tcg_const_i32(s->current_el); | ||
84 | + gen_helper_rebuild_hflags_m32(cpu_env, el); | ||
85 | + tcg_temp_free_i32(el); | ||
86 | gen_lookup_tb(s); | ||
87 | return true; | ||
88 | } | ||
89 | -- | ||
90 | 2.20.1 | ||
91 | |||
92 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Continue setting, but not relying upon, env->hflags. | ||
4 | |||
5 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20191023150057.25731-22-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/intc/armv7m_nvic.c | 22 +++++++++++++--------- | ||
11 | 1 file changed, 13 insertions(+), 9 deletions(-) | ||
12 | |||
13 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/intc/armv7m_nvic.c | ||
16 | +++ b/hw/intc/armv7m_nvic.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, | ||
18 | } | ||
19 | } | ||
20 | nvic_irq_update(s); | ||
21 | - return MEMTX_OK; | ||
22 | + goto exit_ok; | ||
23 | case 0x200 ... 0x23f: /* NVIC Set pend */ | ||
24 | /* the special logic in armv7m_nvic_set_pending() | ||
25 | * is not needed since IRQs are never escalated | ||
26 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, | ||
27 | } | ||
28 | } | ||
29 | nvic_irq_update(s); | ||
30 | - return MEMTX_OK; | ||
31 | + goto exit_ok; | ||
32 | case 0x300 ... 0x33f: /* NVIC Active */ | ||
33 | - return MEMTX_OK; /* R/O */ | ||
34 | + goto exit_ok; /* R/O */ | ||
35 | case 0x400 ... 0x5ef: /* NVIC Priority */ | ||
36 | startvec = (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */ | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, | ||
39 | } | ||
40 | } | ||
41 | nvic_irq_update(s); | ||
42 | - return MEMTX_OK; | ||
43 | + goto exit_ok; | ||
44 | case 0xd18 ... 0xd1b: /* System Handler Priority (SHPR1) */ | ||
45 | if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_MAIN)) { | ||
46 | - return MEMTX_OK; | ||
47 | + goto exit_ok; | ||
48 | } | ||
49 | /* fall through */ | ||
50 | case 0xd1c ... 0xd23: /* System Handler Priority (SHPR2, SHPR3) */ | ||
51 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, | ||
52 | set_prio(s, hdlidx, sbank, newprio); | ||
53 | } | ||
54 | nvic_irq_update(s); | ||
55 | - return MEMTX_OK; | ||
56 | + goto exit_ok; | ||
57 | case 0xd28 ... 0xd2b: /* Configurable Fault Status (CFSR) */ | ||
58 | if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_MAIN)) { | ||
59 | - return MEMTX_OK; | ||
60 | + goto exit_ok; | ||
61 | } | ||
62 | /* All bits are W1C, so construct 32 bit value with 0s in | ||
63 | * the parts not written by the access size | ||
64 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, | ||
65 | */ | ||
66 | s->cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK); | ||
67 | } | ||
68 | - return MEMTX_OK; | ||
69 | + goto exit_ok; | ||
70 | } | ||
71 | if (size == 4) { | ||
72 | nvic_writel(s, offset, value, attrs); | ||
73 | - return MEMTX_OK; | ||
74 | + goto exit_ok; | ||
75 | } | ||
76 | qemu_log_mask(LOG_GUEST_ERROR, | ||
77 | "NVIC: Bad write of size %d at offset 0x%x\n", size, offset); | ||
78 | /* This is UNPREDICTABLE; treat as RAZ/WI */ | ||
79 | + | ||
80 | + exit_ok: | ||
81 | + /* Ensure any changes made are reflected in the cached hflags. */ | ||
82 | + arm_rebuild_hflags(&s->cpu->env); | ||
83 | return MEMTX_OK; | ||
84 | } | ||
85 | |||
86 | -- | ||
87 | 2.20.1 | ||
88 | |||
89 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Continue setting, but not relying upon, env->hflags. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20191023150057.25731-23-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | linux-user/aarch64/cpu_loop.c | 1 + | ||
11 | 1 file changed, 1 insertion(+) | ||
12 | |||
13 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/linux-user/aarch64/cpu_loop.c | ||
16 | +++ b/linux-user/aarch64/cpu_loop.c | ||
17 | @@ -XXX,XX +XXX,XX @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) | ||
18 | for (i = 1; i < 4; ++i) { | ||
19 | env->cp15.sctlr_el[i] |= SCTLR_EE; | ||
20 | } | ||
21 | + arm_rebuild_hflags(env); | ||
22 | #endif | ||
23 | |||
24 | if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Continue setting, but not relying upon, env->hflags. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20191023150057.25731-24-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | linux-user/arm/cpu_loop.c | 1 + | ||
11 | 1 file changed, 1 insertion(+) | ||
12 | |||
13 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/linux-user/arm/cpu_loop.c | ||
16 | +++ b/linux-user/arm/cpu_loop.c | ||
17 | @@ -XXX,XX +XXX,XX @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) | ||
18 | } else { | ||
19 | env->cp15.sctlr_el[1] |= SCTLR_B; | ||
20 | } | ||
21 | + arm_rebuild_hflags(env); | ||
22 | #endif | ||
23 | |||
24 | ts->stack_base = info->start_stack; | ||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This is the payoff. | ||
4 | |||
5 | From perf record -g data of ubuntu 18 boot and shutdown: | ||
6 | |||
7 | BEFORE: | ||
8 | |||
9 | - 23.02% 2.82% qemu-system-aar [.] helper_lookup_tb_ptr | ||
10 | - 20.22% helper_lookup_tb_ptr | ||
11 | + 10.05% tb_htable_lookup | ||
12 | - 9.13% cpu_get_tb_cpu_state | ||
13 | 3.20% aa64_va_parameters_both | ||
14 | 0.55% fp_exception_el | ||
15 | |||
16 | - 11.66% 4.74% qemu-system-aar [.] cpu_get_tb_cpu_state | ||
17 | - 6.96% cpu_get_tb_cpu_state | ||
18 | 3.63% aa64_va_parameters_both | ||
19 | 0.60% fp_exception_el | ||
20 | 0.53% sve_exception_el | ||
21 | |||
22 | AFTER: | ||
23 | |||
24 | - 16.40% 3.40% qemu-system-aar [.] helper_lookup_tb_ptr | ||
25 | - 13.03% helper_lookup_tb_ptr | ||
26 | + 11.19% tb_htable_lookup | ||
27 | 0.55% cpu_get_tb_cpu_state | ||
28 | |||
29 | 0.98% 0.71% qemu-system-aar [.] cpu_get_tb_cpu_state | ||
30 | |||
31 | 0.87% 0.24% qemu-system-aar [.] rebuild_hflags_a64 | ||
32 | |||
33 | Before, helper_lookup_tb_ptr is the second hottest function in the | ||
34 | application, consuming almost a quarter of the runtime. Within the | ||
35 | entire execution, cpu_get_tb_cpu_state consumes about 12%. | ||
36 | |||
37 | After, helper_lookup_tb_ptr has dropped to the fourth hottest function, | ||
38 | with consumption dropping to a sixth of the runtime. Within the | ||
39 | entire execution, cpu_get_tb_cpu_state has dropped below 1%, and the | ||
40 | supporting function to rebuild hflags also consumes about 1%. | ||
41 | |||
42 | Assertions are retained for --enable-debug-tcg. | ||
43 | |||
44 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
45 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
46 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
47 | Message-id: 20191023150057.25731-25-richard.henderson@linaro.org | ||
48 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
49 | --- | ||
50 | target/arm/helper.c | 9 ++++++--- | ||
51 | 1 file changed, 6 insertions(+), 3 deletions(-) | ||
52 | |||
53 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/helper.c | ||
56 | +++ b/target/arm/helper.c | ||
57 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) | ||
58 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
59 | target_ulong *cs_base, uint32_t *pflags) | ||
60 | { | ||
61 | - uint32_t flags, pstate_for_ss; | ||
62 | + uint32_t flags = env->hflags; | ||
63 | + uint32_t pstate_for_ss; | ||
64 | |||
65 | *cs_base = 0; | ||
66 | - flags = rebuild_hflags_internal(env); | ||
67 | +#ifdef CONFIG_DEBUG_TCG | ||
68 | + assert(flags == rebuild_hflags_internal(env)); | ||
69 | +#endif | ||
70 | |||
71 | - if (is_a64(env)) { | ||
72 | + if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) { | ||
73 | *pc = env->pc; | ||
74 | if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | ||
75 | flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); | ||
76 | -- | ||
77 | 2.20.1 | ||
78 | |||
79 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Move bootindex.txt into the system section of the manual and turn it |
---|---|---|---|
2 | into rST format. To make the document make more sense in the context | ||
3 | of the system manual, expand the title and introductory paragraphs to | ||
4 | give more context. | ||
2 | 5 | ||
3 | We will soon implement the SYS_timer. This timer is used by Linux | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | in the thermal subsystem, so once available, the subsystem will be | 7 | Reviewed-by: Markus Armbruster <armbru@redhat.com> |
5 | enabled and poll the temperature sensors. We need to provide the | 8 | Message-id: 20210727194955.7764-1-peter.maydell@linaro.org |
6 | minimum required to keep Linux booting. | 9 | --- |
10 | docs/bootindex.txt | 52 --------------------------- | ||
11 | docs/system/bootindex.rst | 76 +++++++++++++++++++++++++++++++++++++++ | ||
12 | docs/system/index.rst | 1 + | ||
13 | 3 files changed, 77 insertions(+), 52 deletions(-) | ||
14 | delete mode 100644 docs/bootindex.txt | ||
15 | create mode 100644 docs/system/bootindex.rst | ||
7 | 16 | ||
8 | Add a dummy thermal sensor returning ~25°C based on: | 17 | diff --git a/docs/bootindex.txt b/docs/bootindex.txt |
9 | https://github.com/raspberrypi/linux/blob/rpi-5.3.y/drivers/thermal/broadcom/bcm2835_thermal.c | 18 | deleted file mode 100644 |
10 | 19 | index XXXXXXX..XXXXXXX | |
11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 20 | --- a/docs/bootindex.txt |
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 21 | +++ /dev/null |
13 | Message-id: 20191019234715.25750-2-f4bug@amsat.org | 22 | @@ -XXX,XX +XXX,XX @@ |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | -= Bootindex property = |
15 | --- | 24 | - |
16 | hw/misc/Makefile.objs | 1 + | 25 | -Block and net devices have bootindex property. This property is used to |
17 | include/hw/misc/bcm2835_thermal.h | 27 ++++++ | 26 | -determine the order in which firmware will consider devices for booting |
18 | hw/misc/bcm2835_thermal.c | 135 ++++++++++++++++++++++++++++++ | 27 | -the guest OS. If the bootindex property is not set for a device, it gets |
19 | 3 files changed, 163 insertions(+) | 28 | -lowest boot priority. There is no particular order in which devices with |
20 | create mode 100644 include/hw/misc/bcm2835_thermal.h | 29 | -unset bootindex property will be considered for booting, but they will |
21 | create mode 100644 hw/misc/bcm2835_thermal.c | 30 | -still be bootable. |
22 | 31 | - | |
23 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | 32 | -== Example == |
24 | index XXXXXXX..XXXXXXX 100644 | 33 | - |
25 | --- a/hw/misc/Makefile.objs | 34 | -Let's assume we have a QEMU machine with two NICs (virtio, e1000) and two |
26 | +++ b/hw/misc/Makefile.objs | 35 | -disks (IDE, virtio): |
27 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_OMAP) += omap_tap.o | 36 | - |
28 | common-obj-$(CONFIG_RASPI) += bcm2835_mbox.o | 37 | -qemu -drive file=disk1.img,if=none,id=disk1 |
29 | common-obj-$(CONFIG_RASPI) += bcm2835_property.o | 38 | - -device ide-hd,drive=disk1,bootindex=4 |
30 | common-obj-$(CONFIG_RASPI) += bcm2835_rng.o | 39 | - -drive file=disk2.img,if=none,id=disk2 |
31 | +common-obj-$(CONFIG_RASPI) += bcm2835_thermal.o | 40 | - -device virtio-blk-pci,drive=disk2,bootindex=3 |
32 | common-obj-$(CONFIG_SLAVIO) += slavio_misc.o | 41 | - -netdev type=user,id=net0 -device virtio-net-pci,netdev=net0,bootindex=2 |
33 | common-obj-$(CONFIG_ZYNQ) += zynq_slcr.o | 42 | - -netdev type=user,id=net1 -device e1000,netdev=net1,bootindex=1 |
34 | common-obj-$(CONFIG_ZYNQ) += zynq-xadc.o | 43 | - |
35 | diff --git a/include/hw/misc/bcm2835_thermal.h b/include/hw/misc/bcm2835_thermal.h | 44 | -Given the command above, firmware should try to boot from the e1000 NIC |
45 | -first. If this fails, it should try the virtio NIC next; if this fails | ||
46 | -too, it should try the virtio disk, and then the IDE disk. | ||
47 | - | ||
48 | -== Limitations == | ||
49 | - | ||
50 | -1. Some firmware has limitations on which devices can be considered for | ||
51 | -booting. For instance, the PC BIOS boot specification allows only one | ||
52 | -disk to be bootable. If boot from disk fails for some reason, the BIOS | ||
53 | -won't retry booting from other disk. It can still try to boot from | ||
54 | -floppy or net, though. | ||
55 | - | ||
56 | -2. Sometimes, firmware cannot map the device path QEMU wants firmware to | ||
57 | -boot from to a boot method. It doesn't happen for devices the firmware | ||
58 | -can natively boot from, but if firmware relies on an option ROM for | ||
59 | -booting, and the same option ROM is used for booting from more then one | ||
60 | -device, the firmware may not be able to ask the option ROM to boot from | ||
61 | -a particular device reliably. For instance with the PC BIOS, if a SCSI HBA | ||
62 | -has three bootable devices target1, target3, target5 connected to it, | ||
63 | -the option ROM will have a boot method for each of them, but it is not | ||
64 | -possible to map from boot method back to a specific target. This is a | ||
65 | -shortcoming of the PC BIOS boot specification. | ||
66 | - | ||
67 | -== Mixing bootindex and boot order parameters == | ||
68 | - | ||
69 | -Note that it does not make sense to use the bootindex property together | ||
70 | -with the "-boot order=..." (or "-boot once=...") parameter. The guest | ||
71 | -firmware implementations normally either support the one or the other, | ||
72 | -but not both parameters at the same time. Mixing them will result in | ||
73 | -undefined behavior, and thus the guest firmware will likely not boot | ||
74 | -from the expected devices. | ||
75 | diff --git a/docs/system/bootindex.rst b/docs/system/bootindex.rst | ||
36 | new file mode 100644 | 76 | new file mode 100644 |
37 | index XXXXXXX..XXXXXXX | 77 | index XXXXXXX..XXXXXXX |
38 | --- /dev/null | 78 | --- /dev/null |
39 | +++ b/include/hw/misc/bcm2835_thermal.h | 79 | +++ b/docs/system/bootindex.rst |
40 | @@ -XXX,XX +XXX,XX @@ | 80 | @@ -XXX,XX +XXX,XX @@ |
41 | +/* | 81 | +Managing device boot order with bootindex properties |
42 | + * BCM2835 dummy thermal sensor | 82 | +==================================================== |
43 | + * | ||
44 | + * Copyright (C) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
45 | + * | ||
46 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
47 | + */ | ||
48 | + | 83 | + |
49 | +#ifndef HW_MISC_BCM2835_THERMAL_H | 84 | +QEMU can tell QEMU-aware guest firmware (like the x86 PC BIOS) |
50 | +#define HW_MISC_BCM2835_THERMAL_H | 85 | +which order it should look for a bootable OS on which devices. |
86 | +A simple way to set this order is to use the ``-boot order=`` option, | ||
87 | +but you can also do this more flexibly, by setting a ``bootindex`` | ||
88 | +property on the individual block or net devices you specify | ||
89 | +on the QEMU command line. | ||
51 | + | 90 | + |
52 | +#include "hw/sysbus.h" | 91 | +The ``bootindex`` properties are used to determine the order in which |
92 | +firmware will consider devices for booting the guest OS. If the | ||
93 | +``bootindex`` property is not set for a device, it gets the lowest | ||
94 | +boot priority. There is no particular order in which devices with no | ||
95 | +``bootindex`` property set will be considered for booting, but they | ||
96 | +will still be bootable. | ||
53 | + | 97 | + |
54 | +#define TYPE_BCM2835_THERMAL "bcm2835-thermal" | 98 | +Some guest machine types (for instance the s390x machines) do |
99 | +not support ``-boot order=``; on those machines you must always | ||
100 | +use ``bootindex`` properties. | ||
55 | + | 101 | + |
56 | +#define BCM2835_THERMAL(obj) \ | 102 | +There is no way to set a ``bootindex`` property if you are using |
57 | + OBJECT_CHECK(Bcm2835ThermalState, (obj), TYPE_BCM2835_THERMAL) | 103 | +a short-form option like ``-hda`` or ``-cdrom``, so to use |
104 | +``bootindex`` properties you will need to expand out those options | ||
105 | +into long-form ``-drive`` and ``-device`` option pairs. | ||
58 | + | 106 | + |
59 | +typedef struct { | 107 | +Example |
60 | + /*< private >*/ | 108 | +------- |
61 | + SysBusDevice parent_obj; | ||
62 | + /*< public >*/ | ||
63 | + MemoryRegion iomem; | ||
64 | + uint32_t ctl; | ||
65 | +} Bcm2835ThermalState; | ||
66 | + | 109 | + |
67 | +#endif | 110 | +Let's assume we have a QEMU machine with two NICs (virtio, e1000) and two |
68 | diff --git a/hw/misc/bcm2835_thermal.c b/hw/misc/bcm2835_thermal.c | 111 | +disks (IDE, virtio): |
69 | new file mode 100644 | ||
70 | index XXXXXXX..XXXXXXX | ||
71 | --- /dev/null | ||
72 | +++ b/hw/misc/bcm2835_thermal.c | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | +/* | ||
75 | + * BCM2835 dummy thermal sensor | ||
76 | + * | ||
77 | + * Copyright (C) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
78 | + * | ||
79 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
80 | + */ | ||
81 | + | 112 | + |
82 | +#include "qemu/osdep.h" | 113 | +.. parsed-literal:: |
83 | +#include "qemu/log.h" | ||
84 | +#include "qapi/error.h" | ||
85 | +#include "hw/misc/bcm2835_thermal.h" | ||
86 | +#include "hw/registerfields.h" | ||
87 | +#include "migration/vmstate.h" | ||
88 | + | 114 | + |
89 | +REG32(CTL, 0) | 115 | + |qemu_system| -drive file=disk1.img,if=none,id=disk1 \\ |
90 | +FIELD(CTL, POWER_DOWN, 0, 1) | 116 | + -device ide-hd,drive=disk1,bootindex=4 \\ |
91 | +FIELD(CTL, RESET, 1, 1) | 117 | + -drive file=disk2.img,if=none,id=disk2 \\ |
92 | +FIELD(CTL, BANDGAP_CTRL, 2, 3) | 118 | + -device virtio-blk-pci,drive=disk2,bootindex=3 \\ |
93 | +FIELD(CTL, INTERRUPT_ENABLE, 5, 1) | 119 | + -netdev type=user,id=net0 \\ |
94 | +FIELD(CTL, DIRECT, 6, 1) | 120 | + -device virtio-net-pci,netdev=net0,bootindex=2 \\ |
95 | +FIELD(CTL, INTERRUPT_CLEAR, 7, 1) | 121 | + -netdev type=user,id=net1 \\ |
96 | +FIELD(CTL, HOLD, 8, 10) | 122 | + -device e1000,netdev=net1,bootindex=1 |
97 | +FIELD(CTL, RESET_DELAY, 18, 8) | ||
98 | +FIELD(CTL, REGULATOR_ENABLE, 26, 1) | ||
99 | + | 123 | + |
100 | +REG32(STAT, 4) | 124 | +Given the command above, firmware should try to boot from the e1000 NIC |
101 | +FIELD(STAT, DATA, 0, 10) | 125 | +first. If this fails, it should try the virtio NIC next; if this fails |
102 | +FIELD(STAT, VALID, 10, 1) | 126 | +too, it should try the virtio disk, and then the IDE disk. |
103 | +FIELD(STAT, INTERRUPT, 11, 1) | ||
104 | + | 127 | + |
105 | +#define THERMAL_OFFSET_C 412 | 128 | +Limitations |
106 | +#define THERMAL_COEFF (-0.538f) | 129 | +----------- |
107 | + | 130 | + |
108 | +static uint16_t bcm2835_thermal_temp2adc(int temp_C) | 131 | +Some firmware has limitations on which devices can be considered for |
109 | +{ | 132 | +booting. For instance, the PC BIOS boot specification allows only one |
110 | + return (temp_C - THERMAL_OFFSET_C) / THERMAL_COEFF; | 133 | +disk to be bootable. If boot from disk fails for some reason, the BIOS |
111 | +} | 134 | +won't retry booting from other disk. It can still try to boot from |
135 | +floppy or net, though. | ||
112 | + | 136 | + |
113 | +static uint64_t bcm2835_thermal_read(void *opaque, hwaddr addr, unsigned size) | 137 | +Sometimes, firmware cannot map the device path QEMU wants firmware to |
114 | +{ | 138 | +boot from to a boot method. It doesn't happen for devices the firmware |
115 | + Bcm2835ThermalState *s = BCM2835_THERMAL(opaque); | 139 | +can natively boot from, but if firmware relies on an option ROM for |
116 | + uint32_t val = 0; | 140 | +booting, and the same option ROM is used for booting from more then one |
141 | +device, the firmware may not be able to ask the option ROM to boot from | ||
142 | +a particular device reliably. For instance with the PC BIOS, if a SCSI HBA | ||
143 | +has three bootable devices target1, target3, target5 connected to it, | ||
144 | +the option ROM will have a boot method for each of them, but it is not | ||
145 | +possible to map from boot method back to a specific target. This is a | ||
146 | +shortcoming of the PC BIOS boot specification. | ||
117 | + | 147 | + |
118 | + switch (addr) { | 148 | +Mixing bootindex and boot order parameters |
119 | + case A_CTL: | 149 | +------------------------------------------ |
120 | + val = s->ctl; | ||
121 | + break; | ||
122 | + case A_STAT: | ||
123 | + /* Temperature is constantly 25°C. */ | ||
124 | + val = FIELD_DP32(bcm2835_thermal_temp2adc(25), STAT, VALID, true); | ||
125 | + break; | ||
126 | + default: | ||
127 | + /* MemoryRegionOps are aligned, so this can not happen. */ | ||
128 | + g_assert_not_reached(); | ||
129 | + } | ||
130 | + return val; | ||
131 | +} | ||
132 | + | 150 | + |
133 | +static void bcm2835_thermal_write(void *opaque, hwaddr addr, | 151 | +Note that it does not make sense to use the bootindex property together |
134 | + uint64_t value, unsigned size) | 152 | +with the ``-boot order=...`` (or ``-boot once=...``) parameter. The guest |
135 | +{ | 153 | +firmware implementations normally either support the one or the other, |
136 | + Bcm2835ThermalState *s = BCM2835_THERMAL(opaque); | 154 | +but not both parameters at the same time. Mixing them will result in |
137 | + | 155 | +undefined behavior, and thus the guest firmware will likely not boot |
138 | + switch (addr) { | 156 | +from the expected devices. |
139 | + case A_CTL: | 157 | diff --git a/docs/system/index.rst b/docs/system/index.rst |
140 | + s->ctl = value; | 158 | index XXXXXXX..XXXXXXX 100644 |
141 | + break; | 159 | --- a/docs/system/index.rst |
142 | + case A_STAT: | 160 | +++ b/docs/system/index.rst |
143 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: write 0x%" PRIx64 | 161 | @@ -XXX,XX +XXX,XX @@ or Hypervisor.Framework. |
144 | + " to 0x%" HWADDR_PRIx "\n", | 162 | authz |
145 | + __func__, value, addr); | 163 | gdb |
146 | + break; | 164 | managed-startup |
147 | + default: | 165 | + bootindex |
148 | + /* MemoryRegionOps are aligned, so this can not happen. */ | 166 | cpu-hotplug |
149 | + g_assert_not_reached(); | 167 | pr-manager |
150 | + } | 168 | targets |
151 | +} | ||
152 | + | ||
153 | +static const MemoryRegionOps bcm2835_thermal_ops = { | ||
154 | + .read = bcm2835_thermal_read, | ||
155 | + .write = bcm2835_thermal_write, | ||
156 | + .impl.max_access_size = 4, | ||
157 | + .valid.min_access_size = 4, | ||
158 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
159 | +}; | ||
160 | + | ||
161 | +static void bcm2835_thermal_reset(DeviceState *dev) | ||
162 | +{ | ||
163 | + Bcm2835ThermalState *s = BCM2835_THERMAL(dev); | ||
164 | + | ||
165 | + s->ctl = 0; | ||
166 | +} | ||
167 | + | ||
168 | +static void bcm2835_thermal_realize(DeviceState *dev, Error **errp) | ||
169 | +{ | ||
170 | + Bcm2835ThermalState *s = BCM2835_THERMAL(dev); | ||
171 | + | ||
172 | + memory_region_init_io(&s->iomem, OBJECT(s), &bcm2835_thermal_ops, | ||
173 | + s, TYPE_BCM2835_THERMAL, 8); | ||
174 | + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); | ||
175 | +} | ||
176 | + | ||
177 | +static const VMStateDescription bcm2835_thermal_vmstate = { | ||
178 | + .name = "bcm2835_thermal", | ||
179 | + .version_id = 1, | ||
180 | + .minimum_version_id = 1, | ||
181 | + .fields = (VMStateField[]) { | ||
182 | + VMSTATE_UINT32(ctl, Bcm2835ThermalState), | ||
183 | + VMSTATE_END_OF_LIST() | ||
184 | + } | ||
185 | +}; | ||
186 | + | ||
187 | +static void bcm2835_thermal_class_init(ObjectClass *klass, void *data) | ||
188 | +{ | ||
189 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
190 | + | ||
191 | + dc->realize = bcm2835_thermal_realize; | ||
192 | + dc->reset = bcm2835_thermal_reset; | ||
193 | + dc->vmsd = &bcm2835_thermal_vmstate; | ||
194 | +} | ||
195 | + | ||
196 | +static const TypeInfo bcm2835_thermal_info = { | ||
197 | + .name = TYPE_BCM2835_THERMAL, | ||
198 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
199 | + .instance_size = sizeof(Bcm2835ThermalState), | ||
200 | + .class_init = bcm2835_thermal_class_init, | ||
201 | +}; | ||
202 | + | ||
203 | +static void bcm2835_thermal_register_types(void) | ||
204 | +{ | ||
205 | + type_register_static(&bcm2835_thermal_info); | ||
206 | +} | ||
207 | + | ||
208 | +type_init(bcm2835_thermal_register_types) | ||
209 | -- | 169 | -- |
210 | 2.20.1 | 170 | 2.20.1 |
211 | 171 | ||
212 | 172 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Most of docs/barrier.txt is describing the protocol implemented |
---|---|---|---|
2 | by the input-barrier device. Move this into the interop | ||
3 | section of the manual, and rstify it. | ||
2 | 4 | ||
3 | Now that Arm CPUs have advertised features lets add tests to ensure | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | we maintain their expected availability with and without KVM. | 6 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> |
7 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> | ||
8 | Message-id: 20210727204112.12579-2-peter.maydell@linaro.org | ||
9 | --- | ||
10 | docs/barrier.txt | 318 ----------------------------- | ||
11 | docs/interop/barrier.rst | 426 +++++++++++++++++++++++++++++++++++++++ | ||
12 | docs/interop/index.rst | 1 + | ||
13 | 3 files changed, 427 insertions(+), 318 deletions(-) | ||
14 | create mode 100644 docs/interop/barrier.rst | ||
5 | 15 | ||
6 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 16 | diff --git a/docs/barrier.txt b/docs/barrier.txt |
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Message-id: 20191024121808.9612-3-drjones@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | tests/Makefile.include | 5 +- | ||
12 | tests/arm-cpu-features.c | 240 +++++++++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 244 insertions(+), 1 deletion(-) | ||
14 | create mode 100644 tests/arm-cpu-features.c | ||
15 | |||
16 | diff --git a/tests/Makefile.include b/tests/Makefile.include | ||
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/tests/Makefile.include | 18 | --- a/docs/barrier.txt |
19 | +++ b/tests/Makefile.include | 19 | +++ b/docs/barrier.txt |
20 | @@ -XXX,XX +XXX,XX @@ check-qtest-sparc64-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF) | 20 | @@ -XXX,XX +XXX,XX @@ |
21 | check-qtest-sparc64-y += tests/prom-env-test$(EXESUF) | 21 | |
22 | check-qtest-sparc64-y += tests/boot-serial-test$(EXESUF) | 22 | (qemu) object_del barrier0 |
23 | 23 | (qemu) object_add input-barrier,id=barrier0,name=VM-1 | |
24 | +check-qtest-arm-y += tests/arm-cpu-features$(EXESUF) | 24 | - |
25 | check-qtest-arm-y += tests/microbit-test$(EXESUF) | 25 | -* Message format |
26 | check-qtest-arm-y += tests/m25p80-test$(EXESUF) | 26 | - |
27 | check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF) | 27 | - Message format between the server and client is in two parts: |
28 | @@ -XXX,XX +XXX,XX @@ check-qtest-arm-y += tests/boot-serial-test$(EXESUF) | 28 | - |
29 | check-qtest-arm-y += tests/hexloader-test$(EXESUF) | 29 | - 1- the payload length is a 32bit integer in network endianness, |
30 | check-qtest-arm-$(CONFIG_PFLASH_CFI02) += tests/pflash-cfi02-test$(EXESUF) | 30 | - 2- the payload |
31 | 31 | - | |
32 | -check-qtest-aarch64-y = tests/numa-test$(EXESUF) | 32 | - The payload starts with a 4byte string (without NUL) which is the |
33 | +check-qtest-aarch64-y += tests/arm-cpu-features$(EXESUF) | 33 | - command. The first command between the server and the client |
34 | +check-qtest-aarch64-y += tests/numa-test$(EXESUF) | 34 | - is the only command not encoded on 4 bytes ("Barrier"). |
35 | check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF) | 35 | - The remaining part of the payload is decoded according to the command. |
36 | check-qtest-aarch64-y += tests/migration-test$(EXESUF) | 36 | - |
37 | # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make test unconditional | 37 | -* Protocol Description (from barrier/src/lib/barrier/protocol_types.h) |
38 | @@ -XXX,XX +XXX,XX @@ tests/test-qapi-util$(EXESUF): tests/test-qapi-util.o $(test-util-obj-y) | 38 | - |
39 | tests/numa-test$(EXESUF): tests/numa-test.o | 39 | - - barrierCmdHello "Barrier" |
40 | tests/vmgenid-test$(EXESUF): tests/vmgenid-test.o tests/boot-sector.o tests/acpi-utils.o | 40 | - |
41 | tests/cdrom-test$(EXESUF): tests/cdrom-test.o tests/boot-sector.o $(libqos-obj-y) | 41 | - Direction: server -> client |
42 | +tests/arm-cpu-features$(EXESUF): tests/arm-cpu-features.o | 42 | - Parameters: { int16_t minor, int16_t major } |
43 | 43 | - Description: | |
44 | tests/migration/stress$(EXESUF): tests/migration/stress.o | 44 | - |
45 | $(call quiet-command, $(LINKPROG) -static -O3 $(PTHREAD_LIB) -o $@ $< ,"LINK","$(TARGET_DIR)$@") | 45 | - Say hello to client |
46 | diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c | 46 | - minor = protocol major version number supported by server |
47 | - major = protocol minor version number supported by server | ||
48 | - | ||
49 | - - barrierCmdHelloBack "Barrier" | ||
50 | - | ||
51 | - Direction: client ->server | ||
52 | - Parameters: { int16_t minor, int16_t major, char *name} | ||
53 | - Description: | ||
54 | - | ||
55 | - Respond to hello from server | ||
56 | - minor = protocol major version number supported by client | ||
57 | - major = protocol minor version number supported by client | ||
58 | - name = client name | ||
59 | - | ||
60 | - - barrierCmdDInfo "DINF" | ||
61 | - | ||
62 | - Direction: client ->server | ||
63 | - Parameters: { int16_t x_origin, int16_t y_origin, int16_t width, int16_t height, int16_t x, int16_t y} | ||
64 | - Description: | ||
65 | - | ||
66 | - The client screen must send this message in response to the | ||
67 | - barrierCmdQInfo message. It must also send this message when the | ||
68 | - screen's resolution changes. In this case, the client screen should | ||
69 | - ignore any barrierCmdDMouseMove messages until it receives a | ||
70 | - barrierCmdCInfoAck in order to prevent attempts to move the mouse off | ||
71 | - the new screen area. | ||
72 | - | ||
73 | - - barrierCmdCNoop "CNOP" | ||
74 | - | ||
75 | - Direction: client -> server | ||
76 | - Parameters: None | ||
77 | - Description: | ||
78 | - | ||
79 | - No operation | ||
80 | - | ||
81 | - - barrierCmdCClose "CBYE" | ||
82 | - | ||
83 | - Direction: server -> client | ||
84 | - Parameters: None | ||
85 | - Description: | ||
86 | - | ||
87 | - Close connection | ||
88 | - | ||
89 | - - barrierCmdCEnter "CINN" | ||
90 | - | ||
91 | - Direction: server -> client | ||
92 | - Parameters: { int16_t x, int16_t y, int32_t seq, int16_t modifier } | ||
93 | - Description: | ||
94 | - | ||
95 | - Enter screen. | ||
96 | - x,y = entering screen absolute coordinates | ||
97 | - seq = sequence number, which is used to order messages between | ||
98 | - screens. the secondary screen must return this number | ||
99 | - with some messages | ||
100 | - modifier = modifier key mask. this will have bits set for each | ||
101 | - toggle modifier key that is activated on entry to the | ||
102 | - screen. the secondary screen should adjust its toggle | ||
103 | - modifiers to reflect that state. | ||
104 | - | ||
105 | - - barrierCmdCLeave "COUT" | ||
106 | - | ||
107 | - Direction: server -> client | ||
108 | - Parameters: None | ||
109 | - Description: | ||
110 | - | ||
111 | - Leaving screen. the secondary screen should send clipboard data in | ||
112 | - response to this message for those clipboards that it has grabbed | ||
113 | - (i.e. has sent a barrierCmdCClipboard for and has not received a | ||
114 | - barrierCmdCClipboard for with a greater sequence number) and that | ||
115 | - were grabbed or have changed since the last leave. | ||
116 | - | ||
117 | - - barrierCmdCClipboard "CCLP" | ||
118 | - | ||
119 | - Direction: server -> client | ||
120 | - Parameters: { int8_t id, int32_t seq } | ||
121 | - Description: | ||
122 | - | ||
123 | - Grab clipboard. Sent by screen when some other app on that screen | ||
124 | - grabs a clipboard. | ||
125 | - id = the clipboard identifier | ||
126 | - seq = sequence number. Client must use the sequence number passed in | ||
127 | - the most recent barrierCmdCEnter. the server always sends 0. | ||
128 | - | ||
129 | - - barrierCmdCScreenSaver "CSEC" | ||
130 | - | ||
131 | - Direction: server -> client | ||
132 | - Parameters: { int8_t started } | ||
133 | - Description: | ||
134 | - | ||
135 | - Screensaver change. | ||
136 | - started = Screensaver on primary has started (1) or closed (0) | ||
137 | - | ||
138 | - - barrierCmdCResetOptions "CROP" | ||
139 | - | ||
140 | - Direction: server -> client | ||
141 | - Parameters: None | ||
142 | - Description: | ||
143 | - | ||
144 | - Reset options. Client should reset all of its options to their | ||
145 | - defaults. | ||
146 | - | ||
147 | - - barrierCmdCInfoAck "CIAK" | ||
148 | - | ||
149 | - Direction: server -> client | ||
150 | - Parameters: None | ||
151 | - Description: | ||
152 | - | ||
153 | - Resolution change acknowledgment. Sent by server in response to a | ||
154 | - client screen's barrierCmdDInfo. This is sent for every | ||
155 | - barrierCmdDInfo, whether or not the server had sent a barrierCmdQInfo. | ||
156 | - | ||
157 | - - barrierCmdCKeepAlive "CALV" | ||
158 | - | ||
159 | - Direction: server -> client | ||
160 | - Parameters: None | ||
161 | - Description: | ||
162 | - | ||
163 | - Keep connection alive. Sent by the server periodically to verify | ||
164 | - that connections are still up and running. clients must reply in | ||
165 | - kind on receipt. if the server gets an error sending the message or | ||
166 | - does not receive a reply within a reasonable time then the server | ||
167 | - disconnects the client. if the client doesn't receive these (or any | ||
168 | - message) periodically then it should disconnect from the server. the | ||
169 | - appropriate interval is defined by an option. | ||
170 | - | ||
171 | - - barrierCmdDKeyDown "DKDN" | ||
172 | - | ||
173 | - Direction: server -> client | ||
174 | - Parameters: { int16_t keyid, int16_t modifier [,int16_t button] } | ||
175 | - Description: | ||
176 | - | ||
177 | - Key pressed. | ||
178 | - keyid = X11 key id | ||
179 | - modified = modified mask | ||
180 | - button = X11 Xkb keycode (optional) | ||
181 | - | ||
182 | - - barrierCmdDKeyRepeat "DKRP" | ||
183 | - | ||
184 | - Direction: server -> client | ||
185 | - Parameters: { int16_t keyid, int16_t modifier, int16_t repeat [,int16_t button] } | ||
186 | - Description: | ||
187 | - | ||
188 | - Key auto-repeat. | ||
189 | - keyid = X11 key id | ||
190 | - modified = modified mask | ||
191 | - repeat = number of repeats | ||
192 | - button = X11 Xkb keycode (optional) | ||
193 | - | ||
194 | - - barrierCmdDKeyUp "DKUP" | ||
195 | - | ||
196 | - Direction: server -> client | ||
197 | - Parameters: { int16_t keyid, int16_t modifier [,int16_t button] } | ||
198 | - Description: | ||
199 | - | ||
200 | - Key released. | ||
201 | - keyid = X11 key id | ||
202 | - modified = modified mask | ||
203 | - button = X11 Xkb keycode (optional) | ||
204 | - | ||
205 | - - barrierCmdDMouseDown "DMDN" | ||
206 | - | ||
207 | - Direction: server -> client | ||
208 | - Parameters: { int8_t button } | ||
209 | - Description: | ||
210 | - | ||
211 | - Mouse button pressed. | ||
212 | - button = button id | ||
213 | - | ||
214 | - - barrierCmdDMouseUp "DMUP" | ||
215 | - | ||
216 | - Direction: server -> client | ||
217 | - Parameters: { int8_t button } | ||
218 | - Description: | ||
219 | - | ||
220 | - Mouse button release. | ||
221 | - button = button id | ||
222 | - | ||
223 | - - barrierCmdDMouseMove "DMMV" | ||
224 | - | ||
225 | - Direction: server -> client | ||
226 | - Parameters: { int16_t x, int16_t y } | ||
227 | - Description: | ||
228 | - | ||
229 | - Absolute mouse moved. | ||
230 | - x,y = absolute screen coordinates | ||
231 | - | ||
232 | - - barrierCmdDMouseRelMove "DMRM" | ||
233 | - | ||
234 | - Direction: server -> client | ||
235 | - Parameters: { int16_t x, int16_t y } | ||
236 | - Description: | ||
237 | - | ||
238 | - Relative mouse moved. | ||
239 | - x,y = r relative screen coordinates | ||
240 | - | ||
241 | - - barrierCmdDMouseWheel "DMWM" | ||
242 | - | ||
243 | - Direction: server -> client | ||
244 | - Parameters: { int16_t x , int16_t y } or { int16_t y } | ||
245 | - Description: | ||
246 | - | ||
247 | - Mouse scroll. The delta should be +120 for one tick forward (away | ||
248 | - from the user) or right and -120 for one tick backward (toward the | ||
249 | - user) or left. | ||
250 | - x = x delta | ||
251 | - y = y delta | ||
252 | - | ||
253 | - - barrierCmdDClipboard "DCLP" | ||
254 | - | ||
255 | - Direction: server -> client | ||
256 | - Parameters: { int8_t id, int32_t seq, int8_t mark, char *data } | ||
257 | - Description: | ||
258 | - | ||
259 | - Clipboard data. | ||
260 | - id = clipboard id | ||
261 | - seq = sequence number. The sequence number is 0 when sent by the | ||
262 | - server. Client screens should use the/ sequence number from | ||
263 | - the most recent barrierCmdCEnter. | ||
264 | - | ||
265 | - - barrierCmdDSetOptions "DSOP" | ||
266 | - | ||
267 | - Direction: server -> client | ||
268 | - Parameters: { int32 t nb, { int32_t id, int32_t val }[] } | ||
269 | - Description: | ||
270 | - | ||
271 | - Set options. Client should set the given option/value pairs. | ||
272 | - nb = numbers of { id, val } entries | ||
273 | - id = option id | ||
274 | - val = option new value | ||
275 | - | ||
276 | - - barrierCmdDFileTransfer "DFTR" | ||
277 | - | ||
278 | - Direction: server -> client | ||
279 | - Parameters: { int8_t mark, char *content } | ||
280 | - Description: | ||
281 | - | ||
282 | - Transfer file data. | ||
283 | - mark = 0 means the content followed is the file size | ||
284 | - 1 means the content followed is the chunk data | ||
285 | - 2 means the file transfer is finished | ||
286 | - | ||
287 | - - barrierCmdDDragInfo "DDRG" int16_t char * | ||
288 | - | ||
289 | - Direction: server -> client | ||
290 | - Parameters: { int16_t nb, char *content } | ||
291 | - Description: | ||
292 | - | ||
293 | - Drag information. | ||
294 | - nb = number of dragging objects | ||
295 | - content = object's directory | ||
296 | - | ||
297 | - - barrierCmdQInfo "QINF" | ||
298 | - | ||
299 | - Direction: server -> client | ||
300 | - Parameters: None | ||
301 | - Description: | ||
302 | - | ||
303 | - Query screen info | ||
304 | - Client should reply with a barrierCmdDInfo | ||
305 | - | ||
306 | - - barrierCmdEIncompatible "EICV" | ||
307 | - | ||
308 | - Direction: server -> client | ||
309 | - Parameters: { int16_t nb, major *minor } | ||
310 | - Description: | ||
311 | - | ||
312 | - Incompatible version. | ||
313 | - major = major version | ||
314 | - minor = minor version | ||
315 | - | ||
316 | - - barrierCmdEBusy "EBSY" | ||
317 | - | ||
318 | - Direction: server -> client | ||
319 | - Parameters: None | ||
320 | - Description: | ||
321 | - | ||
322 | - Name provided when connecting is already in use. | ||
323 | - | ||
324 | - - barrierCmdEUnknown "EUNK" | ||
325 | - | ||
326 | - Direction: server -> client | ||
327 | - Parameters: None | ||
328 | - Description: | ||
329 | - | ||
330 | - Unknown client. Name provided when connecting is not in primary's | ||
331 | - screen configuration map. | ||
332 | - | ||
333 | - - barrierCmdEBad "EBAD" | ||
334 | - | ||
335 | - Direction: server -> client | ||
336 | - Parameters: None | ||
337 | - Description: | ||
338 | - | ||
339 | - Protocol violation. Server should disconnect after sending this | ||
340 | - message. | ||
341 | - | ||
342 | * TO DO | ||
343 | |||
344 | - Enable SSL | ||
345 | diff --git a/docs/interop/barrier.rst b/docs/interop/barrier.rst | ||
47 | new file mode 100644 | 346 | new file mode 100644 |
48 | index XXXXXXX..XXXXXXX | 347 | index XXXXXXX..XXXXXXX |
49 | --- /dev/null | 348 | --- /dev/null |
50 | +++ b/tests/arm-cpu-features.c | 349 | +++ b/docs/interop/barrier.rst |
51 | @@ -XXX,XX +XXX,XX @@ | 350 | @@ -XXX,XX +XXX,XX @@ |
52 | +/* | 351 | +Barrier client protocol |
53 | + * Arm CPU feature test cases | 352 | +======================= |
54 | + * | 353 | + |
55 | + * Copyright (c) 2019 Red Hat Inc. | 354 | +QEMU's ``input-barrier`` device implements the client end of |
56 | + * Authors: | 355 | +the KVM (Keyboard-Video-Mouse) software |
57 | + * Andrew Jones <drjones@redhat.com> | 356 | +`Barrier <https://github.com/debauchee/barrier>`__. |
58 | + * | 357 | + |
59 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 358 | +This document briefly describes the protocol as we implement it. |
60 | + * See the COPYING file in the top-level directory. | 359 | + |
61 | + */ | 360 | +Message format |
62 | +#include "qemu/osdep.h" | 361 | +-------------- |
63 | +#include "libqtest.h" | 362 | + |
64 | +#include "qapi/qmp/qdict.h" | 363 | +Message format between the server and client is in two parts: |
65 | +#include "qapi/qmp/qjson.h" | 364 | + |
66 | + | 365 | +#. the payload length, a 32bit integer in network endianness |
67 | +#define MACHINE "-machine virt,gic-version=max " | 366 | +#. the payload |
68 | +#define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ | 367 | + |
69 | + "'arguments': { 'type': 'full', " | 368 | +The payload starts with a 4byte string (without NUL) which is the |
70 | +#define QUERY_TAIL "}}" | 369 | +command. The first command between the server and the client |
71 | + | 370 | +is the only command not encoded on 4 bytes ("Barrier"). |
72 | +static QDict *do_query_no_props(QTestState *qts, const char *cpu_type) | 371 | +The remaining part of the payload is decoded according to the command. |
73 | +{ | 372 | + |
74 | + return qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s }" | 373 | +Protocol Description |
75 | + QUERY_TAIL, cpu_type); | 374 | +-------------------- |
76 | +} | 375 | + |
77 | + | 376 | +This comes from ``barrier/src/lib/barrier/protocol_types.h``. |
78 | +static QDict *do_query(QTestState *qts, const char *cpu_type, | 377 | + |
79 | + const char *fmt, ...) | 378 | +barrierCmdHello "Barrier" |
80 | +{ | 379 | +^^^^^^^^^^^^^^^^^^^^^^^^^^ |
81 | + QDict *resp; | 380 | + |
82 | + | 381 | +Direction: |
83 | + if (fmt) { | 382 | + server -> client |
84 | + QDict *args; | 383 | +Parameters: |
85 | + va_list ap; | 384 | + ``{ int16_t minor, int16_t major }`` |
86 | + | 385 | +Description: |
87 | + va_start(ap, fmt); | 386 | + Say hello to client |
88 | + args = qdict_from_vjsonf_nofail(fmt, ap); | 387 | + |
89 | + va_end(ap); | 388 | + ``minor`` = protocol major version number supported by server |
90 | + | 389 | + |
91 | + resp = qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s, " | 390 | + ``major`` = protocol minor version number supported by server |
92 | + "'props': %p }" | 391 | + |
93 | + QUERY_TAIL, cpu_type, args); | 392 | +barrierCmdHelloBack "Barrier" |
94 | + } else { | 393 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
95 | + resp = do_query_no_props(qts, cpu_type); | 394 | + |
96 | + } | 395 | +Direction: |
97 | + | 396 | + client ->server |
98 | + return resp; | 397 | +Parameters: |
99 | +} | 398 | + ``{ int16_t minor, int16_t major, char *name}`` |
100 | + | 399 | +Description: |
101 | +static const char *resp_get_error(QDict *resp) | 400 | + Respond to hello from server |
102 | +{ | 401 | + |
103 | + QDict *qdict; | 402 | + ``minor`` = protocol major version number supported by client |
104 | + | 403 | + |
105 | + g_assert(resp); | 404 | + ``major`` = protocol minor version number supported by client |
106 | + | 405 | + |
107 | + qdict = qdict_get_qdict(resp, "error"); | 406 | + ``name`` = client name |
108 | + if (qdict) { | 407 | + |
109 | + return qdict_get_str(qdict, "desc"); | 408 | +barrierCmdDInfo "DINF" |
110 | + } | 409 | +^^^^^^^^^^^^^^^^^^^^^^^ |
111 | + return NULL; | 410 | + |
112 | +} | 411 | +Direction: |
113 | + | 412 | + client ->server |
114 | +#define assert_error(qts, cpu_type, expected_error, fmt, ...) \ | 413 | +Parameters: |
115 | +({ \ | 414 | + ``{ int16_t x_origin, int16_t y_origin, int16_t width, int16_t height, int16_t x, int16_t y}`` |
116 | + QDict *_resp; \ | 415 | +Description: |
117 | + const char *_error; \ | 416 | + The client screen must send this message in response to the |
118 | + \ | 417 | + barrierCmdQInfo message. It must also send this message when the |
119 | + _resp = do_query(qts, cpu_type, fmt, ##__VA_ARGS__); \ | 418 | + screen's resolution changes. In this case, the client screen should |
120 | + g_assert(_resp); \ | 419 | + ignore any barrierCmdDMouseMove messages until it receives a |
121 | + _error = resp_get_error(_resp); \ | 420 | + barrierCmdCInfoAck in order to prevent attempts to move the mouse off |
122 | + g_assert(_error); \ | 421 | + the new screen area. |
123 | + g_assert(g_str_equal(_error, expected_error)); \ | 422 | + |
124 | + qobject_unref(_resp); \ | 423 | +barrierCmdCNoop "CNOP" |
125 | +}) | 424 | +^^^^^^^^^^^^^^^^^^^^^^^ |
126 | + | 425 | + |
127 | +static bool resp_has_props(QDict *resp) | 426 | +Direction: |
128 | +{ | 427 | + client -> server |
129 | + QDict *qdict; | 428 | +Parameters: |
130 | + | 429 | + None |
131 | + g_assert(resp); | 430 | +Description: |
132 | + | 431 | + No operation |
133 | + if (!qdict_haskey(resp, "return")) { | 432 | + |
134 | + return false; | 433 | +barrierCmdCClose "CBYE" |
135 | + } | 434 | +^^^^^^^^^^^^^^^^^^^^^^^ |
136 | + qdict = qdict_get_qdict(resp, "return"); | 435 | + |
137 | + | 436 | +Direction: |
138 | + if (!qdict_haskey(qdict, "model")) { | 437 | + server -> client |
139 | + return false; | 438 | +Parameters: |
140 | + } | 439 | + None |
141 | + qdict = qdict_get_qdict(qdict, "model"); | 440 | +Description: |
142 | + | 441 | + Close connection |
143 | + return qdict_haskey(qdict, "props"); | 442 | + |
144 | +} | 443 | +barrierCmdCEnter "CINN" |
145 | + | 444 | +^^^^^^^^^^^^^^^^^^^^^^^ |
146 | +static QDict *resp_get_props(QDict *resp) | 445 | + |
147 | +{ | 446 | +Direction: |
148 | + QDict *qdict; | 447 | + server -> client |
149 | + | 448 | +Parameters: |
150 | + g_assert(resp); | 449 | + ``{ int16_t x, int16_t y, int32_t seq, int16_t modifier }`` |
151 | + g_assert(resp_has_props(resp)); | 450 | +Description: |
152 | + | 451 | + Enter screen. |
153 | + qdict = qdict_get_qdict(resp, "return"); | 452 | + |
154 | + qdict = qdict_get_qdict(qdict, "model"); | 453 | + ``x``, ``y`` = entering screen absolute coordinates |
155 | + qdict = qdict_get_qdict(qdict, "props"); | 454 | + |
156 | + return qdict; | 455 | + ``seq`` = sequence number, which is used to order messages between |
157 | +} | 456 | + screens. the secondary screen must return this number |
158 | + | 457 | + with some messages |
159 | +#define assert_has_feature(qts, cpu_type, feature) \ | 458 | + |
160 | +({ \ | 459 | + ``modifier`` = modifier key mask. this will have bits set for each |
161 | + QDict *_resp = do_query_no_props(qts, cpu_type); \ | 460 | + toggle modifier key that is activated on entry to the |
162 | + g_assert(_resp); \ | 461 | + screen. the secondary screen should adjust its toggle |
163 | + g_assert(resp_has_props(_resp)); \ | 462 | + modifiers to reflect that state. |
164 | + g_assert(qdict_get(resp_get_props(_resp), feature)); \ | 463 | + |
165 | + qobject_unref(_resp); \ | 464 | +barrierCmdCLeave "COUT" |
166 | +}) | 465 | +^^^^^^^^^^^^^^^^^^^^^^^ |
167 | + | 466 | + |
168 | +#define assert_has_not_feature(qts, cpu_type, feature) \ | 467 | +Direction: |
169 | +({ \ | 468 | + server -> client |
170 | + QDict *_resp = do_query_no_props(qts, cpu_type); \ | 469 | +Parameters: |
171 | + g_assert(_resp); \ | 470 | + None |
172 | + g_assert(!resp_has_props(_resp) || \ | 471 | +Description: |
173 | + !qdict_get(resp_get_props(_resp), feature)); \ | 472 | + Leaving screen. the secondary screen should send clipboard data in |
174 | + qobject_unref(_resp); \ | 473 | + response to this message for those clipboards that it has grabbed |
175 | +}) | 474 | + (i.e. has sent a barrierCmdCClipboard for and has not received a |
176 | + | 475 | + barrierCmdCClipboard for with a greater sequence number) and that |
177 | +static void assert_type_full(QTestState *qts) | 476 | + were grabbed or have changed since the last leave. |
178 | +{ | 477 | + |
179 | + const char *error; | 478 | +barrierCmdCClipboard "CCLP" |
180 | + QDict *resp; | 479 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
181 | + | 480 | + |
182 | + resp = qtest_qmp(qts, "{ 'execute': 'query-cpu-model-expansion', " | 481 | +Direction: |
183 | + "'arguments': { 'type': 'static', " | 482 | + server -> client |
184 | + "'model': { 'name': 'foo' }}}"); | 483 | +Parameters: |
185 | + g_assert(resp); | 484 | + ``{ int8_t id, int32_t seq }`` |
186 | + error = resp_get_error(resp); | 485 | +Description: |
187 | + g_assert(error); | 486 | + Grab clipboard. Sent by screen when some other app on that screen |
188 | + g_assert(g_str_equal(error, | 487 | + grabs a clipboard. |
189 | + "The requested expansion type is not supported")); | 488 | + |
190 | + qobject_unref(resp); | 489 | + ``id`` = the clipboard identifier |
191 | +} | 490 | + |
192 | + | 491 | + ``seq`` = sequence number. Client must use the sequence number passed in |
193 | +static void assert_bad_props(QTestState *qts, const char *cpu_type) | 492 | + the most recent barrierCmdCEnter. the server always sends 0. |
194 | +{ | 493 | + |
195 | + const char *error; | 494 | +barrierCmdCScreenSaver "CSEC" |
196 | + QDict *resp; | 495 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
197 | + | 496 | + |
198 | + resp = qtest_qmp(qts, "{ 'execute': 'query-cpu-model-expansion', " | 497 | +Direction: |
199 | + "'arguments': { 'type': 'full', " | 498 | + server -> client |
200 | + "'model': { 'name': %s, " | 499 | +Parameters: |
201 | + "'props': false }}}", | 500 | + ``{ int8_t started }`` |
202 | + cpu_type); | 501 | +Description: |
203 | + g_assert(resp); | 502 | + Screensaver change. |
204 | + error = resp_get_error(resp); | 503 | + |
205 | + g_assert(error); | 504 | + ``started`` = Screensaver on primary has started (1) or closed (0) |
206 | + g_assert(g_str_equal(error, | 505 | + |
207 | + "Invalid parameter type for 'props', expected: dict")); | 506 | +barrierCmdCResetOptions "CROP" |
208 | + qobject_unref(resp); | 507 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
209 | +} | 508 | + |
210 | + | 509 | +Direction: |
211 | +static void test_query_cpu_model_expansion(const void *data) | 510 | + server -> client |
212 | +{ | 511 | +Parameters: |
213 | + QTestState *qts; | 512 | + None |
214 | + | 513 | +Description: |
215 | + qts = qtest_init(MACHINE "-cpu max"); | 514 | + Reset options. Client should reset all of its options to their |
216 | + | 515 | + defaults. |
217 | + /* Test common query-cpu-model-expansion input validation */ | 516 | + |
218 | + assert_type_full(qts); | 517 | +barrierCmdCInfoAck "CIAK" |
219 | + assert_bad_props(qts, "max"); | 518 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
220 | + assert_error(qts, "foo", "The CPU type 'foo' is not a recognized " | 519 | + |
221 | + "ARM CPU type", NULL); | 520 | +Direction: |
222 | + assert_error(qts, "max", "Parameter 'not-a-prop' is unexpected", | 521 | + server -> client |
223 | + "{ 'not-a-prop': false }"); | 522 | +Parameters: |
224 | + assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL); | 523 | + None |
225 | + | 524 | +Description: |
226 | + /* Test expected feature presence/absence for some cpu types */ | 525 | + Resolution change acknowledgment. Sent by server in response to a |
227 | + assert_has_feature(qts, "max", "pmu"); | 526 | + client screen's barrierCmdDInfo. This is sent for every |
228 | + assert_has_feature(qts, "cortex-a15", "pmu"); | 527 | + barrierCmdDInfo, whether or not the server had sent a barrierCmdQInfo. |
229 | + assert_has_not_feature(qts, "cortex-a15", "aarch64"); | 528 | + |
230 | + | 529 | +barrierCmdCKeepAlive "CALV" |
231 | + if (g_str_equal(qtest_get_arch(), "aarch64")) { | 530 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
232 | + assert_has_feature(qts, "max", "aarch64"); | 531 | + |
233 | + assert_has_feature(qts, "cortex-a57", "pmu"); | 532 | +Direction: |
234 | + assert_has_feature(qts, "cortex-a57", "aarch64"); | 533 | + server -> client |
235 | + | 534 | +Parameters: |
236 | + /* Test that features that depend on KVM generate errors without. */ | 535 | + None |
237 | + assert_error(qts, "max", | 536 | +Description: |
238 | + "'aarch64' feature cannot be disabled " | 537 | + Keep connection alive. Sent by the server periodically to verify |
239 | + "unless KVM is enabled and 32-bit EL1 " | 538 | + that connections are still up and running. clients must reply in |
240 | + "is supported", | 539 | + kind on receipt. if the server gets an error sending the message or |
241 | + "{ 'aarch64': false }"); | 540 | + does not receive a reply within a reasonable time then the server |
242 | + } | 541 | + disconnects the client. if the client doesn't receive these (or any |
243 | + | 542 | + message) periodically then it should disconnect from the server. the |
244 | + qtest_quit(qts); | 543 | + appropriate interval is defined by an option. |
245 | +} | 544 | + |
246 | + | 545 | +barrierCmdDKeyDown "DKDN" |
247 | +static void test_query_cpu_model_expansion_kvm(const void *data) | 546 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
248 | +{ | 547 | + |
249 | + QTestState *qts; | 548 | +Direction: |
250 | + | 549 | + server -> client |
251 | + qts = qtest_init(MACHINE "-accel kvm -cpu host"); | 550 | +Parameters: |
252 | + | 551 | + ``{ int16_t keyid, int16_t modifier [,int16_t button] }`` |
253 | + if (g_str_equal(qtest_get_arch(), "aarch64")) { | 552 | +Description: |
254 | + assert_has_feature(qts, "host", "aarch64"); | 553 | + Key pressed. |
255 | + assert_has_feature(qts, "host", "pmu"); | 554 | + |
256 | + | 555 | + ``keyid`` = X11 key id |
257 | + assert_error(qts, "cortex-a15", | 556 | + |
258 | + "We cannot guarantee the CPU type 'cortex-a15' works " | 557 | + ``modified`` = modified mask |
259 | + "with KVM on this host", NULL); | 558 | + |
260 | + } else { | 559 | + ``button`` = X11 Xkb keycode (optional) |
261 | + assert_has_not_feature(qts, "host", "aarch64"); | 560 | + |
262 | + assert_has_not_feature(qts, "host", "pmu"); | 561 | +barrierCmdDKeyRepeat "DKRP" |
263 | + } | 562 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
264 | + | 563 | + |
265 | + qtest_quit(qts); | 564 | +Direction: |
266 | +} | 565 | + server -> client |
267 | + | 566 | +Parameters: |
268 | +int main(int argc, char **argv) | 567 | + ``{ int16_t keyid, int16_t modifier, int16_t repeat [,int16_t button] }`` |
269 | +{ | 568 | +Description: |
270 | + bool kvm_available = false; | 569 | + Key auto-repeat. |
271 | + | 570 | + |
272 | + if (!access("/dev/kvm", R_OK | W_OK)) { | 571 | + ``keyid`` = X11 key id |
273 | +#if defined(HOST_AARCH64) | 572 | + |
274 | + kvm_available = g_str_equal(qtest_get_arch(), "aarch64"); | 573 | + ``modified`` = modified mask |
275 | +#elif defined(HOST_ARM) | 574 | + |
276 | + kvm_available = g_str_equal(qtest_get_arch(), "arm"); | 575 | + ``repeat`` = number of repeats |
277 | +#endif | 576 | + |
278 | + } | 577 | + ``button`` = X11 Xkb keycode (optional) |
279 | + | 578 | + |
280 | + g_test_init(&argc, &argv, NULL); | 579 | +barrierCmdDKeyUp "DKUP" |
281 | + | 580 | +^^^^^^^^^^^^^^^^^^^^^^^ |
282 | + qtest_add_data_func("/arm/query-cpu-model-expansion", | 581 | + |
283 | + NULL, test_query_cpu_model_expansion); | 582 | +Direction: |
284 | + | 583 | + server -> client |
285 | + if (kvm_available) { | 584 | +Parameters: |
286 | + qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", | 585 | + ``{ int16_t keyid, int16_t modifier [,int16_t button] }`` |
287 | + NULL, test_query_cpu_model_expansion_kvm); | 586 | +Description: |
288 | + } | 587 | + Key released. |
289 | + | 588 | + |
290 | + return g_test_run(); | 589 | + ``keyid`` = X11 key id |
291 | +} | 590 | + |
591 | + ``modified`` = modified mask | ||
592 | + | ||
593 | + ``button`` = X11 Xkb keycode (optional) | ||
594 | + | ||
595 | +barrierCmdDMouseDown "DMDN" | ||
596 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
597 | + | ||
598 | +Direction: | ||
599 | + server -> client | ||
600 | +Parameters: | ||
601 | + ``{ int8_t button }`` | ||
602 | +Description: | ||
603 | + Mouse button pressed. | ||
604 | + | ||
605 | + ``button`` = button id | ||
606 | + | ||
607 | +barrierCmdDMouseUp "DMUP" | ||
608 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
609 | + | ||
610 | +Direction: | ||
611 | + server -> client | ||
612 | +Parameters: | ||
613 | + ``{ int8_t button }`` | ||
614 | +Description: | ||
615 | + Mouse button release. | ||
616 | + | ||
617 | + ``button`` = button id | ||
618 | + | ||
619 | +barrierCmdDMouseMove "DMMV" | ||
620 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
621 | + | ||
622 | +Direction: | ||
623 | + server -> client | ||
624 | +Parameters: | ||
625 | + ``{ int16_t x, int16_t y }`` | ||
626 | +Description: | ||
627 | + Absolute mouse moved. | ||
628 | + | ||
629 | + ``x``, ``y`` = absolute screen coordinates | ||
630 | + | ||
631 | +barrierCmdDMouseRelMove "DMRM" | ||
632 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
633 | + | ||
634 | +Direction: | ||
635 | + server -> client | ||
636 | +Parameters: | ||
637 | + ``{ int16_t x, int16_t y }`` | ||
638 | +Description: | ||
639 | + Relative mouse moved. | ||
640 | + | ||
641 | + ``x``, ``y`` = r relative screen coordinates | ||
642 | + | ||
643 | +barrierCmdDMouseWheel "DMWM" | ||
644 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
645 | + | ||
646 | +Direction: | ||
647 | + server -> client | ||
648 | +Parameters: | ||
649 | + ``{ int16_t x , int16_t y }`` or ``{ int16_t y }`` | ||
650 | +Description: | ||
651 | + Mouse scroll. The delta should be +120 for one tick forward (away | ||
652 | + from the user) or right and -120 for one tick backward (toward the | ||
653 | + user) or left. | ||
654 | + | ||
655 | + ``x`` = x delta | ||
656 | + | ||
657 | + ``y`` = y delta | ||
658 | + | ||
659 | +barrierCmdDClipboard "DCLP" | ||
660 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
661 | + | ||
662 | +Direction: | ||
663 | + server -> client | ||
664 | +Parameters: | ||
665 | + ``{ int8_t id, int32_t seq, int8_t mark, char *data }`` | ||
666 | +Description: | ||
667 | + Clipboard data. | ||
668 | + | ||
669 | + ``id`` = clipboard id | ||
670 | + | ||
671 | + ``seq`` = sequence number. The sequence number is 0 when sent by the | ||
672 | + server. Client screens should use the/ sequence number from | ||
673 | + the most recent barrierCmdCEnter. | ||
674 | + | ||
675 | +barrierCmdDSetOptions "DSOP" | ||
676 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
677 | + | ||
678 | +Direction: | ||
679 | + server -> client | ||
680 | +Parameters: | ||
681 | + ``{ int32 t nb, { int32_t id, int32_t val }[] }`` | ||
682 | +Description: | ||
683 | + Set options. Client should set the given option/value pairs. | ||
684 | + | ||
685 | + ``nb`` = numbers of ``{ id, val }`` entries | ||
686 | + | ||
687 | + ``id`` = option id | ||
688 | + | ||
689 | + ``val`` = option new value | ||
690 | + | ||
691 | +barrierCmdDFileTransfer "DFTR" | ||
692 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
693 | + | ||
694 | +Direction: | ||
695 | + server -> client | ||
696 | +Parameters: | ||
697 | + ``{ int8_t mark, char *content }`` | ||
698 | +Description: | ||
699 | + Transfer file data. | ||
700 | + | ||
701 | + * ``mark`` = 0 means the content followed is the file size | ||
702 | + * 1 means the content followed is the chunk data | ||
703 | + * 2 means the file transfer is finished | ||
704 | + | ||
705 | +barrierCmdDDragInfo "DDRG" | ||
706 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
707 | + | ||
708 | +Direction: | ||
709 | + server -> client | ||
710 | +Parameters: | ||
711 | + ``{ int16_t nb, char *content }`` | ||
712 | +Description: | ||
713 | + Drag information. | ||
714 | + | ||
715 | + ``nb`` = number of dragging objects | ||
716 | + | ||
717 | + ``content`` = object's directory | ||
718 | + | ||
719 | +barrierCmdQInfo "QINF" | ||
720 | +^^^^^^^^^^^^^^^^^^^^^^^ | ||
721 | + | ||
722 | +Direction: | ||
723 | + server -> client | ||
724 | +Parameters: | ||
725 | + None | ||
726 | +Description: | ||
727 | + Query screen info | ||
728 | + | ||
729 | + Client should reply with a barrierCmdDInfo | ||
730 | + | ||
731 | +barrierCmdEIncompatible "EICV" | ||
732 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
733 | + | ||
734 | +Direction: | ||
735 | + server -> client | ||
736 | +Parameters: | ||
737 | + ``{ int16_t nb, major *minor }`` | ||
738 | +Description: | ||
739 | + Incompatible version. | ||
740 | + | ||
741 | + ``major`` = major version | ||
742 | + | ||
743 | + ``minor`` = minor version | ||
744 | + | ||
745 | +barrierCmdEBusy "EBSY" | ||
746 | +^^^^^^^^^^^^^^^^^^^^^^^ | ||
747 | + | ||
748 | +Direction: | ||
749 | + server -> client | ||
750 | +Parameters: | ||
751 | + None | ||
752 | +Description: | ||
753 | + Name provided when connecting is already in use. | ||
754 | + | ||
755 | +barrierCmdEUnknown "EUNK" | ||
756 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
757 | + | ||
758 | +Direction: | ||
759 | + server -> client | ||
760 | +Parameters: | ||
761 | + None | ||
762 | +Description: | ||
763 | + Unknown client. Name provided when connecting is not in primary's | ||
764 | + screen configuration map. | ||
765 | + | ||
766 | +barrierCmdEBad "EBAD" | ||
767 | +^^^^^^^^^^^^^^^^^^^^^^^ | ||
768 | + | ||
769 | +Direction: | ||
770 | + server -> client | ||
771 | +Parameters: | ||
772 | + None | ||
773 | +Description: | ||
774 | + Protocol violation. Server should disconnect after sending this | ||
775 | + message. | ||
776 | + | ||
777 | diff --git a/docs/interop/index.rst b/docs/interop/index.rst | ||
778 | index XXXXXXX..XXXXXXX 100644 | ||
779 | --- a/docs/interop/index.rst | ||
780 | +++ b/docs/interop/index.rst | ||
781 | @@ -XXX,XX +XXX,XX @@ are useful for making QEMU interoperate with other software. | ||
782 | .. toctree:: | ||
783 | :maxdepth: 2 | ||
784 | |||
785 | + barrier | ||
786 | bitmaps | ||
787 | dbus | ||
788 | dbus-vmstate | ||
292 | -- | 789 | -- |
293 | 2.20.1 | 790 | 2.20.1 |
294 | 791 | ||
295 | 792 | diff view generated by jsdifflib |
1 | Switch the mcf5206 code away from bottom-half based ptimers to | 1 | docs/barrier.txt has a couple of TODO notes about things to be |
---|---|---|---|
2 | the new transaction-based ptimer API. This just requires adding | 2 | implemented in this device; move them into a comment in the |
3 | begin/commit calls around the various places that modify the ptimer | 3 | source code. |
4 | state, and using the new ptimer_init() function to create the timer. | ||
5 | 4 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 6 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> |
8 | Message-id: 20191021140600.10725-1-peter.maydell@linaro.org | 7 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20210727204112.12579-3-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | hw/m68k/mcf5206.c | 15 +++++++++------ | 11 | docs/barrier.txt | 4 ---- |
11 | 1 file changed, 9 insertions(+), 6 deletions(-) | 12 | ui/input-barrier.c | 5 +++++ |
13 | 2 files changed, 5 insertions(+), 4 deletions(-) | ||
12 | 14 | ||
13 | diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c | 15 | diff --git a/docs/barrier.txt b/docs/barrier.txt |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/m68k/mcf5206.c | 17 | --- a/docs/barrier.txt |
16 | +++ b/hw/m68k/mcf5206.c | 18 | +++ b/docs/barrier.txt |
17 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
18 | 20 | ||
21 | (qemu) object_del barrier0 | ||
22 | (qemu) object_add input-barrier,id=barrier0,name=VM-1 | ||
23 | -* TO DO | ||
24 | - | ||
25 | - - Enable SSL | ||
26 | - - Manage SetOptions/ResetOptions commands | ||
27 | |||
28 | diff --git a/ui/input-barrier.c b/ui/input-barrier.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/ui/input-barrier.c | ||
31 | +++ b/ui/input-barrier.c | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
33 | * | ||
34 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
35 | * See the COPYING file in the top-level directory. | ||
36 | + * | ||
37 | + * TODO: | ||
38 | + * | ||
39 | + * - Enable SSL | ||
40 | + * - Manage SetOptions/ResetOptions commands | ||
41 | */ | ||
42 | |||
19 | #include "qemu/osdep.h" | 43 | #include "qemu/osdep.h" |
20 | #include "qemu/error-report.h" | ||
21 | -#include "qemu/main-loop.h" | ||
22 | #include "cpu.h" | ||
23 | #include "hw/hw.h" | ||
24 | #include "hw/irq.h" | ||
25 | @@ -XXX,XX +XXX,XX @@ static void m5206_timer_recalibrate(m5206_timer_state *s) | ||
26 | int prescale; | ||
27 | int mode; | ||
28 | |||
29 | + ptimer_transaction_begin(s->timer); | ||
30 | ptimer_stop(s->timer); | ||
31 | |||
32 | - if ((s->tmr & TMR_RST) == 0) | ||
33 | - return; | ||
34 | + if ((s->tmr & TMR_RST) == 0) { | ||
35 | + goto exit; | ||
36 | + } | ||
37 | |||
38 | prescale = (s->tmr >> 8) + 1; | ||
39 | mode = (s->tmr >> 1) & 3; | ||
40 | @@ -XXX,XX +XXX,XX @@ static void m5206_timer_recalibrate(m5206_timer_state *s) | ||
41 | ptimer_set_limit(s->timer, s->trr, 0); | ||
42 | |||
43 | ptimer_run(s->timer, 0); | ||
44 | +exit: | ||
45 | + ptimer_transaction_commit(s->timer); | ||
46 | } | ||
47 | |||
48 | static void m5206_timer_trigger(void *opaque) | ||
49 | @@ -XXX,XX +XXX,XX @@ static void m5206_timer_write(m5206_timer_state *s, uint32_t addr, uint32_t val) | ||
50 | s->tcr = val; | ||
51 | break; | ||
52 | case 0xc: | ||
53 | + ptimer_transaction_begin(s->timer); | ||
54 | ptimer_set_count(s->timer, val); | ||
55 | + ptimer_transaction_commit(s->timer); | ||
56 | break; | ||
57 | case 0x11: | ||
58 | s->ter &= ~val; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void m5206_timer_write(m5206_timer_state *s, uint32_t addr, uint32_t val) | ||
60 | static m5206_timer_state *m5206_timer_init(qemu_irq irq) | ||
61 | { | ||
62 | m5206_timer_state *s; | ||
63 | - QEMUBH *bh; | ||
64 | |||
65 | s = g_new0(m5206_timer_state, 1); | ||
66 | - bh = qemu_bh_new(m5206_timer_trigger, s); | ||
67 | - s->timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT); | ||
68 | + s->timer = ptimer_init(m5206_timer_trigger, s, PTIMER_POLICY_DEFAULT); | ||
69 | s->irq = irq; | ||
70 | m5206_timer_reset(s); | ||
71 | return s; | ||
72 | -- | 44 | -- |
73 | 2.20.1 | 45 | 2.20.1 |
74 | 46 | ||
75 | 47 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | The remaining text in docs/barrier.txt is user-facing description |
---|---|---|---|
2 | of what the device is and how to use it. Move this into the | ||
3 | system manual and rstify it. | ||
2 | 4 | ||
3 | Add support for the query-cpu-model-expansion QMP command to Arm. We | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | do this selectively, only exposing CPU properties which represent | 6 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> |
5 | optional CPU features which the user may want to enable/disable. | 7 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> |
6 | Additionally we restrict the list of queryable cpu models to 'max', | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | 'host', or the current type when KVM is in use. And, finally, we only | 9 | Message-id: 20210727204112.12579-4-peter.maydell@linaro.org |
8 | implement expansion type 'full', as Arm does not yet have a "base" | 10 | --- |
9 | CPU type. More details and example queries are described in a new | 11 | docs/barrier.txt | 48 ----------------------------------------- |
10 | document (docs/arm-cpu-features.rst). | 12 | docs/system/barrier.rst | 44 +++++++++++++++++++++++++++++++++++++ |
13 | docs/system/index.rst | 1 + | ||
14 | 3 files changed, 45 insertions(+), 48 deletions(-) | ||
15 | delete mode 100644 docs/barrier.txt | ||
16 | create mode 100644 docs/system/barrier.rst | ||
11 | 17 | ||
12 | Note, certainly more features may be added to the list of advertised | 18 | diff --git a/docs/barrier.txt b/docs/barrier.txt |
13 | features, e.g. 'vfp' and 'neon'. The only requirement is that we can | 19 | deleted file mode 100644 |
14 | detect invalid configurations and emit failures at QMP query time. | 20 | index XXXXXXX..XXXXXXX |
15 | For 'vfp' and 'neon' this will require some refactoring to share a | 21 | --- a/docs/barrier.txt |
16 | validation function between the QMP query and the CPU realize | 22 | +++ /dev/null |
17 | functions. | ||
18 | |||
19 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
22 | Reviewed-by: Beata Michalska <beata.michalska@linaro.org> | ||
23 | Message-id: 20191024121808.9612-2-drjones@redhat.com | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | --- | ||
26 | qapi/machine-target.json | 6 +- | ||
27 | target/arm/monitor.c | 146 ++++++++++++++++++++++++++++++++++++++ | ||
28 | docs/arm-cpu-features.rst | 137 +++++++++++++++++++++++++++++++++++ | ||
29 | 3 files changed, 286 insertions(+), 3 deletions(-) | ||
30 | create mode 100644 docs/arm-cpu-features.rst | ||
31 | |||
32 | diff --git a/qapi/machine-target.json b/qapi/machine-target.json | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/qapi/machine-target.json | ||
35 | +++ b/qapi/machine-target.json | ||
36 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
37 | ## | 24 | - QEMU Barrier Client |
38 | { 'struct': 'CpuModelExpansionInfo', | 25 | - |
39 | 'data': { 'model': 'CpuModelInfo' }, | 26 | - |
40 | - 'if': 'defined(TARGET_S390X) || defined(TARGET_I386)' } | 27 | -* About |
41 | + 'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM)' } | 28 | - |
42 | 29 | - Barrier is a KVM (Keyboard-Video-Mouse) software forked from Symless's | |
43 | ## | 30 | - synergy 1.9 codebase. |
44 | # @query-cpu-model-expansion: | 31 | - |
45 | @@ -XXX,XX +XXX,XX @@ | 32 | - See https://github.com/debauchee/barrier |
46 | # query-cpu-model-expansion while using these is not advised. | 33 | - |
47 | # | 34 | -* QEMU usage |
48 | # Some architectures may not support all expansion types. s390x supports | 35 | - |
49 | -# "full" and "static". | 36 | - Generally, mouse and keyboard are grabbed through the QEMU video |
50 | +# "full" and "static". Arm only supports "full". | 37 | - interface emulation. |
51 | # | 38 | - |
52 | # Returns: a CpuModelExpansionInfo. Returns an error if expanding CPU models is | 39 | - But when we want to use a video graphic adapter via a PCI passthrough |
53 | # not supported, if the model cannot be expanded, if the model contains | 40 | - there is no way to provide the keyboard and mouse inputs to the VM |
54 | @@ -XXX,XX +XXX,XX @@ | 41 | - except by plugging a second set of mouse and keyboard to the host |
55 | 'data': { 'type': 'CpuModelExpansionType', | 42 | - or by installing a KVM software in the guest OS. |
56 | 'model': 'CpuModelInfo' }, | 43 | - |
57 | 'returns': 'CpuModelExpansionInfo', | 44 | - The QEMU Barrier client avoids this by implementing directly the Barrier |
58 | - 'if': 'defined(TARGET_S390X) || defined(TARGET_I386)' } | 45 | - protocol into QEMU. |
59 | + 'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM)' } | 46 | - |
60 | 47 | - This protocol is enabled by adding an input-barrier object to QEMU. | |
61 | ## | 48 | - |
62 | # @CpuDefinitionInfo: | 49 | - Syntax: input-barrier,id=<object-id>,name=<guest display name> |
63 | diff --git a/target/arm/monitor.c b/target/arm/monitor.c | 50 | - [,server=<barrier server address>][,port=<barrier server port>] |
64 | index XXXXXXX..XXXXXXX 100644 | 51 | - [,x-origin=<x-origin>][,y-origin=<y-origin>] |
65 | --- a/target/arm/monitor.c | 52 | - [,width=<width>][,height=<height>] |
66 | +++ b/target/arm/monitor.c | 53 | - |
67 | @@ -XXX,XX +XXX,XX @@ | 54 | - The object can be added on the QEMU command line, for instance with: |
68 | */ | 55 | - |
69 | 56 | - ... -object input-barrier,id=barrier0,name=VM-1 ... | |
70 | #include "qemu/osdep.h" | 57 | - |
71 | +#include "hw/boards.h" | 58 | - where VM-1 is the name the display configured int the Barrier server |
72 | #include "kvm_arm.h" | 59 | - on the host providing the mouse and the keyboard events. |
73 | +#include "qapi/error.h" | 60 | - |
74 | +#include "qapi/visitor.h" | 61 | - by default <barrier server address> is "localhost", port is 24800, |
75 | +#include "qapi/qobject-input-visitor.h" | 62 | - <x-origin> and <y-origin> are set to 0, <width> and <height> to |
76 | +#include "qapi/qapi-commands-machine-target.h" | 63 | - 1920 and 1080. |
77 | #include "qapi/qapi-commands-misc-target.h" | 64 | - |
78 | +#include "qapi/qmp/qerror.h" | 65 | - If Barrier server is stopped QEMU needs to be reconnected manually, |
79 | +#include "qapi/qmp/qdict.h" | 66 | - by removing and re-adding the input-barrier object, for instance |
80 | +#include "qom/qom-qobject.h" | 67 | - with the help of the HMP monitor: |
81 | 68 | - | |
82 | static GICCapability *gic_cap_new(int version) | 69 | - (qemu) object_del barrier0 |
83 | { | 70 | - (qemu) object_add input-barrier,id=barrier0,name=VM-1 |
84 | @@ -XXX,XX +XXX,XX @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp) | 71 | - |
85 | 72 | diff --git a/docs/system/barrier.rst b/docs/system/barrier.rst | |
86 | return head; | ||
87 | } | ||
88 | + | ||
89 | +/* | ||
90 | + * These are cpu model features we want to advertise. The order here | ||
91 | + * matters as this is the order in which qmp_query_cpu_model_expansion | ||
92 | + * will attempt to set them. If there are dependencies between features, | ||
93 | + * then the order that considers those dependencies must be used. | ||
94 | + */ | ||
95 | +static const char *cpu_model_advertised_features[] = { | ||
96 | + "aarch64", "pmu", | ||
97 | + NULL | ||
98 | +}; | ||
99 | + | ||
100 | +CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, | ||
101 | + CpuModelInfo *model, | ||
102 | + Error **errp) | ||
103 | +{ | ||
104 | + CpuModelExpansionInfo *expansion_info; | ||
105 | + const QDict *qdict_in = NULL; | ||
106 | + QDict *qdict_out; | ||
107 | + ObjectClass *oc; | ||
108 | + Object *obj; | ||
109 | + const char *name; | ||
110 | + int i; | ||
111 | + | ||
112 | + if (type != CPU_MODEL_EXPANSION_TYPE_FULL) { | ||
113 | + error_setg(errp, "The requested expansion type is not supported"); | ||
114 | + return NULL; | ||
115 | + } | ||
116 | + | ||
117 | + if (!kvm_enabled() && !strcmp(model->name, "host")) { | ||
118 | + error_setg(errp, "The CPU type '%s' requires KVM", model->name); | ||
119 | + return NULL; | ||
120 | + } | ||
121 | + | ||
122 | + oc = cpu_class_by_name(TYPE_ARM_CPU, model->name); | ||
123 | + if (!oc) { | ||
124 | + error_setg(errp, "The CPU type '%s' is not a recognized ARM CPU type", | ||
125 | + model->name); | ||
126 | + return NULL; | ||
127 | + } | ||
128 | + | ||
129 | + if (kvm_enabled()) { | ||
130 | + const char *cpu_type = current_machine->cpu_type; | ||
131 | + int len = strlen(cpu_type) - strlen(ARM_CPU_TYPE_SUFFIX); | ||
132 | + bool supported = false; | ||
133 | + | ||
134 | + if (!strcmp(model->name, "host") || !strcmp(model->name, "max")) { | ||
135 | + /* These are kvmarm's recommended cpu types */ | ||
136 | + supported = true; | ||
137 | + } else if (strlen(model->name) == len && | ||
138 | + !strncmp(model->name, cpu_type, len)) { | ||
139 | + /* KVM is enabled and we're using this type, so it works. */ | ||
140 | + supported = true; | ||
141 | + } | ||
142 | + if (!supported) { | ||
143 | + error_setg(errp, "We cannot guarantee the CPU type '%s' works " | ||
144 | + "with KVM on this host", model->name); | ||
145 | + return NULL; | ||
146 | + } | ||
147 | + } | ||
148 | + | ||
149 | + if (model->props) { | ||
150 | + qdict_in = qobject_to(QDict, model->props); | ||
151 | + if (!qdict_in) { | ||
152 | + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict"); | ||
153 | + return NULL; | ||
154 | + } | ||
155 | + } | ||
156 | + | ||
157 | + obj = object_new(object_class_get_name(oc)); | ||
158 | + | ||
159 | + if (qdict_in) { | ||
160 | + Visitor *visitor; | ||
161 | + Error *err = NULL; | ||
162 | + | ||
163 | + visitor = qobject_input_visitor_new(model->props); | ||
164 | + visit_start_struct(visitor, NULL, NULL, 0, &err); | ||
165 | + if (err) { | ||
166 | + visit_free(visitor); | ||
167 | + object_unref(obj); | ||
168 | + error_propagate(errp, err); | ||
169 | + return NULL; | ||
170 | + } | ||
171 | + | ||
172 | + i = 0; | ||
173 | + while ((name = cpu_model_advertised_features[i++]) != NULL) { | ||
174 | + if (qdict_get(qdict_in, name)) { | ||
175 | + object_property_set(obj, visitor, name, &err); | ||
176 | + if (err) { | ||
177 | + break; | ||
178 | + } | ||
179 | + } | ||
180 | + } | ||
181 | + | ||
182 | + if (!err) { | ||
183 | + visit_check_struct(visitor, &err); | ||
184 | + } | ||
185 | + visit_end_struct(visitor, NULL); | ||
186 | + visit_free(visitor); | ||
187 | + if (err) { | ||
188 | + object_unref(obj); | ||
189 | + error_propagate(errp, err); | ||
190 | + return NULL; | ||
191 | + } | ||
192 | + } | ||
193 | + | ||
194 | + expansion_info = g_new0(CpuModelExpansionInfo, 1); | ||
195 | + expansion_info->model = g_malloc0(sizeof(*expansion_info->model)); | ||
196 | + expansion_info->model->name = g_strdup(model->name); | ||
197 | + | ||
198 | + qdict_out = qdict_new(); | ||
199 | + | ||
200 | + i = 0; | ||
201 | + while ((name = cpu_model_advertised_features[i++]) != NULL) { | ||
202 | + ObjectProperty *prop = object_property_find(obj, name, NULL); | ||
203 | + if (prop) { | ||
204 | + Error *err = NULL; | ||
205 | + QObject *value; | ||
206 | + | ||
207 | + assert(prop->get); | ||
208 | + value = object_property_get_qobject(obj, name, &err); | ||
209 | + assert(!err); | ||
210 | + | ||
211 | + qdict_put_obj(qdict_out, name, value); | ||
212 | + } | ||
213 | + } | ||
214 | + | ||
215 | + if (!qdict_size(qdict_out)) { | ||
216 | + qobject_unref(qdict_out); | ||
217 | + } else { | ||
218 | + expansion_info->model->props = QOBJECT(qdict_out); | ||
219 | + expansion_info->model->has_props = true; | ||
220 | + } | ||
221 | + | ||
222 | + object_unref(obj); | ||
223 | + | ||
224 | + return expansion_info; | ||
225 | +} | ||
226 | diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst | ||
227 | new file mode 100644 | 73 | new file mode 100644 |
228 | index XXXXXXX..XXXXXXX | 74 | index XXXXXXX..XXXXXXX |
229 | --- /dev/null | 75 | --- /dev/null |
230 | +++ b/docs/arm-cpu-features.rst | 76 | +++ b/docs/system/barrier.rst |
231 | @@ -XXX,XX +XXX,XX @@ | 77 | @@ -XXX,XX +XXX,XX @@ |
232 | +================ | 78 | +QEMU Barrier Client |
233 | +ARM CPU Features | ||
234 | +================ | ||
235 | + | ||
236 | +Examples of probing and using ARM CPU features | ||
237 | + | ||
238 | +Introduction | ||
239 | +============ | ||
240 | + | ||
241 | +CPU features are optional features that a CPU of supporting type may | ||
242 | +choose to implement or not. In QEMU, optional CPU features have | ||
243 | +corresponding boolean CPU proprieties that, when enabled, indicate | ||
244 | +that the feature is implemented, and, conversely, when disabled, | ||
245 | +indicate that it is not implemented. An example of an ARM CPU feature | ||
246 | +is the Performance Monitoring Unit (PMU). CPU types such as the | ||
247 | +Cortex-A15 and the Cortex-A57, which respectively implement ARM | ||
248 | +architecture reference manuals ARMv7-A and ARMv8-A, may both optionally | ||
249 | +implement PMUs. For example, if a user wants to use a Cortex-A15 without | ||
250 | +a PMU, then the `-cpu` parameter should contain `pmu=off` on the QEMU | ||
251 | +command line, i.e. `-cpu cortex-a15,pmu=off`. | ||
252 | + | ||
253 | +As not all CPU types support all optional CPU features, then whether or | ||
254 | +not a CPU property exists depends on the CPU type. For example, CPUs | ||
255 | +that implement the ARMv8-A architecture reference manual may optionally | ||
256 | +support the AArch32 CPU feature, which may be enabled by disabling the | ||
257 | +`aarch64` CPU property. A CPU type such as the Cortex-A15, which does | ||
258 | +not implement ARMv8-A, will not have the `aarch64` CPU property. | ||
259 | + | ||
260 | +QEMU's support may be limited for some CPU features, only partially | ||
261 | +supporting the feature or only supporting the feature under certain | ||
262 | +configurations. For example, the `aarch64` CPU feature, which, when | ||
263 | +disabled, enables the optional AArch32 CPU feature, is only supported | ||
264 | +when using the KVM accelerator and when running on a host CPU type that | ||
265 | +supports the feature. | ||
266 | + | ||
267 | +CPU Feature Probing | ||
268 | +=================== | 79 | +=================== |
269 | + | 80 | + |
270 | +Determining which CPU features are available and functional for a given | 81 | +Generally, mouse and keyboard are grabbed through the QEMU video |
271 | +CPU type is possible with the `query-cpu-model-expansion` QMP command. | 82 | +interface emulation. |
272 | +Below are some examples where `scripts/qmp/qmp-shell` (see the top comment | ||
273 | +block in the script for usage) is used to issue the QMP commands. | ||
274 | + | 83 | + |
275 | +(1) Determine which CPU features are available for the `max` CPU type | 84 | +But when we want to use a video graphic adapter via a PCI passthrough |
276 | + (Note, we started QEMU with qemu-system-aarch64, so `max` is | 85 | +there is no way to provide the keyboard and mouse inputs to the VM |
277 | + implementing the ARMv8-A reference manual in this case):: | 86 | +except by plugging a second set of mouse and keyboard to the host |
87 | +or by installing a KVM software in the guest OS. | ||
278 | + | 88 | + |
279 | + (QEMU) query-cpu-model-expansion type=full model={"name":"max"} | 89 | +The QEMU Barrier client avoids this by implementing directly the Barrier |
280 | + { "return": { | 90 | +protocol into QEMU. |
281 | + "model": { "name": "max", "props": { | ||
282 | + "pmu": true, "aarch64": true | ||
283 | + }}}} | ||
284 | + | 91 | + |
285 | +We see that the `max` CPU type has the `pmu` and `aarch64` CPU features. | 92 | +`Barrier <https://github.com/debauchee/barrier>`__ |
286 | +We also see that the CPU features are enabled, as they are all `true`. | 93 | +is a KVM (Keyboard-Video-Mouse) software forked from Symless's |
94 | +synergy 1.9 codebase. | ||
287 | + | 95 | + |
288 | +(2) Let's try to disable the PMU:: | 96 | +This protocol is enabled by adding an input-barrier object to QEMU. |
289 | + | 97 | + |
290 | + (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"pmu":false}} | 98 | +Syntax:: |
291 | + { "return": { | ||
292 | + "model": { "name": "max", "props": { | ||
293 | + "pmu": false, "aarch64": true | ||
294 | + }}}} | ||
295 | + | 99 | + |
296 | +We see it worked, as `pmu` is now `false`. | 100 | + input-barrier,id=<object-id>,name=<guest display name> |
101 | + [,server=<barrier server address>][,port=<barrier server port>] | ||
102 | + [,x-origin=<x-origin>][,y-origin=<y-origin>] | ||
103 | + [,width=<width>][,height=<height>] | ||
297 | + | 104 | + |
298 | +(3) Let's try to disable `aarch64`, which enables the AArch32 CPU feature:: | 105 | +The object can be added on the QEMU command line, for instance with:: |
299 | + | 106 | + |
300 | + (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"aarch64":false}} | 107 | + -object input-barrier,id=barrier0,name=VM-1 |
301 | + {"error": { | ||
302 | + "class": "GenericError", "desc": | ||
303 | + "'aarch64' feature cannot be disabled unless KVM is enabled and 32-bit EL1 is supported" | ||
304 | + }} | ||
305 | + | 108 | + |
306 | +It looks like this feature is limited to a configuration we do not | 109 | +where VM-1 is the name the display configured in the Barrier server |
307 | +currently have. | 110 | +on the host providing the mouse and the keyboard events. |
308 | + | 111 | + |
309 | +(4) Let's try probing CPU features for the Cortex-A15 CPU type:: | 112 | +by default ``<barrier server address>`` is ``localhost``, |
113 | +``<port>`` is ``24800``, ``<x-origin>`` and ``<y-origin>`` are set to ``0``, | ||
114 | +``<width>`` and ``<height>`` to ``1920`` and ``1080``. | ||
310 | + | 115 | + |
311 | + (QEMU) query-cpu-model-expansion type=full model={"name":"cortex-a15"} | 116 | +If the Barrier server is stopped QEMU needs to be reconnected manually, |
312 | + {"return": {"model": {"name": "cortex-a15", "props": {"pmu": true}}}} | 117 | +by removing and re-adding the input-barrier object, for instance |
118 | +with the help of the HMP monitor:: | ||
313 | + | 119 | + |
314 | +Only the `pmu` CPU feature is available. | 120 | + (qemu) object_del barrier0 |
315 | + | 121 | + (qemu) object_add input-barrier,id=barrier0,name=VM-1 |
316 | +A note about CPU feature dependencies | 122 | diff --git a/docs/system/index.rst b/docs/system/index.rst |
317 | +------------------------------------- | 123 | index XXXXXXX..XXXXXXX 100644 |
318 | + | 124 | --- a/docs/system/index.rst |
319 | +It's possible for features to have dependencies on other features. I.e. | 125 | +++ b/docs/system/index.rst |
320 | +it may be possible to change one feature at a time without error, but | 126 | @@ -XXX,XX +XXX,XX @@ or Hypervisor.Framework. |
321 | +when attempting to change all features at once an error could occur | 127 | linuxboot |
322 | +depending on the order they are processed. It's also possible changing | 128 | generic-loader |
323 | +all at once doesn't generate an error, because a feature's dependencies | 129 | guest-loader |
324 | +are satisfied with other features, but the same feature cannot be changed | 130 | + barrier |
325 | +independently without error. For these reasons callers should always | 131 | vnc-security |
326 | +attempt to make their desired changes all at once in order to ensure the | 132 | tls |
327 | +collection is valid. | 133 | secrets |
328 | + | ||
329 | +A note about CPU models and KVM | ||
330 | +------------------------------- | ||
331 | + | ||
332 | +Named CPU models generally do not work with KVM. There are a few cases | ||
333 | +that do work, e.g. using the named CPU model `cortex-a57` with KVM on a | ||
334 | +seattle host, but mostly if KVM is enabled the `host` CPU type must be | ||
335 | +used. This means the guest is provided all the same CPU features as the | ||
336 | +host CPU type has. And, for this reason, the `host` CPU type should | ||
337 | +enable all CPU features that the host has by default. Indeed it's even | ||
338 | +a bit strange to allow disabling CPU features that the host has when using | ||
339 | +the `host` CPU type, but in the absence of CPU models it's the best we can | ||
340 | +do if we want to launch guests without all the host's CPU features enabled. | ||
341 | + | ||
342 | +Enabling KVM also affects the `query-cpu-model-expansion` QMP command. The | ||
343 | +affect is not only limited to specific features, as pointed out in example | ||
344 | +(3) of "CPU Feature Probing", but also to which CPU types may be expanded. | ||
345 | +When KVM is enabled, only the `max`, `host`, and current CPU type may be | ||
346 | +expanded. This restriction is necessary as it's not possible to know all | ||
347 | +CPU types that may work with KVM, but it does impose a small risk of users | ||
348 | +experiencing unexpected errors. For example on a seattle, as mentioned | ||
349 | +above, the `cortex-a57` CPU type is also valid when KVM is enabled. | ||
350 | +Therefore a user could use the `host` CPU type for the current type, but | ||
351 | +then attempt to query `cortex-a57`, however that query will fail with our | ||
352 | +restrictions. This shouldn't be an issue though as management layers and | ||
353 | +users have been preferring the `host` CPU type for use with KVM for quite | ||
354 | +some time. Additionally, if the KVM-enabled QEMU instance running on a | ||
355 | +seattle host is using the `cortex-a57` CPU type, then querying `cortex-a57` | ||
356 | +will work. | ||
357 | + | ||
358 | +Using CPU Features | ||
359 | +================== | ||
360 | + | ||
361 | +After determining which CPU features are available and supported for a | ||
362 | +given CPU type, then they may be selectively enabled or disabled on the | ||
363 | +QEMU command line with that CPU type:: | ||
364 | + | ||
365 | + $ qemu-system-aarch64 -M virt -cpu max,pmu=off | ||
366 | + | ||
367 | +The example above disables the PMU for the `max` CPU type. | ||
368 | + | ||
369 | -- | 134 | -- |
370 | 2.20.1 | 135 | 2.20.1 |
371 | 136 | ||
372 | 137 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrew Jones <drjones@redhat.com> | ||
2 | 1 | ||
3 | Since 97a28b0eeac14 ("target/arm: Allow VFP and Neon to be disabled via | ||
4 | a CPU property") we can disable the 'max' cpu model's VFP and neon | ||
5 | features, but there's no way to disable SVE. Add the 'sve=on|off' | ||
6 | property to give it that flexibility. We also rename | ||
7 | cpu_max_get/set_sve_vq to cpu_max_get/set_sve_max_vq in order for them | ||
8 | to follow the typical *_get/set_<property-name> pattern. | ||
9 | |||
10 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | ||
14 | Reviewed-by: Beata Michalska <beata.michalska@linaro.org> | ||
15 | Message-id: 20191024121808.9612-4-drjones@redhat.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | target/arm/cpu.c | 3 ++- | ||
19 | target/arm/cpu64.c | 52 ++++++++++++++++++++++++++++++++++------ | ||
20 | target/arm/monitor.c | 2 +- | ||
21 | tests/arm-cpu-features.c | 1 + | ||
22 | 4 files changed, 49 insertions(+), 9 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/cpu.c | ||
27 | +++ b/target/arm/cpu.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
29 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); | ||
30 | env->cp15.cptr_el[3] |= CPTR_EZ; | ||
31 | /* with maximum vector length */ | ||
32 | - env->vfp.zcr_el[1] = cpu->sve_max_vq - 1; | ||
33 | + env->vfp.zcr_el[1] = cpu_isar_feature(aa64_sve, cpu) ? | ||
34 | + cpu->sve_max_vq - 1 : 0; | ||
35 | env->vfp.zcr_el[2] = env->vfp.zcr_el[1]; | ||
36 | env->vfp.zcr_el[3] = env->vfp.zcr_el[1]; | ||
37 | /* | ||
38 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/cpu64.c | ||
41 | +++ b/target/arm/cpu64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
43 | define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
44 | } | ||
45 | |||
46 | -static void cpu_max_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
47 | - void *opaque, Error **errp) | ||
48 | +static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
49 | + void *opaque, Error **errp) | ||
50 | { | ||
51 | ARMCPU *cpu = ARM_CPU(obj); | ||
52 | - visit_type_uint32(v, name, &cpu->sve_max_vq, errp); | ||
53 | + uint32_t value; | ||
54 | + | ||
55 | + /* All vector lengths are disabled when SVE is off. */ | ||
56 | + if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
57 | + value = 0; | ||
58 | + } else { | ||
59 | + value = cpu->sve_max_vq; | ||
60 | + } | ||
61 | + visit_type_uint32(v, name, &value, errp); | ||
62 | } | ||
63 | |||
64 | -static void cpu_max_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
65 | - void *opaque, Error **errp) | ||
66 | +static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
67 | + void *opaque, Error **errp) | ||
68 | { | ||
69 | ARMCPU *cpu = ARM_CPU(obj); | ||
70 | Error *err = NULL; | ||
71 | @@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
72 | error_propagate(errp, err); | ||
73 | } | ||
74 | |||
75 | +static void cpu_arm_get_sve(Object *obj, Visitor *v, const char *name, | ||
76 | + void *opaque, Error **errp) | ||
77 | +{ | ||
78 | + ARMCPU *cpu = ARM_CPU(obj); | ||
79 | + bool value = cpu_isar_feature(aa64_sve, cpu); | ||
80 | + | ||
81 | + visit_type_bool(v, name, &value, errp); | ||
82 | +} | ||
83 | + | ||
84 | +static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, | ||
85 | + void *opaque, Error **errp) | ||
86 | +{ | ||
87 | + ARMCPU *cpu = ARM_CPU(obj); | ||
88 | + Error *err = NULL; | ||
89 | + bool value; | ||
90 | + uint64_t t; | ||
91 | + | ||
92 | + visit_type_bool(v, name, &value, &err); | ||
93 | + if (err) { | ||
94 | + error_propagate(errp, err); | ||
95 | + return; | ||
96 | + } | ||
97 | + | ||
98 | + t = cpu->isar.id_aa64pfr0; | ||
99 | + t = FIELD_DP64(t, ID_AA64PFR0, SVE, value); | ||
100 | + cpu->isar.id_aa64pfr0 = t; | ||
101 | +} | ||
102 | + | ||
103 | /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); | ||
104 | * otherwise, a CPU with as many features enabled as our emulation supports. | ||
105 | * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; | ||
106 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
107 | #endif | ||
108 | |||
109 | cpu->sve_max_vq = ARM_MAX_VQ; | ||
110 | - object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_vq, | ||
111 | - cpu_max_set_sve_vq, NULL, NULL, &error_fatal); | ||
112 | + object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | ||
113 | + cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); | ||
114 | + object_property_add(obj, "sve", "bool", cpu_arm_get_sve, | ||
115 | + cpu_arm_set_sve, NULL, NULL, &error_fatal); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | diff --git a/target/arm/monitor.c b/target/arm/monitor.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/monitor.c | ||
122 | +++ b/target/arm/monitor.c | ||
123 | @@ -XXX,XX +XXX,XX @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp) | ||
124 | * then the order that considers those dependencies must be used. | ||
125 | */ | ||
126 | static const char *cpu_model_advertised_features[] = { | ||
127 | - "aarch64", "pmu", | ||
128 | + "aarch64", "pmu", "sve", | ||
129 | NULL | ||
130 | }; | ||
131 | |||
132 | diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/tests/arm-cpu-features.c | ||
135 | +++ b/tests/arm-cpu-features.c | ||
136 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data) | ||
137 | |||
138 | if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
139 | assert_has_feature(qts, "max", "aarch64"); | ||
140 | + assert_has_feature(qts, "max", "sve"); | ||
141 | assert_has_feature(qts, "cortex-a57", "pmu"); | ||
142 | assert_has_feature(qts, "cortex-a57", "aarch64"); | ||
143 | |||
144 | -- | ||
145 | 2.20.1 | ||
146 | |||
147 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrew Jones <drjones@redhat.com> | ||
2 | 1 | ||
3 | These are the SVE equivalents to kvm_arch_get/put_fpsimd. Note, the | ||
4 | swabbing is different than it is for fpsmid because the vector format | ||
5 | is a little-endian stream of words. | ||
6 | |||
7 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | ||
11 | Message-id: 20191024121808.9612-6-drjones@redhat.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/kvm64.c | 185 ++++++++++++++++++++++++++++++++++++++------- | ||
15 | 1 file changed, 156 insertions(+), 29 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/kvm64.c | ||
20 | +++ b/target/arm/kvm64.c | ||
21 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_destroy_vcpu(CPUState *cs) | ||
22 | bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx) | ||
23 | { | ||
24 | /* Return true if the regidx is a register we should synchronize | ||
25 | - * via the cpreg_tuples array (ie is not a core reg we sync by | ||
26 | - * hand in kvm_arch_get/put_registers()) | ||
27 | + * via the cpreg_tuples array (ie is not a core or sve reg that | ||
28 | + * we sync by hand in kvm_arch_get/put_registers()) | ||
29 | */ | ||
30 | switch (regidx & KVM_REG_ARM_COPROC_MASK) { | ||
31 | case KVM_REG_ARM_CORE: | ||
32 | + case KVM_REG_ARM64_SVE: | ||
33 | return false; | ||
34 | default: | ||
35 | return true; | ||
36 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_cpreg_level(uint64_t regidx) | ||
37 | |||
38 | static int kvm_arch_put_fpsimd(CPUState *cs) | ||
39 | { | ||
40 | - ARMCPU *cpu = ARM_CPU(cs); | ||
41 | - CPUARMState *env = &cpu->env; | ||
42 | + CPUARMState *env = &ARM_CPU(cs)->env; | ||
43 | struct kvm_one_reg reg; | ||
44 | - uint32_t fpr; | ||
45 | int i, ret; | ||
46 | |||
47 | for (i = 0; i < 32; i++) { | ||
48 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_fpsimd(CPUState *cs) | ||
49 | } | ||
50 | } | ||
51 | |||
52 | - reg.addr = (uintptr_t)(&fpr); | ||
53 | - fpr = vfp_get_fpsr(env); | ||
54 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
55 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
56 | - if (ret) { | ||
57 | - return ret; | ||
58 | + return 0; | ||
59 | +} | ||
60 | + | ||
61 | +/* | ||
62 | + * SVE registers are encoded in KVM's memory in an endianness-invariant format. | ||
63 | + * The byte at offset i from the start of the in-memory representation contains | ||
64 | + * the bits [(7 + 8 * i) : (8 * i)] of the register value. As this means the | ||
65 | + * lowest offsets are stored in the lowest memory addresses, then that nearly | ||
66 | + * matches QEMU's representation, which is to use an array of host-endian | ||
67 | + * uint64_t's, where the lower offsets are at the lower indices. To complete | ||
68 | + * the translation we just need to byte swap the uint64_t's on big-endian hosts. | ||
69 | + */ | ||
70 | +static uint64_t *sve_bswap64(uint64_t *dst, uint64_t *src, int nr) | ||
71 | +{ | ||
72 | +#ifdef HOST_WORDS_BIGENDIAN | ||
73 | + int i; | ||
74 | + | ||
75 | + for (i = 0; i < nr; ++i) { | ||
76 | + dst[i] = bswap64(src[i]); | ||
77 | } | ||
78 | |||
79 | - reg.addr = (uintptr_t)(&fpr); | ||
80 | - fpr = vfp_get_fpcr(env); | ||
81 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
82 | + return dst; | ||
83 | +#else | ||
84 | + return src; | ||
85 | +#endif | ||
86 | +} | ||
87 | + | ||
88 | +/* | ||
89 | + * KVM SVE registers come in slices where ZREGs have a slice size of 2048 bits | ||
90 | + * and PREGS and the FFR have a slice size of 256 bits. However we simply hard | ||
91 | + * code the slice index to zero for now as it's unlikely we'll need more than | ||
92 | + * one slice for quite some time. | ||
93 | + */ | ||
94 | +static int kvm_arch_put_sve(CPUState *cs) | ||
95 | +{ | ||
96 | + ARMCPU *cpu = ARM_CPU(cs); | ||
97 | + CPUARMState *env = &cpu->env; | ||
98 | + uint64_t tmp[ARM_MAX_VQ * 2]; | ||
99 | + uint64_t *r; | ||
100 | + struct kvm_one_reg reg; | ||
101 | + int n, ret; | ||
102 | + | ||
103 | + for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { | ||
104 | + r = sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * 2); | ||
105 | + reg.addr = (uintptr_t)r; | ||
106 | + reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); | ||
107 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
108 | + if (ret) { | ||
109 | + return ret; | ||
110 | + } | ||
111 | + } | ||
112 | + | ||
113 | + for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { | ||
114 | + r = sve_bswap64(tmp, r = &env->vfp.pregs[n].p[0], | ||
115 | + DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); | ||
116 | + reg.addr = (uintptr_t)r; | ||
117 | + reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); | ||
118 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
119 | + if (ret) { | ||
120 | + return ret; | ||
121 | + } | ||
122 | + } | ||
123 | + | ||
124 | + r = sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0], | ||
125 | + DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); | ||
126 | + reg.addr = (uintptr_t)r; | ||
127 | + reg.id = KVM_REG_ARM64_SVE_FFR(0); | ||
128 | ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
129 | if (ret) { | ||
130 | return ret; | ||
131 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
132 | { | ||
133 | struct kvm_one_reg reg; | ||
134 | uint64_t val; | ||
135 | + uint32_t fpr; | ||
136 | int i, ret; | ||
137 | unsigned int el; | ||
138 | |||
139 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
140 | } | ||
141 | } | ||
142 | |||
143 | - ret = kvm_arch_put_fpsimd(cs); | ||
144 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
145 | + ret = kvm_arch_put_sve(cs); | ||
146 | + } else { | ||
147 | + ret = kvm_arch_put_fpsimd(cs); | ||
148 | + } | ||
149 | + if (ret) { | ||
150 | + return ret; | ||
151 | + } | ||
152 | + | ||
153 | + reg.addr = (uintptr_t)(&fpr); | ||
154 | + fpr = vfp_get_fpsr(env); | ||
155 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
156 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
157 | + if (ret) { | ||
158 | + return ret; | ||
159 | + } | ||
160 | + | ||
161 | + reg.addr = (uintptr_t)(&fpr); | ||
162 | + fpr = vfp_get_fpcr(env); | ||
163 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
164 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
165 | if (ret) { | ||
166 | return ret; | ||
167 | } | ||
168 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
169 | |||
170 | static int kvm_arch_get_fpsimd(CPUState *cs) | ||
171 | { | ||
172 | - ARMCPU *cpu = ARM_CPU(cs); | ||
173 | - CPUARMState *env = &cpu->env; | ||
174 | + CPUARMState *env = &ARM_CPU(cs)->env; | ||
175 | struct kvm_one_reg reg; | ||
176 | - uint32_t fpr; | ||
177 | int i, ret; | ||
178 | |||
179 | for (i = 0; i < 32; i++) { | ||
180 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_fpsimd(CPUState *cs) | ||
181 | } | ||
182 | } | ||
183 | |||
184 | - reg.addr = (uintptr_t)(&fpr); | ||
185 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
186 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
187 | - if (ret) { | ||
188 | - return ret; | ||
189 | - } | ||
190 | - vfp_set_fpsr(env, fpr); | ||
191 | + return 0; | ||
192 | +} | ||
193 | |||
194 | - reg.addr = (uintptr_t)(&fpr); | ||
195 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
196 | +/* | ||
197 | + * KVM SVE registers come in slices where ZREGs have a slice size of 2048 bits | ||
198 | + * and PREGS and the FFR have a slice size of 256 bits. However we simply hard | ||
199 | + * code the slice index to zero for now as it's unlikely we'll need more than | ||
200 | + * one slice for quite some time. | ||
201 | + */ | ||
202 | +static int kvm_arch_get_sve(CPUState *cs) | ||
203 | +{ | ||
204 | + ARMCPU *cpu = ARM_CPU(cs); | ||
205 | + CPUARMState *env = &cpu->env; | ||
206 | + struct kvm_one_reg reg; | ||
207 | + uint64_t *r; | ||
208 | + int n, ret; | ||
209 | + | ||
210 | + for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { | ||
211 | + r = &env->vfp.zregs[n].d[0]; | ||
212 | + reg.addr = (uintptr_t)r; | ||
213 | + reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); | ||
214 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
215 | + if (ret) { | ||
216 | + return ret; | ||
217 | + } | ||
218 | + sve_bswap64(r, r, cpu->sve_max_vq * 2); | ||
219 | + } | ||
220 | + | ||
221 | + for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { | ||
222 | + r = &env->vfp.pregs[n].p[0]; | ||
223 | + reg.addr = (uintptr_t)r; | ||
224 | + reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); | ||
225 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
226 | + if (ret) { | ||
227 | + return ret; | ||
228 | + } | ||
229 | + sve_bswap64(r, r, DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); | ||
230 | + } | ||
231 | + | ||
232 | + r = &env->vfp.pregs[FFR_PRED_NUM].p[0]; | ||
233 | + reg.addr = (uintptr_t)r; | ||
234 | + reg.id = KVM_REG_ARM64_SVE_FFR(0); | ||
235 | ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
236 | if (ret) { | ||
237 | return ret; | ||
238 | } | ||
239 | - vfp_set_fpcr(env, fpr); | ||
240 | + sve_bswap64(r, r, DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); | ||
241 | |||
242 | return 0; | ||
243 | } | ||
244 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
245 | struct kvm_one_reg reg; | ||
246 | uint64_t val; | ||
247 | unsigned int el; | ||
248 | + uint32_t fpr; | ||
249 | int i, ret; | ||
250 | |||
251 | ARMCPU *cpu = ARM_CPU(cs); | ||
252 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
253 | env->spsr = env->banked_spsr[i]; | ||
254 | } | ||
255 | |||
256 | - ret = kvm_arch_get_fpsimd(cs); | ||
257 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
258 | + ret = kvm_arch_get_sve(cs); | ||
259 | + } else { | ||
260 | + ret = kvm_arch_get_fpsimd(cs); | ||
261 | + } | ||
262 | if (ret) { | ||
263 | return ret; | ||
264 | } | ||
265 | |||
266 | + reg.addr = (uintptr_t)(&fpr); | ||
267 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
268 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
269 | + if (ret) { | ||
270 | + return ret; | ||
271 | + } | ||
272 | + vfp_set_fpsr(env, fpr); | ||
273 | + | ||
274 | + reg.addr = (uintptr_t)(&fpr); | ||
275 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
276 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
277 | + if (ret) { | ||
278 | + return ret; | ||
279 | + } | ||
280 | + vfp_set_fpcr(env, fpr); | ||
281 | + | ||
282 | ret = kvm_get_vcpu_events(cpu); | ||
283 | if (ret) { | ||
284 | return ret; | ||
285 | -- | ||
286 | 2.20.1 | ||
287 | |||
288 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrew Jones <drjones@redhat.com> | ||
2 | 1 | ||
3 | Enable SVE in the KVM guest when the 'max' cpu type is configured | ||
4 | and KVM supports it. KVM SVE requires use of the new finalize | ||
5 | vcpu ioctl, so we add that now too. For starters SVE can only be | ||
6 | turned on or off, getting all vector lengths the host CPU supports | ||
7 | when on. We'll add the other SVE CPU properties in later patches. | ||
8 | |||
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
12 | Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | ||
13 | Reviewed-by: Beata Michalska <beata.michalska@linaro.org> | ||
14 | Message-id: 20191024121808.9612-7-drjones@redhat.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/kvm_arm.h | 27 +++++++++++++++++++++++++++ | ||
18 | target/arm/cpu64.c | 17 ++++++++++++++--- | ||
19 | target/arm/kvm.c | 5 +++++ | ||
20 | target/arm/kvm64.c | 20 +++++++++++++++++++- | ||
21 | tests/arm-cpu-features.c | 4 ++++ | ||
22 | 5 files changed, 69 insertions(+), 4 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/kvm_arm.h | ||
27 | +++ b/target/arm/kvm_arm.h | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | */ | ||
30 | int kvm_arm_vcpu_init(CPUState *cs); | ||
31 | |||
32 | +/** | ||
33 | + * kvm_arm_vcpu_finalize | ||
34 | + * @cs: CPUState | ||
35 | + * @feature: int | ||
36 | + * | ||
37 | + * Finalizes the configuration of the specified VCPU feature by | ||
38 | + * invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring | ||
39 | + * this are documented in the "KVM_ARM_VCPU_FINALIZE" section of | ||
40 | + * KVM's API documentation. | ||
41 | + * | ||
42 | + * Returns: 0 if success else < 0 error code | ||
43 | + */ | ||
44 | +int kvm_arm_vcpu_finalize(CPUState *cs, int feature); | ||
45 | + | ||
46 | /** | ||
47 | * kvm_arm_register_device: | ||
48 | * @mr: memory region for this device | ||
49 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_aarch32_supported(CPUState *cs); | ||
50 | */ | ||
51 | bool kvm_arm_pmu_supported(CPUState *cs); | ||
52 | |||
53 | +/** | ||
54 | + * bool kvm_arm_sve_supported: | ||
55 | + * @cs: CPUState | ||
56 | + * | ||
57 | + * Returns true if the KVM VCPU can enable SVE and false otherwise. | ||
58 | + */ | ||
59 | +bool kvm_arm_sve_supported(CPUState *cs); | ||
60 | + | ||
61 | /** | ||
62 | * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the | ||
63 | * IPA address space supported by KVM | ||
64 | @@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_pmu_supported(CPUState *cs) | ||
65 | return false; | ||
66 | } | ||
67 | |||
68 | +static inline bool kvm_arm_sve_supported(CPUState *cs) | ||
69 | +{ | ||
70 | + return false; | ||
71 | +} | ||
72 | + | ||
73 | static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
74 | { | ||
75 | return -ENOENT; | ||
76 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/cpu64.c | ||
79 | +++ b/target/arm/cpu64.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | + if (value && kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { | ||
85 | + error_setg(errp, "'sve' feature not supported by KVM on this host"); | ||
86 | + return; | ||
87 | + } | ||
88 | + | ||
89 | t = cpu->isar.id_aa64pfr0; | ||
90 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, value); | ||
91 | cpu->isar.id_aa64pfr0 = t; | ||
92 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
93 | { | ||
94 | ARMCPU *cpu = ARM_CPU(obj); | ||
95 | uint32_t vq; | ||
96 | + uint64_t t; | ||
97 | |||
98 | if (kvm_enabled()) { | ||
99 | kvm_arm_set_cpu_features_from_host(cpu); | ||
100 | + if (kvm_arm_sve_supported(CPU(cpu))) { | ||
101 | + t = cpu->isar.id_aa64pfr0; | ||
102 | + t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
103 | + cpu->isar.id_aa64pfr0 = t; | ||
104 | + } | ||
105 | } else { | ||
106 | - uint64_t t; | ||
107 | uint32_t u; | ||
108 | aarch64_a57_initfn(obj); | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
111 | |||
112 | object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | ||
113 | cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); | ||
114 | - object_property_add(obj, "sve", "bool", cpu_arm_get_sve, | ||
115 | - cpu_arm_set_sve, NULL, NULL, &error_fatal); | ||
116 | |||
117 | for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
118 | char name[8]; | ||
119 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
120 | cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); | ||
121 | } | ||
122 | } | ||
123 | + | ||
124 | + object_property_add(obj, "sve", "bool", cpu_arm_get_sve, | ||
125 | + cpu_arm_set_sve, NULL, NULL, &error_fatal); | ||
126 | } | ||
127 | |||
128 | struct ARMCPUInfo { | ||
129 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/target/arm/kvm.c | ||
132 | +++ b/target/arm/kvm.c | ||
133 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_vcpu_init(CPUState *cs) | ||
134 | return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init); | ||
135 | } | ||
136 | |||
137 | +int kvm_arm_vcpu_finalize(CPUState *cs, int feature) | ||
138 | +{ | ||
139 | + return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_FINALIZE, &feature); | ||
140 | +} | ||
141 | + | ||
142 | void kvm_arm_init_serror_injection(CPUState *cs) | ||
143 | { | ||
144 | cap_has_inject_serror_esr = kvm_check_extension(cs->kvm_state, | ||
145 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
146 | index XXXXXXX..XXXXXXX 100644 | ||
147 | --- a/target/arm/kvm64.c | ||
148 | +++ b/target/arm/kvm64.c | ||
149 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_aarch32_supported(CPUState *cpu) | ||
150 | return kvm_check_extension(s, KVM_CAP_ARM_EL1_32BIT); | ||
151 | } | ||
152 | |||
153 | +bool kvm_arm_sve_supported(CPUState *cpu) | ||
154 | +{ | ||
155 | + KVMState *s = KVM_STATE(current_machine->accelerator); | ||
156 | + | ||
157 | + return kvm_check_extension(s, KVM_CAP_ARM_SVE); | ||
158 | +} | ||
159 | + | ||
160 | #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 | ||
161 | |||
162 | int kvm_arch_init_vcpu(CPUState *cs) | ||
163 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
164 | cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT; | ||
165 | } | ||
166 | if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { | ||
167 | - cpu->has_pmu = false; | ||
168 | + cpu->has_pmu = false; | ||
169 | } | ||
170 | if (cpu->has_pmu) { | ||
171 | cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; | ||
172 | } else { | ||
173 | unset_feature(&env->features, ARM_FEATURE_PMU); | ||
174 | } | ||
175 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
176 | + assert(kvm_arm_sve_supported(cs)); | ||
177 | + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE; | ||
178 | + } | ||
179 | |||
180 | /* Do KVM_ARM_VCPU_INIT ioctl */ | ||
181 | ret = kvm_arm_vcpu_init(cs); | ||
182 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
183 | return ret; | ||
184 | } | ||
185 | |||
186 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
187 | + ret = kvm_arm_vcpu_finalize(cs, KVM_ARM_VCPU_SVE); | ||
188 | + if (ret) { | ||
189 | + return ret; | ||
190 | + } | ||
191 | + } | ||
192 | + | ||
193 | /* | ||
194 | * When KVM is in use, PSCI is emulated in-kernel and not by qemu. | ||
195 | * Currently KVM has its own idea about MPIDR assignment, so we | ||
196 | diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c | ||
197 | index XXXXXXX..XXXXXXX 100644 | ||
198 | --- a/tests/arm-cpu-features.c | ||
199 | +++ b/tests/arm-cpu-features.c | ||
200 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
201 | assert_has_feature(qts, "host", "aarch64"); | ||
202 | assert_has_feature(qts, "host", "pmu"); | ||
203 | |||
204 | + assert_has_feature(qts, "max", "sve"); | ||
205 | + | ||
206 | assert_error(qts, "cortex-a15", | ||
207 | "We cannot guarantee the CPU type 'cortex-a15' works " | ||
208 | "with KVM on this host", NULL); | ||
209 | } else { | ||
210 | assert_has_not_feature(qts, "host", "aarch64"); | ||
211 | assert_has_not_feature(qts, "host", "pmu"); | ||
212 | + | ||
213 | + assert_has_not_feature(qts, "max", "sve"); | ||
214 | } | ||
215 | |||
216 | qtest_quit(qts); | ||
217 | -- | ||
218 | 2.20.1 | ||
219 | |||
220 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrew Jones <drjones@redhat.com> | ||
2 | 1 | ||
3 | kvm_arm_create_scratch_host_vcpu() takes a struct kvm_vcpu_init | ||
4 | parameter. Rather than just using it as an output parameter to | ||
5 | pass back the preferred target, use it also as an input parameter, | ||
6 | allowing a caller to pass a selected target if they wish and to | ||
7 | also pass cpu features. If the caller doesn't want to select a | ||
8 | target they can pass -1 for the target which indicates they want | ||
9 | to use the preferred target and have it passed back like before. | ||
10 | |||
11 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
14 | Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | ||
15 | Reviewed-by: Beata Michalska <beata.michalska@linaro.org> | ||
16 | Message-id: 20191024121808.9612-8-drjones@redhat.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | target/arm/kvm.c | 20 +++++++++++++++----- | ||
20 | target/arm/kvm32.c | 6 +++++- | ||
21 | target/arm/kvm64.c | 6 +++++- | ||
22 | 3 files changed, 25 insertions(+), 7 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/kvm.c | ||
27 | +++ b/target/arm/kvm.c | ||
28 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, | ||
29 | int *fdarray, | ||
30 | struct kvm_vcpu_init *init) | ||
31 | { | ||
32 | - int ret, kvmfd = -1, vmfd = -1, cpufd = -1; | ||
33 | + int ret = 0, kvmfd = -1, vmfd = -1, cpufd = -1; | ||
34 | |||
35 | kvmfd = qemu_open("/dev/kvm", O_RDWR); | ||
36 | if (kvmfd < 0) { | ||
37 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, | ||
38 | goto finish; | ||
39 | } | ||
40 | |||
41 | - ret = ioctl(vmfd, KVM_ARM_PREFERRED_TARGET, init); | ||
42 | + if (init->target == -1) { | ||
43 | + struct kvm_vcpu_init preferred; | ||
44 | + | ||
45 | + ret = ioctl(vmfd, KVM_ARM_PREFERRED_TARGET, &preferred); | ||
46 | + if (!ret) { | ||
47 | + init->target = preferred.target; | ||
48 | + } | ||
49 | + } | ||
50 | if (ret >= 0) { | ||
51 | ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, init); | ||
52 | if (ret < 0) { | ||
53 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, | ||
54 | * creating one kind of guest CPU which is its preferred | ||
55 | * CPU type. | ||
56 | */ | ||
57 | + struct kvm_vcpu_init try; | ||
58 | + | ||
59 | while (*cpus_to_try != QEMU_KVM_ARM_TARGET_NONE) { | ||
60 | - init->target = *cpus_to_try++; | ||
61 | - memset(init->features, 0, sizeof(init->features)); | ||
62 | - ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, init); | ||
63 | + try.target = *cpus_to_try++; | ||
64 | + memcpy(try.features, init->features, sizeof(init->features)); | ||
65 | + ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, &try); | ||
66 | if (ret >= 0) { | ||
67 | break; | ||
68 | } | ||
69 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, | ||
70 | if (ret < 0) { | ||
71 | goto err; | ||
72 | } | ||
73 | + init->target = try.target; | ||
74 | } else { | ||
75 | /* Treat a NULL cpus_to_try argument the same as an empty | ||
76 | * list, which means we will fail the call since this must | ||
77 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/kvm32.c | ||
80 | +++ b/target/arm/kvm32.c | ||
81 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
82 | QEMU_KVM_ARM_TARGET_CORTEX_A15, | ||
83 | QEMU_KVM_ARM_TARGET_NONE | ||
84 | }; | ||
85 | - struct kvm_vcpu_init init; | ||
86 | + /* | ||
87 | + * target = -1 informs kvm_arm_create_scratch_host_vcpu() | ||
88 | + * to use the preferred target | ||
89 | + */ | ||
90 | + struct kvm_vcpu_init init = { .target = -1, }; | ||
91 | |||
92 | if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { | ||
93 | return false; | ||
94 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
95 | index XXXXXXX..XXXXXXX 100644 | ||
96 | --- a/target/arm/kvm64.c | ||
97 | +++ b/target/arm/kvm64.c | ||
98 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
99 | KVM_ARM_TARGET_CORTEX_A57, | ||
100 | QEMU_KVM_ARM_TARGET_NONE | ||
101 | }; | ||
102 | - struct kvm_vcpu_init init; | ||
103 | + /* | ||
104 | + * target = -1 informs kvm_arm_create_scratch_host_vcpu() | ||
105 | + * to use the preferred target | ||
106 | + */ | ||
107 | + struct kvm_vcpu_init init = { .target = -1, }; | ||
108 | |||
109 | if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { | ||
110 | return false; | ||
111 | -- | ||
112 | 2.20.1 | ||
113 | |||
114 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Map the thermal sensor in the BCM2835 block. | ||
4 | |||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20191019234715.25750-3-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | include/hw/arm/bcm2835_peripherals.h | 2 ++ | ||
11 | include/hw/arm/raspi_platform.h | 1 + | ||
12 | hw/arm/bcm2835_peripherals.c | 13 +++++++++++++ | ||
13 | 3 files changed, 16 insertions(+) | ||
14 | |||
15 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/arm/bcm2835_peripherals.h | ||
18 | +++ b/include/hw/arm/bcm2835_peripherals.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "hw/misc/bcm2835_property.h" | ||
21 | #include "hw/misc/bcm2835_rng.h" | ||
22 | #include "hw/misc/bcm2835_mbox.h" | ||
23 | +#include "hw/misc/bcm2835_thermal.h" | ||
24 | #include "hw/sd/sdhci.h" | ||
25 | #include "hw/sd/bcm2835_sdhost.h" | ||
26 | #include "hw/gpio/bcm2835_gpio.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | ||
28 | SDHCIState sdhci; | ||
29 | BCM2835SDHostState sdhost; | ||
30 | BCM2835GpioState gpio; | ||
31 | + Bcm2835ThermalState thermal; | ||
32 | UnimplementedDeviceState i2s; | ||
33 | UnimplementedDeviceState spi[1]; | ||
34 | UnimplementedDeviceState i2c[3]; | ||
35 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/include/hw/arm/raspi_platform.h | ||
38 | +++ b/include/hw/arm/raspi_platform.h | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | #define SPI0_OFFSET 0x204000 | ||
41 | #define BSC0_OFFSET 0x205000 /* BSC0 I2C/TWI */ | ||
42 | #define OTP_OFFSET 0x20f000 | ||
43 | +#define THERMAL_OFFSET 0x212000 | ||
44 | #define BSC_SL_OFFSET 0x214000 /* SPI slave */ | ||
45 | #define AUX_OFFSET 0x215000 /* AUX: UART1/SPI1/SPI2 */ | ||
46 | #define EMMC1_OFFSET 0x300000 | ||
47 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/arm/bcm2835_peripherals.c | ||
50 | +++ b/hw/arm/bcm2835_peripherals.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
52 | object_property_add_const_link(OBJECT(&s->dma), "dma-mr", | ||
53 | OBJECT(&s->gpu_bus_mr), &error_abort); | ||
54 | |||
55 | + /* Thermal */ | ||
56 | + sysbus_init_child_obj(obj, "thermal", &s->thermal, sizeof(s->thermal), | ||
57 | + TYPE_BCM2835_THERMAL); | ||
58 | + | ||
59 | /* GPIO */ | ||
60 | sysbus_init_child_obj(obj, "gpio", &s->gpio, sizeof(s->gpio), | ||
61 | TYPE_BCM2835_GPIO); | ||
62 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
63 | INTERRUPT_DMA0 + n)); | ||
64 | } | ||
65 | |||
66 | + /* THERMAL */ | ||
67 | + object_property_set_bool(OBJECT(&s->thermal), true, "realized", &err); | ||
68 | + if (err) { | ||
69 | + error_propagate(errp, err); | ||
70 | + return; | ||
71 | + } | ||
72 | + memory_region_add_subregion(&s->peri_mr, THERMAL_OFFSET, | ||
73 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0)); | ||
74 | + | ||
75 | /* GPIO */ | ||
76 | object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err); | ||
77 | if (err) { | ||
78 | -- | ||
79 | 2.20.1 | ||
80 | |||
81 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Connect the recently added SYS_timer. | ||
4 | Now U-Boot does not hang anymore polling a free running counter | ||
5 | stuck at 0. | ||
6 | This timer is also used by the Linux kernel thermal subsystem. | ||
7 | |||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20191019234715.25750-5-f4bug@amsat.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/arm/bcm2835_peripherals.h | 3 ++- | ||
14 | hw/arm/bcm2835_peripherals.c | 17 ++++++++++++++++- | ||
15 | 2 files changed, 18 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/bcm2835_peripherals.h | ||
20 | +++ b/include/hw/arm/bcm2835_peripherals.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | #include "hw/sd/sdhci.h" | ||
23 | #include "hw/sd/bcm2835_sdhost.h" | ||
24 | #include "hw/gpio/bcm2835_gpio.h" | ||
25 | +#include "hw/timer/bcm2835_systmr.h" | ||
26 | #include "hw/misc/unimp.h" | ||
27 | |||
28 | #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | ||
30 | MemoryRegion ram_alias[4]; | ||
31 | qemu_irq irq, fiq; | ||
32 | |||
33 | - UnimplementedDeviceState systmr; | ||
34 | + BCM2835SystemTimerState systmr; | ||
35 | UnimplementedDeviceState armtmr; | ||
36 | UnimplementedDeviceState cprman; | ||
37 | UnimplementedDeviceState a2w; | ||
38 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/arm/bcm2835_peripherals.c | ||
41 | +++ b/hw/arm/bcm2835_peripherals.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
43 | /* Interrupt Controller */ | ||
44 | sysbus_init_child_obj(obj, "ic", &s->ic, sizeof(s->ic), TYPE_BCM2835_IC); | ||
45 | |||
46 | + /* SYS Timer */ | ||
47 | + sysbus_init_child_obj(obj, "systimer", &s->systmr, sizeof(s->systmr), | ||
48 | + TYPE_BCM2835_SYSTIMER); | ||
49 | + | ||
50 | /* UART0 */ | ||
51 | sysbus_init_child_obj(obj, "uart0", &s->uart0, sizeof(s->uart0), | ||
52 | TYPE_PL011); | ||
53 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
54 | sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->ic), 0)); | ||
55 | sysbus_pass_irq(SYS_BUS_DEVICE(s), SYS_BUS_DEVICE(&s->ic)); | ||
56 | |||
57 | + /* Sys Timer */ | ||
58 | + object_property_set_bool(OBJECT(&s->systmr), true, "realized", &err); | ||
59 | + if (err) { | ||
60 | + error_propagate(errp, err); | ||
61 | + return; | ||
62 | + } | ||
63 | + memory_region_add_subregion(&s->peri_mr, ST_OFFSET, | ||
64 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systmr), 0)); | ||
65 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 0, | ||
66 | + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ, | ||
67 | + INTERRUPT_ARM_TIMER)); | ||
68 | + | ||
69 | /* UART0 */ | ||
70 | qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0)); | ||
71 | object_property_set_bool(OBJECT(&s->uart0), true, "realized", &err); | ||
72 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
73 | } | ||
74 | |||
75 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
76 | - create_unimp(s, &s->systmr, "bcm2835-systimer", ST_OFFSET, 0x20); | ||
77 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | ||
78 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | ||
79 | create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100); | ||
80 | -- | ||
81 | 2.20.1 | ||
82 | |||
83 | diff view generated by jsdifflib |