From patchwork Fri Sep 1 02:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719494 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp18020lti; Thu, 31 Aug 2023 19:28:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErdd8H7fzHzkhp6BA8g+eKF+4bsODh9jXjPrLw/Q2BizeNv+Z9o19V322PLG2CgZ085CnC X-Received: by 2002:a05:620a:4414:b0:76c:ae1f:201e with SMTP id v20-20020a05620a441400b0076cae1f201emr6325534qkp.27.1693535301587; Thu, 31 Aug 2023 19:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535301; cv=none; d=google.com; s=arc-20160816; b=ntkP3GswtIAUJjQuRFeK92HjC2y5qg4rHTZ2myE4D6bwGUYt4+jdnLjGezZxsN9hJG 3ffHUxLWh5BMRHJ7q2loKt0D0VZQGfB4ZMfkh5KzRehsJoQDkVYdSdTEqG10bEgJ9XME B25IKHQk7GzKAespXdo62C3qrQ26Pu0me9zy4qykvyDMH/jQvmGVtlE8eJtW14I6i21B O5/6slsBGFIjYq3JGADHRBcXmjAAV6YYreJkUH7rt1+iU6j9L3435xAycEcaG9JN6GKf 88wsh6zbHBSbX+XyWtAX1uk9gnaBsekgLKMWkplSxWVSFx669RPd4+n5v8GnQLm9qatP 7nIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oX0Wvey1e2J0VCCaIBZPR7REasOlAnSls/c5wuVfncQ=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=0iwKU30tXBqL08gKFYCOhcI7lkz5kPSEVdge4NIRlHEAe64BPHkrmOLnMhmwm1Si+X tC7/gUaX7cSwpu0wHjFL8jeOWrcka8at5LUlRnbyZxSRcMgYLguSVN98FQPjmlIytvIP XJXMz8OPUMMDfkHvrMPn6p5WsOf6h1bq83KOcn4tGmFYJD929Ic2GR1X7fXIuNrifgF7 9aEklXakoS99uAlcJHFZucfyI7CYAs82iyUXcr1D+sTZZFs0naVRBaEdMFeaEhdO49PG rGkm/mC1DTozuj7UPwwNv46gcs2WKEwlw+bMwOupIdMCWjeuV9WnUs0CIZ95XcDNpWkz z5Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KW+ZGb3t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fi16-20020a0562141a5000b006505e1ecb0fsi1759301qvb.212.2023.08.31.19.28.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:28:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KW+ZGb3t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbtp6-0006Xg-Te; Thu, 31 Aug 2023 22:23:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp5-0006Ww-Le for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:47 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp3-0001Q8-EE for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:47 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68730bafa6bso1786144b3a.1 for ; Thu, 31 Aug 2023 19:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535024; x=1694139824; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oX0Wvey1e2J0VCCaIBZPR7REasOlAnSls/c5wuVfncQ=; b=KW+ZGb3tufrc/+PV17+VgExsYCcQKh5d6nmfb3amL6MKyYSKlOqndrXHsMm7K3lQ4j X8qc79dpPc36U0HHFkj9xvyRrA1CbWCzo2XovOgsb4q3+AyOn41ySSJIjoEeYFtnN9cy Psai99+kh2jRvdorZFerM8llchvplW/3K1d7X5Tk98Di+j1ypv58vxNpOI2aElE0v/+x alZu8es1PnRLiW47ngZlkvxWnukOn0j5aNQ1vYuHW2esN+FrW45beMZo69SGqwjByJRx oHRMUAkhN8foTr7N/aScr7FUgzw7we1oHZXw+5aZQCfrT4DFduq0ypiH6pJnBJdJOgYL DiKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535024; x=1694139824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oX0Wvey1e2J0VCCaIBZPR7REasOlAnSls/c5wuVfncQ=; b=HQ9YSz0aYoIpP/n7rrIZFyX68dXKZfrFNNvZWxZq8q88x3DPqzYTkCyrn0UCswmC0K I89DRoqTceDn8gOhInzlekkAyTsooP15SvB7O+fJHwWz24pZIAYPvejHFUMmuJ33gTd3 w44AmYvJs8geCKYSbjhw6dC+i45Nnei0NJT1NvTDIZReRWYvl9eF6FWWIq8lq1VxyFsX ozF0bvSoanlfDCEIjmiAi0jgV7J2fVDN0g1sp4MIR7602M2IBtiWLaAMwV367pgLFa5d y17TNnw9lByMjORa2NN5r5OSpIom8W5emqXi06KntnH8hk5E/TO2Lys1+NWuL99UylbS 4UYg== X-Gm-Message-State: AOJu0YzBb15o/JwteZ6FaTjthOmX4sIsjAbNc6rczhP4s29fO390ymGR SQyv10YSqgfAzJOdyjZChJw7qrKMeXhaiVrqZqg= X-Received: by 2002:a05:6a00:27ab:b0:68b:fc76:7dea with SMTP id bd43-20020a056a0027ab00b0068bfc767deamr1541860pfb.12.1693535024189; Thu, 31 Aug 2023 19:23:44 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 14/33] softmmu/physmem: Remove HOST_PAGE_ALIGN Date: Thu, 31 Aug 2023 19:23:12 -0700 Message-Id: <20230901022331.115247-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Align allocation sizes to the maximum of host and target page sizes. Signed-off-by: Richard Henderson --- softmmu/physmem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 6f963ea127..04d8423b68 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -1662,7 +1662,8 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp) assert(block); - newsize = HOST_PAGE_ALIGN(newsize); + newsize = TARGET_PAGE_ALIGN(newsize); + newsize = REAL_HOST_PAGE_ALIGN(newsize); if (block->used_length == newsize) { /* @@ -1897,7 +1898,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, return NULL; } - size = HOST_PAGE_ALIGN(size); + size = TARGET_PAGE_ALIGN(size); + size = REAL_HOST_PAGE_ALIGN(size); + file_size = get_file_size(fd); if (file_size > offset && file_size < (offset + size)) { error_setg(errp, "backing store size 0x%" PRIx64 @@ -1975,13 +1978,17 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size, { RAMBlock *new_block; Error *local_err = NULL; + int align; assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC | RAM_NORESERVE)) == 0); assert(!host ^ (ram_flags & RAM_PREALLOC)); - size = HOST_PAGE_ALIGN(size); - max_size = HOST_PAGE_ALIGN(max_size); + align = qemu_real_host_page_size(); + align = MAX(align, TARGET_PAGE_SIZE); + size = ROUND_UP(size, align); + max_size = ROUND_UP(max_size, align); + new_block = g_malloc0(sizeof(*new_block)); new_block->mr = mr; new_block->resized = resized;