freebsd-dev/sys/x86/xen
Dimitry Andric 8e3c56d6b6 xen: Fix warning by adding KERNBASE to modlist_paddr before casting
Clang 13 produces the following warning for hammer_time_xen():

sys/x86/xen/pv.c:183:19: error: the pointer incremented by -2147483648 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements) [-Werror,-Warray-bounds]
                    (vm_paddr_t)start_info->modlist_paddr + KERNBASE;
                                ^                               ~~~~~~~~
sys/xen/interface/arch-x86/hvm/start_info.h:131:5: note: array 'modlist_paddr' declared here
    uint64_t modlist_paddr;         /* Physical address of an array of           */
    ^

This is because the expression first casts start_info->modlist_paddr to
struct hvm_modlist_entry * (via vmpaddr_t), and *then* adds KERNBASE,
which is then interpreted as KERNBASE * sizeof(struct
hvm_modlist_entry).

Instead, parenthesize the addition to get the intended result, and cast
it to struct hvm_modlist_entry * afterwards. Also remove the cast to
vmpaddr_t since it is not necessary.

Reviewed by:	royger
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D31711
2021-08-29 19:43:00 +02:00
..
hvm.c xen: remove hypervisor_info 2021-05-17 10:56:52 +02:00
pv.c xen: Fix warning by adding KERNBASE to modlist_paddr before casting 2021-08-29 19:43:00 +02:00
xen_apic.c x86: clean up empty lines in .c and .h files 2020-09-01 21:23:59 +00:00
xen_intr.c xen: introduce xen_has_percpu_evtchn() 2021-07-28 17:27:05 +02:00