Cast to pointer type via long to avoid compile
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · Xen patchbot-unstable
[VMXASSIST] Cast to pointer type via long to avoid compile warnings/errors with latest gcc versions.
Signed-off-by Keir Fraser <[email protected]>
Are you sure you don't want these to be unsigned, seeing that the x86-64 kernels have the top bit set for kernel addresses?
Quoted 9 lines
diff -r
5c522692edd1-r1d0e75523636tools/firmware/vmxassist/vm86.ctools/firmware/vmxassist/vm86.c +1
-1@@ -68,7 +68,7 @@ guest_linear_to_real(uint32_t base)return base;if (!(oldctx.cr4 &CR4_PAE )) { - l1_mfn = ((uint32_t *)gcr3)[(base >>22 ) &0x3ff ]; + l1_mfn = ((uint32_t *)(long )gcr3)[(base >>22 ) &0x3ff ];
Signature · 1 line
All Rights Reversed
Quoted 6 lines · Rik van Riel
Quoted 3 lines
[VMXASSIST] Cast to pointer type via long to avoid compile warnings/errors with latest gcc versions.
Signed-off-by Keir Fraser <[email protected]>Are you sure you don't want these to be unsigned, seeing that the x86-64 kernels have the top bit set for kernel addresses?
It's the original type that determines whether sign extension happens, and they are u32 or u64, so there are no sign-extending issues in the type change from u32/u64 to long. 'long' is the same size as a pointer on x86, so no widening/narrowing happens in the final cast to pointer type, so there are also no sign-extending issues in the type change from long to pointer. So the code should be fine as is and avoiding 'unsigned long' means we don't end up wrapping 80 columns or needing extra line breaks.
-- Keir