Skip to contentSkip to conversation

fix corruption in qla1280

PATCH Arjan van de Ven 2 participants 3 messages Jul 14, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

In C, doing >> 32 on a 32 bit wide variable is undefined behavior, and the code that gets generated by gcc (using the cpu shr) effectively means that it's a nop. The patch below to qla1280.c fixes such a case, doing

Quoted 1 line
Quoted 1 line

16 twice looks more expensive but gcc optimizes it out while keeping

correct behavior.

Greetings,
Arjan van de Ven

drivers/scsi/qla1280.c renamed from drivers/scsi/qla1280.c~ +1 -1
@@ -327,7 +327,7 @@
 /* 3.16 */
 #ifdef QLA_64BIT_PTR
 #define pci_dma_lo32(a)		(a & 0xffffffff)
-#define pci_dma_hi32(a)		(a >> 32)
+#define pci_dma_hi32(a)		((a >> 16)>>16)
 #else
 #define pci_dma_lo32(a)		(a & 0xffffffff)
 #define pci_dma_hi32(a)		0
#1 lore raw

Arjan,

Quoted 5 lines · Arjan van de Ven

In C, doing >> 32 on a 32 bit wide variable is undefined behavior, and the code that gets generated by gcc (using the cpu shr) effectively means that it's a nop. The patch below to qla1280.c fixes such a case, doing

Quoted 1 line
Quoted 1 line

16 twice looks more expensive but gcc optimizes it out while keeping

correct behavior.

If it's really a 32 bit variable,
#define pci_dma_hi32(a) (0)
would be correct. Shifting a 32bit value 32times to the right is just 0. What do I miss?

Regards,

Signature · 3 lines
Kurt Garloff  <[email protected]>                          Eindhoven, NL
GPG key: See mail header, key servers                 SuSE Labs (Head)
SuSE Linux AG, Nuernberg, DE                            SCSI, Security
#2 lore raw
Quoted 6 lines · Kurt Garloff

Arjan,

Quoted 3 lines · Arjan van de Ven

In C, doing >> 32 on a 32 bit wide variable is undefined behavior, and the code that gets generated by gcc (using the cpu shr) effectively means that it's a nop. The patch below to qla1280.c fixes such a case, doing

Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

16 twice looks more expensive but gcc optimizes it out while keeping

correct behavior.

If it's really a 32 bit variable,
#define pci_dma_hi32(a) (0)
would be correct. Shifting a 32bit value 32times to the right is just 0. What do I miss?

it's only a 32 bit variable on 32 bit platforms
(or rather, when dma_addr_t is 32 bit.. the ifdefs for that get evil)