1 | target-arm queue for rc1 -- these are all bug fixes. | 1 | Almost nothing in here is arm-related, but the target-arm |
---|---|---|---|
2 | queue was convenient for these last minute bits and pieces | ||
3 | for 5.0... | ||
2 | 4 | ||
3 | thanks | 5 | thanks |
4 | -- PMM | 6 | -- PMM |
5 | 7 | ||
6 | The following changes since commit b9404bf592e7ba74180e1a54ed7a266ec6ee67f2: | 8 | The following changes since commit 14e5526b51910efd62cd31cd95b49baca975c83f: |
7 | 9 | ||
8 | Merge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20190715' into staging (2019-07-15 12:22:07 +0100) | 10 | Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-04-13 15:42:51 +0100) |
9 | 11 | ||
10 | are available in the Git repository at: | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190715 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200414 |
13 | 15 | ||
14 | for you to fetch changes up to 51c9122e92b776a3f16af0b9282f1dc5012e2a19: | 16 | for you to fetch changes up to 84f82ddcbb4ac4ed04c8675e85155329f23184f0: |
15 | 17 | ||
16 | target/arm: NS BusFault on vector table fetch escalates to NS HardFault (2019-07-15 14:17:04 +0100) | 18 | Deprecate KVM support for AArch32 (2020-04-14 17:20:22 +0100) |
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | target-arm queue: | 21 | patch queue: |
20 | * report ARMv8-A FP support for AArch32 -cpu max | 22 | * Fix some problems that trip up Coverity's scanner |
21 | * hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory | 23 | * run-coverity-scan: New script automating the scan-and-upload process |
22 | * hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[] | 24 | * docs: Improve our gdbstub documentation |
23 | * hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO | 25 | * configure: Honour --disable-werror for Sphinx |
24 | * hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO | 26 | * docs: Fix errors produced when building with Sphinx 3.0 |
25 | * hw/arm/virt: Fix non-secure flash mode | 27 | * docs: Require Sphinx 1.6 or better |
26 | * pl031: Correctly migrate state when using -rtc clock=host | 28 | * Add deprecation notice for KVM support on AArch32 hosts |
27 | * fix regression that meant arm926 and arm1026 lost VFP | ||
28 | double-precision support | ||
29 | * v8M: NS BusFault on vector table fetch escalates to NS HardFault | ||
30 | 29 | ||
31 | ---------------------------------------------------------------- | 30 | ---------------------------------------------------------------- |
32 | Alex Bennée (1): | 31 | Peter Maydell (12): |
33 | target/arm: report ARMv8-A FP support for AArch32 -cpu max | 32 | osdep.h: Drop no-longer-needed Coverity workarounds |
33 | thread.h: Fix Coverity version of qemu_cond_timedwait() | ||
34 | thread.h: Remove trailing semicolons from Coverity qemu_mutex_lock() etc | ||
35 | linux-user/flatload.c: Use "" for include of QEMU header target_flat.h | ||
36 | scripts/run-coverity-scan: Script to run Coverity Scan build | ||
37 | scripts/coverity-scan: Add Docker support | ||
38 | docs: Improve our gdbstub documentation | ||
39 | configure: Honour --disable-werror for Sphinx | ||
40 | scripts/kernel-doc: Add missing close-paren in c:function directives | ||
41 | kernel-doc: Use c:struct for Sphinx 3.0 and later | ||
42 | docs: Require Sphinx 1.6 or better | ||
43 | Deprecate KVM support for AArch32 | ||
34 | 44 | ||
35 | David Engraf (1): | 45 | configure | 9 +- |
36 | hw/arm/virt: Fix non-secure flash mode | 46 | Makefile | 2 +- |
47 | include/qemu/osdep.h | 14 - | ||
48 | include/qemu/thread.h | 12 +- | ||
49 | linux-user/flatload.c | 2 +- | ||
50 | MAINTAINERS | 5 + | ||
51 | docs/conf.py | 6 +- | ||
52 | docs/sphinx/kerneldoc.py | 1 + | ||
53 | docs/system/deprecated.rst | 8 + | ||
54 | docs/system/gdb.rst | 22 +- | ||
55 | qemu-options.hx | 24 +- | ||
56 | scripts/coverity-scan/coverity-scan.docker | 131 ++++++++++ | ||
57 | scripts/coverity-scan/run-coverity-scan | 401 +++++++++++++++++++++++++++++ | ||
58 | scripts/kernel-doc | 18 +- | ||
59 | 14 files changed, 615 insertions(+), 40 deletions(-) | ||
60 | create mode 100644 scripts/coverity-scan/coverity-scan.docker | ||
61 | create mode 100755 scripts/coverity-scan/run-coverity-scan | ||
37 | 62 | ||
38 | Peter Maydell (3): | ||
39 | pl031: Correctly migrate state when using -rtc clock=host | ||
40 | target/arm: Set VFP-related MVFR0 fields for arm926 and arm1026 | ||
41 | target/arm: NS BusFault on vector table fetch escalates to NS HardFault | ||
42 | |||
43 | Philippe Mathieu-Daudé (5): | ||
44 | hw/ssi/xilinx_spips: Convert lqspi_read() to read_with_attrs | ||
45 | hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory | ||
46 | hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[] | ||
47 | hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO | ||
48 | hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO | ||
49 | |||
50 | include/hw/timer/pl031.h | 2 ++ | ||
51 | hw/arm/virt.c | 2 +- | ||
52 | hw/core/machine.c | 1 + | ||
53 | hw/display/xlnx_dp.c | 15 +++++--- | ||
54 | hw/ssi/mss-spi.c | 8 ++++- | ||
55 | hw/ssi/xilinx_spips.c | 43 +++++++++++++++------- | ||
56 | hw/timer/pl031.c | 92 +++++++++++++++++++++++++++++++++++++++++++++--- | ||
57 | target/arm/cpu.c | 16 +++++++++ | ||
58 | target/arm/m_helper.c | 21 ++++++++--- | ||
59 | 9 files changed, 174 insertions(+), 26 deletions(-) | ||
60 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In commit a1a98357e3fd in 2018 we added some workarounds for Coverity | ||
2 | not being able to handle the _Float* types introduced by recent | ||
3 | glibc. Newer versions of the Coverity scan tools have support for | ||
4 | these types, and will fail with errors about duplicate typedefs if we | ||
5 | have our workaround. Remove our copy of the typedefs. | ||
1 | 6 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200319193323.2038-2-peter.maydell@linaro.org | ||
10 | --- | ||
11 | include/qemu/osdep.h | 14 -------------- | ||
12 | 1 file changed, 14 deletions(-) | ||
13 | |||
14 | diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/qemu/osdep.h | ||
17 | +++ b/include/qemu/osdep.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #else | ||
20 | #include "exec/poison.h" | ||
21 | #endif | ||
22 | -#ifdef __COVERITY__ | ||
23 | -/* Coverity does not like the new _Float* types that are used by | ||
24 | - * recent glibc, and croaks on every single file that includes | ||
25 | - * stdlib.h. These typedefs are enough to please it. | ||
26 | - * | ||
27 | - * Note that these fix parse errors so they cannot be placed in | ||
28 | - * scripts/coverity-model.c. | ||
29 | - */ | ||
30 | -typedef float _Float32; | ||
31 | -typedef double _Float32x; | ||
32 | -typedef double _Float64; | ||
33 | -typedef __float80 _Float64x; | ||
34 | -typedef __float128 _Float128; | ||
35 | -#endif | ||
36 | |||
37 | #include "qemu/compiler.h" | ||
38 | |||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | For Coverity's benefit, we provide simpler versions of functions like | ||
2 | qemu_mutex_lock(), qemu_cond_wait() and qemu_cond_timedwait(). When | ||
3 | we added qemu_cond_timedwait() in commit 3dcc9c6ec4ea, a cut and | ||
4 | paste error meant that the Coverity version of qemu_cond_timedwait() | ||
5 | was using the wrong _impl function, which makes the Coverity parser | ||
6 | complain: | ||
1 | 7 | ||
8 | "/qemu/include/qemu/thread.h", line 159: warning #140: too many arguments in | ||
9 | function call | ||
10 | return qemu_cond_timedwait(cond, mutex, ms); | ||
11 | ^ | ||
12 | |||
13 | "/qemu/include/qemu/thread.h", line 159: warning #120: return value type does | ||
14 | not match the function type | ||
15 | return qemu_cond_timedwait(cond, mutex, ms); | ||
16 | ^ | ||
17 | |||
18 | "/qemu/include/qemu/thread.h", line 156: warning #1563: function | ||
19 | "qemu_cond_timedwait" not emitted, consider modeling it or review | ||
20 | parse diagnostics to improve fidelity | ||
21 | static inline bool (qemu_cond_timedwait)(QemuCond *cond, QemuMutex *mutex, | ||
22 | ^ | ||
23 | |||
24 | These aren't fatal, but reduce the scope of the analysis. Fix the error. | ||
25 | |||
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
28 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
29 | Message-id: 20200319193323.2038-3-peter.maydell@linaro.org | ||
30 | --- | ||
31 | include/qemu/thread.h | 2 +- | ||
32 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
33 | |||
34 | diff --git a/include/qemu/thread.h b/include/qemu/thread.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/include/qemu/thread.h | ||
37 | +++ b/include/qemu/thread.h | ||
38 | @@ -XXX,XX +XXX,XX @@ extern QemuCondTimedWaitFunc qemu_cond_timedwait_func; | ||
39 | #define qemu_cond_wait(c, m) \ | ||
40 | qemu_cond_wait_impl(c, m, __FILE__, __LINE__); | ||
41 | #define qemu_cond_timedwait(c, m, ms) \ | ||
42 | - qemu_cond_wait_impl(c, m, ms, __FILE__, __LINE__); | ||
43 | + qemu_cond_timedwait_impl(c, m, ms, __FILE__, __LINE__); | ||
44 | #else | ||
45 | #define qemu_mutex_lock(m) ({ \ | ||
46 | QemuMutexLockFunc _f = atomic_read(&qemu_mutex_lock_func); \ | ||
47 | -- | ||
48 | 2.20.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
1 | In the M-profile architecture, when we do a vector table fetch and it | 1 | All the Coverity-specific definitions of qemu_mutex_lock() and friends |
---|---|---|---|
2 | fails, we need to report a HardFault. Whether this is a Secure HF or | 2 | have a trailing semicolon. This works fine almost everywhere because |
3 | a NonSecure HF depends on several things. If AIRCR.BFHFNMINS is 0 | 3 | of QEMU's mandatory-braces coding style and because most callsites are |
4 | then HF is always Secure, because there is no NonSecure HardFault. | 4 | simple, but target/s390x/sigp.c has a use of qemu_mutex_trylock() as |
5 | Otherwise, the answer depends on whether the 'underlying exception' | 5 | an if() statement, which makes the ';' a syntax error: |
6 | (MemManage, BusFault, SecureFault) targets Secure or NonSecure. (In | 6 | "../target/s390x/sigp.c", line 461: warning #18: expected a ")" |
7 | the pseudocode, this is handled in the Vector() function: the final | 7 | if (qemu_mutex_trylock(&qemu_sigp_mutex)) { |
8 | exc.isSecure is calculated by looking at the exc.isSecure from the | 8 | ^ |
9 | exception returned from the memory access, not the isSecure input | ||
10 | argument.) | ||
11 | 9 | ||
12 | We weren't doing this correctly, because we were looking at | 10 | Remove the bogus semicolons from the macro definitions. |
13 | the target security domain of the exception we were trying to | ||
14 | load the vector table entry for. This produces errors of two kinds: | ||
15 | * a load from the NS vector table which hits the "NS access | ||
16 | to S memory" SecureFault should end up as a Secure HardFault, | ||
17 | but we were raising an NS HardFault | ||
18 | * a load from the S vector table which causes a BusFault | ||
19 | should raise an NS HardFault if BFHFNMINS == 1 (because | ||
20 | in that case all BusFaults are NonSecure), but we were raising | ||
21 | a Secure HardFault | ||
22 | |||
23 | Correct the logic. | ||
24 | |||
25 | We also fix a comment error where we claimed that we might | ||
26 | be escalating MemManage to HardFault, and forgot about SecureFault. | ||
27 | (Vector loads can never hit MPU access faults, because they're | ||
28 | always aligned and always use the default address map.) | ||
29 | 11 | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | Message-id: 20190705094823.28905-1-peter.maydell@linaro.org | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Message-id: 20200319193323.2038-4-peter.maydell@linaro.org | ||
32 | --- | 16 | --- |
33 | target/arm/m_helper.c | 21 +++++++++++++++++---- | 17 | include/qemu/thread.h | 12 ++++++------ |
34 | 1 file changed, 17 insertions(+), 4 deletions(-) | 18 | 1 file changed, 6 insertions(+), 6 deletions(-) |
35 | 19 | ||
36 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 20 | diff --git a/include/qemu/thread.h b/include/qemu/thread.h |
37 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/target/arm/m_helper.c | 22 | --- a/include/qemu/thread.h |
39 | +++ b/target/arm/m_helper.c | 23 | +++ b/include/qemu/thread.h |
40 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | 24 | @@ -XXX,XX +XXX,XX @@ extern QemuCondTimedWaitFunc qemu_cond_timedwait_func; |
41 | if (sattrs.ns) { | 25 | * hide them. |
42 | attrs.secure = false; | 26 | */ |
43 | } else if (!targets_secure) { | 27 | #define qemu_mutex_lock(m) \ |
44 | - /* NS access to S memory */ | 28 | - qemu_mutex_lock_impl(m, __FILE__, __LINE__); |
45 | + /* | 29 | + qemu_mutex_lock_impl(m, __FILE__, __LINE__) |
46 | + * NS access to S memory: the underlying exception which we escalate | 30 | #define qemu_mutex_trylock(m) \ |
47 | + * to HardFault is SecureFault, which always targets Secure. | 31 | - qemu_mutex_trylock_impl(m, __FILE__, __LINE__); |
48 | + */ | 32 | + qemu_mutex_trylock_impl(m, __FILE__, __LINE__) |
49 | + exc_secure = true; | 33 | #define qemu_rec_mutex_lock(m) \ |
50 | goto load_fail; | 34 | - qemu_rec_mutex_lock_impl(m, __FILE__, __LINE__); |
51 | } | 35 | + qemu_rec_mutex_lock_impl(m, __FILE__, __LINE__) |
52 | } | 36 | #define qemu_rec_mutex_trylock(m) \ |
53 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | 37 | - qemu_rec_mutex_trylock_impl(m, __FILE__, __LINE__); |
54 | vector_entry = address_space_ldl(arm_addressspace(cs, attrs), addr, | 38 | + qemu_rec_mutex_trylock_impl(m, __FILE__, __LINE__) |
55 | attrs, &result); | 39 | #define qemu_cond_wait(c, m) \ |
56 | if (result != MEMTX_OK) { | 40 | - qemu_cond_wait_impl(c, m, __FILE__, __LINE__); |
57 | + /* | 41 | + qemu_cond_wait_impl(c, m, __FILE__, __LINE__) |
58 | + * Underlying exception is BusFault: its target security state | 42 | #define qemu_cond_timedwait(c, m, ms) \ |
59 | + * depends on BFHFNMINS. | 43 | - qemu_cond_timedwait_impl(c, m, ms, __FILE__, __LINE__); |
60 | + */ | 44 | + qemu_cond_timedwait_impl(c, m, ms, __FILE__, __LINE__) |
61 | + exc_secure = !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK); | 45 | #else |
62 | goto load_fail; | 46 | #define qemu_mutex_lock(m) ({ \ |
63 | } | 47 | QemuMutexLockFunc _f = atomic_read(&qemu_mutex_lock_func); \ |
64 | *pvec = vector_entry; | ||
65 | @@ -XXX,XX +XXX,XX @@ load_fail: | ||
66 | /* | ||
67 | * All vector table fetch fails are reported as HardFault, with | ||
68 | * HFSR.VECTTBL and .FORCED set. (FORCED is set because | ||
69 | - * technically the underlying exception is a MemManage or BusFault | ||
70 | + * technically the underlying exception is a SecureFault or BusFault | ||
71 | * that is escalated to HardFault.) This is a terminal exception, | ||
72 | * so we will either take the HardFault immediately or else enter | ||
73 | * lockup (the latter case is handled in armv7m_nvic_set_pending_derived()). | ||
74 | + * The HardFault is Secure if BFHFNMINS is 0 (meaning that all HFs are | ||
75 | + * secure); otherwise it targets the same security state as the | ||
76 | + * underlying exception. | ||
77 | */ | ||
78 | - exc_secure = targets_secure || | ||
79 | - !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK); | ||
80 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
81 | + exc_secure = true; | ||
82 | + } | ||
83 | env->v7m.hfsr |= R_V7M_HFSR_VECTTBL_MASK | R_V7M_HFSR_FORCED_MASK; | ||
84 | armv7m_nvic_set_pending_derived(env->nvic, ARMV7M_EXCP_HARD, exc_secure); | ||
85 | return false; | ||
86 | -- | 48 | -- |
87 | 2.20.1 | 49 | 2.20.1 |
88 | 50 | ||
89 | 51 | diff view generated by jsdifflib |
1 | From: David Engraf <david.engraf@sysgo.com> | 1 | The target_flat.h file is a QEMU header, so we should include it using |
---|---|---|---|
2 | quotes, not angle brackets. | ||
2 | 3 | ||
3 | Using the whole 128 MiB flash in non-secure mode is not working because | 4 | Coverity otherwise is unable to find the header: |
4 | virt_flash_fdt() expects the same address for secure_sysmem and sysmem. | ||
5 | This is not correctly handled by caller because it forwards NULL for | ||
6 | secure_sysmem in non-secure flash mode. | ||
7 | 5 | ||
8 | Fixed by using sysmem when secure_sysmem is NULL. | 6 | "../linux-user/flatload.c", line 40: error #1712: cannot open source file |
7 | "target_flat.h" | ||
8 | #include <target_flat.h> | ||
9 | ^ | ||
9 | 10 | ||
10 | Signed-off-by: David Engraf <david.engraf@sysgo.com> | 11 | because the relevant directory is only on the -iquote path, not the -I path. |
11 | Message-id: 20190712075002.14326-1-david.engraf@sysgo.com | 12 | |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Message-id: 20200319193323.2038-5-peter.maydell@linaro.org | ||
14 | --- | 17 | --- |
15 | hw/arm/virt.c | 2 +- | 18 | linux-user/flatload.c | 2 +- |
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 19 | 1 file changed, 1 insertion(+), 1 deletion(-) |
17 | 20 | ||
18 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 21 | diff --git a/linux-user/flatload.c b/linux-user/flatload.c |
19 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/virt.c | 23 | --- a/linux-user/flatload.c |
21 | +++ b/hw/arm/virt.c | 24 | +++ b/linux-user/flatload.c |
22 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 25 | @@ -XXX,XX +XXX,XX @@ |
23 | &machine->device_memory->mr); | 26 | |
24 | } | 27 | #include "qemu.h" |
25 | 28 | #include "flat.h" | |
26 | - virt_flash_fdt(vms, sysmem, secure_sysmem); | 29 | -#include <target_flat.h> |
27 | + virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); | 30 | +#include "target_flat.h" |
28 | 31 | ||
29 | create_gic(vms, pic); | 32 | //#define DEBUG |
30 | 33 | ||
31 | -- | 34 | -- |
32 | 2.20.1 | 35 | 2.20.1 |
33 | 36 | ||
34 | 37 | diff view generated by jsdifflib |
1 | The PL031 RTC tracks the difference between the guest RTC | 1 | Add a new script to automate the process of running the Coverity |
---|---|---|---|
2 | and the host RTC using a tick_offset field. For migration, | 2 | Scan build tools and uploading the resulting tarball to the |
3 | however, we currently always migrate the offset between | 3 | website. |
4 | the guest and the vm_clock, even if the RTC clock is not | 4 | |
5 | the same as the vm_clock; this was an attempt to retain | 5 | This is intended eventually to be driven from Travis, |
6 | migration backwards compatibility. | 6 | but it can be run locally, if you are a maintainer of the |
7 | 7 | QEMU project on the Coverity Scan website and have the secret | |
8 | Unfortunately this results in the RTC behaving oddly across | 8 | upload token. |
9 | a VM state save and restore -- since the VM clock stands still | 9 | |
10 | across save-then-restore, regardless of how much real world | 10 | The script must be run on a Fedora 30 system. Support for using a |
11 | time has elapsed, the guest RTC ends up out of sync with the | 11 | Docker container is added in a following commit. |
12 | host RTC in the restored VM. | 12 | |
13 | 13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | |
14 | Fix this by migrating the raw tick_offset. To retain migration | ||
15 | compatibility as far as possible, we have a new property | ||
16 | migrate-tick-offset; by default this is 'true' and we will | ||
17 | migrate the true tick offset in a new subsection; if the | ||
18 | incoming data has no subsection we fall back to the old | ||
19 | vm_clock-based offset information, so old->new migration | ||
20 | compatibility is preserved. For complete new->old migration | ||
21 | compatibility, the property is set to 'false' for 4.0 and | ||
22 | earlier machine types (this will only affect 'virt-4.0' | ||
23 | and below, as none of the other pl031-using machines are | ||
24 | versioned). | ||
25 | |||
26 | Reported-by: Russell King <rmk@armlinux.org.uk> | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> | 15 | Message-id: 20200319193323.2038-6-peter.maydell@linaro.org |
29 | Message-id: 20190709143912.28905-1-peter.maydell@linaro.org | ||
30 | --- | 16 | --- |
31 | include/hw/timer/pl031.h | 2 + | 17 | MAINTAINERS | 5 + |
32 | hw/core/machine.c | 1 + | 18 | scripts/coverity-scan/run-coverity-scan | 311 ++++++++++++++++++++++++ |
33 | hw/timer/pl031.c | 92 ++++++++++++++++++++++++++++++++++++++-- | 19 | 2 files changed, 316 insertions(+) |
34 | 3 files changed, 91 insertions(+), 4 deletions(-) | 20 | create mode 100755 scripts/coverity-scan/run-coverity-scan |
35 | 21 | ||
36 | diff --git a/include/hw/timer/pl031.h b/include/hw/timer/pl031.h | 22 | diff --git a/MAINTAINERS b/MAINTAINERS |
37 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/include/hw/timer/pl031.h | 24 | --- a/MAINTAINERS |
39 | +++ b/include/hw/timer/pl031.h | 25 | +++ b/MAINTAINERS |
40 | @@ -XXX,XX +XXX,XX @@ typedef struct PL031State { | 26 | @@ -XXX,XX +XXX,XX @@ M: Markus Armbruster <armbru@redhat.com> |
41 | */ | 27 | S: Supported |
42 | uint32_t tick_offset_vmstate; | 28 | F: scripts/coverity-model.c |
43 | uint32_t tick_offset; | 29 | |
44 | + bool tick_offset_migrated; | 30 | +Coverity Scan integration |
45 | + bool migrate_tick_offset; | 31 | +M: Peter Maydell <peter.maydell@linaro.org> |
46 | 32 | +S: Maintained | |
47 | uint32_t mr; | 33 | +F: scripts/coverity-scan/ |
48 | uint32_t lr; | 34 | + |
49 | diff --git a/hw/core/machine.c b/hw/core/machine.c | 35 | Device Tree |
50 | index XXXXXXX..XXXXXXX 100644 | 36 | M: Alistair Francis <alistair.francis@wdc.com> |
51 | --- a/hw/core/machine.c | 37 | R: David Gibson <david@gibson.dropbear.id.au> |
52 | +++ b/hw/core/machine.c | 38 | diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-scan/run-coverity-scan |
53 | @@ -XXX,XX +XXX,XX @@ GlobalProperty hw_compat_4_0[] = { | 39 | new file mode 100755 |
54 | { "virtio-gpu-pci", "edid", "false" }, | 40 | index XXXXXXX..XXXXXXX |
55 | { "virtio-device", "use-started", "false" }, | 41 | --- /dev/null |
56 | { "virtio-balloon-device", "qemu-4-0-config-size", "true" }, | 42 | +++ b/scripts/coverity-scan/run-coverity-scan |
57 | + { "pl031", "migrate-tick-offset", "false" }, | 43 | @@ -XXX,XX +XXX,XX @@ |
58 | }; | 44 | +#!/bin/sh -e |
59 | const size_t hw_compat_4_0_len = G_N_ELEMENTS(hw_compat_4_0); | 45 | + |
60 | 46 | +# Upload a created tarball to Coverity Scan, as per | |
61 | diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c | 47 | +# https://scan.coverity.com/projects/qemu/builds/new |
62 | index XXXXXXX..XXXXXXX 100644 | 48 | + |
63 | --- a/hw/timer/pl031.c | 49 | +# This work is licensed under the terms of the GNU GPL version 2, |
64 | +++ b/hw/timer/pl031.c | 50 | +# or (at your option) any later version. |
65 | @@ -XXX,XX +XXX,XX @@ static int pl031_pre_save(void *opaque) | 51 | +# See the COPYING file in the top-level directory. |
66 | { | 52 | +# |
67 | PL031State *s = opaque; | 53 | +# Copyright (c) 2017-2020 Linaro Limited |
68 | 54 | +# Written by Peter Maydell | |
69 | - /* tick_offset is base_time - rtc_clock base time. Instead, we want to | 55 | + |
70 | - * store the base time relative to the QEMU_CLOCK_VIRTUAL for backwards-compatibility. */ | 56 | +# Note that this script will automatically download and |
71 | + /* | 57 | +# run the (closed-source) coverity build tools, so don't |
72 | + * The PL031 device model code uses the tick_offset field, which is | 58 | +# use it if you don't trust them! |
73 | + * the offset between what the guest RTC should read and what the | 59 | + |
74 | + * QEMU rtc_clock reads: | 60 | +# This script assumes that you're running it from a QEMU source |
75 | + * guest_rtc = rtc_clock + tick_offset | 61 | +# tree, and that tree is a fresh clean one, because we do an in-tree |
76 | + * and so | 62 | +# build. (This is necessary so that the filenames that the Coverity |
77 | + * tick_offset = guest_rtc - rtc_clock | 63 | +# Scan server sees are relative paths that match up with the component |
78 | + * | 64 | +# regular expressions it uses; an out-of-tree build won't work for this.) |
79 | + * We want to migrate this offset, which sounds straightforward. | 65 | +# The host machine should have as many of QEMU's dependencies |
80 | + * Unfortunately older versions of QEMU migrated a conversion of this | 66 | +# installed as possible, for maximum coverity coverage. |
81 | + * offset into an offset from the vm_clock. (This was in turn an | 67 | + |
82 | + * attempt to be compatible with even older QEMU versions, but it | 68 | +# To do an upload you need to be a maintainer in the Coverity online |
83 | + * has incorrect behaviour if the rtc_clock is not the same as the | 69 | +# service, and you will need to know the "Coverity token", which is a |
84 | + * vm_clock.) So we put the actual tick_offset into a migration | 70 | +# secret 8 digit hex string. You can find that from the web UI in the |
85 | + * subsection, and the backwards-compatible time-relative-to-vm_clock | 71 | +# project settings, if you have maintainer access there. |
86 | + * in the main migration state. | 72 | + |
87 | + * | 73 | +# Command line options: |
88 | + * Calculate base time relative to QEMU_CLOCK_VIRTUAL: | 74 | +# --dry-run : run the tools, but don't actually do the upload |
89 | + */ | 75 | +# --update-tools-only : update the cached copy of the tools, but don't run them |
90 | int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 76 | +# --tokenfile : file to read Coverity token from |
91 | s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND; | 77 | +# --version ver : specify version being analyzed (default: ask git) |
92 | 78 | +# --description desc : specify description of this version (default: ask git) | |
93 | return 0; | 79 | +# --srcdir : QEMU source tree to analyze (default: current working dir) |
94 | } | 80 | +# --results-tarball : path to copy the results tarball to (default: don't |
95 | 81 | +# copy it anywhere, just upload it) | |
96 | +static int pl031_pre_load(void *opaque) | 82 | +# |
97 | +{ | 83 | +# User-specifiable environment variables: |
98 | + PL031State *s = opaque; | 84 | +# COVERITY_TOKEN -- Coverity token |
99 | + | 85 | +# COVERITY_EMAIL -- the email address to use for uploads (default: |
100 | + s->tick_offset_migrated = false; | 86 | +# looks at your git user.email config) |
101 | + return 0; | 87 | +# COVERITY_BUILD_CMD -- make command (default: 'make -jN' where N is |
88 | +# number of CPUs as determined by 'nproc') | ||
89 | +# COVERITY_TOOL_BASE -- set to directory to put coverity tools | ||
90 | +# (default: /tmp/coverity-tools) | ||
91 | +# | ||
92 | +# You must specify the token, either by environment variable or by | ||
93 | +# putting it in a file and using --tokenfile. Everything else has | ||
94 | +# a reasonable default if this is run from a git tree. | ||
95 | + | ||
96 | +check_upload_permissions() { | ||
97 | + # Check whether we can do an upload to the server; will exit the script | ||
98 | + # with status 1 if the check failed (usually a bad token); | ||
99 | + # will exit the script with status 0 if the check indicated that we | ||
100 | + # can't upload yet (ie we are at quota) | ||
101 | + # Assumes that PROJTOKEN, PROJNAME and DRYRUN have been initialized. | ||
102 | + | ||
103 | + echo "Checking upload permissions..." | ||
104 | + | ||
105 | + if ! up_perm="$(wget https://scan.coverity.com/api/upload_permitted --post-data "token=$PROJTOKEN&project=$PROJNAME" -q -O -)"; then | ||
106 | + echo "Coverity Scan API access denied: bad token?" | ||
107 | + exit 1 | ||
108 | + fi | ||
109 | + | ||
110 | + # Really up_perm is a JSON response with either | ||
111 | + # {upload_permitted:true} or {next_upload_permitted_at:<date>} | ||
112 | + # We do some hacky string parsing instead of properly parsing it. | ||
113 | + case "$up_perm" in | ||
114 | + *upload_permitted*true*) | ||
115 | + echo "Coverity Scan: upload permitted" | ||
116 | + ;; | ||
117 | + *next_upload_permitted_at*) | ||
118 | + if [ "$DRYRUN" = yes ]; then | ||
119 | + echo "Coverity Scan: upload quota reached, continuing dry run" | ||
120 | + else | ||
121 | + echo "Coverity Scan: upload quota reached; stopping here" | ||
122 | + # Exit success as this isn't a build error. | ||
123 | + exit 0 | ||
124 | + fi | ||
125 | + ;; | ||
126 | + *) | ||
127 | + echo "Coverity Scan upload check: unexpected result $up_perm" | ||
128 | + exit 1 | ||
129 | + ;; | ||
130 | + esac | ||
102 | +} | 131 | +} |
103 | + | 132 | + |
104 | static int pl031_post_load(void *opaque, int version_id) | 133 | + |
105 | { | 134 | +update_coverity_tools () { |
106 | PL031State *s = opaque; | 135 | + # Check for whether we need to download the Coverity tools |
107 | 136 | + # (either because we don't have a copy, or because it's out of date) | |
108 | - int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 137 | + # Assumes that COVERITY_TOOL_BASE, PROJTOKEN and PROJNAME are set. |
109 | - s->tick_offset = s->tick_offset_vmstate - delta / NANOSECONDS_PER_SECOND; | 138 | + |
110 | + /* | 139 | + mkdir -p "$COVERITY_TOOL_BASE" |
111 | + * If we got the tick_offset subsection, then we can just use | 140 | + cd "$COVERITY_TOOL_BASE" |
112 | + * the value in that. Otherwise the source is an older QEMU and | 141 | + |
113 | + * has given us the offset from the vm_clock; convert it back to | 142 | + echo "Checking for new version of coverity build tools..." |
114 | + * an offset from the rtc_clock. This will cause time to incorrectly | 143 | + wget https://scan.coverity.com/download/linux64 --post-data "token=$PROJTOKEN&project=$PROJNAME&md5=1" -O coverity_tool.md5.new |
115 | + * go backwards compared to the host RTC, but this is unavoidable. | 144 | + |
116 | + */ | 145 | + if ! cmp -s coverity_tool.md5 coverity_tool.md5.new; then |
117 | + | 146 | + # out of date md5 or no md5: download new build tool |
118 | + if (!s->tick_offset_migrated) { | 147 | + # blow away the old build tool |
119 | + int64_t delta = qemu_clock_get_ns(rtc_clock) - | 148 | + echo "Downloading coverity build tools..." |
120 | + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 149 | + rm -rf coverity_tool coverity_tool.tgz |
121 | + s->tick_offset = s->tick_offset_vmstate - | 150 | + wget https://scan.coverity.com/download/linux64 --post-data "token=$PROJTOKEN&project=$PROJNAME" -O coverity_tool.tgz |
122 | + delta / NANOSECONDS_PER_SECOND; | 151 | + if ! (cat coverity_tool.md5.new; echo " coverity_tool.tgz") | md5sum -c --status; then |
123 | + } | 152 | + echo "Downloaded tarball didn't match md5sum!" |
124 | pl031_set_alarm(s); | 153 | + exit 1 |
125 | return 0; | 154 | + fi |
126 | } | 155 | + # extract the new one, keeping it corralled in a 'coverity_tool' directory |
127 | 156 | + echo "Unpacking coverity build tools..." | |
128 | +static int pl031_tick_offset_post_load(void *opaque, int version_id) | 157 | + mkdir -p coverity_tool |
129 | +{ | 158 | + cd coverity_tool |
130 | + PL031State *s = opaque; | 159 | + tar xf ../coverity_tool.tgz |
131 | + | 160 | + cd .. |
132 | + s->tick_offset_migrated = true; | 161 | + mv coverity_tool.md5.new coverity_tool.md5 |
133 | + return 0; | 162 | + fi |
163 | + | ||
164 | + rm -f coverity_tool.md5.new | ||
134 | +} | 165 | +} |
135 | + | 166 | + |
136 | +static bool pl031_tick_offset_needed(void *opaque) | 167 | + |
137 | +{ | 168 | +# Check user-provided environment variables and arguments |
138 | + PL031State *s = opaque; | 169 | +DRYRUN=no |
139 | + | 170 | +UPDATE_ONLY=no |
140 | + return s->migrate_tick_offset; | 171 | + |
141 | +} | 172 | +while [ "$#" -ge 1 ]; do |
142 | + | 173 | + case "$1" in |
143 | +static const VMStateDescription vmstate_pl031_tick_offset = { | 174 | + --dry-run) |
144 | + .name = "pl031/tick-offset", | 175 | + shift |
145 | + .version_id = 1, | 176 | + DRYRUN=yes |
146 | + .minimum_version_id = 1, | 177 | + ;; |
147 | + .needed = pl031_tick_offset_needed, | 178 | + --update-tools-only) |
148 | + .post_load = pl031_tick_offset_post_load, | 179 | + shift |
149 | + .fields = (VMStateField[]) { | 180 | + UPDATE_ONLY=yes |
150 | + VMSTATE_UINT32(tick_offset, PL031State), | 181 | + ;; |
151 | + VMSTATE_END_OF_LIST() | 182 | + --version) |
152 | + } | 183 | + shift |
153 | +}; | 184 | + if [ $# -eq 0 ]; then |
154 | + | 185 | + echo "--version needs an argument" |
155 | static const VMStateDescription vmstate_pl031 = { | 186 | + exit 1 |
156 | .name = "pl031", | 187 | + fi |
157 | .version_id = 1, | 188 | + VERSION="$1" |
158 | .minimum_version_id = 1, | 189 | + shift |
159 | .pre_save = pl031_pre_save, | 190 | + ;; |
160 | + .pre_load = pl031_pre_load, | 191 | + --description) |
161 | .post_load = pl031_post_load, | 192 | + shift |
162 | .fields = (VMStateField[]) { | 193 | + if [ $# -eq 0 ]; then |
163 | VMSTATE_UINT32(tick_offset_vmstate, PL031State), | 194 | + echo "--description needs an argument" |
164 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl031 = { | 195 | + exit 1 |
165 | VMSTATE_UINT32(im, PL031State), | 196 | + fi |
166 | VMSTATE_UINT32(is, PL031State), | 197 | + DESCRIPTION="$1" |
167 | VMSTATE_END_OF_LIST() | 198 | + shift |
168 | + }, | 199 | + ;; |
169 | + .subsections = (const VMStateDescription*[]) { | 200 | + --tokenfile) |
170 | + &vmstate_pl031_tick_offset, | 201 | + shift |
171 | + NULL | 202 | + if [ $# -eq 0 ]; then |
172 | } | 203 | + echo "--tokenfile needs an argument" |
173 | }; | 204 | + exit 1 |
174 | 205 | + fi | |
175 | +static Property pl031_properties[] = { | 206 | + COVERITY_TOKEN="$(cat "$1")" |
176 | + /* | 207 | + shift |
177 | + * True to correctly migrate the tick offset of the RTC. False to | 208 | + ;; |
178 | + * obtain backward migration compatibility with older QEMU versions, | 209 | + --srcdir) |
179 | + * at the expense of the guest RTC going backwards compared with the | 210 | + shift |
180 | + * host RTC when the VM is saved/restored if using -rtc host. | 211 | + if [ $# -eq 0 ]; then |
181 | + * (Even if set to 'true' older QEMU can migrate forward to newer QEMU; | 212 | + echo "--srcdir needs an argument" |
182 | + * 'false' also permits newer QEMU to migrate to older QEMU.) | 213 | + exit 1 |
183 | + */ | 214 | + fi |
184 | + DEFINE_PROP_BOOL("migrate-tick-offset", | 215 | + SRCDIR="$1" |
185 | + PL031State, migrate_tick_offset, true), | 216 | + shift |
186 | + DEFINE_PROP_END_OF_LIST() | 217 | + ;; |
187 | +}; | 218 | + --results-tarball) |
188 | + | 219 | + shift |
189 | static void pl031_class_init(ObjectClass *klass, void *data) | 220 | + if [ $# -eq 0 ]; then |
190 | { | 221 | + echo "--results-tarball needs an argument" |
191 | DeviceClass *dc = DEVICE_CLASS(klass); | 222 | + exit 1 |
192 | 223 | + fi | |
193 | dc->vmsd = &vmstate_pl031; | 224 | + RESULTSTARBALL="$1" |
194 | + dc->props = pl031_properties; | 225 | + shift |
195 | } | 226 | + ;; |
196 | 227 | + *) | |
197 | static const TypeInfo pl031_info = { | 228 | + echo "Unexpected argument '$1'" |
229 | + exit 1 | ||
230 | + ;; | ||
231 | + esac | ||
232 | +done | ||
233 | + | ||
234 | +if [ -z "$COVERITY_TOKEN" ]; then | ||
235 | + echo "COVERITY_TOKEN environment variable not set" | ||
236 | + exit 1 | ||
237 | +fi | ||
238 | + | ||
239 | +if [ -z "$COVERITY_BUILD_CMD" ]; then | ||
240 | + NPROC=$(nproc) | ||
241 | + COVERITY_BUILD_CMD="make -j$NPROC" | ||
242 | + echo "COVERITY_BUILD_CMD: using default '$COVERITY_BUILD_CMD'" | ||
243 | +fi | ||
244 | + | ||
245 | +if [ -z "$COVERITY_TOOL_BASE" ]; then | ||
246 | + echo "COVERITY_TOOL_BASE: using default /tmp/coverity-tools" | ||
247 | + COVERITY_TOOL_BASE=/tmp/coverity-tools | ||
248 | +fi | ||
249 | + | ||
250 | +if [ -z "$SRCDIR" ]; then | ||
251 | + SRCDIR="$PWD" | ||
252 | +fi | ||
253 | + | ||
254 | +PROJTOKEN="$COVERITY_TOKEN" | ||
255 | +PROJNAME=QEMU | ||
256 | +TARBALL=cov-int.tar.xz | ||
257 | + | ||
258 | + | ||
259 | +if [ "$UPDATE_ONLY" = yes ]; then | ||
260 | + # Just do the tools update; we don't need to check whether | ||
261 | + # we are in a source tree or have upload rights for this, | ||
262 | + # so do it before some of the command line and source tree checks. | ||
263 | + update_coverity_tools | ||
264 | + exit 0 | ||
265 | +fi | ||
266 | + | ||
267 | +cd "$SRCDIR" | ||
268 | + | ||
269 | +echo "Checking this is a QEMU source tree..." | ||
270 | +if ! [ -e "$SRCDIR/VERSION" ]; then | ||
271 | + echo "Not in a QEMU source tree?" | ||
272 | + exit 1 | ||
273 | +fi | ||
274 | + | ||
275 | +# Fill in defaults used by the non-update-only process | ||
276 | +if [ -z "$VERSION" ]; then | ||
277 | + VERSION="$(git describe --always HEAD)" | ||
278 | +fi | ||
279 | + | ||
280 | +if [ -z "$DESCRIPTION" ]; then | ||
281 | + DESCRIPTION="$(git rev-parse HEAD)" | ||
282 | +fi | ||
283 | + | ||
284 | +if [ -z "$COVERITY_EMAIL" ]; then | ||
285 | + COVERITY_EMAIL="$(git config user.email)" | ||
286 | +fi | ||
287 | + | ||
288 | +check_upload_permissions | ||
289 | + | ||
290 | +update_coverity_tools | ||
291 | + | ||
292 | +TOOLBIN="$(cd "$COVERITY_TOOL_BASE" && echo $PWD/coverity_tool/cov-analysis-*/bin)" | ||
293 | + | ||
294 | +if ! test -x "$TOOLBIN/cov-build"; then | ||
295 | + echo "Couldn't find cov-build in the coverity build-tool directory??" | ||
296 | + exit 1 | ||
297 | +fi | ||
298 | + | ||
299 | +export PATH="$TOOLBIN:$PATH" | ||
300 | + | ||
301 | +cd "$SRCDIR" | ||
302 | + | ||
303 | +echo "Doing make distclean..." | ||
304 | +make distclean | ||
305 | + | ||
306 | +echo "Configuring..." | ||
307 | +# We configure with a fixed set of enables here to ensure that we don't | ||
308 | +# accidentally reduce the scope of the analysis by doing the build on | ||
309 | +# the system that's missing a dependency that we need to build part of | ||
310 | +# the codebase. | ||
311 | +./configure --disable-modules --enable-sdl --enable-gtk \ | ||
312 | + --enable-opengl --enable-vte --enable-gnutls \ | ||
313 | + --enable-nettle --enable-curses --enable-curl \ | ||
314 | + --audio-drv-list=oss,alsa,sdl,pa --enable-virtfs \ | ||
315 | + --enable-vnc --enable-vnc-sasl --enable-vnc-jpeg --enable-vnc-png \ | ||
316 | + --enable-xen --enable-brlapi \ | ||
317 | + --enable-linux-aio --enable-attr \ | ||
318 | + --enable-cap-ng --enable-trace-backends=log --enable-spice --enable-rbd \ | ||
319 | + --enable-xfsctl --enable-libusb --enable-usb-redir \ | ||
320 | + --enable-libiscsi --enable-libnfs --enable-seccomp \ | ||
321 | + --enable-tpm --enable-libssh --enable-lzo --enable-snappy --enable-bzip2 \ | ||
322 | + --enable-numa --enable-rdma --enable-smartcard --enable-virglrenderer \ | ||
323 | + --enable-mpath --enable-libxml2 --enable-glusterfs \ | ||
324 | + --enable-virtfs --enable-zstd | ||
325 | + | ||
326 | +echo "Making libqemustub.a..." | ||
327 | +make libqemustub.a | ||
328 | + | ||
329 | +echo "Running cov-build..." | ||
330 | +rm -rf cov-int | ||
331 | +mkdir cov-int | ||
332 | +cov-build --dir cov-int $COVERITY_BUILD_CMD | ||
333 | + | ||
334 | +echo "Creating results tarball..." | ||
335 | +tar cvf - cov-int | xz > "$TARBALL" | ||
336 | + | ||
337 | +if [ ! -z "$RESULTSTARBALL" ]; then | ||
338 | + echo "Copying results tarball to $RESULTSTARBALL..." | ||
339 | + cp "$TARBALL" "$RESULTSTARBALL" | ||
340 | +fi | ||
341 | + | ||
342 | +echo "Uploading results tarball..." | ||
343 | + | ||
344 | +if [ "$DRYRUN" = yes ]; then | ||
345 | + echo "Dry run only, not uploading $TARBALL" | ||
346 | + exit 0 | ||
347 | +fi | ||
348 | + | ||
349 | +curl --form token="$PROJTOKEN" --form email="$COVERITY_EMAIL" \ | ||
350 | + --form file=@"$TARBALL" --form version="$VERSION" \ | ||
351 | + --form description="$DESCRIPTION" \ | ||
352 | + https://scan.coverity.com/builds?project="$PROJNAME" | ||
353 | + | ||
354 | +echo "Done." | ||
198 | -- | 355 | -- |
199 | 2.20.1 | 356 | 2.20.1 |
200 | 357 | ||
201 | 358 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Add support for running the Coverity Scan tools inside a Docker |
---|---|---|---|
2 | 2 | container rather than directly on the host system. | |
3 | Reading the RX_DATA register when the RX_FIFO is empty triggers | 3 | |
4 | an abort. This can be easily reproduced: | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
5 | |||
6 | $ qemu-system-arm -M emcraft-sf2 -monitor stdio -S | ||
7 | QEMU 4.0.50 monitor - type 'help' for more information | ||
8 | (qemu) x 0x40001010 | ||
9 | Aborted (core dumped) | ||
10 | |||
11 | (gdb) bt | ||
12 | #1 0x00007f035874f895 in abort () at /lib64/libc.so.6 | ||
13 | #2 0x00005628686591ff in fifo8_pop (fifo=0x56286a9a4c68) at util/fifo8.c:66 | ||
14 | #3 0x00005628683e0b8e in fifo32_pop (fifo=0x56286a9a4c68) at include/qemu/fifo32.h:137 | ||
15 | #4 0x00005628683e0efb in spi_read (opaque=0x56286a9a4850, addr=4, size=4) at hw/ssi/mss-spi.c:168 | ||
16 | #5 0x0000562867f96801 in memory_region_read_accessor (mr=0x56286a9a4b60, addr=16, value=0x7ffeecb0c5c8, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:439 | ||
17 | #6 0x0000562867f96cdb in access_with_adjusted_size (addr=16, value=0x7ffeecb0c5c8, size=4, access_size_min=1, access_size_max=4, access_fn=0x562867f967c3 <memory_region_read_accessor>, mr=0x56286a9a4b60, attrs=...) at memory.c:569 | ||
18 | #7 0x0000562867f99940 in memory_region_dispatch_read1 (mr=0x56286a9a4b60, addr=16, pval=0x7ffeecb0c5c8, size=4, attrs=...) at memory.c:1420 | ||
19 | #8 0x0000562867f99a08 in memory_region_dispatch_read (mr=0x56286a9a4b60, addr=16, pval=0x7ffeecb0c5c8, size=4, attrs=...) at memory.c:1447 | ||
20 | #9 0x0000562867f38721 in flatview_read_continue (fv=0x56286aec6360, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, addr1=16, l=4, mr=0x56286a9a4b60) at exec.c:3385 | ||
21 | #10 0x0000562867f38874 in flatview_read (fv=0x56286aec6360, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4) at exec.c:3423 | ||
22 | #11 0x0000562867f388ea in address_space_read_full (as=0x56286aa3e890, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4) at exec.c:3436 | ||
23 | #12 0x0000562867f389c5 in address_space_rw (as=0x56286aa3e890, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, is_write=false) at exec.c:3466 | ||
24 | #13 0x0000562867f3bdd7 in cpu_memory_rw_debug (cpu=0x56286aa19d00, addr=1073745936, buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, is_write=0) at exec.c:3976 | ||
25 | #14 0x000056286811ed51 in memory_dump (mon=0x56286a8c32d0, count=1, format=120, wsize=4, addr=1073745936, is_physical=0) at monitor/misc.c:730 | ||
26 | #15 0x000056286811eff1 in hmp_memory_dump (mon=0x56286a8c32d0, qdict=0x56286b15c400) at monitor/misc.c:785 | ||
27 | #16 0x00005628684740ee in handle_hmp_command (mon=0x56286a8c32d0, cmdline=0x56286a8caeb2 "0x40001010") at monitor/hmp.c:1082 | ||
28 | |||
29 | From the datasheet "Actel SmartFusion Microcontroller Subsystem | ||
30 | User's Guide" Rev.1, Table 13-3 "SPI Register Summary", this | ||
31 | register has a reset value of 0. | ||
32 | |||
33 | Check the FIFO is not empty before accessing it, else log an | ||
34 | error message. | ||
35 | |||
36 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
37 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
38 | Message-id: 20190709113715.7761-3-philmd@redhat.com | ||
39 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Message-id: 20200319193323.2038-7-peter.maydell@linaro.org | ||
40 | --- | 7 | --- |
41 | hw/ssi/mss-spi.c | 8 +++++++- | 8 | scripts/coverity-scan/coverity-scan.docker | 131 +++++++++++++++++++++ |
42 | 1 file changed, 7 insertions(+), 1 deletion(-) | 9 | scripts/coverity-scan/run-coverity-scan | 90 ++++++++++++++ |
43 | 10 | 2 files changed, 221 insertions(+) | |
44 | diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c | 11 | create mode 100644 scripts/coverity-scan/coverity-scan.docker |
45 | index XXXXXXX..XXXXXXX 100644 | 12 | |
46 | --- a/hw/ssi/mss-spi.c | 13 | diff --git a/scripts/coverity-scan/coverity-scan.docker b/scripts/coverity-scan/coverity-scan.docker |
47 | +++ b/hw/ssi/mss-spi.c | 14 | new file mode 100644 |
48 | @@ -XXX,XX +XXX,XX @@ spi_read(void *opaque, hwaddr addr, unsigned int size) | 15 | index XXXXXXX..XXXXXXX |
49 | case R_SPI_RX: | 16 | --- /dev/null |
50 | s->regs[R_SPI_STATUS] &= ~S_RXFIFOFUL; | 17 | +++ b/scripts/coverity-scan/coverity-scan.docker |
51 | s->regs[R_SPI_STATUS] &= ~S_RXCHOVRF; | 18 | @@ -XXX,XX +XXX,XX @@ |
52 | - ret = fifo32_pop(&s->rx_fifo); | 19 | +# syntax=docker/dockerfile:1.0.0-experimental |
53 | + if (fifo32_is_empty(&s->rx_fifo)) { | 20 | +# |
54 | + qemu_log_mask(LOG_GUEST_ERROR, | 21 | +# Docker setup for running the "Coverity Scan" tools over the source |
55 | + "%s: Reading empty RX_FIFO\n", | 22 | +# tree and uploading them to the website, as per |
56 | + __func__); | 23 | +# https://scan.coverity.com/projects/qemu/builds/new |
57 | + } else { | 24 | +# We do this on a fixed config (currently Fedora 30 with a known |
58 | + ret = fifo32_pop(&s->rx_fifo); | 25 | +# set of dependencies and a configure command that enables a specific |
59 | + } | 26 | +# set of options) so that random changes don't result in our accidentally |
60 | if (fifo32_is_empty(&s->rx_fifo)) { | 27 | +# dropping some files from the scan. |
61 | s->regs[R_SPI_STATUS] |= S_RXFIFOEMP; | 28 | +# |
62 | } | 29 | +# We don't build on top of the fedora.docker file because we don't |
30 | +# want to accidentally change or break the scan config when that | ||
31 | +# is updated. | ||
32 | + | ||
33 | +# The work of actually doing the build is handled by the | ||
34 | +# run-coverity-scan script. | ||
35 | + | ||
36 | +FROM fedora:30 | ||
37 | +ENV PACKAGES \ | ||
38 | + alsa-lib-devel \ | ||
39 | + bc \ | ||
40 | + bison \ | ||
41 | + brlapi-devel \ | ||
42 | + bzip2 \ | ||
43 | + bzip2-devel \ | ||
44 | + ccache \ | ||
45 | + clang \ | ||
46 | + curl \ | ||
47 | + cyrus-sasl-devel \ | ||
48 | + dbus-daemon \ | ||
49 | + device-mapper-multipath-devel \ | ||
50 | + findutils \ | ||
51 | + flex \ | ||
52 | + gcc \ | ||
53 | + gcc-c++ \ | ||
54 | + gettext \ | ||
55 | + git \ | ||
56 | + glib2-devel \ | ||
57 | + glusterfs-api-devel \ | ||
58 | + gnutls-devel \ | ||
59 | + gtk3-devel \ | ||
60 | + hostname \ | ||
61 | + libaio-devel \ | ||
62 | + libasan \ | ||
63 | + libattr-devel \ | ||
64 | + libblockdev-mpath-devel \ | ||
65 | + libcap-devel \ | ||
66 | + libcap-ng-devel \ | ||
67 | + libcurl-devel \ | ||
68 | + libepoxy-devel \ | ||
69 | + libfdt-devel \ | ||
70 | + libgbm-devel \ | ||
71 | + libiscsi-devel \ | ||
72 | + libjpeg-devel \ | ||
73 | + libpmem-devel \ | ||
74 | + libnfs-devel \ | ||
75 | + libpng-devel \ | ||
76 | + librbd-devel \ | ||
77 | + libseccomp-devel \ | ||
78 | + libssh-devel \ | ||
79 | + libubsan \ | ||
80 | + libudev-devel \ | ||
81 | + libusbx-devel \ | ||
82 | + libxml2-devel \ | ||
83 | + libzstd-devel \ | ||
84 | + llvm \ | ||
85 | + lzo-devel \ | ||
86 | + make \ | ||
87 | + mingw32-bzip2 \ | ||
88 | + mingw32-curl \ | ||
89 | + mingw32-glib2 \ | ||
90 | + mingw32-gmp \ | ||
91 | + mingw32-gnutls \ | ||
92 | + mingw32-gtk3 \ | ||
93 | + mingw32-libjpeg-turbo \ | ||
94 | + mingw32-libpng \ | ||
95 | + mingw32-libtasn1 \ | ||
96 | + mingw32-nettle \ | ||
97 | + mingw32-nsis \ | ||
98 | + mingw32-pixman \ | ||
99 | + mingw32-pkg-config \ | ||
100 | + mingw32-SDL2 \ | ||
101 | + mingw64-bzip2 \ | ||
102 | + mingw64-curl \ | ||
103 | + mingw64-glib2 \ | ||
104 | + mingw64-gmp \ | ||
105 | + mingw64-gnutls \ | ||
106 | + mingw64-gtk3 \ | ||
107 | + mingw64-libjpeg-turbo \ | ||
108 | + mingw64-libpng \ | ||
109 | + mingw64-libtasn1 \ | ||
110 | + mingw64-nettle \ | ||
111 | + mingw64-pixman \ | ||
112 | + mingw64-pkg-config \ | ||
113 | + mingw64-SDL2 \ | ||
114 | + ncurses-devel \ | ||
115 | + nettle-devel \ | ||
116 | + nss-devel \ | ||
117 | + numactl-devel \ | ||
118 | + perl \ | ||
119 | + perl-Test-Harness \ | ||
120 | + pixman-devel \ | ||
121 | + pulseaudio-libs-devel \ | ||
122 | + python3 \ | ||
123 | + python3-sphinx \ | ||
124 | + PyYAML \ | ||
125 | + rdma-core-devel \ | ||
126 | + SDL2-devel \ | ||
127 | + snappy-devel \ | ||
128 | + sparse \ | ||
129 | + spice-server-devel \ | ||
130 | + systemd-devel \ | ||
131 | + systemtap-sdt-devel \ | ||
132 | + tar \ | ||
133 | + texinfo \ | ||
134 | + usbredir-devel \ | ||
135 | + virglrenderer-devel \ | ||
136 | + vte291-devel \ | ||
137 | + wget \ | ||
138 | + which \ | ||
139 | + xen-devel \ | ||
140 | + xfsprogs-devel \ | ||
141 | + zlib-devel | ||
142 | +ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3 | ||
143 | + | ||
144 | +RUN dnf install -y $PACKAGES | ||
145 | +RUN rpm -q $PACKAGES | sort > /packages.txt | ||
146 | +ENV PATH $PATH:/usr/libexec/python3-sphinx/ | ||
147 | +ENV COVERITY_TOOL_BASE=/coverity-tools | ||
148 | +COPY run-coverity-scan run-coverity-scan | ||
149 | +RUN --mount=type=secret,id=coverity.token,required ./run-coverity-scan --update-tools-only --tokenfile /run/secrets/coverity.token | ||
150 | diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-scan/run-coverity-scan | ||
151 | index XXXXXXX..XXXXXXX 100755 | ||
152 | --- a/scripts/coverity-scan/run-coverity-scan | ||
153 | +++ b/scripts/coverity-scan/run-coverity-scan | ||
154 | @@ -XXX,XX +XXX,XX @@ | ||
155 | |||
156 | # Command line options: | ||
157 | # --dry-run : run the tools, but don't actually do the upload | ||
158 | +# --docker : create and work inside a docker container | ||
159 | # --update-tools-only : update the cached copy of the tools, but don't run them | ||
160 | # --tokenfile : file to read Coverity token from | ||
161 | # --version ver : specify version being analyzed (default: ask git) | ||
162 | @@ -XXX,XX +XXX,XX @@ | ||
163 | # --srcdir : QEMU source tree to analyze (default: current working dir) | ||
164 | # --results-tarball : path to copy the results tarball to (default: don't | ||
165 | # copy it anywhere, just upload it) | ||
166 | +# --src-tarball : tarball to untar into src dir (default: none); this | ||
167 | +# is intended mainly for internal use by the Docker support | ||
168 | # | ||
169 | # User-specifiable environment variables: | ||
170 | # COVERITY_TOKEN -- Coverity token | ||
171 | @@ -XXX,XX +XXX,XX @@ update_coverity_tools () { | ||
172 | # Check user-provided environment variables and arguments | ||
173 | DRYRUN=no | ||
174 | UPDATE_ONLY=no | ||
175 | +DOCKER=no | ||
176 | |||
177 | while [ "$#" -ge 1 ]; do | ||
178 | case "$1" in | ||
179 | @@ -XXX,XX +XXX,XX @@ while [ "$#" -ge 1 ]; do | ||
180 | RESULTSTARBALL="$1" | ||
181 | shift | ||
182 | ;; | ||
183 | + --src-tarball) | ||
184 | + shift | ||
185 | + if [ $# -eq 0 ]; then | ||
186 | + echo "--src-tarball needs an argument" | ||
187 | + exit 1 | ||
188 | + fi | ||
189 | + SRCTARBALL="$1" | ||
190 | + shift | ||
191 | + ;; | ||
192 | + --docker) | ||
193 | + DOCKER=yes | ||
194 | + shift | ||
195 | + ;; | ||
196 | *) | ||
197 | echo "Unexpected argument '$1'" | ||
198 | exit 1 | ||
199 | @@ -XXX,XX +XXX,XX @@ PROJTOKEN="$COVERITY_TOKEN" | ||
200 | PROJNAME=QEMU | ||
201 | TARBALL=cov-int.tar.xz | ||
202 | |||
203 | +if [ "$UPDATE_ONLY" = yes ] && [ "$DOCKER" = yes ]; then | ||
204 | + echo "Combining --docker and --update-only is not supported" | ||
205 | + exit 1 | ||
206 | +fi | ||
207 | |||
208 | if [ "$UPDATE_ONLY" = yes ]; then | ||
209 | # Just do the tools update; we don't need to check whether | ||
210 | @@ -XXX,XX +XXX,XX @@ if [ "$UPDATE_ONLY" = yes ]; then | ||
211 | exit 0 | ||
212 | fi | ||
213 | |||
214 | +if [ ! -e "$SRCDIR" ]; then | ||
215 | + mkdir "$SRCDIR" | ||
216 | +fi | ||
217 | + | ||
218 | cd "$SRCDIR" | ||
219 | |||
220 | +if [ ! -z "$SRCTARBALL" ]; then | ||
221 | + echo "Untarring source tarball into $SRCDIR..." | ||
222 | + tar xvf "$SRCTARBALL" | ||
223 | +fi | ||
224 | + | ||
225 | echo "Checking this is a QEMU source tree..." | ||
226 | if ! [ -e "$SRCDIR/VERSION" ]; then | ||
227 | echo "Not in a QEMU source tree?" | ||
228 | @@ -XXX,XX +XXX,XX @@ if [ -z "$COVERITY_EMAIL" ]; then | ||
229 | COVERITY_EMAIL="$(git config user.email)" | ||
230 | fi | ||
231 | |||
232 | +# Run ourselves inside docker if that's what the user wants | ||
233 | +if [ "$DOCKER" = yes ]; then | ||
234 | + # build docker container including the coverity-scan tools | ||
235 | + # Put the Coverity token into a temporary file that only | ||
236 | + # we have read access to, and then pass it to docker build | ||
237 | + # using --secret. This requires at least Docker 18.09. | ||
238 | + # Mostly what we are trying to do here is ensure we don't leak | ||
239 | + # the token into the Docker image. | ||
240 | + umask 077 | ||
241 | + SECRETDIR=$(mktemp -d) | ||
242 | + if [ -z "$SECRETDIR" ]; then | ||
243 | + echo "Failed to create temporary directory" | ||
244 | + exit 1 | ||
245 | + fi | ||
246 | + trap 'rm -rf "$SECRETDIR"' INT TERM EXIT | ||
247 | + echo "Created temporary directory $SECRETDIR" | ||
248 | + SECRET="$SECRETDIR/token" | ||
249 | + echo "$COVERITY_TOKEN" > "$SECRET" | ||
250 | + echo "Building docker container..." | ||
251 | + # TODO: This re-downloads the tools every time, rather than | ||
252 | + # caching and reusing the image produced with the downloaded tools. | ||
253 | + # Not sure why. | ||
254 | + # TODO: how do you get 'docker build' to print the output of the | ||
255 | + # commands it is running to its stdout? This would be useful for debug. | ||
256 | + DOCKER_BUILDKIT=1 docker build -t coverity-scanner \ | ||
257 | + --secret id=coverity.token,src="$SECRET" \ | ||
258 | + -f scripts/coverity-scan/coverity-scan.docker \ | ||
259 | + scripts/coverity-scan | ||
260 | + echo "Archiving sources to be analyzed..." | ||
261 | + ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" | ||
262 | + if [ "$DRYRUN" = yes ]; then | ||
263 | + DRYRUNARG=--dry-run | ||
264 | + fi | ||
265 | + echo "Running scanner..." | ||
266 | + # If we need to capture the output tarball, get the inner run to | ||
267 | + # save it to the secrets directory so we can copy it out before the | ||
268 | + # directory is cleaned up. | ||
269 | + if [ ! -z "$RESULTSTARBALL" ]; then | ||
270 | + RTARGS="--results-tarball /work/cov-int.tar.xz" | ||
271 | + else | ||
272 | + RTARGS="" | ||
273 | + fi | ||
274 | + # Arrange for this docker run to get access to the sources with -v. | ||
275 | + # We pass through all the configuration from the outer script to the inner. | ||
276 | + export COVERITY_EMAIL COVERITY_BUILD_CMD | ||
277 | + docker run -it --env COVERITY_EMAIL --env COVERITY_BUILD_CMD \ | ||
278 | + -v "$SECRETDIR:/work" coverity-scanner \ | ||
279 | + ./run-coverity-scan --version "$VERSION" \ | ||
280 | + --description "$DESCRIPTION" $DRYRUNARG --tokenfile /work/token \ | ||
281 | + --srcdir /qemu --src-tarball /work/qemu-sources.tgz $RTARGS | ||
282 | + if [ ! -z "$RESULTSTARBALL" ]; then | ||
283 | + echo "Copying results tarball to $RESULTSTARBALL..." | ||
284 | + cp "$SECRETDIR/cov-int.tar.xz" "$RESULTSTARBALL" | ||
285 | + fi | ||
286 | + echo "Docker work complete." | ||
287 | + exit 0 | ||
288 | +fi | ||
289 | + | ||
290 | +# Otherwise, continue with the full build and upload process. | ||
291 | + | ||
292 | check_upload_permissions | ||
293 | |||
294 | update_coverity_tools | ||
63 | -- | 295 | -- |
64 | 2.20.1 | 296 | 2.20.1 |
65 | 297 | ||
66 | 298 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | The documentation of our -s and -gdb options is quite old; in |
---|---|---|---|
2 | particular it still claims that it will cause QEMU to stop and wait | ||
3 | for the gdb connection, when this has not been true for some time: | ||
4 | you also need to pass -S if you want to make QEMU not launch the | ||
5 | guest on startup. | ||
2 | 6 | ||
3 | Both lqspi_read() and lqspi_load_cache() expect a 32-bit | 7 | Improve the documentation to mention this requirement in the |
4 | aligned address. | 8 | executable's --help output, the documentation of the -gdb option in |
9 | the manual, and in the "GDB usage" chapter. | ||
5 | 10 | ||
6 | >From UG1085 datasheet [*] chapter on 'Quad-SPI Controller': | 11 | Includes some minor tweaks to these paragraphs of documentation |
12 | since I was editing them anyway (such as dropping the description | ||
13 | of our gdb support as "primitive"). | ||
7 | 14 | ||
8 | Transfer Size Limitations | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
19 | Message-id: 20200403094014.9589-1-peter.maydell@linaro.org | ||
20 | --- | ||
21 | docs/system/gdb.rst | 22 +++++++++++++++------- | ||
22 | qemu-options.hx | 24 ++++++++++++++++++------ | ||
23 | 2 files changed, 33 insertions(+), 13 deletions(-) | ||
9 | 24 | ||
10 | Because of the 32-bit wide TX, RX, and generic FIFO, all | 25 | diff --git a/docs/system/gdb.rst b/docs/system/gdb.rst |
11 | APB/AXI transfers must be an integer multiple of 4-bytes. | ||
12 | Shorter transfers are not possible. | ||
13 | |||
14 | Set MemoryRegionOps.impl values to force 32-bit accesses, | ||
15 | this way we are sure we do not access the lqspi_buf[] array | ||
16 | out of bound. | ||
17 | |||
18 | [*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf | ||
19 | |||
20 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
21 | Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
22 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | --- | ||
25 | hw/ssi/xilinx_spips.c | 4 ++++ | ||
26 | 1 file changed, 4 insertions(+) | ||
27 | |||
28 | diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/hw/ssi/xilinx_spips.c | 27 | --- a/docs/system/gdb.rst |
31 | +++ b/hw/ssi/xilinx_spips.c | 28 | +++ b/docs/system/gdb.rst |
32 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps lqspi_ops = { | 29 | @@ -XXX,XX +XXX,XX @@ |
33 | .read_with_attrs = lqspi_read, | 30 | GDB usage |
34 | .write_with_attrs = lqspi_write, | 31 | --------- |
35 | .endianness = DEVICE_NATIVE_ENDIAN, | 32 | |
36 | + .impl = { | 33 | -QEMU has a primitive support to work with gdb, so that you can do |
37 | + .min_access_size = 4, | 34 | -'Ctrl-C' while the virtual machine is running and inspect its state. |
38 | + .max_access_size = 4, | 35 | +QEMU supports working with gdb via gdb's remote-connection facility |
39 | + }, | 36 | +(the "gdbstub"). This allows you to debug guest code in the same |
40 | .valid = { | 37 | +way that you might with a low-level debug facility like JTAG |
41 | .min_access_size = 1, | 38 | +on real hardware. You can stop and start the virtual machine, |
42 | .max_access_size = 4 | 39 | +examine state like registers and memory, and set breakpoints and |
40 | +watchpoints. | ||
41 | |||
42 | -In order to use gdb, launch QEMU with the '-s' option. It will wait for | ||
43 | -a gdb connection: | ||
44 | +In order to use gdb, launch QEMU with the ``-s`` and ``-S`` options. | ||
45 | +The ``-s`` option will make QEMU listen for an incoming connection | ||
46 | +from gdb on TCP port 1234, and ``-S`` will make QEMU not start the | ||
47 | +guest until you tell it to from gdb. (If you want to specify which | ||
48 | +TCP port to use or to use something other than TCP for the gdbstub | ||
49 | +connection, use the ``-gdb dev`` option instead of ``-s``.) | ||
50 | |||
51 | .. parsed-literal:: | ||
52 | |||
53 | - |qemu_system| -s -kernel bzImage -hda rootdisk.img -append "root=/dev/hda" | ||
54 | - Connected to host network interface: tun0 | ||
55 | - Waiting gdb connection on port 1234 | ||
56 | + |qemu_system| -s -S -kernel bzImage -hda rootdisk.img -append "root=/dev/hda" | ||
57 | + | ||
58 | +QEMU will launch but will silently wait for gdb to connect. | ||
59 | |||
60 | Then launch gdb on the 'vmlinux' executable:: | ||
61 | |||
62 | diff --git a/qemu-options.hx b/qemu-options.hx | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/qemu-options.hx | ||
65 | +++ b/qemu-options.hx | ||
66 | @@ -XXX,XX +XXX,XX @@ SRST | ||
67 | ERST | ||
68 | |||
69 | DEF("gdb", HAS_ARG, QEMU_OPTION_gdb, \ | ||
70 | - "-gdb dev wait for gdb connection on 'dev'\n", QEMU_ARCH_ALL) | ||
71 | + "-gdb dev accept gdb connection on 'dev'. (QEMU defaults to starting\n" | ||
72 | + " the guest without waiting for gdb to connect; use -S too\n" | ||
73 | + " if you want it to not start execution.)\n", | ||
74 | + QEMU_ARCH_ALL) | ||
75 | SRST | ||
76 | ``-gdb dev`` | ||
77 | - Wait for gdb connection on device dev (see | ||
78 | - :ref:`gdb_005fusage`). Typical connections will likely be | ||
79 | - TCP-based, but also UDP, pseudo TTY, or even stdio are reasonable | ||
80 | - use case. The latter is allowing to start QEMU from within gdb and | ||
81 | - establish the connection via a pipe: | ||
82 | + Accept a gdb connection on device dev (see | ||
83 | + :ref:`gdb_005fusage`). Note that this option does not pause QEMU | ||
84 | + execution -- if you want QEMU to not start the guest until you | ||
85 | + connect with gdb and issue a ``continue`` command, you will need to | ||
86 | + also pass the ``-S`` option to QEMU. | ||
87 | + | ||
88 | + The most usual configuration is to listen on a local TCP socket:: | ||
89 | + | ||
90 | + -gdb tcp::3117 | ||
91 | + | ||
92 | + but you can specify other backends; UDP, pseudo TTY, or even stdio | ||
93 | + are all reasonable use cases. For example, a stdio connection | ||
94 | + allows you to start QEMU from within gdb and establish the | ||
95 | + connection via a pipe: | ||
96 | |||
97 | .. parsed-literal:: | ||
98 | |||
43 | -- | 99 | -- |
44 | 2.20.1 | 100 | 2.20.1 |
45 | 101 | ||
46 | 102 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | If we are not making warnings fatal for compilation, make them |
---|---|---|---|
2 | non-fatal when building the Sphinx documentation also. (For instance | ||
3 | Sphinx 3.0 warns about some constructs that older versions were happy | ||
4 | with, which is a build failure if we use the warnings-as-errors | ||
5 | flag.) | ||
2 | 6 | ||
3 | Lei Sun found while auditing the code that a CPU write would | 7 | This provides a workaround at least for LP:1872113. |
4 | trigger a NULL pointer dereference. | ||
5 | 8 | ||
6 | >From UG1085 datasheet [*] AXI writes in this region are ignored | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | and generates an AXI Slave Error (SLVERR). | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20200411182934.28678-2-peter.maydell@linaro.org | ||
12 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
13 | --- | ||
14 | configure | 9 ++++++++- | ||
15 | Makefile | 2 +- | ||
16 | 2 files changed, 9 insertions(+), 2 deletions(-) | ||
8 | 17 | ||
9 | Fix by implementing the write_with_attrs() handler. | 18 | diff --git a/configure b/configure |
10 | Return MEMTX_ERROR when the region is accessed (this error maps | 19 | index XXXXXXX..XXXXXXX 100755 |
11 | to an AXI slave error). | 20 | --- a/configure |
12 | 21 | +++ b/configure | |
13 | [*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf | 22 | @@ -XXX,XX +XXX,XX @@ if check_include sys/kcov.h ; then |
14 | 23 | kcov=yes | |
15 | Reported-by: Lei Sun <slei.casper@gmail.com> | 24 | fi |
16 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 25 | |
17 | Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 26 | +# If we're making warnings fatal, apply this to Sphinx runs as well |
18 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 27 | +sphinx_werror="" |
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | +if test "$werror" = "yes"; then |
20 | --- | 29 | + sphinx_werror="-W" |
21 | hw/ssi/xilinx_spips.c | 16 ++++++++++++++++ | 30 | +fi |
22 | 1 file changed, 16 insertions(+) | 31 | + |
23 | 32 | # Check we have a new enough version of sphinx-build | |
24 | diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c | 33 | has_sphinx_build() { |
34 | # This is a bit awkward but works: create a trivial document and | ||
35 | @@ -XXX,XX +XXX,XX @@ has_sphinx_build() { | ||
36 | # sphinx-build doesn't exist at all or if it is too old. | ||
37 | mkdir -p "$TMPDIR1/sphinx" | ||
38 | touch "$TMPDIR1/sphinx/index.rst" | ||
39 | - "$sphinx_build" -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1 | ||
40 | + "$sphinx_build" $sphinx_werror -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1 | ||
41 | } | ||
42 | |||
43 | # Check if tools are available to build documentation. | ||
44 | @@ -XXX,XX +XXX,XX @@ echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak | ||
45 | echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak | ||
46 | echo "PYTHON=$python" >> $config_host_mak | ||
47 | echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak | ||
48 | +echo "SPHINX_WERROR=$sphinx_werror" >> $config_host_mak | ||
49 | echo "GENISOIMAGE=$genisoimage" >> $config_host_mak | ||
50 | echo "CC=$cc" >> $config_host_mak | ||
51 | if $iasl -h > /dev/null 2>&1; then | ||
52 | diff --git a/Makefile b/Makefile | ||
25 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/ssi/xilinx_spips.c | 54 | --- a/Makefile |
27 | +++ b/hw/ssi/xilinx_spips.c | 55 | +++ b/Makefile |
28 | @@ -XXX,XX +XXX,XX @@ static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value, | 56 | @@ -XXX,XX +XXX,XX @@ sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \ |
29 | return lqspi_read(opaque, addr, value, size, attrs); | 57 | # Note the use of different doctree for each (manual, builder) tuple; |
30 | } | 58 | # this works around Sphinx not handling parallel invocation on |
31 | 59 | # a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946 | |
32 | +static MemTxResult lqspi_write(void *opaque, hwaddr offset, uint64_t value, | 60 | -build-manual = $(call quiet-command,CONFDIR="$(qemu_confdir)" $(SPHINX_BUILD) $(if $(V),,-q) -W -b $2 -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1-$2 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1") |
33 | + unsigned size, MemTxAttrs attrs) | 61 | +build-manual = $(call quiet-command,CONFDIR="$(qemu_confdir)" $(SPHINX_BUILD) $(if $(V),,-q) $(SPHINX_WERROR) -b $2 -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1-$2 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1") |
34 | +{ | 62 | # We assume all RST files in the manual's directory are used in it |
35 | + /* | 63 | manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst $(SRC_PATH)/docs/$1/*/*.rst) \ |
36 | + * From UG1085, Chapter 24 (Quad-SPI controllers): | 64 | $(SRC_PATH)/docs/defs.rst.inc \ |
37 | + * - Writes are ignored | ||
38 | + * - AXI writes generate an external AXI slave error (SLVERR) | ||
39 | + */ | ||
40 | + qemu_log_mask(LOG_GUEST_ERROR, "%s Unexpected %u-bit access to 0x%" PRIx64 | ||
41 | + " (value: 0x%" PRIx64 "\n", | ||
42 | + __func__, size << 3, offset, value); | ||
43 | + | ||
44 | + return MEMTX_ERROR; | ||
45 | +} | ||
46 | + | ||
47 | static const MemoryRegionOps lqspi_ops = { | ||
48 | .read_with_attrs = lqspi_read, | ||
49 | + .write_with_attrs = lqspi_write, | ||
50 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
51 | .valid = { | ||
52 | .min_access_size = 1, | ||
53 | -- | 65 | -- |
54 | 2.20.1 | 66 | 2.20.1 |
55 | 67 | ||
56 | 68 | diff view generated by jsdifflib |
1 | The ARMv5 architecture didn't specify detailed per-feature ID | 1 | When kernel-doc generates a 'c:function' directive for a function |
---|---|---|---|
2 | registers. Now that we're using the MVFR0 register fields to | 2 | one of whose arguments is a function pointer, it fails to print |
3 | gate the existence of VFP instructions, we need to set up | 3 | the close-paren after the argument list of the function pointer |
4 | the correct values in the cpu->isar structure so that we still | 4 | argument, for instance in the memory API documentation: |
5 | provide an FPU to the guest. | 5 | .. c:function:: void memory_region_init_resizeable_ram (MemoryRegion * mr, struct Object * owner, const char * name, uint64_t size, uint64_t max_size, void (*resized) (const char*, uint64_t length, void *host, Error ** errp) |
6 | 6 | ||
7 | This fixes a regression in the arm926 and arm1026 CPUs, which | 7 | which should have a ')' after the 'void *host' which is the |
8 | are the only ones that both have VFP and are ARMv5 or earlier. | 8 | last argument to 'resized'. |
9 | This regression was introduced by the VFP refactoring, and more | ||
10 | specifically by commits 1120827fa182f0e76 and 266bd25c485597c, | ||
11 | which accidentally disabled VFP short-vector support and | ||
12 | double-precision support on these CPUs. | ||
13 | 9 | ||
14 | Fixes: 1120827fa182f0e | 10 | Older versions of Sphinx don't try to parse the argumnet |
15 | Fixes: 266bd25c485597c | 11 | to c:function, but Sphinx 3.0 does do this and will complain: |
16 | Fixes: https://bugs.launchpad.net/qemu/+bug/1836192 | 12 | |
17 | Reported-by: Christophe Lyon <christophe.lyon@linaro.org> | 13 | /home/petmay01/linaro/qemu-from-laptop/qemu/docs/../include/exec/memory.h:834: WARNING: Error in declarator or parameters |
14 | Invalid C declaration: Expecting "," or ")" in parameters, got "EOF". [error at 208] | ||
15 | void memory_region_init_resizeable_ram (MemoryRegion * mr, struct Object * owner, const char * name, uint64_t size, uint64_t max_size, void (*resized) (const char*, uint64_t length, void *host, Error ** errp) | ||
16 | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^ | ||
17 | |||
18 | Add the missing close-paren. | ||
19 | |||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
22 | Message-id: 20200411182934.28678-3-peter.maydell@linaro.org | ||
20 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 23 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
21 | Tested-by: Christophe Lyon <christophe.lyon@linaro.org> | ||
22 | Message-id: 20190711131241.22231-1-peter.maydell@linaro.org | ||
23 | --- | 24 | --- |
24 | target/arm/cpu.c | 12 ++++++++++++ | 25 | scripts/kernel-doc | 2 +- |
25 | 1 file changed, 12 insertions(+) | 26 | 1 file changed, 1 insertion(+), 1 deletion(-) |
26 | 27 | ||
27 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 28 | diff --git a/scripts/kernel-doc b/scripts/kernel-doc |
28 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100755 |
29 | --- a/target/arm/cpu.c | 30 | --- a/scripts/kernel-doc |
30 | +++ b/target/arm/cpu.c | 31 | +++ b/scripts/kernel-doc |
31 | @@ -XXX,XX +XXX,XX @@ static void arm926_initfn(Object *obj) | 32 | @@ -XXX,XX +XXX,XX @@ sub output_function_rst(%) { |
32 | * set the field to indicate Jazelle support within QEMU. | 33 | |
33 | */ | 34 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
34 | cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | 35 | # pointer-to-function |
35 | + /* | 36 | - print $1 . $parameter . ") (" . $2; |
36 | + * Similarly, we need to set MVFR0 fields to enable double precision | 37 | + print $1 . $parameter . ") (" . $2 . ")"; |
37 | + * and short vector support even though ARMv5 doesn't have this register. | 38 | } else { |
38 | + */ | 39 | print $type . " " . $parameter; |
39 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | 40 | } |
40 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); | ||
41 | } | ||
42 | |||
43 | static void arm946_initfn(Object *obj) | ||
44 | @@ -XXX,XX +XXX,XX @@ static void arm1026_initfn(Object *obj) | ||
45 | * set the field to indicate Jazelle support within QEMU. | ||
46 | */ | ||
47 | cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | ||
48 | + /* | ||
49 | + * Similarly, we need to set MVFR0 fields to enable double precision | ||
50 | + * and short vector support even though ARMv5 doesn't have this register. | ||
51 | + */ | ||
52 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
53 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); | ||
54 | |||
55 | { | ||
56 | /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */ | ||
57 | -- | 41 | -- |
58 | 2.20.1 | 42 | 2.20.1 |
59 | 43 | ||
60 | 44 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | The kernel-doc Sphinx plugin and associated script currently emit |
---|---|---|---|
2 | 'c:type' directives for "struct foo" documentation. | ||
2 | 3 | ||
3 | When we converted to using feature bits in 602f6e42cfbf we missed out | 4 | Sphinx 3.0 warns about this: |
4 | the fact (dp && arm_dc_feature(s, ARM_FEATURE_V8)) was supported for | 5 | /home/petmay01/linaro/qemu-from-laptop/qemu/docs/../include/exec/memory.h:3: WARNING: Type must be either just a name or a typedef-like declaration. |
5 | -cpu max configurations. This caused a regression in the GCC test | 6 | If just a name: |
6 | suite. Fix this by setting the appropriate bits in mvfr1.FPHP to | 7 | Error in declarator or parameters |
7 | report ARMv8-A with FP support (but not ARMv8.2-FP16). | 8 | Invalid C declaration: Expected identifier in nested name, got keyword: struct [error at 6] |
9 | struct MemoryListener | ||
10 | ------^ | ||
11 | If typedef-like declaration: | ||
12 | Error in declarator or parameters | ||
13 | Invalid C declaration: Expected identifier in nested name. [error at 21] | ||
14 | struct MemoryListener | ||
15 | ---------------------^ | ||
8 | 16 | ||
9 | Fixes: https://bugs.launchpad.net/qemu/+bug/1836078 | 17 | because it wants us to use the new-in-3.0 'c:struct' instead. |
10 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 18 | |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 19 | Plumb the Sphinx version through to the kernel-doc script |
12 | Message-id: 20190711103737.10017-1-alex.bennee@linaro.org | 20 | and use it to select 'c:struct' for newer versions than 3.0. |
21 | |||
22 | Fixes: LP:1872113 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | --- | 25 | --- |
15 | target/arm/cpu.c | 4 ++++ | 26 | docs/sphinx/kerneldoc.py | 1 + |
16 | 1 file changed, 4 insertions(+) | 27 | scripts/kernel-doc | 16 +++++++++++++++- |
28 | 2 files changed, 16 insertions(+), 1 deletion(-) | ||
17 | 29 | ||
18 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 30 | diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py |
19 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/cpu.c | 32 | --- a/docs/sphinx/kerneldoc.py |
21 | +++ b/target/arm/cpu.c | 33 | +++ b/docs/sphinx/kerneldoc.py |
22 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | 34 | @@ -XXX,XX +XXX,XX @@ class KernelDocDirective(Directive): |
23 | t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | 35 | env.note_dependency(os.path.abspath(f)) |
24 | cpu->isar.id_isar6 = t; | 36 | cmd += ['-export-file', f] |
25 | 37 | ||
26 | + t = cpu->isar.mvfr1; | 38 | + cmd += ['-sphinx-version', sphinx.__version__] |
27 | + t = FIELD_DP32(t, MVFR1, FPHP, 2); /* v8.0 FP support */ | 39 | cmd += [filename] |
28 | + cpu->isar.mvfr1 = t; | 40 | |
29 | + | 41 | try: |
30 | t = cpu->isar.mvfr2; | 42 | diff --git a/scripts/kernel-doc b/scripts/kernel-doc |
31 | t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | 43 | index XXXXXXX..XXXXXXX 100755 |
32 | t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | 44 | --- a/scripts/kernel-doc |
45 | +++ b/scripts/kernel-doc | ||
46 | @@ -XXX,XX +XXX,XX @@ Output selection (mutually exclusive): | ||
47 | DOC: sections. May be specified multiple times. | ||
48 | |||
49 | Output selection modifiers: | ||
50 | + -sphinx-version VER Generate rST syntax for the specified Sphinx version. | ||
51 | + Only works with reStructuredTextFormat. | ||
52 | -no-doc-sections Do not output DOC: sections. | ||
53 | -enable-lineno Enable output of #define LINENO lines. Only works with | ||
54 | reStructuredText format. | ||
55 | @@ -XXX,XX +XXX,XX @@ use constant { | ||
56 | }; | ||
57 | my $output_selection = OUTPUT_ALL; | ||
58 | my $show_not_found = 0; # No longer used | ||
59 | +my $sphinx_version = "0.0"; # if not specified, assume old | ||
60 | |||
61 | my @export_file_list; | ||
62 | |||
63 | @@ -XXX,XX +XXX,XX @@ while ($ARGV[0] =~ m/^--?(.*)/) { | ||
64 | $enable_lineno = 1; | ||
65 | } elsif ($cmd eq 'show-not-found') { | ||
66 | $show_not_found = 1; # A no-op but don't fail | ||
67 | + } elsif ($cmd eq 'sphinx-version') { | ||
68 | + $sphinx_version = shift @ARGV; | ||
69 | } else { | ||
70 | # Unknown argument | ||
71 | usage(); | ||
72 | @@ -XXX,XX +XXX,XX @@ sub output_struct_rst(%) { | ||
73 | my $oldprefix = $lineprefix; | ||
74 | my $name = $args{'type'} . " " . $args{'struct'}; | ||
75 | |||
76 | - print "\n\n.. c:type:: " . $name . "\n\n"; | ||
77 | + # Sphinx 3.0 and up will emit warnings for "c:type:: struct Foo". | ||
78 | + # It wants to see "c:struct:: Foo" (and will add the word 'struct' in | ||
79 | + # the rendered output). | ||
80 | + if ((split(/\./, $sphinx_version))[0] >= 3) { | ||
81 | + my $sname = $name; | ||
82 | + $sname =~ s/^struct //; | ||
83 | + print "\n\n.. c:struct:: " . $sname . "\n\n"; | ||
84 | + } else { | ||
85 | + print "\n\n.. c:type:: " . $name . "\n\n"; | ||
86 | + } | ||
87 | print_lineno($declaration_start_line); | ||
88 | $lineprefix = " "; | ||
89 | output_highlight_rst($args{'purpose'}); | ||
33 | -- | 90 | -- |
34 | 2.20.1 | 91 | 2.20.1 |
35 | 92 | ||
36 | 93 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Versions of Sphinx older than 1.6 can't build all of our documentation, |
---|---|---|---|
2 | because they are too picky about the syntax of the argument to the | ||
3 | option:: directive; see Sphinx bugs #646, #3366: | ||
2 | 4 | ||
3 | In the next commit we will implement the write_with_attrs() | 5 | https://github.com/sphinx-doc/sphinx/issues/646 |
4 | handler. To avoid using different APIs, convert the read() | 6 | https://github.com/sphinx-doc/sphinx/issues/3366 |
5 | handler first. | ||
6 | 7 | ||
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 8 | Trying to build with a 1.4.x Sphinx fails with |
8 | Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 9 | docs/system/images.rst:4: SEVERE: Duplicate ID: "cmdoption-qcow2-arg-encrypt" |
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 10 | and a 1.5.x Sphinx fails with |
11 | docs/system/invocation.rst:544: WARNING: Malformed option description '[enable=]PATTERN', should look like "opt", "-opt | ||
12 | args", "--opt args", "/opt args" or "+opt args" | ||
13 | |||
14 | Update our needs_sphinx setting to indicate that we require at least | ||
15 | 1.6. This will allow configure to fall back to "don't build the | ||
16 | docs" rather than causing the build to fail entirely, which is | ||
17 | probably what most users building on a host old enough to have such | ||
18 | an old Sphinx would want; if they do want the docs then they'll have | ||
19 | a useful indication of what they need to do (upgrade Sphinx!) rather | ||
20 | than a confusing error message. | ||
21 | |||
22 | In theory our distro support policy would suggest that we should | ||
23 | support building on the Sphinx shipped in those distros, but: | ||
24 | * EPEL7 has Sphinx 1.2.3 (which we've never supported!) | ||
25 | * Debian Stretch has Sphinx 1.4.8 | ||
26 | |||
27 | Trying to get our docs to work with Sphinx 1.4 is not tractable | ||
28 | for the 5.0 release and I'm not sure it's worthwhile effort anyway; | ||
29 | at least with this change the build as a whole now succeeds. | ||
30 | |||
31 | Thanks to John Snow for doing the investigation and testing to | ||
32 | confirm what Sphinx versions fail in what ways and what distros | ||
33 | shipped what. | ||
34 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
36 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | 37 | --- |
12 | hw/ssi/xilinx_spips.c | 23 +++++++++++------------ | 38 | docs/conf.py | 6 ++++-- |
13 | 1 file changed, 11 insertions(+), 12 deletions(-) | 39 | 1 file changed, 4 insertions(+), 2 deletions(-) |
14 | 40 | ||
15 | diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c | 41 | diff --git a/docs/conf.py b/docs/conf.py |
16 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/ssi/xilinx_spips.c | 43 | --- a/docs/conf.py |
18 | +++ b/hw/ssi/xilinx_spips.c | 44 | +++ b/docs/conf.py |
19 | @@ -XXX,XX +XXX,XX @@ static void lqspi_load_cache(void *opaque, hwaddr addr) | 45 | @@ -XXX,XX +XXX,XX @@ sys.path.insert(0, os.path.join(qemu_docdir, "sphinx")) |
20 | } | 46 | |
21 | } | 47 | # If your documentation needs a minimal Sphinx version, state it here. |
22 | 48 | # | |
23 | -static uint64_t | 49 | -# 1.3 is where the 'alabaster' theme was shipped with Sphinx. |
24 | -lqspi_read(void *opaque, hwaddr addr, unsigned int size) | 50 | -needs_sphinx = '1.3' |
25 | +static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value, | 51 | +# Sphinx 1.5 and earlier can't build our docs because they are too |
26 | + unsigned size, MemTxAttrs attrs) | 52 | +# picky about the syntax of the argument to the option:: directive |
27 | { | 53 | +# (see Sphinx bugs #646, #3366). |
28 | - XilinxQSPIPS *q = opaque; | 54 | +needs_sphinx = '1.6' |
29 | - uint32_t ret; | 55 | |
30 | + XilinxQSPIPS *q = XILINX_QSPIPS(opaque); | 56 | # Add any Sphinx extension module names here, as strings. They can be |
31 | 57 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | |
32 | if (addr >= q->lqspi_cached_addr && | ||
33 | addr <= q->lqspi_cached_addr + LQSPI_CACHE_SIZE - 4) { | ||
34 | uint8_t *retp = &q->lqspi_buf[addr - q->lqspi_cached_addr]; | ||
35 | - ret = cpu_to_le32(*(uint32_t *)retp); | ||
36 | - DB_PRINT_L(1, "addr: %08x, data: %08x\n", (unsigned)addr, | ||
37 | - (unsigned)ret); | ||
38 | - return ret; | ||
39 | - } else { | ||
40 | - lqspi_load_cache(opaque, addr); | ||
41 | - return lqspi_read(opaque, addr, size); | ||
42 | + *value = cpu_to_le32(*(uint32_t *)retp); | ||
43 | + DB_PRINT_L(1, "addr: %08" HWADDR_PRIx ", data: %08" PRIx64 "\n", | ||
44 | + addr, *value); | ||
45 | + return MEMTX_OK; | ||
46 | } | ||
47 | + | ||
48 | + lqspi_load_cache(opaque, addr); | ||
49 | + return lqspi_read(opaque, addr, value, size, attrs); | ||
50 | } | ||
51 | |||
52 | static const MemoryRegionOps lqspi_ops = { | ||
53 | - .read = lqspi_read, | ||
54 | + .read_with_attrs = lqspi_read, | ||
55 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
56 | .valid = { | ||
57 | .min_access_size = 1, | ||
58 | -- | 58 | -- |
59 | 2.20.1 | 59 | 2.20.1 |
60 | 60 | ||
61 | 61 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | The Linux kernel has dropped support for allowing 32-bit Arm systems |
---|---|---|---|
2 | to host KVM guests (kernel commit 541ad0150ca4aa663a2, which just | ||
3 | landed upstream in the 5.7 merge window). Mark QEMU's support for | ||
4 | this configuration as deprecated, so that we can delete that support | ||
5 | code in 5.2. | ||
2 | 6 | ||
3 | In the previous commit we fixed a crash when the guest read a | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | register that pop from an empty FIFO. | 8 | Reviewed-by: Andrew Jones <drjones@redhat.com> |
5 | By auditing the repository, we found another similar use with | 9 | --- |
6 | an easy way to reproduce: | 10 | docs/system/deprecated.rst | 8 ++++++++ |
11 | 1 file changed, 8 insertions(+) | ||
7 | 12 | ||
8 | $ qemu-system-aarch64 -M xlnx-zcu102 -monitor stdio -S | 13 | diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst |
9 | QEMU 4.0.50 monitor - type 'help' for more information | ||
10 | (qemu) xp/b 0xfd4a0134 | ||
11 | Aborted (core dumped) | ||
12 | |||
13 | (gdb) bt | ||
14 | #0 0x00007f6936dea57f in raise () at /lib64/libc.so.6 | ||
15 | #1 0x00007f6936dd4895 in abort () at /lib64/libc.so.6 | ||
16 | #2 0x0000561ad32975ec in xlnx_dp_aux_pop_rx_fifo (s=0x7f692babee70) at hw/display/xlnx_dp.c:431 | ||
17 | #3 0x0000561ad3297dc0 in xlnx_dp_read (opaque=0x7f692babee70, offset=77, size=4) at hw/display/xlnx_dp.c:667 | ||
18 | #4 0x0000561ad321b896 in memory_region_read_accessor (mr=0x7f692babf620, addr=308, value=0x7ffe05c1db88, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:439 | ||
19 | #5 0x0000561ad321bd70 in access_with_adjusted_size (addr=308, value=0x7ffe05c1db88, size=1, access_size_min=4, access_size_max=4, access_fn=0x561ad321b858 <memory_region_read_accessor>, mr=0x7f692babf620, attrs=...) at memory.c:569 | ||
20 | #6 0x0000561ad321e9d5 in memory_region_dispatch_read1 (mr=0x7f692babf620, addr=308, pval=0x7ffe05c1db88, size=1, attrs=...) at memory.c:1420 | ||
21 | #7 0x0000561ad321ea9d in memory_region_dispatch_read (mr=0x7f692babf620, addr=308, pval=0x7ffe05c1db88, size=1, attrs=...) at memory.c:1447 | ||
22 | #8 0x0000561ad31bd742 in flatview_read_continue (fv=0x561ad69c04f0, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1, addr1=308, l=1, mr=0x7f692babf620) at exec.c:3385 | ||
23 | #9 0x0000561ad31bd895 in flatview_read (fv=0x561ad69c04f0, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1) at exec.c:3423 | ||
24 | #10 0x0000561ad31bd90b in address_space_read_full (as=0x561ad5bb3020, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1) at exec.c:3436 | ||
25 | #11 0x0000561ad33b1c42 in address_space_read (len=1, buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", attrs=..., addr=4249485620, as=0x561ad5bb3020) at include/exec/memory.h:2131 | ||
26 | #12 0x0000561ad33b1c42 in memory_dump (mon=0x561ad59c4530, count=1, format=120, wsize=1, addr=4249485620, is_physical=1) at monitor/misc.c:723 | ||
27 | #13 0x0000561ad33b1fc1 in hmp_physical_memory_dump (mon=0x561ad59c4530, qdict=0x561ad6c6fd00) at monitor/misc.c:795 | ||
28 | #14 0x0000561ad37b4a9f in handle_hmp_command (mon=0x561ad59c4530, cmdline=0x561ad59d0f22 "/b 0x00000000fd4a0134") at monitor/hmp.c:1082 | ||
29 | |||
30 | Fix by checking the FIFO is not empty before popping from it. | ||
31 | |||
32 | The datasheet is not clear about the reset value of this register, | ||
33 | we choose to return '0'. | ||
34 | |||
35 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
36 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
37 | Message-id: 20190709113715.7761-4-philmd@redhat.com | ||
38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
39 | --- | ||
40 | hw/display/xlnx_dp.c | 15 +++++++++++---- | ||
41 | 1 file changed, 11 insertions(+), 4 deletions(-) | ||
42 | |||
43 | diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/hw/display/xlnx_dp.c | 15 | --- a/docs/system/deprecated.rst |
46 | +++ b/hw/display/xlnx_dp.c | 16 | +++ b/docs/system/deprecated.rst |
47 | @@ -XXX,XX +XXX,XX @@ static uint8_t xlnx_dp_aux_pop_rx_fifo(XlnxDPState *s) | 17 | @@ -XXX,XX +XXX,XX @@ The ``compat`` property used to set backwards compatibility modes for |
48 | uint8_t ret; | 18 | the processor has been deprecated. The ``max-cpu-compat`` property of |
49 | 19 | the ``pseries`` machine type should be used instead. | |
50 | if (fifo8_is_empty(&s->rx_fifo)) { | 20 | |
51 | - DPRINTF("rx_fifo underflow..\n"); | 21 | +KVM guest support on 32-bit Arm hosts (since 5.0) |
52 | - abort(); | 22 | +''''''''''''''''''''''''''''''''''''''''''''''''' |
53 | + qemu_log_mask(LOG_GUEST_ERROR, | 23 | + |
54 | + "%s: Reading empty RX_FIFO\n", | 24 | +The Linux kernel has dropped support for allowing 32-bit Arm systems |
55 | + __func__); | 25 | +to host KVM guests as of the 5.7 kernel. Accordingly, QEMU is deprecating |
56 | + /* | 26 | +its support for this configuration and will remove it in a future version. |
57 | + * The datasheet is not clear about the reset value, it seems | 27 | +Running 32-bit guests on a 64-bit Arm host remains supported. |
58 | + * to be unspecified. We choose to return '0'. | 28 | + |
59 | + */ | 29 | System emulator devices |
60 | + ret = 0; | 30 | ----------------------- |
61 | + } else { | ||
62 | + ret = fifo8_pop(&s->rx_fifo); | ||
63 | + DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret); | ||
64 | } | ||
65 | - ret = fifo8_pop(&s->rx_fifo); | ||
66 | - DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret); | ||
67 | return ret; | ||
68 | } | ||
69 | 31 | ||
70 | -- | 32 | -- |
71 | 2.20.1 | 33 | 2.20.1 |
72 | 34 | ||
73 | 35 | diff view generated by jsdifflib |