Skip to contentSkip to conversation

target-mips: fix call to memset in soft reset code

PATCH Applied Aurelien Jarno 6 participants 11 messages May 9, 2016 – May 12, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-mips: fix call to memset in soft reset code

Recent versions of GCC report the following error when compiling target-mips/helper.c:

qemu/target-mips/helper.c:542:9: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]

This is indeed correct and due to a wrong usage of sizeof(). Fix that.

Cc: Stefan Weil <[email protected]>
Cc: Leon Alrae <[email protected]>
LP: https://bugs.launchpad.net/qemu/+bug/1577841

---
 target-mips/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-mips/helper.c +1 -1
index 1004ede..cfea177 100644
@@ -539,7 +539,7 @@ void mips_cpu_do_interrupt(CPUState *cs)
         break;
     case EXCP_SRESET:
         env->CP0_Status |= (1 << CP0St_SR);
-        memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo));
+        memset(env->CP0_WatchLo, 0, sizeof(env->CP0_WatchLo));
         goto set_error_EPC;
     case EXCP_NMI:
         env->CP0_Status |= (1 << CP0St_NMI);
Signature · 1 line
2.8.1
Reviewed-by on v1 1/1
#1 lore raw

Am 09.05.2016 um 18:44 schrieb Aurelien Jarno:

Quoted 23 lines

Recent versions of GCC report the following error when compiling target-mips/helper.c:

qemu/target-mips/helper.c:542:9: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]

This is indeed correct and due to a wrong usage of sizeof(). Fix that.

Cc: Stefan Weil <[email protected]>
Cc: Leon Alrae <[email protected]>
LP: https://bugs.launchpad.net/qemu/+bug/1577841

---
 target-mips/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-mips/helper.c +0 -0
index 1004ede..cfea177 100644

target-mips/helper.c void mips_cpu_do_interrupt(CPUState *cs) · line 545

Quoted 8 lines
target-mips/helper.c +1 -1
@@ -539,7 +539,7 @@ void mips_cpu_do_interrupt(CPUState *cs)
         break;
     case EXCP_SRESET:
         env->CP0_Status |= (1 << CP0St_SR);
-        memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo));
+        memset(env->CP0_WatchLo, 0, sizeof(env->CP0_WatchLo));
         goto set_error_EPC;
     case EXCP_NMI:
         env->CP0_Status |= (1 << CP0St_NMI);

I suggest to apply this patch to 2.6, if this is still possible:

* It is a very small modification which fixes a bug.
* It fixes a new build error with recent gcc versions.

The first reason alone would not justify it for 2.6 as this is a rather old bug.

Stefan

#2 lore raw
Quoted 1 line · Stefan Weil

I suggest to apply this patch to 2.6, if this is still possible

It is not; sorry.

thanks
-- PMM

#3 lore raw
Quoted 4 lines · Peter Maydell
Quoted 1 line · Stefan Weil

I suggest to apply this patch to 2.6, if this is still possible

It is not; sorry.

Note that it's only an error if you're building with -Werror, and releases don't default to -Werror, so users using released QEMU 2.6 shouldn't hit this even with the newer gcc. Developers developing on trunk shouldn't be unduly inconvenienced if the commit fixing it is post-2.6-release rather than the actual release.

thanks
-- PMM

#4 lore raw
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Quoted 1 line · Stefan Weil

I suggest to apply this patch to 2.6, if this is still possible

It is not; sorry.

I think we have delayed 2.6 already far too long (so please release) but

Quoted 5 lines

Note that it's only an error if you're building with -Werror, and releases don't default to -Werror, so users using released QEMU 2.6 shouldn't hit this even with the newer gcc. Developers developing on trunk shouldn't be unduly inconvenienced if the commit fixing it is post-2.6-release rather than the actual release.

to me it looks like that this is not a compile time error, instead we really do not memset a variable that we are supposed to memset. the only reason to not consider it for 2.6 is that its is really old and it did not seem to cause harm.

Christian

#5 lore raw
Quoted 9 lines · Christian Borntraeger
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Quoted 1 line · Stefan Weil

I suggest to apply this patch to 2.6, if this is still possible

It is not; sorry.

I think we have delayed 2.6 already far too long (so please release) but

Already done :-)

Quoted 10 lines
Quoted 5 lines

Note that it's only an error if you're building with -Werror, and releases don't default to -Werror, so users using released QEMU 2.6 shouldn't hit this even with the newer gcc. Developers developing on trunk shouldn't be unduly inconvenienced if the commit fixing it is post-2.6-release rather than the actual release.

to me it looks like that this is not a compile time error, instead we really do not memset a variable that we are supposed to memset. the only reason to not consider it for 2.6 is that its is really old and it did not seem to cause harm.

Yes, it is both a code bug and a compile error, but the former has been present for many releases so is not a regression, and the latter is only an error if you're building with -Werror. So in my view it's the kind of bug we'd certainly fix at about rc3 or so, but not a bug which is "release critical showstopper".

thanks
-- PMM

#6 lore raw
Quoted 24 lines · Peter Maydell
Quoted 9 lines · Christian Borntraeger
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Quoted 1 line · Stefan Weil

I suggest to apply this patch to 2.6, if this is still possible

It is not; sorry.

I think we have delayed 2.6 already far too long (so please release) but

Already done :-)

Quoted 10 lines
Quoted 5 lines

