From nobody Sun Nov 16 18:52:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.66 as permitted sender) client-ip=209.85.128.66; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f66.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1601224790; cv=none; d=zohomail.com; s=zohoarc; b=S+TaPTd5/olJh7gVZpSKbGBs0MkZHMq6Gg2wJiNxU3Mt7EkT+fKb4twUod9zft77qMDFQrViEhCnJ7MrDOnvuV3nAfMgg3hb31sGGL8xNLygkxLwKtTl4Xlx+U8dtxL+fKBatnBiV0FAG+MtTnbxJmRLz70mfdrewpkp6DZoZEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601224790; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v2AAXqYVbggYqD2O82lQGNTgT9BbKcX2OEontmBjDXk=; b=j40yk/HjhE1gagMusUe0vIkR/o4zjH9uTlO73COPRAs9ToKXxLCj+mAWu1zWjkGGSMa06/vA5lPGxUjWMXsNaPQUenZNCOYL1GKVg8muzbbLPpSxxUiApQ5mraFa+ZcSD7FKX5AoDDMfVk7rk4ZNhl8PdCy8fi7X/G/dgj0AFoA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.66 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.zohomail.com with SMTPS id 1601224790277107.60358562417957; Sun, 27 Sep 2020 09:39:50 -0700 (PDT) Received: by mail-wm1-f66.google.com with SMTP id s13so4046615wmh.4 for ; Sun, 27 Sep 2020 09:39:49 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (74.red-83-53-161.dynamicip.rima-tde.net. [83.53.161.74]) by smtp.gmail.com with ESMTPSA id m10sm5820184wmi.9.2020.09.27.09.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 09:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v2AAXqYVbggYqD2O82lQGNTgT9BbKcX2OEontmBjDXk=; b=kcePoqC/il0PHMHBaHYw5MgQELKldh1nRgODSlIBuKx6G2WYyw3idFGnVwxnJFwG2T GbOmzBngiqtRUJmcn7gJJQOkT++H7HnZk2lFxcAk/TTrMLuf2Wr4p6JGTNI2n2PZLGpO kmd24enYnaMR/HMA8r2fWzlawbcGYYNHIbYyyuwIgjytMWEDJ6lKFZOFiSQ/qugNQJcT pfnyZkCdAscH8Aut237MZEG5IebugPjgh47IG4kUyIsuVcVc31Pees85r0vHpc7UqWUW 4lRTQFVHiEN5jsUFkBmBIWHO5wQSfiYSWRG1Hqbu26R1oLE7BGlrdJbO8s0nftQfJZ93 XyaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=v2AAXqYVbggYqD2O82lQGNTgT9BbKcX2OEontmBjDXk=; b=AIUWOLD8K/Tueruxxrij+x+tkaEQfKuT4GPmK6NjCt+Sfp9sl/uBMmfgKQxeU8k/BB Bop/ykwXz4JrKaEQJawsmPI8F625xQlosK3QJ1Upv55XAi2+EG2kviAcNO8o1423DzC/ 1oBEvLMFGrg6dHmf/jJpzJgCSWgS1T5YNkgECKM1QfsqikC+Nf9d89THmWhcpuBSxmVZ Q8pd+DmhyrKcyDV3c9xkA9RQ1aohXpBZsyojGv6IiNhmA5HemqCXmtf10LDz3fb7dN2s v4UI4ceZgxJ4Drt/0hJLm5+I7kwAxiOeeBcj//V0f+z9INhxA9bQFUo1ezQxH/kapAei GbAQ== X-Gm-Message-State: AOAM533V//P9cVXmAvAmGRP0RjOyE5lfrN4pT4GmVSs1czeot1F0ZAoh mK1j9sedxImgnj4P4/00p28= X-Google-Smtp-Source: ABdhPJydbLG609apzb9XsDTaup4cXrqHD2NRV3RLa8xV3fimjfRKwQu71axI1dkCjKL7N9/JkmI7OQ== X-Received: by 2002:a05:600c:2054:: with SMTP id p20mr7475146wmg.173.1601224788309; Sun, 27 Sep 2020 09:39:48 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Aleksandar Rikalo , Aleksandar Markovic , Jiaxun Yang , Huacai Chen , Aurelien Jarno , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Huacai Chen Subject: [PATCH 2/2] hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE) Date: Sun, 27 Sep 2020 18:39:43 +0200 Message-Id: <20200927163943.614604-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200927163943.614604-1-f4bug@amsat.org> References: <20200927163943.614604-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Instead of using a INITRD_PAGE_MASK definition, use the simpler INITRD_PAGE_SIZE one which allows us to simplify the code by using directly the self-explicit ROUND_UP() macro. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/hw/mips/mips.h | 4 +++- hw/mips/fuloong2e.c | 3 +-- hw/mips/malta.c | 6 +++--- hw/mips/mipssim.c | 3 +-- hw/mips/r4k.c | 3 +-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/hw/mips/mips.h b/include/hw/mips/mips.h index 0af4c3d5d74..6c9c8805f3f 100644 --- a/include/hw/mips/mips.h +++ b/include/hw/mips/mips.h @@ -2,8 +2,10 @@ #define HW_MIPS_H /* Definitions for mips board emulation. */ =20 +#include "qemu/units.h" + /* Kernels can be configured with 64KB pages */ -#define INITRD_PAGE_MASK (~((1 << 16) - 1)) +#define INITRD_PAGE_SIZE (64 * KiB) =20 #include "exec/memory.h" =20 diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index f28609976bf..ef5dbe97b7d 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -132,8 +132,7 @@ static int64_t load_kernel(CPUMIPSState *env) if (loaderparams.initrd_filename) { initrd_size =3D get_image_size(loaderparams.initrd_filename); if (initrd_size > 0) { - initrd_offset =3D (kernel_high + ~INITRD_PAGE_MASK) & - INITRD_PAGE_MASK; + initrd_offset =3D ROUND_UP(kernel_high, INITRD_PAGE_SIZE); if (initrd_offset + initrd_size > ram_size) { error_report("memory too small for initial ram disk '%s'", loaderparams.initrd_filename); diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 4019c9dc1a8..5de5cb152eb 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -1074,9 +1074,9 @@ static int64_t load_kernel(void) * the initrd. It takes at most 128kiB for 2GB RAM and 4kiB * pages. */ - initrd_offset =3D (loaderparams.ram_low_size - initrd_size - - (128 * KiB) - - ~INITRD_PAGE_MASK) & INITRD_PAGE_MASK; + initrd_offset =3D ROUND_UP(loaderparams.ram_low_size + - (initrd_size + 128 * KiB), + INITRD_PAGE_SIZE); if (kernel_high >=3D initrd_offset) { error_report("memory too small for initial ram disk '%s'", loaderparams.initrd_filename); diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index 3aeb1207e1a..1862eeda396 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -89,8 +89,7 @@ static int64_t load_kernel(void) if (loaderparams.initrd_filename) { initrd_size =3D get_image_size(loaderparams.initrd_filename); if (initrd_size > 0) { - initrd_offset =3D (kernel_high + ~INITRD_PAGE_MASK) & - INITRD_PAGE_MASK; + initrd_offset =3D ROUND_UP(kernel_high, INITRD_PAGE_SIZE); if (initrd_offset + initrd_size > loaderparams.ram_size) { error_report("memory too small for initial ram disk '%s'", loaderparams.initrd_filename); diff --git a/hw/mips/r4k.c b/hw/mips/r4k.c index 74f916a3982..24cee357f34 100644 --- a/hw/mips/r4k.c +++ b/hw/mips/r4k.c @@ -114,8 +114,7 @@ static int64_t load_kernel(void) if (loaderparams.initrd_filename) { initrd_size =3D get_image_size(loaderparams.initrd_filename); if (initrd_size > 0) { - initrd_offset =3D (kernel_high + ~INITRD_PAGE_MASK) & - INITRD_PAGE_MASK; + initrd_offset =3D ROUND_UP(kernel_high, INITRD_PAGE_SIZE); if (initrd_offset + initrd_size > ram_size) { error_report("memory too small for initial ram disk '%s'", loaderparams.initrd_filename); --=20 2.26.2