* [Qemu-devel] [PATCH] hw/pxa2xx.c: Fix handling of R/WC bits in PMCR
@ 2011-11-09 20:46 Peter Maydell
2011-11-11 19:45 ` Anthony Liguori
0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2011-11-09 20:46 UTC (permalink / raw)
To: qemu-devel; +Cc: patches
Fix a bug in handling the write-one-to-clear bits in the PMCR
which meant that we would always clear the bit even if the
value written was a zero. Spotted by Coverity (see bug 887883).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/pxa2xx.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index bfc28a9..d38b922 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -114,7 +114,9 @@ static void pxa2xx_pm_write(void *opaque, target_phys_addr_t addr,
switch (addr) {
case PMCR:
- s->pm_regs[addr >> 2] &= 0x15 & ~(value & 0x2a);
+ /* Clear the write-one-to-clear bits... */
+ s->pm_regs[addr >> 2] &= ~(value & 0x2a);
+ /* ...and set the plain r/w bits */
s->pm_regs[addr >> 2] |= value & 0x15;
break;
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pxa2xx.c: Fix handling of R/WC bits in PMCR
2011-11-09 20:46 [Qemu-devel] [PATCH] hw/pxa2xx.c: Fix handling of R/WC bits in PMCR Peter Maydell
@ 2011-11-11 19:45 ` Anthony Liguori
2011-11-11 21:05 ` andrzej zaborowski
0 siblings, 1 reply; 4+ messages in thread
From: Anthony Liguori @ 2011-11-11 19:45 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, patches
On 11/09/2011 02:46 PM, Peter Maydell wrote:
> Fix a bug in handling the write-one-to-clear bits in the PMCR
> which meant that we would always clear the bit even if the
> value written was a zero. Spotted by Coverity (see bug 887883).
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> hw/pxa2xx.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
> index bfc28a9..d38b922 100644
> --- a/hw/pxa2xx.c
> +++ b/hw/pxa2xx.c
> @@ -114,7 +114,9 @@ static void pxa2xx_pm_write(void *opaque, target_phys_addr_t addr,
>
> switch (addr) {
> case PMCR:
> - s->pm_regs[addr>> 2]&= 0x15& ~(value& 0x2a);
> + /* Clear the write-one-to-clear bits... */
> + s->pm_regs[addr>> 2]&= ~(value& 0x2a);
> + /* ...and set the plain r/w bits */
> s->pm_regs[addr>> 2] |= value& 0x15;
> break;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pxa2xx.c: Fix handling of R/WC bits in PMCR
2011-11-11 19:45 ` Anthony Liguori
@ 2011-11-11 21:05 ` andrzej zaborowski
2011-11-11 23:20 ` Peter Maydell
0 siblings, 1 reply; 4+ messages in thread
From: andrzej zaborowski @ 2011-11-11 21:05 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Peter Maydell, qemu-devel, patches
Hi,
On 11 November 2011 20:45, Anthony Liguori <anthony@codemonkey.ws> wrote:
> On 11/09/2011 02:46 PM, Peter Maydell wrote:
>>
>> Fix a bug in handling the write-one-to-clear bits in the PMCR
>> which meant that we would always clear the bit even if the
>> value written was a zero. Spotted by Coverity (see bug 887883).
>>
>> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
>
> Applied. Thanks.
>
> Regards,
>
> Anthony Liguori
>
>> ---
>> hw/pxa2xx.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
>> index bfc28a9..d38b922 100644
>> --- a/hw/pxa2xx.c
>> +++ b/hw/pxa2xx.c
>> @@ -114,7 +114,9 @@ static void pxa2xx_pm_write(void *opaque,
>> target_phys_addr_t addr,
>>
>> switch (addr) {
>> case PMCR:
>> - s->pm_regs[addr>> 2]&= 0x15& ~(value& 0x2a);
>> + /* Clear the write-one-to-clear bits... */
>> + s->pm_regs[addr>> 2]&= ~(value& 0x2a);
>> + /* ...and set the plain r/w bits */
>> s->pm_regs[addr>> 2] |= value& 0x15;
As I was about to push these patches also, I noticed this isn't
exactly setting the r/w bits. But it would work if the first line was
(~value) & 0x2a instead, should I fix it this way, am I looking at it
right?
Cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pxa2xx.c: Fix handling of R/WC bits in PMCR
2011-11-11 21:05 ` andrzej zaborowski
@ 2011-11-11 23:20 ` Peter Maydell
0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2011-11-11 23:20 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: qemu-devel, patches
On 11 November 2011 21:05, andrzej zaborowski <balrogg@gmail.com> wrote:
>>> - s->pm_regs[addr>> 2]&= 0x15& ~(value& 0x2a);
>>> + /* Clear the write-one-to-clear bits... */
>>> + s->pm_regs[addr>> 2]&= ~(value& 0x2a);
>>> + /* ...and set the plain r/w bits */
>>> s->pm_regs[addr>> 2] |= value& 0x15;
>
> As I was about to push these patches also, I noticed this isn't
> exactly setting the r/w bits. But it would work if the first line was
> (~value) & 0x2a instead, should I fix it this way, am I looking at it
> right?
Rats, you're right. Your fix works (although it renders the comment wrong
as it's then not just clearing the W1C bits). Alternatively add an
extra line to give:
/* Clear the write-one-to-clear bits... */
s->pm_regs[addr >> 2] &= ~(value & 0x2a);
/* ...and set the plain r/w bits */
s->pm_regs[addr >> 2] &= ~0x15;
s->pm_regs[addr>> 2] |= value & 0x15;
(this is slightly different in effect from your code in that it
leaves register bits [31:5] untouched where yours will always clear
them.) Feel free to do whichever you think is clearest.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-11 23:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-09 20:46 [Qemu-devel] [PATCH] hw/pxa2xx.c: Fix handling of R/WC bits in PMCR Peter Maydell
2011-11-11 19:45 ` Anthony Liguori
2011-11-11 21:05 ` andrzej zaborowski
2011-11-11 23:20 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).