* [Qemu-devel] [PATCH] block.h: Make BDRV_SECTOR_SIZE 64 bit safe
@ 2010-05-27 13:46 Jes.Sorensen
2010-05-27 14:27 ` Kevin Wolf
0 siblings, 1 reply; 6+ messages in thread
From: Jes.Sorensen @ 2010-05-27 13:46 UTC (permalink / raw)
To: anthony; +Cc: Jes Sorensen, qemu-devel
From: Jes Sorensen <Jes.Sorensen@redhat.com>
C defaults to int, so make definition of BDRV_SECTOR_SIZE 64 bit
safe as it and BDRV_SECTOR_MASK may be used against 64 bit addresses.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
block.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/block.h b/block.h
index 24efeb6..5e05612 100644
--- a/block.h
+++ b/block.h
@@ -38,7 +38,7 @@ typedef struct QEMUSnapshotInfo {
#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB)
#define BDRV_SECTOR_BITS 9
-#define BDRV_SECTOR_SIZE (1 << BDRV_SECTOR_BITS)
+#define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS)
#define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1)
typedef enum {
--
1.6.5.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] block.h: Make BDRV_SECTOR_SIZE 64 bit safe
2010-05-27 13:46 [Qemu-devel] [PATCH] block.h: Make BDRV_SECTOR_SIZE 64 bit safe Jes.Sorensen
@ 2010-05-27 14:27 ` Kevin Wolf
2010-05-27 15:38 ` [Qemu-devel] " Paolo Bonzini
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Wolf @ 2010-05-27 14:27 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: qemu-devel
Am 27.05.2010 15:46, schrieb Jes.Sorensen@redhat.com:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> C defaults to int, so make definition of BDRV_SECTOR_SIZE 64 bit
> safe as it and BDRV_SECTOR_MASK may be used against 64 bit addresses.
>
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH] block.h: Make BDRV_SECTOR_SIZE 64 bit safe
2010-05-27 14:27 ` Kevin Wolf
@ 2010-05-27 15:38 ` Paolo Bonzini
2010-05-27 15:44 ` Jes Sorensen
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2010-05-27 15:38 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Jes.Sorensen, qemu-devel
On 05/27/2010 04:27 PM, Kevin Wolf wrote:
> Am 27.05.2010 15:46, schrieb Jes.Sorensen@redhat.com:
>> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>>
>> C defaults to int, so make definition of BDRV_SECTOR_SIZE 64 bit
>> safe as it and BDRV_SECTOR_MASK may be used against 64 bit addresses.
>>
>> Signed-off-by: Jes Sorensen<Jes.Sorensen@redhat.com>
>
> Thanks, applied to the block branch.
Candidate for stable too?
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH] block.h: Make BDRV_SECTOR_SIZE 64 bit safe
2010-05-27 15:38 ` [Qemu-devel] " Paolo Bonzini
@ 2010-05-27 15:44 ` Jes Sorensen
2010-05-28 8:32 ` Paolo Bonzini
0 siblings, 1 reply; 6+ messages in thread
From: Jes Sorensen @ 2010-05-27 15:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Kevin Wolf, qemu-devel
On 05/27/10 17:38, Paolo Bonzini wrote:
> On 05/27/2010 04:27 PM, Kevin Wolf wrote:
>> Am 27.05.2010 15:46, schrieb Jes.Sorensen@redhat.com:
>>> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>>>
>>> C defaults to int, so make definition of BDRV_SECTOR_SIZE 64 bit
>>> safe as it and BDRV_SECTOR_MASK may be used against 64 bit addresses.
>>>
>>> Signed-off-by: Jes Sorensen<Jes.Sorensen@redhat.com>
>>
>> Thanks, applied to the block branch.
>
> Candidate for stable too?
It should be safe to apply, but I didn't find any current users where
the mask was applied in a way where it was causing problems. Not sure if
you want the noise, or apply it as better safe than sorry?
Cheers,
Jes
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH] block.h: Make BDRV_SECTOR_SIZE 64 bit safe
2010-05-27 15:44 ` Jes Sorensen
@ 2010-05-28 8:32 ` Paolo Bonzini
2010-05-28 9:38 ` Jes Sorensen
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2010-05-28 8:32 UTC (permalink / raw)
To: Jes Sorensen; +Cc: Kevin Wolf, qemu-devel
On 05/27/2010 05:44 PM, Jes Sorensen wrote:
> > Candidate for stable too?
> It should be safe to apply, but I didn't find any current users where
> the mask was applied in a way where it was causing problems. Not sure if
> you want the noise, or apply it as better safe than sorry?
The only use in fact is this:
addr = qemu_get_be64(f);
flags = addr & ~BDRV_SECTOR_MASK;
which is safe since the ~~ cancels to give back 511 again. So
nevermind, just asking. If there are no bugs related to it it seems
just as safe not to apply it.
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH] block.h: Make BDRV_SECTOR_SIZE 64 bit safe
2010-05-28 8:32 ` Paolo Bonzini
@ 2010-05-28 9:38 ` Jes Sorensen
0 siblings, 0 replies; 6+ messages in thread
From: Jes Sorensen @ 2010-05-28 9:38 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Kevin Wolf, qemu-devel
On 05/28/10 10:32, Paolo Bonzini wrote:
> On 05/27/2010 05:44 PM, Jes Sorensen wrote:
>> > Candidate for stable too?
>> It should be safe to apply, but I didn't find any current users where
>> the mask was applied in a way where it was causing problems. Not sure if
>> you want the noise, or apply it as better safe than sorry?
>
> The only use in fact is this:
>
> addr = qemu_get_be64(f);
> flags = addr & ~BDRV_SECTOR_MASK;
>
> which is safe since the ~~ cancels to give back 511 again. So
> nevermind, just asking. If there are no bugs related to it it seems
> just as safe not to apply it.
That is correct, which is why I don't think it is necessary for the
stable release. However I want to see the fix in upstream as the macro
is likely to get used for other things in the future and it's a hidden
bug waiting to happen.
Cheers,
Jes
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-05-28 9:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-27 13:46 [Qemu-devel] [PATCH] block.h: Make BDRV_SECTOR_SIZE 64 bit safe Jes.Sorensen
2010-05-27 14:27 ` Kevin Wolf
2010-05-27 15:38 ` [Qemu-devel] " Paolo Bonzini
2010-05-27 15:44 ` Jes Sorensen
2010-05-28 8:32 ` Paolo Bonzini
2010-05-28 9:38 ` Jes Sorensen
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).