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=-11.3 required=3.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 A3736C433E3 for ; Tue, 28 Jul 2020 11:10:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 6F1E820656 for ; Tue, 28 Jul 2020 11:10:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="mAie5v7U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F1E820656 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k0NUE-0003at-6C; Tue, 28 Jul 2020 11:09:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k0NUD-0003ao-Nm for xen-devel@lists.xenproject.org; Tue, 28 Jul 2020 11:09:33 +0000 X-Inumbo-ID: d036db5c-d0c2-11ea-a8a0-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d036db5c-d0c2-11ea-a8a0-12813bfff9fa; Tue, 28 Jul 2020 11:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1595934572; x=1627470572; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=3Requ7kIPFVQtzR1jFatrXyBIb7TnieU1eKfFKFEi2Y=; b=mAie5v7UlX+RWi45EdTAqrIOaaX0AdGC6xcw5ZSOcZ2EaK3+OXRlTMF3 EfSBnaccobsg3vlSnHLaUnXwCvKcBr+Yrr42O85ygDuuYQLPfFcNpxq+F 79RLxaxl3FlTjtGX03vXj5bag4GVvG59sx72Mq9rbNvtP8yUmXp+Jn3I3 Q=; IronPort-SDR: TxpgzrKoVN4IKCnHDU0jgqi0jdFjgJEyuTLyxPTtGoXoAEvXnXiN4TzJIywZV/NEkO2Pnm8f/H Pah0glIPdQfw== X-IronPort-AV: E=Sophos;i="5.75,406,1589241600"; d="scan'208";a="63548064" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2c-2225282c.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 28 Jul 2020 11:09:30 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2c-2225282c.us-west-2.amazon.com (Postfix) with ESMTPS id 3561BA1DD9; Tue, 28 Jul 2020 11:09:30 +0000 (UTC) Received: from EX13D03EUA002.ant.amazon.com (10.43.165.166) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 28 Jul 2020 11:09:29 +0000 Received: from a483e73f63b0.ant.amazon.com (10.43.162.73) by EX13D03EUA002.ant.amazon.com (10.43.165.166) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 28 Jul 2020 11:09:25 +0000 Subject: Re: [PATCH] x86/vhpet: Fix type size in timer_int_route_valid To: Andrew Cooper , Eslam Elnikety , References: <20200728083357.77999-1-elnikety@amazon.com> From: Eslam Elnikety Message-ID: <09b2f75d-13d7-8f53-54a1-6f10ecd7b6e2@amazon.com> Date: Tue, 28 Jul 2020 13:09:21 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.43.162.73] X-ClientProxiedBy: EX13D42UWB004.ant.amazon.com (10.43.161.99) To EX13D03EUA002.ant.amazon.com (10.43.165.166) Precedence: Bulk X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Paul Durrant , Jan Beulich , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 28.07.20 11:26, Andrew Cooper wrote: > On 28/07/2020 09:33, Eslam Elnikety wrote: >> The macro timer_int_route_cap evalutes to a 64 bit value. Extend the >> size of left side of timer_int_route_valid to match. >> >> This bug was discovered and resolved using Coverity Static Analysis >> Security Testing (SAST) by Synopsys, Inc. >> >> Signed-off-by: Eslam Elnikety >> --- >> xen/arch/x86/hvm/hpet.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c >> index ca94e8b453..9afe6e6760 100644 >> --- a/xen/arch/x86/hvm/hpet.c >> +++ b/xen/arch/x86/hvm/hpet.c >> @@ -66,7 +66,7 @@ >> MASK_EXTR(timer_config(h, n), HPET_TN_INT_ROUTE_CAP) >> >> #define timer_int_route_valid(h, n) \ >> - ((1u << timer_int_route(h, n)) & timer_int_route_cap(h, n)) >> + ((1ULL << timer_int_route(h, n)) & timer_int_route_cap(h, n)) >> >> static inline uint64_t hpet_read_maincounter(HPETState *h, uint64_t guest_time) >> { > > Does this work? Yes! This is better than my fix (and I like that it clarifies the route part of the config. Will you sign-off and send a patch? > > diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c > index ca94e8b453..638f6174de 100644 > --- a/xen/arch/x86/hvm/hpet.c > +++ b/xen/arch/x86/hvm/hpet.c > @@ -62,8 +62,7 @@ > >  #define timer_int_route(h, n)    MASK_EXTR(timer_config(h, n), > HPET_TN_ROUTE) > > -#define timer_int_route_cap(h, n) \ > -    MASK_EXTR(timer_config(h, n), HPET_TN_INT_ROUTE_CAP) > +#define timer_int_route_cap(h, n) (h)->hpet.timers[(n)].route > >  #define timer_int_route_valid(h, n) \ >      ((1u << timer_int_route(h, n)) & timer_int_route_cap(h, n)) > diff --git a/xen/include/asm-x86/hvm/vpt.h b/xen/include/asm-x86/hvm/vpt.h > index f0e0eaec83..a41fc443cc 100644 > --- a/xen/include/asm-x86/hvm/vpt.h > +++ b/xen/include/asm-x86/hvm/vpt.h > @@ -73,7 +73,13 @@ struct hpet_registers { >      uint64_t isr;               /* interrupt status reg */ >      uint64_t mc64;              /* main counter */ >      struct {                    /* timers */ > -        uint64_t config;        /* configuration/cap */ > +        union { > +            uint64_t config;    /* configuration/cap */ > +            struct { > +                uint32_t _; > +                uint32_t route; > +            }; > +        }; >          uint64_t cmp;           /* comparator */ >          uint64_t fsb;           /* FSB route, not supported now */ >      } timers[HPET_TIMER_NUM]; > >