1
Small pile of bug fixes for rc1. I've included my patches to get
1
Hi; here's a queue of arm patches (plus a few elf2dmp changes);
2
our docs building with Sphinx 3, just for convenience...
2
mostly these are minor cleanups and bugfixes.
3
3
4
thanks
4
-- PMM
5
-- PMM
5
6
6
The following changes since commit b149dea55cce97cb226683d06af61984a1c11e96:
7
The following changes since commit deaca3fd30d3a8829160f8d3705d65ad83176800:
7
8
8
Merge remote-tracking branch 'remotes/cschoenebeck/tags/pull-9p-20201102' into staging (2020-11-02 10:57:48 +0000)
9
Merge tag 'pull-vfio-20231018' of https://github.com/legoater/qemu into staging (2023-10-18 06:21:15 -0400)
9
10
10
are available in the Git repository at:
11
are available in the Git repository at:
11
12
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201102
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20231019
13
14
14
for you to fetch changes up to ffb4fbf90a2f63c9cb33e4bb9f854c79bf04ca4a:
15
for you to fetch changes up to 2a052b4ee01b3c413cef2ef49cb780cde17d4ba1:
15
16
16
tests/qtest/npcm7xx_rng-test: Disable randomness tests (2020-11-02 16:52:18 +0000)
17
contrib/elf2dmp: Use g_malloc(), g_new() and g_free() (2023-10-19 14:32:13 +0100)
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
target-arm queue:
20
target-arm queue:
20
* target/arm: Fix Neon emulation bugs on big-endian hosts
21
* hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder
21
* target/arm: fix handling of HCR.FB
22
* hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot'
22
* target/arm: fix LORID_EL1 access check
23
* xlnx devices: remove deprecated device reset
23
* disas/capstone: Fix monitor disassembly of >32 bytes
24
* xlnx-bbram: hw/nvram: Use dot in device type name
24
* hw/arm/smmuv3: Fix potential integer overflow (CID 1432363)
25
* elf2dmp: fix coverity issues
25
* hw/arm/boot: fix SVE for EL3 direct kernel boot
26
* elf2dmp: convert to g_malloc, g_new and g_free
26
* hw/display/omap_lcdc: Fix potential NULL pointer dereference
27
* target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0
27
* hw/display/exynos4210_fimd: Fix potential NULL pointer dereference
28
* hw/arm: refactor virt PPI logic
28
* target/arm: Get correct MMU index for other-security-state
29
* arm/kvm: convert to kvm_set_one_reg, kvm_get_one_reg
29
* configure: Test that gio libs from pkg-config work
30
* target/arm: Permit T32 LDM with single register
30
* hw/intc/arm_gicv3_cpuif: Make GIC maintenance interrupts work
31
* smmuv3: Advertise SMMUv3.1-XNX
31
* docs: Fix building with Sphinx 3
32
* target/arm: Implement FEAT_HPMN0
32
* tests/qtest/npcm7xx_rng-test: Disable randomness tests
33
* Remove some unnecessary include lines
34
* target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL
35
* hw/timer/npcm7xx_timer: Prevent timer from counting down past zero
33
36
34
----------------------------------------------------------------
37
----------------------------------------------------------------
35
AlexChen (2):
38
Chris Rauer (1):
36
hw/display/omap_lcdc: Fix potential NULL pointer dereference
39
hw/timer/npcm7xx_timer: Prevent timer from counting down past zero
37
hw/display/exynos4210_fimd: Fix potential NULL pointer dereference
38
40
39
Peter Maydell (9):
41
Cornelia Huck (2):
40
target/arm: Fix float16 pairwise Neon ops on big-endian hosts
42
arm/kvm: convert to kvm_set_one_reg
41
target/arm: Fix VUDOT/VSDOT (scalar) on big-endian hosts
43
arm/kvm: convert to kvm_get_one_reg
42
disas/capstone: Fix monitor disassembly of >32 bytes
44
43
target/arm: Get correct MMU index for other-security-state
45
Leif Lindholm (3):
44
configure: Test that gio libs from pkg-config work
46
{include/}hw/arm: refactor virt PPI logic
45
hw/intc/arm_gicv3_cpuif: Make GIC maintenance interrupts work
47
include/hw/arm: move BSA definitions to bsa.h
46
scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments
48
hw/arm/sbsa-ref: use bsa.h for PPI definitions
47
qemu-option-trace.rst.inc: Don't use option:: markup
49
48
tests/qtest/npcm7xx_rng-test: Disable randomness tests
50
Michal Orzel (1):
51
target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0
52
53
Peter Maydell (8):
54
target/arm: Permit T32 LDM with single register
55
hw/arm/smmuv3: Update ID register bit field definitions
56
hw/arm/smmuv3: Sort ID register setting into field order
57
hw/arm/smmuv3: Advertise SMMUv3.1-XNX feature
58
target/arm: Implement FEAT_HPMN0
59
target/arm/kvm64.c: Remove unused include
60
target/arm/common-semi-target.h: Remove unnecessary boot.h include
61
target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL
49
62
50
Philippe Mathieu-Daudé (1):
63
Philippe Mathieu-Daudé (1):
51
hw/arm/smmuv3: Fix potential integer overflow (CID 1432363)
64
hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot.h'
52
65
53
Richard Henderson (11):
66
Suraj Shirvankar (1):
54
target/arm: Introduce neon_full_reg_offset
67
contrib/elf2dmp: Use g_malloc(), g_new() and g_free()
55
target/arm: Move neon_element_offset to translate.c
56
target/arm: Use neon_element_offset in neon_load/store_reg
57
target/arm: Use neon_element_offset in vfp_reg_offset
58
target/arm: Add read/write_neon_element32
59
target/arm: Expand read/write_neon_element32 to all MemOp
60
target/arm: Rename neon_load_reg32 to vfp_load_reg32
61
target/arm: Add read/write_neon_element64
62
target/arm: Rename neon_load_reg64 to vfp_load_reg64
63
target/arm: Simplify do_long_3d and do_2scalar_long
64
target/arm: Improve do_prewiden_3d
65
68
66
Rémi Denis-Courmont (3):
69
Thomas Huth (1):
67
target/arm: fix handling of HCR.FB
70
hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder
68
target/arm: fix LORID_EL1 access check
69
hw/arm/boot: fix SVE for EL3 direct kernel boot
70
71
71
docs/qemu-option-trace.rst.inc | 6 +-
72
Tong Ho (4):
72
configure | 10 +-
73
xlnx-bbram: hw/nvram: Remove deprecated device reset
73
include/hw/intc/arm_gicv3_common.h | 1 -
74
xlnx-zynqmp-efuse: hw/nvram: Remove deprecated device reset
74
disas/capstone.c | 2 +-
75
xlnx-versal-efuse: hw/nvram: Remove deprecated device reset
75
hw/arm/boot.c | 3 +
76
xlnx-bbram: hw/nvram: Use dot in device type name
76
hw/arm/smmuv3.c | 3 +-
77
hw/display/exynos4210_fimd.c | 4 +-
78
hw/display/omap_lcdc.c | 10 +-
79
hw/intc/arm_gicv3_cpuif.c | 5 +-
80
target/arm/helper.c | 24 +-
81
target/arm/m_helper.c | 3 +-
82
target/arm/translate.c | 153 +++++++++---
83
target/arm/vec_helper.c | 12 +-
84
tests/qtest/npcm7xx_rng-test.c | 14 +-
85
scripts/kernel-doc | 18 +-
86
target/arm/translate-neon.c.inc | 472 ++++++++++++++++++++-----------------
87
target/arm/translate-vfp.c.inc | 341 +++++++++++----------------
88
17 files changed, 588 insertions(+), 493 deletions(-)
89
77
78
Viktor Prutyanov (2):
79
elf2dmp: limit print length for sign_rsds
80
elf2dmp: check array bounds in pdb_get_file_size
81
82
MAINTAINERS | 2 +-
83
docs/system/arm/emulation.rst | 1 +
84
hw/arm/smmuv3-internal.h | 38 ++++++++
85
include/hw/arm/bsa.h | 35 +++++++
86
include/hw/arm/exynos4210.h | 2 +-
87
include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0
88
include/hw/arm/virt.h | 12 +--
89
include/hw/nvram/xlnx-bbram.h | 2 +-
90
target/arm/common-semi-target.h | 4 +-
91
target/arm/cpu-qom.h | 2 -
92
target/arm/cpu.h | 22 +++++
93
contrib/elf2dmp/addrspace.c | 7 +-
94
contrib/elf2dmp/main.c | 11 +--
95
contrib/elf2dmp/pdb.c | 32 ++++---
96
contrib/elf2dmp/qemu_elf.c | 7 +-
97
hw/arm/boot.c | 95 +++++--------------
98
hw/arm/sbsa-ref.c | 21 ++---
99
hw/arm/smmuv3.c | 8 +-
100
hw/arm/virt-acpi-build.c | 12 +--
101
hw/arm/virt.c | 24 +++--
102
hw/misc/bcm2835_property.c | 2 +-
103
hw/nvram/xlnx-bbram.c | 8 +-
104
hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +-
105
hw/nvram/xlnx-zynqmp-efuse.c | 8 +-
106
hw/timer/npcm7xx_timer.c | 3 +
107
target/arm/arm-powerctl.c | 53 +----------
108
target/arm/cpu.c | 95 +++++++++++++++++++
109
target/arm/helper.c | 19 +---
110
target/arm/kvm.c | 28 ++----
111
target/arm/kvm64.c | 124 +++++++------------------
112
target/arm/tcg/cpu32.c | 4 +
113
target/arm/tcg/cpu64.c | 1 +
114
target/arm/tcg/translate.c | 37 +++++---
115
33 files changed, 368 insertions(+), 359 deletions(-)
116
create mode 100644 include/hw/arm/bsa.h
117
rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%)
118
diff view generated by jsdifflib
1
The randomness tests in the NPCM7xx RNG test fail intermittently
1
From: Thomas Huth <thuth@redhat.com>
2
but fairly frequently. On my machine running the test in a loop:
3
while QTEST_QEMU_BINARY=./qemu-system-aarch64 ./tests/qtest/npcm7xx_rng-test; do true; done
4
2
5
will fail in less than a minute with an error like:
3
The file is obviously related to the raspberrypi machine, so
6
ERROR:../../tests/qtest/npcm7xx_rng-test.c:256:test_first_byte_runs:
4
it should reside in hw/arm/ instead of hw/misc/. And while we're
7
assertion failed (calc_runs_p(buf.l, sizeof(buf) * BITS_PER_BYTE) > 0.01): (0.00286205989 > 0.01)
5
at it, also adjust the wildcard in MAINTAINERS so that it covers
6
this file, too.
8
7
9
(Failures have been observed on all 4 of the randomness tests,
8
Signed-off-by: Thomas Huth <thuth@redhat.com>
10
not just first_byte_runs.)
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20231012073458.860187-1-thuth@redhat.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
MAINTAINERS | 2 +-
15
include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0
16
hw/misc/bcm2835_property.c | 2 +-
17
3 files changed, 2 insertions(+), 2 deletions(-)
18
rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%)
11
19
12
It's not clear why these tests are failing like this, but intermittent
20
diff --git a/MAINTAINERS b/MAINTAINERS
13
failures make CI and merge testing awkward, so disable running them
14
unless a developer specifically sets QEMU_TEST_FLAKY_RNG_TESTS when
15
running the test suite, until we work out the cause.
16
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
19
Message-id: 20201102152454.8287-1-peter.maydell@linaro.org
20
Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
21
---
22
tests/qtest/npcm7xx_rng-test.c | 14 ++++++++++----
23
1 file changed, 10 insertions(+), 4 deletions(-)
24
25
diff --git a/tests/qtest/npcm7xx_rng-test.c b/tests/qtest/npcm7xx_rng-test.c
26
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
27
--- a/tests/qtest/npcm7xx_rng-test.c
22
--- a/MAINTAINERS
28
+++ b/tests/qtest/npcm7xx_rng-test.c
23
+++ b/MAINTAINERS
29
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
24
@@ -XXX,XX +XXX,XX @@ S: Odd Fixes
30
25
F: hw/arm/raspi.c
31
qtest_add_func("npcm7xx_rng/enable_disable", test_enable_disable);
26
F: hw/arm/raspi_platform.h
32
qtest_add_func("npcm7xx_rng/rosel", test_rosel);
27
F: hw/*/bcm283*
33
- qtest_add_func("npcm7xx_rng/continuous/monobit", test_continuous_monobit);
28
-F: include/hw/arm/raspi*
34
- qtest_add_func("npcm7xx_rng/continuous/runs", test_continuous_runs);
29
+F: include/hw/arm/rasp*
35
- qtest_add_func("npcm7xx_rng/first_byte/monobit", test_first_byte_monobit);
30
F: include/hw/*/bcm283*
36
- qtest_add_func("npcm7xx_rng/first_byte/runs", test_first_byte_runs);
31
F: docs/system/arm/raspi.rst
37
+ /*
32
38
+ * These tests fail intermittently; only run them on explicit
33
diff --git a/include/hw/misc/raspberrypi-fw-defs.h b/include/hw/arm/raspberrypi-fw-defs.h
39
+ * request until we figure out why.
34
similarity index 100%
40
+ */
35
rename from include/hw/misc/raspberrypi-fw-defs.h
41
+ if (getenv("QEMU_TEST_FLAKY_RNG_TESTS")) {
36
rename to include/hw/arm/raspberrypi-fw-defs.h
42
+ qtest_add_func("npcm7xx_rng/continuous/monobit", test_continuous_monobit);
37
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
43
+ qtest_add_func("npcm7xx_rng/continuous/runs", test_continuous_runs);
38
index XXXXXXX..XXXXXXX 100644
44
+ qtest_add_func("npcm7xx_rng/first_byte/monobit", test_first_byte_monobit);
39
--- a/hw/misc/bcm2835_property.c
45
+ qtest_add_func("npcm7xx_rng/first_byte/runs", test_first_byte_runs);
40
+++ b/hw/misc/bcm2835_property.c
46
+ }
41
@@ -XXX,XX +XXX,XX @@
47
42
#include "migration/vmstate.h"
48
qtest_start("-machine npcm750-evb");
43
#include "hw/irq.h"
49
ret = g_test_run();
44
#include "hw/misc/bcm2835_mbox_defs.h"
45
-#include "hw/misc/raspberrypi-fw-defs.h"
46
+#include "hw/arm/raspberrypi-fw-defs.h"
47
#include "sysemu/dma.h"
48
#include "qemu/log.h"
49
#include "qemu/module.h"
50
--
50
--
51
2.20.1
51
2.34.1
52
52
53
53
diff view generated by jsdifflib
1
From: AlexChen <alex.chen@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
In exynos4210_fimd_update(), the pointer s is dereferinced before
3
struct arm_boot_info is declared in "hw/arm/boot.h".
4
being check if it is valid, which may lead to NULL pointer dereference.
4
By including the correct header we don't need to declare
5
So move the assignment to global_width after checking that the s is valid.
5
it again in "target/arm/cpu-qom.h".
6
6
7
Reported-by: Euler Robot <euler.robot@huawei.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Signed-off-by: Alex Chen <alex.chen@huawei.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: 20231013130214.95742-1-philmd@linaro.org
10
Message-id: 5F9F8D88.9030102@huawei.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
hw/display/exynos4210_fimd.c | 4 +++-
12
include/hw/arm/exynos4210.h | 2 +-
14
1 file changed, 3 insertions(+), 1 deletion(-)
13
target/arm/cpu-qom.h | 2 --
14
2 files changed, 1 insertion(+), 3 deletions(-)
15
15
16
diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
16
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/display/exynos4210_fimd.c
18
--- a/include/hw/arm/exynos4210.h
19
+++ b/hw/display/exynos4210_fimd.c
19
+++ b/include/hw/arm/exynos4210.h
20
@@ -XXX,XX +XXX,XX @@ static void exynos4210_fimd_update(void *opaque)
20
@@ -XXX,XX +XXX,XX @@
21
bool blend = false;
21
#include "hw/intc/exynos4210_gic.h"
22
uint8_t *host_fb_addr;
22
#include "hw/intc/exynos4210_combiner.h"
23
bool is_dirty = false;
23
#include "hw/core/split-irq.h"
24
- const int global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1;
24
-#include "target/arm/cpu-qom.h"
25
+ int global_width;
25
+#include "hw/arm/boot.h"
26
26
#include "qom/object.h"
27
if (!s || !s->console || !s->enabled ||
27
28
surface_bits_per_pixel(qemu_console_surface(s->console)) == 0) {
28
#define EXYNOS4210_NCPUS 2
29
return;
29
diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
30
}
30
index XXXXXXX..XXXXXXX 100644
31
+
31
--- a/target/arm/cpu-qom.h
32
+ global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1;
32
+++ b/target/arm/cpu-qom.h
33
exynos4210_update_resolution(s);
33
@@ -XXX,XX +XXX,XX @@
34
surface = qemu_console_surface(s->console);
34
#include "hw/core/cpu.h"
35
35
#include "qom/object.h"
36
37
-struct arm_boot_info;
38
-
39
#define TYPE_ARM_CPU "arm-cpu"
40
41
OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU)
36
--
42
--
37
2.20.1
43
2.34.1
38
44
39
45
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
When booting a CPU with EL3 using the -kernel flag, set up CPTR_EL3 so
3
This change implements the ResettableClass interface for the device.
4
that SVE will not trap to EL3.
5
4
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20201030151541.11976-1-remi@remlab.net
7
Message-id: 20231003052345.199725-1-tong.ho@amd.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
9
---
11
hw/arm/boot.c | 3 +++
10
hw/nvram/xlnx-bbram.c | 8 +++++---
12
1 file changed, 3 insertions(+)
11
1 file changed, 5 insertions(+), 3 deletions(-)
13
12
14
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
13
diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/boot.c
15
--- a/hw/nvram/xlnx-bbram.c
17
+++ b/hw/arm/boot.c
16
+++ b/hw/nvram/xlnx-bbram.c
18
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
17
@@ -XXX,XX +XXX,XX @@
19
if (cpu_isar_feature(aa64_mte, cpu)) {
18
* QEMU model of the Xilinx BBRAM Battery Backed RAM
20
env->cp15.scr_el3 |= SCR_ATA;
19
*
21
}
20
* Copyright (c) 2014-2021 Xilinx Inc.
22
+ if (cpu_isar_feature(aa64_sve, cpu)) {
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
23
+ env->cp15.cptr_el[3] |= CPTR_EZ;
22
*
24
+ }
23
* Permission is hereby granted, free of charge, to any person obtaining a copy
25
/* AArch64 kernels never boot in secure mode */
24
* of this software and associated documentation files (the "Software"), to deal
26
assert(!info->secure_boot);
25
@@ -XXX,XX +XXX,XX @@ static RegisterAccessInfo bbram_ctrl_regs_info[] = {
27
/* This hook is only supported for AArch32 currently:
26
}
27
};
28
29
-static void bbram_ctrl_reset(DeviceState *dev)
30
+static void bbram_ctrl_reset_hold(Object *obj)
31
{
32
- XlnxBBRam *s = XLNX_BBRAM(dev);
33
+ XlnxBBRam *s = XLNX_BBRAM(obj);
34
unsigned int i;
35
36
for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
37
@@ -XXX,XX +XXX,XX @@ static Property bbram_ctrl_props[] = {
38
static void bbram_ctrl_class_init(ObjectClass *klass, void *data)
39
{
40
DeviceClass *dc = DEVICE_CLASS(klass);
41
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
42
43
- dc->reset = bbram_ctrl_reset;
44
+ rc->phases.hold = bbram_ctrl_reset_hold;
45
dc->realize = bbram_ctrl_realize;
46
dc->vmsd = &vmstate_bbram_ctrl;
47
device_class_set_props(dc, bbram_ctrl_props);
28
--
48
--
29
2.20.1
49
2.34.1
30
50
31
51
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
The only uses of this function are for loading VFP
3
This change implements the ResettableClass interface for the device.
4
double-precision values, and nothing to do with NEON.
5
4
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
7
Message-id: 20201030022618.785675-10-richard.henderson@linaro.org
6
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20231004055713.324009-1-tong.ho@amd.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
9
---
11
target/arm/translate.c | 8 ++--
10
hw/nvram/xlnx-zynqmp-efuse.c | 8 +++++---
12
target/arm/translate-vfp.c.inc | 84 +++++++++++++++++-----------------
11
1 file changed, 5 insertions(+), 3 deletions(-)
13
2 files changed, 46 insertions(+), 46 deletions(-)
14
12
15
diff --git a/target/arm/translate.c b/target/arm/translate.c
13
diff --git a/hw/nvram/xlnx-zynqmp-efuse.c b/hw/nvram/xlnx-zynqmp-efuse.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate.c
15
--- a/hw/nvram/xlnx-zynqmp-efuse.c
18
+++ b/target/arm/translate.c
16
+++ b/hw/nvram/xlnx-zynqmp-efuse.c
19
@@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg)
17
@@ -XXX,XX +XXX,XX @@
20
}
18
* QEMU model of the ZynqMP eFuse
19
*
20
* Copyright (c) 2015 Xilinx Inc.
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
22
*
23
* Written by Edgar E. Iglesias <edgari@xilinx.com>
24
*
25
@@ -XXX,XX +XXX,XX @@ static void zynqmp_efuse_register_reset(RegisterInfo *reg)
26
register_reset(reg);
21
}
27
}
22
28
23
-static inline void neon_load_reg64(TCGv_i64 var, int reg)
29
-static void zynqmp_efuse_reset(DeviceState *dev)
24
+static inline void vfp_load_reg64(TCGv_i64 var, int reg)
30
+static void zynqmp_efuse_reset_hold(Object *obj)
25
{
31
{
26
- tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg));
32
- XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(dev);
27
+ tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(true, reg));
33
+ XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj);
28
}
34
unsigned int i;
29
35
30
-static inline void neon_store_reg64(TCGv_i64 var, int reg)
36
for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
31
+static inline void vfp_store_reg64(TCGv_i64 var, int reg)
37
@@ -XXX,XX +XXX,XX @@ static Property zynqmp_efuse_props[] = {
38
static void zynqmp_efuse_class_init(ObjectClass *klass, void *data)
32
{
39
{
33
- tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg));
40
DeviceClass *dc = DEVICE_CLASS(klass);
34
+ tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(true, reg));
41
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
35
}
42
36
43
- dc->reset = zynqmp_efuse_reset;
37
static inline void vfp_load_reg32(TCGv_i32 var, int reg)
44
+ rc->phases.hold = zynqmp_efuse_reset_hold;
38
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
45
dc->realize = zynqmp_efuse_realize;
39
index XXXXXXX..XXXXXXX 100644
46
dc->vmsd = &vmstate_efuse;
40
--- a/target/arm/translate-vfp.c.inc
47
device_class_set_props(dc, zynqmp_efuse_props);
41
+++ b/target/arm/translate-vfp.c.inc
42
@@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a)
43
tcg_gen_ext_i32_i64(nf, cpu_NF);
44
tcg_gen_ext_i32_i64(vf, cpu_VF);
45
46
- neon_load_reg64(frn, rn);
47
- neon_load_reg64(frm, rm);
48
+ vfp_load_reg64(frn, rn);
49
+ vfp_load_reg64(frm, rm);
50
switch (a->cc) {
51
case 0: /* eq: Z */
52
tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero,
53
@@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a)
54
tcg_temp_free_i64(tmp);
55
break;
56
}
57
- neon_store_reg64(dest, rd);
58
+ vfp_store_reg64(dest, rd);
59
tcg_temp_free_i64(frn);
60
tcg_temp_free_i64(frm);
61
tcg_temp_free_i64(dest);
62
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a)
63
TCGv_i64 tcg_res;
64
tcg_op = tcg_temp_new_i64();
65
tcg_res = tcg_temp_new_i64();
66
- neon_load_reg64(tcg_op, rm);
67
+ vfp_load_reg64(tcg_op, rm);
68
gen_helper_rintd(tcg_res, tcg_op, fpst);
69
- neon_store_reg64(tcg_res, rd);
70
+ vfp_store_reg64(tcg_res, rd);
71
tcg_temp_free_i64(tcg_op);
72
tcg_temp_free_i64(tcg_res);
73
} else {
74
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a)
75
tcg_double = tcg_temp_new_i64();
76
tcg_res = tcg_temp_new_i64();
77
tcg_tmp = tcg_temp_new_i32();
78
- neon_load_reg64(tcg_double, rm);
79
+ vfp_load_reg64(tcg_double, rm);
80
if (is_signed) {
81
gen_helper_vfp_tosld(tcg_res, tcg_double, tcg_shift, fpst);
82
} else {
83
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a)
84
tmp = tcg_temp_new_i64();
85
if (a->l) {
86
gen_aa32_ld64(s, tmp, addr, get_mem_index(s));
87
- neon_store_reg64(tmp, a->vd);
88
+ vfp_store_reg64(tmp, a->vd);
89
} else {
90
- neon_load_reg64(tmp, a->vd);
91
+ vfp_load_reg64(tmp, a->vd);
92
gen_aa32_st64(s, tmp, addr, get_mem_index(s));
93
}
94
tcg_temp_free_i64(tmp);
95
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a)
96
if (a->l) {
97
/* load */
98
gen_aa32_ld64(s, tmp, addr, get_mem_index(s));
99
- neon_store_reg64(tmp, a->vd + i);
100
+ vfp_store_reg64(tmp, a->vd + i);
101
} else {
102
/* store */
103
- neon_load_reg64(tmp, a->vd + i);
104
+ vfp_load_reg64(tmp, a->vd + i);
105
gen_aa32_st64(s, tmp, addr, get_mem_index(s));
106
}
107
tcg_gen_addi_i32(addr, addr, offset);
108
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn,
109
fd = tcg_temp_new_i64();
110
fpst = fpstatus_ptr(FPST_FPCR);
111
112
- neon_load_reg64(f0, vn);
113
- neon_load_reg64(f1, vm);
114
+ vfp_load_reg64(f0, vn);
115
+ vfp_load_reg64(f1, vm);
116
117
for (;;) {
118
if (reads_vd) {
119
- neon_load_reg64(fd, vd);
120
+ vfp_load_reg64(fd, vd);
121
}
122
fn(fd, f0, f1, fpst);
123
- neon_store_reg64(fd, vd);
124
+ vfp_store_reg64(fd, vd);
125
126
if (veclen == 0) {
127
break;
128
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn,
129
veclen--;
130
vd = vfp_advance_dreg(vd, delta_d);
131
vn = vfp_advance_dreg(vn, delta_d);
132
- neon_load_reg64(f0, vn);
133
+ vfp_load_reg64(f0, vn);
134
if (delta_m) {
135
vm = vfp_advance_dreg(vm, delta_m);
136
- neon_load_reg64(f1, vm);
137
+ vfp_load_reg64(f1, vm);
138
}
139
}
140
141
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm)
142
f0 = tcg_temp_new_i64();
143
fd = tcg_temp_new_i64();
144
145
- neon_load_reg64(f0, vm);
146
+ vfp_load_reg64(f0, vm);
147
148
for (;;) {
149
fn(fd, f0);
150
- neon_store_reg64(fd, vd);
151
+ vfp_store_reg64(fd, vd);
152
153
if (veclen == 0) {
154
break;
155
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm)
156
/* single source one-many */
157
while (veclen--) {
158
vd = vfp_advance_dreg(vd, delta_d);
159
- neon_store_reg64(fd, vd);
160
+ vfp_store_reg64(fd, vd);
161
}
162
break;
163
}
164
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm)
165
veclen--;
166
vd = vfp_advance_dreg(vd, delta_d);
167
vd = vfp_advance_dreg(vm, delta_m);
168
- neon_load_reg64(f0, vm);
169
+ vfp_load_reg64(f0, vm);
170
}
171
172
tcg_temp_free_i64(f0);
173
@@ -XXX,XX +XXX,XX @@ static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d)
174
vm = tcg_temp_new_i64();
175
vd = tcg_temp_new_i64();
176
177
- neon_load_reg64(vn, a->vn);
178
- neon_load_reg64(vm, a->vm);
179
+ vfp_load_reg64(vn, a->vn);
180
+ vfp_load_reg64(vm, a->vm);
181
if (neg_n) {
182
/* VFNMS, VFMS */
183
gen_helper_vfp_negd(vn, vn);
184
}
185
- neon_load_reg64(vd, a->vd);
186
+ vfp_load_reg64(vd, a->vd);
187
if (neg_d) {
188
/* VFNMA, VFNMS */
189
gen_helper_vfp_negd(vd, vd);
190
}
191
fpst = fpstatus_ptr(FPST_FPCR);
192
gen_helper_vfp_muladdd(vd, vn, vm, vd, fpst);
193
- neon_store_reg64(vd, a->vd);
194
+ vfp_store_reg64(vd, a->vd);
195
196
tcg_temp_free_ptr(fpst);
197
tcg_temp_free_i64(vn);
198
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a)
199
fd = tcg_const_i64(vfp_expand_imm(MO_64, a->imm));
200
201
for (;;) {
202
- neon_store_reg64(fd, vd);
203
+ vfp_store_reg64(fd, vd);
204
205
if (veclen == 0) {
206
break;
207
@@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a)
208
vd = tcg_temp_new_i64();
209
vm = tcg_temp_new_i64();
210
211
- neon_load_reg64(vd, a->vd);
212
+ vfp_load_reg64(vd, a->vd);
213
if (a->z) {
214
tcg_gen_movi_i64(vm, 0);
215
} else {
216
- neon_load_reg64(vm, a->vm);
217
+ vfp_load_reg64(vm, a->vm);
218
}
219
220
if (a->e) {
221
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a)
222
tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t));
223
vd = tcg_temp_new_i64();
224
gen_helper_vfp_fcvt_f16_to_f64(vd, tmp, fpst, ahp_mode);
225
- neon_store_reg64(vd, a->vd);
226
+ vfp_store_reg64(vd, a->vd);
227
tcg_temp_free_i32(ahp_mode);
228
tcg_temp_free_ptr(fpst);
229
tcg_temp_free_i32(tmp);
230
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a)
231
tmp = tcg_temp_new_i32();
232
vm = tcg_temp_new_i64();
233
234
- neon_load_reg64(vm, a->vm);
235
+ vfp_load_reg64(vm, a->vm);
236
gen_helper_vfp_fcvt_f64_to_f16(tmp, vm, fpst, ahp_mode);
237
tcg_temp_free_i64(vm);
238
tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t));
239
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a)
240
}
241
242
tmp = tcg_temp_new_i64();
243
- neon_load_reg64(tmp, a->vm);
244
+ vfp_load_reg64(tmp, a->vm);
245
fpst = fpstatus_ptr(FPST_FPCR);
246
gen_helper_rintd(tmp, tmp, fpst);
247
- neon_store_reg64(tmp, a->vd);
248
+ vfp_store_reg64(tmp, a->vd);
249
tcg_temp_free_ptr(fpst);
250
tcg_temp_free_i64(tmp);
251
return true;
252
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a)
253
}
254
255
tmp = tcg_temp_new_i64();
256
- neon_load_reg64(tmp, a->vm);
257
+ vfp_load_reg64(tmp, a->vm);
258
fpst = fpstatus_ptr(FPST_FPCR);
259
tcg_rmode = tcg_const_i32(float_round_to_zero);
260
gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
261
gen_helper_rintd(tmp, tmp, fpst);
262
gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
263
- neon_store_reg64(tmp, a->vd);
264
+ vfp_store_reg64(tmp, a->vd);
265
tcg_temp_free_ptr(fpst);
266
tcg_temp_free_i64(tmp);
267
tcg_temp_free_i32(tcg_rmode);
268
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a)
269
}
270
271
tmp = tcg_temp_new_i64();
272
- neon_load_reg64(tmp, a->vm);
273
+ vfp_load_reg64(tmp, a->vm);
274
fpst = fpstatus_ptr(FPST_FPCR);
275
gen_helper_rintd_exact(tmp, tmp, fpst);
276
- neon_store_reg64(tmp, a->vd);
277
+ vfp_store_reg64(tmp, a->vd);
278
tcg_temp_free_ptr(fpst);
279
tcg_temp_free_i64(tmp);
280
return true;
281
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a)
282
vd = tcg_temp_new_i64();
283
vfp_load_reg32(vm, a->vm);
284
gen_helper_vfp_fcvtds(vd, vm, cpu_env);
285
- neon_store_reg64(vd, a->vd);
286
+ vfp_store_reg64(vd, a->vd);
287
tcg_temp_free_i32(vm);
288
tcg_temp_free_i64(vd);
289
return true;
290
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a)
291
292
vd = tcg_temp_new_i32();
293
vm = tcg_temp_new_i64();
294
- neon_load_reg64(vm, a->vm);
295
+ vfp_load_reg64(vm, a->vm);
296
gen_helper_vfp_fcvtsd(vd, vm, cpu_env);
297
vfp_store_reg32(vd, a->vd);
298
tcg_temp_free_i32(vd);
299
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a)
300
/* u32 -> f64 */
301
gen_helper_vfp_uitod(vd, vm, fpst);
302
}
303
- neon_store_reg64(vd, a->vd);
304
+ vfp_store_reg64(vd, a->vd);
305
tcg_temp_free_i32(vm);
306
tcg_temp_free_i64(vd);
307
tcg_temp_free_ptr(fpst);
308
@@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a)
309
310
vm = tcg_temp_new_i64();
311
vd = tcg_temp_new_i32();
312
- neon_load_reg64(vm, a->vm);
313
+ vfp_load_reg64(vm, a->vm);
314
gen_helper_vjcvt(vd, vm, cpu_env);
315
vfp_store_reg32(vd, a->vd);
316
tcg_temp_free_i64(vm);
317
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a)
318
frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm);
319
320
vd = tcg_temp_new_i64();
321
- neon_load_reg64(vd, a->vd);
322
+ vfp_load_reg64(vd, a->vd);
323
324
fpst = fpstatus_ptr(FPST_FPCR);
325
shift = tcg_const_i32(frac_bits);
326
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a)
327
g_assert_not_reached();
328
}
329
330
- neon_store_reg64(vd, a->vd);
331
+ vfp_store_reg64(vd, a->vd);
332
tcg_temp_free_i64(vd);
333
tcg_temp_free_i32(shift);
334
tcg_temp_free_ptr(fpst);
335
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a)
336
fpst = fpstatus_ptr(FPST_FPCR);
337
vm = tcg_temp_new_i64();
338
vd = tcg_temp_new_i32();
339
- neon_load_reg64(vm, a->vm);
340
+ vfp_load_reg64(vm, a->vm);
341
342
if (a->s) {
343
if (a->rz) {
344
--
48
--
345
2.20.1
49
2.34.1
346
347
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
The only uses of this function are for loading VFP
3
This change implements the ResettableClass interface for the device.
4
single-precision values, and nothing to do with NEON.
5
4
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
7
Message-id: 20201030022618.785675-8-richard.henderson@linaro.org
6
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20231004055339.323833-1-tong.ho@amd.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
9
---
11
target/arm/translate.c | 4 +-
10
hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +++++---
12
target/arm/translate-vfp.c.inc | 184 ++++++++++++++++-----------------
11
1 file changed, 5 insertions(+), 3 deletions(-)
13
2 files changed, 94 insertions(+), 94 deletions(-)
14
12
15
diff --git a/target/arm/translate.c b/target/arm/translate.c
13
diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate.c
15
--- a/hw/nvram/xlnx-versal-efuse-ctrl.c
18
+++ b/target/arm/translate.c
16
+++ b/hw/nvram/xlnx-versal-efuse-ctrl.c
19
@@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg64(TCGv_i64 var, int reg)
17
@@ -XXX,XX +XXX,XX @@
20
tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg));
18
* QEMU model of the Versal eFuse controller
19
*
20
* Copyright (c) 2020 Xilinx Inc.
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
22
*
23
* Permission is hereby granted, free of charge, to any person obtaining a copy
24
* of this software and associated documentation files (the "Software"), to deal
25
@@ -XXX,XX +XXX,XX @@ static void efuse_ctrl_register_reset(RegisterInfo *reg)
26
register_reset(reg);
21
}
27
}
22
28
23
-static inline void neon_load_reg32(TCGv_i32 var, int reg)
29
-static void efuse_ctrl_reset(DeviceState *dev)
24
+static inline void vfp_load_reg32(TCGv_i32 var, int reg)
30
+static void efuse_ctrl_reset_hold(Object *obj)
25
{
31
{
26
tcg_gen_ld_i32(var, cpu_env, vfp_reg_offset(false, reg));
32
- XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(dev);
27
}
33
+ XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj);
28
34
unsigned int i;
29
-static inline void neon_store_reg32(TCGv_i32 var, int reg)
35
30
+static inline void vfp_store_reg32(TCGv_i32 var, int reg)
36
for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
37
@@ -XXX,XX +XXX,XX @@ static Property efuse_ctrl_props[] = {
38
static void efuse_ctrl_class_init(ObjectClass *klass, void *data)
31
{
39
{
32
tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg));
40
DeviceClass *dc = DEVICE_CLASS(klass);
33
}
41
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
34
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
42
35
index XXXXXXX..XXXXXXX 100644
43
- dc->reset = efuse_ctrl_reset;
36
--- a/target/arm/translate-vfp.c.inc
44
+ rc->phases.hold = efuse_ctrl_reset_hold;
37
+++ b/target/arm/translate-vfp.c.inc
45
dc->realize = efuse_ctrl_realize;
38
@@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a)
46
dc->vmsd = &vmstate_efuse_ctrl;
39
frn = tcg_temp_new_i32();
47
device_class_set_props(dc, efuse_ctrl_props);
40
frm = tcg_temp_new_i32();
41
dest = tcg_temp_new_i32();
42
- neon_load_reg32(frn, rn);
43
- neon_load_reg32(frm, rm);
44
+ vfp_load_reg32(frn, rn);
45
+ vfp_load_reg32(frm, rm);
46
switch (a->cc) {
47
case 0: /* eq: Z */
48
tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero,
49
@@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a)
50
if (sz == 1) {
51
tcg_gen_andi_i32(dest, dest, 0xffff);
52
}
53
- neon_store_reg32(dest, rd);
54
+ vfp_store_reg32(dest, rd);
55
tcg_temp_free_i32(frn);
56
tcg_temp_free_i32(frm);
57
tcg_temp_free_i32(dest);
58
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a)
59
TCGv_i32 tcg_res;
60
tcg_op = tcg_temp_new_i32();
61
tcg_res = tcg_temp_new_i32();
62
- neon_load_reg32(tcg_op, rm);
63
+ vfp_load_reg32(tcg_op, rm);
64
if (sz == 1) {
65
gen_helper_rinth(tcg_res, tcg_op, fpst);
66
} else {
67
gen_helper_rints(tcg_res, tcg_op, fpst);
68
}
69
- neon_store_reg32(tcg_res, rd);
70
+ vfp_store_reg32(tcg_res, rd);
71
tcg_temp_free_i32(tcg_op);
72
tcg_temp_free_i32(tcg_res);
73
}
74
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a)
75
gen_helper_vfp_tould(tcg_res, tcg_double, tcg_shift, fpst);
76
}
77
tcg_gen_extrl_i64_i32(tcg_tmp, tcg_res);
78
- neon_store_reg32(tcg_tmp, rd);
79
+ vfp_store_reg32(tcg_tmp, rd);
80
tcg_temp_free_i32(tcg_tmp);
81
tcg_temp_free_i64(tcg_res);
82
tcg_temp_free_i64(tcg_double);
83
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a)
84
TCGv_i32 tcg_single, tcg_res;
85
tcg_single = tcg_temp_new_i32();
86
tcg_res = tcg_temp_new_i32();
87
- neon_load_reg32(tcg_single, rm);
88
+ vfp_load_reg32(tcg_single, rm);
89
if (sz == 1) {
90
if (is_signed) {
91
gen_helper_vfp_toslh(tcg_res, tcg_single, tcg_shift, fpst);
92
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a)
93
gen_helper_vfp_touls(tcg_res, tcg_single, tcg_shift, fpst);
94
}
95
}
96
- neon_store_reg32(tcg_res, rd);
97
+ vfp_store_reg32(tcg_res, rd);
98
tcg_temp_free_i32(tcg_res);
99
tcg_temp_free_i32(tcg_single);
100
}
101
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_half(DisasContext *s, arg_VMOV_single *a)
102
if (a->l) {
103
/* VFP to general purpose register */
104
tmp = tcg_temp_new_i32();
105
- neon_load_reg32(tmp, a->vn);
106
+ vfp_load_reg32(tmp, a->vn);
107
tcg_gen_andi_i32(tmp, tmp, 0xffff);
108
store_reg(s, a->rt, tmp);
109
} else {
110
/* general purpose register to VFP */
111
tmp = load_reg(s, a->rt);
112
tcg_gen_andi_i32(tmp, tmp, 0xffff);
113
- neon_store_reg32(tmp, a->vn);
114
+ vfp_store_reg32(tmp, a->vn);
115
tcg_temp_free_i32(tmp);
116
}
117
118
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a)
119
if (a->l) {
120
/* VFP to general purpose register */
121
tmp = tcg_temp_new_i32();
122
- neon_load_reg32(tmp, a->vn);
123
+ vfp_load_reg32(tmp, a->vn);
124
if (a->rt == 15) {
125
/* Set the 4 flag bits in the CPSR. */
126
gen_set_nzcv(tmp);
127
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a)
128
} else {
129
/* general purpose register to VFP */
130
tmp = load_reg(s, a->rt);
131
- neon_store_reg32(tmp, a->vn);
132
+ vfp_store_reg32(tmp, a->vn);
133
tcg_temp_free_i32(tmp);
134
}
135
136
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_sp(DisasContext *s, arg_VMOV_64_sp *a)
137
if (a->op) {
138
/* fpreg to gpreg */
139
tmp = tcg_temp_new_i32();
140
- neon_load_reg32(tmp, a->vm);
141
+ vfp_load_reg32(tmp, a->vm);
142
store_reg(s, a->rt, tmp);
143
tmp = tcg_temp_new_i32();
144
- neon_load_reg32(tmp, a->vm + 1);
145
+ vfp_load_reg32(tmp, a->vm + 1);
146
store_reg(s, a->rt2, tmp);
147
} else {
148
/* gpreg to fpreg */
149
tmp = load_reg(s, a->rt);
150
- neon_store_reg32(tmp, a->vm);
151
+ vfp_store_reg32(tmp, a->vm);
152
tcg_temp_free_i32(tmp);
153
tmp = load_reg(s, a->rt2);
154
- neon_store_reg32(tmp, a->vm + 1);
155
+ vfp_store_reg32(tmp, a->vm + 1);
156
tcg_temp_free_i32(tmp);
157
}
158
159
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_dp *a)
160
if (a->op) {
161
/* fpreg to gpreg */
162
tmp = tcg_temp_new_i32();
163
- neon_load_reg32(tmp, a->vm * 2);
164
+ vfp_load_reg32(tmp, a->vm * 2);
165
store_reg(s, a->rt, tmp);
166
tmp = tcg_temp_new_i32();
167
- neon_load_reg32(tmp, a->vm * 2 + 1);
168
+ vfp_load_reg32(tmp, a->vm * 2 + 1);
169
store_reg(s, a->rt2, tmp);
170
} else {
171
/* gpreg to fpreg */
172
tmp = load_reg(s, a->rt);
173
- neon_store_reg32(tmp, a->vm * 2);
174
+ vfp_store_reg32(tmp, a->vm * 2);
175
tcg_temp_free_i32(tmp);
176
tmp = load_reg(s, a->rt2);
177
- neon_store_reg32(tmp, a->vm * 2 + 1);
178
+ vfp_store_reg32(tmp, a->vm * 2 + 1);
179
tcg_temp_free_i32(tmp);
180
}
181
182
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_hp(DisasContext *s, arg_VLDR_VSTR_sp *a)
183
tmp = tcg_temp_new_i32();
184
if (a->l) {
185
gen_aa32_ld16u(s, tmp, addr, get_mem_index(s));
186
- neon_store_reg32(tmp, a->vd);
187
+ vfp_store_reg32(tmp, a->vd);
188
} else {
189
- neon_load_reg32(tmp, a->vd);
190
+ vfp_load_reg32(tmp, a->vd);
191
gen_aa32_st16(s, tmp, addr, get_mem_index(s));
192
}
193
tcg_temp_free_i32(tmp);
194
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a)
195
tmp = tcg_temp_new_i32();
196
if (a->l) {
197
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
198
- neon_store_reg32(tmp, a->vd);
199
+ vfp_store_reg32(tmp, a->vd);
200
} else {
201
- neon_load_reg32(tmp, a->vd);
202
+ vfp_load_reg32(tmp, a->vd);
203
gen_aa32_st32(s, tmp, addr, get_mem_index(s));
204
}
205
tcg_temp_free_i32(tmp);
206
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a)
207
if (a->l) {
208
/* load */
209
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
210
- neon_store_reg32(tmp, a->vd + i);
211
+ vfp_store_reg32(tmp, a->vd + i);
212
} else {
213
/* store */
214
- neon_load_reg32(tmp, a->vd + i);
215
+ vfp_load_reg32(tmp, a->vd + i);
216
gen_aa32_st32(s, tmp, addr, get_mem_index(s));
217
}
218
tcg_gen_addi_i32(addr, addr, offset);
219
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn,
220
fd = tcg_temp_new_i32();
221
fpst = fpstatus_ptr(FPST_FPCR);
222
223
- neon_load_reg32(f0, vn);
224
- neon_load_reg32(f1, vm);
225
+ vfp_load_reg32(f0, vn);
226
+ vfp_load_reg32(f1, vm);
227
228
for (;;) {
229
if (reads_vd) {
230
- neon_load_reg32(fd, vd);
231
+ vfp_load_reg32(fd, vd);
232
}
233
fn(fd, f0, f1, fpst);
234
- neon_store_reg32(fd, vd);
235
+ vfp_store_reg32(fd, vd);
236
237
if (veclen == 0) {
238
break;
239
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn,
240
veclen--;
241
vd = vfp_advance_sreg(vd, delta_d);
242
vn = vfp_advance_sreg(vn, delta_d);
243
- neon_load_reg32(f0, vn);
244
+ vfp_load_reg32(f0, vn);
245
if (delta_m) {
246
vm = vfp_advance_sreg(vm, delta_m);
247
- neon_load_reg32(f1, vm);
248
+ vfp_load_reg32(f1, vm);
249
}
250
}
251
252
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_hp(DisasContext *s, VFPGen3OpSPFn *fn,
253
fd = tcg_temp_new_i32();
254
fpst = fpstatus_ptr(FPST_FPCR_F16);
255
256
- neon_load_reg32(f0, vn);
257
- neon_load_reg32(f1, vm);
258
+ vfp_load_reg32(f0, vn);
259
+ vfp_load_reg32(f1, vm);
260
261
if (reads_vd) {
262
- neon_load_reg32(fd, vd);
263
+ vfp_load_reg32(fd, vd);
264
}
265
fn(fd, f0, f1, fpst);
266
- neon_store_reg32(fd, vd);
267
+ vfp_store_reg32(fd, vd);
268
269
tcg_temp_free_i32(f0);
270
tcg_temp_free_i32(f1);
271
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)
272
f0 = tcg_temp_new_i32();
273
fd = tcg_temp_new_i32();
274
275
- neon_load_reg32(f0, vm);
276
+ vfp_load_reg32(f0, vm);
277
278
for (;;) {
279
fn(fd, f0);
280
- neon_store_reg32(fd, vd);
281
+ vfp_store_reg32(fd, vd);
282
283
if (veclen == 0) {
284
break;
285
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)
286
/* single source one-many */
287
while (veclen--) {
288
vd = vfp_advance_sreg(vd, delta_d);
289
- neon_store_reg32(fd, vd);
290
+ vfp_store_reg32(fd, vd);
291
}
292
break;
293
}
294
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)
295
veclen--;
296
vd = vfp_advance_sreg(vd, delta_d);
297
vm = vfp_advance_sreg(vm, delta_m);
298
- neon_load_reg32(f0, vm);
299
+ vfp_load_reg32(f0, vm);
300
}
301
302
tcg_temp_free_i32(f0);
303
@@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_hp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)
304
}
305
306
f0 = tcg_temp_new_i32();
307
- neon_load_reg32(f0, vm);
308
+ vfp_load_reg32(f0, vm);
309
fn(f0, f0);
310
- neon_store_reg32(f0, vd);
311
+ vfp_store_reg32(f0, vd);
312
tcg_temp_free_i32(f0);
313
314
return true;
315
@@ -XXX,XX +XXX,XX @@ static bool do_vfm_hp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d)
316
vm = tcg_temp_new_i32();
317
vd = tcg_temp_new_i32();
318
319
- neon_load_reg32(vn, a->vn);
320
- neon_load_reg32(vm, a->vm);
321
+ vfp_load_reg32(vn, a->vn);
322
+ vfp_load_reg32(vm, a->vm);
323
if (neg_n) {
324
/* VFNMS, VFMS */
325
gen_helper_vfp_negh(vn, vn);
326
}
327
- neon_load_reg32(vd, a->vd);
328
+ vfp_load_reg32(vd, a->vd);
329
if (neg_d) {
330
/* VFNMA, VFNMS */
331
gen_helper_vfp_negh(vd, vd);
332
}
333
fpst = fpstatus_ptr(FPST_FPCR_F16);
334
gen_helper_vfp_muladdh(vd, vn, vm, vd, fpst);
335
- neon_store_reg32(vd, a->vd);
336
+ vfp_store_reg32(vd, a->vd);
337
338
tcg_temp_free_ptr(fpst);
339
tcg_temp_free_i32(vn);
340
@@ -XXX,XX +XXX,XX @@ static bool do_vfm_sp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d)
341
vm = tcg_temp_new_i32();
342
vd = tcg_temp_new_i32();
343
344
- neon_load_reg32(vn, a->vn);
345
- neon_load_reg32(vm, a->vm);
346
+ vfp_load_reg32(vn, a->vn);
347
+ vfp_load_reg32(vm, a->vm);
348
if (neg_n) {
349
/* VFNMS, VFMS */
350
gen_helper_vfp_negs(vn, vn);
351
}
352
- neon_load_reg32(vd, a->vd);
353
+ vfp_load_reg32(vd, a->vd);
354
if (neg_d) {
355
/* VFNMA, VFNMS */
356
gen_helper_vfp_negs(vd, vd);
357
}
358
fpst = fpstatus_ptr(FPST_FPCR);
359
gen_helper_vfp_muladds(vd, vn, vm, vd, fpst);
360
- neon_store_reg32(vd, a->vd);
361
+ vfp_store_reg32(vd, a->vd);
362
363
tcg_temp_free_ptr(fpst);
364
tcg_temp_free_i32(vn);
365
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_hp(DisasContext *s, arg_VMOV_imm_sp *a)
366
}
367
368
fd = tcg_const_i32(vfp_expand_imm(MO_16, a->imm));
369
- neon_store_reg32(fd, a->vd);
370
+ vfp_store_reg32(fd, a->vd);
371
tcg_temp_free_i32(fd);
372
return true;
373
}
374
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a)
375
fd = tcg_const_i32(vfp_expand_imm(MO_32, a->imm));
376
377
for (;;) {
378
- neon_store_reg32(fd, vd);
379
+ vfp_store_reg32(fd, vd);
380
381
if (veclen == 0) {
382
break;
383
@@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_hp(DisasContext *s, arg_VCMP_sp *a)
384
vd = tcg_temp_new_i32();
385
vm = tcg_temp_new_i32();
386
387
- neon_load_reg32(vd, a->vd);
388
+ vfp_load_reg32(vd, a->vd);
389
if (a->z) {
390
tcg_gen_movi_i32(vm, 0);
391
} else {
392
- neon_load_reg32(vm, a->vm);
393
+ vfp_load_reg32(vm, a->vm);
394
}
395
396
if (a->e) {
397
@@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_sp(DisasContext *s, arg_VCMP_sp *a)
398
vd = tcg_temp_new_i32();
399
vm = tcg_temp_new_i32();
400
401
- neon_load_reg32(vd, a->vd);
402
+ vfp_load_reg32(vd, a->vd);
403
if (a->z) {
404
tcg_gen_movi_i32(vm, 0);
405
} else {
406
- neon_load_reg32(vm, a->vm);
407
+ vfp_load_reg32(vm, a->vm);
408
}
409
410
if (a->e) {
411
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a)
412
/* The T bit tells us if we want the low or high 16 bits of Vm */
413
tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t));
414
gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp_mode);
415
- neon_store_reg32(tmp, a->vd);
416
+ vfp_store_reg32(tmp, a->vd);
417
tcg_temp_free_i32(ahp_mode);
418
tcg_temp_free_ptr(fpst);
419
tcg_temp_free_i32(tmp);
420
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a)
421
ahp_mode = get_ahp_flag();
422
tmp = tcg_temp_new_i32();
423
424
- neon_load_reg32(tmp, a->vm);
425
+ vfp_load_reg32(tmp, a->vm);
426
gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp_mode);
427
tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t));
428
tcg_temp_free_i32(ahp_mode);
429
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_hp(DisasContext *s, arg_VRINTR_sp *a)
430
}
431
432
tmp = tcg_temp_new_i32();
433
- neon_load_reg32(tmp, a->vm);
434
+ vfp_load_reg32(tmp, a->vm);
435
fpst = fpstatus_ptr(FPST_FPCR_F16);
436
gen_helper_rinth(tmp, tmp, fpst);
437
- neon_store_reg32(tmp, a->vd);
438
+ vfp_store_reg32(tmp, a->vd);
439
tcg_temp_free_ptr(fpst);
440
tcg_temp_free_i32(tmp);
441
return true;
442
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a)
443
}
444
445
tmp = tcg_temp_new_i32();
446
- neon_load_reg32(tmp, a->vm);
447
+ vfp_load_reg32(tmp, a->vm);
448
fpst = fpstatus_ptr(FPST_FPCR);
449
gen_helper_rints(tmp, tmp, fpst);
450
- neon_store_reg32(tmp, a->vd);
451
+ vfp_store_reg32(tmp, a->vd);
452
tcg_temp_free_ptr(fpst);
453
tcg_temp_free_i32(tmp);
454
return true;
455
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_hp(DisasContext *s, arg_VRINTZ_sp *a)
456
}
457
458
tmp = tcg_temp_new_i32();
459
- neon_load_reg32(tmp, a->vm);
460
+ vfp_load_reg32(tmp, a->vm);
461
fpst = fpstatus_ptr(FPST_FPCR_F16);
462
tcg_rmode = tcg_const_i32(float_round_to_zero);
463
gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
464
gen_helper_rinth(tmp, tmp, fpst);
465
gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
466
- neon_store_reg32(tmp, a->vd);
467
+ vfp_store_reg32(tmp, a->vd);
468
tcg_temp_free_ptr(fpst);
469
tcg_temp_free_i32(tcg_rmode);
470
tcg_temp_free_i32(tmp);
471
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a)
472
}
473
474
tmp = tcg_temp_new_i32();
475
- neon_load_reg32(tmp, a->vm);
476
+ vfp_load_reg32(tmp, a->vm);
477
fpst = fpstatus_ptr(FPST_FPCR);
478
tcg_rmode = tcg_const_i32(float_round_to_zero);
479
gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
480
gen_helper_rints(tmp, tmp, fpst);
481
gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
482
- neon_store_reg32(tmp, a->vd);
483
+ vfp_store_reg32(tmp, a->vd);
484
tcg_temp_free_ptr(fpst);
485
tcg_temp_free_i32(tcg_rmode);
486
tcg_temp_free_i32(tmp);
487
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_hp(DisasContext *s, arg_VRINTX_sp *a)
488
}
489
490
tmp = tcg_temp_new_i32();
491
- neon_load_reg32(tmp, a->vm);
492
+ vfp_load_reg32(tmp, a->vm);
493
fpst = fpstatus_ptr(FPST_FPCR_F16);
494
gen_helper_rinth_exact(tmp, tmp, fpst);
495
- neon_store_reg32(tmp, a->vd);
496
+ vfp_store_reg32(tmp, a->vd);
497
tcg_temp_free_ptr(fpst);
498
tcg_temp_free_i32(tmp);
499
return true;
500
@@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a)
501
}
502
503
tmp = tcg_temp_new_i32();
504
- neon_load_reg32(tmp, a->vm);
505
+ vfp_load_reg32(tmp, a->vm);
506
fpst = fpstatus_ptr(FPST_FPCR);
507
gen_helper_rints_exact(tmp, tmp, fpst);
508
- neon_store_reg32(tmp, a->vd);
509
+ vfp_store_reg32(tmp, a->vd);
510
tcg_temp_free_ptr(fpst);
511
tcg_temp_free_i32(tmp);
512
return true;
513
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a)
514
515
vm = tcg_temp_new_i32();
516
vd = tcg_temp_new_i64();
517
- neon_load_reg32(vm, a->vm);
518
+ vfp_load_reg32(vm, a->vm);
519
gen_helper_vfp_fcvtds(vd, vm, cpu_env);
520
neon_store_reg64(vd, a->vd);
521
tcg_temp_free_i32(vm);
522
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a)
523
vm = tcg_temp_new_i64();
524
neon_load_reg64(vm, a->vm);
525
gen_helper_vfp_fcvtsd(vd, vm, cpu_env);
526
- neon_store_reg32(vd, a->vd);
527
+ vfp_store_reg32(vd, a->vd);
528
tcg_temp_free_i32(vd);
529
tcg_temp_free_i64(vm);
530
return true;
531
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a)
532
}
533
534
vm = tcg_temp_new_i32();
535
- neon_load_reg32(vm, a->vm);
536
+ vfp_load_reg32(vm, a->vm);
537
fpst = fpstatus_ptr(FPST_FPCR_F16);
538
if (a->s) {
539
/* i32 -> f16 */
540
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a)
541
/* u32 -> f16 */
542
gen_helper_vfp_uitoh(vm, vm, fpst);
543
}
544
- neon_store_reg32(vm, a->vd);
545
+ vfp_store_reg32(vm, a->vd);
546
tcg_temp_free_i32(vm);
547
tcg_temp_free_ptr(fpst);
548
return true;
549
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a)
550
}
551
552
vm = tcg_temp_new_i32();
553
- neon_load_reg32(vm, a->vm);
554
+ vfp_load_reg32(vm, a->vm);
555
fpst = fpstatus_ptr(FPST_FPCR);
556
if (a->s) {
557
/* i32 -> f32 */
558
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a)
559
/* u32 -> f32 */
560
gen_helper_vfp_uitos(vm, vm, fpst);
561
}
562
- neon_store_reg32(vm, a->vd);
563
+ vfp_store_reg32(vm, a->vd);
564
tcg_temp_free_i32(vm);
565
tcg_temp_free_ptr(fpst);
566
return true;
567
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a)
568
569
vm = tcg_temp_new_i32();
570
vd = tcg_temp_new_i64();
571
- neon_load_reg32(vm, a->vm);
572
+ vfp_load_reg32(vm, a->vm);
573
fpst = fpstatus_ptr(FPST_FPCR);
574
if (a->s) {
575
/* i32 -> f64 */
576
@@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a)
577
vd = tcg_temp_new_i32();
578
neon_load_reg64(vm, a->vm);
579
gen_helper_vjcvt(vd, vm, cpu_env);
580
- neon_store_reg32(vd, a->vd);
581
+ vfp_store_reg32(vd, a->vd);
582
tcg_temp_free_i64(vm);
583
tcg_temp_free_i32(vd);
584
return true;
585
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a)
586
frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm);
587
588
vd = tcg_temp_new_i32();
589
- neon_load_reg32(vd, a->vd);
590
+ vfp_load_reg32(vd, a->vd);
591
592
fpst = fpstatus_ptr(FPST_FPCR_F16);
593
shift = tcg_const_i32(frac_bits);
594
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a)
595
g_assert_not_reached();
596
}
597
598
- neon_store_reg32(vd, a->vd);
599
+ vfp_store_reg32(vd, a->vd);
600
tcg_temp_free_i32(vd);
601
tcg_temp_free_i32(shift);
602
tcg_temp_free_ptr(fpst);
603
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a)
604
frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm);
605
606
vd = tcg_temp_new_i32();
607
- neon_load_reg32(vd, a->vd);
608
+ vfp_load_reg32(vd, a->vd);
609
610
fpst = fpstatus_ptr(FPST_FPCR);
611
shift = tcg_const_i32(frac_bits);
612
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a)
613
g_assert_not_reached();
614
}
615
616
- neon_store_reg32(vd, a->vd);
617
+ vfp_store_reg32(vd, a->vd);
618
tcg_temp_free_i32(vd);
619
tcg_temp_free_i32(shift);
620
tcg_temp_free_ptr(fpst);
621
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a)
622
623
fpst = fpstatus_ptr(FPST_FPCR_F16);
624
vm = tcg_temp_new_i32();
625
- neon_load_reg32(vm, a->vm);
626
+ vfp_load_reg32(vm, a->vm);
627
628
if (a->s) {
629
if (a->rz) {
630
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a)
631
gen_helper_vfp_touih(vm, vm, fpst);
632
}
633
}
634
- neon_store_reg32(vm, a->vd);
635
+ vfp_store_reg32(vm, a->vd);
636
tcg_temp_free_i32(vm);
637
tcg_temp_free_ptr(fpst);
638
return true;
639
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a)
640
641
fpst = fpstatus_ptr(FPST_FPCR);
642
vm = tcg_temp_new_i32();
643
- neon_load_reg32(vm, a->vm);
644
+ vfp_load_reg32(vm, a->vm);
645
646
if (a->s) {
647
if (a->rz) {
648
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a)
649
gen_helper_vfp_touis(vm, vm, fpst);
650
}
651
}
652
- neon_store_reg32(vm, a->vd);
653
+ vfp_store_reg32(vm, a->vd);
654
tcg_temp_free_i32(vm);
655
tcg_temp_free_ptr(fpst);
656
return true;
657
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a)
658
gen_helper_vfp_touid(vd, vm, fpst);
659
}
660
}
661
- neon_store_reg32(vd, a->vd);
662
+ vfp_store_reg32(vd, a->vd);
663
tcg_temp_free_i32(vd);
664
tcg_temp_free_i64(vm);
665
tcg_temp_free_ptr(fpst);
666
@@ -XXX,XX +XXX,XX @@ static bool trans_VINS(DisasContext *s, arg_VINS *a)
667
/* Insert low half of Vm into high half of Vd */
668
rm = tcg_temp_new_i32();
669
rd = tcg_temp_new_i32();
670
- neon_load_reg32(rm, a->vm);
671
- neon_load_reg32(rd, a->vd);
672
+ vfp_load_reg32(rm, a->vm);
673
+ vfp_load_reg32(rd, a->vd);
674
tcg_gen_deposit_i32(rd, rd, rm, 16, 16);
675
- neon_store_reg32(rd, a->vd);
676
+ vfp_store_reg32(rd, a->vd);
677
tcg_temp_free_i32(rm);
678
tcg_temp_free_i32(rd);
679
return true;
680
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOVX(DisasContext *s, arg_VINS *a)
681
682
/* Set Vd to high half of Vm */
683
rm = tcg_temp_new_i32();
684
- neon_load_reg32(rm, a->vm);
685
+ vfp_load_reg32(rm, a->vm);
686
tcg_gen_shri_i32(rm, rm, 16);
687
- neon_store_reg32(rm, a->vd);
688
+ vfp_store_reg32(rm, a->vd);
689
tcg_temp_free_i32(rm);
690
return true;
691
}
692
--
48
--
693
2.20.1
49
2.34.1
694
695
diff view generated by jsdifflib
1
Sphinx 3.2 is pickier than earlier versions about the option:: markup,
1
From: Tong Ho <tong.ho@amd.com>
2
and complains about our usage in qemu-option-trace.rst:
3
2
4
../../docs/qemu-option-trace.rst.inc:4:Malformed option description
3
This replaces the comma (,) to dot (.) in the device type name
5
'[enable=]PATTERN', should look like "opt", "-opt args", "--opt args",
4
so the name can be used with the 'driver=' command line option.
6
"/opt args" or "+opt args"
7
5
8
In this file, we're really trying to document the different parts of
6
Signed-off-by: Tong Ho <tong.ho@amd.com>
9
the top-level --trace option, which qemu-nbd.rst and qemu-img.rst
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
10
have already introduced with an option:: markup. So it's not right
8
Message-id: 20231003052139.199665-1-tong.ho@amd.com
11
to use option:: here anyway. Switch to a different markup
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
(definition lists) which gives about the same formatted output.
10
---
11
include/hw/nvram/xlnx-bbram.h | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
13
14
(Unlike option::, this markup doesn't produce index entries; but
14
diff --git a/include/hw/nvram/xlnx-bbram.h b/include/hw/nvram/xlnx-bbram.h
15
at the moment we don't do anything much with indexes anyway, and
16
in any case I think it doesn't make much sense to have individual
17
index entries for the sub-parts of the --trace option.)
18
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
21
Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
22
Message-id: 20201030174700.7204-3-peter.maydell@linaro.org
23
---
24
docs/qemu-option-trace.rst.inc | 6 +++---
25
1 file changed, 3 insertions(+), 3 deletions(-)
26
27
diff --git a/docs/qemu-option-trace.rst.inc b/docs/qemu-option-trace.rst.inc
28
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
29
--- a/docs/qemu-option-trace.rst.inc
16
--- a/include/hw/nvram/xlnx-bbram.h
30
+++ b/docs/qemu-option-trace.rst.inc
17
+++ b/include/hw/nvram/xlnx-bbram.h
31
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@
32
19
33
Specify tracing options.
20
#define RMAX_XLNX_BBRAM ((0x4c / 4) + 1)
34
21
35
-.. option:: [enable=]PATTERN
22
-#define TYPE_XLNX_BBRAM "xlnx,bbram-ctrl"
36
+``[enable=]PATTERN``
23
+#define TYPE_XLNX_BBRAM "xlnx.bbram-ctrl"
37
24
OBJECT_DECLARE_SIMPLE_TYPE(XlnxBBRam, XLNX_BBRAM);
38
Immediately enable events matching *PATTERN*
25
39
(either event name or a globbing pattern). This option is only
26
struct XlnxBBRam {
40
@@ -XXX,XX +XXX,XX @@ Specify tracing options.
41
42
Use :option:`-trace help` to print a list of names of trace points.
43
44
-.. option:: events=FILE
45
+``events=FILE``
46
47
Immediately enable events listed in *FILE*.
48
The file must contain one event name (as listed in the ``trace-events-all``
49
@@ -XXX,XX +XXX,XX @@ Specify tracing options.
50
available if QEMU has been compiled with the ``simple``, ``log`` or
51
``ftrace`` tracing backend.
52
53
-.. option:: file=FILE
54
+``file=FILE``
55
56
Log output traces to *FILE*.
57
This option is only available if QEMU has been compiled with
58
--
27
--
59
2.20.1
28
2.34.1
60
61
diff view generated by jsdifflib
1
If we're using the capstone disassembler, disassembly of a run of
1
From: Viktor Prutyanov <viktor@daynix.com>
2
instructions more than 32 bytes long disassembles the wrong data for
3
instructions beyond the 32 byte mark:
4
2
5
(qemu) xp /16x 0x100
3
String sign_rsds isn't terminated, so the print length must be limited.
6
0000000000000100: 0x00000005 0x54410001 0x00000001 0x00001000
7
0000000000000110: 0x00000000 0x00000004 0x54410002 0x3c000000
8
0000000000000120: 0x00000000 0x00000004 0x54410009 0x74736574
9
0000000000000130: 0x00000000 0x00000000 0x00000000 0x00000000
10
(qemu) xp /16i 0x100
11
0x00000100: 00000005 andeq r0, r0, r5
12
0x00000104: 54410001 strbpl r0, [r1], #-1
13
0x00000108: 00000001 andeq r0, r0, r1
14
0x0000010c: 00001000 andeq r1, r0, r0
15
0x00000110: 00000000 andeq r0, r0, r0
16
0x00000114: 00000004 andeq r0, r0, r4
17
0x00000118: 54410002 strbpl r0, [r1], #-2
18
0x0000011c: 3c000000 .byte 0x00, 0x00, 0x00, 0x3c
19
0x00000120: 54410001 strbpl r0, [r1], #-1
20
0x00000124: 00000001 andeq r0, r0, r1
21
0x00000128: 00001000 andeq r1, r0, r0
22
0x0000012c: 00000000 andeq r0, r0, r0
23
0x00000130: 00000004 andeq r0, r0, r4
24
0x00000134: 54410002 strbpl r0, [r1], #-2
25
0x00000138: 3c000000 .byte 0x00, 0x00, 0x00, 0x3c
26
0x0000013c: 00000000 andeq r0, r0, r0
27
4
28
Here the disassembly of 0x120..0x13f is using the data that is in
5
Fixes: Coverity CID 1521598
29
0x104..0x123.
6
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
30
7
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
31
This is caused by passing the wrong value to the read_memory_func().
8
Message-id: 20230930235317.11469-2-viktor@daynix.com
32
The intention is that at this point in the loop the 'cap_buf' buffer
33
already contains 'csize' bytes of data for the instruction at guest
34
addr 'pc', and we want to read in an extra 'tsize' bytes. Those
35
extra bytes are therefore at 'pc + csize', not 'pc'. On the first
36
time through the loop 'csize' happens to be zero, so the initial read
37
of 32 bytes into cap_buf is correct and as long as the disassembly
38
never needs to read more data we return the correct information.
39
40
Use the correct guest address in the call to read_memory_func().
41
42
Cc: qemu-stable@nongnu.org
43
Fixes: https://bugs.launchpad.net/qemu/+bug/1900779
44
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
45
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
46
Message-id: 20201022132445.25039-1-peter.maydell@linaro.org
47
---
10
---
48
disas/capstone.c | 2 +-
11
contrib/elf2dmp/main.c | 2 +-
49
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
50
13
51
diff --git a/disas/capstone.c b/disas/capstone.c
14
diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
52
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
53
--- a/disas/capstone.c
16
--- a/contrib/elf2dmp/main.c
54
+++ b/disas/capstone.c
17
+++ b/contrib/elf2dmp/main.c
55
@@ -XXX,XX +XXX,XX @@ bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count)
18
@@ -XXX,XX +XXX,XX @@ static bool pe_check_pdb_name(uint64_t base, void *start_addr,
56
19
}
57
/* Make certain that we can make progress. */
20
58
assert(tsize != 0);
21
if (memcmp(&rsds->Signature, sign_rsds, sizeof(sign_rsds))) {
59
- info->read_memory_func(pc, cap_buf + csize, tsize, info);
22
- eprintf("CodeView signature is \'%.4s\', \'%s\' expected\n",
60
+ info->read_memory_func(pc + csize, cap_buf + csize, tsize, info);
23
+ eprintf("CodeView signature is \'%.4s\', \'%.4s\' expected\n",
61
csize += tsize;
24
rsds->Signature, sign_rsds);
62
25
return false;
63
if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) {
26
}
64
--
27
--
65
2.20.1
28
2.34.1
66
67
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Viktor Prutyanov <viktor@daynix.com>
2
2
3
We can use proper widening loads to extend 32-bit inputs,
3
Index in file_size array must be checked against num_files, because the
4
and skip the "widenfn" step.
4
entries we are looking for may be absent in the PDB.
5
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Fixes: Coverity CID 1521597
7
Message-id: 20201030022618.785675-12-richard.henderson@linaro.org
7
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Message-id: 20230930235317.11469-3-viktor@daynix.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
target/arm/translate.c | 6 +++
13
contrib/elf2dmp/pdb.c | 13 +++++++++----
12
target/arm/translate-neon.c.inc | 66 ++++++++++++++++++---------------
14
1 file changed, 9 insertions(+), 4 deletions(-)
13
2 files changed, 43 insertions(+), 29 deletions(-)
14
15
15
diff --git a/target/arm/translate.c b/target/arm/translate.c
16
diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate.c
18
--- a/contrib/elf2dmp/pdb.c
18
+++ b/target/arm/translate.c
19
+++ b/contrib/elf2dmp/pdb.c
19
@@ -XXX,XX +XXX,XX @@ static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop)
20
@@ -XXX,XX +XXX,XX @@
20
long off = neon_element_offset(reg, ele, memop);
21
21
22
static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx)
22
switch (memop) {
23
+ case MO_SL:
24
+ tcg_gen_ld32s_i64(dest, cpu_env, off);
25
+ break;
26
+ case MO_UL:
27
+ tcg_gen_ld32u_i64(dest, cpu_env, off);
28
+ break;
29
case MO_Q:
30
tcg_gen_ld_i64(dest, cpu_env, off);
31
break;
32
diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/translate-neon.c.inc
35
+++ b/target/arm/translate-neon.c.inc
36
@@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1reg_imm *a)
37
static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
38
NeonGenWidenFn *widenfn,
39
NeonGenTwo64OpFn *opfn,
40
- bool src1_wide)
41
+ int src1_mop, int src2_mop)
42
{
23
{
43
/* 3-regs different lengths, prewidening case (VADDL/VSUBL/VAADW/VSUBW) */
24
+ if (idx >= r->ds.toc->num_files) {
44
TCGv_i64 rn0_64, rn1_64, rm_64;
25
+ return 0;
45
- TCGv_i32 rm;
26
+ }
46
27
+
47
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
28
return r->ds.toc->file_size[idx];
48
return false;
29
}
49
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
30
50
return false;
31
@@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read_file(struct pdb_reader* r, uint32_t file_number)
32
33
static int pdb_init_segments(struct pdb_reader *r)
34
{
35
- char *segs;
36
unsigned stream_idx = r->segments;
37
38
- segs = pdb_ds_read_file(r, stream_idx);
39
- if (!segs) {
40
+ r->segs = pdb_ds_read_file(r, stream_idx);
41
+ if (!r->segs) {
42
return 1;
51
}
43
}
52
44
53
- if (!widenfn || !opfn) {
45
- r->segs = segs;
54
+ if (!opfn) {
46
r->segs_size = pdb_get_file_size(r, stream_idx);
55
/* size == 3 case, which is an entirely different insn group */
47
+ if (!r->segs_size) {
56
return false;
48
+ return 1;
57
}
58
59
- if ((a->vd & 1) || (src1_wide && (a->vn & 1))) {
60
+ if ((a->vd & 1) || (src1_mop == MO_Q && (a->vn & 1))) {
61
return false;
62
}
63
64
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
65
rn1_64 = tcg_temp_new_i64();
66
rm_64 = tcg_temp_new_i64();
67
68
- if (src1_wide) {
69
- read_neon_element64(rn0_64, a->vn, 0, MO_64);
70
+ if (src1_mop >= 0) {
71
+ read_neon_element64(rn0_64, a->vn, 0, src1_mop);
72
} else {
73
TCGv_i32 tmp = tcg_temp_new_i32();
74
read_neon_element32(tmp, a->vn, 0, MO_32);
75
widenfn(rn0_64, tmp);
76
tcg_temp_free_i32(tmp);
77
}
78
- rm = tcg_temp_new_i32();
79
- read_neon_element32(rm, a->vm, 0, MO_32);
80
+ if (src2_mop >= 0) {
81
+ read_neon_element64(rm_64, a->vm, 0, src2_mop);
82
+ } else {
83
+ TCGv_i32 tmp = tcg_temp_new_i32();
84
+ read_neon_element32(tmp, a->vm, 0, MO_32);
85
+ widenfn(rm_64, tmp);
86
+ tcg_temp_free_i32(tmp);
87
+ }
49
+ }
88
50
89
- widenfn(rm_64, rm);
51
return 0;
90
- tcg_temp_free_i32(rm);
91
opfn(rn0_64, rn0_64, rm_64);
92
93
/*
94
* Load second pass inputs before storing the first pass result, to
95
* avoid incorrect results if a narrow input overlaps with the result.
96
*/
97
- if (src1_wide) {
98
- read_neon_element64(rn1_64, a->vn, 1, MO_64);
99
+ if (src1_mop >= 0) {
100
+ read_neon_element64(rn1_64, a->vn, 1, src1_mop);
101
} else {
102
TCGv_i32 tmp = tcg_temp_new_i32();
103
read_neon_element32(tmp, a->vn, 1, MO_32);
104
widenfn(rn1_64, tmp);
105
tcg_temp_free_i32(tmp);
106
}
107
- rm = tcg_temp_new_i32();
108
- read_neon_element32(rm, a->vm, 1, MO_32);
109
+ if (src2_mop >= 0) {
110
+ read_neon_element64(rm_64, a->vm, 1, src2_mop);
111
+ } else {
112
+ TCGv_i32 tmp = tcg_temp_new_i32();
113
+ read_neon_element32(tmp, a->vm, 1, MO_32);
114
+ widenfn(rm_64, tmp);
115
+ tcg_temp_free_i32(tmp);
116
+ }
117
118
write_neon_element64(rn0_64, a->vd, 0, MO_64);
119
120
- widenfn(rm_64, rm);
121
- tcg_temp_free_i32(rm);
122
opfn(rn1_64, rn1_64, rm_64);
123
write_neon_element64(rn1_64, a->vd, 1, MO_64);
124
125
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
126
return true;
127
}
52
}
128
129
-#define DO_PREWIDEN(INSN, S, EXT, OP, SRC1WIDE) \
130
+#define DO_PREWIDEN(INSN, S, OP, SRC1WIDE, SIGN) \
131
static bool trans_##INSN##_3d(DisasContext *s, arg_3diff *a) \
132
{ \
133
static NeonGenWidenFn * const widenfn[] = { \
134
gen_helper_neon_widen_##S##8, \
135
gen_helper_neon_widen_##S##16, \
136
- tcg_gen_##EXT##_i32_i64, \
137
- NULL, \
138
+ NULL, NULL, \
139
}; \
140
static NeonGenTwo64OpFn * const addfn[] = { \
141
gen_helper_neon_##OP##l_u16, \
142
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
143
tcg_gen_##OP##_i64, \
144
NULL, \
145
}; \
146
- return do_prewiden_3d(s, a, widenfn[a->size], \
147
- addfn[a->size], SRC1WIDE); \
148
+ int narrow_mop = a->size == MO_32 ? MO_32 | SIGN : -1; \
149
+ return do_prewiden_3d(s, a, widenfn[a->size], addfn[a->size], \
150
+ SRC1WIDE ? MO_Q : narrow_mop, \
151
+ narrow_mop); \
152
}
153
154
-DO_PREWIDEN(VADDL_S, s, ext, add, false)
155
-DO_PREWIDEN(VADDL_U, u, extu, add, false)
156
-DO_PREWIDEN(VSUBL_S, s, ext, sub, false)
157
-DO_PREWIDEN(VSUBL_U, u, extu, sub, false)
158
-DO_PREWIDEN(VADDW_S, s, ext, add, true)
159
-DO_PREWIDEN(VADDW_U, u, extu, add, true)
160
-DO_PREWIDEN(VSUBW_S, s, ext, sub, true)
161
-DO_PREWIDEN(VSUBW_U, u, extu, sub, true)
162
+DO_PREWIDEN(VADDL_S, s, add, false, MO_SIGN)
163
+DO_PREWIDEN(VADDL_U, u, add, false, 0)
164
+DO_PREWIDEN(VSUBL_S, s, sub, false, MO_SIGN)
165
+DO_PREWIDEN(VSUBL_U, u, sub, false, 0)
166
+DO_PREWIDEN(VADDW_S, s, add, true, MO_SIGN)
167
+DO_PREWIDEN(VADDW_U, u, add, true, 0)
168
+DO_PREWIDEN(VSUBW_S, s, sub, true, MO_SIGN)
169
+DO_PREWIDEN(VSUBW_U, u, sub, true, 0)
170
171
static bool do_narrow_3d(DisasContext *s, arg_3diff *a,
172
NeonGenTwo64OpFn *opfn, NeonGenNarrowFn *narrowfn)
173
--
53
--
174
2.20.1
54
2.34.1
175
55
176
56
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Michal Orzel <michal.orzel@amd.com>
2
2
3
Secure mode is not exempted from checking SCR_EL3.TLOR, and in the
3
On an attempt to access CNTPCT_EL0 from EL0 using a guest running on top
4
future HCR_EL2.TLOR when S-EL2 is enabled.
4
of Xen, a trap from EL2 was observed which is something not reproducible
5
on HW (also, Xen does not trap accesses to physical counter).
5
6
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
7
This is because gt_counter_access() checks for an incorrect bit (1
8
instead of 0) of CNTHCTL_EL2 if HCR_EL2.E2H is 0 and access is made to
9
physical counter. Refer ARM ARM DDI 0487J.a, D19.12.2:
10
When HCR_EL2.E2H is 0:
11
- EL1PCTEN, bit [0]: refers to physical counter
12
- EL1PCEN, bit [1]: refers to physical timer registers
13
14
Drop entire block "if (hcr & HCR_E2H) {...} else {...}" from EL0 case
15
and fall through to EL1 case, given that after fixing checking for the
16
correct bit, the handling is the same.
17
18
Fixes: 5bc8437136fb ("target/arm: Update timer access for VHE")
19
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
20
Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
21
Message-id: 20230928094404.20802-1-michal.orzel@amd.com
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
22
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
24
---
10
target/arm/helper.c | 19 +++++--------------
25
target/arm/helper.c | 17 +----------------
11
1 file changed, 5 insertions(+), 14 deletions(-)
26
1 file changed, 1 insertion(+), 16 deletions(-)
12
27
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
30
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
31
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri)
32
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
18
#endif
33
if (!extract32(env->cp15.c14_cntkctl, timeridx, 1)) {
19
34
return CP_ACCESS_TRAP;
20
/* Shared logic between LORID and the rest of the LOR* registers.
35
}
21
- * Secure state has already been delt with.
22
+ * Secure state exclusion has already been dealt with.
23
*/
24
-static CPAccessResult access_lor_ns(CPUARMState *env)
25
+static CPAccessResult access_lor_ns(CPUARMState *env,
26
+ const ARMCPRegInfo *ri, bool isread)
27
{
28
int el = arm_current_el(env);
29
30
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_ns(CPUARMState *env)
31
return CP_ACCESS_OK;
32
}
33
34
-static CPAccessResult access_lorid(CPUARMState *env, const ARMCPRegInfo *ri,
35
- bool isread)
36
-{
37
- if (arm_is_secure_below_el3(env)) {
38
- /* Access ok in secure mode. */
39
- return CP_ACCESS_OK;
40
- }
41
- return access_lor_ns(env);
42
-}
43
-
36
-
44
static CPAccessResult access_lor_other(CPUARMState *env,
37
- /* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PCTEN. */
45
const ARMCPRegInfo *ri, bool isread)
38
- if (hcr & HCR_E2H) {
46
{
39
- if (timeridx == GTIMER_PHYS &&
47
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_other(CPUARMState *env,
40
- !extract32(env->cp15.cnthctl_el2, 10, 1)) {
48
/* Access denied in secure mode. */
41
- return CP_ACCESS_TRAP_EL2;
49
return CP_ACCESS_TRAP;
42
- }
50
}
43
- } else {
51
- return access_lor_ns(env);
44
- /* If HCR_EL2.<E2H> == 0: check CNTHCTL_EL2.EL1PCEN. */
52
+ return access_lor_ns(env, ri, isread);
45
- if (has_el2 && timeridx == GTIMER_PHYS &&
53
}
46
- !extract32(env->cp15.cnthctl_el2, 1, 1)) {
54
47
- return CP_ACCESS_TRAP_EL2;
55
/*
48
- }
56
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = {
49
- }
57
.type = ARM_CP_CONST, .resetvalue = 0 },
50
- break;
58
{ .name = "LORID_EL1", .state = ARM_CP_STATE_AA64,
51
-
59
.opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7,
52
+ /* fall through */
60
- .access = PL1_R, .accessfn = access_lorid,
53
case 1:
61
+ .access = PL1_R, .accessfn = access_lor_ns,
54
/* Check CNTHCTL_EL2.EL1PCTEN, which changes location based on E2H. */
62
.type = ARM_CP_CONST, .resetvalue = 0 },
55
if (has_el2 && timeridx == GTIMER_PHYS &&
63
REGINFO_SENTINEL
64
};
65
--
56
--
66
2.20.1
57
2.34.1
67
68
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
This will shortly have users outside of translate-neon.c.inc.
3
GIC Private Peripheral Interrupts (PPI) are defined as GIC INTID 16-31.
4
As in, PPI0 is INTID16 .. PPI15 is INTID31.
5
Arm's Base System Architecture specification (BSA) lists the mandated and
6
recommended private interrupt IDs by INTID, not by PPI index. But current
7
definitions in virt define them by PPI index, complicating cross
8
referencing.
4
9
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Meanwhile, the PPI(x) macro counterintuitively adds 16 to the input value,
6
Message-id: 20201030022618.785675-3-richard.henderson@linaro.org
11
converting a PPI index to an INTID.
12
13
Resolve this by redefining the BSA-allocated PPIs by their INTIDs,
14
and replacing the PPI(x) macro with an INTID_TO_PPI(x) one where required.
15
16
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
17
Message-id: 20230919090229.188092-2-quic_llindhol@quicinc.com
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
20
---
10
target/arm/translate.c | 20 ++++++++++++++++++++
21
include/hw/arm/virt.h | 14 +++++++-------
11
target/arm/translate-neon.c.inc | 19 -------------------
22
hw/arm/virt-acpi-build.c | 12 ++++++------
12
2 files changed, 20 insertions(+), 19 deletions(-)
23
hw/arm/virt.c | 24 ++++++++++++++----------
24
3 files changed, 27 insertions(+), 23 deletions(-)
13
25
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
26
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
15
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.c
28
--- a/include/hw/arm/virt.h
17
+++ b/target/arm/translate.c
29
+++ b/include/hw/arm/virt.h
18
@@ -XXX,XX +XXX,XX @@ static long neon_full_reg_offset(unsigned reg)
30
@@ -XXX,XX +XXX,XX @@
19
return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]);
31
#define NUM_VIRTIO_TRANSPORTS 32
32
#define NUM_SMMU_IRQS 4
33
34
-#define ARCH_GIC_MAINT_IRQ 9
35
+#define ARCH_GIC_MAINT_IRQ 25
36
37
-#define ARCH_TIMER_VIRT_IRQ 11
38
-#define ARCH_TIMER_S_EL1_IRQ 13
39
-#define ARCH_TIMER_NS_EL1_IRQ 14
40
-#define ARCH_TIMER_NS_EL2_IRQ 10
41
+#define ARCH_TIMER_VIRT_IRQ 27
42
+#define ARCH_TIMER_S_EL1_IRQ 29
43
+#define ARCH_TIMER_NS_EL1_IRQ 30
44
+#define ARCH_TIMER_NS_EL2_IRQ 26
45
46
-#define VIRTUAL_PMU_IRQ 7
47
+#define VIRTUAL_PMU_IRQ 23
48
49
-#define PPI(irq) ((irq) + 16)
50
+#define INTID_TO_PPI(irq) ((irq) - 16)
51
52
/* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */
53
#define PVTIME_SIZE_PER_CPU 64
54
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/arm/virt-acpi-build.c
57
+++ b/hw/arm/virt-acpi-build.c
58
@@ -XXX,XX +XXX,XX @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
59
* The interrupt values are the same with the device tree when adding 16
60
*/
61
/* Secure EL1 timer GSIV */
62
- build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ + 16, 4);
63
+ build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ, 4);
64
/* Secure EL1 timer Flags */
65
build_append_int_noprefix(table_data, irqflags, 4);
66
/* Non-Secure EL1 timer GSIV */
67
- build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ + 16, 4);
68
+ build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ, 4);
69
/* Non-Secure EL1 timer Flags */
70
build_append_int_noprefix(table_data, irqflags |
71
1UL << 2, /* Always-on Capability */
72
4);
73
/* Virtual timer GSIV */
74
- build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ + 16, 4);
75
+ build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ, 4);
76
/* Virtual Timer Flags */
77
build_append_int_noprefix(table_data, irqflags, 4);
78
/* Non-Secure EL2 timer GSIV */
79
- build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ + 16, 4);
80
+ build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ, 4);
81
/* Non-Secure EL2 timer Flags */
82
build_append_int_noprefix(table_data, irqflags, 4);
83
/* CntReadBase Physical address */
84
@@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
85
for (i = 0; i < MACHINE(vms)->smp.cpus; i++) {
86
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
87
uint64_t physical_base_address = 0, gich = 0, gicv = 0;
88
- uint32_t vgic_interrupt = vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : 0;
89
+ uint32_t vgic_interrupt = vms->virt ? ARCH_GIC_MAINT_IRQ : 0;
90
uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ?
91
- PPI(VIRTUAL_PMU_IRQ) : 0;
92
+ VIRTUAL_PMU_IRQ : 0;
93
94
if (vms->gic_version == VIRT_GIC_VERSION_2) {
95
physical_base_address = memmap[VIRT_GIC_CPU].base;
96
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
97
index XXXXXXX..XXXXXXX 100644
98
--- a/hw/arm/virt.c
99
+++ b/hw/arm/virt.c
100
@@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms)
101
}
102
qemu_fdt_setprop(ms->fdt, "/timer", "always-on", NULL, 0);
103
qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts",
104
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_S_EL1_IRQ, irqflags,
105
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL1_IRQ, irqflags,
106
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_VIRT_IRQ, irqflags,
107
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL2_IRQ, irqflags);
108
+ GIC_FDT_IRQ_TYPE_PPI,
109
+ INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags,
110
+ GIC_FDT_IRQ_TYPE_PPI,
111
+ INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags,
112
+ GIC_FDT_IRQ_TYPE_PPI,
113
+ INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags,
114
+ GIC_FDT_IRQ_TYPE_PPI,
115
+ INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags);
20
}
116
}
21
117
22
+/*
118
static void fdt_add_cpu_nodes(const VirtMachineState *vms)
23
+ * Return the offset of a 2**SIZE piece of a NEON register, at index ELE,
119
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
24
+ * where 0 is the least significant end of the register.
120
*/
25
+ */
121
for (i = 0; i < smp_cpus; i++) {
26
+static long neon_element_offset(int reg, int element, MemOp size)
122
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
27
+{
123
- int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
28
+ int element_size = 1 << size;
124
+ int intidbase = NUM_IRQS + i * GIC_INTERNAL;
29
+ int ofs = element * element_size;
125
/* Mapping from the output timer irq lines from the CPU to the
30
+#ifdef HOST_WORDS_BIGENDIAN
126
* GIC PPI inputs we use for the virt board.
31
+ /*
127
*/
32
+ * Calculate the offset assuming fully little-endian,
128
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
33
+ * then XOR to account for the order of the 8-byte units.
129
for (unsigned irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
34
+ */
130
qdev_connect_gpio_out(cpudev, irq,
35
+ if (element_size < 8) {
131
qdev_get_gpio_in(vms->gic,
36
+ ofs ^= 8 - element_size;
132
- ppibase + timer_irq[irq]));
37
+ }
133
+ intidbase + timer_irq[irq]));
38
+#endif
134
}
39
+ return neon_full_reg_offset(reg) + ofs;
135
40
+}
136
if (vms->gic_version != VIRT_GIC_VERSION_2) {
41
+
137
qemu_irq irq = qdev_get_gpio_in(vms->gic,
42
static inline long vfp_reg_offset(bool dp, unsigned reg)
138
- ppibase + ARCH_GIC_MAINT_IRQ);
43
{
139
+ intidbase + ARCH_GIC_MAINT_IRQ);
44
if (dp) {
140
qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt",
45
diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc
141
0, irq);
46
index XXXXXXX..XXXXXXX 100644
142
} else if (vms->virt) {
47
--- a/target/arm/translate-neon.c.inc
143
qemu_irq irq = qdev_get_gpio_in(vms->gic,
48
+++ b/target/arm/translate-neon.c.inc
144
- ppibase + ARCH_GIC_MAINT_IRQ);
49
@@ -XXX,XX +XXX,XX @@ static inline int neon_3same_fp_size(DisasContext *s, int x)
145
+ intidbase + ARCH_GIC_MAINT_IRQ);
50
#include "decode-neon-ls.c.inc"
146
sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq);
51
#include "decode-neon-shared.c.inc"
147
}
52
148
53
-/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE,
149
qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
54
- * where 0 is the least significant end of the register.
150
- qdev_get_gpio_in(vms->gic, ppibase
55
- */
151
+ qdev_get_gpio_in(vms->gic, intidbase
56
-static inline long
152
+ VIRTUAL_PMU_IRQ));
57
-neon_element_offset(int reg, int element, MemOp size)
153
58
-{
154
sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
59
- int element_size = 1 << size;
155
@@ -XXX,XX +XXX,XX @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)
60
- int ofs = element * element_size;
156
if (pmu) {
61
-#ifdef HOST_WORDS_BIGENDIAN
157
assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU));
62
- /* Calculate the offset assuming fully little-endian,
158
if (kvm_irqchip_in_kernel()) {
63
- * then XOR to account for the order of the 8-byte units.
159
- kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ));
64
- */
160
+ kvm_arm_pmu_set_irq(cpu, VIRTUAL_PMU_IRQ);
65
- if (element_size < 8) {
161
}
66
- ofs ^= 8 - element_size;
162
kvm_arm_pmu_init(cpu);
67
- }
163
}
68
-#endif
69
- return neon_full_reg_offset(reg) + ofs;
70
-}
71
-
72
static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop)
73
{
74
long offset = neon_element_offset(reg, ele, mop & MO_SIZE);
75
--
164
--
76
2.20.1
165
2.34.1
77
78
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
This seems a bit more readable than using offsetof CPU_DoubleU.
3
virt.h defines a number of IRQs that are ultimately described by Arm's
4
Base System Architecture specification. Move these to a dedicated header
5
so that they can be reused by other platforms that do the same.
6
Include that header from virt.h to minimise churn.
4
7
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
While we're moving the definitions, sort them into numerical order,
6
Message-id: 20201030022618.785675-5-richard.henderson@linaro.org
9
and add the ARCH_TIMER_NS_EL2_VIRT_IRQ definition used by sbsa-ref
10
and which will eventually be needed by virt also.
11
12
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
13
Message-id: 20230919090229.188092-3-quic_llindhol@quicinc.com
14
[PMM: Remove unused PPI_TO_INTID macro; sort numerically;
15
add ARCH_TIMER_NS_EL2_VIRT_IRQ]
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
18
---
10
target/arm/translate.c | 13 ++++---------
19
include/hw/arm/bsa.h | 35 +++++++++++++++++++++++++++++++++++
11
1 file changed, 4 insertions(+), 9 deletions(-)
20
include/hw/arm/virt.h | 12 +-----------
21
2 files changed, 36 insertions(+), 11 deletions(-)
22
create mode 100644 include/hw/arm/bsa.h
12
23
13
diff --git a/target/arm/translate.c b/target/arm/translate.c
24
diff --git a/include/hw/arm/bsa.h b/include/hw/arm/bsa.h
25
new file mode 100644
26
index XXXXXXX..XXXXXXX
27
--- /dev/null
28
+++ b/include/hw/arm/bsa.h
29
@@ -XXX,XX +XXX,XX @@
30
+/*
31
+ * Common definitions for Arm Base System Architecture (BSA) platforms.
32
+ *
33
+ * Copyright (c) 2015 Linaro Limited
34
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
35
+ *
36
+ * This program is free software; you can redistribute it and/or modify it
37
+ * under the terms and conditions of the GNU General Public License,
38
+ * version 2 or later, as published by the Free Software Foundation.
39
+ *
40
+ * This program is distributed in the hope it will be useful, but WITHOUT
41
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
42
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
43
+ * more details.
44
+ *
45
+ * You should have received a copy of the GNU General Public License along with
46
+ * this program. If not, see <http://www.gnu.org/licenses/>.
47
+ *
48
+ */
49
+
50
+#ifndef QEMU_ARM_BSA_H
51
+#define QEMU_ARM_BSA_H
52
+
53
+/* These are architectural INTID values */
54
+#define VIRTUAL_PMU_IRQ 23
55
+#define ARCH_GIC_MAINT_IRQ 25
56
+#define ARCH_TIMER_NS_EL2_IRQ 26
57
+#define ARCH_TIMER_VIRT_IRQ 27
58
+#define ARCH_TIMER_NS_EL2_VIRT_IRQ 28
59
+#define ARCH_TIMER_S_EL1_IRQ 29
60
+#define ARCH_TIMER_NS_EL1_IRQ 30
61
+
62
+#define INTID_TO_PPI(irq) ((irq) - 16)
63
+
64
+#endif /* QEMU_ARM_BSA_H */
65
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
14
index XXXXXXX..XXXXXXX 100644
66
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate.c
67
--- a/include/hw/arm/virt.h
16
+++ b/target/arm/translate.c
68
+++ b/include/hw/arm/virt.h
17
@@ -XXX,XX +XXX,XX @@ static long neon_element_offset(int reg, int element, MemOp size)
69
@@ -XXX,XX +XXX,XX @@
18
return neon_full_reg_offset(reg) + ofs;
70
#include "qemu/notify.h"
19
}
71
#include "hw/boards.h"
20
72
#include "hw/arm/boot.h"
21
-static inline long vfp_reg_offset(bool dp, unsigned reg)
73
+#include "hw/arm/bsa.h"
22
+/* Return the offset of a VFP Dreg (dp = true) or VFP Sreg (dp = false). */
74
#include "hw/block/flash.h"
23
+static long vfp_reg_offset(bool dp, unsigned reg)
75
#include "sysemu/kvm.h"
24
{
76
#include "hw/intc/arm_gicv3_common.h"
25
if (dp) {
77
@@ -XXX,XX +XXX,XX @@
26
- return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]);
78
#define NUM_VIRTIO_TRANSPORTS 32
27
+ return neon_element_offset(reg, 0, MO_64);
79
#define NUM_SMMU_IRQS 4
28
} else {
80
29
- long ofs = offsetof(CPUARMState, vfp.zregs[reg >> 2].d[(reg >> 1) & 1]);
81
-#define ARCH_GIC_MAINT_IRQ 25
30
- if (reg & 1) {
82
-
31
- ofs += offsetof(CPU_DoubleU, l.upper);
83
-#define ARCH_TIMER_VIRT_IRQ 27
32
- } else {
84
-#define ARCH_TIMER_S_EL1_IRQ 29
33
- ofs += offsetof(CPU_DoubleU, l.lower);
85
-#define ARCH_TIMER_NS_EL1_IRQ 30
34
- }
86
-#define ARCH_TIMER_NS_EL2_IRQ 26
35
- return ofs;
87
-
36
+ return neon_element_offset(reg >> 1, reg & 1, MO_32);
88
-#define VIRTUAL_PMU_IRQ 23
37
}
89
-
38
}
90
-#define INTID_TO_PPI(irq) ((irq) - 16)
91
-
92
/* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */
93
#define PVTIME_SIZE_PER_CPU 64
39
94
40
--
95
--
41
2.20.1
96
2.34.1
42
43
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
In both cases, we can sink the write-back and perform
3
Use the private peripheral interrupt definitions from bsa.h instead of
4
the accumulate into the normal destination temps.
4
defining them locally. Refactor to use the INTIDs defined there instead
5
of the PPI# used previously.
5
6
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
7
Message-id: 20201030022618.785675-11-richard.henderson@linaro.org
8
Message-id: 20230919090229.188092-4-quic_llindhol@quicinc.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
target/arm/translate-neon.c.inc | 23 +++++++++--------------
12
hw/arm/sbsa-ref.c | 21 +++++++++------------
12
1 file changed, 9 insertions(+), 14 deletions(-)
13
1 file changed, 9 insertions(+), 12 deletions(-)
13
14
14
diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc
15
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-neon.c.inc
17
--- a/hw/arm/sbsa-ref.c
17
+++ b/target/arm/translate-neon.c.inc
18
+++ b/hw/arm/sbsa-ref.c
18
@@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a,
19
@@ -XXX,XX +XXX,XX @@
19
if (accfn) {
20
* ARM SBSA Reference Platform emulation
20
tmp = tcg_temp_new_i64();
21
*
21
read_neon_element64(tmp, a->vd, 0, MO_64);
22
* Copyright (c) 2018 Linaro Limited
22
- accfn(tmp, tmp, rd0);
23
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
23
- write_neon_element64(tmp, a->vd, 0, MO_64);
24
* Written by Hongbo Zhang <hongbo.zhang@linaro.org>
24
+ accfn(rd0, tmp, rd0);
25
*
25
read_neon_element64(tmp, a->vd, 1, MO_64);
26
* This program is free software; you can redistribute it and/or modify it
26
- accfn(tmp, tmp, rd1);
27
@@ -XXX,XX +XXX,XX @@
27
- write_neon_element64(tmp, a->vd, 1, MO_64);
28
#include "exec/hwaddr.h"
28
+ accfn(rd1, tmp, rd1);
29
#include "kvm_arm.h"
29
tcg_temp_free_i64(tmp);
30
#include "hw/arm/boot.h"
30
- } else {
31
+#include "hw/arm/bsa.h"
31
- write_neon_element64(rd0, a->vd, 0, MO_64);
32
#include "hw/arm/fdt.h"
32
- write_neon_element64(rd1, a->vd, 1, MO_64);
33
#include "hw/arm/smmuv3.h"
33
}
34
#include "hw/block/flash.h"
34
35
@@ -XXX,XX +XXX,XX @@
35
+ write_neon_element64(rd0, a->vd, 0, MO_64);
36
#define NUM_SMMU_IRQS 4
36
+ write_neon_element64(rd1, a->vd, 1, MO_64);
37
#define NUM_SATA_PORTS 6
37
tcg_temp_free_i64(rd0);
38
38
tcg_temp_free_i64(rd1);
39
-#define VIRTUAL_PMU_IRQ 7
39
40
-#define ARCH_GIC_MAINT_IRQ 9
40
@@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a,
41
-#define ARCH_TIMER_VIRT_IRQ 11
41
if (accfn) {
42
-#define ARCH_TIMER_S_EL1_IRQ 13
42
TCGv_i64 t64 = tcg_temp_new_i64();
43
-#define ARCH_TIMER_NS_EL1_IRQ 14
43
read_neon_element64(t64, a->vd, 0, MO_64);
44
-#define ARCH_TIMER_NS_EL2_IRQ 10
44
- accfn(t64, t64, rn0_64);
45
-#define ARCH_TIMER_NS_EL2_VIRT_IRQ 12
45
- write_neon_element64(t64, a->vd, 0, MO_64);
46
-
46
+ accfn(rn0_64, t64, rn0_64);
47
enum {
47
read_neon_element64(t64, a->vd, 1, MO_64);
48
SBSA_FLASH,
48
- accfn(t64, t64, rn1_64);
49
SBSA_MEM,
49
- write_neon_element64(t64, a->vd, 1, MO_64);
50
@@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
50
+ accfn(rn1_64, t64, rn1_64);
51
*/
51
tcg_temp_free_i64(t64);
52
for (i = 0; i < smp_cpus; i++) {
52
- } else {
53
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
53
- write_neon_element64(rn0_64, a->vd, 0, MO_64);
54
- int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
54
- write_neon_element64(rn1_64, a->vd, 1, MO_64);
55
+ int intidbase = NUM_IRQS + i * GIC_INTERNAL;
55
}
56
int irq;
57
/*
58
* Mapping from the output timer irq lines from the CPU to the
59
@@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
60
for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
61
qdev_connect_gpio_out(cpudev, irq,
62
qdev_get_gpio_in(sms->gic,
63
- ppibase + timer_irq[irq]));
64
+ intidbase + timer_irq[irq]));
65
}
66
67
qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0,
68
- qdev_get_gpio_in(sms->gic, ppibase
69
+ qdev_get_gpio_in(sms->gic,
70
+ intidbase
71
+ ARCH_GIC_MAINT_IRQ));
56
+
72
+
57
+ write_neon_element64(rn0_64, a->vd, 0, MO_64);
73
qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
58
+ write_neon_element64(rn1_64, a->vd, 1, MO_64);
74
- qdev_get_gpio_in(sms->gic, ppibase
59
tcg_temp_free_i64(rn0_64);
75
+ qdev_get_gpio_in(sms->gic,
60
tcg_temp_free_i64(rn1_64);
76
+ intidbase
61
return true;
77
+ VIRTUAL_PMU_IRQ));
78
79
sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
62
--
80
--
63
2.20.1
81
2.34.1
64
65
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Cornelia Huck <cohuck@redhat.com>
2
2
3
This function makes it clear that we're talking about the whole
3
We can neaten the code by switching to the kvm_set_one_reg function.
4
register, and not the 32-bit piece at index 0. This fixes a bug
4
5
when running on a big-endian host.
5
Reviewed-by: Gavin Shan <gshan@redhat.com>
6
6
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20201030022618.785675-2-richard.henderson@linaro.org
8
Message-id: 20231010142453.224369-2-cohuck@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
target/arm/translate.c | 8 ++++++
12
target/arm/kvm.c | 13 +++------
13
target/arm/translate-neon.c.inc | 44 ++++++++++++++++-----------------
13
target/arm/kvm64.c | 66 +++++++++++++---------------------------------
14
target/arm/translate-vfp.c.inc | 2 +-
14
2 files changed, 21 insertions(+), 58 deletions(-)
15
3 files changed, 31 insertions(+), 23 deletions(-)
15
16
16
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
17
diff --git a/target/arm/translate.c b/target/arm/translate.c
18
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/translate.c
18
--- a/target/arm/kvm.c
20
+++ b/target/arm/translate.c
19
+++ b/target/arm/kvm.c
21
@@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm)
20
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
22
unallocated_encoding(s);
21
bool ok = true;
22
23
for (i = 0; i < cpu->cpreg_array_len; i++) {
24
- struct kvm_one_reg r;
25
uint64_t regidx = cpu->cpreg_indexes[i];
26
uint32_t v32;
27
int ret;
28
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
29
continue;
30
}
31
32
- r.id = regidx;
33
switch (regidx & KVM_REG_SIZE_MASK) {
34
case KVM_REG_SIZE_U32:
35
v32 = cpu->cpreg_values[i];
36
- r.addr = (uintptr_t)&v32;
37
+ ret = kvm_set_one_reg(cs, regidx, &v32);
38
break;
39
case KVM_REG_SIZE_U64:
40
- r.addr = (uintptr_t)(cpu->cpreg_values + i);
41
+ ret = kvm_set_one_reg(cs, regidx, cpu->cpreg_values + i);
42
break;
43
default:
44
g_assert_not_reached();
45
}
46
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r);
47
if (ret) {
48
/* We might fail for "unknown register" and also for
49
* "you tried to set a register which is constant with
50
@@ -XXX,XX +XXX,XX @@ void kvm_arm_get_virtual_time(CPUState *cs)
51
void kvm_arm_put_virtual_time(CPUState *cs)
52
{
53
ARMCPU *cpu = ARM_CPU(cs);
54
- struct kvm_one_reg reg = {
55
- .id = KVM_REG_ARM_TIMER_CNT,
56
- .addr = (uintptr_t)&cpu->kvm_vtime,
57
- };
58
int ret;
59
60
if (!cpu->kvm_vtime_dirty) {
61
return;
62
}
63
64
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
65
+ ret = kvm_set_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime);
66
if (ret) {
67
error_report("Failed to set KVM_REG_ARM_TIMER_CNT");
68
abort();
69
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/target/arm/kvm64.c
72
+++ b/target/arm/kvm64.c
73
@@ -XXX,XX +XXX,XX @@ static int kvm_arm_sve_set_vls(CPUState *cs)
74
{
75
ARMCPU *cpu = ARM_CPU(cs);
76
uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map };
77
- struct kvm_one_reg reg = {
78
- .id = KVM_REG_ARM64_SVE_VLS,
79
- .addr = (uint64_t)&vls[0],
80
- };
81
82
assert(cpu->sve_max_vq <= KVM_ARM64_SVE_VQ_MAX);
83
84
- return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
85
+ return kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_VLS, &vls[0]);
23
}
86
}
24
87
25
+/*
88
#define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5
26
+ * Return the offset of a "full" NEON Dreg.
89
@@ -XXX,XX +XXX,XX @@ static void kvm_inject_arm_sea(CPUState *c)
27
+ */
90
static int kvm_arch_put_fpsimd(CPUState *cs)
28
+static long neon_full_reg_offset(unsigned reg)
91
{
29
+{
92
CPUARMState *env = &ARM_CPU(cs)->env;
30
+ return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]);
93
- struct kvm_one_reg reg;
31
+}
94
int i, ret;
32
+
95
33
static inline long vfp_reg_offset(bool dp, unsigned reg)
96
for (i = 0; i < 32; i++) {
34
{
97
uint64_t *q = aa64_vfp_qreg(env, i);
35
if (dp) {
98
#if HOST_BIG_ENDIAN
36
diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc
99
uint64_t fp_val[2] = { q[1], q[0] };
37
index XXXXXXX..XXXXXXX 100644
100
- reg.addr = (uintptr_t)fp_val;
38
--- a/target/arm/translate-neon.c.inc
101
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]),
39
+++ b/target/arm/translate-neon.c.inc
102
+ fp_val);
40
@@ -XXX,XX +XXX,XX @@ neon_element_offset(int reg, int element, MemOp size)
103
#else
41
ofs ^= 8 - element_size;
104
- reg.addr = (uintptr_t)q;
42
}
105
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q);
43
#endif
106
#endif
44
- return neon_reg_offset(reg, 0) + ofs;
107
- reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]);
45
+ return neon_full_reg_offset(reg) + ofs;
108
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
46
}
109
if (ret) {
47
110
return ret;
48
static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop)
111
}
49
@@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a)
112
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs)
50
* We cannot write 16 bytes at once because the
113
CPUARMState *env = &cpu->env;
51
* destination is unaligned.
114
uint64_t tmp[ARM_MAX_VQ * 2];
52
*/
115
uint64_t *r;
53
- tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0),
116
- struct kvm_one_reg reg;
54
+ tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd),
117
int n, ret;
55
8, 8, tmp);
118
56
- tcg_gen_gvec_mov(0, neon_reg_offset(vd + 1, 0),
119
for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) {
57
- neon_reg_offset(vd, 0), 8, 8);
120
r = sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * 2);
58
+ tcg_gen_gvec_mov(0, neon_full_reg_offset(vd + 1),
121
- reg.addr = (uintptr_t)r;
59
+ neon_full_reg_offset(vd), 8, 8);
122
- reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0);
60
} else {
123
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
61
- tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0),
124
+ ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_ZREG(n, 0), r);
62
+ tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd),
125
if (ret) {
63
vec_size, vec_size, tmp);
126
return ret;
64
}
127
}
65
tcg_gen_addi_i32(addr, addr, 1 << size);
128
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs)
66
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
129
for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) {
67
static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn)
130
r = sve_bswap64(tmp, r = &env->vfp.pregs[n].p[0],
68
{
131
DIV_ROUND_UP(cpu->sve_max_vq * 2, 8));
69
int vec_size = a->q ? 16 : 8;
132
- reg.addr = (uintptr_t)r;
70
- int rd_ofs = neon_reg_offset(a->vd, 0);
133
- reg.id = KVM_REG_ARM64_SVE_PREG(n, 0);
71
- int rn_ofs = neon_reg_offset(a->vn, 0);
134
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
72
- int rm_ofs = neon_reg_offset(a->vm, 0);
135
+ ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_PREG(n, 0), r);
73
+ int rd_ofs = neon_full_reg_offset(a->vd);
136
if (ret) {
74
+ int rn_ofs = neon_full_reg_offset(a->vn);
137
return ret;
75
+ int rm_ofs = neon_full_reg_offset(a->vm);
138
}
76
139
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs)
77
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
140
78
return false;
141
r = sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0],
79
@@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn)
142
DIV_ROUND_UP(cpu->sve_max_vq * 2, 8));
80
{
143
- reg.addr = (uintptr_t)r;
81
/* Handle a 2-reg-shift insn which can be vectorized. */
144
- reg.id = KVM_REG_ARM64_SVE_FFR(0);
82
int vec_size = a->q ? 16 : 8;
145
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
83
- int rd_ofs = neon_reg_offset(a->vd, 0);
146
+ ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_FFR(0), r);
84
- int rm_ofs = neon_reg_offset(a->vm, 0);
147
if (ret) {
85
+ int rd_ofs = neon_full_reg_offset(a->vd);
148
return ret;
86
+ int rm_ofs = neon_full_reg_offset(a->vm);
149
}
87
150
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs)
88
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
151
89
return false;
152
int kvm_arch_put_registers(CPUState *cs, int level)
90
@@ -XXX,XX +XXX,XX @@ static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a,
153
{
91
{
154
- struct kvm_one_reg reg;
92
/* FP operations in 2-reg-and-shift group */
155
uint64_t val;
93
int vec_size = a->q ? 16 : 8;
156
uint32_t fpr;
94
- int rd_ofs = neon_reg_offset(a->vd, 0);
157
int i, ret;
95
- int rm_ofs = neon_reg_offset(a->vm, 0);
158
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
96
+ int rd_ofs = neon_full_reg_offset(a->vd);
159
}
97
+ int rm_ofs = neon_full_reg_offset(a->vm);
160
98
TCGv_ptr fpst;
161
for (i = 0; i < 31; i++) {
99
162
- reg.id = AARCH64_CORE_REG(regs.regs[i]);
100
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
163
- reg.addr = (uintptr_t) &env->xregs[i];
101
@@ -XXX,XX +XXX,XX @@ static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a,
164
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
102
return true;
165
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]),
103
}
166
+ &env->xregs[i]);
104
167
if (ret) {
105
- reg_ofs = neon_reg_offset(a->vd, 0);
168
return ret;
106
+ reg_ofs = neon_full_reg_offset(a->vd);
169
}
107
vec_size = a->q ? 16 : 8;
170
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
108
imm = asimd_imm_const(a->imm, a->cmode, a->op);
171
*/
109
172
aarch64_save_sp(env, 1);
110
@@ -XXX,XX +XXX,XX @@ static bool trans_VMULL_P_3d(DisasContext *s, arg_3diff *a)
173
111
return true;
174
- reg.id = AARCH64_CORE_REG(regs.sp);
112
}
175
- reg.addr = (uintptr_t) &env->sp_el[0];
113
176
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
114
- tcg_gen_gvec_3_ool(neon_reg_offset(a->vd, 0),
177
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.sp), &env->sp_el[0]);
115
- neon_reg_offset(a->vn, 0),
178
if (ret) {
116
- neon_reg_offset(a->vm, 0),
179
return ret;
117
+ tcg_gen_gvec_3_ool(neon_full_reg_offset(a->vd),
180
}
118
+ neon_full_reg_offset(a->vn),
181
119
+ neon_full_reg_offset(a->vm),
182
- reg.id = AARCH64_CORE_REG(sp_el1);
120
16, 16, 0, fn_gvec);
183
- reg.addr = (uintptr_t) &env->sp_el[1];
121
return true;
184
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
122
}
185
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(sp_el1), &env->sp_el[1]);
123
@@ -XXX,XX +XXX,XX @@ static bool do_2scalar_fp_vec(DisasContext *s, arg_2scalar *a,
186
if (ret) {
124
{
187
return ret;
125
/* Two registers and a scalar, using gvec */
188
}
126
int vec_size = a->q ? 16 : 8;
189
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
127
- int rd_ofs = neon_reg_offset(a->vd, 0);
190
} else {
128
- int rn_ofs = neon_reg_offset(a->vn, 0);
191
val = cpsr_read(env);
129
+ int rd_ofs = neon_full_reg_offset(a->vd);
192
}
130
+ int rn_ofs = neon_full_reg_offset(a->vn);
193
- reg.id = AARCH64_CORE_REG(regs.pstate);
131
int rm_ofs;
194
- reg.addr = (uintptr_t) &val;
132
int idx;
195
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
133
TCGv_ptr fpstatus;
196
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.pstate), &val);
134
@@ -XXX,XX +XXX,XX @@ static bool do_2scalar_fp_vec(DisasContext *s, arg_2scalar *a,
197
if (ret) {
135
/* a->vm is M:Vm, which encodes both register and index */
198
return ret;
136
idx = extract32(a->vm, a->size + 2, 2);
199
}
137
a->vm = extract32(a->vm, 0, a->size + 2);
200
138
- rm_ofs = neon_reg_offset(a->vm, 0);
201
- reg.id = AARCH64_CORE_REG(regs.pc);
139
+ rm_ofs = neon_full_reg_offset(a->vm);
202
- reg.addr = (uintptr_t) &env->pc;
140
203
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
141
fpstatus = fpstatus_ptr(a->size == 1 ? FPST_STD_F16 : FPST_STD);
204
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc);
142
tcg_gen_gvec_3_ptr(rd_ofs, rn_ofs, rm_ofs, fpstatus,
205
if (ret) {
143
@@ -XXX,XX +XXX,XX @@ static bool trans_VDUP_scalar(DisasContext *s, arg_VDUP_scalar *a)
206
return ret;
144
return true;
207
}
145
}
208
146
209
- reg.id = AARCH64_CORE_REG(elr_el1);
147
- tcg_gen_gvec_dup_mem(a->size, neon_reg_offset(a->vd, 0),
210
- reg.addr = (uintptr_t) &env->elr_el[1];
148
+ tcg_gen_gvec_dup_mem(a->size, neon_full_reg_offset(a->vd),
211
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
149
neon_element_offset(a->vm, a->index, a->size),
212
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]);
150
a->q ? 16 : 8, a->q ? 16 : 8);
213
if (ret) {
151
return true;
214
return ret;
152
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a)
215
}
153
static bool do_2misc_vec(DisasContext *s, arg_2misc *a, GVecGen2Fn *fn)
216
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
154
{
217
155
int vec_size = a->q ? 16 : 8;
218
/* KVM 0-4 map to QEMU banks 1-5 */
156
- int rd_ofs = neon_reg_offset(a->vd, 0);
219
for (i = 0; i < KVM_NR_SPSR; i++) {
157
- int rm_ofs = neon_reg_offset(a->vm, 0);
220
- reg.id = AARCH64_CORE_REG(spsr[i]);
158
+ int rd_ofs = neon_full_reg_offset(a->vd);
221
- reg.addr = (uintptr_t) &env->banked_spsr[i + 1];
159
+ int rm_ofs = neon_full_reg_offset(a->vm);
222
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
160
223
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(spsr[i]),
161
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
224
+ &env->banked_spsr[i + 1]);
162
return false;
225
if (ret) {
163
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
226
return ret;
164
index XXXXXXX..XXXXXXX 100644
227
}
165
--- a/target/arm/translate-vfp.c.inc
228
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
166
+++ b/target/arm/translate-vfp.c.inc
229
return ret;
167
@@ -XXX,XX +XXX,XX @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a)
230
}
168
}
231
169
232
- reg.addr = (uintptr_t)(&fpr);
170
tmp = load_reg(s, a->rt);
233
fpr = vfp_get_fpsr(env);
171
- tcg_gen_gvec_dup_i32(size, neon_reg_offset(a->vn, 0),
234
- reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr);
172
+ tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(a->vn),
235
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
173
vec_size, vec_size, tmp);
236
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr);
174
tcg_temp_free_i32(tmp);
237
if (ret) {
175
238
return ret;
239
}
240
241
- reg.addr = (uintptr_t)(&fpr);
242
fpr = vfp_get_fpcr(env);
243
- reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr);
244
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
245
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr);
246
if (ret) {
247
return ret;
248
}
176
--
249
--
177
2.20.1
250
2.34.1
178
251
179
252
diff view generated by jsdifflib
1
From: AlexChen <alex.chen@huawei.com>
1
From: Cornelia Huck <cohuck@redhat.com>
2
2
3
In omap_lcd_interrupts(), the pointer omap_lcd is dereferinced before
3
We can neaten the code by switching the callers that work on a
4
being check if it is valid, which may lead to NULL pointer dereference.
4
CPUstate to the kvm_get_one_reg function.
5
So move the assignment to surface after checking that the omap_lcd is valid
5
6
and move surface_bits_per_pixel(surface) to after the surface assignment.
6
Reviewed-by: Gavin Shan <gshan@redhat.com>
7
7
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
8
Reported-by: Euler Robot <euler.robot@huawei.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: AlexChen <alex.chen@huawei.com>
9
Message-id: 20231010142453.224369-3-cohuck@redhat.com
10
Message-id: 5F9CDB8A.9000001@huawei.com
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
12
---
14
hw/display/omap_lcdc.c | 10 +++++++---
13
target/arm/kvm.c | 15 +++---------
15
1 file changed, 7 insertions(+), 3 deletions(-)
14
target/arm/kvm64.c | 57 ++++++++++++----------------------------------
16
15
2 files changed, 18 insertions(+), 54 deletions(-)
17
diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c
16
17
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
18
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/display/omap_lcdc.c
19
--- a/target/arm/kvm.c
20
+++ b/hw/display/omap_lcdc.c
20
+++ b/target/arm/kvm.c
21
@@ -XXX,XX +XXX,XX @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s)
21
@@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu)
22
static void omap_update_display(void *opaque)
22
bool ok = true;
23
{
23
24
struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque;
24
for (i = 0; i < cpu->cpreg_array_len; i++) {
25
- DisplaySurface *surface = qemu_console_surface(omap_lcd->con);
25
- struct kvm_one_reg r;
26
+ DisplaySurface *surface;
26
uint64_t regidx = cpu->cpreg_indexes[i];
27
draw_line_func draw_line;
27
uint32_t v32;
28
int size, height, first, last;
28
int ret;
29
int width, linesize, step, bpp, frame_offset;
29
30
hwaddr frame_base;
30
- r.id = regidx;
31
31
-
32
- if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable ||
32
switch (regidx & KVM_REG_SIZE_MASK) {
33
- !surface_bits_per_pixel(surface)) {
33
case KVM_REG_SIZE_U32:
34
+ if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable) {
34
- r.addr = (uintptr_t)&v32;
35
+ return;
35
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r);
36
+ }
36
+ ret = kvm_get_one_reg(cs, regidx, &v32);
37
+
37
if (!ret) {
38
+ surface = qemu_console_surface(omap_lcd->con);
38
cpu->cpreg_values[i] = v32;
39
+ if (!surface_bits_per_pixel(surface)) {
39
}
40
break;
41
case KVM_REG_SIZE_U64:
42
- r.addr = (uintptr_t)(cpu->cpreg_values + i);
43
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r);
44
+ ret = kvm_get_one_reg(cs, regidx, cpu->cpreg_values + i);
45
break;
46
default:
47
g_assert_not_reached();
48
@@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu)
49
void kvm_arm_get_virtual_time(CPUState *cs)
50
{
51
ARMCPU *cpu = ARM_CPU(cs);
52
- struct kvm_one_reg reg = {
53
- .id = KVM_REG_ARM_TIMER_CNT,
54
- .addr = (uintptr_t)&cpu->kvm_vtime,
55
- };
56
int ret;
57
58
if (cpu->kvm_vtime_dirty) {
40
return;
59
return;
41
}
60
}
42
61
62
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
63
+ ret = kvm_get_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime);
64
if (ret) {
65
error_report("Failed to get KVM_REG_ARM_TIMER_CNT");
66
abort();
67
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/kvm64.c
70
+++ b/target/arm/kvm64.c
71
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
72
static int kvm_arch_get_fpsimd(CPUState *cs)
73
{
74
CPUARMState *env = &ARM_CPU(cs)->env;
75
- struct kvm_one_reg reg;
76
int i, ret;
77
78
for (i = 0; i < 32; i++) {
79
uint64_t *q = aa64_vfp_qreg(env, i);
80
- reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]);
81
- reg.addr = (uintptr_t)q;
82
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
83
+ ret = kvm_get_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q);
84
if (ret) {
85
return ret;
86
} else {
87
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs)
88
{
89
ARMCPU *cpu = ARM_CPU(cs);
90
CPUARMState *env = &cpu->env;
91
- struct kvm_one_reg reg;
92
uint64_t *r;
93
int n, ret;
94
95
for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) {
96
r = &env->vfp.zregs[n].d[0];
97
- reg.addr = (uintptr_t)r;
98
- reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0);
99
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
100
+ ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_ZREG(n, 0), r);
101
if (ret) {
102
return ret;
103
}
104
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs)
105
106
for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) {
107
r = &env->vfp.pregs[n].p[0];
108
- reg.addr = (uintptr_t)r;
109
- reg.id = KVM_REG_ARM64_SVE_PREG(n, 0);
110
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
111
+ ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_PREG(n, 0), r);
112
if (ret) {
113
return ret;
114
}
115
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs)
116
}
117
118
r = &env->vfp.pregs[FFR_PRED_NUM].p[0];
119
- reg.addr = (uintptr_t)r;
120
- reg.id = KVM_REG_ARM64_SVE_FFR(0);
121
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
122
+ ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_FFR(0), r);
123
if (ret) {
124
return ret;
125
}
126
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs)
127
128
int kvm_arch_get_registers(CPUState *cs)
129
{
130
- struct kvm_one_reg reg;
131
uint64_t val;
132
unsigned int el;
133
uint32_t fpr;
134
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
135
CPUARMState *env = &cpu->env;
136
137
for (i = 0; i < 31; i++) {
138
- reg.id = AARCH64_CORE_REG(regs.regs[i]);
139
- reg.addr = (uintptr_t) &env->xregs[i];
140
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
141
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]),
142
+ &env->xregs[i]);
143
if (ret) {
144
return ret;
145
}
146
}
147
148
- reg.id = AARCH64_CORE_REG(regs.sp);
149
- reg.addr = (uintptr_t) &env->sp_el[0];
150
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
151
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.sp), &env->sp_el[0]);
152
if (ret) {
153
return ret;
154
}
155
156
- reg.id = AARCH64_CORE_REG(sp_el1);
157
- reg.addr = (uintptr_t) &env->sp_el[1];
158
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
159
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(sp_el1), &env->sp_el[1]);
160
if (ret) {
161
return ret;
162
}
163
164
- reg.id = AARCH64_CORE_REG(regs.pstate);
165
- reg.addr = (uintptr_t) &val;
166
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
167
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pstate), &val);
168
if (ret) {
169
return ret;
170
}
171
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
172
*/
173
aarch64_restore_sp(env, 1);
174
175
- reg.id = AARCH64_CORE_REG(regs.pc);
176
- reg.addr = (uintptr_t) &env->pc;
177
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
178
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc);
179
if (ret) {
180
return ret;
181
}
182
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
183
aarch64_sync_64_to_32(env);
184
}
185
186
- reg.id = AARCH64_CORE_REG(elr_el1);
187
- reg.addr = (uintptr_t) &env->elr_el[1];
188
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
189
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]);
190
if (ret) {
191
return ret;
192
}
193
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
194
* KVM SPSRs 0-4 map to QEMU banks 1-5
195
*/
196
for (i = 0; i < KVM_NR_SPSR; i++) {
197
- reg.id = AARCH64_CORE_REG(spsr[i]);
198
- reg.addr = (uintptr_t) &env->banked_spsr[i + 1];
199
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
200
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(spsr[i]),
201
+ &env->banked_spsr[i + 1]);
202
if (ret) {
203
return ret;
204
}
205
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
206
return ret;
207
}
208
209
- reg.addr = (uintptr_t)(&fpr);
210
- reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr);
211
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
212
+ ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr);
213
if (ret) {
214
return ret;
215
}
216
vfp_set_fpsr(env, fpr);
217
218
- reg.addr = (uintptr_t)(&fpr);
219
- reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr);
220
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
221
+ ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr);
222
if (ret) {
223
return ret;
224
}
43
--
225
--
44
2.20.1
226
2.34.1
45
227
46
228
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
For the Thumb T32 encoding of LDM, if only a single register is
2
specified in the register list this instruction is UNPREDICTABLE,
3
with the following choices:
4
* instruction UNDEFs
5
* instruction is a NOP
6
* instruction loads a single register
7
* instruction loads an unspecified set of registers
2
8
3
Model these off the aa64 read/write_vec_element functions.
9
Currently we choose to UNDEF (a behaviour chosen in commit
4
Use it within translate-neon.c.inc. The new functions do
10
4b222545dbf30 in 2019; previously we treated it as "load the
5
not allocate or free temps, so this rearranges the calling
11
specified single register").
6
code a bit.
7
12
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Unfortunately there is real world code out there (which shipped in at
9
Message-id: 20201030022618.785675-6-richard.henderson@linaro.org
14
least Android 11, 12 and 13) which incorrectly uses this
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
UNPREDICTABLE insn on the assumption that it does a single register
16
load, which is (presumably) what it happens to do on real hardware,
17
and is also what it does on the equivalent A32 encoding.
18
19
Revert to the pre-4b222545dbf30 behaviour of not UNDEFing
20
for this T32 encoding.
21
22
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1799
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
26
Message-id: 20230927101853.39288-1-peter.maydell@linaro.org
12
---
27
---
13
target/arm/translate.c | 26 ++++
28
target/arm/tcg/translate.c | 37 +++++++++++++++++++++++--------------
14
target/arm/translate-neon.c.inc | 256 ++++++++++++++++++++------------
29
1 file changed, 23 insertions(+), 14 deletions(-)
15
2 files changed, 183 insertions(+), 99 deletions(-)
16
30
17
diff --git a/target/arm/translate.c b/target/arm/translate.c
31
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
18
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/translate.c
33
--- a/target/arm/tcg/translate.c
20
+++ b/target/arm/translate.c
34
+++ b/target/arm/tcg/translate.c
21
@@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg32(TCGv_i32 var, int reg)
35
@@ -XXX,XX +XXX,XX @@ static void op_addr_block_post(DisasContext *s, arg_ldst_block *a,
22
tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg));
36
}
23
}
37
}
24
38
25
+static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size)
39
-static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
26
+{
40
+static bool op_stm(DisasContext *s, arg_ldst_block *a)
27
+ long off = neon_element_offset(reg, ele, size);
28
+
29
+ switch (size) {
30
+ case MO_32:
31
+ tcg_gen_ld_i32(dest, cpu_env, off);
32
+ break;
33
+ default:
34
+ g_assert_not_reached();
35
+ }
36
+}
37
+
38
+static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp size)
39
+{
40
+ long off = neon_element_offset(reg, ele, size);
41
+
42
+ switch (size) {
43
+ case MO_32:
44
+ tcg_gen_st_i32(src, cpu_env, off);
45
+ break;
46
+ default:
47
+ g_assert_not_reached();
48
+ }
49
+}
50
+
51
static TCGv_ptr vfp_reg_ptr(bool dp, int reg)
52
{
41
{
53
TCGv_ptr ret = tcg_temp_new_ptr();
42
int i, j, n, list, mem_idx;
54
diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc
43
bool user = a->u;
55
index XXXXXXX..XXXXXXX 100644
44
@@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
56
--- a/target/arm/translate-neon.c.inc
45
57
+++ b/target/arm/translate-neon.c.inc
46
list = a->list;
58
@@ -XXX,XX +XXX,XX @@ static bool do_3same_pair(DisasContext *s, arg_3same *a, NeonGenTwoOpFn *fn)
47
n = ctpop16(list);
59
* early. Since Q is 0 there are always just two passes, so instead
48
- if (n < min_n || a->rn == 15) {
60
* of a complicated loop over each pass we just unroll.
49
+ /*
61
*/
50
+ * This is UNPREDICTABLE for n < 1 in all encodings, and we choose
62
- tmp = neon_load_reg(a->vn, 0);
51
+ * to UNDEF. In the T32 STM encoding n == 1 is also UNPREDICTABLE,
63
- tmp2 = neon_load_reg(a->vn, 1);
52
+ * but hardware treats it like the A32 version and implements the
64
+ tmp = tcg_temp_new_i32();
53
+ * single-register-store, and some in-the-wild (buggy) software
65
+ tmp2 = tcg_temp_new_i32();
54
+ * assumes that, so we don't UNDEF on that case.
66
+ tmp3 = tcg_temp_new_i32();
55
+ */
67
+
56
+ if (n < 1 || a->rn == 15) {
68
+ read_neon_element32(tmp, a->vn, 0, MO_32);
57
unallocated_encoding(s);
69
+ read_neon_element32(tmp2, a->vn, 1, MO_32);
70
fn(tmp, tmp, tmp2);
71
- tcg_temp_free_i32(tmp2);
72
73
- tmp3 = neon_load_reg(a->vm, 0);
74
- tmp2 = neon_load_reg(a->vm, 1);
75
+ read_neon_element32(tmp3, a->vm, 0, MO_32);
76
+ read_neon_element32(tmp2, a->vm, 1, MO_32);
77
fn(tmp3, tmp3, tmp2);
78
- tcg_temp_free_i32(tmp2);
79
80
- neon_store_reg(a->vd, 0, tmp);
81
- neon_store_reg(a->vd, 1, tmp3);
82
+ write_neon_element32(tmp, a->vd, 0, MO_32);
83
+ write_neon_element32(tmp3, a->vd, 1, MO_32);
84
+
85
+ tcg_temp_free_i32(tmp);
86
+ tcg_temp_free_i32(tmp2);
87
+ tcg_temp_free_i32(tmp3);
88
return true;
89
}
90
91
@@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a,
92
* 2-reg-and-shift operations, size < 3 case, where the
93
* helper needs to be passed cpu_env.
94
*/
95
- TCGv_i32 constimm;
96
+ TCGv_i32 constimm, tmp;
97
int pass;
98
99
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
100
@@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a,
101
* by immediate using the variable shift operations.
102
*/
103
constimm = tcg_const_i32(dup_const(a->size, a->shift));
104
+ tmp = tcg_temp_new_i32();
105
106
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
107
- TCGv_i32 tmp = neon_load_reg(a->vm, pass);
108
+ read_neon_element32(tmp, a->vm, pass, MO_32);
109
fn(tmp, cpu_env, tmp, constimm);
110
- neon_store_reg(a->vd, pass, tmp);
111
+ write_neon_element32(tmp, a->vd, pass, MO_32);
112
}
113
+ tcg_temp_free_i32(tmp);
114
tcg_temp_free_i32(constimm);
115
return true;
116
}
117
@@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a,
118
constimm = tcg_const_i64(-a->shift);
119
rm1 = tcg_temp_new_i64();
120
rm2 = tcg_temp_new_i64();
121
+ rd = tcg_temp_new_i32();
122
123
/* Load both inputs first to avoid potential overwrite if rm == rd */
124
neon_load_reg64(rm1, a->vm);
125
neon_load_reg64(rm2, a->vm + 1);
126
127
shiftfn(rm1, rm1, constimm);
128
- rd = tcg_temp_new_i32();
129
narrowfn(rd, cpu_env, rm1);
130
- neon_store_reg(a->vd, 0, rd);
131
+ write_neon_element32(rd, a->vd, 0, MO_32);
132
133
shiftfn(rm2, rm2, constimm);
134
- rd = tcg_temp_new_i32();
135
narrowfn(rd, cpu_env, rm2);
136
- neon_store_reg(a->vd, 1, rd);
137
+ write_neon_element32(rd, a->vd, 1, MO_32);
138
139
+ tcg_temp_free_i32(rd);
140
tcg_temp_free_i64(rm1);
141
tcg_temp_free_i64(rm2);
142
tcg_temp_free_i64(constimm);
143
@@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a,
144
constimm = tcg_const_i32(imm);
145
146
/* Load all inputs first to avoid potential overwrite */
147
- rm1 = neon_load_reg(a->vm, 0);
148
- rm2 = neon_load_reg(a->vm, 1);
149
- rm3 = neon_load_reg(a->vm + 1, 0);
150
- rm4 = neon_load_reg(a->vm + 1, 1);
151
+ rm1 = tcg_temp_new_i32();
152
+ rm2 = tcg_temp_new_i32();
153
+ rm3 = tcg_temp_new_i32();
154
+ rm4 = tcg_temp_new_i32();
155
+ read_neon_element32(rm1, a->vm, 0, MO_32);
156
+ read_neon_element32(rm2, a->vm, 1, MO_32);
157
+ read_neon_element32(rm3, a->vm, 2, MO_32);
158
+ read_neon_element32(rm4, a->vm, 3, MO_32);
159
rtmp = tcg_temp_new_i64();
160
161
shiftfn(rm1, rm1, constimm);
162
@@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a,
163
tcg_temp_free_i32(rm2);
164
165
narrowfn(rm1, cpu_env, rtmp);
166
- neon_store_reg(a->vd, 0, rm1);
167
+ write_neon_element32(rm1, a->vd, 0, MO_32);
168
+ tcg_temp_free_i32(rm1);
169
170
shiftfn(rm3, rm3, constimm);
171
shiftfn(rm4, rm4, constimm);
172
@@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a,
173
174
narrowfn(rm3, cpu_env, rtmp);
175
tcg_temp_free_i64(rtmp);
176
- neon_store_reg(a->vd, 1, rm3);
177
+ write_neon_element32(rm3, a->vd, 1, MO_32);
178
+ tcg_temp_free_i32(rm3);
179
return true;
180
}
181
182
@@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a,
183
widen_mask = dup_const(a->size + 1, widen_mask);
184
}
185
186
- rm0 = neon_load_reg(a->vm, 0);
187
- rm1 = neon_load_reg(a->vm, 1);
188
+ rm0 = tcg_temp_new_i32();
189
+ rm1 = tcg_temp_new_i32();
190
+ read_neon_element32(rm0, a->vm, 0, MO_32);
191
+ read_neon_element32(rm1, a->vm, 1, MO_32);
192
tmp = tcg_temp_new_i64();
193
194
widenfn(tmp, rm0);
195
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
196
if (src1_wide) {
197
neon_load_reg64(rn0_64, a->vn);
198
} else {
199
- TCGv_i32 tmp = neon_load_reg(a->vn, 0);
200
+ TCGv_i32 tmp = tcg_temp_new_i32();
201
+ read_neon_element32(tmp, a->vn, 0, MO_32);
202
widenfn(rn0_64, tmp);
203
tcg_temp_free_i32(tmp);
204
}
205
- rm = neon_load_reg(a->vm, 0);
206
+ rm = tcg_temp_new_i32();
207
+ read_neon_element32(rm, a->vm, 0, MO_32);
208
209
widenfn(rm_64, rm);
210
tcg_temp_free_i32(rm);
211
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
212
if (src1_wide) {
213
neon_load_reg64(rn1_64, a->vn + 1);
214
} else {
215
- TCGv_i32 tmp = neon_load_reg(a->vn, 1);
216
+ TCGv_i32 tmp = tcg_temp_new_i32();
217
+ read_neon_element32(tmp, a->vn, 1, MO_32);
218
widenfn(rn1_64, tmp);
219
tcg_temp_free_i32(tmp);
220
}
221
- rm = neon_load_reg(a->vm, 1);
222
+ rm = tcg_temp_new_i32();
223
+ read_neon_element32(rm, a->vm, 1, MO_32);
224
225
neon_store_reg64(rn0_64, a->vd);
226
227
@@ -XXX,XX +XXX,XX @@ static bool do_narrow_3d(DisasContext *s, arg_3diff *a,
228
229
narrowfn(rd1, rn_64);
230
231
- neon_store_reg(a->vd, 0, rd0);
232
- neon_store_reg(a->vd, 1, rd1);
233
+ write_neon_element32(rd0, a->vd, 0, MO_32);
234
+ write_neon_element32(rd1, a->vd, 1, MO_32);
235
236
+ tcg_temp_free_i32(rd0);
237
+ tcg_temp_free_i32(rd1);
238
tcg_temp_free_i64(rn_64);
239
tcg_temp_free_i64(rm_64);
240
241
@@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a,
242
rd0 = tcg_temp_new_i64();
243
rd1 = tcg_temp_new_i64();
244
245
- rn = neon_load_reg(a->vn, 0);
246
- rm = neon_load_reg(a->vm, 0);
247
+ rn = tcg_temp_new_i32();
248
+ rm = tcg_temp_new_i32();
249
+ read_neon_element32(rn, a->vn, 0, MO_32);
250
+ read_neon_element32(rm, a->vm, 0, MO_32);
251
opfn(rd0, rn, rm);
252
- tcg_temp_free_i32(rn);
253
- tcg_temp_free_i32(rm);
254
255
- rn = neon_load_reg(a->vn, 1);
256
- rm = neon_load_reg(a->vm, 1);
257
+ read_neon_element32(rn, a->vn, 1, MO_32);
258
+ read_neon_element32(rm, a->vm, 1, MO_32);
259
opfn(rd1, rn, rm);
260
tcg_temp_free_i32(rn);
261
tcg_temp_free_i32(rm);
262
@@ -XXX,XX +XXX,XX @@ static void gen_neon_dup_high16(TCGv_i32 var)
263
264
static inline TCGv_i32 neon_get_scalar(int size, int reg)
265
{
266
- TCGv_i32 tmp;
267
- if (size == 1) {
268
- tmp = neon_load_reg(reg & 7, reg >> 4);
269
+ TCGv_i32 tmp = tcg_temp_new_i32();
270
+ if (size == MO_16) {
271
+ read_neon_element32(tmp, reg & 7, reg >> 4, MO_32);
272
if (reg & 8) {
273
gen_neon_dup_high16(tmp);
274
} else {
275
gen_neon_dup_low16(tmp);
276
}
277
} else {
278
- tmp = neon_load_reg(reg & 15, reg >> 4);
279
+ read_neon_element32(tmp, reg & 15, reg >> 4, MO_32);
280
}
281
return tmp;
282
}
283
@@ -XXX,XX +XXX,XX @@ static bool do_2scalar(DisasContext *s, arg_2scalar *a,
284
* perform an accumulation operation of that result into the
285
* destination.
286
*/
287
- TCGv_i32 scalar;
288
+ TCGv_i32 scalar, tmp;
289
int pass;
290
291
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
292
@@ -XXX,XX +XXX,XX @@ static bool do_2scalar(DisasContext *s, arg_2scalar *a,
293
}
294
295
scalar = neon_get_scalar(a->size, a->vm);
296
+ tmp = tcg_temp_new_i32();
297
298
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
299
- TCGv_i32 tmp = neon_load_reg(a->vn, pass);
300
+ read_neon_element32(tmp, a->vn, pass, MO_32);
301
opfn(tmp, tmp, scalar);
302
if (accfn) {
303
- TCGv_i32 rd = neon_load_reg(a->vd, pass);
304
+ TCGv_i32 rd = tcg_temp_new_i32();
305
+ read_neon_element32(rd, a->vd, pass, MO_32);
306
accfn(tmp, rd, tmp);
307
tcg_temp_free_i32(rd);
308
}
309
- neon_store_reg(a->vd, pass, tmp);
310
+ write_neon_element32(tmp, a->vd, pass, MO_32);
311
}
312
+ tcg_temp_free_i32(tmp);
313
tcg_temp_free_i32(scalar);
314
return true;
315
}
316
@@ -XXX,XX +XXX,XX @@ static bool do_vqrdmlah_2sc(DisasContext *s, arg_2scalar *a,
317
* performs a kind of fused op-then-accumulate using a helper
318
* function that takes all of rd, rn and the scalar at once.
319
*/
320
- TCGv_i32 scalar;
321
+ TCGv_i32 scalar, rn, rd;
322
int pass;
323
324
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
325
@@ -XXX,XX +XXX,XX @@ static bool do_vqrdmlah_2sc(DisasContext *s, arg_2scalar *a,
326
}
327
328
scalar = neon_get_scalar(a->size, a->vm);
329
+ rn = tcg_temp_new_i32();
330
+ rd = tcg_temp_new_i32();
331
332
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
333
- TCGv_i32 rn = neon_load_reg(a->vn, pass);
334
- TCGv_i32 rd = neon_load_reg(a->vd, pass);
335
+ read_neon_element32(rn, a->vn, pass, MO_32);
336
+ read_neon_element32(rd, a->vd, pass, MO_32);
337
opfn(rd, cpu_env, rn, scalar, rd);
338
- tcg_temp_free_i32(rn);
339
- neon_store_reg(a->vd, pass, rd);
340
+ write_neon_element32(rd, a->vd, pass, MO_32);
341
}
342
+ tcg_temp_free_i32(rn);
343
+ tcg_temp_free_i32(rd);
344
tcg_temp_free_i32(scalar);
345
346
return true;
347
@@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a,
348
scalar = neon_get_scalar(a->size, a->vm);
349
350
/* Load all inputs before writing any outputs, in case of overlap */
351
- rn = neon_load_reg(a->vn, 0);
352
+ rn = tcg_temp_new_i32();
353
+ read_neon_element32(rn, a->vn, 0, MO_32);
354
rn0_64 = tcg_temp_new_i64();
355
opfn(rn0_64, rn, scalar);
356
- tcg_temp_free_i32(rn);
357
358
- rn = neon_load_reg(a->vn, 1);
359
+ read_neon_element32(rn, a->vn, 1, MO_32);
360
rn1_64 = tcg_temp_new_i64();
361
opfn(rn1_64, rn, scalar);
362
tcg_temp_free_i32(rn);
363
@@ -XXX,XX +XXX,XX @@ static bool trans_VTBL(DisasContext *s, arg_VTBL *a)
364
return false;
365
}
366
n <<= 3;
367
+ tmp = tcg_temp_new_i32();
368
if (a->op) {
369
- tmp = neon_load_reg(a->vd, 0);
370
+ read_neon_element32(tmp, a->vd, 0, MO_32);
371
} else {
372
- tmp = tcg_temp_new_i32();
373
tcg_gen_movi_i32(tmp, 0);
374
}
375
- tmp2 = neon_load_reg(a->vm, 0);
376
+ tmp2 = tcg_temp_new_i32();
377
+ read_neon_element32(tmp2, a->vm, 0, MO_32);
378
ptr1 = vfp_reg_ptr(true, a->vn);
379
tmp4 = tcg_const_i32(n);
380
gen_helper_neon_tbl(tmp2, tmp2, tmp, ptr1, tmp4);
381
- tcg_temp_free_i32(tmp);
382
+
383
if (a->op) {
384
- tmp = neon_load_reg(a->vd, 1);
385
+ read_neon_element32(tmp, a->vd, 1, MO_32);
386
} else {
387
- tmp = tcg_temp_new_i32();
388
tcg_gen_movi_i32(tmp, 0);
389
}
390
- tmp3 = neon_load_reg(a->vm, 1);
391
+ tmp3 = tcg_temp_new_i32();
392
+ read_neon_element32(tmp3, a->vm, 1, MO_32);
393
gen_helper_neon_tbl(tmp3, tmp3, tmp, ptr1, tmp4);
394
+ tcg_temp_free_i32(tmp);
395
tcg_temp_free_i32(tmp4);
396
tcg_temp_free_ptr(ptr1);
397
- neon_store_reg(a->vd, 0, tmp2);
398
- neon_store_reg(a->vd, 1, tmp3);
399
- tcg_temp_free_i32(tmp);
400
+
401
+ write_neon_element32(tmp2, a->vd, 0, MO_32);
402
+ write_neon_element32(tmp3, a->vd, 1, MO_32);
403
+ tcg_temp_free_i32(tmp2);
404
+ tcg_temp_free_i32(tmp3);
405
return true;
406
}
407
408
@@ -XXX,XX +XXX,XX @@ static bool trans_VDUP_scalar(DisasContext *s, arg_VDUP_scalar *a)
409
static bool trans_VREV64(DisasContext *s, arg_VREV64 *a)
410
{
411
int pass, half;
412
+ TCGv_i32 tmp[2];
413
414
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
415
return false;
416
@@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_VREV64 *a)
417
return true;
58
return true;
418
}
59
}
419
60
@@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
420
- for (pass = 0; pass < (a->q ? 2 : 1); pass++) {
61
421
- TCGv_i32 tmp[2];
62
static bool trans_STM(DisasContext *s, arg_ldst_block *a)
422
+ tmp[0] = tcg_temp_new_i32();
63
{
423
+ tmp[1] = tcg_temp_new_i32();
64
- /* BitCount(list) < 1 is UNPREDICTABLE */
424
65
- return op_stm(s, a, 1);
425
+ for (pass = 0; pass < (a->q ? 2 : 1); pass++) {
66
+ return op_stm(s, a);
426
for (half = 0; half < 2; half++) {
427
- tmp[half] = neon_load_reg(a->vm, pass * 2 + half);
428
+ read_neon_element32(tmp[half], a->vm, pass * 2 + half, MO_32);
429
switch (a->size) {
430
case 0:
431
tcg_gen_bswap32_i32(tmp[half], tmp[half]);
432
@@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_VREV64 *a)
433
g_assert_not_reached();
434
}
435
}
436
- neon_store_reg(a->vd, pass * 2, tmp[1]);
437
- neon_store_reg(a->vd, pass * 2 + 1, tmp[0]);
438
+ write_neon_element32(tmp[1], a->vd, pass * 2, MO_32);
439
+ write_neon_element32(tmp[0], a->vd, pass * 2 + 1, MO_32);
440
}
441
+
442
+ tcg_temp_free_i32(tmp[0]);
443
+ tcg_temp_free_i32(tmp[1]);
444
return true;
445
}
67
}
446
68
447
@@ -XXX,XX +XXX,XX @@ static bool do_2misc_pairwise(DisasContext *s, arg_2misc *a,
69
static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a)
448
rm0_64 = tcg_temp_new_i64();
70
@@ -XXX,XX +XXX,XX @@ static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a)
449
rm1_64 = tcg_temp_new_i64();
71
unallocated_encoding(s);
450
rd_64 = tcg_temp_new_i64();
451
- tmp = neon_load_reg(a->vm, pass * 2);
452
+
453
+ tmp = tcg_temp_new_i32();
454
+ read_neon_element32(tmp, a->vm, pass * 2, MO_32);
455
widenfn(rm0_64, tmp);
456
- tcg_temp_free_i32(tmp);
457
- tmp = neon_load_reg(a->vm, pass * 2 + 1);
458
+ read_neon_element32(tmp, a->vm, pass * 2 + 1, MO_32);
459
widenfn(rm1_64, tmp);
460
tcg_temp_free_i32(tmp);
461
+
462
opfn(rd_64, rm0_64, rm1_64);
463
tcg_temp_free_i64(rm0_64);
464
tcg_temp_free_i64(rm1_64);
465
@@ -XXX,XX +XXX,XX @@ static bool do_vmovn(DisasContext *s, arg_2misc *a,
466
narrowfn(rd0, cpu_env, rm);
467
neon_load_reg64(rm, a->vm + 1);
468
narrowfn(rd1, cpu_env, rm);
469
- neon_store_reg(a->vd, 0, rd0);
470
- neon_store_reg(a->vd, 1, rd1);
471
+ write_neon_element32(rd0, a->vd, 0, MO_32);
472
+ write_neon_element32(rd1, a->vd, 1, MO_32);
473
+ tcg_temp_free_i32(rd0);
474
+ tcg_temp_free_i32(rd1);
475
tcg_temp_free_i64(rm);
476
return true;
477
}
478
@@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL(DisasContext *s, arg_2misc *a)
479
}
480
481
rd = tcg_temp_new_i64();
482
+ rm0 = tcg_temp_new_i32();
483
+ rm1 = tcg_temp_new_i32();
484
485
- rm0 = neon_load_reg(a->vm, 0);
486
- rm1 = neon_load_reg(a->vm, 1);
487
+ read_neon_element32(rm0, a->vm, 0, MO_32);
488
+ read_neon_element32(rm1, a->vm, 1, MO_32);
489
490
widenfn(rd, rm0);
491
tcg_gen_shli_i64(rd, rd, 8 << a->size);
492
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F16_F32(DisasContext *s, arg_2misc *a)
493
494
fpst = fpstatus_ptr(FPST_STD);
495
ahp = get_ahp_flag();
496
- tmp = neon_load_reg(a->vm, 0);
497
+ tmp = tcg_temp_new_i32();
498
+ read_neon_element32(tmp, a->vm, 0, MO_32);
499
gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp);
500
- tmp2 = neon_load_reg(a->vm, 1);
501
+ tmp2 = tcg_temp_new_i32();
502
+ read_neon_element32(tmp2, a->vm, 1, MO_32);
503
gen_helper_vfp_fcvt_f32_to_f16(tmp2, tmp2, fpst, ahp);
504
tcg_gen_shli_i32(tmp2, tmp2, 16);
505
tcg_gen_or_i32(tmp2, tmp2, tmp);
506
- tcg_temp_free_i32(tmp);
507
- tmp = neon_load_reg(a->vm, 2);
508
+ read_neon_element32(tmp, a->vm, 2, MO_32);
509
gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp);
510
- tmp3 = neon_load_reg(a->vm, 3);
511
- neon_store_reg(a->vd, 0, tmp2);
512
+ tmp3 = tcg_temp_new_i32();
513
+ read_neon_element32(tmp3, a->vm, 3, MO_32);
514
+ write_neon_element32(tmp2, a->vd, 0, MO_32);
515
+ tcg_temp_free_i32(tmp2);
516
gen_helper_vfp_fcvt_f32_to_f16(tmp3, tmp3, fpst, ahp);
517
tcg_gen_shli_i32(tmp3, tmp3, 16);
518
tcg_gen_or_i32(tmp3, tmp3, tmp);
519
- neon_store_reg(a->vd, 1, tmp3);
520
+ write_neon_element32(tmp3, a->vd, 1, MO_32);
521
+ tcg_temp_free_i32(tmp3);
522
tcg_temp_free_i32(tmp);
523
tcg_temp_free_i32(ahp);
524
tcg_temp_free_ptr(fpst);
525
@@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a)
526
fpst = fpstatus_ptr(FPST_STD);
527
ahp = get_ahp_flag();
528
tmp3 = tcg_temp_new_i32();
529
- tmp = neon_load_reg(a->vm, 0);
530
- tmp2 = neon_load_reg(a->vm, 1);
531
+ tmp2 = tcg_temp_new_i32();
532
+ tmp = tcg_temp_new_i32();
533
+ read_neon_element32(tmp, a->vm, 0, MO_32);
534
+ read_neon_element32(tmp2, a->vm, 1, MO_32);
535
tcg_gen_ext16u_i32(tmp3, tmp);
536
gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp);
537
- neon_store_reg(a->vd, 0, tmp3);
538
+ write_neon_element32(tmp3, a->vd, 0, MO_32);
539
tcg_gen_shri_i32(tmp, tmp, 16);
540
gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp);
541
- neon_store_reg(a->vd, 1, tmp);
542
- tmp3 = tcg_temp_new_i32();
543
+ write_neon_element32(tmp, a->vd, 1, MO_32);
544
+ tcg_temp_free_i32(tmp);
545
tcg_gen_ext16u_i32(tmp3, tmp2);
546
gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp);
547
- neon_store_reg(a->vd, 2, tmp3);
548
+ write_neon_element32(tmp3, a->vd, 2, MO_32);
549
+ tcg_temp_free_i32(tmp3);
550
tcg_gen_shri_i32(tmp2, tmp2, 16);
551
gen_helper_vfp_fcvt_f16_to_f32(tmp2, tmp2, fpst, ahp);
552
- neon_store_reg(a->vd, 3, tmp2);
553
+ write_neon_element32(tmp2, a->vd, 3, MO_32);
554
+ tcg_temp_free_i32(tmp2);
555
tcg_temp_free_i32(ahp);
556
tcg_temp_free_ptr(fpst);
557
558
@@ -XXX,XX +XXX,XX @@ DO_2M_CRYPTO(SHA256SU0, aa32_sha2, 2)
559
560
static bool do_2misc(DisasContext *s, arg_2misc *a, NeonGenOneOpFn *fn)
561
{
562
+ TCGv_i32 tmp;
563
int pass;
564
565
/* Handle a 2-reg-misc operation by iterating 32 bits at a time */
566
@@ -XXX,XX +XXX,XX @@ static bool do_2misc(DisasContext *s, arg_2misc *a, NeonGenOneOpFn *fn)
567
return true;
72
return true;
568
}
73
}
569
74
- /* BitCount(list) < 2 is UNPREDICTABLE */
570
+ tmp = tcg_temp_new_i32();
75
- return op_stm(s, a, 2);
571
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
76
+ return op_stm(s, a);
572
- TCGv_i32 tmp = neon_load_reg(a->vm, pass);
573
+ read_neon_element32(tmp, a->vm, pass, MO_32);
574
fn(tmp, tmp);
575
- neon_store_reg(a->vd, pass, tmp);
576
+ write_neon_element32(tmp, a->vd, pass, MO_32);
577
}
578
+ tcg_temp_free_i32(tmp);
579
580
return true;
581
}
77
}
582
@@ -XXX,XX +XXX,XX @@ static bool trans_VTRN(DisasContext *s, arg_2misc *a)
78
79
-static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n)
80
+static bool do_ldm(DisasContext *s, arg_ldst_block *a)
81
{
82
int i, j, n, list, mem_idx;
83
bool loaded_base;
84
@@ -XXX,XX +XXX,XX @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n)
85
86
list = a->list;
87
n = ctpop16(list);
88
- if (n < min_n || a->rn == 15) {
89
+ /*
90
+ * This is UNPREDICTABLE for n < 1 in all encodings, and we choose
91
+ * to UNDEF. In the T32 LDM encoding n == 1 is also UNPREDICTABLE,
92
+ * but hardware treats it like the A32 version and implements the
93
+ * single-register-load, and some in-the-wild (buggy) software
94
+ * assumes that, so we don't UNDEF on that case.
95
+ */
96
+ if (n < 1 || a->rn == 15) {
97
unallocated_encoding(s);
583
return true;
98
return true;
584
}
99
}
585
100
@@ -XXX,XX +XXX,XX @@ static bool trans_LDM_a32(DisasContext *s, arg_ldst_block *a)
586
- if (a->size == 2) {
101
unallocated_encoding(s);
587
+ tmp = tcg_temp_new_i32();
102
return true;
588
+ tmp2 = tcg_temp_new_i32();
589
+ if (a->size == MO_32) {
590
for (pass = 0; pass < (a->q ? 4 : 2); pass += 2) {
591
- tmp = neon_load_reg(a->vm, pass);
592
- tmp2 = neon_load_reg(a->vd, pass + 1);
593
- neon_store_reg(a->vm, pass, tmp2);
594
- neon_store_reg(a->vd, pass + 1, tmp);
595
+ read_neon_element32(tmp, a->vm, pass, MO_32);
596
+ read_neon_element32(tmp2, a->vd, pass + 1, MO_32);
597
+ write_neon_element32(tmp2, a->vm, pass, MO_32);
598
+ write_neon_element32(tmp, a->vd, pass + 1, MO_32);
599
}
600
} else {
601
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
602
- tmp = neon_load_reg(a->vm, pass);
603
- tmp2 = neon_load_reg(a->vd, pass);
604
- if (a->size == 0) {
605
+ read_neon_element32(tmp, a->vm, pass, MO_32);
606
+ read_neon_element32(tmp2, a->vd, pass, MO_32);
607
+ if (a->size == MO_8) {
608
gen_neon_trn_u8(tmp, tmp2);
609
} else {
610
gen_neon_trn_u16(tmp, tmp2);
611
}
612
- neon_store_reg(a->vm, pass, tmp2);
613
- neon_store_reg(a->vd, pass, tmp);
614
+ write_neon_element32(tmp2, a->vm, pass, MO_32);
615
+ write_neon_element32(tmp, a->vd, pass, MO_32);
616
}
617
}
103
}
618
+ tcg_temp_free_i32(tmp);
104
- /* BitCount(list) < 1 is UNPREDICTABLE */
619
+ tcg_temp_free_i32(tmp2);
105
- return do_ldm(s, a, 1);
620
return true;
106
+ return do_ldm(s, a);
621
}
107
}
108
109
static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a)
110
@@ -XXX,XX +XXX,XX @@ static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a)
111
unallocated_encoding(s);
112
return true;
113
}
114
- /* BitCount(list) < 2 is UNPREDICTABLE */
115
- return do_ldm(s, a, 2);
116
+ return do_ldm(s, a);
117
}
118
119
static bool trans_LDM_t16(DisasContext *s, arg_ldst_block *a)
120
{
121
/* Writeback is conditional on the base register not being loaded. */
122
a->w = !(a->list & (1 << a->rn));
123
- /* BitCount(list) < 1 is UNPREDICTABLE */
124
- return do_ldm(s, a, 1);
125
+ return do_ldm(s, a);
126
}
127
128
static bool trans_CLRM(DisasContext *s, arg_CLRM *a)
622
--
129
--
623
2.20.1
130
2.34.1
624
131
625
132
diff view generated by jsdifflib
1
In arm_v7m_mmu_idx_for_secstate() we get the 'priv' level to pass to
1
Update the SMMUv3 ID register bit field definitions to the
2
armv7m_mmu_idx_for_secstate_and_priv() by calling arm_current_el().
2
set in the most recent specification (IHI0700 F.a).
3
This is incorrect when the security state being queried is not the
4
current one, because arm_current_el() uses the current security state
5
to determine which of the banked CONTROL.nPRIV bits to look at.
6
The effect was that if (for instance) Secure state was in privileged
7
mode but Non-Secure was not then we would return the wrong MMU index.
8
9
The only places where we are using this function in a way that could
10
trigger this bug are for the stack loads during a v8M function-return
11
and for the instruction fetch of a v8M SG insn.
12
13
Fix the bug by expanding out the M-profile version of the
14
arm_current_el() logic inline so it can use the passed in secstate
15
rather than env->v7m.secure.
16
3
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20201022164408.13214-1-peter.maydell@linaro.org
6
Reviewed-by: Mostafa Saleh <smostafa@google.com>
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Message-id: 20230914145705.1648377-2-peter.maydell@linaro.org
20
---
9
---
21
target/arm/m_helper.c | 3 ++-
10
hw/arm/smmuv3-internal.h | 38 ++++++++++++++++++++++++++++++++++++++
22
1 file changed, 2 insertions(+), 1 deletion(-)
11
1 file changed, 38 insertions(+)
23
12
24
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
13
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
25
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/m_helper.c
15
--- a/hw/arm/smmuv3-internal.h
27
+++ b/target/arm/m_helper.c
16
+++ b/hw/arm/smmuv3-internal.h
28
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
17
@@ -XXX,XX +XXX,XX @@ REG32(IDR0, 0x0)
29
/* Return the MMU index for a v7M CPU in the specified security state */
18
FIELD(IDR0, S1P, 1 , 1)
30
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
19
FIELD(IDR0, TTF, 2 , 2)
31
{
20
FIELD(IDR0, COHACC, 4 , 1)
32
- bool priv = arm_current_el(env) != 0;
21
+ FIELD(IDR0, BTM, 5 , 1)
33
+ bool priv = arm_v7m_is_handler_mode(env) ||
22
+ FIELD(IDR0, HTTU, 6 , 2)
34
+ !(env->v7m.control[secstate] & 1);
23
+ FIELD(IDR0, DORMHINT, 8 , 1)
35
24
+ FIELD(IDR0, HYP, 9 , 1)
36
return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
25
+ FIELD(IDR0, ATS, 10, 1)
37
}
26
+ FIELD(IDR0, NS1ATS, 11, 1)
27
FIELD(IDR0, ASID16, 12, 1)
28
+ FIELD(IDR0, MSI, 13, 1)
29
+ FIELD(IDR0, SEV, 14, 1)
30
+ FIELD(IDR0, ATOS, 15, 1)
31
+ FIELD(IDR0, PRI, 16, 1)
32
+ FIELD(IDR0, VMW, 17, 1)
33
FIELD(IDR0, VMID16, 18, 1)
34
+ FIELD(IDR0, CD2L, 19, 1)
35
+ FIELD(IDR0, VATOS, 20, 1)
36
FIELD(IDR0, TTENDIAN, 21, 2)
37
+ FIELD(IDR0, ATSRECERR, 23, 1)
38
FIELD(IDR0, STALL_MODEL, 24, 2)
39
FIELD(IDR0, TERM_MODEL, 26, 1)
40
FIELD(IDR0, STLEVEL, 27, 2)
41
+ FIELD(IDR0, RME_IMPL, 30, 1)
42
43
REG32(IDR1, 0x4)
44
FIELD(IDR1, SIDSIZE, 0 , 6)
45
+ FIELD(IDR1, SSIDSIZE, 6 , 5)
46
+ FIELD(IDR1, PRIQS, 11, 5)
47
FIELD(IDR1, EVENTQS, 16, 5)
48
FIELD(IDR1, CMDQS, 21, 5)
49
+ FIELD(IDR1, ATTR_PERMS_OVR, 26, 1)
50
+ FIELD(IDR1, ATTR_TYPES_OVR, 27, 1)
51
+ FIELD(IDR1, REL, 28, 1)
52
+ FIELD(IDR1, QUEUES_PRESET, 29, 1)
53
+ FIELD(IDR1, TABLES_PRESET, 30, 1)
54
+ FIELD(IDR1, ECMDQ, 31, 1)
55
56
#define SMMU_IDR1_SIDSIZE 16
57
#define SMMU_CMDQS 19
58
#define SMMU_EVENTQS 19
59
60
REG32(IDR2, 0x8)
61
+ FIELD(IDR2, BA_VATOS, 0, 10)
62
+
63
REG32(IDR3, 0xc)
64
FIELD(IDR3, HAD, 2, 1);
65
+ FIELD(IDR3, PBHA, 3, 1);
66
+ FIELD(IDR3, XNX, 4, 1);
67
+ FIELD(IDR3, PPS, 5, 1);
68
+ FIELD(IDR3, MPAM, 7, 1);
69
+ FIELD(IDR3, FWB, 8, 1);
70
+ FIELD(IDR3, STT, 9, 1);
71
FIELD(IDR3, RIL, 10, 1);
72
FIELD(IDR3, BBML, 11, 2);
73
+ FIELD(IDR3, E0PD, 13, 1);
74
+ FIELD(IDR3, PTWNNC, 14, 1);
75
+ FIELD(IDR3, DPT, 15, 1);
76
+
77
REG32(IDR4, 0x10)
78
+
79
REG32(IDR5, 0x14)
80
FIELD(IDR5, OAS, 0, 3);
81
FIELD(IDR5, GRAN4K, 4, 1);
82
FIELD(IDR5, GRAN16K, 5, 1);
83
FIELD(IDR5, GRAN64K, 6, 1);
84
+ FIELD(IDR5, VAX, 10, 2);
85
+ FIELD(IDR5, STALL_MAX, 16, 16);
86
87
#define SMMU_IDR5_OAS 4
88
38
--
89
--
39
2.20.1
90
2.34.1
40
41
diff view generated by jsdifflib
1
The helper functions for performing the udot/sdot operations against
1
In smmuv3_init_regs() when we set the various bits in the ID
2
a scalar were not using an address-swizzling macro when converting
2
registers, we do this almost in order of the fields in the
3
the index of the scalar element into a pointer into the vm array.
3
registers, but not quite. Move the initialization of
4
This had no effect on little-endian hosts but meant we generated
4
SMMU_IDR3.RIL and SMMU_IDR5.OAS into their correct places.
5
incorrect results on big-endian hosts.
6
7
For these insns, the index is indexing over group of 4 8-bit values,
8
so 32 bits per indexed entity, and H4() is therefore what we want.
9
(For Neon the only possible input indexes are 0 and 1.)
10
5
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Mostafa Saleh <smostafa@google.com>
14
Message-id: 20201028191712.4910-3-peter.maydell@linaro.org
9
Reviewed-by: Eric Auger <eric.auger@redhat.com>
10
Message-id: 20230914145705.1648377-3-peter.maydell@linaro.org
15
---
11
---
16
target/arm/vec_helper.c | 4 ++--
12
hw/arm/smmuv3.c | 4 ++--
17
1 file changed, 2 insertions(+), 2 deletions(-)
13
1 file changed, 2 insertions(+), 2 deletions(-)
18
14
19
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
15
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/vec_helper.c
17
--- a/hw/arm/smmuv3.c
22
+++ b/target/arm/vec_helper.c
18
+++ b/hw/arm/smmuv3.c
23
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_sdot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc)
19
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
24
intptr_t index = simd_data(desc);
20
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, EVENTQS, SMMU_EVENTQS);
25
uint32_t *d = vd;
21
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS);
26
int8_t *n = vn;
22
27
- int8_t *m_indexed = (int8_t *)vm + index * 4;
23
- s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
28
+ int8_t *m_indexed = (int8_t *)vm + H4(index) * 4;
24
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1);
29
25
+ s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
30
/* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd.
26
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2);
31
* Otherwise opr_sz is a multiple of 16.
27
32
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_udot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc)
28
+ s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */
33
intptr_t index = simd_data(desc);
29
/* 4K, 16K and 64K granule support */
34
uint32_t *d = vd;
30
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1);
35
uint8_t *n = vn;
31
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, 1);
36
- uint8_t *m_indexed = (uint8_t *)vm + index * 4;
32
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, 1);
37
+ uint8_t *m_indexed = (uint8_t *)vm + H4(index) * 4;
33
- s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */
38
34
39
/* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd.
35
s->cmdq.base = deposit64(s->cmdq.base, 0, 5, SMMU_CMDQS);
40
* Otherwise opr_sz is a multiple of 16.
36
s->cmdq.prod = 0;
41
--
37
--
42
2.20.1
38
2.34.1
43
44
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
The SMMUv3.1-XNX feature is mandatory for an SMMUv3.1 if S2P is
2
supported, so we should theoretically have implemented it as part of
3
the recent S2P work. Fortunately, for us the implementation is a
4
no-op.
2
5
3
Use the BIT_ULL() macro to ensure we use 64-bit arithmetic.
6
This feature is about interpretation of the stage 2 page table
4
This fixes the following Coverity issue (OVERFLOW_BEFORE_WIDEN):
7
descriptor XN bits, which control execute permissions.
5
8
6
CID 1432363 (#1 of 1): Unintentional integer overflow:
9
For QEMU, the permission bits passed to an IOMMU (via MemTxAttrs and
10
IOMMUAccessFlags) only indicate read and write; we do not distinguish
11
data reads from instruction reads outside the CPU proper. In the
12
SMMU architecture's terms, our interconnect between the client device
13
and the SMMU doesn't have the ability to convey the INST attribute,
14
and we therefore use the default value of "data" for this attribute.
7
15
8
overflow_before_widen:
16
We also do not support the bits in the Stream Table Entry that can
9
Potentially overflowing expression 1 << scale with type int
17
override the on-the-bus transaction attribute permissions (we do not
10
(32 bits, signed) is evaluated using 32-bit arithmetic, and
18
set SMMU_IDR1.ATTR_PERMS_OVR=1).
11
then used in a context that expects an expression of type
12
hwaddr (64 bits, unsigned).
13
19
14
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
20
These two things together mean that for our implementation, it never
15
Acked-by: Eric Auger <eric.auger@redhat.com>
21
has to deal with transactions with the INST attribute, and so it can
16
Message-id: 20201030144617.1535064-1-philmd@redhat.com
22
correctly ignore the XN bits entirely. So we already implement
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
23
FEAT_XNX's "XN field is now 2 bits, not 1" behaviour to the extent
24
that we need to.
25
26
Advertise the presence of the feature in SMMU_IDR3.XNX.
27
18
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: Mostafa Saleh <smostafa@google.com>
31
Reviewed-by: Eric Auger <eric.auger@redhat.com>
32
Message-id: 20230914145705.1648377-4-peter.maydell@linaro.org
19
---
33
---
20
hw/arm/smmuv3.c | 3 ++-
34
hw/arm/smmuv3.c | 4 ++++
21
1 file changed, 2 insertions(+), 1 deletion(-)
35
1 file changed, 4 insertions(+)
22
36
23
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
37
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
24
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/arm/smmuv3.c
39
--- a/hw/arm/smmuv3.c
26
+++ b/hw/arm/smmuv3.c
40
+++ b/hw/arm/smmuv3.c
27
@@ -XXX,XX +XXX,XX @@
41
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
28
*/
42
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS);
29
43
30
#include "qemu/osdep.h"
44
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1);
31
+#include "qemu/bitops.h"
45
+ if (FIELD_EX32(s->idr[0], IDR0, S2P)) {
32
#include "hw/irq.h"
46
+ /* XNX is a stage-2-specific feature */
33
#include "hw/sysbus.h"
47
+ s->idr[3] = FIELD_DP32(s->idr[3], IDR3, XNX, 1);
34
#include "migration/vmstate.h"
48
+ }
35
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
49
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
36
scale = CMD_SCALE(cmd);
50
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2);
37
num = CMD_NUM(cmd);
51
38
ttl = CMD_TTL(cmd);
39
- num_pages = (num + 1) * (1 << (scale));
40
+ num_pages = (num + 1) * BIT_ULL(scale);
41
}
42
43
if (type == SMMU_CMD_TLBI_NH_VA) {
44
--
52
--
45
2.20.1
53
2.34.1
46
47
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
FEAT_HPMN0 is a small feature which defines that it is valid for
2
MDCR_EL2.HPMN to be set to 0, meaning "no PMU event counters provided
3
to an EL1 guest" (previously this setting was reserved). QEMU's
4
implementation almost gets HPMN == 0 right, but we need to fix
5
one check in pmevcntr_is_64_bit(). That is enough for us to
6
advertise the feature in the 'max' CPU.
2
7
3
HCR should be applied when NS is set, not when it is cleared.
8
(We don't need to make the behaviour conditional on feature
9
presence, because the FEAT_HPMN0 behaviour is within the range
10
of permitted UNPREDICTABLE behaviour for a non-FEAT_HPMN0
11
implementation.)
4
12
5
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20230921185445.3339214-1-peter.maydell@linaro.org
8
---
16
---
9
target/arm/helper.c | 5 ++---
17
docs/system/arm/emulation.rst | 1 +
10
1 file changed, 2 insertions(+), 3 deletions(-)
18
target/arm/helper.c | 2 +-
19
target/arm/tcg/cpu32.c | 4 ++++
20
target/arm/tcg/cpu64.c | 1 +
21
4 files changed, 7 insertions(+), 1 deletion(-)
11
22
23
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
24
index XXXXXXX..XXXXXXX 100644
25
--- a/docs/system/arm/emulation.rst
26
+++ b/docs/system/arm/emulation.rst
27
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
28
- FEAT_HCX (Support for the HCRX_EL2 register)
29
- FEAT_HPDS (Hierarchical permission disables)
30
- FEAT_HPDS2 (Translation table page-based hardware attributes)
31
+- FEAT_HPMN0 (Setting of MDCR_EL2.HPMN to zero)
32
- FEAT_I8MM (AArch64 Int8 matrix multiplication instructions)
33
- FEAT_IDST (ID space trap handling)
34
- FEAT_IESB (Implicit error synchronization event)
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
37
--- a/target/arm/helper.c
15
+++ b/target/arm/helper.c
38
+++ b/target/arm/helper.c
16
@@ -XXX,XX +XXX,XX @@ static void tlbimvaa_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
39
@@ -XXX,XX +XXX,XX @@ static bool pmevcntr_is_64_bit(CPUARMState *env, int counter)
17
40
bool hlp = env->cp15.mdcr_el2 & MDCR_HLP;
18
/*
41
int hpmn = env->cp15.mdcr_el2 & MDCR_HPMN;
19
* Non-IS variants of TLB operations are upgraded to
42
20
- * IS versions if we are at NS EL1 and HCR_EL2.FB is set to
43
- if (hpmn != 0 && counter >= hpmn) {
21
+ * IS versions if we are at EL1 and HCR_EL2.FB is effectively set to
44
+ if (counter >= hpmn) {
22
* force broadcast of these operations.
45
return hlp;
23
*/
46
}
24
static bool tlb_force_broadcast(CPUARMState *env)
47
}
25
{
48
diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c
26
- return (env->cp15.hcr_el2 & HCR_FB) &&
49
index XXXXXXX..XXXXXXX 100644
27
- arm_current_el(env) == 1 && arm_is_secure_below_el3(env);
50
--- a/target/arm/tcg/cpu32.c
28
+ return arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_FB);
51
+++ b/target/arm/tcg/cpu32.c
52
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
53
t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */
54
t = FIELD_DP32(t, ID_DFR0, PERFMON, 6); /* FEAT_PMUv3p5 */
55
cpu->isar.id_dfr0 = t;
56
+
57
+ t = cpu->isar.id_dfr1;
58
+ t = FIELD_DP32(t, ID_DFR1, HPMN0, 1); /* FEAT_HPMN0 */
59
+ cpu->isar.id_dfr1 = t;
29
}
60
}
30
61
31
static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri,
62
/* CPU models. These are not needed for the AArch64 linux-user build. */
63
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/tcg/cpu64.c
66
+++ b/target/arm/tcg/cpu64.c
67
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
68
t = cpu->isar.id_aa64dfr0;
69
t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */
70
t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */
71
+ t = FIELD_DP64(t, ID_AA64DFR0, HPMN0, 1); /* FEAT_HPMN0 */
72
cpu->isar.id_aa64dfr0 = t;
73
74
t = cpu->isar.id_aa64smfr0;
32
--
75
--
33
2.20.1
76
2.34.1
34
35
diff view generated by jsdifflib
1
The kerneldoc script currently emits Sphinx markup for a macro with
1
The include of hw/arm/virt.h in kvm64.c is unnecessary and also a
2
arguments that uses the c:function directive. This is correct for
2
layering violation since the generic KVM code shouldn't need to know
3
Sphinx versions earlier than Sphinx 3, where c:macro doesn't allow
3
anything about board-specifics. The include line is an accidental
4
documentation of macros with arguments and c:function is not picky
4
leftover from commit 15613357ba53a4763, where we cleaned up the code
5
about the syntax of what it is passed. However, in Sphinx 3 the
5
to not depend on virt board internals but forgot to also remove the
6
c:macro directive was enhanced to support macros with arguments,
6
now-redundant include line.
7
and c:function was made more picky about what syntax it accepted.
8
9
When kerneldoc is told that it needs to produce output for Sphinx
10
3 or later, make it emit c:function only for functions and c:macro
11
for macros with arguments. We assume that anything with a return
12
type is a function and anything without is a macro.
13
14
This fixes the Sphinx error:
15
16
/home/petmay01/linaro/qemu-from-laptop/qemu/docs/../include/qom/object.h:155:Error in declarator
17
If declarator-id with parameters (e.g., 'void f(int arg)'):
18
Invalid C declaration: Expected identifier in nested name. [error at 25]
19
DECLARE_INSTANCE_CHECKER ( InstanceType, OBJ_NAME, TYPENAME)
20
-------------------------^
21
If parenthesis in noptr-declarator (e.g., 'void (*f(int arg))(double)'):
22
Error in declarator or parameters
23
Invalid C declaration: Expecting "(" in parameters. [error at 39]
24
DECLARE_INSTANCE_CHECKER ( InstanceType, OBJ_NAME, TYPENAME)
25
---------------------------------------^
26
7
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
9
Reviewed-by: Gavin Shan <gshan@redhat.com>
29
Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
30
Message-id: 20201030174700.7204-2-peter.maydell@linaro.org
11
Message-id: 20230925110429.3917202-1-peter.maydell@linaro.org
31
---
12
---
32
scripts/kernel-doc | 18 +++++++++++++++++-
13
target/arm/kvm64.c | 1 -
33
1 file changed, 17 insertions(+), 1 deletion(-)
14
1 file changed, 1 deletion(-)
34
15
35
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
16
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
36
index XXXXXXX..XXXXXXX 100755
17
index XXXXXXX..XXXXXXX 100644
37
--- a/scripts/kernel-doc
18
--- a/target/arm/kvm64.c
38
+++ b/scripts/kernel-doc
19
+++ b/target/arm/kvm64.c
39
@@ -XXX,XX +XXX,XX @@ sub output_function_rst(%) {
20
@@ -XXX,XX +XXX,XX @@
40
    output_highlight_rst($args{'purpose'});
21
#include "internals.h"
41
    $start = "\n\n**Syntax**\n\n ``";
22
#include "hw/acpi/acpi.h"
42
} else {
23
#include "hw/acpi/ghes.h"
43
-    print ".. c:function:: ";
24
-#include "hw/arm/virt.h"
44
+ if ((split(/\./, $sphinx_version))[0] >= 3) {
25
45
+ # Sphinx 3 and later distinguish macros and functions and
26
static bool have_guest_debug;
46
+ # complain if you use c:function with something that's not
27
47
+ # syntactically valid as a function declaration.
48
+ # We assume that anything with a return type is a function
49
+ # and anything without is a macro.
50
+ if ($args{'functiontype'} ne "") {
51
+ print ".. c:function:: ";
52
+ } else {
53
+ print ".. c:macro:: ";
54
+ }
55
+ } else {
56
+ # Older Sphinx don't support documenting macros that take
57
+ # arguments with c:macro, and don't complain about the use
58
+ # of c:function for this.
59
+ print ".. c:function:: ";
60
+ }
61
}
62
if ($args{'functiontype'} ne "") {
63
    $start .= $args{'functiontype'} . " " . $args{'function'} . " (";
64
--
28
--
65
2.20.1
29
2.34.1
66
30
67
31
diff view generated by jsdifflib
1
In the neon_padd/pmax/pmin helpers for float16, a cut-and-paste error
1
The hw/arm/boot.h include in common-semi-target.h is not actually
2
meant we were using the H4() address swizzler macro rather than the
2
needed, and it's a bit odd because it pulls a hw/arm header into a
3
H2() which is required for 2-byte data. This had no effect on
3
target/arm file.
4
little-endian hosts but meant we put the result data into the
4
5
destination Dreg in the wrong order on big-endian hosts.
5
This include was originally needed because the semihosting code used
6
the arm_boot_info struct to get the base address of the RAM in system
7
emulation, to use in a (bad) heuristic for the return values for the
8
SYS_HEAPINFO semihosting call. We've since overhauled how we
9
calculate the HEAPINFO values in system emulation, and the code no
10
longer uses the arm_boot_info struct.
11
12
Remove the now-redundant include line, and instead directly include
13
the cpu-qom.h header that we were previously getting via boot.h.
6
14
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20230925112219.3919261-1-peter.maydell@linaro.org
10
Message-id: 20201028191712.4910-2-peter.maydell@linaro.org
11
---
18
---
12
target/arm/vec_helper.c | 8 ++++----
19
target/arm/common-semi-target.h | 4 +---
13
1 file changed, 4 insertions(+), 4 deletions(-)
20
1 file changed, 1 insertion(+), 3 deletions(-)
14
21
15
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
22
diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.h
16
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/vec_helper.c
24
--- a/target/arm/common-semi-target.h
18
+++ b/target/arm/vec_helper.c
25
+++ b/target/arm/common-semi-target.h
19
@@ -XXX,XX +XXX,XX @@ DO_ABA(gvec_uaba_d, uint64_t)
26
@@ -XXX,XX +XXX,XX @@
20
r2 = float16_##OP(m[H2(0)], m[H2(1)], fpst); \
27
#ifndef TARGET_ARM_COMMON_SEMI_TARGET_H
21
r3 = float16_##OP(m[H2(2)], m[H2(3)], fpst); \
28
#define TARGET_ARM_COMMON_SEMI_TARGET_H
22
\
29
23
- d[H4(0)] = r0; \
30
-#ifndef CONFIG_USER_ONLY
24
- d[H4(1)] = r1; \
31
-#include "hw/arm/boot.h"
25
- d[H4(2)] = r2; \
32
-#endif
26
- d[H4(3)] = r3; \
33
+#include "target/arm/cpu-qom.h"
27
+ d[H2(0)] = r0; \
34
28
+ d[H2(1)] = r1; \
35
static inline target_ulong common_semi_arg(CPUState *cs, int argno)
29
+ d[H2(2)] = r2; \
36
{
30
+ d[H2(3)] = r3; \
31
}
32
33
DO_NEON_PAIRWISE(neon_padd, add)
34
--
37
--
35
2.20.1
38
2.34.1
36
37
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
The code for powering on a CPU in arm-powerctl.c has two separate
2
2
use cases:
3
Replace all uses of neon_load/store_reg64 within translate-neon.c.inc.
3
* emulation of a real hardware power controller
4
4
* emulation of firmware interfaces (primarily PSCI) with
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
CPU on/off APIs
6
Message-id: 20201030022618.785675-9-richard.henderson@linaro.org
6
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
For the first case, we only need to reset the CPU and set its
8
starting PC and X0. For the second case, because we're emulating the
9
firmware we need to ensure that it's in the state that the firmware
10
provides. In particular, when we reset to a lower EL than the
11
highest one we are emulating, we need to put the CPU into a state
12
that permits correct running at that lower EL. We already do a
13
little of this in arm-powerctl.c (for instance we set SCR_HCE to
14
enable the HVC insn) but we don't do enough of it. This means that
15
in the case where we are emulating EL3 but also providing emulated
16
PSCI the guest will crash when a secondary core tries to use a
17
feature that needs an SCR_EL3 bit to be set, such as MTE or PAuth.
18
19
The hw/arm/boot.c code also has to support this "start guest code in
20
an EL that's lower than the highest emulated EL" case in order to do
21
direct guest kernel booting; it has all the necessary initialization
22
code to set the SCR_EL3 bits. Pull the relevant boot.c code out into
23
a separate function so we can share it between there and
24
arm-powerctl.c.
25
26
This refactoring has a few code changes that look like they
27
might be behaviour changes but aren't:
28
* if info->secure_boot is false and info->secure_board_setup is
29
true, then the old code would start the first CPU in Hyp
30
mode but without changing SCR.NS and NSACR.{CP11,CP10}.
31
This was wrong behaviour because there's no such thing
32
as Secure Hyp mode. The new code will leave the CPU in SVC.
33
(There is no board which sets secure_boot to false and
34
secure_board_setup to true, so this isn't a behaviour
35
change for any of our boards.)
36
* we don't explicitly clear SCR.NS when arm-powerctl.c
37
does a CPU-on to EL3. This was a no-op because CPU reset
38
will reset to NS == 0.
39
40
And some real behaviour changes:
41
* we no longer set HCR_EL2.RW when booting into EL2: the guest
42
can and should do that themselves before dropping into their
43
EL1 code. (arm-powerctl and boot did this differently; I
44
opted to use the logic from arm-powerctl, which only sets
45
HCR_EL2.RW when it's directly starting the guest in EL1,
46
because it's more correct, and I don't expect guests to be
47
accidentally depending on our having set the RW bit for them.)
48
* if we are booting a CPU into AArch32 Secure SVC then we won't
49
set SCR.HCE any more. This affects only the vexpress-a15 and
50
raspi2b machine types. Guests booting in this case will either:
51
- be able to set SCR.HCE themselves as part of moving from
52
Secure SVC into NS Hyp mode
53
- will move from Secure SVC to NS SVC, and won't care about
54
behaviour of the HVC insn
55
- will stay in Secure SVC, and won't care about HVC
56
* on an arm-powerctl CPU-on we will now set the SCR bits for
57
pauth/mte/sve/sme/hcx/fgt features
58
59
The first two of these are very minor and I don't expect guest
60
code to trip over them, so I didn't judge it worth convoluting
61
the code in an attempt to keep exactly the same boot.c behaviour.
62
The third change fixes issue 1899.
63
64
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1899
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
65
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
66
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
67
Message-id: 20230926155619.4028618-1-peter.maydell@linaro.org
9
---
68
---
10
target/arm/translate.c | 26 +++++++++
69
target/arm/cpu.h | 22 +++++++++
11
target/arm/translate-neon.c.inc | 94 ++++++++++++++++-----------------
70
hw/arm/boot.c | 95 ++++++++++-----------------------------
12
2 files changed, 73 insertions(+), 47 deletions(-)
71
target/arm/arm-powerctl.c | 53 +---------------------
13
72
target/arm/cpu.c | 95 +++++++++++++++++++++++++++++++++++++++
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
73
4 files changed, 141 insertions(+), 124 deletions(-)
74
75
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
index XXXXXXX..XXXXXXX 100644
76
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.c
77
--- a/target/arm/cpu.h
17
+++ b/target/arm/translate.c
78
+++ b/target/arm/cpu.h
18
@@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop)
79
@@ -XXX,XX +XXX,XX @@ int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
80
int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
81
int cpuid, DumpState *s);
82
83
+/**
84
+ * arm_emulate_firmware_reset: Emulate firmware CPU reset handling
85
+ * @cpu: CPU (which must have been freshly reset)
86
+ * @target_el: exception level to put the CPU into
87
+ * @secure: whether to put the CPU in secure state
88
+ *
89
+ * When QEMU is directly running a guest kernel at a lower level than
90
+ * EL3 it implicitly emulates some aspects of the guest firmware.
91
+ * This includes that on reset we need to configure the parts of the
92
+ * CPU corresponding to EL3 so that the real guest code can run at its
93
+ * lower exception level. This function does that post-reset CPU setup,
94
+ * for when we do direct boot of a guest kernel, and for when we
95
+ * emulate PSCI and similar firmware interfaces starting a CPU at a
96
+ * lower exception level.
97
+ *
98
+ * @target_el must be an EL implemented by the CPU between 1 and 3.
99
+ * We do not support dropping into a Secure EL other than 3.
100
+ *
101
+ * It is the responsibility of the caller to call arm_rebuild_hflags().
102
+ */
103
+void arm_emulate_firmware_reset(CPUState *cpustate, int target_el);
104
+
105
#ifdef TARGET_AARCH64
106
int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
107
int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
108
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
109
index XXXXXXX..XXXXXXX 100644
110
--- a/hw/arm/boot.c
111
+++ b/hw/arm/boot.c
112
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
113
114
cpu_set_pc(cs, entry);
115
} else {
116
- /* If we are booting Linux then we need to check whether we are
117
- * booting into secure or non-secure state and adjust the state
118
- * accordingly. Out of reset, ARM is defined to be in secure state
119
- * (SCR.NS = 0), we change that here if non-secure boot has been
120
- * requested.
121
+ /*
122
+ * If we are booting Linux then we might need to do so at:
123
+ * - AArch64 NS EL2 or NS EL1
124
+ * - AArch32 Secure SVC (EL3)
125
+ * - AArch32 NS Hyp (EL2)
126
+ * - AArch32 NS SVC (EL1)
127
+ * Configure the CPU in the way boot firmware would do to
128
+ * drop us down to the appropriate level.
129
*/
130
- if (arm_feature(env, ARM_FEATURE_EL3)) {
131
- /* AArch64 is defined to come out of reset into EL3 if enabled.
132
- * If we are booting Linux then we need to adjust our EL as
133
- * Linux expects us to be in EL2 or EL1. AArch32 resets into
134
- * SVC, which Linux expects, so no privilege/exception level to
135
- * adjust.
136
- */
137
- if (env->aarch64) {
138
- env->cp15.scr_el3 |= SCR_RW;
139
- if (arm_feature(env, ARM_FEATURE_EL2)) {
140
- env->cp15.hcr_el2 |= HCR_RW;
141
- env->pstate = PSTATE_MODE_EL2h;
142
- } else {
143
- env->pstate = PSTATE_MODE_EL1h;
144
- }
145
- if (cpu_isar_feature(aa64_pauth, cpu)) {
146
- env->cp15.scr_el3 |= SCR_API | SCR_APK;
147
- }
148
- if (cpu_isar_feature(aa64_mte, cpu)) {
149
- env->cp15.scr_el3 |= SCR_ATA;
150
- }
151
- if (cpu_isar_feature(aa64_sve, cpu)) {
152
- env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK;
153
- env->vfp.zcr_el[3] = 0xf;
154
- }
155
- if (cpu_isar_feature(aa64_sme, cpu)) {
156
- env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK;
157
- env->cp15.scr_el3 |= SCR_ENTP2;
158
- env->vfp.smcr_el[3] = 0xf;
159
- }
160
- if (cpu_isar_feature(aa64_hcx, cpu)) {
161
- env->cp15.scr_el3 |= SCR_HXEN;
162
- }
163
- if (cpu_isar_feature(aa64_fgt, cpu)) {
164
- env->cp15.scr_el3 |= SCR_FGTEN;
165
- }
166
+ int target_el = arm_feature(env, ARM_FEATURE_EL2) ? 2 : 1;
167
168
- /* AArch64 kernels never boot in secure mode */
169
- assert(!info->secure_boot);
170
- /* This hook is only supported for AArch32 currently:
171
- * bootloader_aarch64[] will not call the hook, and
172
- * the code above has already dropped us into EL2 or EL1.
173
- */
174
- assert(!info->secure_board_setup);
175
- }
176
-
177
- if (arm_feature(env, ARM_FEATURE_EL2)) {
178
- /* If we have EL2 then Linux expects the HVC insn to work */
179
- env->cp15.scr_el3 |= SCR_HCE;
180
- }
181
-
182
- /* Set to non-secure if not a secure boot */
183
- if (!info->secure_boot &&
184
- (cs != first_cpu || !info->secure_board_setup)) {
185
- /* Linux expects non-secure state */
186
- env->cp15.scr_el3 |= SCR_NS;
187
- /* Set NSACR.{CP11,CP10} so NS can access the FPU */
188
- env->cp15.nsacr |= 3 << 10;
189
- }
190
- }
191
-
192
- if (!env->aarch64 && !info->secure_boot &&
193
- arm_feature(env, ARM_FEATURE_EL2)) {
194
+ if (env->aarch64) {
195
/*
196
- * This is an AArch32 boot not to Secure state, and
197
- * we have Hyp mode available, so boot the kernel into
198
- * Hyp mode. This is not how the CPU comes out of reset,
199
- * so we need to manually put it there.
200
+ * AArch64 kernels never boot in secure mode, and we don't
201
+ * support the secure_board_setup hook for AArch64.
202
*/
203
- cpsr_write(env, ARM_CPU_MODE_HYP, CPSR_M, CPSRWriteRaw);
204
+ assert(!info->secure_boot);
205
+ assert(!info->secure_board_setup);
206
+ } else {
207
+ if (arm_feature(env, ARM_FEATURE_EL3) &&
208
+ (info->secure_boot ||
209
+ (info->secure_board_setup && cs == first_cpu))) {
210
+ /* Start this CPU in Secure SVC */
211
+ target_el = 3;
212
+ }
213
}
214
215
+ arm_emulate_firmware_reset(cs, target_el);
216
+
217
if (cs == first_cpu) {
218
AddressSpace *as = arm_boot_address_space(cpu, info);
219
220
diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c
221
index XXXXXXX..XXXXXXX 100644
222
--- a/target/arm/arm-powerctl.c
223
+++ b/target/arm/arm-powerctl.c
224
@@ -XXX,XX +XXX,XX @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state,
225
226
/* Initialize the cpu we are turning on */
227
cpu_reset(target_cpu_state);
228
+ arm_emulate_firmware_reset(target_cpu_state, info->target_el);
229
target_cpu_state->halted = 0;
230
231
- if (info->target_aa64) {
232
- if ((info->target_el < 3) && arm_feature(&target_cpu->env,
233
- ARM_FEATURE_EL3)) {
234
- /*
235
- * As target mode is AArch64, we need to set lower
236
- * exception level (the requested level 2) to AArch64
237
- */
238
- target_cpu->env.cp15.scr_el3 |= SCR_RW;
239
- }
240
-
241
- if ((info->target_el < 2) && arm_feature(&target_cpu->env,
242
- ARM_FEATURE_EL2)) {
243
- /*
244
- * As target mode is AArch64, we need to set lower
245
- * exception level (the requested level 1) to AArch64
246
- */
247
- target_cpu->env.cp15.hcr_el2 |= HCR_RW;
248
- }
249
-
250
- target_cpu->env.pstate = aarch64_pstate_mode(info->target_el, true);
251
- } else {
252
- /* We are requested to boot in AArch32 mode */
253
- static const uint32_t mode_for_el[] = { 0,
254
- ARM_CPU_MODE_SVC,
255
- ARM_CPU_MODE_HYP,
256
- ARM_CPU_MODE_SVC };
257
-
258
- cpsr_write(&target_cpu->env, mode_for_el[info->target_el], CPSR_M,
259
- CPSRWriteRaw);
260
- }
261
-
262
- if (info->target_el == 3) {
263
- /* Processor is in secure mode */
264
- target_cpu->env.cp15.scr_el3 &= ~SCR_NS;
265
- } else {
266
- /* Processor is not in secure mode */
267
- target_cpu->env.cp15.scr_el3 |= SCR_NS;
268
-
269
- /* Set NSACR.{CP11,CP10} so NS can access the FPU */
270
- target_cpu->env.cp15.nsacr |= 3 << 10;
271
-
272
- /*
273
- * If QEMU is providing the equivalent of EL3 firmware, then we need
274
- * to make sure a CPU targeting EL2 comes out of reset with a
275
- * functional HVC insn.
276
- */
277
- if (arm_feature(&target_cpu->env, ARM_FEATURE_EL3)
278
- && info->target_el == 2) {
279
- target_cpu->env.cp15.scr_el3 |= SCR_HCE;
280
- }
281
- }
282
-
283
/* We check if the started CPU is now at the correct level */
284
assert(info->target_el == arm_current_el(&target_cpu->env));
285
286
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
287
index XXXXXXX..XXXXXXX 100644
288
--- a/target/arm/cpu.c
289
+++ b/target/arm/cpu.c
290
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj)
19
}
291
}
20
}
292
}
21
293
22
+static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop)
294
+void arm_emulate_firmware_reset(CPUState *cpustate, int target_el)
23
+{
295
+{
24
+ long off = neon_element_offset(reg, ele, memop);
296
+ ARMCPU *cpu = ARM_CPU(cpustate);
25
+
297
+ CPUARMState *env = &cpu->env;
26
+ switch (memop) {
298
+ bool have_el3 = arm_feature(env, ARM_FEATURE_EL3);
27
+ case MO_Q:
299
+ bool have_el2 = arm_feature(env, ARM_FEATURE_EL2);
28
+ tcg_gen_ld_i64(dest, cpu_env, off);
300
+
301
+ /*
302
+ * Check we have the EL we're aiming for. If that is the
303
+ * highest implemented EL, then cpu_reset has already done
304
+ * all the work.
305
+ */
306
+ switch (target_el) {
307
+ case 3:
308
+ assert(have_el3);
309
+ return;
310
+ case 2:
311
+ assert(have_el2);
312
+ if (!have_el3) {
313
+ return;
314
+ }
315
+ break;
316
+ case 1:
317
+ if (!have_el3 && !have_el2) {
318
+ return;
319
+ }
29
+ break;
320
+ break;
30
+ default:
321
+ default:
31
+ g_assert_not_reached();
322
+ g_assert_not_reached();
32
+ }
323
+ }
33
+}
324
+
34
+
325
+ if (have_el3) {
35
static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop)
326
+ /*
36
{
327
+ * Set the EL3 state so code can run at EL2. This should match
37
long off = neon_element_offset(reg, ele, memop);
328
+ * the requirements set by Linux in its booting spec.
38
@@ -XXX,XX +XXX,XX @@ static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop)
329
+ */
39
}
330
+ if (env->aarch64) {
40
}
331
+ env->cp15.scr_el3 |= SCR_RW;
41
332
+ if (cpu_isar_feature(aa64_pauth, cpu)) {
42
+static void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop)
333
+ env->cp15.scr_el3 |= SCR_API | SCR_APK;
43
+{
334
+ }
44
+ long off = neon_element_offset(reg, ele, memop);
335
+ if (cpu_isar_feature(aa64_mte, cpu)) {
45
+
336
+ env->cp15.scr_el3 |= SCR_ATA;
46
+ switch (memop) {
337
+ }
47
+ case MO_64:
338
+ if (cpu_isar_feature(aa64_sve, cpu)) {
48
+ tcg_gen_st_i64(src, cpu_env, off);
339
+ env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK;
49
+ break;
340
+ env->vfp.zcr_el[3] = 0xf;
50
+ default:
341
+ }
51
+ g_assert_not_reached();
342
+ if (cpu_isar_feature(aa64_sme, cpu)) {
343
+ env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK;
344
+ env->cp15.scr_el3 |= SCR_ENTP2;
345
+ env->vfp.smcr_el[3] = 0xf;
346
+ }
347
+ if (cpu_isar_feature(aa64_hcx, cpu)) {
348
+ env->cp15.scr_el3 |= SCR_HXEN;
349
+ }
350
+ if (cpu_isar_feature(aa64_fgt, cpu)) {
351
+ env->cp15.scr_el3 |= SCR_FGTEN;
352
+ }
353
+ }
354
+
355
+ if (target_el == 2) {
356
+ /* If the guest is at EL2 then Linux expects the HVC insn to work */
357
+ env->cp15.scr_el3 |= SCR_HCE;
358
+ }
359
+
360
+ /* Put CPU into non-secure state */
361
+ env->cp15.scr_el3 |= SCR_NS;
362
+ /* Set NSACR.{CP11,CP10} so NS can access the FPU */
363
+ env->cp15.nsacr |= 3 << 10;
364
+ }
365
+
366
+ if (have_el2 && target_el < 2) {
367
+ /* Set EL2 state so code can run at EL1. */
368
+ if (env->aarch64) {
369
+ env->cp15.hcr_el2 |= HCR_RW;
370
+ }
371
+ }
372
+
373
+ /* Set the CPU to the desired state */
374
+ if (env->aarch64) {
375
+ env->pstate = aarch64_pstate_mode(target_el, true);
376
+ } else {
377
+ static const uint32_t mode_for_el[] = {
378
+ 0,
379
+ ARM_CPU_MODE_SVC,
380
+ ARM_CPU_MODE_HYP,
381
+ ARM_CPU_MODE_SVC,
382
+ };
383
+
384
+ cpsr_write(env, mode_for_el[target_el], CPSR_M, CPSRWriteRaw);
52
+ }
385
+ }
53
+}
386
+}
54
+
387
+
55
static TCGv_ptr vfp_reg_ptr(bool dp, int reg)
388
+
56
{
389
#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
57
TCGv_ptr ret = tcg_temp_new_ptr();
390
58
diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc
391
static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/translate-neon.c.inc
61
+++ b/target/arm/translate-neon.c.inc
62
@@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a,
63
for (pass = 0; pass < a->q + 1; pass++) {
64
TCGv_i64 tmp = tcg_temp_new_i64();
65
66
- neon_load_reg64(tmp, a->vm + pass);
67
+ read_neon_element64(tmp, a->vm, pass, MO_64);
68
fn(tmp, cpu_env, tmp, constimm);
69
- neon_store_reg64(tmp, a->vd + pass);
70
+ write_neon_element64(tmp, a->vd, pass, MO_64);
71
tcg_temp_free_i64(tmp);
72
}
73
tcg_temp_free_i64(constimm);
74
@@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a,
75
rd = tcg_temp_new_i32();
76
77
/* Load both inputs first to avoid potential overwrite if rm == rd */
78
- neon_load_reg64(rm1, a->vm);
79
- neon_load_reg64(rm2, a->vm + 1);
80
+ read_neon_element64(rm1, a->vm, 0, MO_64);
81
+ read_neon_element64(rm2, a->vm, 1, MO_64);
82
83
shiftfn(rm1, rm1, constimm);
84
narrowfn(rd, cpu_env, rm1);
85
@@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a,
86
tcg_gen_shli_i64(tmp, tmp, a->shift);
87
tcg_gen_andi_i64(tmp, tmp, ~widen_mask);
88
}
89
- neon_store_reg64(tmp, a->vd);
90
+ write_neon_element64(tmp, a->vd, 0, MO_64);
91
92
widenfn(tmp, rm1);
93
tcg_temp_free_i32(rm1);
94
@@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a,
95
tcg_gen_shli_i64(tmp, tmp, a->shift);
96
tcg_gen_andi_i64(tmp, tmp, ~widen_mask);
97
}
98
- neon_store_reg64(tmp, a->vd + 1);
99
+ write_neon_element64(tmp, a->vd, 1, MO_64);
100
tcg_temp_free_i64(tmp);
101
return true;
102
}
103
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
104
rm_64 = tcg_temp_new_i64();
105
106
if (src1_wide) {
107
- neon_load_reg64(rn0_64, a->vn);
108
+ read_neon_element64(rn0_64, a->vn, 0, MO_64);
109
} else {
110
TCGv_i32 tmp = tcg_temp_new_i32();
111
read_neon_element32(tmp, a->vn, 0, MO_32);
112
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
113
* avoid incorrect results if a narrow input overlaps with the result.
114
*/
115
if (src1_wide) {
116
- neon_load_reg64(rn1_64, a->vn + 1);
117
+ read_neon_element64(rn1_64, a->vn, 1, MO_64);
118
} else {
119
TCGv_i32 tmp = tcg_temp_new_i32();
120
read_neon_element32(tmp, a->vn, 1, MO_32);
121
@@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a,
122
rm = tcg_temp_new_i32();
123
read_neon_element32(rm, a->vm, 1, MO_32);
124
125
- neon_store_reg64(rn0_64, a->vd);
126
+ write_neon_element64(rn0_64, a->vd, 0, MO_64);
127
128
widenfn(rm_64, rm);
129
tcg_temp_free_i32(rm);
130
opfn(rn1_64, rn1_64, rm_64);
131
- neon_store_reg64(rn1_64, a->vd + 1);
132
+ write_neon_element64(rn1_64, a->vd, 1, MO_64);
133
134
tcg_temp_free_i64(rn0_64);
135
tcg_temp_free_i64(rn1_64);
136
@@ -XXX,XX +XXX,XX @@ static bool do_narrow_3d(DisasContext *s, arg_3diff *a,
137
rd0 = tcg_temp_new_i32();
138
rd1 = tcg_temp_new_i32();
139
140
- neon_load_reg64(rn_64, a->vn);
141
- neon_load_reg64(rm_64, a->vm);
142
+ read_neon_element64(rn_64, a->vn, 0, MO_64);
143
+ read_neon_element64(rm_64, a->vm, 0, MO_64);
144
145
opfn(rn_64, rn_64, rm_64);
146
147
narrowfn(rd0, rn_64);
148
149
- neon_load_reg64(rn_64, a->vn + 1);
150
- neon_load_reg64(rm_64, a->vm + 1);
151
+ read_neon_element64(rn_64, a->vn, 1, MO_64);
152
+ read_neon_element64(rm_64, a->vm, 1, MO_64);
153
154
opfn(rn_64, rn_64, rm_64);
155
156
@@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a,
157
/* Don't store results until after all loads: they might overlap */
158
if (accfn) {
159
tmp = tcg_temp_new_i64();
160
- neon_load_reg64(tmp, a->vd);
161
+ read_neon_element64(tmp, a->vd, 0, MO_64);
162
accfn(tmp, tmp, rd0);
163
- neon_store_reg64(tmp, a->vd);
164
- neon_load_reg64(tmp, a->vd + 1);
165
+ write_neon_element64(tmp, a->vd, 0, MO_64);
166
+ read_neon_element64(tmp, a->vd, 1, MO_64);
167
accfn(tmp, tmp, rd1);
168
- neon_store_reg64(tmp, a->vd + 1);
169
+ write_neon_element64(tmp, a->vd, 1, MO_64);
170
tcg_temp_free_i64(tmp);
171
} else {
172
- neon_store_reg64(rd0, a->vd);
173
- neon_store_reg64(rd1, a->vd + 1);
174
+ write_neon_element64(rd0, a->vd, 0, MO_64);
175
+ write_neon_element64(rd1, a->vd, 1, MO_64);
176
}
177
178
tcg_temp_free_i64(rd0);
179
@@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a,
180
181
if (accfn) {
182
TCGv_i64 t64 = tcg_temp_new_i64();
183
- neon_load_reg64(t64, a->vd);
184
+ read_neon_element64(t64, a->vd, 0, MO_64);
185
accfn(t64, t64, rn0_64);
186
- neon_store_reg64(t64, a->vd);
187
- neon_load_reg64(t64, a->vd + 1);
188
+ write_neon_element64(t64, a->vd, 0, MO_64);
189
+ read_neon_element64(t64, a->vd, 1, MO_64);
190
accfn(t64, t64, rn1_64);
191
- neon_store_reg64(t64, a->vd + 1);
192
+ write_neon_element64(t64, a->vd, 1, MO_64);
193
tcg_temp_free_i64(t64);
194
} else {
195
- neon_store_reg64(rn0_64, a->vd);
196
- neon_store_reg64(rn1_64, a->vd + 1);
197
+ write_neon_element64(rn0_64, a->vd, 0, MO_64);
198
+ write_neon_element64(rn1_64, a->vd, 1, MO_64);
199
}
200
tcg_temp_free_i64(rn0_64);
201
tcg_temp_free_i64(rn1_64);
202
@@ -XXX,XX +XXX,XX @@ static bool trans_VEXT(DisasContext *s, arg_VEXT *a)
203
right = tcg_temp_new_i64();
204
dest = tcg_temp_new_i64();
205
206
- neon_load_reg64(right, a->vn);
207
- neon_load_reg64(left, a->vm);
208
+ read_neon_element64(right, a->vn, 0, MO_64);
209
+ read_neon_element64(left, a->vm, 0, MO_64);
210
tcg_gen_extract2_i64(dest, right, left, a->imm * 8);
211
- neon_store_reg64(dest, a->vd);
212
+ write_neon_element64(dest, a->vd, 0, MO_64);
213
214
tcg_temp_free_i64(left);
215
tcg_temp_free_i64(right);
216
@@ -XXX,XX +XXX,XX @@ static bool trans_VEXT(DisasContext *s, arg_VEXT *a)
217
destright = tcg_temp_new_i64();
218
219
if (a->imm < 8) {
220
- neon_load_reg64(right, a->vn);
221
- neon_load_reg64(middle, a->vn + 1);
222
+ read_neon_element64(right, a->vn, 0, MO_64);
223
+ read_neon_element64(middle, a->vn, 1, MO_64);
224
tcg_gen_extract2_i64(destright, right, middle, a->imm * 8);
225
- neon_load_reg64(left, a->vm);
226
+ read_neon_element64(left, a->vm, 0, MO_64);
227
tcg_gen_extract2_i64(destleft, middle, left, a->imm * 8);
228
} else {
229
- neon_load_reg64(right, a->vn + 1);
230
- neon_load_reg64(middle, a->vm);
231
+ read_neon_element64(right, a->vn, 1, MO_64);
232
+ read_neon_element64(middle, a->vm, 0, MO_64);
233
tcg_gen_extract2_i64(destright, right, middle, (a->imm - 8) * 8);
234
- neon_load_reg64(left, a->vm + 1);
235
+ read_neon_element64(left, a->vm, 1, MO_64);
236
tcg_gen_extract2_i64(destleft, middle, left, (a->imm - 8) * 8);
237
}
238
239
- neon_store_reg64(destright, a->vd);
240
- neon_store_reg64(destleft, a->vd + 1);
241
+ write_neon_element64(destright, a->vd, 0, MO_64);
242
+ write_neon_element64(destleft, a->vd, 1, MO_64);
243
244
tcg_temp_free_i64(destright);
245
tcg_temp_free_i64(destleft);
246
@@ -XXX,XX +XXX,XX @@ static bool do_2misc_pairwise(DisasContext *s, arg_2misc *a,
247
248
if (accfn) {
249
TCGv_i64 tmp64 = tcg_temp_new_i64();
250
- neon_load_reg64(tmp64, a->vd + pass);
251
+ read_neon_element64(tmp64, a->vd, pass, MO_64);
252
accfn(rd_64, tmp64, rd_64);
253
tcg_temp_free_i64(tmp64);
254
}
255
- neon_store_reg64(rd_64, a->vd + pass);
256
+ write_neon_element64(rd_64, a->vd, pass, MO_64);
257
tcg_temp_free_i64(rd_64);
258
}
259
return true;
260
@@ -XXX,XX +XXX,XX @@ static bool do_vmovn(DisasContext *s, arg_2misc *a,
261
rd0 = tcg_temp_new_i32();
262
rd1 = tcg_temp_new_i32();
263
264
- neon_load_reg64(rm, a->vm);
265
+ read_neon_element64(rm, a->vm, 0, MO_64);
266
narrowfn(rd0, cpu_env, rm);
267
- neon_load_reg64(rm, a->vm + 1);
268
+ read_neon_element64(rm, a->vm, 1, MO_64);
269
narrowfn(rd1, cpu_env, rm);
270
write_neon_element32(rd0, a->vd, 0, MO_32);
271
write_neon_element32(rd1, a->vd, 1, MO_32);
272
@@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL(DisasContext *s, arg_2misc *a)
273
274
widenfn(rd, rm0);
275
tcg_gen_shli_i64(rd, rd, 8 << a->size);
276
- neon_store_reg64(rd, a->vd);
277
+ write_neon_element64(rd, a->vd, 0, MO_64);
278
widenfn(rd, rm1);
279
tcg_gen_shli_i64(rd, rd, 8 << a->size);
280
- neon_store_reg64(rd, a->vd + 1);
281
+ write_neon_element64(rd, a->vd, 1, MO_64);
282
283
tcg_temp_free_i64(rd);
284
tcg_temp_free_i32(rm0);
285
@@ -XXX,XX +XXX,XX @@ static bool trans_VSWP(DisasContext *s, arg_2misc *a)
286
rm = tcg_temp_new_i64();
287
rd = tcg_temp_new_i64();
288
for (pass = 0; pass < (a->q ? 2 : 1); pass++) {
289
- neon_load_reg64(rm, a->vm + pass);
290
- neon_load_reg64(rd, a->vd + pass);
291
- neon_store_reg64(rm, a->vd + pass);
292
- neon_store_reg64(rd, a->vm + pass);
293
+ read_neon_element64(rm, a->vm, pass, MO_64);
294
+ read_neon_element64(rd, a->vd, pass, MO_64);
295
+ write_neon_element64(rm, a->vd, pass, MO_64);
296
+ write_neon_element64(rd, a->vm, pass, MO_64);
297
}
298
tcg_temp_free_i64(rm);
299
tcg_temp_free_i64(rd);
300
--
392
--
301
2.20.1
393
2.34.1
302
303
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Chris Rauer <crauer@google.com>
2
2
3
We can then use this to improve VMOV (scalar to gp) and
3
The counter register is only 24-bits and counts down. If the timer is
4
VMOV (gp to scalar) so that we simply perform the memory
4
running but the qtimer to reset it hasn't fired off yet, there is a chance
5
operation that we wanted, rather than inserting or
5
the regster read can return an invalid result.
6
extracting from a 32-bit quantity.
7
6
8
These were the last uses of neon_load/store_reg, so remove them.
7
Signed-off-by: Chris Rauer <crauer@google.com>
9
8
Message-id: 20230922181411.2697135-1-crauer@google.com
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20201030022618.785675-7-richard.henderson@linaro.org
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
11
---
15
target/arm/translate.c | 50 +++++++++++++-----------
12
hw/timer/npcm7xx_timer.c | 3 +++
16
target/arm/translate-vfp.c.inc | 71 +++++-----------------------------
13
1 file changed, 3 insertions(+)
17
2 files changed, 37 insertions(+), 84 deletions(-)
18
14
19
diff --git a/target/arm/translate.c b/target/arm/translate.c
15
diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/translate.c
17
--- a/hw/timer/npcm7xx_timer.c
22
+++ b/target/arm/translate.c
18
+++ b/hw/timer/npcm7xx_timer.c
23
@@ -XXX,XX +XXX,XX @@ static long neon_full_reg_offset(unsigned reg)
19
@@ -XXX,XX +XXX,XX @@ static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t, uint32_t count)
24
* Return the offset of a 2**SIZE piece of a NEON register, at index ELE,
20
/* Convert a time interval in nanoseconds to a timer cycle count. */
25
* where 0 is the least significant end of the register.
21
static uint32_t npcm7xx_timer_ns_to_count(NPCM7xxTimer *t, int64_t ns)
26
*/
27
-static long neon_element_offset(int reg, int element, MemOp size)
28
+static long neon_element_offset(int reg, int element, MemOp memop)
29
{
22
{
30
- int element_size = 1 << size;
23
+ if (ns < 0) {
31
+ int element_size = 1 << (memop & MO_SIZE);
24
+ return 0;
32
int ofs = element * element_size;
25
+ }
33
#ifdef HOST_WORDS_BIGENDIAN
26
return clock_ns_to_ticks(t->ctrl->clock, ns) /
34
/*
27
npcm7xx_tcsr_prescaler(t->tcsr);
35
@@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg)
36
}
37
}
38
39
-static TCGv_i32 neon_load_reg(int reg, int pass)
40
-{
41
- TCGv_i32 tmp = tcg_temp_new_i32();
42
- tcg_gen_ld_i32(tmp, cpu_env, neon_element_offset(reg, pass, MO_32));
43
- return tmp;
44
-}
45
-
46
-static void neon_store_reg(int reg, int pass, TCGv_i32 var)
47
-{
48
- tcg_gen_st_i32(var, cpu_env, neon_element_offset(reg, pass, MO_32));
49
- tcg_temp_free_i32(var);
50
-}
51
-
52
static inline void neon_load_reg64(TCGv_i64 var, int reg)
53
{
54
tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg));
55
@@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg32(TCGv_i32 var, int reg)
56
tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg));
57
}
58
59
-static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size)
60
+static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop)
61
{
62
- long off = neon_element_offset(reg, ele, size);
63
+ long off = neon_element_offset(reg, ele, memop);
64
65
- switch (size) {
66
- case MO_32:
67
+ switch (memop) {
68
+ case MO_SB:
69
+ tcg_gen_ld8s_i32(dest, cpu_env, off);
70
+ break;
71
+ case MO_UB:
72
+ tcg_gen_ld8u_i32(dest, cpu_env, off);
73
+ break;
74
+ case MO_SW:
75
+ tcg_gen_ld16s_i32(dest, cpu_env, off);
76
+ break;
77
+ case MO_UW:
78
+ tcg_gen_ld16u_i32(dest, cpu_env, off);
79
+ break;
80
+ case MO_UL:
81
+ case MO_SL:
82
tcg_gen_ld_i32(dest, cpu_env, off);
83
break;
84
default:
85
@@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size)
86
}
87
}
88
89
-static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp size)
90
+static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop)
91
{
92
- long off = neon_element_offset(reg, ele, size);
93
+ long off = neon_element_offset(reg, ele, memop);
94
95
- switch (size) {
96
+ switch (memop) {
97
+ case MO_8:
98
+ tcg_gen_st8_i32(src, cpu_env, off);
99
+ break;
100
+ case MO_16:
101
+ tcg_gen_st16_i32(src, cpu_env, off);
102
+ break;
103
case MO_32:
104
tcg_gen_st_i32(src, cpu_env, off);
105
break;
106
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
107
index XXXXXXX..XXXXXXX 100644
108
--- a/target/arm/translate-vfp.c.inc
109
+++ b/target/arm/translate-vfp.c.inc
110
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a)
111
{
112
/* VMOV scalar to general purpose register */
113
TCGv_i32 tmp;
114
- int pass;
115
- uint32_t offset;
116
117
- /* SIZE == 2 is a VFP instruction; otherwise NEON. */
118
- if (a->size == 2
119
+ /* SIZE == MO_32 is a VFP instruction; otherwise NEON. */
120
+ if (a->size == MO_32
121
? !dc_isar_feature(aa32_fpsp_v2, s)
122
: !arm_dc_feature(s, ARM_FEATURE_NEON)) {
123
return false;
124
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a)
125
return false;
126
}
127
128
- offset = a->index << a->size;
129
- pass = extract32(offset, 2, 1);
130
- offset = extract32(offset, 0, 2) * 8;
131
-
132
if (!vfp_access_check(s)) {
133
return true;
134
}
135
136
- tmp = neon_load_reg(a->vn, pass);
137
- switch (a->size) {
138
- case 0:
139
- if (offset) {
140
- tcg_gen_shri_i32(tmp, tmp, offset);
141
- }
142
- if (a->u) {
143
- gen_uxtb(tmp);
144
- } else {
145
- gen_sxtb(tmp);
146
- }
147
- break;
148
- case 1:
149
- if (a->u) {
150
- if (offset) {
151
- tcg_gen_shri_i32(tmp, tmp, 16);
152
- } else {
153
- gen_uxth(tmp);
154
- }
155
- } else {
156
- if (offset) {
157
- tcg_gen_sari_i32(tmp, tmp, 16);
158
- } else {
159
- gen_sxth(tmp);
160
- }
161
- }
162
- break;
163
- case 2:
164
- break;
165
- }
166
+ tmp = tcg_temp_new_i32();
167
+ read_neon_element32(tmp, a->vn, a->index, a->size | (a->u ? 0 : MO_SIGN));
168
store_reg(s, a->rt, tmp);
169
170
return true;
171
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a)
172
static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a)
173
{
174
/* VMOV general purpose register to scalar */
175
- TCGv_i32 tmp, tmp2;
176
- int pass;
177
- uint32_t offset;
178
+ TCGv_i32 tmp;
179
180
- /* SIZE == 2 is a VFP instruction; otherwise NEON. */
181
- if (a->size == 2
182
+ /* SIZE == MO_32 is a VFP instruction; otherwise NEON. */
183
+ if (a->size == MO_32
184
? !dc_isar_feature(aa32_fpsp_v2, s)
185
: !arm_dc_feature(s, ARM_FEATURE_NEON)) {
186
return false;
187
@@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a)
188
return false;
189
}
190
191
- offset = a->index << a->size;
192
- pass = extract32(offset, 2, 1);
193
- offset = extract32(offset, 0, 2) * 8;
194
-
195
if (!vfp_access_check(s)) {
196
return true;
197
}
198
199
tmp = load_reg(s, a->rt);
200
- switch (a->size) {
201
- case 0:
202
- tmp2 = neon_load_reg(a->vn, pass);
203
- tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8);
204
- tcg_temp_free_i32(tmp2);
205
- break;
206
- case 1:
207
- tmp2 = neon_load_reg(a->vn, pass);
208
- tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16);
209
- tcg_temp_free_i32(tmp2);
210
- break;
211
- case 2:
212
- break;
213
- }
214
- neon_store_reg(a->vn, pass, tmp);
215
+ write_neon_element32(tmp, a->vn, a->index, a->size);
216
+ tcg_temp_free_i32(tmp);
217
218
return true;
219
}
28
}
220
--
29
--
221
2.20.1
30
2.34.1
222
223
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Suraj Shirvankar <surajshirvankar@gmail.com>
2
2
3
These are the only users of neon_reg_offset, so remove that.
3
QEMU coding style uses the glib memory allocation APIs, not
4
the raw libc malloc/free. Switch the allocation and free
5
calls in elf2dmp to use these functions (dropping the now-unneeded
6
checks for failure).
4
7
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
6
Message-id: 20201030022618.785675-4-richard.henderson@linaro.org
9
Message-id: 169753938460.23804.11418813007617535750-1@git.sr.ht
10
[PMM: also remove NULL checks from g_malloc() calls;
11
beef up commit message]
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
14
---
10
target/arm/translate.c | 14 ++------------
15
contrib/elf2dmp/addrspace.c | 7 ++-----
11
1 file changed, 2 insertions(+), 12 deletions(-)
16
contrib/elf2dmp/main.c | 9 +++------
17
contrib/elf2dmp/pdb.c | 19 ++++++++-----------
18
contrib/elf2dmp/qemu_elf.c | 7 ++-----
19
4 files changed, 15 insertions(+), 27 deletions(-)
12
20
13
diff --git a/target/arm/translate.c b/target/arm/translate.c
21
diff --git a/contrib/elf2dmp/addrspace.c b/contrib/elf2dmp/addrspace.c
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate.c
23
--- a/contrib/elf2dmp/addrspace.c
16
+++ b/target/arm/translate.c
24
+++ b/contrib/elf2dmp/addrspace.c
17
@@ -XXX,XX +XXX,XX @@ static inline long vfp_reg_offset(bool dp, unsigned reg)
25
@@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf)
26
}
18
}
27
}
28
29
- ps->block = malloc(sizeof(*ps->block) * ps->block_nr);
30
- if (!ps->block) {
31
- return 1;
32
- }
33
+ ps->block = g_new(struct pa_block, ps->block_nr);
34
35
for (i = 0; i < phdr_nr; i++) {
36
if (phdr[i].p_type == PT_LOAD) {
37
@@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf)
38
void pa_space_destroy(struct pa_space *ps)
39
{
40
ps->block_nr = 0;
41
- free(ps->block);
42
+ g_free(ps->block);
19
}
43
}
20
44
21
-/* Return the offset of a 32-bit piece of a NEON register.
45
void va_space_set_dtb(struct va_space *vs, uint64_t dtb)
22
- zero is the least significant end of the register. */
46
diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
23
-static inline long
47
index XXXXXXX..XXXXXXX 100644
24
-neon_reg_offset (int reg, int n)
48
--- a/contrib/elf2dmp/main.c
25
-{
49
+++ b/contrib/elf2dmp/main.c
26
- int sreg;
50
@@ -XXX,XX +XXX,XX @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb,
27
- sreg = reg * 2 + n;
51
}
28
- return vfp_reg_offset(0, sreg);
52
}
29
-}
53
30
-
54
- kdbg = malloc(kdbg_hdr.Size);
31
static TCGv_i32 neon_load_reg(int reg, int pass)
55
- if (!kdbg) {
56
- return NULL;
57
- }
58
+ kdbg = g_malloc(kdbg_hdr.Size);
59
60
if (va_space_rw(vs, KdDebuggerDataBlock, kdbg, kdbg_hdr.Size, 0)) {
61
eprintf("Failed to extract entire KDBG\n");
62
- free(kdbg);
63
+ g_free(kdbg);
64
return NULL;
65
}
66
67
@@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[])
68
}
69
70
out_kdbg:
71
- free(kdbg);
72
+ g_free(kdbg);
73
out_pdb:
74
pdb_exit(&pdb);
75
out_pdb_file:
76
diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/contrib/elf2dmp/pdb.c
79
+++ b/contrib/elf2dmp/pdb.c
80
@@ -XXX,XX +XXX,XX @@ uint64_t pdb_resolve(uint64_t img_base, struct pdb_reader *r, const char *name)
81
82
static void pdb_reader_ds_exit(struct pdb_reader *r)
32
{
83
{
33
TCGv_i32 tmp = tcg_temp_new_i32();
84
- free(r->ds.toc);
34
- tcg_gen_ld_i32(tmp, cpu_env, neon_reg_offset(reg, pass));
85
+ g_free(r->ds.toc);
35
+ tcg_gen_ld_i32(tmp, cpu_env, neon_element_offset(reg, pass, MO_32));
36
return tmp;
37
}
86
}
38
87
39
static void neon_store_reg(int reg, int pass, TCGv_i32 var)
88
static void pdb_exit_symbols(struct pdb_reader *r)
40
{
89
{
41
- tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass));
90
- free(r->modimage);
42
+ tcg_gen_st_i32(var, cpu_env, neon_element_offset(reg, pass, MO_32));
91
- free(r->symbols);
43
tcg_temp_free_i32(var);
92
+ g_free(r->modimage);
93
+ g_free(r->symbols);
44
}
94
}
45
95
96
static void pdb_exit_segments(struct pdb_reader *r)
97
{
98
- free(r->segs);
99
+ g_free(r->segs);
100
}
101
102
static void *pdb_ds_read(const PDB_DS_HEADER *header,
103
@@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read(const PDB_DS_HEADER *header,
104
105
nBlocks = (size + header->block_size - 1) / header->block_size;
106
107
- buffer = malloc(nBlocks * header->block_size);
108
- if (!buffer) {
109
- return NULL;
110
- }
111
+ buffer = g_malloc(nBlocks * header->block_size);
112
113
for (i = 0; i < nBlocks; i++) {
114
memcpy(buffer + i * header->block_size, (const char *)header +
115
@@ -XXX,XX +XXX,XX @@ static int pdb_init_symbols(struct pdb_reader *r)
116
return 0;
117
118
out_symbols:
119
- free(symbols);
120
+ g_free(symbols);
121
122
return err;
123
}
124
@@ -XXX,XX +XXX,XX @@ static int pdb_reader_init(struct pdb_reader *r, void *data)
125
out_sym:
126
pdb_exit_symbols(r);
127
out_root:
128
- free(r->ds.root);
129
+ g_free(r->ds.root);
130
out_ds:
131
pdb_reader_ds_exit(r);
132
133
@@ -XXX,XX +XXX,XX @@ static void pdb_reader_exit(struct pdb_reader *r)
134
{
135
pdb_exit_segments(r);
136
pdb_exit_symbols(r);
137
- free(r->ds.root);
138
+ g_free(r->ds.root);
139
pdb_reader_ds_exit(r);
140
}
141
142
diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
143
index XXXXXXX..XXXXXXX 100644
144
--- a/contrib/elf2dmp/qemu_elf.c
145
+++ b/contrib/elf2dmp/qemu_elf.c
146
@@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe)
147
148
printf("%zu CPU states has been found\n", cpu_nr);
149
150
- qe->state = malloc(sizeof(*qe->state) * cpu_nr);
151
- if (!qe->state) {
152
- return 1;
153
- }
154
+ qe->state = g_new(QEMUCPUState*, cpu_nr);
155
156
cpu_nr = 0;
157
158
@@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe)
159
160
static void exit_states(QEMU_Elf *qe)
161
{
162
- free(qe->state);
163
+ g_free(qe->state);
164
}
165
166
static bool check_ehdr(QEMU_Elf *qe)
46
--
167
--
47
2.20.1
168
2.34.1
48
49
diff view generated by jsdifflib
Deleted patch
1
On some hosts (eg Ubuntu Bionic) pkg-config returns a set of
2
libraries for gio-2.0 which don't actually work when compiling
3
statically. (Specifically, the returned library string includes
4
-lmount, but not -lblkid which -lmount depends upon, so linking
5
fails due to missing symbols.)
6
1
7
Check that the libraries work, and don't enable gio if they don't,
8
in the same way we do for gnutls.
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Message-id: 20200928160402.7961-1-peter.maydell@linaro.org
14
---
15
configure | 10 +++++++++-
16
1 file changed, 9 insertions(+), 1 deletion(-)
17
18
diff --git a/configure b/configure
19
index XXXXXXX..XXXXXXX 100755
20
--- a/configure
21
+++ b/configure
22
@@ -XXX,XX +XXX,XX @@ if test "$static" = yes && test "$mingw32" = yes; then
23
fi
24
25
if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
26
- gio=yes
27
gio_cflags=$($pkg_config --cflags gio-2.0)
28
gio_libs=$($pkg_config --libs gio-2.0)
29
gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
30
if [ ! -x "$gdbus_codegen" ]; then
31
gdbus_codegen=
32
fi
33
+ # Check that the libraries actually work -- Ubuntu 18.04 ships
34
+ # with pkg-config --static --libs data for gio-2.0 that is missing
35
+ # -lblkid and will give a link error.
36
+ write_c_skeleton
37
+ if compile_prog "" "gio_libs" ; then
38
+ gio=yes
39
+ else
40
+ gio=no
41
+ fi
42
else
43
gio=no
44
fi
45
--
46
2.20.1
47
48
diff view generated by jsdifflib
Deleted patch
1
In gicv3_init_cpuif() we copy the ARMCPU gicv3_maintenance_interrupt
2
into the GICv3CPUState struct's maintenance_irq field. This will
3
only work if the board happens to have already wired up the CPU
4
maintenance IRQ before the GIC was realized. Unfortunately this is
5
not the case for the 'virt' board, and so the value that gets copied
6
is NULL (since a qemu_irq is really a pointer to an IRQState struct
7
under the hood). The effect is that the CPU interface code never
8
actually raises the maintenance interrupt line.
9
1
10
Instead, since the GICv3CPUState has a pointer to the CPUState, make
11
the dereference at the point where we want to raise the interrupt, to
12
avoid an implicit requirement on board code to wire things up in a
13
particular order.
14
15
Reported-by: Jose Martins <josemartins90@gmail.com>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Message-id: 20201009153904.28529-1-peter.maydell@linaro.org
18
Reviewed-by: Luc Michel <luc@lmichel.fr>
19
---
20
include/hw/intc/arm_gicv3_common.h | 1 -
21
hw/intc/arm_gicv3_cpuif.c | 5 ++---
22
2 files changed, 2 insertions(+), 4 deletions(-)
23
24
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/intc/arm_gicv3_common.h
27
+++ b/include/hw/intc/arm_gicv3_common.h
28
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
29
qemu_irq parent_fiq;
30
qemu_irq parent_virq;
31
qemu_irq parent_vfiq;
32
- qemu_irq maintenance_irq;
33
34
/* Redistributor */
35
uint32_t level; /* Current IRQ level */
36
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/intc/arm_gicv3_cpuif.c
39
+++ b/hw/intc/arm_gicv3_cpuif.c
40
@@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs)
41
int irqlevel = 0;
42
int fiqlevel = 0;
43
int maintlevel = 0;
44
+ ARMCPU *cpu = ARM_CPU(cs->cpu);
45
46
idx = hppvi_index(cs);
47
trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx);
48
@@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs)
49
50
qemu_set_irq(cs->parent_vfiq, fiqlevel);
51
qemu_set_irq(cs->parent_virq, irqlevel);
52
- qemu_set_irq(cs->maintenance_irq, maintlevel);
53
+ qemu_set_irq(cpu->gicv3_maintenance_interrupt, maintlevel);
54
}
55
56
static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
57
@@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s)
58
&& cpu->gic_num_lrs) {
59
int j;
60
61
- cs->maintenance_irq = cpu->gicv3_maintenance_interrupt;
62
-
63
cs->num_list_regs = cpu->gic_num_lrs;
64
cs->vpribits = cpu->gic_vpribits;
65
cs->vprebits = cpu->gic_vprebits;
66
--
67
2.20.1
68
69
diff view generated by jsdifflib