summary refs log tree commit diff stats
path: root/gitlab/issues/target_i386/host_missing/accel_missing/2817.toml
blob: aa1af6f230ad41a34f0736e5b6826add3cc97de3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
id = 2817
title = "Strange floating-point behaviour under Windows with some CPU models"
state = "opened"
created_at = "2025-02-18T12:02:17.591Z"
closed_at = "n/a"
labels = ["Softfloat", "target: i386"]
url = "https://gitlab.com/qemu-project/qemu/-/issues/2817"
host-os = "Debian 12"
host-arch = "x86_64"
qemu-version = "QEMU emulator version 7.2.13 (Debian 1:7.2+dfsg-7+deb12u7)"
guest-os = "Windows 10, Windows Server 2022"
guest-arch = "x86_64"
description = """I'm encountering a very weird bug with some floating-point maths code, but only under very specific configurations. First I thought it was a Clang bug, but then further digging eventually showed it to only occur under Windows VMs with specific QEMU CPU options, I'm not certain whether it is a QEMU/KVM bug or a Windows bug, but thought starting here would be easiest.

When compiled under MSVC Clang with modern CPU instructions disabled (e.g. `-march=pentium3` or `-march=pentium-mmx`), the `floorf()` call in the following program always returns 0.0, while the truncation works correctly:

```
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
\tfloat n = atof(argv[1]);
\tprintf("n = %f\\n", n);
\t
\tfloat f = floorf(n);
\tprintf("f = %f\\n", f);
\t
\tfloat c = (int)(n);
\tprintf("c = %f\\n", c);
\t
\treturn 0;
}
```

Example output on an affected VM:

```
C:\\Users\\Administrator> floorf-p3.exe 10
n = 10.000000
f = 0.000000
c = 10.000000

C:\\Users\\Administrator> floorf-p4.exe 10
n = 10.000000
f = 10.000000
c = 10.000000
```

(`floorf-p3.exe` was compiled with `-march=pentium3` and `floorf-p4.exe` with `-march=pentium4` above)

I've tried a few QEMU CPU models on a variety of Intel/AMD VM hosts and two different Windows versions (10 and Server 2022), and observed the following:

* `host-passthrough` - works (on AMD and Intel hosts)
* `qemu64` - broken
* `EPYC-Milan` - works
* `Westmere` - works
* `Penryn` - broken

(I also reported this via the mailing list, but I think it might've swallowed my post)"""
reproduce = "n/a"
additional = "n/a"