From patchwork Mon Jul 17 12:12:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13315551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7BFEEB64DC for ; Mon, 17 Jul 2023 12:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbjGQMMo (ORCPT ); Mon, 17 Jul 2023 08:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231175AbjGQMMl (ORCPT ); Mon, 17 Jul 2023 08:12:41 -0400 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CB5510F for ; Mon, 17 Jul 2023 05:12:36 -0700 (PDT) Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-3143ac4a562so2526392f8f.2 for ; Mon, 17 Jul 2023 05:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689595955; x=1692187955; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=OT3nNpOhhq2jFjD1bjRGMPWxdQKCqhAj/pYOGxaWcGI=; b=aTGvxLMv7SerldCRAktF0kCNWvtj4AfJfz8eecxAFyz6jxqesIadhatWFbZUTilUgE Yxccd413ODkGpIRCeRdSHk5ekmGJE5hx8TJRkQ4kS7QrAR4UmaqG/GYgQPL10hEnkbsE alhZm4bjT6AsALos27yNjDAotLSTswfizFbpY+v+ThycuSs3qSAo+S60/goA75RL5hYT ZbudBfG6l3r4sSSJvclaCMz8bOySTLSl+wEWBJVI6DXkvaHS6AdE7t98cGd996YJWd8y 4+dXRGcHAKnxw+4HvZFTPcBfeedam4tcbjVCbS5HDaIEoIwTWHnBDgzCF/TiiCAUy7Yb n8kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689595955; x=1692187955; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OT3nNpOhhq2jFjD1bjRGMPWxdQKCqhAj/pYOGxaWcGI=; b=KQKeFkMtcy9y3/4axjmZ52MMFp8+XI5+UOMkkfMl2pfu0wvvQvDF+7IWOUnnBrudCU zNZlZS8yVKB/zZmFpP/VA2AdaoN4vTiFoUqTkWJoup/UwJ5kvysWESt4WxgG4X7XzGNn Id9qUC6+gIq/4oTipmQacTwVEyjDjc+IyQHQJVuskA/dY6EufkCeR7Eq4mnAUxO5sL2Q UcDMOIFmNdLwT75YuIxnbh5GtFC8ufKVq6XSor+5ycJ2LNH0smuQLmT2kigYM0QUFO6I bJ2Km6EOm4hkEkjvUChhIzzjf+Dg8tq6G8vY0gzelaeFX/z/6xTmGsVK7fesU6zk20Fj 8Wsw== X-Gm-Message-State: ABy/qLanbP/p+cFN6jSrIeM5Md0FvinHykN4fEvzNvWodJti4eZBQjy+ MRHzoITzwoMjBP4Hhj/k0X5fOD8PwY2QR1NpTLt3KznFRsscl5joVaQHLlMWVtoqgcF69pKmYLZ ieSS0QvW5J7QNBTNJCGG14Mx0+bRXZ4qX1EyljtLfk9oRfIb0oVhFc30= X-Google-Smtp-Source: APBJJlHKnzqiPbswcbuMyq7WhyB6gsyRTil1XL2lnpf2jJvmJT/gAIeDsNufUd30GIdDCyGiYrkisnmTgQ== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a5d:49cf:0:b0:314:23a9:c56b with SMTP id t15-20020a5d49cf000000b0031423a9c56bmr84516wrs.7.1689595954430; Mon, 17 Jul 2023 05:12:34 -0700 (PDT) Date: Mon, 17 Jul 2023 13:12:29 +0100 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230717121232.3559948-1-tabba@google.com> Subject: [PATCH kvmtool v2 0/3] Align value generated by get_ram_size() to the host's page size From: Fuad Tabba To: kvm@vger.kernel.org Cc: julien.thierry.kdev@gmail.com, will@kernel.org, penberg@kernel.org, alexandru.elisei@arm.com, tabba@google.com Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi, This patch series ensures that the value returned by get_ram_size() is aligned to the host's page size. Without that, KVM_SET_USER_MEMORY_REGION could fail when passed an unaligned value. Changes from V1: - Factor out code for getting _SC_PHYS_PAGES into a function (Will) - Apply the scaling down of the ramsize to the number of pages (Will) Cheers, /fuad Fixes: 18bd8c3bd2a7 ("kvm tools: Don't use all of host RAM for guests by default") Signed-off-by: Fuad Tabba Fuad Tabba (3): Factor out getting the host page size Factor out getting the number of physical memory host pages Apply scaling down the calculated guest ram size to the number of pages builtin-run.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) base-commit: bd4ba57156dad39349edfb2338bdc2f4ed3c0bae