Received: by 10.192.165.148 with SMTP id m20csp3202971imm; Mon, 23 Apr 2018 02:23:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/VE6o7u2ykCBUl0752gSAVoH9AZttJc8ox3rjgn6Z1q9OYGHDT/wCs3kz0KKouII4tLoN X-Received: by 10.101.90.194 with SMTP id d2mr16606615pgt.352.1524475433195; Mon, 23 Apr 2018 02:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524475433; cv=none; d=google.com; s=arc-20160816; b=jUGI2ueL8mnQ6K9y9nIMqoa1RMUYLjdWDtJGF+XMSh3cA2SyMAwg0uAskJPHP++0We lBNni8P5Xf11YTRGDQpe3pEom3TkGPWEA8IXyvCQ1vkGgDVkgeRMEoTSN8ND5kc4CncD 8bYNYilWugPdTgTqIXquLWWxfbLrr7uj9NSp+w3fol4JNOzkm98ASBj530ABMZsQNfRM MDf/c8Phu39M+hTgvdDKV1ezkkU4QmZEtCa46JsktT5HMRrrj9vf7LHOEs7qoD725m3s eWs2x2O5opcmcAPcRDquvgOt3X8NcfPYu2grP3twUuGNZ4gVX7jrDjEv3bH3Aa+SxP0a xdwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=Di8JPkYvDgZAzChwCvJ4cdluSAke8dKCakpPL2uiz+s=; b=X0SfdeHNEqPryYoXHpGBVwJTaoRFhSoBHGcopWHbGpVYqEJM8aYe4RXbzEbhAVTD18 T9jNxTyPPbcRuMUcqLaBYjFwkywkbURrprWBU9xYXcqPKZA+zqpxnEZxVoa4KIJcdk+K BtkviV8c+J75oEnbnp/vdYLlnR86BBkoh3iF1DnJ8Vr5UD0xnY+4STXcYi5VnOLNqPqP +sN7BtrBxUDqPGw4DT2Yc4+9le1ZSf0dR8I/H+fTxIDMGl6sP98wJHBkOHejMfLInG82 UF/6yfQ3B7Q5v3XF3xqUxN814nPXW2GlbhahY68eKQT/XwKWlEFO6SXUiQxFBEKZLB6o P5zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Kn61xQZB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 145si7829570pgd.561.2018.04.23.02.23.39; Mon, 23 Apr 2018 02:23:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Kn61xQZB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754579AbeDWJW1 (ORCPT + 99 others); Mon, 23 Apr 2018 05:22:27 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:34498 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754201AbeDWJWT (ORCPT ); Mon, 23 Apr 2018 05:22:19 -0400 Received: by mail-io0-f193.google.com with SMTP id d6-v6so17650893iog.1 for ; Mon, 23 Apr 2018 02:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Di8JPkYvDgZAzChwCvJ4cdluSAke8dKCakpPL2uiz+s=; b=Kn61xQZBlfapPTPkVnjWxDfMlir9U46Wh/R01CnbBtaiwhI88sNDDdn4WVV60p687O G1y3U/OQSv0SVLPtcH6dHfDIosEc7nqT0LCTrX3ifvsDX3loZ6PMi6NOJgyXpz7kPl6u 9bfAAr0IuAuLxrW0jReN4eA6WVctAhEUMC0bJd7E07clLvEs2q49OHqnDS/BuV+uHJkH V2Z1KW/+KSahn01f+9lPeRw8uGQT8bIPuCUv3guNM8W6d36jHYBgsPB0SWmeSVgy7f9R +F1y4AmXdW/ej34oFAFYkkglkJ5YFQvXtCGzL8OYO7hLmHi1TIFGQCt4Dt/0XS2gC7/a Peqg== 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=Di8JPkYvDgZAzChwCvJ4cdluSAke8dKCakpPL2uiz+s=; b=J/wwP0dp88zRC4eBqokTTwkxek+7F9b2zNFZKsNyVpUhMcNTNMYilfMeQB+Py52KrQ 3Ua+kC5SnKeUmfr5SmcS36i3nWKSB0k0PQlIr6zhSYkOm/nYS34gYkO2WHWfUrqfTuoE NDBOuWxgNlVTvFuy0VvW7smAmg+w3nR9tPcdOFj6zIRjNkyXQ2SIN7DuKncTObacwV9+ T8bPTYgaRXs2NnbJI8CCnZSvB8y62joD5iRisYTjAoPy3mxCh0FirjXgGb7pcCcCuTmt qphA7apStMuLZ7WrxJtuLfqdQWKef4xwDMZxOe00o6lmTNjYaukAbCO2oTP9WLF9HAqY CStQ== X-Gm-Message-State: ALQs6tC5hDJVnsQNoBXL5ZHStdOZKPrJ+6TYqEOO50RXLOIcF7RLk8T6 p2nDTOt3/piPXA+E0baaZWH/Ky/ebTpdvdsSRoK7sA== X-Received: by 2002:a6b:bad5:: with SMTP id k204-v6mr19635666iof.226.1524475337778; Mon, 23 Apr 2018 02:22:17 -0700 (PDT) MIME-Version: 1.0 References: <20180412101350.210547-1-tweek@google.com> <20180412101350.210547-2-tweek@google.com> <20180417030202.GA30624@ziepe.ca> <20180417140013.GA2029@ziepe.ca> <20180420145740.GC30433@ziepe.ca> In-Reply-To: <20180420145740.GC30433@ziepe.ca> From: Thiebaud Weksteen Date: Mon, 23 Apr 2018 09:22:06 +0000 Message-ID: Subject: Re: [PATCH v2 1/4] tpm: Add explicit endianness cast To: jgg@ziepe.ca, Christopher Li Cc: Jarkko Sakkinen , Nayna Jain , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 20, 2018 at 4:57 PM Jason Gunthorpe wrote: > On Thu, Apr 19, 2018 at 01:09:12PM +0000, Thiebaud Weksteen wrote: > > On Tue, Apr 17, 2018 at 4:00 PM Jason Gunthorpe wrote: > > > > > On Tue, Apr 17, 2018 at 08:32:33AM +0000, Thiebaud Weksteen wrote: > > > > On Tue, Apr 17, 2018 at 5:02 AM Jason Gunthorpe wrote: > > > > > > > > > On Thu, Apr 12, 2018 at 12:13:47PM +0200, Thiebaud Weksteen wrote: > > > > > > Signed-off-by: Thiebaud Weksteen > > > > > > drivers/char/tpm/tpm_eventlog_of.c | 4 ++-- > > > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > > > > > diff --git a/drivers/char/tpm/tpm_eventlog_of.c > > > > b/drivers/char/tpm/tpm_eventlog_of.c > > > > > > index 96fd5646f866..d74568d58a66 100644 > > > > > > +++ b/drivers/char/tpm/tpm_eventlog_of.c > > > > > > @@ -56,8 +56,8 @@ int tpm_read_log_of(struct tpm_chip *chip) > > > > > > * but physical tpm needs the conversion. > > > > > > */ > > > > > > if (of_property_match_string(np, "compatible", "IBM,vtpm") < > > 0) { > > > > > > - size = be32_to_cpup(sizep); > > > > > > - base = be64_to_cpup(basep); > > > > > > + size = be32_to_cpup((__be32 *)sizep); > > > > > > + base = be64_to_cpup((__be64 *)basep); > > > > > > > > > Er, no.. change the definitions of sizep and basep to be __be > > > > > > > > > Jason > > > > > > > > Please read the comment before the condition. sizep and > > > > basep may contain either little endian or big endian and this block is > > used > > > > to adjust that. Let me know if there is a better way for handling this. > > > > > Well a cast like that will throw sparse warnings, you need __force at > > > least > > > > I don't think so. Since the variable is only defined as u32*, no specific > > warning is generated. I've used `make C=2 drivers/char/tpm/` with this > > patch applied and no new warning is being triggered. > I'm surprised to hear you say that.. > Sparse is supposed to require force on all cast that change the > annotation, and there are many examples in the kernel that have force > in that case. > Jason +linux-sparse@vger.kernel.org and sparse@chrisli.org for a sanity check. If you look at the man page of sparse, under the bitwise option, it states: "Sparse will warn on [...] any conversion of one restricted type into another, except via a cast that includes __attribute__((force)).". In our case, it is a conversion from unrestricted to restricted which does not fall in this category.