1 | The following changes since commit 6eeea6725a70e6fcb5abba0764496bdab07ddfb3: | 1 | A last small test of bug fixes before rc1. |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-10-06' into staging (2020-10-06 21:13:34 +0100) | 3 | thanks |
4 | -- PMM | ||
5 | |||
6 | The following changes since commit ed8ad9728a9c0eec34db9dff61dfa2f1dd625637: | ||
7 | |||
8 | Merge tag 'pull-tpm-2023-07-14-1' of https://github.com/stefanberger/qemu-tpm into staging (2023-07-15 14:54:04 +0100) | ||
4 | 9 | ||
5 | are available in the Git repository at: | 10 | are available in the Git repository at: |
6 | 11 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201008 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230717 |
8 | 13 | ||
9 | for you to fetch changes up to ba118c26e16a97e6ff6de8184057d3420ce16a23: | 14 | for you to fetch changes up to c2c1c4a35c7c2b1a4140b0942b9797c857e476a4: |
10 | 15 | ||
11 | target/arm: Make '-cpu max' have a 48-bit PA (2020-10-08 15:24:32 +0100) | 16 | hw/nvram: Avoid unnecessary Xilinx eFuse backstore write (2023-07-17 11:05:52 +0100) |
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | target-arm queue: | 19 | target-arm queue: |
15 | * hw/ssi/npcm7xx_fiu: Fix handling of unsigned integer | 20 | * hw/arm/sbsa-ref: set 'slots' property of xhci |
16 | * hw/arm/fsl-imx25: Fix a typo | 21 | * linux-user: Remove pointless NULL check in clock_adjtime handling |
17 | * hw/arm/sbsa-ref : Fix SMMUv3 Initialisation | 22 | * ptw: Fix S1_ptw_translate() debug path |
18 | * hw/arm/sbsa-ref : allocate IRQs for SMMUv3 | 23 | * ptw: Account for FEAT_RME when applying {N}SW, SA bits |
19 | * hw/char/bcm2835_aux: Allow less than 32-bit accesses | 24 | * accel/tcg: Zero-pad PC in TCG CPU exec trace lines |
20 | * hw/arm/virt: Implement kvm-steal-time | 25 | * hw/nvram: Avoid unnecessary Xilinx eFuse backstore write |
21 | * target/arm: Make '-cpu max' have a 48-bit PA | ||
22 | 26 | ||
23 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
24 | Andrew Jones (6): | 28 | Peter Maydell (5): |
25 | linux headers: sync to 5.9-rc7 | 29 | linux-user: Remove pointless NULL check in clock_adjtime handling |
26 | target/arm/kvm: Make uncalled stubs explicitly unreachable | 30 | target/arm/ptw.c: Add comments to S1Translate struct fields |
27 | hw/arm/virt: Move post cpu realize check into its own function | 31 | target/arm: Fix S1_ptw_translate() debug path |
28 | hw/arm/virt: Move kvm pmu setup to virt_cpu_post_init | 32 | target/arm/ptw.c: Account for FEAT_RME when applying {N}SW, SA bits |
29 | tests/qtest: Restore aarch64 arm-cpu-features test | 33 | accel/tcg: Zero-pad PC in TCG CPU exec trace lines |
30 | hw/arm/virt: Implement kvm-steal-time | ||
31 | 34 | ||
32 | Graeme Gregory (2): | 35 | Tong Ho (1): |
33 | hw/arm/sbsa-ref : Fix SMMUv3 Initialisation | 36 | hw/nvram: Avoid unnecessary Xilinx eFuse backstore write |
34 | hw/arm/sbsa-ref : allocate IRQs for SMMUv3 | ||
35 | 37 | ||
36 | Peter Maydell (1): | 38 | Yuquan Wang (1): |
37 | target/arm: Make '-cpu max' have a 48-bit PA | 39 | hw/arm/sbsa-ref: set 'slots' property of xhci |
38 | 40 | ||
39 | Philippe Mathieu-Daudé (3): | 41 | accel/tcg/cpu-exec.c | 4 +-- |
40 | hw/ssi/npcm7xx_fiu: Fix handling of unsigned integer | 42 | accel/tcg/translate-all.c | 2 +- |
41 | hw/arm/fsl-imx25: Fix a typo | 43 | hw/arm/sbsa-ref.c | 1 + |
42 | hw/char/bcm2835_aux: Allow less than 32-bit accesses | 44 | hw/nvram/xlnx-efuse.c | 11 ++++-- |
43 | 45 | linux-user/syscall.c | 12 +++---- | |
44 | docs/system/arm/cpu-features.rst | 11 ++++ | 46 | target/arm/ptw.c | 90 +++++++++++++++++++++++++++++++++++++++++------ |
45 | include/hw/arm/fsl-imx25.h | 2 +- | 47 | 6 files changed, 98 insertions(+), 22 deletions(-) |
46 | include/hw/arm/virt.h | 5 ++ | ||
47 | linux-headers/linux/kvm.h | 6 ++- | ||
48 | target/arm/cpu.h | 4 ++ | ||
49 | target/arm/kvm_arm.h | 94 ++++++++++++++++++++++++++------- | ||
50 | hw/arm/sbsa-ref.c | 3 +- | ||
51 | hw/arm/virt.c | 110 ++++++++++++++++++++++++++++----------- | ||
52 | hw/char/bcm2835_aux.c | 4 +- | ||
53 | hw/ssi/npcm7xx_fiu.c | 12 ++--- | ||
54 | target/arm/cpu.c | 8 +++ | ||
55 | target/arm/cpu64.c | 4 ++ | ||
56 | target/arm/kvm.c | 16 ++++++ | ||
57 | target/arm/kvm64.c | 64 +++++++++++++++++++++-- | ||
58 | target/arm/monitor.c | 2 +- | ||
59 | tests/qtest/arm-cpu-features.c | 25 +++++++-- | ||
60 | hw/ssi/trace-events | 2 +- | ||
61 | tests/qtest/meson.build | 3 +- | ||
62 | 18 files changed, 303 insertions(+), 72 deletions(-) | ||
63 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Fix integer handling issues handling issue reported by Coverity: | ||
4 | |||
5 | hw/ssi/npcm7xx_fiu.c: 162 in npcm7xx_fiu_flash_read() | ||
6 | >>> CID 1432730: Integer handling issues (NEGATIVE_RETURNS) | ||
7 | >>> "npcm7xx_fiu_cs_index(fiu, f)" is passed to a parameter that cannot be negative. | ||
8 | 162 npcm7xx_fiu_select(fiu, npcm7xx_fiu_cs_index(fiu, f)); | ||
9 | |||
10 | hw/ssi/npcm7xx_fiu.c: 221 in npcm7xx_fiu_flash_write() | ||
11 | 218 cs_id = npcm7xx_fiu_cs_index(fiu, f); | ||
12 | 219 trace_npcm7xx_fiu_flash_write(DEVICE(fiu)->canonical_path, cs_id, addr, | ||
13 | 220 size, v); | ||
14 | >>> CID 1432729: Integer handling issues (NEGATIVE_RETURNS) | ||
15 | >>> "cs_id" is passed to a parameter that cannot be negative. | ||
16 | 221 npcm7xx_fiu_select(fiu, cs_id); | ||
17 | |||
18 | Since the index of the flash can not be negative, return an | ||
19 | unsigned type. | ||
20 | |||
21 | Reported-by: Coverity (CID 1432729 & 1432730: NEGATIVE_RETURNS) | ||
22 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
23 | Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com> | ||
24 | Message-id: 20200919132435.310527-1-f4bug@amsat.org | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | --- | ||
27 | hw/ssi/npcm7xx_fiu.c | 12 ++++++------ | ||
28 | hw/ssi/trace-events | 2 +- | ||
29 | 2 files changed, 7 insertions(+), 7 deletions(-) | ||
30 | |||
31 | diff --git a/hw/ssi/npcm7xx_fiu.c b/hw/ssi/npcm7xx_fiu.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/ssi/npcm7xx_fiu.c | ||
34 | +++ b/hw/ssi/npcm7xx_fiu.c | ||
35 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxFIURegister { | ||
36 | * Returns the index of flash in the fiu->flash array. This corresponds to the | ||
37 | * chip select ID of the flash. | ||
38 | */ | ||
39 | -static int npcm7xx_fiu_cs_index(NPCM7xxFIUState *fiu, NPCM7xxFIUFlash *flash) | ||
40 | +static unsigned npcm7xx_fiu_cs_index(NPCM7xxFIUState *fiu, | ||
41 | + NPCM7xxFIUFlash *flash) | ||
42 | { | ||
43 | int index = flash - fiu->flash; | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ static int npcm7xx_fiu_cs_index(NPCM7xxFIUState *fiu, NPCM7xxFIUFlash *flash) | ||
46 | } | ||
47 | |||
48 | /* Assert the chip select specified in the UMA Control/Status Register. */ | ||
49 | -static void npcm7xx_fiu_select(NPCM7xxFIUState *s, int cs_id) | ||
50 | +static void npcm7xx_fiu_select(NPCM7xxFIUState *s, unsigned cs_id) | ||
51 | { | ||
52 | trace_npcm7xx_fiu_select(DEVICE(s)->canonical_path, cs_id); | ||
53 | |||
54 | if (cs_id < s->cs_count) { | ||
55 | qemu_irq_lower(s->cs_lines[cs_id]); | ||
56 | + s->active_cs = cs_id; | ||
57 | } else { | ||
58 | qemu_log_mask(LOG_GUEST_ERROR, | ||
59 | "%s: UMA to CS%d; this module has only %d chip selects", | ||
60 | DEVICE(s)->canonical_path, cs_id, s->cs_count); | ||
61 | - cs_id = -1; | ||
62 | + s->active_cs = -1; | ||
63 | } | ||
64 | - | ||
65 | - s->active_cs = cs_id; | ||
66 | } | ||
67 | |||
68 | /* Deassert the currently active chip select. */ | ||
69 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_fiu_flash_write(void *opaque, hwaddr addr, uint64_t v, | ||
70 | NPCM7xxFIUFlash *f = opaque; | ||
71 | NPCM7xxFIUState *fiu = f->fiu; | ||
72 | uint32_t dwr_cfg; | ||
73 | - int cs_id; | ||
74 | + unsigned cs_id; | ||
75 | int i; | ||
76 | |||
77 | if (fiu->active_cs != -1) { | ||
78 | diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/hw/ssi/trace-events | ||
81 | +++ b/hw/ssi/trace-events | ||
82 | @@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_deselect(const char *id, int cs) "%s deselect CS%d" | ||
83 | npcm7xx_fiu_ctrl_read(const char *id, uint64_t addr, uint32_t data) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 | ||
84 | npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 | ||
85 | npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 | ||
86 | -npcm7xx_fiu_flash_write(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 | ||
87 | +npcm7xx_fiu_flash_write(const char *id, unsigned cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 | ||
88 | -- | ||
89 | 2.20.1 | ||
90 | |||
91 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Message-id: 20201002080935.1660005-1-f4bug@amsat.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/arm/fsl-imx25.h | 2 +- | ||
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/include/hw/arm/fsl-imx25.h | ||
14 | +++ b/include/hw/arm/fsl-imx25.h | ||
15 | @@ -XXX,XX +XXX,XX @@ struct FslIMX25State { | ||
16 | * 0xBB00_0000 0xBB00_0FFF 4 Kbytes NAND flash main area buffer | ||
17 | * 0xBB00_1000 0xBB00_11FF 512 B NAND flash spare area buffer | ||
18 | * 0xBB00_1200 0xBB00_1DFF 3 Kbytes Reserved | ||
19 | - * 0xBB00_1E00 0xBB00_1FFF 512 B NAND flash control regisers | ||
20 | + * 0xBB00_1E00 0xBB00_1FFF 512 B NAND flash control registers | ||
21 | * 0xBB01_2000 0xBFFF_FFFF 96 Mbytes (minus 8 Kbytes) Reserved | ||
22 | * 0xC000_0000 0xFFFF_FFFF 1024 Mbytes Reserved | ||
23 | */ | ||
24 | -- | ||
25 | 2.20.1 | ||
26 | |||
27 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Graeme Gregory <graeme@nuviainc.com> | ||
2 | 1 | ||
3 | SMMUv3 has an error in a previous patch where an i was transposed to a 1 | ||
4 | meaning interrupts would not have been correctly assigned to the SMMUv3 | ||
5 | instance. | ||
6 | |||
7 | Fixes: 48ba18e6d3f3 ("hw/arm/sbsa-ref: Simplify by moving the gic in the machine state") | ||
8 | Signed-off-by: Graeme Gregory <graeme@nuviainc.com> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Message-id: 20201007100732.4103790-2-graeme@nuviainc.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/sbsa-ref.c | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/sbsa-ref.c | ||
20 | +++ b/hw/arm/sbsa-ref.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus) | ||
22 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
23 | for (i = 0; i < NUM_SMMU_IRQS; i++) { | ||
24 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
25 | - qdev_get_gpio_in(sms->gic, irq + 1)); | ||
26 | + qdev_get_gpio_in(sms->gic, irq + i)); | ||
27 | } | ||
28 | } | ||
29 | |||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
1 | From: Graeme Gregory <graeme@nuviainc.com> | 1 | From: Yuquan Wang <wangyuquan1236@phytium.com.cn> |
---|---|---|---|
2 | 2 | ||
3 | Original commit did not allocate IRQs for the SMMUv3 in the irqmap | 3 | This extends the slots of xhci to 64, since the default xhci_sysbus |
4 | effectively using irq 0->3 (shared with other devices). Assuming | 4 | just supports one slot. |
5 | original intent was to allocate unique IRQs then add an allocation | ||
6 | to the irqmap. | ||
7 | 5 | ||
8 | Fixes: e9fdf453240 ("hw/arm: Add arm SBSA reference machine, devices part") | 6 | Signed-off-by: Wang Yuquan <wangyuquan1236@phytium.com.cn> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> |
10 | Signed-off-by: Graeme Gregory <graeme@nuviainc.com> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 9 | Reviewed-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
12 | Message-id: 20201007100732.4103790-3-graeme@nuviainc.com | 10 | Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
11 | Message-id: 20230710063750.473510-2-wangyuquan1236@phytium.com.cn | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 13 | --- |
15 | hw/arm/sbsa-ref.c | 1 + | 14 | hw/arm/sbsa-ref.c | 1 + |
16 | 1 file changed, 1 insertion(+) | 15 | 1 file changed, 1 insertion(+) |
17 | 16 | ||
18 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 17 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/sbsa-ref.c | 19 | --- a/hw/arm/sbsa-ref.c |
21 | +++ b/hw/arm/sbsa-ref.c | 20 | +++ b/hw/arm/sbsa-ref.c |
22 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { | 21 | @@ -XXX,XX +XXX,XX @@ static void create_xhci(const SBSAMachineState *sms) |
23 | [SBSA_SECURE_UART_MM] = 9, | 22 | hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base; |
24 | [SBSA_AHCI] = 10, | 23 | int irq = sbsa_ref_irqmap[SBSA_XHCI]; |
25 | [SBSA_EHCI] = 11, | 24 | DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS); |
26 | + [SBSA_SMMU] = 12, /* ... to 15 */ | 25 | + qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS); |
27 | }; | 26 | |
28 | 27 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | |
29 | static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) | 28 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); |
30 | -- | 29 | -- |
31 | 2.20.1 | 30 | 2.34.1 |
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | The "BCM2835 ARM Peripherals" datasheet [*] chapter 2 | ||
4 | ("Auxiliaries: UART1 & SPI1, SPI2"), list the register | ||
5 | sizes as 3/8/16/32 bits. We assume this means this | ||
6 | peripheral allows 8-bit accesses. | ||
7 | |||
8 | This was not an issue until commit 5d971f9e67 which reverted | ||
9 | ("memory: accept mismatching sizes in memory_region_access_valid"). | ||
10 | |||
11 | The model is implemented as 32-bit accesses (see commit 97398d900c, | ||
12 | all registers are 32-bit) so replace MemoryRegionOps.valid as | ||
13 | MemoryRegionOps.impl, and re-introduce MemoryRegionOps.valid | ||
14 | with a 8/32-bit range. | ||
15 | |||
16 | [*] https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf | ||
17 | |||
18 | Fixes: 97398d900c ("bcm2835_aux: add emulation of BCM2835 AUX (aka UART1) block") | ||
19 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Message-id: 20201002181032.1899463-1-f4bug@amsat.org | ||
21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | --- | ||
24 | hw/char/bcm2835_aux.c | 4 +++- | ||
25 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
26 | |||
27 | diff --git a/hw/char/bcm2835_aux.c b/hw/char/bcm2835_aux.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/char/bcm2835_aux.c | ||
30 | +++ b/hw/char/bcm2835_aux.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps bcm2835_aux_ops = { | ||
32 | .read = bcm2835_aux_read, | ||
33 | .write = bcm2835_aux_write, | ||
34 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
35 | - .valid.min_access_size = 4, | ||
36 | + .impl.min_access_size = 4, | ||
37 | + .impl.max_access_size = 4, | ||
38 | + .valid.min_access_size = 1, | ||
39 | .valid.max_access_size = 4, | ||
40 | }; | ||
41 | |||
42 | -- | ||
43 | 2.20.1 | ||
44 | |||
45 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrew Jones <drjones@redhat.com> | ||
2 | 1 | ||
3 | Update against Linux 5.9-rc7. | ||
4 | |||
5 | Cc: Paolo Bonzini <pbonzini@redhat.com> | ||
6 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
7 | Message-id: 20201001061718.101915-2-drjones@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | linux-headers/linux/kvm.h | 6 ++++-- | ||
11 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/linux-headers/linux/kvm.h | ||
16 | +++ b/linux-headers/linux/kvm.h | ||
17 | @@ -XXX,XX +XXX,XX @@ struct kvm_ppc_resize_hpt { | ||
18 | #define KVM_VM_PPC_HV 1 | ||
19 | #define KVM_VM_PPC_PR 2 | ||
20 | |||
21 | -/* on MIPS, 0 forces trap & emulate, 1 forces VZ ASE */ | ||
22 | -#define KVM_VM_MIPS_TE 0 | ||
23 | +/* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */ | ||
24 | +#define KVM_VM_MIPS_AUTO 0 | ||
25 | #define KVM_VM_MIPS_VZ 1 | ||
26 | +#define KVM_VM_MIPS_TE 2 | ||
27 | |||
28 | #define KVM_S390_SIE_PAGE_OFFSET 1 | ||
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ struct kvm_ppc_resize_hpt { | ||
31 | #define KVM_CAP_LAST_CPU 184 | ||
32 | #define KVM_CAP_SMALLER_MAXPHYADDR 185 | ||
33 | #define KVM_CAP_S390_DIAG318 186 | ||
34 | +#define KVM_CAP_STEAL_TIME 187 | ||
35 | |||
36 | #ifdef KVM_CAP_IRQ_ROUTING | ||
37 | |||
38 | -- | ||
39 | 2.20.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | In the code for TARGET_NR_clock_adjtime, we set the pointer phtx to |
---|---|---|---|
2 | the address of the local variable htx. This means it can never be | ||
3 | NULL, but later in the code we check it for NULL anyway. Coverity | ||
4 | complains about this (CID 1507683) because the NULL check comes after | ||
5 | a call to clock_adjtime() that assumes it is non-NULL. | ||
2 | 6 | ||
3 | arm-cpu-features got dropped from the AArch64 tests during the meson | 7 | Since phtx is always &htx, and is used only in three places, it's not |
4 | conversion shuffle. | 8 | really necessary. Remove it, bringing the code structure in to line |
9 | with that for TARGET_NR_clock_adjtime64, which already uses a simple | ||
10 | '&htx' when it wants a pointer to 'htx'. | ||
5 | 11 | ||
6 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
7 | Message-id: 20201001061718.101915-6-drjones@redhat.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20230623144410.1837261-1-peter.maydell@linaro.org | ||
10 | --- | 16 | --- |
11 | tests/qtest/meson.build | 3 ++- | 17 | linux-user/syscall.c | 12 +++++------- |
12 | 1 file changed, 2 insertions(+), 1 deletion(-) | 18 | 1 file changed, 5 insertions(+), 7 deletions(-) |
13 | 19 | ||
14 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | 20 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tests/qtest/meson.build | 22 | --- a/linux-user/syscall.c |
17 | +++ b/tests/qtest/meson.build | 23 | +++ b/linux-user/syscall.c |
18 | @@ -XXX,XX +XXX,XX @@ qtests_aarch64 = \ | 24 | @@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, |
19 | (cpu != 'arm' ? ['bios-tables-test'] : []) + \ | 25 | #if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME) |
20 | (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \ | 26 | case TARGET_NR_clock_adjtime: |
21 | (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \ | 27 | { |
22 | - ['numa-test', | 28 | - struct timex htx, *phtx = &htx; |
23 | + ['arm-cpu-features', | 29 | + struct timex htx; |
24 | + 'numa-test', | 30 | |
25 | 'boot-serial-test', | 31 | - if (target_to_host_timex(phtx, arg2) != 0) { |
26 | 'migration-test'] | 32 | + if (target_to_host_timex(&htx, arg2) != 0) { |
27 | 33 | return -TARGET_EFAULT; | |
34 | } | ||
35 | - ret = get_errno(clock_adjtime(arg1, phtx)); | ||
36 | - if (!is_error(ret) && phtx) { | ||
37 | - if (host_to_target_timex(arg2, phtx) != 0) { | ||
38 | - return -TARGET_EFAULT; | ||
39 | - } | ||
40 | + ret = get_errno(clock_adjtime(arg1, &htx)); | ||
41 | + if (!is_error(ret) && host_to_target_timex(arg2, &htx)) { | ||
42 | + return -TARGET_EFAULT; | ||
43 | } | ||
44 | } | ||
45 | return ret; | ||
28 | -- | 46 | -- |
29 | 2.20.1 | 47 | 2.34.1 |
30 | 48 | ||
31 | 49 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Add comments to the in_* fields in the S1Translate struct |
---|---|---|---|
2 | that explain what they're doing. | ||
2 | 3 | ||
3 | When we compile without KVM support !defined(CONFIG_KVM) we generate | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | stubs for functions that the linker will still encounter. Sometimes | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | these stubs can be executed safely and are placed in paths where they | 6 | Message-id: 20230710152130.3928330-2-peter.maydell@linaro.org |
6 | get executed with or without KVM. Other functions should never be | 7 | --- |
7 | called without KVM. Those functions should be guarded by kvm_enabled(), | 8 | target/arm/ptw.c | 40 ++++++++++++++++++++++++++++++++++++++++ |
8 | but should also be robust to refactoring mistakes. Putting a | 9 | 1 file changed, 40 insertions(+) |
9 | g_assert_not_reached() in the function should help. Additionally, | ||
10 | the g_assert_not_reached() calls may actually help the linker remove | ||
11 | some code. | ||
12 | 10 | ||
13 | We remove the stubs for kvm_arm_get/put_virtual_time(), as they aren't | 11 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
14 | necessary at all - the only caller is in kvm.c | ||
15 | |||
16 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
17 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
18 | Message-id: 20201001061718.101915-3-drjones@redhat.com | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | target/arm/kvm_arm.h | 51 +++++++++++++++++++++++++++----------------- | ||
22 | 1 file changed, 32 insertions(+), 19 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/kvm_arm.h | 13 | --- a/target/arm/ptw.c |
27 | +++ b/target/arm/kvm_arm.h | 14 | +++ b/target/arm/ptw.c |
28 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level); | 15 | @@ -XXX,XX +XXX,XX @@ |
29 | |||
30 | #else | ||
31 | |||
32 | -static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | ||
33 | -{ | ||
34 | - /* | ||
35 | - * This should never actually be called in the "not KVM" case, | ||
36 | - * but set up the fields to indicate an error anyway. | ||
37 | - */ | ||
38 | - cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE; | ||
39 | - cpu->host_cpu_probe_failed = true; | ||
40 | -} | ||
41 | - | ||
42 | -static inline void kvm_arm_add_vcpu_properties(Object *obj) {} | ||
43 | - | ||
44 | +/* | ||
45 | + * It's safe to call these functions without KVM support. | ||
46 | + * They should either do nothing or return "not supported". | ||
47 | + */ | ||
48 | static inline bool kvm_arm_aarch32_supported(void) | ||
49 | { | ||
50 | return false; | ||
51 | @@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_sve_supported(void) | ||
52 | return false; | ||
53 | } | ||
54 | |||
55 | +/* | ||
56 | + * These functions should never actually be called without KVM support. | ||
57 | + */ | ||
58 | +static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | ||
59 | +{ | ||
60 | + g_assert_not_reached(); | ||
61 | +} | ||
62 | + | ||
63 | +static inline void kvm_arm_add_vcpu_properties(Object *obj) | ||
64 | +{ | ||
65 | + g_assert_not_reached(); | ||
66 | +} | ||
67 | + | ||
68 | static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
69 | { | ||
70 | - return -ENOENT; | ||
71 | + g_assert_not_reached(); | ||
72 | } | ||
73 | |||
74 | static inline int kvm_arm_vgic_probe(void) | ||
75 | { | ||
76 | - return 0; | ||
77 | + g_assert_not_reached(); | ||
78 | } | ||
79 | |||
80 | -static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {} | ||
81 | -static inline void kvm_arm_pmu_init(CPUState *cs) {} | ||
82 | +static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) | ||
83 | +{ | ||
84 | + g_assert_not_reached(); | ||
85 | +} | ||
86 | |||
87 | -static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {} | ||
88 | +static inline void kvm_arm_pmu_init(CPUState *cs) | ||
89 | +{ | ||
90 | + g_assert_not_reached(); | ||
91 | +} | ||
92 | + | ||
93 | +static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) | ||
94 | +{ | ||
95 | + g_assert_not_reached(); | ||
96 | +} | ||
97 | |||
98 | -static inline void kvm_arm_get_virtual_time(CPUState *cs) {} | ||
99 | -static inline void kvm_arm_put_virtual_time(CPUState *cs) {} | ||
100 | #endif | 16 | #endif |
101 | 17 | ||
102 | static inline const char *gic_class_name(void) | 18 | typedef struct S1Translate { |
19 | + /* | ||
20 | + * in_mmu_idx : specifies which TTBR, TCR, etc to use for the walk. | ||
21 | + * Together with in_space, specifies the architectural translation regime. | ||
22 | + */ | ||
23 | ARMMMUIdx in_mmu_idx; | ||
24 | + /* | ||
25 | + * in_ptw_idx: specifies which mmuidx to use for the actual | ||
26 | + * page table descriptor load operations. This will be one of the | ||
27 | + * ARMMMUIdx_Stage2* or one of the ARMMMUIdx_Phys_* indexes. | ||
28 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, | ||
29 | + * this field is updated accordingly. | ||
30 | + */ | ||
31 | ARMMMUIdx in_ptw_idx; | ||
32 | + /* | ||
33 | + * in_space: the security space for this walk. This plus | ||
34 | + * the in_mmu_idx specify the architectural translation regime. | ||
35 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, | ||
36 | + * this field is updated accordingly. | ||
37 | + * | ||
38 | + * Note that the security space for the in_ptw_idx may be different | ||
39 | + * from that for the in_mmu_idx. We do not need to explicitly track | ||
40 | + * the in_ptw_idx security space because: | ||
41 | + * - if the in_ptw_idx is an ARMMMUIdx_Phys_* then the mmuidx | ||
42 | + * itself specifies the security space | ||
43 | + * - if the in_ptw_idx is an ARMMMUIdx_Stage2* then the security | ||
44 | + * space used for ptw reads is the same as that of the security | ||
45 | + * space of the stage 1 translation for all cases except where | ||
46 | + * stage 1 is Secure; in that case the only possibilities for | ||
47 | + * the ptw read are Secure and NonSecure, and the in_ptw_idx | ||
48 | + * value being Stage2 vs Stage2_S distinguishes those. | ||
49 | + */ | ||
50 | ARMSecuritySpace in_space; | ||
51 | + /* | ||
52 | + * in_secure: whether the translation regime is a Secure one. | ||
53 | + * This is always equal to arm_space_is_secure(in_space). | ||
54 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, | ||
55 | + * this field is updated accordingly. | ||
56 | + */ | ||
57 | bool in_secure; | ||
58 | + /* | ||
59 | + * in_debug: is this a QEMU debug access (gdbstub, etc)? Debug | ||
60 | + * accesses will not update the guest page table access flags | ||
61 | + * and will not change the state of the softmmu TLBs. | ||
62 | + */ | ||
63 | bool in_debug; | ||
64 | /* | ||
65 | * If this is stage 2 of a stage 1+2 page table walk, then this must | ||
103 | -- | 66 | -- |
104 | 2.20.1 | 67 | 2.34.1 |
105 | |||
106 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | In commit fe4a5472ccd6 we rearranged the logic in S1_ptw_translate() |
---|---|---|---|
2 | so that the debug-access "call get_phys_addr_*" codepath is used both | ||
3 | when S1 is doing ptw reads from stage 2 and when it is doing ptw | ||
4 | reads from physical memory. However, we didn't update the | ||
5 | calculation of s2ptw->in_space and s2ptw->in_secure to account for | ||
6 | the "ptw reads from physical memory" case. This meant that debug | ||
7 | accesses when in Secure state broke. | ||
2 | 8 | ||
3 | We'll add more to this new function in coming patches so we also | 9 | Create a new function S2_security_space() which returns the |
4 | state the gic must be created and call it below create_gic(). | 10 | correct security space to use for the ptw load, and use it to |
11 | determine the correct .in_secure and .in_space fields for the | ||
12 | stage 2 lookup for the ptw load. | ||
5 | 13 | ||
6 | No functional change intended. | 14 | Reported-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
7 | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | |
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 16 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 18 | Message-id: 20230710152130.3928330-3-peter.maydell@linaro.org |
11 | Message-id: 20201001061718.101915-4-drjones@redhat.com | 19 | Fixes: fe4a5472ccd6 ("target/arm: Use get_phys_addr_with_struct in S1_ptw_translate") |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 21 | --- |
14 | hw/arm/virt.c | 43 +++++++++++++++++++++++++++---------------- | 22 | target/arm/ptw.c | 37 ++++++++++++++++++++++++++++++++----- |
15 | 1 file changed, 27 insertions(+), 16 deletions(-) | 23 | 1 file changed, 32 insertions(+), 5 deletions(-) |
16 | 24 | ||
17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 25 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
18 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/virt.c | 27 | --- a/target/arm/ptw.c |
20 | +++ b/hw/arm/virt.c | 28 | +++ b/target/arm/ptw.c |
21 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | 29 | @@ -XXX,XX +XXX,XX @@ static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs) |
22 | } | 30 | } |
23 | } | 31 | } |
24 | 32 | ||
25 | +/* | 33 | +static ARMSecuritySpace S2_security_space(ARMSecuritySpace s1_space, |
26 | + * virt_cpu_post_init() must be called after the CPUs have | 34 | + ARMMMUIdx s2_mmu_idx) |
27 | + * been realized and the GIC has been created. | ||
28 | + */ | ||
29 | +static void virt_cpu_post_init(VirtMachineState *vms) | ||
30 | +{ | 35 | +{ |
31 | + bool aarch64; | 36 | + /* |
32 | + | 37 | + * Return the security space to use for stage 2 when doing |
33 | + aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL); | 38 | + * the S1 page table descriptor load. |
34 | + | 39 | + */ |
35 | + if (!kvm_enabled()) { | 40 | + if (regime_is_stage2(s2_mmu_idx)) { |
36 | + if (aarch64 && vms->highmem) { | 41 | + /* |
37 | + int requested_pa_size = 64 - clz64(vms->highest_gpa); | 42 | + * The security space for ptw reads is almost always the same |
38 | + int pamax = arm_pamax(ARM_CPU(first_cpu)); | 43 | + * as that of the security space of the stage 1 translation. |
39 | + | 44 | + * The only exception is when stage 1 is Secure; in that case |
40 | + if (pamax < requested_pa_size) { | 45 | + * the ptw read might be to the Secure or the NonSecure space |
41 | + error_report("VCPU supports less PA bits (%d) than " | 46 | + * (but never Realm or Root), and the s2_mmu_idx tells us which. |
42 | + "requested by the memory map (%d)", | 47 | + * Root translations are always single-stage. |
43 | + pamax, requested_pa_size); | 48 | + */ |
44 | + exit(1); | 49 | + if (s1_space == ARMSS_Secure) { |
45 | + } | 50 | + return arm_secure_to_space(s2_mmu_idx == ARMMMUIdx_Stage2_S); |
51 | + } else { | ||
52 | + assert(s2_mmu_idx != ARMMMUIdx_Stage2_S); | ||
53 | + assert(s1_space != ARMSS_Root); | ||
54 | + return s1_space; | ||
46 | + } | 55 | + } |
56 | + } else { | ||
57 | + /* ptw loads are from phys: the mmu idx itself says which space */ | ||
58 | + return arm_phys_to_space(s2_mmu_idx); | ||
47 | + } | 59 | + } |
48 | +} | 60 | +} |
49 | + | 61 | + |
50 | static void machvirt_init(MachineState *machine) | 62 | /* Translate a S1 pagetable walk through S2 if needed. */ |
63 | static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, | ||
64 | hwaddr addr, ARMMMUFaultInfo *fi) | ||
51 | { | 65 | { |
52 | VirtMachineState *vms = VIRT_MACHINE(machine); | 66 | - ARMSecuritySpace space = ptw->in_space; |
53 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 67 | bool is_secure = ptw->in_secure; |
54 | fdt_add_timer_nodes(vms); | 68 | ARMMMUIdx mmu_idx = ptw->in_mmu_idx; |
55 | fdt_add_cpu_nodes(vms); | 69 | ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx; |
56 | 70 | @@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, | |
57 | - if (!kvm_enabled()) { | 71 | * From gdbstub, do not use softmmu so that we don't modify the |
58 | - ARMCPU *cpu = ARM_CPU(first_cpu); | 72 | * state of the cpu at all, including softmmu tlb contents. |
59 | - bool aarch64 = object_property_get_bool(OBJECT(cpu), "aarch64", NULL); | 73 | */ |
60 | - | 74 | + ARMSecuritySpace s2_space = S2_security_space(ptw->in_space, s2_mmu_idx); |
61 | - if (aarch64 && vms->highmem) { | 75 | S1Translate s2ptw = { |
62 | - int requested_pa_size, pamax = arm_pamax(cpu); | 76 | .in_mmu_idx = s2_mmu_idx, |
63 | - | 77 | .in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx), |
64 | - requested_pa_size = 64 - clz64(vms->highest_gpa); | 78 | - .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S, |
65 | - if (pamax < requested_pa_size) { | 79 | - .in_space = (s2_mmu_idx == ARMMMUIdx_Stage2_S ? ARMSS_Secure |
66 | - error_report("VCPU supports less PA bits (%d) than requested " | 80 | - : space == ARMSS_Realm ? ARMSS_Realm |
67 | - "by the memory map (%d)", pamax, requested_pa_size); | 81 | - : ARMSS_NonSecure), |
68 | - exit(1); | 82 | + .in_secure = arm_space_is_secure(s2_space), |
69 | - } | 83 | + .in_space = s2_space, |
70 | - } | 84 | .in_debug = true, |
71 | - } | 85 | }; |
72 | - | 86 | GetPhysAddrResult s2 = { }; |
73 | memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, | ||
74 | machine->ram); | ||
75 | if (machine->device_memory) { | ||
76 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
77 | |||
78 | create_gic(vms); | ||
79 | |||
80 | + virt_cpu_post_init(vms); | ||
81 | + | ||
82 | fdt_add_pmu_nodes(vms); | ||
83 | |||
84 | create_uart(vms, VIRT_UART, sysmem, serial_hd(0)); | ||
85 | -- | 87 | -- |
86 | 2.20.1 | 88 | 2.34.1 |
87 | |||
88 | diff view generated by jsdifflib |
1 | QEMU supports a 48-bit physical address range, but we don't currently | 1 | In get_phys_addr_twostage() the code that applies the effects of |
---|---|---|---|
2 | expose it in the '-cpu max' ID registers (you get the same range as | 2 | VSTCR.{SA,SW} and VTCR.{NSA,NSW} only updates result->f.attrs.secure. |
3 | Cortex-A57, which is 44 bits). | 3 | Now we also have f.attrs.space for FEAT_RME, we need to keep the two |
4 | in sync. | ||
4 | 5 | ||
5 | Set the ID_AA64MMFR0.PARange field to indicate 48 bits. | 6 | These bits only have an effect for Secure space translations, not |
7 | for Root, so use the input in_space field to determine whether to | ||
8 | apply them rather than the input is_secure. This doesn't actually | ||
9 | make a difference because Root translations are never two-stage, | ||
10 | but it's a little clearer. | ||
6 | 11 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201001160116.18095-1-peter.maydell@linaro.org | 14 | Message-id: 20230710152130.3928330-4-peter.maydell@linaro.org |
10 | --- | 15 | --- |
11 | target/arm/cpu64.c | 4 ++++ | 16 | target/arm/ptw.c | 13 ++++++++----- |
12 | 1 file changed, 4 insertions(+) | 17 | 1 file changed, 8 insertions(+), 5 deletions(-) |
13 | 18 | ||
14 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 19 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu64.c | 21 | --- a/target/arm/ptw.c |
17 | +++ b/target/arm/cpu64.c | 22 | +++ b/target/arm/ptw.c |
18 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 23 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
19 | t = FIELD_DP64(t, ID_AA64PFR1, MTE, 2); | 24 | hwaddr ipa; |
20 | cpu->isar.id_aa64pfr1 = t; | 25 | int s1_prot, s1_lgpgsz; |
21 | 26 | bool is_secure = ptw->in_secure; | |
22 | + t = cpu->isar.id_aa64mmfr0; | 27 | + ARMSecuritySpace in_space = ptw->in_space; |
23 | + t = FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 5); /* PARange: 48 bits */ | 28 | bool ret, ipa_secure; |
24 | + cpu->isar.id_aa64mmfr0 = t; | 29 | ARMCacheAttrs cacheattrs1; |
25 | + | 30 | ARMSecuritySpace ipa_space; |
26 | t = cpu->isar.id_aa64mmfr1; | 31 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
27 | t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ | 32 | * Check if IPA translates to secure or non-secure PA space. |
28 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); | 33 | * Note that VSTCR overrides VTCR and {N}SW overrides {N}SA. |
34 | */ | ||
35 | - result->f.attrs.secure = | ||
36 | - (is_secure | ||
37 | - && !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) | ||
38 | - && (ipa_secure | ||
39 | - || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)))); | ||
40 | + if (in_space == ARMSS_Secure) { | ||
41 | + result->f.attrs.secure = | ||
42 | + !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) | ||
43 | + && (ipa_secure | ||
44 | + || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))); | ||
45 | + result->f.attrs.space = arm_secure_to_space(result->f.attrs.secure); | ||
46 | + } | ||
47 | |||
48 | return false; | ||
49 | } | ||
29 | -- | 50 | -- |
30 | 2.20.1 | 51 | 2.34.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | In commit f0a08b0913befbd we changed the type of the PC from |
---|---|---|---|
2 | target_ulong to vaddr. In doing so we inadvertently dropped the | ||
3 | zero-padding on the PC in trace lines (the second item inside the [] | ||
4 | in these lines). They used to look like this on AArch64, for | ||
5 | instance: | ||
2 | 6 | ||
3 | Move the KVM PMU setup part of fdt_add_pmu_nodes() to | 7 | Trace 0: 0x7f2260000100 [00000000/0000000040000000/00000061/ff200000] |
4 | virt_cpu_post_init(), which is a more appropriate location. Now | ||
5 | fdt_add_pmu_nodes() is also named more appropriately, because it | ||
6 | no longer does anything but fdt node creation. | ||
7 | 8 | ||
8 | No functional change intended. | 9 | and now they look like this: |
10 | Trace 0: 0x7f4f50000100 [00000000/40000000/00000061/ff200000] | ||
9 | 11 | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | and if the PC happens to be somewhere low like 0x5000 |
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 13 | then the field is shown as /5000/. |
12 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 14 | |
13 | Message-id: 20201001061718.101915-5-drjones@redhat.com | 15 | This is because TARGET_FMT_lx is a "%08x" or "%016x" specifier, |
16 | depending on TARGET_LONG_SIZE, whereas VADDR_PRIx is just PRIx64 | ||
17 | with no width specifier. | ||
18 | |||
19 | Restore the zero-padding by adding an 016 width specifier to | ||
20 | this tracing and a couple of others that were similarly recently | ||
21 | changed to use VADDR_PRIx without a width specifier. | ||
22 | |||
23 | We can't unfortunately restore the "32-bit guests are padded to | ||
24 | 8 hex digits and 64-bit guests to 16 hex digits" behaviour so | ||
25 | easily. | ||
26 | |||
27 | Fixes: f0a08b0913befbd ("accel/tcg/cpu-exec.c: Widen pc to vaddr") | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
30 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
31 | Message-id: 20230711165434.4123674-1-peter.maydell@linaro.org | ||
15 | --- | 32 | --- |
16 | hw/arm/virt.c | 34 ++++++++++++++++++---------------- | 33 | accel/tcg/cpu-exec.c | 4 ++-- |
17 | 1 file changed, 18 insertions(+), 16 deletions(-) | 34 | accel/tcg/translate-all.c | 2 +- |
35 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
18 | 36 | ||
19 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 37 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c |
20 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/virt.c | 39 | --- a/accel/tcg/cpu-exec.c |
22 | +++ b/hw/arm/virt.c | 40 | +++ b/accel/tcg/cpu-exec.c |
23 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_gic_node(VirtMachineState *vms) | 41 | @@ -XXX,XX +XXX,XX @@ static void log_cpu_exec(vaddr pc, CPUState *cpu, |
24 | 42 | if (qemu_log_in_addr_range(pc)) { | |
25 | static void fdt_add_pmu_nodes(const VirtMachineState *vms) | 43 | qemu_log_mask(CPU_LOG_EXEC, |
26 | { | 44 | "Trace %d: %p [%08" PRIx64 |
27 | - CPUState *cpu; | 45 | - "/%" VADDR_PRIx "/%08x/%08x] %s\n", |
28 | - ARMCPU *armcpu; | 46 | + "/%016" VADDR_PRIx "/%08x/%08x] %s\n", |
29 | + ARMCPU *armcpu = ARM_CPU(first_cpu); | 47 | cpu->cpu_index, tb->tc.ptr, tb->cs_base, pc, |
30 | uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI; | 48 | tb->flags, tb->cflags, lookup_symbol(pc)); |
31 | 49 | ||
32 | - CPU_FOREACH(cpu) { | 50 | @@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) |
33 | - armcpu = ARM_CPU(cpu); | 51 | if (qemu_loglevel_mask(CPU_LOG_EXEC)) { |
34 | - if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { | 52 | vaddr pc = log_pc(cpu, last_tb); |
35 | - return; | 53 | if (qemu_log_in_addr_range(pc)) { |
36 | - } | 54 | - qemu_log("Stopped execution of TB chain before %p [%" |
37 | - if (kvm_enabled()) { | 55 | + qemu_log("Stopped execution of TB chain before %p [%016" |
38 | - if (kvm_irqchip_in_kernel()) { | 56 | VADDR_PRIx "] %s\n", |
39 | - kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ)); | 57 | last_tb->tc.ptr, pc, lookup_symbol(pc)); |
40 | - } | 58 | } |
41 | - kvm_arm_pmu_init(cpu); | 59 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
42 | - } | 60 | index XXXXXXX..XXXXXXX 100644 |
43 | + if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { | 61 | --- a/accel/tcg/translate-all.c |
44 | + assert(!object_property_get_bool(OBJECT(armcpu), "pmu", NULL)); | 62 | +++ b/accel/tcg/translate-all.c |
45 | + return; | 63 | @@ -XXX,XX +XXX,XX @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) |
64 | if (qemu_loglevel_mask(CPU_LOG_EXEC)) { | ||
65 | vaddr pc = log_pc(cpu, tb); | ||
66 | if (qemu_log_in_addr_range(pc)) { | ||
67 | - qemu_log("cpu_io_recompile: rewound execution of TB to %" | ||
68 | + qemu_log("cpu_io_recompile: rewound execution of TB to %016" | ||
69 | VADDR_PRIx "\n", pc); | ||
70 | } | ||
46 | } | 71 | } |
47 | |||
48 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
49 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) | ||
50 | (1 << vms->smp_cpus) - 1); | ||
51 | } | ||
52 | |||
53 | - armcpu = ARM_CPU(qemu_get_cpu(0)); | ||
54 | qemu_fdt_add_subnode(vms->fdt, "/pmu"); | ||
55 | if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) { | ||
56 | const char compat[] = "arm,armv8-pmuv3"; | ||
57 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
58 | */ | ||
59 | static void virt_cpu_post_init(VirtMachineState *vms) | ||
60 | { | ||
61 | - bool aarch64; | ||
62 | + bool aarch64, pmu; | ||
63 | + CPUState *cpu; | ||
64 | |||
65 | aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL); | ||
66 | + pmu = object_property_get_bool(OBJECT(first_cpu), "pmu", NULL); | ||
67 | |||
68 | - if (!kvm_enabled()) { | ||
69 | + if (kvm_enabled()) { | ||
70 | + CPU_FOREACH(cpu) { | ||
71 | + if (pmu) { | ||
72 | + assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU)); | ||
73 | + if (kvm_irqchip_in_kernel()) { | ||
74 | + kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ)); | ||
75 | + } | ||
76 | + kvm_arm_pmu_init(cpu); | ||
77 | + } | ||
78 | + } | ||
79 | + } else { | ||
80 | if (aarch64 && vms->highmem) { | ||
81 | int requested_pa_size = 64 - clz64(vms->highest_gpa); | ||
82 | int pamax = arm_pamax(ARM_CPU(first_cpu)); | ||
83 | -- | 72 | -- |
84 | 2.20.1 | 73 | 2.34.1 |
85 | 74 | ||
86 | 75 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | We add the kvm-steal-time CPU property and implement it for machvirt. | 3 | Add a check in the bit-set operation to write the backstore |
4 | A tiny bit of refactoring was also done to allow pmu and pvtime to | 4 | only if the affected bit is 0 before. |
5 | use the same vcpu device helper functions. | ||
6 | 5 | ||
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 6 | With this in place, there will be no need for callers to |
8 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 7 | do the checking in order to avoid unnecessary writes. |
9 | Message-id: 20201001061718.101915-7-drjones@redhat.com | 8 | |
9 | Signed-off-by: Tong Ho <tong.ho@amd.com> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 14 | --- |
12 | docs/system/arm/cpu-features.rst | 11 ++++++ | 15 | hw/nvram/xlnx-efuse.c | 11 +++++++++-- |
13 | include/hw/arm/virt.h | 5 +++ | 16 | 1 file changed, 9 insertions(+), 2 deletions(-) |
14 | target/arm/cpu.h | 4 ++ | ||
15 | target/arm/kvm_arm.h | 43 +++++++++++++++++++++ | ||
16 | hw/arm/virt.c | 43 +++++++++++++++++++-- | ||
17 | target/arm/cpu.c | 8 ++++ | ||
18 | target/arm/kvm.c | 16 ++++++++ | ||
19 | target/arm/kvm64.c | 64 +++++++++++++++++++++++++++++--- | ||
20 | target/arm/monitor.c | 2 +- | ||
21 | tests/qtest/arm-cpu-features.c | 25 +++++++++++-- | ||
22 | 10 files changed, 208 insertions(+), 13 deletions(-) | ||
23 | 17 | ||
24 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst | 18 | diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c |
25 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/docs/system/arm/cpu-features.rst | 20 | --- a/hw/nvram/xlnx-efuse.c |
27 | +++ b/docs/system/arm/cpu-features.rst | 21 | +++ b/hw/nvram/xlnx-efuse.c |
28 | @@ -XXX,XX +XXX,XX @@ the list of KVM VCPU features and their descriptions. | 22 | @@ -XXX,XX +XXX,XX @@ static bool efuse_ro_bits_find(XlnxEFuse *s, uint32_t k) |
29 | adjustment, also restoring the legacy (pre-5.0) | 23 | |
30 | behavior. | 24 | bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit) |
31 | 25 | { | |
32 | + kvm-steal-time Since v5.2, kvm-steal-time is enabled by | 26 | + uint32_t set, *row; |
33 | + default when KVM is enabled, the feature is | ||
34 | + supported, and the guest is 64-bit. | ||
35 | + | 27 | + |
36 | + When kvm-steal-time is enabled a 64-bit guest | 28 | if (efuse_ro_bits_find(s, bit)) { |
37 | + can account for time its CPUs were not running | 29 | g_autofree char *path = object_get_canonical_path(OBJECT(s)); |
38 | + due to the host not scheduling the corresponding | 30 | |
39 | + VCPU threads. The accounting statistics may | 31 | @@ -XXX,XX +XXX,XX @@ bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit) |
40 | + influence the guest scheduler behavior and/or be | ||
41 | + exposed to the guest userspace. | ||
42 | + | ||
43 | SVE CPU Properties | ||
44 | ================== | ||
45 | |||
46 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/include/hw/arm/virt.h | ||
49 | +++ b/include/hw/arm/virt.h | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | |||
52 | #define PPI(irq) ((irq) + 16) | ||
53 | |||
54 | +/* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */ | ||
55 | +#define PVTIME_SIZE_PER_CPU 64 | ||
56 | + | ||
57 | enum { | ||
58 | VIRT_FLASH, | ||
59 | VIRT_MEM, | ||
60 | @@ -XXX,XX +XXX,XX @@ enum { | ||
61 | VIRT_PCDIMM_ACPI, | ||
62 | VIRT_ACPI_GED, | ||
63 | VIRT_NVDIMM_ACPI, | ||
64 | + VIRT_PVTIME, | ||
65 | VIRT_LOWMEMMAP_LAST, | ||
66 | }; | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineClass { | ||
69 | bool no_highmem_ecam; | ||
70 | bool no_ged; /* Machines < 4.2 has no support for ACPI GED device */ | ||
71 | bool kvm_no_adjvtime; | ||
72 | + bool no_kvm_steal_time; | ||
73 | bool acpi_expose_flash; | ||
74 | }; | ||
75 | |||
76 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/cpu.h | ||
79 | +++ b/target/arm/cpu.h | ||
80 | @@ -XXX,XX +XXX,XX @@ | ||
81 | #include "hw/registerfields.h" | ||
82 | #include "cpu-qom.h" | ||
83 | #include "exec/cpu-defs.h" | ||
84 | +#include "qapi/qapi-types-common.h" | ||
85 | |||
86 | /* ARM processors have a weak memory model */ | ||
87 | #define TCG_GUEST_DEFAULT_MO (0) | ||
88 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
89 | bool kvm_vtime_dirty; | ||
90 | uint64_t kvm_vtime; | ||
91 | |||
92 | + /* KVM steal time */ | ||
93 | + OnOffAuto kvm_steal_time; | ||
94 | + | ||
95 | /* Uniprocessor system with MP extensions */ | ||
96 | bool mp_is_up; | ||
97 | |||
98 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/kvm_arm.h | ||
101 | +++ b/target/arm/kvm_arm.h | ||
102 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); | ||
103 | */ | ||
104 | void kvm_arm_add_vcpu_properties(Object *obj); | ||
105 | |||
106 | +/** | ||
107 | + * kvm_arm_steal_time_finalize: | ||
108 | + * @cpu: ARMCPU for which to finalize kvm-steal-time | ||
109 | + * @errp: Pointer to Error* for error propagation | ||
110 | + * | ||
111 | + * Validate the kvm-steal-time property selection and set its default | ||
112 | + * based on KVM support and guest configuration. | ||
113 | + */ | ||
114 | +void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp); | ||
115 | + | ||
116 | +/** | ||
117 | + * kvm_arm_steal_time_supported: | ||
118 | + * | ||
119 | + * Returns: true if KVM can enable steal time reporting | ||
120 | + * and false otherwise. | ||
121 | + */ | ||
122 | +bool kvm_arm_steal_time_supported(void); | ||
123 | + | ||
124 | /** | ||
125 | * kvm_arm_aarch32_supported: | ||
126 | * | ||
127 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_vgic_probe(void); | ||
128 | |||
129 | void kvm_arm_pmu_set_irq(CPUState *cs, int irq); | ||
130 | void kvm_arm_pmu_init(CPUState *cs); | ||
131 | + | ||
132 | +/** | ||
133 | + * kvm_arm_pvtime_init: | ||
134 | + * @cs: CPUState | ||
135 | + * @ipa: Per-vcpu guest physical base address of the pvtime structures | ||
136 | + * | ||
137 | + * Initializes PVTIME for the VCPU, setting the PVTIME IPA to @ipa. | ||
138 | + */ | ||
139 | +void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa); | ||
140 | + | ||
141 | int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level); | ||
142 | |||
143 | #else | ||
144 | @@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_sve_supported(void) | ||
145 | return false; | ||
146 | } | ||
147 | |||
148 | +static inline bool kvm_arm_steal_time_supported(void) | ||
149 | +{ | ||
150 | + return false; | ||
151 | +} | ||
152 | + | ||
153 | /* | ||
154 | * These functions should never actually be called without KVM support. | ||
155 | */ | ||
156 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_pmu_init(CPUState *cs) | ||
157 | g_assert_not_reached(); | ||
158 | } | ||
159 | |||
160 | +static inline void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa) | ||
161 | +{ | ||
162 | + g_assert_not_reached(); | ||
163 | +} | ||
164 | + | ||
165 | +static inline void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) | ||
166 | +{ | ||
167 | + g_assert_not_reached(); | ||
168 | +} | ||
169 | + | ||
170 | static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) | ||
171 | { | ||
172 | g_assert_not_reached(); | ||
173 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/hw/arm/virt.c | ||
176 | +++ b/hw/arm/virt.c | ||
177 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry base_memmap[] = { | ||
178 | [VIRT_PCDIMM_ACPI] = { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, | ||
179 | [VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN }, | ||
180 | [VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN}, | ||
181 | + [VIRT_PVTIME] = { 0x090a0000, 0x00010000 }, | ||
182 | [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, | ||
183 | /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ | ||
184 | [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, | ||
185 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
186 | * virt_cpu_post_init() must be called after the CPUs have | ||
187 | * been realized and the GIC has been created. | ||
188 | */ | ||
189 | -static void virt_cpu_post_init(VirtMachineState *vms) | ||
190 | +static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus, | ||
191 | + MemoryRegion *sysmem) | ||
192 | { | ||
193 | - bool aarch64, pmu; | ||
194 | + bool aarch64, pmu, steal_time; | ||
195 | CPUState *cpu; | ||
196 | |||
197 | aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL); | ||
198 | pmu = object_property_get_bool(OBJECT(first_cpu), "pmu", NULL); | ||
199 | + steal_time = object_property_get_bool(OBJECT(first_cpu), | ||
200 | + "kvm-steal-time", NULL); | ||
201 | |||
202 | if (kvm_enabled()) { | ||
203 | + hwaddr pvtime_reg_base = vms->memmap[VIRT_PVTIME].base; | ||
204 | + hwaddr pvtime_reg_size = vms->memmap[VIRT_PVTIME].size; | ||
205 | + | ||
206 | + if (steal_time) { | ||
207 | + MemoryRegion *pvtime = g_new(MemoryRegion, 1); | ||
208 | + hwaddr pvtime_size = max_cpus * PVTIME_SIZE_PER_CPU; | ||
209 | + | ||
210 | + /* The memory region size must be a multiple of host page size. */ | ||
211 | + pvtime_size = REAL_HOST_PAGE_ALIGN(pvtime_size); | ||
212 | + | ||
213 | + if (pvtime_size > pvtime_reg_size) { | ||
214 | + error_report("pvtime requires a %ld byte memory region for " | ||
215 | + "%d CPUs, but only %ld has been reserved", | ||
216 | + pvtime_size, max_cpus, pvtime_reg_size); | ||
217 | + exit(1); | ||
218 | + } | ||
219 | + | ||
220 | + memory_region_init_ram(pvtime, NULL, "pvtime", pvtime_size, NULL); | ||
221 | + memory_region_add_subregion(sysmem, pvtime_reg_base, pvtime); | ||
222 | + } | ||
223 | + | ||
224 | CPU_FOREACH(cpu) { | ||
225 | if (pmu) { | ||
226 | assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU)); | ||
227 | @@ -XXX,XX +XXX,XX @@ static void virt_cpu_post_init(VirtMachineState *vms) | ||
228 | } | ||
229 | kvm_arm_pmu_init(cpu); | ||
230 | } | ||
231 | + if (steal_time) { | ||
232 | + kvm_arm_pvtime_init(cpu, pvtime_reg_base + | ||
233 | + cpu->cpu_index * PVTIME_SIZE_PER_CPU); | ||
234 | + } | ||
235 | } | ||
236 | } else { | ||
237 | if (aarch64 && vms->highmem) { | ||
238 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
239 | object_property_set_bool(cpuobj, "kvm-no-adjvtime", true, NULL); | ||
240 | } | ||
241 | |||
242 | + if (vmc->no_kvm_steal_time && | ||
243 | + object_property_find(cpuobj, "kvm-steal-time")) { | ||
244 | + object_property_set_bool(cpuobj, "kvm-steal-time", false, NULL); | ||
245 | + } | ||
246 | + | ||
247 | if (vmc->no_pmu && object_property_find(cpuobj, "pmu")) { | ||
248 | object_property_set_bool(cpuobj, "pmu", false, NULL); | ||
249 | } | ||
250 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
251 | |||
252 | create_gic(vms); | ||
253 | |||
254 | - virt_cpu_post_init(vms); | ||
255 | + virt_cpu_post_init(vms, possible_cpus->len, sysmem); | ||
256 | |||
257 | fdt_add_pmu_nodes(vms); | ||
258 | |||
259 | @@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 2) | ||
260 | |||
261 | static void virt_machine_5_1_options(MachineClass *mc) | ||
262 | { | ||
263 | + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); | ||
264 | + | ||
265 | virt_machine_5_2_options(mc); | ||
266 | compat_props_add(mc->compat_props, hw_compat_5_1, hw_compat_5_1_len); | ||
267 | + vmc->no_kvm_steal_time = true; | ||
268 | } | ||
269 | DEFINE_VIRT_MACHINE(5, 1) | ||
270 | |||
271 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
272 | index XXXXXXX..XXXXXXX 100644 | ||
273 | --- a/target/arm/cpu.c | ||
274 | +++ b/target/arm/cpu.c | ||
275 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | ||
276 | return; | ||
277 | } | ||
278 | } | ||
279 | + | ||
280 | + if (kvm_enabled()) { | ||
281 | + kvm_arm_steal_time_finalize(cpu, &local_err); | ||
282 | + if (local_err != NULL) { | ||
283 | + error_propagate(errp, local_err); | ||
284 | + return; | ||
285 | + } | ||
286 | + } | ||
287 | } | ||
288 | |||
289 | static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
290 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
291 | index XXXXXXX..XXXXXXX 100644 | ||
292 | --- a/target/arm/kvm.c | ||
293 | +++ b/target/arm/kvm.c | ||
294 | @@ -XXX,XX +XXX,XX @@ static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp) | ||
295 | ARM_CPU(obj)->kvm_adjvtime = !value; | ||
296 | } | ||
297 | |||
298 | +static bool kvm_steal_time_get(Object *obj, Error **errp) | ||
299 | +{ | ||
300 | + return ARM_CPU(obj)->kvm_steal_time != ON_OFF_AUTO_OFF; | ||
301 | +} | ||
302 | + | ||
303 | +static void kvm_steal_time_set(Object *obj, bool value, Error **errp) | ||
304 | +{ | ||
305 | + ARM_CPU(obj)->kvm_steal_time = value ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; | ||
306 | +} | ||
307 | + | ||
308 | /* KVM VCPU properties should be prefixed with "kvm-". */ | ||
309 | void kvm_arm_add_vcpu_properties(Object *obj) | ||
310 | { | ||
311 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_add_vcpu_properties(Object *obj) | ||
312 | "the virtual counter. VM stopped time " | ||
313 | "will be counted."); | ||
314 | } | ||
315 | + | ||
316 | + cpu->kvm_steal_time = ON_OFF_AUTO_AUTO; | ||
317 | + object_property_add_bool(obj, "kvm-steal-time", kvm_steal_time_get, | ||
318 | + kvm_steal_time_set); | ||
319 | + object_property_set_description(obj, "kvm-steal-time", | ||
320 | + "Set off to disable KVM steal time."); | ||
321 | } | ||
322 | |||
323 | bool kvm_arm_pmu_supported(void) | ||
324 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
325 | index XXXXXXX..XXXXXXX 100644 | ||
326 | --- a/target/arm/kvm64.c | ||
327 | +++ b/target/arm/kvm64.c | ||
328 | @@ -XXX,XX +XXX,XX @@ | ||
329 | #include <linux/kvm.h> | ||
330 | |||
331 | #include "qemu-common.h" | ||
332 | +#include "qapi/error.h" | ||
333 | #include "cpu.h" | ||
334 | #include "qemu/timer.h" | ||
335 | #include "qemu/error-report.h" | ||
336 | @@ -XXX,XX +XXX,XX @@ static CPUWatchpoint *find_hw_watchpoint(CPUState *cpu, target_ulong addr) | ||
337 | return NULL; | ||
338 | } | ||
339 | |||
340 | -static bool kvm_arm_pmu_set_attr(CPUState *cs, struct kvm_device_attr *attr) | ||
341 | +static bool kvm_arm_set_device_attr(CPUState *cs, struct kvm_device_attr *attr, | ||
342 | + const char *name) | ||
343 | { | ||
344 | int err; | ||
345 | |||
346 | err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr); | ||
347 | if (err != 0) { | ||
348 | - error_report("PMU: KVM_HAS_DEVICE_ATTR: %s", strerror(-err)); | ||
349 | + error_report("%s: KVM_HAS_DEVICE_ATTR: %s", name, strerror(-err)); | ||
350 | return false; | 32 | return false; |
351 | } | 33 | } |
352 | 34 | ||
353 | err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr); | 35 | - s->fuse32[bit / 32] |= 1 << (bit % 32); |
354 | if (err != 0) { | 36 | - efuse_bdrv_sync(s, bit); |
355 | - error_report("PMU: KVM_SET_DEVICE_ATTR: %s", strerror(-err)); | 37 | + /* Avoid back-end write unless there is a real update */ |
356 | + error_report("%s: KVM_SET_DEVICE_ATTR: %s", name, strerror(-err)); | 38 | + row = &s->fuse32[bit / 32]; |
357 | return false; | 39 | + set = 1 << (bit % 32); |
358 | } | 40 | + if (!(set & *row)) { |
359 | 41 | + *row |= set; | |
360 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_pmu_init(CPUState *cs) | 42 | + efuse_bdrv_sync(s, bit); |
361 | if (!ARM_CPU(cs)->has_pmu) { | ||
362 | return; | ||
363 | } | ||
364 | - if (!kvm_arm_pmu_set_attr(cs, &attr)) { | ||
365 | + if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) { | ||
366 | error_report("failed to init PMU"); | ||
367 | abort(); | ||
368 | } | ||
369 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq) | ||
370 | if (!ARM_CPU(cs)->has_pmu) { | ||
371 | return; | ||
372 | } | ||
373 | - if (!kvm_arm_pmu_set_attr(cs, &attr)) { | ||
374 | + if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) { | ||
375 | error_report("failed to set irq for PMU"); | ||
376 | abort(); | ||
377 | } | ||
378 | } | ||
379 | |||
380 | +void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa) | ||
381 | +{ | ||
382 | + struct kvm_device_attr attr = { | ||
383 | + .group = KVM_ARM_VCPU_PVTIME_CTRL, | ||
384 | + .attr = KVM_ARM_VCPU_PVTIME_IPA, | ||
385 | + .addr = (uint64_t)&ipa, | ||
386 | + }; | ||
387 | + | ||
388 | + if (ARM_CPU(cs)->kvm_steal_time == ON_OFF_AUTO_OFF) { | ||
389 | + return; | ||
390 | + } | 43 | + } |
391 | + if (!kvm_arm_set_device_attr(cs, &attr, "PVTIME IPA")) { | ||
392 | + error_report("failed to init PVTIME IPA"); | ||
393 | + abort(); | ||
394 | + } | ||
395 | +} | ||
396 | + | ||
397 | static int read_sys_reg32(int fd, uint32_t *pret, uint64_t id) | ||
398 | { | ||
399 | uint64_t ret; | ||
400 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
401 | return true; | 44 | return true; |
402 | } | 45 | } |
403 | 46 | ||
404 | +void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) | ||
405 | +{ | ||
406 | + bool has_steal_time = kvm_arm_steal_time_supported(); | ||
407 | + | ||
408 | + if (cpu->kvm_steal_time == ON_OFF_AUTO_AUTO) { | ||
409 | + if (!has_steal_time || !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
410 | + cpu->kvm_steal_time = ON_OFF_AUTO_OFF; | ||
411 | + } else { | ||
412 | + cpu->kvm_steal_time = ON_OFF_AUTO_ON; | ||
413 | + } | ||
414 | + } else if (cpu->kvm_steal_time == ON_OFF_AUTO_ON) { | ||
415 | + if (!has_steal_time) { | ||
416 | + error_setg(errp, "'kvm-steal-time' cannot be enabled " | ||
417 | + "on this host"); | ||
418 | + return; | ||
419 | + } else if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
420 | + /* | ||
421 | + * DEN0057A chapter 2 says "This specification only covers | ||
422 | + * systems in which the Execution state of the hypervisor | ||
423 | + * as well as EL1 of virtual machines is AArch64.". And, | ||
424 | + * to ensure that, the smc/hvc calls are only specified as | ||
425 | + * smc64/hvc64. | ||
426 | + */ | ||
427 | + error_setg(errp, "'kvm-steal-time' cannot be enabled " | ||
428 | + "for AArch32 guests"); | ||
429 | + return; | ||
430 | + } | ||
431 | + } | ||
432 | +} | ||
433 | + | ||
434 | bool kvm_arm_aarch32_supported(void) | ||
435 | { | ||
436 | return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL1_32BIT); | ||
437 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_sve_supported(void) | ||
438 | return kvm_check_extension(kvm_state, KVM_CAP_ARM_SVE); | ||
439 | } | ||
440 | |||
441 | +bool kvm_arm_steal_time_supported(void) | ||
442 | +{ | ||
443 | + return kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME); | ||
444 | +} | ||
445 | + | ||
446 | QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1); | ||
447 | |||
448 | void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) | ||
449 | diff --git a/target/arm/monitor.c b/target/arm/monitor.c | ||
450 | index XXXXXXX..XXXXXXX 100644 | ||
451 | --- a/target/arm/monitor.c | ||
452 | +++ b/target/arm/monitor.c | ||
453 | @@ -XXX,XX +XXX,XX @@ static const char *cpu_model_advertised_features[] = { | ||
454 | "sve128", "sve256", "sve384", "sve512", | ||
455 | "sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280", | ||
456 | "sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048", | ||
457 | - "kvm-no-adjvtime", | ||
458 | + "kvm-no-adjvtime", "kvm-steal-time", | ||
459 | NULL | ||
460 | }; | ||
461 | |||
462 | diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c | ||
463 | index XXXXXXX..XXXXXXX 100644 | ||
464 | --- a/tests/qtest/arm-cpu-features.c | ||
465 | +++ b/tests/qtest/arm-cpu-features.c | ||
466 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data) | ||
467 | assert_set_feature(qts, "max", "pmu", true); | ||
468 | |||
469 | assert_has_not_feature(qts, "max", "kvm-no-adjvtime"); | ||
470 | + assert_has_not_feature(qts, "max", "kvm-steal-time"); | ||
471 | |||
472 | if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
473 | assert_has_feature_enabled(qts, "max", "aarch64"); | ||
474 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
475 | assert_set_feature(qts, "host", "kvm-no-adjvtime", false); | ||
476 | |||
477 | if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
478 | + bool kvm_supports_steal_time; | ||
479 | bool kvm_supports_sve; | ||
480 | char max_name[8], name[8]; | ||
481 | uint32_t max_vq, vq; | ||
482 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
483 | QDict *resp; | ||
484 | char *error; | ||
485 | |||
486 | + assert_error(qts, "cortex-a15", | ||
487 | + "We cannot guarantee the CPU type 'cortex-a15' works " | ||
488 | + "with KVM on this host", NULL); | ||
489 | + | ||
490 | assert_has_feature_enabled(qts, "host", "aarch64"); | ||
491 | |||
492 | /* Enabling and disabling pmu should always work. */ | ||
493 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
494 | assert_set_feature(qts, "host", "pmu", false); | ||
495 | assert_set_feature(qts, "host", "pmu", true); | ||
496 | |||
497 | - assert_error(qts, "cortex-a15", | ||
498 | - "We cannot guarantee the CPU type 'cortex-a15' works " | ||
499 | - "with KVM on this host", NULL); | ||
500 | - | ||
501 | + /* | ||
502 | + * Some features would be enabled by default, but they're disabled | ||
503 | + * because this instance of KVM doesn't support them. Test that the | ||
504 | + * features are present, and, when enabled, issue further tests. | ||
505 | + */ | ||
506 | + assert_has_feature(qts, "host", "kvm-steal-time"); | ||
507 | assert_has_feature(qts, "host", "sve"); | ||
508 | + | ||
509 | resp = do_query_no_props(qts, "host"); | ||
510 | + kvm_supports_steal_time = resp_get_feature(resp, "kvm-steal-time"); | ||
511 | kvm_supports_sve = resp_get_feature(resp, "sve"); | ||
512 | vls = resp_get_sve_vls(resp); | ||
513 | qobject_unref(resp); | ||
514 | |||
515 | + if (kvm_supports_steal_time) { | ||
516 | + /* If we have steal-time then we should be able to toggle it. */ | ||
517 | + assert_set_feature(qts, "host", "kvm-steal-time", false); | ||
518 | + assert_set_feature(qts, "host", "kvm-steal-time", true); | ||
519 | + } | ||
520 | + | ||
521 | if (kvm_supports_sve) { | ||
522 | g_assert(vls != 0); | ||
523 | max_vq = 64 - __builtin_clzll(vls); | ||
524 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
525 | assert_has_not_feature(qts, "host", "aarch64"); | ||
526 | assert_has_not_feature(qts, "host", "pmu"); | ||
527 | assert_has_not_feature(qts, "host", "sve"); | ||
528 | + assert_has_not_feature(qts, "host", "kvm-steal-time"); | ||
529 | } | ||
530 | |||
531 | qtest_quit(qts); | ||
532 | -- | 47 | -- |
533 | 2.20.1 | 48 | 2.34.1 |
534 | 49 | ||
535 | 50 | diff view generated by jsdifflib |