From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 110B0C433DB for ; Fri, 19 Mar 2021 17:53:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4EB1D6197E for ; Fri, 19 Mar 2021 17:53:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EB1D6197E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNJJm-0000sv-0P for qemu-devel@archiver.kernel.org; Fri, 19 Mar 2021 13:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNJIy-0000QT-4L for qemu-devel@nongnu.org; Fri, 19 Mar 2021 13:53:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNJIv-0008RV-IB for qemu-devel@nongnu.org; Fri, 19 Mar 2021 13:52:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616176376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9nQxIRGGfJtXG6JcIdCAR30qr1vG75wlX1zJo93u3Zk=; b=O6Oq9tNM01ict6v+eGC1WobVd6TcFDS7QuRC1Nct/qEOET99irZVMFjDagzT3J5jFKmN4F iXNFDiOOtTcZu+8rHkJXV78DVt9NicfCs0/FO2Bifl7f1xsLtQnoziB16DMZznh12LC2oI HIqaI1wp8kyybvnz8H8X2NYg7M0KmSU= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-0szIgXP3OhKUvrbr_ntkBg-1; Fri, 19 Mar 2021 13:52:53 -0400 X-MC-Unique: 0szIgXP3OhKUvrbr_ntkBg-1 Received: by mail-pf1-f198.google.com with SMTP id t16so5954470pfg.1 for ; Fri, 19 Mar 2021 10:52:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9nQxIRGGfJtXG6JcIdCAR30qr1vG75wlX1zJo93u3Zk=; b=P3wj1WlyS28auWg28I2YP8ftxpnHgrbWtXZkAZmOMLK20wh6jEkoTpY/0F/RE1OW8e gKEUKRnrcQEgGGJ2brfYLsXT9hPWeMmQ62FfpweoA468oVXAia9ADhOt4mtJUrEJ0wCu fAVZPDf8esXqrlNbWuO/ClnI1f+lNXIfF396fWYUGUDf1mYMOaGnnqzYoc24M+TAnnkQ LpAQa+pTYd8uLp82jUHGOTavpebm8kuggh01meF9MX9AM7/8Re+L+m+J8oSkUDVDEt33 TIDXhjlGNpe2Yz3/LNaFPIohqYFym6tJzpPfQBK/8M+BLefIG05IBxIERzClLBP+avLV TL8g== X-Gm-Message-State: AOAM532zH+giOodAqdvK8j/K4TSqDx/OEgJlK7nBPQKJrPcFI5lcYwBb MRBLjTv1jdrMmc5AKW2Mc1osq7Q/yq/xUq1+13Iar76DejLs6EbOaHesh1/uIxHLWFuZxlN61Q5 zcXdvYYq9+JtsEWLOlISCU87XuKsP7Cw= X-Received: by 2002:a05:6a00:78c:b029:1f5:d587:1701 with SMTP id g12-20020a056a00078cb02901f5d5871701mr10207612pfu.59.1616176372630; Fri, 19 Mar 2021 10:52:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypDKcCWNl0X+3d9fUWVVVAFYi07KbdD+Agh8xKXuQO0IKYM9CJUew1AyH7Gqk6WmMU4ryQtffqtf4XKUJ+gcg= X-Received: by 2002:a05:6a00:78c:b029:1f5:d587:1701 with SMTP id g12-20020a056a00078cb02901f5d5871701mr10207593pfu.59.1616176372362; Fri, 19 Mar 2021 10:52:52 -0700 (PDT) MIME-Version: 1.0 References: <1549390526-24246-1-git-send-email-pbonzini@redhat.com> <1549390526-24246-19-git-send-email-pbonzini@redhat.com> <20210319173524.rnrxslpmdjck6uxv@steredhat> In-Reply-To: <20210319173524.rnrxslpmdjck6uxv@steredhat> From: Paolo Bonzini Date: Fri, 19 Mar 2021 18:52:39 +0100 Message-ID: Subject: Re: [Qemu-devel] [PULL 18/76] optionrom: add new PVH option rom To: Stefano Garzarella Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="00000000000091d0d505bde762ea" Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.251, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , qemu-devel Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000091d0d505bde762ea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It's likely that the compiler will online it. But indeed it's better to add -minline-all-stringops to the compiler command line. Paolo Il ven 19 mar 2021, 18:35 Stefano Garzarella ha scritto: > On Fri, Mar 19, 2021 at 06:03:59PM +0100, Paolo Bonzini wrote: > >On 19/03/21 15:06, Philippe Mathieu-Daud=C3=A9 wrote: > >>>+ > >>>+/* Search RSDP signature. */ > >>>+static uintptr_t search_rsdp(uint32_t start_addr, uint32_t end_addr) > >>>+{ > >>>+ uint64_t *rsdp_p; > >>>+ > >>>+ /* RSDP signature is always on a 16 byte boundary */ > >>>+ for (rsdp_p =3D (uint64_t *)start_addr; rsdp_p < (uint64_t > *)end_addr; > >>>+ rsdp_p +=3D 2) { > >>>+ if (*rsdp_p =3D=3D RSDP_SIGNATURE) { > >>>+ return (uintptr_t)rsdp_p; > >>>+ } > >>>+ } > >>>+ > >>>+ return 0; > >>>+} > >>gcc 10.2.1 "cc (Alpine 10.2.1_pre2) 10.2.1 20210313" reports: > >> > >>pc-bios/optionrom/pvh_main.c: In function 'search_rsdp': > >>pc-bios/optionrom/pvh_main.c:61:21: warning: comparison is always false > >>due to limited range of data type [-Wtype-limits] > >> 61 | if (*rsdp_p =3D=3D RSDP_SIGNATURE) { > >> | ^~ > > > >This is probably a different bug, but I'll also add that uint64_t is > >supposed to be aligned to 64 bits, so you need either > >__attribute__((packed)), or use char* and memcmp. If you go for the > >latter, it would fix the issue that Philippe is reporting. > > Yes, memcmp maybe is also more readable, but being baremetal, I have to > implement it right? > > Thanks, > Stefano > > --00000000000091d0d505bde762ea Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It's likely that the compiler will online it. But ind= eed it's better to add -minline-all-stringops to the compiler command l= ine.

Paolo

Il ven 19 mar = 2021, 18:35 Stefano Garzarella <s= garzare@redhat.com> ha scritto:
On Fri, Mar 19, 2021 at 06:03:59PM +0100, Paolo Bonzini wrote:
>On 19/03/21 15:06, Philippe Mathieu-Daud=C3=A9 wrote:
>>>+
>>>+/* Search RSDP signature. */
>>>+static uintptr_t search_rsdp(uint32_t start_addr, uint32_t end= _addr)
>>>+{
>>>+=C2=A0 =C2=A0 uint64_t *rsdp_p;
>>>+
>>>+=C2=A0 =C2=A0 /* RSDP signature is always on a 16 byte boundar= y */
>>>+=C2=A0 =C2=A0 for (rsdp_p =3D (uint64_t *)start_addr; rsdp_p &= lt; (uint64_t *)end_addr;
>>>+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rsdp_p +=3D 2) {
>>>+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (*rsdp_p =3D=3D RSDP_SIGNATURE)= {
>>>+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return (uintptr_t)rs= dp_p;
>>>+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>>>+=C2=A0 =C2=A0 }
>>>+
>>>+=C2=A0 =C2=A0 return 0;
>>>+}
>>gcc 10.2.1 "cc (Alpine 10.2.1_pre2) 10.2.1 20210313" repo= rts:
>>
>>pc-bios/optionrom/pvh_main.c: In function 'search_rsdp': >>pc-bios/optionrom/pvh_main.c:61:21: warning: comparison is always f= alse
>>due to limited range of data type [-Wtype-limits]
>>=C2=A0 =C2=A0 61 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (*rsdp_p =3D= =3D RSDP_SIGNATURE) {
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^~
>
>This is probably a different bug, but I'll also add that uint64_t i= s
>supposed to be aligned to 64 bits, so you need either
>__attribute__((packed)), or use char* and memcmp.=C2=A0 If you go for t= he
>latter, it would fix the issue that Philippe is reporting.

Yes, memcmp maybe is also more readable, but being baremetal, I have to implement it right?

Thanks,
Stefano

--00000000000091d0d505bde762ea--