From nobody Sat Apr 20 19:34:30 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VMMCg431Dz5JKwg for ; Sat, 20 Apr 2024 19:34:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4VMMCg128sz4N9X; Sat, 20 Apr 2024 19:34:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 43KJYUAM028135; Sat, 20 Apr 2024 22:34:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 43KJYUAM028135 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 43KJYUia028134; Sat, 20 Apr 2024 22:34:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 20 Apr 2024 22:34:30 +0300 From: Konstantin Belousov To: Souradeep Chakrabarti Cc: Dag-Erling =?utf-8?B?U23DuHJncmF2?= , Wei Hu , Warner Losh , "freebsd-hackers@FreeBSD.org" Subject: Re: [EXTERNAL] Re: How to add a -W flag in local Makefile Message-ID: References: <86cyqlbovo.fsf@ltc.des.dev> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on tom.home X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4VMMCg128sz4N9X On Sat, Apr 20, 2024 at 12:01:13PM +0000, Souradeep Chakrabarti wrote: > > > >-----Original Message----- > >From: owner-freebsd-hackers@FreeBSD.org >hackers@FreeBSD.org> On Behalf Of Dag-Erling Smørgrav > >Sent: Friday, April 19, 2024 4:28 PM > >To: Wei Hu > >Cc: Konstantin Belousov ; Warner Losh > >; freebsd-hackers@FreeBSD.org > >Subject: [EXTERNAL] Re: How to add a -W flag in local Makefile > > > >Wei Hu 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. Indexing bank_contents is not a valid C code. You do not need the second flexible member, instead you should calculate the location manually and access it there. Your hack relies on the internal layouts of the structures, but should instead use proper address arithmetic. > 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 >