From nobody Wed May 8 05:10:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1585842832; cv=none; d=zohomail.com; s=zohoarc; b=BeoVzEX0YToFBKYigMDx1gBpt3OZ3m6xgBpfEFeVEn6zVitTfQ2kAA4f3Ly76kBCtMiA3SFYXa/hzDFXXIMpTLg9cXxN0bIwa233eyK/Y9Rp1Msh/baoImBOZmKdVNMa2LRIx1T76tSpFpgdFOoc1PpLyxzQcyhSAJw7kKaumQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585842832; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=AVEvemLr4Biqm7wYYR5hPV0RkS9Fxm05rC7rAzhCIwQ=; b=AFZ9S//LrC/LlV8l7bRLpxEhi8/GrBCx9Qnr/waVoQfHmvY8lBwlCFmE11d6+3m9VtO81A+zZ+pL35YxdTS0xATNvCggJ8rlmk5zowDXLtnq1tlJ4cetGOKeQV884iz1RA/4/I1WVYQQt0PRIgeeCgqzw69lBS6hp7dr41TnS1w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1585842832164141.2035429421543; Thu, 2 Apr 2020 08:53:52 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jK29s-0005fx-6m; Thu, 02 Apr 2020 15:53:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jK29q-0005fs-9z for xen-devel@lists.xenproject.org; Thu, 02 Apr 2020 15:53:30 +0000 Received: from mail-pj1-x1044.google.com (unknown [2607:f8b0:4864:20::1044]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 18b3aa10-74fa-11ea-83d8-bc764e2007e4; Thu, 02 Apr 2020 15:53:29 +0000 (UTC) Received: by mail-pj1-x1044.google.com with SMTP id jz1so3395915pjb.0 for ; Thu, 02 Apr 2020 08:53:29 -0700 (PDT) Received: from simran-Inspiron-5558 ([2409:4052:99d:cf8:4926:6e0b:60ca:635c]) by smtp.gmail.com with ESMTPSA id x188sm4075889pfx.198.2020.04.02.08.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 08:53:28 -0700 (PDT) X-Inumbo-ID: 18b3aa10-74fa-11ea-83d8-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=AVEvemLr4Biqm7wYYR5hPV0RkS9Fxm05rC7rAzhCIwQ=; b=ZLl2QTd/xaZzRVjyC9vExivmHH1lBIFoSMe2+9NiNZcGk6mUXIdZJNRBV/J6SbcvAY loL72/0S0cUM10GrEyE9QnlGvc3+ooANgqAkR4U8M5mbYVKxx4EC03ttBa4dPc9IKbmK l/4GcGtsrdNSy0l2WIK0C1C5W4Awvqb1vFllE+VwjkMX2fINM0f0Pu8alSAEeaYhsn2m ylj7GWFxXmZFVkxhox9xYc90Cu2aebndiZaCeuEMIHrFIDYoS748b2ToQhQvHJmWqvta 64nPrvhJ+2YzNOD5/Xe0Jzb0WDfetkAu7dMwZD8ncrOiJYtommtPQuMj4JdwQTkZaoRs yHew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=AVEvemLr4Biqm7wYYR5hPV0RkS9Fxm05rC7rAzhCIwQ=; b=KMIOMvpQlkOyttgC/PvHm7kRrWOrqM5uC4+B4QGdYoCdndfAh7pkNyEYnjAqluXcox syKWW3hfo14TyKuRsAAbj96M8JTwGSUL/y3D9nS1mEth0iHuDF7yMMW1sPNYT8wb1P/m 3hZY55MOrE97AzCS6I58WMaEUSaQ8hUwwnXEhWctoxpFhyGzrDi/x7r3DLD4dzN6F0ta bM+sd5JUAKurePVwnT8ZensGmqrpOzLQ+oZeFpriRHyFbCWNVC78Bsn/uV/X4EH/B+74 NOq9VLPzEBL6Z+ey3WhyuOArmU8rNCr/2yrhpG+/yXCGuZdJx67J+2RwQCFv7xJ3mUN8 hz7A== X-Gm-Message-State: AGi0PuZgIjhhS8merHrC9uaGhJTBvhZQNHnoe8FF1D6nJu/uJyQ3Vm0q J8XjGtj62/Fx+yssJWIDjS4= X-Google-Smtp-Source: APiQypIxcMHBSPBknzSwpX6D0tejjsPsEQ3W6AoctFC+0tKCqkvuEbY+lL4K6hMnc6EYa0gcZhUB9w== X-Received: by 2002:a17:90a:34e:: with SMTP id 14mr4617074pjf.32.1585842808812; Thu, 02 Apr 2020 08:53:28 -0700 (PDT) Date: Thu, 2 Apr 2020 21:23:22 +0530 From: Simran Singhal To: xen-devel@lists.xenproject.org Subject: [PATCH] xen/x86: Use macro DIV_ROUND_UP Message-ID: <20200402155322.GA16696@simran-Inspiron-5558> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Lukasz Hawrylko , Wei Liu , Jan Beulich , Roger Pau =?iso-8859-1?Q?Monn=E9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the DIV_ROUND_UP macro to replace open-coded divisor calculation (((n) + (d) - 1) /(d)) to improve readability. Signed-off-by: Simran Singhal Acked-by: Andrew Cooper --- xen/arch/x86/mm.c | 2 +- xen/arch/x86/tboot.c | 2 +- xen/arch/x86/x86_64/mm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index c7617f80e8..a381eac81c 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -240,7 +240,7 @@ static void __init init_frametable_chunk(void *start, v= oid *end) void __init init_frametable(void) { unsigned int sidx, eidx, nidx; - unsigned int max_idx =3D (max_pdx + PDX_GROUP_COUNT - 1) / PDX_GROUP_C= OUNT; + unsigned int max_idx =3D DIV_ROUND_UP(max_pdx, PDX_GROUP_COUNT); struct page_info *end_pg, *top_pg; =20 BUILD_BUG_ON(XEN_VIRT_END > FRAMETABLE_VIRT_START); diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index 102c3cd203..320e06f129 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -310,7 +310,7 @@ static void tboot_gen_frametable_integrity(const uint8_= t key[TB_KEY_SIZE], vmac_t *mac) { unsigned int sidx, eidx, nidx; - unsigned int max_idx =3D (max_pdx + PDX_GROUP_COUNT - 1)/PDX_GROUP_COU= NT; + unsigned int max_idx =3D DIV_ROUND_UP(max_pdx, PDX_GROUP_COUNT); uint8_t nonce[16] =3D {}; vmac_ctx_t ctx; =20 diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index b7ce833ffc..cee836ec37 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -801,7 +801,7 @@ static int extend_frame_table(struct mem_hotadd_info *i= nfo) spfn =3D _mfn(info->spfn); epfn =3D _mfn(info->epfn); =20 - eidx =3D (mfn_to_pdx(epfn) + PDX_GROUP_COUNT - 1) / PDX_GROUP_COUNT; + eidx =3D DIV_ROUND_UP(mfn_to_pdx(epfn), PDX_GROUP_COUNT); nidx =3D cidx =3D mfn_to_pdx(spfn)/PDX_GROUP_COUNT; =20 ASSERT( mfn_to_pdx(epfn) <=3D (DIRECTMAP_SIZE >> PAGE_SHIFT) && --=20 2.17.1