RE: [EXTERNAL] Re: How to add a -W flag in local Makefile

From: Souradeep Chakrabarti <schakrabarti_at_microsoft.com>
Date: Sat, 20 Apr 2024 12:01:13 UTC

>-----Original Message-----
>From: owner-freebsd-hackers@FreeBSD.org <owner-freebsd-
>hackers@FreeBSD.org> On Behalf Of Dag-Erling Smørgrav
>Sent: Friday, April 19, 2024 4:28 PM
>To: Wei Hu <weh@microsoft.com>
>Cc: Konstantin Belousov <kostikbel@gmail.com>; Warner Losh
><imp@bsdimp.com>; freebsd-hackers@FreeBSD.org
>Subject: [EXTERNAL] Re: How to add a -W flag in local Makefile
>
>Wei Hu <weh@microsoft.com> writes:
>> The same code already exists in Linux and Windows. Linux also added a
>> compiling flag to suppress similar warnings.
>
>That's not an excuse.  The code makes no sense.
The way it works is as follows:

> > +struct hv_vpset {
> > +       uint64_t format;
> > +       uint64_t valid_bank_mask;
> > +       uint64_t bank_contents[];
> > +} __packed;
> > +
> > +struct hv_tlb_flush_ex {
> > +       uint64_t address_space;
> > +       uint64_t flags;
> > +       struct hv_vpset hv_vp_set;
> > +       uint64_t gva_list[];
> > +} __packed;

Here an pointer is allocated for struct hv_tlb_flush_ex with 4K size.
Now gva_list and bank_contents are sharing same space.
But gva_list gets filled up from the particular index position, where bank_contents
is ending. 
Total space used by bank_contents[0-(n-1)] + gva_list[n-end_of_the heap allocated] = 4K - (sizeof(format) + sizeof(valid_bank_mask) + sizeof(address_space) + sizeof(flags) )
During a call to hypervisor we need to send in this message format for proper deserialization and there we also specify the bank_contents index that is n-1.
Thanks 
Souradeep
>
>> Anyway, the purpose of this email is to understand how to add such
>> flags in local Makefiles and make it effective for global buildkernel.
>> Adding such flags in local Makefiles already proves to be working when
>> only building under local directory.
>
>You would have to add it to every line in sys/conf/files* that references a C file
>which includes this header.
>
>DES
>--
>Dag-Erling Smørgrav - des@FreeBSD.org