Note that it's only an error if you're building with -Werror, and releases don't default to -Werror, so users using released QEMU 2.6 shouldn't hit this even with the newer gcc. Developers developing on trunk shouldn't be unduly inconvenienced if the commit fixing it is post-2.6-release rather than the actual release.

to me it looks like that this is not a compile time error, instead we really do not memset a variable that we are supposed to memset. the only reason to not consider it for 2.6 is that its is really old and it did not seem to cause harm.

Quoted 5 lines

Yes, it is both a code bug and a compile error, but the former has been present for many releases so is not a regression, and the latter is only an error if you're building with -Werror. So in my view it's the kind of bug we'd certainly fix at about rc3 or so, but not a bug which is "release critical showstopper".

Maybe a topic for this years QEMU summit could be to talk about release process and release criterias.

We could
a: allow more patches , e.g. I thing that this patch would be have been taken in the Linux kernel a day before the release, see for example what is applied 4 days before a release as network fixes:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4d8bbbff1227bbb27fdb02b6db17f080c06eedad

22 files changed, 258 insertions, 86 deletions

b: as we are strict and only apply hand selected patches, regressions are very unlikely, so we could release sooner. For example the CVE fixes could have just been taken and rc5 being released as final. (which we did anyway but 3 days later)

c: we consider everything fine and keep the process

d: better ideas

#7 lore raw
Quoted 2 lines · Christian Borntraeger

Maybe a topic for this years QEMU summit could be to talk about release process and release criterias.

Yeah, I'm happy to talk about what we could do better with releases (both on the mailing list and at the summit). A couple of notes:

This time around we had to delay by at least a week because of the timing of the CVEs -- we had to allow a reasonable time before raising the embargo for distros to prepare fixes, and the bugs came in pretty close to when we'd otherwise have done our final rc for the release.

I think one significant difference between us and Linux is that we have fewer people testing our rcs, so I worry that if we put more stuff in then we are less likely to notice bugs in it in time.

The intended purpose of the "few days gap then final release is same as last rc" approach is to give a safety valve in case the patches that went into the final rc had some horrendous bug in them. In this case the last rc only had the CVE fixes so was pretty safe, but in previous releases we've often had a few more patches than that in final-rc. I don't think two extra days before reopening the tree is a very big cost.

thanks
-- PMM

#8 lore raw
In reply to Christian Borntraeger
Quoted 2 lines · On Thu, 12 May 2016 09:40:21 +0200 Christian Borntraeger…

Maybe a topic for this years QEMU summit could be to talk about release process and release criterias.

+1 to that.

Quoted 6 lines

We could
a: allow more patches , e.g. I thing that this patch would be have been taken in the Linux kernel a day before the release, see for example what is applied 4 days before a release as network fixes:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4d8bbbff1227bbb27fdb02b6db17f080c06eedad

22 files changed, 258 insertions, 86 deletions

Personally, I would probably go for something between applying this patch and that networking pull :)

Quoted 8 lines

b: as we are strict and only apply hand selected patches, regressions are very unlikely, so we could release sooner. For example the CVE fixes could have just been taken and rc5 being released as final. (which we did anyway but 3 days later)

c: we consider everything fine and keep the process

d: better ideas

One thing I've noticed is that softfreeze/early hardfreeze qemus often seem more unstable than versions earlier in the development cycle - probably because people panic and rush to get code in for the release. I don't know if stricter rules/enforcement of what is supposed to go in during softfreeze/hardfreeze would help here.

#9 lore raw
Quoted 25 lines · Cornelia Huck
Quoted 2 lines · On Thu, 12 May 2016 09:40:21 +0200 Christian Borntraeger…

Maybe a topic for this years QEMU summit could be to talk about release process and release criterias.

+1 to that.

Quoted 6 lines

We could
a: allow more patches , e.g. I thing that this patch would be have been taken in the Linux kernel a day before the release, see for example what is applied 4 days before a release as network fixes:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4d8bbbff1227bbb27fdb02b6db17f080c06eedad

22 files changed, 258 insertions, 86 deletions

Personally, I would probably go for something between applying this patch and that networking pull :)

Quoted 7 lines

b: as we are strict and only apply hand selected patches, regressions are very unlikely, so we could release sooner. For example the CVE fixes could have just been taken and rc5 being released as final. (which we did anyway but 3 days later)

c: we consider everything fine and keep the process

Quoted 7 lines
Quoted 1 line

d: better ideas

One thing I've noticed is that softfreeze/early hardfreeze qemus often seem more unstable than versions earlier in the development cycle - probably because people panic and rush to get code in for the release. I don't know if stricter rules/enforcement of what is supposed to go in during softfreeze/hardfreeze would help here.

Yes, there are some problems here. But I fully agree with Peter. We really do need more infrastructure and people to
- maintain stable release much more often and for more than one release (that would allow to be less strict before a release)
- have something like qemu-next
- have something like kbuild test robot (aka 0-Day)
- have releases more often (to reduce the pressure to rush in)

Christian

Applied
#10 lore raw
In reply to Aurelien Jarno
Quoted 9 lines · Aurelien Jarno

Recent versions of GCC report the following error when compiling target-mips/helper.c:

qemu/target-mips/helper.c:542:9: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]

This is indeed correct and due to a wrong usage of sizeof(). Fix that.

Quoted 7 lines

Cc: Stefan Weil <[email protected]>
Cc: Leon Alrae <[email protected]>
LP: https://bugs.launchpad.net/qemu/+bug/1577841

---
 target-mips/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to target-mips queue and added Cc: [email protected].

Thanks,
Leon