1
The following changes since commit ad1b4ec39caa5b3f17cbd8160283a03a3dcfe2ae:
1
A mixed bag, all bug fixes or similar small stuff.
2
2
3
Merge remote-tracking branch 'remotes/kraxel/tags/input-20180515-pull-request' into staging (2018-05-15 12:50:06 +0100)
3
thanks
4
-- PMM
5
6
7
The following changes since commit 19eb2d4e736dc895f31fbd6b520e514f10cc08e0:
8
9
Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2019-05-07 10:43:32 +0100)
4
10
5
are available in the Git repository at:
11
are available in the Git repository at:
6
12
7
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180515
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190507
8
14
9
for you to fetch changes up to ae7651804748c6b479d5ae09aeac4edb9c44f76e:
15
for you to fetch changes up to 63159601fb3e396b28da14cbb71e50ed3f5a0331:
10
16
11
tcg: Optionally log FPU state in TCG -d cpu logging (2018-05-15 14:58:44 +0100)
17
target/arm: Stop using variable length array in dc_zva (2019-05-07 12:55:04 +0100)
12
18
13
----------------------------------------------------------------
19
----------------------------------------------------------------
14
target-arm queue:
20
target-arm queue:
15
* Fix coverity nit in int_to_float code
21
* Stop using variable length array in dc_zva
16
* Don't set Invalid for float-to-int(MAXINT)
22
* Implement M-profile XPSR GE bits
17
* Fix fp_status_f16 tininess before rounding
23
* Don't enable ARMV7M_EXCP_DEBUG from reset
18
* Add various missing insns from the v8.2-FP16 extension
24
* armv7m_nvic: NS BFAR and BFSR are RAZ/WI if BFHFNMINS == 0
19
* Fix sqrt_f16 exception raising
25
* armv7m_nvic: Check subpriority in nvic_recompute_state_secure()
20
* sdcard: Correct CRC16 offset in sd_function_switch()
26
* fix various minor issues to allow building for Windows-on-ARM64
21
* tcg: Optionally log FPU state in TCG -d cpu logging
27
* aspeed: Set SDRAM size
28
* Allow system registers for KVM guests to be changed by QEMU code
29
* raspi: Diagnose requests for too much RAM
30
* virt: Support firmware configuration with -blockdev
22
31
23
----------------------------------------------------------------
32
----------------------------------------------------------------
24
Alex Bennée (5):
33
Cao Jiaxi (4):
25
fpu/softfloat: int_to_float ensure r fully initialised
34
QEMU_PACKED: Remove gcc_struct attribute in Windows non x86 targets
26
target/arm: Implement FCMP for fp16
35
qga: Fix mingw compilation warnings on enum conversion
27
target/arm: Implement FCSEL for fp16
36
util/cacheinfo: Use uint64_t on LLP64 model to satisfy Windows ARM64
28
target/arm: Implement FMOV (immediate) for fp16
37
osdep: Fix mingw compilation regarding stdio formats
29
target/arm: Fix sqrt_f16 exception raising
30
38
31
Peter Maydell (3):
39
Joel Stanley (1):
32
fpu/softfloat: Don't set Invalid for float-to-int(MAXINT)
40
arm: aspeed: Set SDRAM size
33
target/arm: Fix fp_status_f16 tininess before rounding
34
tcg: Optionally log FPU state in TCG -d cpu logging
35
41
36
Philippe Mathieu-Daudé (1):
42
Markus Armbruster (3):
37
sdcard: Correct CRC16 offset in sd_function_switch()
43
pc: Rearrange pc_system_firmware_init()'s legacy -drive loop
44
pflash_cfi01: New pflash_cfi01_legacy_drive()
45
hw/arm/virt: Support firmware configuration with -blockdev
38
46
39
Richard Henderson (7):
47
Peter Maydell (7):
40
target/arm: Implement FMOV (general) for fp16
48
hw/arm/raspi: Diagnose requests for too much RAM
41
target/arm: Early exit after unallocated_encoding in disas_fp_int_conv
49
arm: Allow system registers for KVM guests to be changed by QEMU code
42
target/arm: Implement FCVT (scalar, integer) for fp16
50
hw/arm/armv7m_nvic: Check subpriority in nvic_recompute_state_secure()
43
target/arm: Implement FCVT (scalar, fixed-point) for fp16
51
hw/intc/armv7m_nvic: NS BFAR and BFSR are RAZ/WI if BFHFNMINS == 0
44
target/arm: Introduce and use read_fp_hreg
52
hw/intc/armv7m_nvic: Don't enable ARMV7M_EXCP_DEBUG from reset
45
target/arm: Implement FP data-processing (2 source) for fp16
53
target/arm: Implement XPSR GE bits
46
target/arm: Implement FP data-processing (3 source) for fp16
54
target/arm: Stop using variable length array in dc_zva
47
55
48
include/qemu/log.h | 1 +
56
contrib/libvhost-user/libvhost-user.h | 2 +-
49
target/arm/helper-a64.h | 2 +
57
include/hw/arm/aspeed.h | 1 +
50
target/arm/helper.h | 6 +
58
include/hw/arm/virt.h | 2 +
51
accel/tcg/cpu-exec.c | 9 +-
59
include/hw/block/flash.h | 1 +
52
fpu/softfloat.c | 6 +-
60
include/qemu/compiler.h | 2 +-
53
hw/sd/sd.c | 2 +-
61
include/qemu/osdep.h | 10 +-
54
target/arm/cpu.c | 2 +
62
scripts/cocci-macro-file.h | 7 +-
55
target/arm/helper-a64.c | 10 ++
63
target/arm/cpu.h | 13 ++-
56
target/arm/helper.c | 38 +++-
64
hw/arm/aspeed.c | 8 ++
57
target/arm/translate-a64.c | 421 ++++++++++++++++++++++++++++++++++++++-------
65
hw/arm/raspi.c | 7 ++
58
util/log.c | 2 +
66
hw/arm/virt.c | 202 ++++++++++++++++++++++------------
59
11 files changed, 428 insertions(+), 71 deletions(-)
67
hw/block/pflash_cfi01.c | 28 +++++
68
hw/i386/pc_sysfw.c | 18 +--
69
hw/intc/armv7m_nvic.c | 40 ++++++-
70
qga/commands-win32.c | 2 +-
71
target/arm/helper.c | 47 +++++++-
72
target/arm/kvm.c | 8 ++
73
target/arm/kvm32.c | 20 +---
74
target/arm/kvm64.c | 2 +
75
target/arm/machine.c | 2 +-
76
util/cacheinfo.c | 2 +-
77
21 files changed, 294 insertions(+), 130 deletions(-)
60
78
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Markus Armbruster <armbru@redhat.com>
2
2
3
We are meant to explicitly pass fpst, not cpu_env.
3
The loop does two things: map legacy -drive to properties, and collect
4
all the backends for use after the loop. The next patch will factor
5
out the former for reuse in hw/arm/virt.c. To make that easier,
6
rearrange the loop so it does the first thing first, and the second
7
thing second.
4
8
5
Cc: qemu-stable@nongnu.org
9
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190416091348.26075-2-armbru@redhat.com
9
Tested-by: Alex Bennée <alex.bennee@linaro.org>
10
Message-id: 20180512003217.9105-12-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
14
---
13
target/arm/translate-a64.c | 3 ++-
15
hw/i386/pc_sysfw.c | 24 +++++++++++-------------
14
1 file changed, 2 insertions(+), 1 deletion(-)
16
1 file changed, 11 insertions(+), 13 deletions(-)
15
17
16
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
18
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate-a64.c
20
--- a/hw/i386/pc_sysfw.c
19
+++ b/target/arm/translate-a64.c
21
+++ b/hw/i386/pc_sysfw.c
20
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn)
22
@@ -XXX,XX +XXX,XX @@ void pc_system_firmware_init(PCMachineState *pcms,
21
tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
23
22
break;
24
/* Map legacy -drive if=pflash to machine properties */
23
case 0x3: /* FSQRT */
25
for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) {
24
- gen_helper_sqrt_f16(tcg_res, tcg_op, cpu_env);
26
- pflash_blk[i] = pflash_cfi01_get_blk(pcms->flash[i]);
25
+ fpst = get_fpstatus_ptr(true);
27
pflash_drv = drive_get(IF_PFLASH, 0, i);
26
+ gen_helper_sqrt_f16(tcg_res, tcg_op, fpst);
28
- if (!pflash_drv) {
27
break;
29
- continue;
28
case 0x8: /* FRINTN */
30
+ if (pflash_drv) {
29
case 0x9: /* FRINTP */
31
+ loc_push_none(&loc);
32
+ qemu_opts_loc_restore(pflash_drv->opts);
33
+ if (pflash_cfi01_get_blk(pcms->flash[i])) {
34
+ error_report("clashes with -machine");
35
+ exit(1);
36
+ }
37
+ qdev_prop_set_drive(DEVICE(pcms->flash[i]), "drive",
38
+ blk_by_legacy_dinfo(pflash_drv), &error_fatal);
39
+ loc_pop(&loc);
40
}
41
- loc_push_none(&loc);
42
- qemu_opts_loc_restore(pflash_drv->opts);
43
- if (pflash_blk[i]) {
44
- error_report("clashes with -machine");
45
- exit(1);
46
- }
47
- pflash_blk[i] = blk_by_legacy_dinfo(pflash_drv);
48
- qdev_prop_set_drive(DEVICE(pcms->flash[i]),
49
- "drive", pflash_blk[i], &error_fatal);
50
- loc_pop(&loc);
51
+ pflash_blk[i] = pflash_cfi01_get_blk(pcms->flash[i]);
52
}
53
54
/* Reject gaps */
30
--
55
--
31
2.17.0
56
2.20.1
32
57
33
58
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Markus Armbruster <armbru@redhat.com>
2
2
3
Cc: qemu-stable@nongnu.org
3
Factored out of pc_system_firmware_init() so the next commit can reuse
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
it in hw/arm/virt.c.
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
6
Tested-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7
Message-id: 20180512003217.9105-6-richard.henderson@linaro.org
7
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: 20190416091348.26075-3-armbru@redhat.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
11
---
10
target/arm/translate-a64.c | 30 ++++++++++++++----------------
12
include/hw/block/flash.h | 1 +
11
1 file changed, 14 insertions(+), 16 deletions(-)
13
hw/block/pflash_cfi01.c | 28 ++++++++++++++++++++++++++++
14
hw/i386/pc_sysfw.c | 16 ++--------------
15
3 files changed, 31 insertions(+), 14 deletions(-)
12
16
13
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
17
diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h
14
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a64.c
19
--- a/include/hw/block/flash.h
16
+++ b/target/arm/translate-a64.c
20
+++ b/include/hw/block/flash.h
17
@@ -XXX,XX +XXX,XX @@ static TCGv_i32 read_fp_sreg(DisasContext *s, int reg)
21
@@ -XXX,XX +XXX,XX @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
18
return v;
22
int be);
23
BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl);
24
MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl);
25
+void pflash_cfi01_legacy_drive(PFlashCFI01 *dev, DriveInfo *dinfo);
26
27
/* pflash_cfi02.c */
28
29
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/block/pflash_cfi01.c
32
+++ b/hw/block/pflash_cfi01.c
33
@@ -XXX,XX +XXX,XX @@
34
#include "qapi/error.h"
35
#include "qemu/timer.h"
36
#include "qemu/bitops.h"
37
+#include "qemu/error-report.h"
38
#include "qemu/host-utils.h"
39
#include "qemu/log.h"
40
+#include "qemu/option.h"
41
#include "hw/sysbus.h"
42
+#include "sysemu/blockdev.h"
43
#include "sysemu/sysemu.h"
44
#include "trace.h"
45
46
@@ -XXX,XX +XXX,XX @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl)
47
return &fl->mem;
19
}
48
}
20
49
21
+static TCGv_i32 read_fp_hreg(DisasContext *s, int reg)
50
+/*
51
+ * Handle -drive if=pflash for machines that use properties.
52
+ * If @dinfo is null, do nothing.
53
+ * Else if @fl's property "drive" is already set, fatal error.
54
+ * Else set it to the BlockBackend with @dinfo.
55
+ */
56
+void pflash_cfi01_legacy_drive(PFlashCFI01 *fl, DriveInfo *dinfo)
22
+{
57
+{
23
+ TCGv_i32 v = tcg_temp_new_i32();
58
+ Location loc;
24
+
59
+
25
+ tcg_gen_ld16u_i32(v, cpu_env, fp_reg_offset(s, reg, MO_16));
60
+ if (!dinfo) {
26
+ return v;
61
+ return;
62
+ }
63
+
64
+ loc_push_none(&loc);
65
+ qemu_opts_loc_restore(dinfo->opts);
66
+ if (fl->blk) {
67
+ error_report("clashes with -machine");
68
+ exit(1);
69
+ }
70
+ qdev_prop_set_drive(DEVICE(fl), "drive",
71
+ blk_by_legacy_dinfo(dinfo), &error_fatal);
72
+ loc_pop(&loc);
27
+}
73
+}
28
+
74
+
29
/* Clear the bits above an N-bit vector, for N = (is_q ? 128 : 64).
75
static void postload_update_cb(void *opaque, int running, RunState state)
30
* If SVE is not enabled, then there are only 128 bits in the vector.
31
*/
32
@@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
33
static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn)
34
{
76
{
35
TCGv_ptr fpst = NULL;
77
PFlashCFI01 *pfl = opaque;
36
- TCGv_i32 tcg_op = tcg_temp_new_i32();
78
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
37
+ TCGv_i32 tcg_op = read_fp_hreg(s, rn);
79
index XXXXXXX..XXXXXXX 100644
38
TCGv_i32 tcg_res = tcg_temp_new_i32();
80
--- a/hw/i386/pc_sysfw.c
39
81
+++ b/hw/i386/pc_sysfw.c
40
- read_vec_element_i32(s, tcg_op, rn, 0, MO_16);
82
@@ -XXX,XX +XXX,XX @@ void pc_system_firmware_init(PCMachineState *pcms,
41
-
83
{
42
switch (opcode) {
84
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
43
case 0x0: /* FMOV */
85
int i;
44
tcg_gen_mov_i32(tcg_res, tcg_op);
86
- DriveInfo *pflash_drv;
45
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_diff(DisasContext *s, uint32_t insn)
87
BlockBackend *pflash_blk[ARRAY_SIZE(pcms->flash)];
46
tcg_temp_free_i64(tcg_op2);
88
- Location loc;
47
tcg_temp_free_i64(tcg_res);
89
48
} else {
90
if (!pcmc->pci_enabled) {
49
- TCGv_i32 tcg_op1 = tcg_temp_new_i32();
91
old_pc_system_rom_init(rom_memory, true);
50
- TCGv_i32 tcg_op2 = tcg_temp_new_i32();
92
@@ -XXX,XX +XXX,XX @@ void pc_system_firmware_init(PCMachineState *pcms,
51
+ TCGv_i32 tcg_op1 = read_fp_hreg(s, rn);
93
52
+ TCGv_i32 tcg_op2 = read_fp_hreg(s, rm);
94
/* Map legacy -drive if=pflash to machine properties */
53
TCGv_i64 tcg_res = tcg_temp_new_i64();
95
for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) {
54
96
- pflash_drv = drive_get(IF_PFLASH, 0, i);
55
- read_vec_element_i32(s, tcg_op1, rn, 0, MO_16);
97
- if (pflash_drv) {
56
- read_vec_element_i32(s, tcg_op2, rm, 0, MO_16);
98
- loc_push_none(&loc);
57
-
99
- qemu_opts_loc_restore(pflash_drv->opts);
58
gen_helper_neon_mull_s16(tcg_res, tcg_op1, tcg_op2);
100
- if (pflash_cfi01_get_blk(pcms->flash[i])) {
59
gen_helper_neon_addl_saturate_s32(tcg_res, cpu_env, tcg_res, tcg_res);
101
- error_report("clashes with -machine");
60
102
- exit(1);
61
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s,
103
- }
62
104
- qdev_prop_set_drive(DEVICE(pcms->flash[i]), "drive",
63
fpst = get_fpstatus_ptr(true);
105
- blk_by_legacy_dinfo(pflash_drv), &error_fatal);
64
106
- loc_pop(&loc);
65
- tcg_op1 = tcg_temp_new_i32();
107
- }
66
- tcg_op2 = tcg_temp_new_i32();
108
+ pflash_cfi01_legacy_drive(pcms->flash[i],
67
+ tcg_op1 = read_fp_hreg(s, rn);
109
+ drive_get(IF_PFLASH, 0, i));
68
+ tcg_op2 = read_fp_hreg(s, rm);
110
pflash_blk[i] = pflash_cfi01_get_blk(pcms->flash[i]);
69
tcg_res = tcg_temp_new_i32();
70
71
- read_vec_element_i32(s, tcg_op1, rn, 0, MO_16);
72
- read_vec_element_i32(s, tcg_op2, rm, 0, MO_16);
73
-
74
switch (fpopcode) {
75
case 0x03: /* FMULX */
76
gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
77
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
78
}
111
}
79
112
80
if (is_scalar) {
81
- TCGv_i32 tcg_op = tcg_temp_new_i32();
82
+ TCGv_i32 tcg_op = read_fp_hreg(s, rn);
83
TCGv_i32 tcg_res = tcg_temp_new_i32();
84
85
- read_vec_element_i32(s, tcg_op, rn, 0, MO_16);
86
-
87
switch (fpop) {
88
case 0x1a: /* FCVTNS */
89
case 0x1b: /* FCVTMS */
90
--
113
--
91
2.17.0
114
2.20.1
92
115
93
116
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Markus Armbruster <armbru@redhat.com>
2
2
3
These where missed out from the rest of the half-precision work.
3
The ARM virt machines put firmware in flash memory. To configure it,
4
4
you use -drive if=pflash,unit=0,... and optionally -drive
5
Cc: qemu-stable@nongnu.org
5
if=pflash,unit=1,...
6
7
Why two -drive? This permits setting up one part of the flash memory
8
read-only, and the other part read/write. It also makes upgrading
9
firmware on the host easier. Below the hood, we get two separate
10
flash devices, because we were too lazy to improve our flash device
11
models to support sector protection.
12
13
The problem at hand is to do the same with -blockdev somehow, as one
14
more step towards deprecating -drive.
15
16
We recently solved this problem for x86 PC machines, in commit
17
ebc29e1beab. See the commit message for design rationale.
18
19
This commit solves it for ARM virt basically the same way: new machine
20
properties pflash0, pflash1 forward to the onboard flash devices'
21
properties. Requires creating the onboard devices in the
22
.instance_init() method virt_instance_init(). The existing code to
23
pick up drives defined with -drive if=pflash is replaced by code to
24
desugar into the machine properties.
25
26
There are a few behavioral differences, though:
27
28
* The flash devices are always present (x86: only present if
29
configured)
30
31
* Flash base addresses and sizes are fixed (x86: sizes depend on
32
images, mapped back to back below a fixed address)
33
34
* -bios configures contents of first pflash (x86: -bios configures ROM
35
contents)
36
37
* -bios is rejected when first pflash is also configured with -machine
38
pflash0=... (x86: bios is silently ignored then)
39
40
* -machine pflash1=... does not require -machine pflash0=... (x86: it
41
does).
42
43
The actual code is a bit simpler than for x86 mostly due to the first
44
two differences.
45
46
Before the patch, all the action is in create_flash(), called from the
47
machine's .init() method machvirt_init():
48
49
main()
50
machine_run_board_init()
51
machvirt_init()
52
create_flash()
53
create_one_flash() for flash[0]
54
create
55
configure
56
includes obeying -drive if=pflash,unit=0
57
realize
58
map
59
fall back to -bios
60
create_one_flash() for flash[1]
61
create
62
configure
63
includes obeying -drive if=pflash,unit=1
64
realize
65
map
66
update FDT
67
68
To make the machine properties work, we need to move device creation
69
to its .instance_init() method virt_instance_init().
70
71
Another complication is machvirt_init()'s computation of
72
@firmware_loaded: it predicts what create_flash() will do. Instead of
73
predicting what create_flash()'s replacement virt_firmware_init() will
74
do, I decided to have virt_firmware_init() return what it did.
75
Requires calling it a bit earlier.
76
77
Resulting call tree:
78
79
main()
80
current_machine = object_new()
81
...
82
virt_instance_init()
83
virt_flash_create()
84
virt_flash_create1() for flash[0]
85
create
86
configure: set defaults
87
become child of machine [NEW]
88
add machine prop pflash0 as alias for drive [NEW]
89
virt_flash_create1() for flash[1]
90
create
91
configure: set defaults
92
become child of machine [NEW]
93
add machine prop pflash1 as alias for drive [NEW]
94
for all machine props from the command line: machine_set_property()
95
...
96
property_set_alias() for machine props pflash0, pflash1
97
...
98
set_drive() for cfi.pflash01 prop drive
99
this is how -machine pflash0=... etc set
100
machine_run_board_init(current_machine);
101
virt_firmware_init()
102
pflash_cfi01_legacy_drive()
103
legacy -drive if=pflash,unit=0 and =1 [NEW]
104
virt_flash_map()
105
virt_flash_map1() for flash[0]
106
configure: num-blocks
107
realize
108
map
109
virt_flash_map1() for flash[1]
110
configure: num-blocks
111
realize
112
map
113
fall back to -bios
114
virt_flash_fdt()
115
update FDT
116
117
You have László to thank for making me explain this in detail.
118
119
Signed-off-by: Markus Armbruster <armbru@redhat.com>
120
Acked-by: Laszlo Ersek <lersek@redhat.com>
121
Message-id: 20190416091348.26075-4-armbru@redhat.com
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
122
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Tested-by: Alex Bennée <alex.bennee@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180512003217.9105-9-richard.henderson@linaro.org
11
[rth: Diagnose lack of FP16 before fp_access_check]
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
123
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
124
---
15
target/arm/helper-a64.h | 2 +
125
include/hw/arm/virt.h | 2 +
16
target/arm/helper-a64.c | 10 +++++
126
hw/arm/virt.c | 202 +++++++++++++++++++++++++++---------------
17
target/arm/translate-a64.c | 88 ++++++++++++++++++++++++++++++--------
127
2 files changed, 132 insertions(+), 72 deletions(-)
18
3 files changed, 83 insertions(+), 17 deletions(-)
128
19
129
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
20
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
21
index XXXXXXX..XXXXXXX 100644
130
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/helper-a64.h
131
--- a/include/hw/arm/virt.h
23
+++ b/target/arm/helper-a64.h
132
+++ b/include/hw/arm/virt.h
24
@@ -XXX,XX +XXX,XX @@
133
@@ -XXX,XX +XXX,XX @@
25
DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
134
#include "qemu/notify.h"
26
DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
135
#include "hw/boards.h"
27
DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64)
136
#include "hw/arm/arm.h"
28
+DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr)
137
+#include "hw/block/flash.h"
29
+DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr)
138
#include "sysemu/kvm.h"
30
DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr)
139
#include "hw/intc/arm_gicv3_common.h"
31
DEF_HELPER_3(vfp_cmpes_a64, i64, f32, f32, ptr)
140
32
DEF_HELPER_3(vfp_cmpd_a64, i64, f64, f64, ptr)
141
@@ -XXX,XX +XXX,XX @@ typedef struct {
33
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
142
Notifier machine_done;
143
DeviceState *platform_bus_dev;
144
FWCfgState *fw_cfg;
145
+ PFlashCFI01 *flash[2];
146
bool secure;
147
bool highmem;
148
bool highmem_ecam;
149
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
34
index XXXXXXX..XXXXXXX 100644
150
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/helper-a64.c
151
--- a/hw/arm/virt.c
36
+++ b/target/arm/helper-a64.c
152
+++ b/hw/arm/virt.c
37
@@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res)
153
@@ -XXX,XX +XXX,XX @@
38
return flags;
154
39
}
155
#include "qemu/osdep.h"
40
156
#include "qemu/units.h"
41
+uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status)
157
+#include "qemu/option.h"
42
+{
158
#include "qapi/error.h"
43
+ return float_rel_to_flags(float16_compare_quiet(x, y, fp_status));
159
#include "hw/sysbus.h"
44
+}
160
#include "hw/arm/arm.h"
45
+
161
@@ -XXX,XX +XXX,XX @@ static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic)
46
+uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status)
47
+{
48
+ return float_rel_to_flags(float16_compare(x, y, fp_status));
49
+}
50
+
51
uint64_t HELPER(vfp_cmps_a64)(float32 x, float32 y, void *fp_status)
52
{
53
return float_rel_to_flags(float32_compare_quiet(x, y, fp_status));
54
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/target/arm/translate-a64.c
57
+++ b/target/arm/translate-a64.c
58
@@ -XXX,XX +XXX,XX @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn)
59
}
162
}
60
}
163
}
61
164
62
-static void handle_fp_compare(DisasContext *s, bool is_double,
165
-static void create_one_flash(const char *name, hwaddr flashbase,
63
+static void handle_fp_compare(DisasContext *s, int size,
166
- hwaddr flashsize, const char *file,
64
unsigned int rn, unsigned int rm,
167
- MemoryRegion *sysmem)
65
bool cmp_with_zero, bool signal_all_nans)
168
+#define VIRT_FLASH_SECTOR_SIZE (256 * KiB)
169
+
170
+static PFlashCFI01 *virt_flash_create1(VirtMachineState *vms,
171
+ const char *name,
172
+ const char *alias_prop_name)
66
{
173
{
67
TCGv_i64 tcg_flags = tcg_temp_new_i64();
174
- /* Create and map a single flash device. We use the same
68
- TCGv_ptr fpst = get_fpstatus_ptr(false);
175
- * parameters as the flash devices on the Versatile Express board.
69
+ TCGv_ptr fpst = get_fpstatus_ptr(size == MO_16);
176
+ /*
70
177
+ * Create a single flash device. We use the same parameters as
71
- if (is_double) {
178
+ * the flash devices on the Versatile Express board.
72
+ if (size == MO_64) {
179
*/
73
TCGv_i64 tcg_vn, tcg_vm;
180
- DriveInfo *dinfo = drive_get_next(IF_PFLASH);
74
181
DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
75
tcg_vn = read_fp_dreg(s, rn);
182
- SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
76
@@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double,
183
- const uint64_t sectorlength = 256 * 1024;
77
tcg_temp_free_i64(tcg_vn);
184
78
tcg_temp_free_i64(tcg_vm);
185
- if (dinfo) {
186
- qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo),
187
- &error_abort);
188
- }
189
-
190
- qdev_prop_set_uint32(dev, "num-blocks", flashsize / sectorlength);
191
- qdev_prop_set_uint64(dev, "sector-length", sectorlength);
192
+ qdev_prop_set_uint64(dev, "sector-length", VIRT_FLASH_SECTOR_SIZE);
193
qdev_prop_set_uint8(dev, "width", 4);
194
qdev_prop_set_uint8(dev, "device-width", 2);
195
qdev_prop_set_bit(dev, "big-endian", false);
196
@@ -XXX,XX +XXX,XX @@ static void create_one_flash(const char *name, hwaddr flashbase,
197
qdev_prop_set_uint16(dev, "id2", 0x00);
198
qdev_prop_set_uint16(dev, "id3", 0x00);
199
qdev_prop_set_string(dev, "name", name);
200
- qdev_init_nofail(dev);
201
-
202
- memory_region_add_subregion(sysmem, flashbase,
203
- sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
204
-
205
- if (file) {
206
- char *fn;
207
- int image_size;
208
-
209
- if (drive_get(IF_PFLASH, 0, 0)) {
210
- error_report("The contents of the first flash device may be "
211
- "specified with -bios or with -drive if=pflash... "
212
- "but you cannot use both options at once");
213
- exit(1);
214
- }
215
- fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, file);
216
- if (!fn) {
217
- error_report("Could not find ROM image '%s'", file);
218
- exit(1);
219
- }
220
- image_size = load_image_mr(fn, sysbus_mmio_get_region(sbd, 0));
221
- g_free(fn);
222
- if (image_size < 0) {
223
- error_report("Could not load ROM image '%s'", file);
224
- exit(1);
225
- }
226
- }
227
+ object_property_add_child(OBJECT(vms), name, OBJECT(dev),
228
+ &error_abort);
229
+ object_property_add_alias(OBJECT(vms), alias_prop_name,
230
+ OBJECT(dev), "drive", &error_abort);
231
+ return PFLASH_CFI01(dev);
232
}
233
234
-static void create_flash(const VirtMachineState *vms,
235
- MemoryRegion *sysmem,
236
- MemoryRegion *secure_sysmem)
237
+static void virt_flash_create(VirtMachineState *vms)
238
{
239
- /* Create two flash devices to fill the VIRT_FLASH space in the memmap.
240
- * Any file passed via -bios goes in the first of these.
241
+ vms->flash[0] = virt_flash_create1(vms, "virt.flash0", "pflash0");
242
+ vms->flash[1] = virt_flash_create1(vms, "virt.flash1", "pflash1");
243
+}
244
+
245
+static void virt_flash_map1(PFlashCFI01 *flash,
246
+ hwaddr base, hwaddr size,
247
+ MemoryRegion *sysmem)
248
+{
249
+ DeviceState *dev = DEVICE(flash);
250
+
251
+ assert(size % VIRT_FLASH_SECTOR_SIZE == 0);
252
+ assert(size / VIRT_FLASH_SECTOR_SIZE <= UINT32_MAX);
253
+ qdev_prop_set_uint32(dev, "num-blocks", size / VIRT_FLASH_SECTOR_SIZE);
254
+ qdev_init_nofail(dev);
255
+
256
+ memory_region_add_subregion(sysmem, base,
257
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(dev),
258
+ 0));
259
+}
260
+
261
+static void virt_flash_map(VirtMachineState *vms,
262
+ MemoryRegion *sysmem,
263
+ MemoryRegion *secure_sysmem)
264
+{
265
+ /*
266
+ * Map two flash devices to fill the VIRT_FLASH space in the memmap.
267
* sysmem is the system memory space. secure_sysmem is the secure view
268
* of the system, and the first flash device should be made visible only
269
* there. The second flash device is visible to both secure and nonsecure.
270
@@ -XXX,XX +XXX,XX @@ static void create_flash(const VirtMachineState *vms,
271
*/
272
hwaddr flashsize = vms->memmap[VIRT_FLASH].size / 2;
273
hwaddr flashbase = vms->memmap[VIRT_FLASH].base;
274
- char *nodename;
275
276
- create_one_flash("virt.flash0", flashbase, flashsize,
277
- bios_name, secure_sysmem);
278
- create_one_flash("virt.flash1", flashbase + flashsize, flashsize,
279
- NULL, sysmem);
280
+ virt_flash_map1(vms->flash[0], flashbase, flashsize,
281
+ secure_sysmem);
282
+ virt_flash_map1(vms->flash[1], flashbase + flashsize, flashsize,
283
+ sysmem);
284
+}
285
+
286
+static void virt_flash_fdt(VirtMachineState *vms,
287
+ MemoryRegion *sysmem,
288
+ MemoryRegion *secure_sysmem)
289
+{
290
+ hwaddr flashsize = vms->memmap[VIRT_FLASH].size / 2;
291
+ hwaddr flashbase = vms->memmap[VIRT_FLASH].base;
292
+ char *nodename;
293
294
if (sysmem == secure_sysmem) {
295
/* Report both flash devices as a single node in the DT */
296
@@ -XXX,XX +XXX,XX @@ static void create_flash(const VirtMachineState *vms,
297
qemu_fdt_setprop_cell(vms->fdt, nodename, "bank-width", 4);
298
g_free(nodename);
79
} else {
299
} else {
80
- TCGv_i32 tcg_vn, tcg_vm;
300
- /* Report the devices as separate nodes so we can mark one as
81
+ TCGv_i32 tcg_vn = tcg_temp_new_i32();
301
+ /*
82
+ TCGv_i32 tcg_vm = tcg_temp_new_i32();
302
+ * Report the devices as separate nodes so we can mark one as
83
303
* only visible to the secure world.
84
- tcg_vn = read_fp_sreg(s, rn);
304
*/
85
+ read_vec_element_i32(s, tcg_vn, rn, 0, size);
305
nodename = g_strdup_printf("/secflash@%" PRIx64, flashbase);
86
if (cmp_with_zero) {
306
@@ -XXX,XX +XXX,XX @@ static void create_flash(const VirtMachineState *vms,
87
- tcg_vm = tcg_const_i32(0);
88
+ tcg_gen_movi_i32(tcg_vm, 0);
89
} else {
90
- tcg_vm = read_fp_sreg(s, rm);
91
+ read_vec_element_i32(s, tcg_vm, rm, 0, size);
92
}
93
- if (signal_all_nans) {
94
- gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst);
95
- } else {
96
- gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst);
97
+
98
+ switch (size) {
99
+ case MO_32:
100
+ if (signal_all_nans) {
101
+ gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst);
102
+ } else {
103
+ gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst);
104
+ }
105
+ break;
106
+ case MO_16:
107
+ if (signal_all_nans) {
108
+ gen_helper_vfp_cmpeh_a64(tcg_flags, tcg_vn, tcg_vm, fpst);
109
+ } else {
110
+ gen_helper_vfp_cmph_a64(tcg_flags, tcg_vn, tcg_vm, fpst);
111
+ }
112
+ break;
113
+ default:
114
+ g_assert_not_reached();
115
}
116
+
117
tcg_temp_free_i32(tcg_vn);
118
tcg_temp_free_i32(tcg_vm);
119
}
307
}
120
@@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double,
308
}
121
static void disas_fp_compare(DisasContext *s, uint32_t insn)
309
310
+static bool virt_firmware_init(VirtMachineState *vms,
311
+ MemoryRegion *sysmem,
312
+ MemoryRegion *secure_sysmem)
313
+{
314
+ int i;
315
+ BlockBackend *pflash_blk0;
316
+
317
+ /* Map legacy -drive if=pflash to machine properties */
318
+ for (i = 0; i < ARRAY_SIZE(vms->flash); i++) {
319
+ pflash_cfi01_legacy_drive(vms->flash[i],
320
+ drive_get(IF_PFLASH, 0, i));
321
+ }
322
+
323
+ virt_flash_map(vms, sysmem, secure_sysmem);
324
+
325
+ pflash_blk0 = pflash_cfi01_get_blk(vms->flash[0]);
326
+
327
+ if (bios_name) {
328
+ char *fname;
329
+ MemoryRegion *mr;
330
+ int image_size;
331
+
332
+ if (pflash_blk0) {
333
+ error_report("The contents of the first flash device may be "
334
+ "specified with -bios or with -drive if=pflash... "
335
+ "but you cannot use both options at once");
336
+ exit(1);
337
+ }
338
+
339
+ /* Fall back to -bios */
340
+
341
+ fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
342
+ if (!fname) {
343
+ error_report("Could not find ROM image '%s'", bios_name);
344
+ exit(1);
345
+ }
346
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(vms->flash[0]), 0);
347
+ image_size = load_image_mr(fname, mr);
348
+ g_free(fname);
349
+ if (image_size < 0) {
350
+ error_report("Could not load ROM image '%s'", bios_name);
351
+ exit(1);
352
+ }
353
+ }
354
+
355
+ return pflash_blk0 || bios_name;
356
+}
357
+
358
static FWCfgState *create_fw_cfg(const VirtMachineState *vms, AddressSpace *as)
122
{
359
{
123
unsigned int mos, type, rm, op, rn, opc, op2r;
360
hwaddr base = vms->memmap[VIRT_FW_CFG].base;
124
+ int size;
361
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
125
362
MemoryRegion *secure_sysmem = NULL;
126
mos = extract32(insn, 29, 3);
363
int n, virt_max_cpus;
127
- type = extract32(insn, 22, 2); /* 0 = single, 1 = double */
364
MemoryRegion *ram = g_new(MemoryRegion, 1);
128
+ type = extract32(insn, 22, 2);
365
- bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0);
129
rm = extract32(insn, 16, 5);
366
+ bool firmware_loaded;
130
op = extract32(insn, 14, 2);
367
bool aarch64 = true;
131
rn = extract32(insn, 5, 5);
368
132
opc = extract32(insn, 3, 2);
369
/*
133
op2r = extract32(insn, 0, 3);
370
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
134
371
exit(1);
135
- if (mos || op || op2r || type > 1) {
372
}
136
+ if (mos || op || op2r) {
373
137
+ unallocated_encoding(s);
374
+ if (vms->secure) {
138
+ return;
375
+ if (kvm_enabled()) {
376
+ error_report("mach-virt: KVM does not support Security extensions");
377
+ exit(1);
378
+ }
379
+
380
+ /*
381
+ * The Secure view of the world is the same as the NonSecure,
382
+ * but with a few extra devices. Create it as a container region
383
+ * containing the system memory at low priority; any secure-only
384
+ * devices go in at higher priority and take precedence.
385
+ */
386
+ secure_sysmem = g_new(MemoryRegion, 1);
387
+ memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory",
388
+ UINT64_MAX);
389
+ memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
139
+ }
390
+ }
140
+
391
+
141
+ switch (type) {
392
+ firmware_loaded = virt_firmware_init(vms, sysmem,
142
+ case 0:
393
+ secure_sysmem ?: sysmem);
143
+ size = MO_32;
394
+
144
+ break;
395
/* If we have an EL3 boot ROM then the assumption is that it will
145
+ case 1:
396
* implement PSCI itself, so disable QEMU's internal implementation
146
+ size = MO_64;
397
* so it doesn't get in the way. Instead of starting secondary
147
+ break;
398
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
148
+ case 3:
399
exit(1);
149
+ size = MO_16;
150
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
151
+ break;
152
+ }
153
+ /* fallthru */
154
+ default:
155
unallocated_encoding(s);
156
return;
157
}
400
}
158
@@ -XXX,XX +XXX,XX @@ static void disas_fp_compare(DisasContext *s, uint32_t insn)
401
159
return;
402
- if (vms->secure) {
403
- if (kvm_enabled()) {
404
- error_report("mach-virt: KVM does not support Security extensions");
405
- exit(1);
406
- }
407
-
408
- /* The Secure view of the world is the same as the NonSecure,
409
- * but with a few extra devices. Create it as a container region
410
- * containing the system memory at low priority; any secure-only
411
- * devices go in at higher priority and take precedence.
412
- */
413
- secure_sysmem = g_new(MemoryRegion, 1);
414
- memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory",
415
- UINT64_MAX);
416
- memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
417
- }
418
-
419
create_fdt(vms);
420
421
possible_cpus = mc->possible_cpu_arch_ids(machine);
422
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
423
&machine->device_memory->mr);
160
}
424
}
161
425
162
- handle_fp_compare(s, type, rn, rm, opc & 1, opc & 2);
426
- create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem);
163
+ handle_fp_compare(s, size, rn, rm, opc & 1, opc & 2);
427
+ virt_flash_fdt(vms, sysmem, secure_sysmem);
428
429
create_gic(vms, pic);
430
431
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
432
NULL);
433
434
vms->irqmap = a15irqmap;
435
+
436
+ virt_flash_create(vms);
164
}
437
}
165
438
166
/* Floating point conditional compare
439
static const TypeInfo virt_machine_info = {
167
@@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn)
168
unsigned int mos, type, rm, cond, rn, op, nzcv;
169
TCGv_i64 tcg_flags;
170
TCGLabel *label_continue = NULL;
171
+ int size;
172
173
mos = extract32(insn, 29, 3);
174
- type = extract32(insn, 22, 2); /* 0 = single, 1 = double */
175
+ type = extract32(insn, 22, 2);
176
rm = extract32(insn, 16, 5);
177
cond = extract32(insn, 12, 4);
178
rn = extract32(insn, 5, 5);
179
op = extract32(insn, 4, 1);
180
nzcv = extract32(insn, 0, 4);
181
182
- if (mos || type > 1) {
183
+ if (mos) {
184
+ unallocated_encoding(s);
185
+ return;
186
+ }
187
+
188
+ switch (type) {
189
+ case 0:
190
+ size = MO_32;
191
+ break;
192
+ case 1:
193
+ size = MO_64;
194
+ break;
195
+ case 3:
196
+ size = MO_16;
197
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
198
+ break;
199
+ }
200
+ /* fallthru */
201
+ default:
202
unallocated_encoding(s);
203
return;
204
}
205
@@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn)
206
gen_set_label(label_match);
207
}
208
209
- handle_fp_compare(s, type, rn, rm, false, op);
210
+ handle_fp_compare(s, size, rn, rm, false, op);
211
212
if (cond < 0x0e) {
213
gen_set_label(label_continue);
214
--
440
--
215
2.17.0
441
2.20.1
216
442
217
443
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
The Raspberry Pi boards have a physical memory map which does
2
not allow for more than 1GB of RAM. Currently if the user tries
3
to ask for more then we fail in a confusing way:
2
4
3
These were missed out from the rest of the half-precision work.
5
$ qemu-system-aarch64 --machine raspi3 -m 8G
6
Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164:
7
qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t
8
Aborted (core dumped)
4
9
5
Cc: qemu-stable@nongnu.org
10
Catch this earlier and diagnose it with a more friendly message:
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
$ qemu-system-aarch64 --machine raspi3 -m 8G
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
12
qemu-system-aarch64: Requested ram size is too large for this machine: maximum is 1GB
8
Tested-by: Alex Bennée <alex.bennee@linaro.org>
13
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Fixes: https://bugs.launchpad.net/qemu/+bug/1794187
10
Message-id: 20180512003217.9105-10-richard.henderson@linaro.org
11
[rth: Fix erroneous check vs type]
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
14
---
19
---
15
target/arm/translate-a64.c | 31 +++++++++++++++++++++++++------
20
hw/arm/raspi.c | 7 +++++++
16
1 file changed, 25 insertions(+), 6 deletions(-)
21
1 file changed, 7 insertions(+)
17
22
18
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
23
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
19
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate-a64.c
25
--- a/hw/arm/raspi.c
21
+++ b/target/arm/translate-a64.c
26
+++ b/hw/arm/raspi.c
22
@@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
27
@@ -XXX,XX +XXX,XX @@
23
unsigned int mos, type, rm, cond, rn, rd;
28
*/
24
TCGv_i64 t_true, t_false, t_zero;
29
25
DisasCompare64 c;
30
#include "qemu/osdep.h"
26
+ TCGMemOp sz;
31
+#include "qemu/units.h"
27
32
#include "qapi/error.h"
28
mos = extract32(insn, 29, 3);
33
#include "qemu-common.h"
29
- type = extract32(insn, 22, 2); /* 0 = single, 1 = double */
34
#include "cpu.h"
30
+ type = extract32(insn, 22, 2);
35
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
31
rm = extract32(insn, 16, 5);
36
BusState *bus;
32
cond = extract32(insn, 12, 4);
37
DeviceState *carddev;
33
rn = extract32(insn, 5, 5);
38
34
rd = extract32(insn, 0, 5);
39
+ if (machine->ram_size > 1 * GiB) {
35
40
+ error_report("Requested ram size is too large for this machine: "
36
- if (mos || type > 1) {
41
+ "maximum is 1GB");
37
+ if (mos) {
42
+ exit(1);
38
+ unallocated_encoding(s);
39
+ return;
40
+ }
43
+ }
41
+
44
+
42
+ switch (type) {
45
object_initialize(&s->soc, sizeof(s->soc),
43
+ case 0:
46
version == 3 ? TYPE_BCM2837 : TYPE_BCM2836);
44
+ sz = MO_32;
47
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
45
+ break;
46
+ case 1:
47
+ sz = MO_64;
48
+ break;
49
+ case 3:
50
+ sz = MO_16;
51
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
52
+ break;
53
+ }
54
+ /* fallthru */
55
+ default:
56
unallocated_encoding(s);
57
return;
58
}
59
@@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
60
return;
61
}
62
63
- /* Zero extend sreg inputs to 64 bits now. */
64
+ /* Zero extend sreg & hreg inputs to 64 bits now. */
65
t_true = tcg_temp_new_i64();
66
t_false = tcg_temp_new_i64();
67
- read_vec_element(s, t_true, rn, 0, type ? MO_64 : MO_32);
68
- read_vec_element(s, t_false, rm, 0, type ? MO_64 : MO_32);
69
+ read_vec_element(s, t_true, rn, 0, sz);
70
+ read_vec_element(s, t_false, rm, 0, sz);
71
72
a64_test_cc(&c, cond);
73
t_zero = tcg_const_i64(0);
74
@@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
75
tcg_temp_free_i64(t_false);
76
a64_free_cc(&c);
77
78
- /* Note that sregs write back zeros to the high bits,
79
+ /* Note that sregs & hregs write back zeros to the high bits,
80
and we've already done the zero-extension. */
81
write_fp_dreg(s, rd, t_true);
82
tcg_temp_free_i64(t_true);
83
--
48
--
84
2.17.0
49
2.20.1
85
50
86
51
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
At the moment the Arm implementations of kvm_arch_{get,put}_registers()
2
2
don't support having QEMU change the values of system registers
3
Cc: qemu-stable@nongnu.org
3
(aka coprocessor registers for AArch32). This is because although
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
kvm_arch_get_registers() calls write_list_to_cpustate() to
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
update the CPU state struct fields (so QEMU code can read the
6
Tested-by: Alex Bennée <alex.bennee@linaro.org>
6
values in the usual way), kvm_arch_put_registers() does not
7
Message-id: 20180512003217.9105-4-richard.henderson@linaro.org
7
call write_cpustate_to_list(), meaning that any changes to
8
the CPU state struct fields will not be passed back to KVM.
9
10
The rationale for this design is documented in a comment in the
11
AArch32 kvm_arch_put_registers() -- writing the values in the
12
cpregs list into the CPU state struct is "lossy" because the
13
write of a register might not succeed, and so if we blindly
14
copy the CPU state values back again we will incorrectly
15
change register values for the guest. The assumption was that
16
no QEMU code would need to write to the registers.
17
18
However, when we implemented debug support for KVM guests, we
19
broke that assumption: the code to handle "set the guest up
20
to take a breakpoint exception" does so by updating various
21
guest registers including ESR_EL1.
22
23
Support this by making kvm_arch_put_registers() synchronize
24
CPU state back into the list. We sync only those registers
25
where the initial write succeeds, which should be sufficient.
26
27
This commit is the same as commit 823e1b3818f9b10b824ddc which we
28
had to revert in commit 942f99c825fc94c8b1a4, except that the bug
29
which was preventing EDK2 guest firmware running has been fixed:
30
kvm_arm_reset_vcpu() now calls write_list_to_cpustate().
31
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
33
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
34
Tested-by: Eric Auger <eric.auger@redhat.com>
9
---
35
---
10
target/arm/helper.h | 6 +++
36
target/arm/cpu.h | 9 ++++++++-
11
target/arm/helper.c | 38 ++++++++++++++-
37
target/arm/helper.c | 27 +++++++++++++++++++++++++--
12
target/arm/translate-a64.c | 96 +++++++++++++++++++++++++++++++-------
38
target/arm/kvm.c | 8 ++++++++
13
3 files changed, 122 insertions(+), 18 deletions(-)
39
target/arm/kvm32.c | 20 ++------------------
14
40
target/arm/kvm64.c | 2 ++
15
diff --git a/target/arm/helper.h b/target/arm/helper.h
41
target/arm/machine.c | 2 +-
16
index XXXXXXX..XXXXXXX 100644
42
6 files changed, 46 insertions(+), 22 deletions(-)
17
--- a/target/arm/helper.h
43
18
+++ b/target/arm/helper.h
44
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr)
45
index XXXXXXX..XXXXXXX 100644
20
DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr)
46
--- a/target/arm/cpu.h
21
DEF_HELPER_3(vfp_touhh, i32, f16, i32, ptr)
47
+++ b/target/arm/cpu.h
22
DEF_HELPER_3(vfp_toshh, i32, f16, i32, ptr)
48
@@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu);
23
+DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr)
49
/**
24
+DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr)
50
* write_cpustate_to_list:
25
+DEF_HELPER_3(vfp_touqh, i64, f16, i32, ptr)
51
* @cpu: ARMCPU
26
+DEF_HELPER_3(vfp_tosqh, i64, f16, i32, ptr)
52
+ * @kvm_sync: true if this is for syncing back to KVM
27
DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr)
53
*
28
DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr)
54
* For each register listed in the ARMCPU cpreg_indexes list, write
29
DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr)
55
* its value from the ARMCPUState structure into the cpreg_values list.
30
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr)
56
* This is used to copy info from TCG's working data structures into
31
DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr)
57
* KVM or for outbound migration.
32
DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr)
58
*
33
DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr)
59
+ * @kvm_sync is true if we are doing this in order to sync the
34
+DEF_HELPER_3(vfp_sqtoh, f16, i64, i32, ptr)
60
+ * register state back to KVM. In this case we will only update
35
+DEF_HELPER_3(vfp_uqtoh, f16, i64, i32, ptr)
61
+ * values in the list if the previous list->cpustate sync actually
36
62
+ * successfully wrote the CPU state. Otherwise we will keep the value
37
DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr)
63
+ * that is in the list.
38
DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env)
64
+ *
65
* Returns: true if all register values were read correctly,
66
* false if some register was unknown or could not be read.
67
* Note that we do not stop early on failure -- we will attempt
68
* reading all registers in the list.
69
*/
70
-bool write_cpustate_to_list(ARMCPU *cpu);
71
+bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
72
73
#define ARM_CPUID_TI915T 0x54029152
74
#define ARM_CPUID_TI925T 0x54029252
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
75
diff --git a/target/arm/helper.c b/target/arm/helper.c
40
index XXXXXXX..XXXXXXX 100644
76
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/helper.c
77
--- a/target/arm/helper.c
42
+++ b/target/arm/helper.c
78
+++ b/target/arm/helper.c
43
@@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64)
79
@@ -XXX,XX +XXX,XX @@ static bool raw_accessors_invalid(const ARMCPRegInfo *ri)
44
#undef VFP_CONV_FIX_A64
80
return true;
45
46
/* Conversion to/from f16 can overflow to infinity before/after scaling.
47
- * Therefore we convert to f64 (which does not round), scale,
48
- * and then convert f64 to f16 (which may round).
49
+ * Therefore we convert to f64, scale, and then convert f64 to f16; or
50
+ * vice versa for conversion to integer.
51
+ *
52
+ * For 16- and 32-bit integers, the conversion to f64 never rounds.
53
+ * For 64-bit integers, any integer that would cause rounding will also
54
+ * overflow to f16 infinity, so there is no double rounding problem.
55
*/
56
57
static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst)
58
@@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst)
59
return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst);
60
}
81
}
61
82
62
+float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst)
83
-bool write_cpustate_to_list(ARMCPU *cpu)
63
+{
84
+bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync)
64
+ return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst);
65
+}
66
+
67
+float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
68
+{
69
+ return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst);
70
+}
71
+
72
static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst)
73
{
85
{
74
if (unlikely(float16_is_any_nan(f))) {
86
/* Write the coprocessor state from cpu->env to the (index,value) list. */
75
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst)
87
int i;
76
return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst);
88
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu)
89
for (i = 0; i < cpu->cpreg_array_len; i++) {
90
uint32_t regidx = kvm_to_cpreg_id(cpu->cpreg_indexes[i]);
91
const ARMCPRegInfo *ri;
92
+ uint64_t newval;
93
94
ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
95
if (!ri) {
96
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu)
97
if (ri->type & ARM_CP_NO_RAW) {
98
continue;
99
}
100
- cpu->cpreg_values[i] = read_raw_cp_reg(&cpu->env, ri);
101
+
102
+ newval = read_raw_cp_reg(&cpu->env, ri);
103
+ if (kvm_sync) {
104
+ /*
105
+ * Only sync if the previous list->cpustate sync succeeded.
106
+ * Rather than tracking the success/failure state for every
107
+ * item in the list, we just recheck "does the raw write we must
108
+ * have made in write_list_to_cpustate() read back OK" here.
109
+ */
110
+ uint64_t oldval = cpu->cpreg_values[i];
111
+
112
+ if (oldval == newval) {
113
+ continue;
114
+ }
115
+
116
+ write_raw_cp_reg(&cpu->env, ri, oldval);
117
+ if (read_raw_cp_reg(&cpu->env, ri) != oldval) {
118
+ continue;
119
+ }
120
+
121
+ write_raw_cp_reg(&cpu->env, ri, newval);
122
+ }
123
+ cpu->cpreg_values[i] = newval;
124
}
125
return ok;
77
}
126
}
78
127
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
79
+uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst)
128
index XXXXXXX..XXXXXXX 100644
80
+{
129
--- a/target/arm/kvm.c
81
+ return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst);
130
+++ b/target/arm/kvm.c
82
+}
131
@@ -XXX,XX +XXX,XX @@ void kvm_arm_reset_vcpu(ARMCPU *cpu)
83
+
132
fprintf(stderr, "write_kvmstate_to_list failed\n");
84
+uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst)
133
abort();
85
+{
134
}
86
+ return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst);
135
+ /*
87
+}
136
+ * Sync the reset values also into the CPUState. This is necessary
88
+
137
+ * because the next thing we do will be a kvm_arch_put_registers()
89
+uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst)
138
+ * which will update the list values from the CPUState before copying
90
+{
139
+ * the list values back to KVM. It's OK to ignore failure returns here
91
+ return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst);
140
+ * for the same reason we do so in kvm_arch_get_registers().
92
+}
141
+ */
93
+
142
+ write_list_to_cpustate(cpu);
94
+uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst)
143
}
95
+{
144
96
+ return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst);
145
/*
97
+}
146
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
98
+
147
index XXXXXXX..XXXXXXX 100644
99
/* Set the current fp rounding mode and return the old one.
148
--- a/target/arm/kvm32.c
100
* The argument is a softfloat float_round_ value.
149
+++ b/target/arm/kvm32.c
101
*/
150
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
102
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
151
return ret;
103
index XXXXXXX..XXXXXXX 100644
152
}
104
--- a/target/arm/translate-a64.c
153
105
+++ b/target/arm/translate-a64.c
154
- /* Note that we do not call write_cpustate_to_list()
106
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
155
- * here, so we are only writing the tuple list back to
107
bool itof, int rmode, int scale, int sf, int type)
156
- * KVM. This is safe because nothing can change the
108
{
157
- * CPUARMState cp15 fields (in particular gdb accesses cannot)
109
bool is_signed = !(opcode & 1);
158
- * and so there are no changes to sync. In fact syncing would
110
- bool is_double = type;
159
- * be wrong at this point: for a constant register where TCG and
111
TCGv_ptr tcg_fpstatus;
160
- * KVM disagree about its value, the preceding write_list_to_cpustate()
112
- TCGv_i32 tcg_shift;
161
- * would not have had any effect on the CPUARMState value (since the
113
+ TCGv_i32 tcg_shift, tcg_single;
162
- * register is read-only), and a write_cpustate_to_list() here would
114
+ TCGv_i64 tcg_double;
163
- * then try to write the TCG value back into KVM -- this would either
115
164
- * fail or incorrectly change the value the guest sees.
116
- tcg_fpstatus = get_fpstatus_ptr(false);
165
- *
117
+ tcg_fpstatus = get_fpstatus_ptr(type == 3);
166
- * If we ever want to allow the user to modify cp15 registers via
118
167
- * the gdb stub, we would need to be more clever here (for instance
119
tcg_shift = tcg_const_i32(64 - scale);
168
- * tracking the set of registers kvm_arch_get_registers() successfully
120
169
- * managed to update the CPUARMState with, and only allowing those
121
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
170
- * to be written back up into the kernel).
122
tcg_int = tcg_extend;
171
- */
123
}
172
+ write_cpustate_to_list(cpu, true);
124
173
+
125
- if (is_double) {
174
if (!write_list_to_kvmstate(cpu, level)) {
126
- TCGv_i64 tcg_double = tcg_temp_new_i64();
175
return EINVAL;
127
+ switch (type) {
176
}
128
+ case 1: /* float64 */
177
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
129
+ tcg_double = tcg_temp_new_i64();
178
index XXXXXXX..XXXXXXX 100644
130
if (is_signed) {
179
--- a/target/arm/kvm64.c
131
gen_helper_vfp_sqtod(tcg_double, tcg_int,
180
+++ b/target/arm/kvm64.c
132
tcg_shift, tcg_fpstatus);
181
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
133
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
182
return ret;
134
}
183
}
135
write_fp_dreg(s, rd, tcg_double);
184
136
tcg_temp_free_i64(tcg_double);
185
+ write_cpustate_to_list(cpu, true);
137
- } else {
186
+
138
- TCGv_i32 tcg_single = tcg_temp_new_i32();
187
if (!write_list_to_kvmstate(cpu, level)) {
139
+ break;
188
return EINVAL;
140
+
189
}
141
+ case 0: /* float32 */
190
diff --git a/target/arm/machine.c b/target/arm/machine.c
142
+ tcg_single = tcg_temp_new_i32();
191
index XXXXXXX..XXXXXXX 100644
143
if (is_signed) {
192
--- a/target/arm/machine.c
144
gen_helper_vfp_sqtos(tcg_single, tcg_int,
193
+++ b/target/arm/machine.c
145
tcg_shift, tcg_fpstatus);
194
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
146
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
195
abort();
147
}
148
write_fp_sreg(s, rd, tcg_single);
149
tcg_temp_free_i32(tcg_single);
150
+ break;
151
+
152
+ case 3: /* float16 */
153
+ tcg_single = tcg_temp_new_i32();
154
+ if (is_signed) {
155
+ gen_helper_vfp_sqtoh(tcg_single, tcg_int,
156
+ tcg_shift, tcg_fpstatus);
157
+ } else {
158
+ gen_helper_vfp_uqtoh(tcg_single, tcg_int,
159
+ tcg_shift, tcg_fpstatus);
160
+ }
161
+ write_fp_sreg(s, rd, tcg_single);
162
+ tcg_temp_free_i32(tcg_single);
163
+ break;
164
+
165
+ default:
166
+ g_assert_not_reached();
167
}
196
}
168
} else {
197
} else {
169
TCGv_i64 tcg_int = cpu_reg(s, rd);
198
- if (!write_cpustate_to_list(cpu)) {
170
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
199
+ if (!write_cpustate_to_list(cpu, false)) {
171
200
/* This should never fail. */
172
gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
201
abort();
173
174
- if (is_double) {
175
- TCGv_i64 tcg_double = read_fp_dreg(s, rn);
176
+ switch (type) {
177
+ case 1: /* float64 */
178
+ tcg_double = read_fp_dreg(s, rn);
179
if (is_signed) {
180
if (!sf) {
181
gen_helper_vfp_tosld(tcg_int, tcg_double,
182
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
183
tcg_shift, tcg_fpstatus);
184
}
185
}
186
+ if (!sf) {
187
+ tcg_gen_ext32u_i64(tcg_int, tcg_int);
188
+ }
189
tcg_temp_free_i64(tcg_double);
190
- } else {
191
- TCGv_i32 tcg_single = read_fp_sreg(s, rn);
192
+ break;
193
+
194
+ case 0: /* float32 */
195
+ tcg_single = read_fp_sreg(s, rn);
196
if (sf) {
197
if (is_signed) {
198
gen_helper_vfp_tosqs(tcg_int, tcg_single,
199
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
200
tcg_temp_free_i32(tcg_dest);
201
}
202
tcg_temp_free_i32(tcg_single);
203
+ break;
204
+
205
+ case 3: /* float16 */
206
+ tcg_single = read_fp_sreg(s, rn);
207
+ if (sf) {
208
+ if (is_signed) {
209
+ gen_helper_vfp_tosqh(tcg_int, tcg_single,
210
+ tcg_shift, tcg_fpstatus);
211
+ } else {
212
+ gen_helper_vfp_touqh(tcg_int, tcg_single,
213
+ tcg_shift, tcg_fpstatus);
214
+ }
215
+ } else {
216
+ TCGv_i32 tcg_dest = tcg_temp_new_i32();
217
+ if (is_signed) {
218
+ gen_helper_vfp_toslh(tcg_dest, tcg_single,
219
+ tcg_shift, tcg_fpstatus);
220
+ } else {
221
+ gen_helper_vfp_toulh(tcg_dest, tcg_single,
222
+ tcg_shift, tcg_fpstatus);
223
+ }
224
+ tcg_gen_extu_i32_i64(tcg_int, tcg_dest);
225
+ tcg_temp_free_i32(tcg_dest);
226
+ }
227
+ tcg_temp_free_i32(tcg_single);
228
+ break;
229
+
230
+ default:
231
+ g_assert_not_reached();
232
}
233
234
gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
235
tcg_temp_free_i32(tcg_rmode);
236
-
237
- if (!sf) {
238
- tcg_gen_ext32u_i64(tcg_int, tcg_int);
239
- }
240
}
241
242
tcg_temp_free_ptr(tcg_fpstatus);
243
@@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn)
244
/* actual FP conversions */
245
bool itof = extract32(opcode, 1, 1);
246
247
- if (type > 1 || (rmode != 0 && opcode > 1)) {
248
+ if (rmode != 0 && opcode > 1) {
249
+ unallocated_encoding(s);
250
+ return;
251
+ }
252
+ switch (type) {
253
+ case 0: /* float32 */
254
+ case 1: /* float64 */
255
+ break;
256
+ case 3: /* float16 */
257
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
258
+ break;
259
+ }
260
+ /* fallthru */
261
+ default:
262
unallocated_encoding(s);
263
return;
264
}
202
}
265
--
203
--
266
2.17.0
204
2.20.1
267
205
268
206
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Joel Stanley <joel@jms.id.au>
2
2
3
Per the Physical Layer Simplified Spec. "4.3.10.4 Switch Function Status":
3
We currently use Qemu's default of 128MB. As we know how much ram each
4
machine ships with, make it easier on users by setting a default.
4
5
5
The block length is predefined to 512 bits
6
It can still be overridden with -m on the command line.
6
7
7
and "4.10.2 SD Status":
8
Signed-off-by: Joel Stanley <joel@jms.id.au>
8
9
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
9
The SD Status contains status bits that are related to the SD Memory Card
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
proprietary features and may be used for future application-specific usage.
11
Message-id: 20190503022958.1394-1-joel@jms.id.au
11
The size of the SD Status is one data block of 512 bit. The content of this
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
register is transmitted to the Host over the DAT bus along with a 16-bit CRC.
13
14
Thus the 16-bit CRC goes at offset 64.
15
16
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20180509060104.4458-3-f4bug@amsat.org
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
14
---
21
hw/sd/sd.c | 2 +-
15
include/hw/arm/aspeed.h | 1 +
22
1 file changed, 1 insertion(+), 1 deletion(-)
16
hw/arm/aspeed.c | 8 ++++++++
17
2 files changed, 9 insertions(+)
23
18
24
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
19
diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
25
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/sd/sd.c
21
--- a/include/hw/arm/aspeed.h
27
+++ b/hw/sd/sd.c
22
+++ b/include/hw/arm/aspeed.h
28
@@ -XXX,XX +XXX,XX @@ static void sd_function_switch(SDState *sd, uint32_t arg)
23
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedBoardConfig {
29
sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4);
24
const char *spi_model;
30
}
25
uint32_t num_cs;
31
memset(&sd->data[17], 0, 47);
26
void (*i2c_init)(AspeedBoardState *bmc);
32
- stw_be_p(sd->data + 65, sd_crc16(sd->data, 64));
27
+ uint32_t ram;
33
+ stw_be_p(sd->data + 64, sd_crc16(sd->data, 64));
28
} AspeedBoardConfig;
29
30
#define TYPE_ASPEED_MACHINE MACHINE_TYPE_NAME("aspeed")
31
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/aspeed.c
34
+++ b/hw/arm/aspeed.c
35
@@ -XXX,XX +XXX,XX @@
36
#include "sysemu/block-backend.h"
37
#include "hw/loader.h"
38
#include "qemu/error-report.h"
39
+#include "qemu/units.h"
40
41
static struct arm_boot_info aspeed_board_binfo = {
42
.board_id = -1, /* device-tree-only board */
43
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data)
44
mc->no_floppy = 1;
45
mc->no_cdrom = 1;
46
mc->no_parallel = 1;
47
+ if (board->ram) {
48
+ mc->default_ram_size = board->ram;
49
+ }
50
amc->board = board;
34
}
51
}
35
52
36
static inline bool sd_wp_addr(SDState *sd, uint64_t addr)
53
@@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = {
54
.spi_model = "mx25l25635e",
55
.num_cs = 1,
56
.i2c_init = palmetto_bmc_i2c_init,
57
+ .ram = 256 * MiB,
58
}, {
59
.name = MACHINE_TYPE_NAME("ast2500-evb"),
60
.desc = "Aspeed AST2500 EVB (ARM1176)",
61
@@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = {
62
.spi_model = "mx25l25635e",
63
.num_cs = 1,
64
.i2c_init = ast2500_evb_i2c_init,
65
+ .ram = 512 * MiB,
66
}, {
67
.name = MACHINE_TYPE_NAME("romulus-bmc"),
68
.desc = "OpenPOWER Romulus BMC (ARM1176)",
69
@@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = {
70
.spi_model = "mx66l1g45g",
71
.num_cs = 2,
72
.i2c_init = romulus_bmc_i2c_init,
73
+ .ram = 512 * MiB,
74
}, {
75
.name = MACHINE_TYPE_NAME("witherspoon-bmc"),
76
.desc = "OpenPOWER Witherspoon BMC (ARM1176)",
77
@@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = {
78
.spi_model = "mx66l1g45g",
79
.num_cs = 2,
80
.i2c_init = witherspoon_bmc_i2c_init,
81
+ .ram = 512 * MiB,
82
},
83
};
84
37
--
85
--
38
2.17.0
86
2.20.1
39
87
40
88
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Cao Jiaxi <driver1998@foxmail.com>
2
2
3
All the hard work is already done by vfp_expand_imm, we just need to
3
gcc_struct is for x86 only, and it generates an warning on ARM64 Clang/MinGW targets.
4
make sure we pick up the correct size.
5
4
6
Cc: qemu-stable@nongnu.org
5
Signed-off-by: Cao Jiaxi <driver1998@foxmail.com>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Thomas Huth <thuth@redhat.com>
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
Message-id: 20190503003618.10089-1-driver1998@foxmail.com
9
Tested-by: Alex Bennée <alex.bennee@linaro.org>
8
[PMM: dropped the slirp change as slirp is now a submodule]
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180512003217.9105-11-richard.henderson@linaro.org
12
[rth: Merge unallocated_encoding check with TCGMemOp conversion.]
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
10
---
16
target/arm/translate-a64.c | 20 +++++++++++++++++---
11
contrib/libvhost-user/libvhost-user.h | 2 +-
17
1 file changed, 17 insertions(+), 3 deletions(-)
12
include/qemu/compiler.h | 2 +-
13
scripts/cocci-macro-file.h | 7 ++++++-
14
3 files changed, 8 insertions(+), 3 deletions(-)
18
15
19
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
16
diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/libvhost-user.h
20
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/translate-a64.c
18
--- a/contrib/libvhost-user/libvhost-user.h
22
+++ b/target/arm/translate-a64.c
19
+++ b/contrib/libvhost-user/libvhost-user.h
23
@@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn)
20
@@ -XXX,XX +XXX,XX @@ typedef struct VhostUserInflight {
24
{
21
uint16_t queue_size;
25
int rd = extract32(insn, 0, 5);
22
} VhostUserInflight;
26
int imm8 = extract32(insn, 13, 8);
23
27
- int is_double = extract32(insn, 22, 2);
24
-#if defined(_WIN32)
28
+ int type = extract32(insn, 22, 2);
25
+#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
29
uint64_t imm;
26
# define VU_PACKED __attribute__((gcc_struct, packed))
30
TCGv_i64 tcg_res;
27
#else
31
+ TCGMemOp sz;
28
# define VU_PACKED __attribute__((packed))
32
29
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
33
- if (is_double > 1) {
30
index XXXXXXX..XXXXXXX 100644
34
+ switch (type) {
31
--- a/include/qemu/compiler.h
35
+ case 0:
32
+++ b/include/qemu/compiler.h
36
+ sz = MO_32;
33
@@ -XXX,XX +XXX,XX @@
37
+ break;
34
38
+ case 1:
35
#define QEMU_SENTINEL __attribute__((sentinel))
39
+ sz = MO_64;
36
40
+ break;
37
-#if defined(_WIN32)
41
+ case 3:
38
+#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
42
+ sz = MO_16;
39
# define QEMU_PACKED __attribute__((gcc_struct, packed))
43
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
40
#else
44
+ break;
41
# define QEMU_PACKED __attribute__((packed))
45
+ }
42
diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
46
+ /* fallthru */
43
index XXXXXXX..XXXXXXX 100644
47
+ default:
44
--- a/scripts/cocci-macro-file.h
48
unallocated_encoding(s);
45
+++ b/scripts/cocci-macro-file.h
49
return;
46
@@ -XXX,XX +XXX,XX @@
50
}
47
#define QEMU_NORETURN __attribute__ ((__noreturn__))
51
@@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn)
48
#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
52
return;
49
#define QEMU_SENTINEL __attribute__((sentinel))
53
}
50
-#define QEMU_PACKED __attribute__((gcc_struct, packed))
54
51
+
55
- imm = vfp_expand_imm(MO_32 + is_double, imm8);
52
+#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
56
+ imm = vfp_expand_imm(sz, imm8);
53
+# define QEMU_PACKED __attribute__((gcc_struct, packed))
57
54
+#else
58
tcg_res = tcg_const_i64(imm);
55
+# define QEMU_PACKED __attribute__((packed))
59
write_fp_dreg(s, rd, tcg_res);
56
+#endif
57
58
#define cat(x,y) x ## y
59
#define cat2(x,y) cat(x,y)
60
--
60
--
61
2.17.0
61
2.20.1
62
62
63
63
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Cao Jiaxi <driver1998@foxmail.com>
2
2
3
No sense in emitting code after the exception.
3
The win2qemu[] is supposed to be the conversion table to convert between
4
STORAGE_BUS_TYPE in Windows SDK and GuestDiskBusType in qga.
4
5
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
But it was incorrectly written that it forces to set a GuestDiskBusType
6
Tested-by: Alex Bennée <alex.bennee@linaro.org>
7
value to STORAGE_BUS_TYPE, which generates an enum conversion warning in clang.
7
Message-id: 20180512003217.9105-3-richard.henderson@linaro.org
8
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Suggested-by: Eric Blake <eblake@redhat.com>
10
Signed-off-by: Cao Jiaxi <driver1998@foxmail.com>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Thomas Huth <thuth@redhat.com>
13
Message-id: 20190503003650.10137-1-driver1998@foxmail.com
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
15
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
17
---
11
target/arm/translate-a64.c | 2 +-
18
qga/commands-win32.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
19
1 file changed, 1 insertion(+), 1 deletion(-)
13
20
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
21
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
15
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
23
--- a/qga/commands-win32.c
17
+++ b/target/arm/translate-a64.c
24
+++ b/qga/commands-win32.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn)
25
@@ -XXX,XX +XXX,XX @@ void qmp_guest_file_flush(int64_t handle, Error **errp)
19
default:
26
20
/* all other sf/type/rmode combinations are invalid */
27
#ifdef CONFIG_QGA_NTDDSCSI
21
unallocated_encoding(s);
28
22
- break;
29
-static STORAGE_BUS_TYPE win2qemu[] = {
23
+ return;
30
+static GuestDiskBusType win2qemu[] = {
24
}
31
[BusTypeUnknown] = GUEST_DISK_BUS_TYPE_UNKNOWN,
25
32
[BusTypeScsi] = GUEST_DISK_BUS_TYPE_SCSI,
26
if (!fp_access_check(s)) {
33
[BusTypeAtapi] = GUEST_DISK_BUS_TYPE_IDE,
27
--
34
--
28
2.17.0
35
2.20.1
29
36
30
37
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Cao Jiaxi <driver1998@foxmail.com>
2
2
3
Reported by Coverity (CID1390635). We ensure this for uint_to_float
3
Windows ARM64 uses LLP64 model, which breaks current assumptions.
4
later on so we might as well mirror that.
5
4
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Cao Jiaxi <driver1998@foxmail.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
8
Message-id: 20190503003707.10185-1-driver1998@foxmail.com
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
fpu/softfloat.c | 2 +-
13
util/cacheinfo.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
13
15
14
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
16
diff --git a/util/cacheinfo.c b/util/cacheinfo.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/fpu/softfloat.c
18
--- a/util/cacheinfo.c
17
+++ b/fpu/softfloat.c
19
+++ b/util/cacheinfo.c
18
@@ -XXX,XX +XXX,XX @@ FLOAT_TO_UINT(64, 64)
20
@@ -XXX,XX +XXX,XX @@ static void sys_cache_info(int *isize, int *dsize)
19
21
static void arch_cache_info(int *isize, int *dsize)
20
static FloatParts int_to_float(int64_t a, float_status *status)
21
{
22
{
22
- FloatParts r;
23
if (*isize == 0 || *dsize == 0) {
23
+ FloatParts r = {};
24
- unsigned long ctr;
24
if (a == 0) {
25
+ uint64_t ctr;
25
r.cls = float_class_zero;
26
26
r.sign = false;
27
/* The real cache geometry is in CCSIDR_EL1/CLIDR_EL1/CSSELR_EL1,
28
but (at least under Linux) these are marked protected by the
27
--
29
--
28
2.17.0
30
2.20.1
29
31
30
32
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Cao Jiaxi <driver1998@foxmail.com>
2
2
3
Cc: qemu-stable@nongnu.org
3
I encountered the following compilation error on mingw:
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
/mnt/d/qemu/include/qemu/osdep.h:97:9: error: '__USE_MINGW_ANSI_STDIO' macro redefined [-Werror,-Wmacro-redefined]
6
Tested-by: Alex Bennée <alex.bennee@linaro.org>
6
#define __USE_MINGW_ANSI_STDIO 1
7
Message-id: 20180512003217.9105-5-richard.henderson@linaro.org
7
^
8
/mnt/d/llvm-mingw/aarch64-w64-mingw32/include/_mingw.h:433:9: note: previous definition is here
9
#define __USE_MINGW_ANSI_STDIO 0 /* was not defined so it should be 0 */
10
11
It turns out that __USE_MINGW_ANSI_STDIO must be set before any
12
system headers are included, not just before stdio.h.
13
14
Signed-off-by: Cao Jiaxi <driver1998@foxmail.com>
15
Reviewed-by: Thomas Huth <thuth@redhat.com>
16
Reviewed-by: Stefan Weil <sw@weilnetz.de>
17
Message-id: 20190503003719.10233-1-driver1998@foxmail.com
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
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-a64.c | 17 +++++++++++++++--
21
include/qemu/osdep.h | 10 +++++-----
11
1 file changed, 15 insertions(+), 2 deletions(-)
22
1 file changed, 5 insertions(+), 5 deletions(-)
12
23
13
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
24
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
14
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a64.c
26
--- a/include/qemu/osdep.h
16
+++ b/target/arm/translate-a64.c
27
+++ b/include/qemu/osdep.h
17
@@ -XXX,XX +XXX,XX @@ static void disas_fp_fixed_conv(DisasContext *s, uint32_t insn)
28
@@ -XXX,XX +XXX,XX @@ extern int daemon(int, int);
18
bool sf = extract32(insn, 31, 1);
29
#endif
19
bool itof;
30
#endif
20
31
21
- if (sbit || (type > 1)
32
+/* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */
22
- || (!sf && scale < 32)) {
33
+#ifdef __MINGW32__
23
+ if (sbit || (!sf && scale < 32)) {
34
+#define __USE_MINGW_ANSI_STDIO 1
24
+ unallocated_encoding(s);
35
+#endif
25
+ return;
26
+ }
27
+
36
+
28
+ switch (type) {
37
#include <stdarg.h>
29
+ case 0: /* float32 */
38
#include <stddef.h>
30
+ case 1: /* float64 */
39
#include <stdbool.h>
31
+ break;
40
#include <stdint.h>
32
+ case 3: /* float16 */
41
#include <sys/types.h>
33
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
42
#include <stdlib.h>
34
+ break;
43
-
35
+ }
44
-/* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */
36
+ /* fallthru */
45
-#ifdef __MINGW32__
37
+ default:
46
-#define __USE_MINGW_ANSI_STDIO 1
38
unallocated_encoding(s);
47
-#endif
39
return;
48
#include <stdio.h>
40
}
49
50
#include <string.h>
41
--
51
--
42
2.17.0
52
2.20.1
43
53
44
54
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
Rule R_CQRV says that if two pending interrupts have the same
2
group priority then ties are broken by looking at the subpriority.
3
We had a comment describing this but had forgotten to actually
4
implement the subpriority comparison. Correct the omission.
2
5
3
Adding the fp16 moves to/from general registers.
6
(The further tie break rules of "lowest exception number" and
7
"secure before non-secure" are handled implicitly by the order
8
in which we iterate through the exceptions in the loops.)
4
9
5
Cc: qemu-stable@nongnu.org
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Tested-by: Alex Bennée <alex.bennee@linaro.org>
8
Message-id: 20180512003217.9105-2-richard.henderson@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
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190430131439.25251-2-peter.maydell@linaro.org
11
---
13
---
12
target/arm/translate-a64.c | 21 +++++++++++++++++++++
14
hw/intc/armv7m_nvic.c | 9 +++++++--
13
1 file changed, 21 insertions(+)
15
1 file changed, 7 insertions(+), 2 deletions(-)
14
16
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
17
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
19
--- a/hw/intc/armv7m_nvic.c
18
+++ b/target/arm/translate-a64.c
20
+++ b/hw/intc/armv7m_nvic.c
19
@@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof)
21
@@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state_secure(NVICState *s)
20
tcg_gen_st_i64(tcg_rn, cpu_env, fp_reg_hi_offset(s, rd));
22
int active_prio = NVIC_NOEXC_PRIO;
21
clear_vec_high(s, true, rd);
23
int pend_irq = 0;
22
break;
24
bool pending_is_s_banked = false;
23
+ case 3:
25
+ int pend_subprio = 0;
24
+ /* 16 bit */
26
25
+ tmp = tcg_temp_new_i64();
27
/* R_CQRV: precedence is by:
26
+ tcg_gen_ext16u_i64(tmp, tcg_rn);
28
* - lowest group priority; if both the same then
27
+ write_fp_dreg(s, rd, tmp);
29
@@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state_secure(NVICState *s)
28
+ tcg_temp_free_i64(tmp);
30
for (i = 1; i < s->num_irq; i++) {
29
+ break;
31
for (bank = M_REG_S; bank >= M_REG_NS; bank--) {
30
+ default:
32
VecInfo *vec;
31
+ g_assert_not_reached();
33
- int prio;
32
}
34
+ int prio, subprio;
33
} else {
35
bool targets_secure;
34
TCGv_i64 tcg_rd = cpu_reg(s, rd);
36
35
@@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof)
37
if (bank == M_REG_S) {
36
/* 64 bits from top half */
38
@@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state_secure(NVICState *s)
37
tcg_gen_ld_i64(tcg_rd, cpu_env, fp_reg_hi_offset(s, rn));
39
}
38
break;
40
39
+ case 3:
41
prio = exc_group_prio(s, vec->prio, targets_secure);
40
+ /* 16 bit */
42
- if (vec->enabled && vec->pending && prio < pend_prio) {
41
+ tcg_gen_ld16u_i64(tcg_rd, cpu_env, fp_reg_offset(s, rn, MO_16));
43
+ subprio = vec->prio & ~nvic_gprio_mask(s, targets_secure);
42
+ break;
44
+ if (vec->enabled && vec->pending &&
43
+ default:
45
+ ((prio < pend_prio) ||
44
+ g_assert_not_reached();
46
+ (prio == pend_prio && prio >= 0 && subprio < pend_subprio))) {
45
}
47
pend_prio = prio;
46
}
48
+ pend_subprio = subprio;
47
}
49
pend_irq = i;
48
@@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn)
50
pending_is_s_banked = (bank == M_REG_S);
49
case 0xa: /* 64 bit */
51
}
50
case 0xd: /* 64 bit to top half of quad */
51
break;
52
+ case 0x6: /* 16-bit float, 32-bit int */
53
+ case 0xe: /* 16-bit float, 64-bit int */
54
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
55
+ break;
56
+ }
57
+ /* fallthru */
58
default:
59
/* all other sf/type/rmode combinations are invalid */
60
unallocated_encoding(s);
61
--
52
--
62
2.17.0
53
2.20.1
63
54
64
55
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
The non-secure versions of the BFAR and BFSR registers are
2
supposed to be RAZ/WI if AICR.BFHFNMINS == 0; we were
3
incorrectly allowing NS code to access the real values.
2
4
3
We missed all of the scalar fp16 fma operations.
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190430131439.25251-3-peter.maydell@linaro.org
8
---
9
hw/intc/armv7m_nvic.c | 27 ++++++++++++++++++++++++---
10
1 file changed, 24 insertions(+), 3 deletions(-)
4
11
5
Cc: qemu-stable@nongnu.org
12
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Tested-by: Alex Bennée <alex.bennee@linaro.org>
9
Message-id: 20180512003217.9105-8-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/translate-a64.c | 48 ++++++++++++++++++++++++++++++++++++++
13
1 file changed, 48 insertions(+)
14
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
16
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
14
--- a/hw/intc/armv7m_nvic.c
18
+++ b/target/arm/translate-a64.c
15
+++ b/hw/intc/armv7m_nvic.c
19
@@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1,
16
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
20
tcg_temp_free_i64(tcg_res);
17
if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
21
}
18
goto bad_offset;
22
23
+/* Floating-point data-processing (3 source) - half precision */
24
+static void handle_fp_3src_half(DisasContext *s, bool o0, bool o1,
25
+ int rd, int rn, int rm, int ra)
26
+{
27
+ TCGv_i32 tcg_op1, tcg_op2, tcg_op3;
28
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
29
+ TCGv_ptr fpst = get_fpstatus_ptr(true);
30
+
31
+ tcg_op1 = read_fp_hreg(s, rn);
32
+ tcg_op2 = read_fp_hreg(s, rm);
33
+ tcg_op3 = read_fp_hreg(s, ra);
34
+
35
+ /* These are fused multiply-add, and must be done as one
36
+ * floating point operation with no rounding between the
37
+ * multiplication and addition steps.
38
+ * NB that doing the negations here as separate steps is
39
+ * correct : an input NaN should come out with its sign bit
40
+ * flipped if it is a negated-input.
41
+ */
42
+ if (o1 == true) {
43
+ tcg_gen_xori_i32(tcg_op3, tcg_op3, 0x8000);
44
+ }
45
+
46
+ if (o0 != o1) {
47
+ tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000);
48
+ }
49
+
50
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_op3, fpst);
51
+
52
+ write_fp_sreg(s, rd, tcg_res);
53
+
54
+ tcg_temp_free_ptr(fpst);
55
+ tcg_temp_free_i32(tcg_op1);
56
+ tcg_temp_free_i32(tcg_op2);
57
+ tcg_temp_free_i32(tcg_op3);
58
+ tcg_temp_free_i32(tcg_res);
59
+}
60
+
61
/* Floating point data-processing (3 source)
62
* 31 30 29 28 24 23 22 21 20 16 15 14 10 9 5 4 0
63
* +---+---+---+-----------+------+----+------+----+------+------+------+
64
@@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn)
65
}
19
}
66
handle_fp_3src_double(s, o0, o1, rd, rn, rm, ra);
20
+ if (!attrs.secure &&
67
break;
21
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
68
+ case 3:
22
+ return 0;
69
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
23
+ }
70
+ unallocated_encoding(s);
24
return cpu->env.v7m.bfar;
25
case 0xd3c: /* Aux Fault Status. */
26
/* TODO: Implement fault status registers. */
27
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
28
if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
29
goto bad_offset;
30
}
31
+ if (!attrs.secure &&
32
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
71
+ return;
33
+ return;
72
+ }
34
+ }
73
+ if (!fp_access_check(s)) {
35
cpu->env.v7m.bfar = value;
74
+ return;
36
return;
37
case 0xd3c: /* Aux Fault Status. */
38
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
39
val = 0;
40
break;
41
};
42
- /* The BFSR bits [15:8] are shared between security states
43
- * and we store them in the NS copy
44
+ /*
45
+ * The BFSR bits [15:8] are shared between security states
46
+ * and we store them in the NS copy. They are RAZ/WI for
47
+ * NS code if AIRCR.BFHFNMINS is 0.
48
*/
49
val = s->cpu->env.v7m.cfsr[attrs.secure];
50
- val |= s->cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK;
51
+ if (!attrs.secure &&
52
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
53
+ val &= ~R_V7M_CFSR_BFSR_MASK;
54
+ } else {
55
+ val |= s->cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK;
75
+ }
56
+ }
76
+ handle_fp_3src_half(s, o0, o1, rd, rn, rm, ra);
57
val = extract32(val, (offset - 0xd28) * 8, size * 8);
77
+ break;
58
break;
78
default:
59
case 0xfe0 ... 0xfff: /* ID. */
79
unallocated_encoding(s);
60
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
80
}
61
*/
62
value <<= ((offset - 0xd28) * 8);
63
64
+ if (!attrs.secure &&
65
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
66
+ /* BFSR bits are RAZ/WI for NS if BFHFNMINS is set */
67
+ value &= ~R_V7M_CFSR_BFSR_MASK;
68
+ }
69
+
70
s->cpu->env.v7m.cfsr[attrs.secure] &= ~value;
71
if (attrs.secure) {
72
/* The BFSR bits [15:8] are shared between security states
81
--
73
--
82
2.17.0
74
2.20.1
83
75
84
76
diff view generated by jsdifflib
1
Usually the logging of the CPU state produced by -d cpu is sufficient
1
The M-profile architecture specifies that the DebugMonitor exception
2
to diagnose problems, but sometimes you want to see the state of
2
should be initially disabled, not enabled. It should be controlled
3
the floating point registers as well. We don't want to enable that
3
by the DEMCR register's MON_EN bit, but we don't implement that
4
by default as it adds a lot of extra data to the log; instead,
4
register yet (like most of the debug architecture for M-profile).
5
allow it to be optionally enabled via -d fpu.
5
6
Note that BKPT instructions will still work, because they
7
will be escalated to HardFault.
6
8
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180510130024.31678-1-peter.maydell@linaro.org
11
Message-id: 20190430131439.25251-4-peter.maydell@linaro.org
10
---
12
---
11
include/qemu/log.h | 1 +
13
hw/intc/armv7m_nvic.c | 4 +++-
12
accel/tcg/cpu-exec.c | 9 ++++++---
14
1 file changed, 3 insertions(+), 1 deletion(-)
13
util/log.c | 2 ++
14
3 files changed, 9 insertions(+), 3 deletions(-)
15
15
16
diff --git a/include/qemu/log.h b/include/qemu/log.h
16
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/qemu/log.h
18
--- a/hw/intc/armv7m_nvic.c
19
+++ b/include/qemu/log.h
19
+++ b/hw/intc/armv7m_nvic.c
20
@@ -XXX,XX +XXX,XX @@ static inline bool qemu_log_separate(void)
20
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
21
#define CPU_LOG_PAGE (1 << 14)
21
* the System Handler Control register
22
/* LOG_TRACE (1 << 15) is defined in log-for-trace.h */
22
*/
23
#define CPU_LOG_TB_OP_IND (1 << 16)
23
s->vectors[ARMV7M_EXCP_SVC].enabled = 1;
24
+#define CPU_LOG_TB_FPU (1 << 17)
24
- s->vectors[ARMV7M_EXCP_DEBUG].enabled = 1;
25
25
s->vectors[ARMV7M_EXCP_PENDSV].enabled = 1;
26
/* Lock output for a series of related logs. Since this is not needed
26
s->vectors[ARMV7M_EXCP_SYSTICK].enabled = 1;
27
* for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we
27
28
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
28
+ /* DebugMonitor is enabled via DEMCR.MON_EN */
29
index XXXXXXX..XXXXXXX 100644
29
+ s->vectors[ARMV7M_EXCP_DEBUG].enabled = 0;
30
--- a/accel/tcg/cpu-exec.c
30
+
31
+++ b/accel/tcg/cpu-exec.c
31
resetprio = arm_feature(&s->cpu->env, ARM_FEATURE_V8) ? -4 : -3;
32
@@ -XXX,XX +XXX,XX @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb)
32
s->vectors[ARMV7M_EXCP_RESET].prio = resetprio;
33
if (qemu_loglevel_mask(CPU_LOG_TB_CPU)
33
s->vectors[ARMV7M_EXCP_NMI].prio = -2;
34
&& qemu_log_in_addr_range(itb->pc)) {
35
qemu_log_lock();
36
+ int flags = 0;
37
+ if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) {
38
+ flags |= CPU_DUMP_FPU;
39
+ }
40
#if defined(TARGET_I386)
41
- log_cpu_state(cpu, CPU_DUMP_CCOP);
42
-#else
43
- log_cpu_state(cpu, 0);
44
+ flags |= CPU_DUMP_CCOP;
45
#endif
46
+ log_cpu_state(cpu, flags);
47
qemu_log_unlock();
48
}
49
#endif /* DEBUG_DISAS */
50
diff --git a/util/log.c b/util/log.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/util/log.c
53
+++ b/util/log.c
54
@@ -XXX,XX +XXX,XX @@ const QEMULogItem qemu_log_items[] = {
55
"show trace before each executed TB (lots of logs)" },
56
{ CPU_LOG_TB_CPU, "cpu",
57
"show CPU registers before entering a TB (lots of logs)" },
58
+ { CPU_LOG_TB_FPU, "fpu",
59
+ "include FPU registers in the 'cpu' logging" },
60
{ CPU_LOG_MMU, "mmu",
61
"log MMU-related activities" },
62
{ CPU_LOG_PCALL, "pcall",
63
--
34
--
64
2.17.0
35
2.20.1
65
36
66
37
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
In the M-profile architecture, if the CPU implements the DSP extension
2
then the XPSR has GE bits, in the same way as the A-profile CPSR. When
3
we added DSP extension support we forgot to add support for reading
4
and writing the GE bits, which are stored in env->GE. We did put in
5
the code to add XPSR_GE to the mask of bits to update in the v7m_msr
6
helper, but forgot it in v7m_mrs. We also must not allow the XPSR we
7
pull off the stack on exception return to set the nonexistent GE bits.
8
Correct these errors:
9
* read and write env->GE in xpsr_read() and xpsr_write()
10
* only set GE bits on exception return if DSP present
11
* read GE bits for MRS if DSP present
2
12
3
We missed all of the scalar fp16 binary operations.
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20190430131439.25251-5-peter.maydell@linaro.org
16
---
17
target/arm/cpu.h | 4 ++++
18
target/arm/helper.c | 12 ++++++++++--
19
2 files changed, 14 insertions(+), 2 deletions(-)
4
20
5
Cc: qemu-stable@nongnu.org
21
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Tested-by: Alex Bennée <alex.bennee@linaro.org>
9
Message-id: 20180512003217.9105-7-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/translate-a64.c | 65 ++++++++++++++++++++++++++++++++++++++
13
1 file changed, 65 insertions(+)
14
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
23
--- a/target/arm/cpu.h
18
+++ b/target/arm/translate-a64.c
24
+++ b/target/arm/cpu.h
19
@@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_double(DisasContext *s, int opcode,
25
@@ -XXX,XX +XXX,XX @@ static inline uint32_t xpsr_read(CPUARMState *env)
20
tcg_temp_free_i64(tcg_res);
26
| (env->CF << 29) | ((env->VF & 0x80000000) >> 3) | (env->QF << 27)
27
| (env->thumb << 24) | ((env->condexec_bits & 3) << 25)
28
| ((env->condexec_bits & 0xfc) << 8)
29
+ | (env->GE << 16)
30
| env->v7m.exception;
21
}
31
}
22
32
23
+/* Floating-point data-processing (2 source) - half precision */
33
@@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
24
+static void handle_fp_2src_half(DisasContext *s, int opcode,
34
if (mask & XPSR_Q) {
25
+ int rd, int rn, int rm)
35
env->QF = ((val & XPSR_Q) != 0);
26
+{
36
}
27
+ TCGv_i32 tcg_op1;
37
+ if (mask & XPSR_GE) {
28
+ TCGv_i32 tcg_op2;
38
+ env->GE = (val & XPSR_GE) >> 16;
29
+ TCGv_i32 tcg_res;
39
+ }
30
+ TCGv_ptr fpst;
40
if (mask & XPSR_T) {
41
env->thumb = ((val & XPSR_T) != 0);
42
}
43
diff --git a/target/arm/helper.c b/target/arm/helper.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/helper.c
46
+++ b/target/arm/helper.c
47
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
48
{
49
CPUARMState *env = &cpu->env;
50
uint32_t excret;
51
- uint32_t xpsr;
52
+ uint32_t xpsr, xpsr_mask;
53
bool ufault = false;
54
bool sfault = false;
55
bool return_to_sp_process;
56
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
57
}
58
*frame_sp_p = frameptr;
59
}
31
+
60
+
32
+ tcg_res = tcg_temp_new_i32();
61
+ xpsr_mask = ~(XPSR_SPREALIGN | XPSR_SFPA);
33
+ fpst = get_fpstatus_ptr(true);
62
+ if (!arm_feature(env, ARM_FEATURE_THUMB_DSP)) {
34
+ tcg_op1 = read_fp_hreg(s, rn);
63
+ xpsr_mask &= ~XPSR_GE;
35
+ tcg_op2 = read_fp_hreg(s, rm);
36
+
37
+ switch (opcode) {
38
+ case 0x0: /* FMUL */
39
+ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
40
+ break;
41
+ case 0x1: /* FDIV */
42
+ gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
43
+ break;
44
+ case 0x2: /* FADD */
45
+ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
46
+ break;
47
+ case 0x3: /* FSUB */
48
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
49
+ break;
50
+ case 0x4: /* FMAX */
51
+ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
52
+ break;
53
+ case 0x5: /* FMIN */
54
+ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
55
+ break;
56
+ case 0x6: /* FMAXNM */
57
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
58
+ break;
59
+ case 0x7: /* FMINNM */
60
+ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
61
+ break;
62
+ case 0x8: /* FNMUL */
63
+ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
64
+ tcg_gen_xori_i32(tcg_res, tcg_res, 0x8000);
65
+ break;
66
+ default:
67
+ g_assert_not_reached();
68
+ }
64
+ }
69
+
65
/* This xpsr_write() will invalidate frame_sp_p as it may switch stack */
70
+ write_fp_sreg(s, rd, tcg_res);
66
- xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA));
71
+
67
+ xpsr_write(env, xpsr, xpsr_mask);
72
+ tcg_temp_free_ptr(fpst);
68
73
+ tcg_temp_free_i32(tcg_op1);
69
if (env->v7m.secure) {
74
+ tcg_temp_free_i32(tcg_op2);
70
bool sfpa = xpsr & XPSR_SFPA;
75
+ tcg_temp_free_i32(tcg_res);
71
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
76
+}
77
+
78
/* Floating point data-processing (2 source)
79
* 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0
80
* +---+---+---+-----------+------+---+------+--------+-----+------+------+
81
@@ -XXX,XX +XXX,XX @@ static void disas_fp_2src(DisasContext *s, uint32_t insn)
82
}
72
}
83
handle_fp_2src_double(s, opcode, rd, rn, rm);
73
if (!(reg & 4)) {
84
break;
74
mask |= XPSR_NZCV | XPSR_Q; /* APSR */
85
+ case 3:
75
+ if (arm_feature(env, ARM_FEATURE_THUMB_DSP)) {
86
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
76
+ mask |= XPSR_GE;
87
+ unallocated_encoding(s);
77
+ }
88
+ return;
78
}
89
+ }
79
/* EPSR reads as zero */
90
+ if (!fp_access_check(s)) {
80
return xpsr_read(env) & mask;
91
+ return;
92
+ }
93
+ handle_fp_2src_half(s, opcode, rd, rn, rm);
94
+ break;
95
default:
96
unallocated_encoding(s);
97
}
98
--
81
--
99
2.17.0
82
2.20.1
100
83
101
84
diff view generated by jsdifflib
1
In float-to-integer conversion, if the floating point input
1
Currently the dc_zva helper function uses a variable length
2
converts exactly to the largest or smallest integer that
2
array. In fact we know (as the comment above remarks) that
3
fits in to the result type, this is not an overflow.
3
the length of this array is bounded because the architecture
4
In this situation we were producing the correct result value,
4
limits the block size and QEMU limits the target page size.
5
but were incorrectly setting the Invalid flag.
5
Use a fixed array size and assert that we don't run off it.
6
For example for Arm A64, "FCVTAS w0, d0" on an input of
7
0x41dfffffffc00000 should produce 0x7fffffff and set no flags.
8
6
9
Fix the boundary case to take the right half of the if()
10
statements.
11
12
This fixes a regression from 2.11 introduced by the softfloat
13
refactoring.
14
15
Cc: qemu-stable@nongnu.org
16
Fixes: ab52f973a50
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20180510140141.12120-1-peter.maydell@linaro.org
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20190503120448.13385-1-peter.maydell@linaro.org
20
---
12
---
21
fpu/softfloat.c | 4 ++--
13
target/arm/helper.c | 8 ++++++--
22
1 file changed, 2 insertions(+), 2 deletions(-)
14
1 file changed, 6 insertions(+), 2 deletions(-)
23
15
24
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
25
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
26
--- a/fpu/softfloat.c
18
--- a/target/arm/helper.c
27
+++ b/fpu/softfloat.c
19
+++ b/target/arm/helper.c
28
@@ -XXX,XX +XXX,XX @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode,
20
@@ -XXX,XX +XXX,XX @@
29
r = UINT64_MAX;
21
#include "qemu/osdep.h"
30
}
22
+#include "qemu/units.h"
31
if (p.sign) {
23
#include "target/arm/idau.h"
32
- if (r < -(uint64_t) min) {
24
#include "trace.h"
33
+ if (r <= -(uint64_t) min) {
25
#include "cpu.h"
34
return -r;
26
@@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
35
} else {
27
* We know that in fact for any v8 CPU the page size is at least 4K
36
s->float_exception_flags = orig_flags | float_flag_invalid;
28
* and the block size must be 2K or less, but TARGET_PAGE_SIZE is only
37
return min;
29
* 1K as an artefact of legacy v5 subpage support being present in the
38
}
30
- * same QEMU executable.
39
} else {
31
+ * same QEMU executable. So in practice the hostaddr[] array has
40
- if (r < max) {
32
+ * two entries, given the current setting of TARGET_PAGE_BITS_MIN.
41
+ if (r <= max) {
33
*/
42
return r;
34
int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE);
43
} else {
35
- void *hostaddr[maxidx];
44
s->float_exception_flags = orig_flags | float_flag_invalid;
36
+ void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)];
37
int try, i;
38
unsigned mmu_idx = cpu_mmu_index(env, false);
39
TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);
40
41
+ assert(maxidx <= ARRAY_SIZE(hostaddr));
42
+
43
for (try = 0; try < 2; try++) {
44
45
for (i = 0; i < maxidx; i++) {
45
--
46
--
46
2.17.0
47
2.20.1
47
48
48
49
diff view generated by jsdifflib
Deleted patch
1
In commit d81ce0ef2c4f105 we added an extra float_status field
2
fp_status_fp16 for Arm, but forgot to initialize it correctly
3
by setting it to float_tininess_before_rounding. This currently
4
will only cause problems for the new V8_FP16 feature, since the
5
float-to-float conversion code doesn't use it yet. The effect
6
would be that we failed to set the Underflow IEEE exception flag
7
in all the cases where we should.
8
1
9
Add the missing initialization.
10
11
Fixes: d81ce0ef2c4f105
12
Cc: qemu-stable@nongnu.org
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Message-id: 20180512004311.9299-16-richard.henderson@linaro.org
17
---
18
target/arm/cpu.c | 2 ++
19
1 file changed, 2 insertions(+)
20
21
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/cpu.c
24
+++ b/target/arm/cpu.c
25
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s)
26
&env->vfp.fp_status);
27
set_float_detect_tininess(float_tininess_before_rounding,
28
&env->vfp.standard_fp_status);
29
+ set_float_detect_tininess(float_tininess_before_rounding,
30
+ &env->vfp.fp_status_f16);
31
#ifndef CONFIG_USER_ONLY
32
if (kvm_enabled()) {
33
kvm_arm_reset_vcpu(cpu);
34
--
35
2.17.0
36
37
diff view generated by jsdifflib