From patchwork Tue Jan 2 01:58:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759362 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857650wrw; Mon, 1 Jan 2024 18:03:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEibyFAIM24Bh9njFdaEIRpTvrBas/fDUpMeTlJ+miCBhAh8DMC0D2TEUX5icpOrrFnwil X-Received: by 2002:a05:6214:2341:b0:67a:a721:d782 with SMTP id hu1-20020a056214234100b0067aa721d782mr24261487qvb.104.1704161033059; Mon, 01 Jan 2024 18:03:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704161033; cv=none; d=google.com; s=arc-20160816; b=I5CrsT12SRvUHCNjAt/wZqSYqfVvwWoABUi80sGsO2xAgiq4f27hR+C0icyzipyo/Y ZU2g/BK5HvrCey8gfxp4BHd7LXvpf1WogwlA9MemFxeEfuRMAR7/BHypbixonLWk7HUf 00ZL+/AX/FfbbLjRmoamjhMWZvqC0nnYGJKPUmfmtrdqlHhvyVx4JCp6f2aKZBsVP1Qx tc+dd8AcdeQoqQs575Fe3FtojX3fiffZ3w7wN9m0nmVegxz4VQuoFI5HJao26J3SuKRN ai0AqZ6bVM5092mzv+SjUM+WGDYnrOOjeFwcneuq24MEs0kKHT/tHPNKBQlExf0rY4tR YSBA== 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:to:from :dkim-signature; bh=cKA7tvrOkGtPLWpEPatX1MbkSLxefO/Qsp6i6MEPEuU=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=Zc3tgMWf03dmvJk7i6FsMiWWIOEsDAjGb0IuvnEKqw0VgMhIgTO43RAG4+7s8STz4V 5aqE/ZMPZpZs5tUhUMSulg61w/PkwzkeuHmFxbCP5hvyfmqHhRIKeD3z4fLNCBwCxxKf IpEw7nV7fB6TKAnMdUmqKMt3kH+IW1nPiO1ovLwdZqSrUhVviQSP5zDF13i8kG+uRIoD a69eRei7Mz0c9vp0R6GTKQfOIdJwteFkotxJYNmVe9BcSq7MMWymRihQ6yVidftXJlif yWnmvj9rngBHnZ7S8vFbDpT//jpRlhNW/SINU8WH64yUpjpDplJxFjd9jS0gV+lzOlbX dI9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xbv57JQw; 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 m25-20020a05620a215900b0078154e42cbfsi14971782qkm.770.2024.01.01.18.03.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:03:53 -0800 (PST) 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=Xbv57JQw; 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 1rKU3u-0004Aq-Ge; Mon, 01 Jan 2024 20:59:22 -0500 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 1rKU3s-00044I-IZ for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:20 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3r-00076z-0X for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:20 -0500 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso7047200a12.3 for ; Mon, 01 Jan 2024 17:59:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160757; x=1704765557; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cKA7tvrOkGtPLWpEPatX1MbkSLxefO/Qsp6i6MEPEuU=; b=Xbv57JQwqEVC7t8eeKcadGzP8eoMWfKouwFxmMHCgmBpH2m8mqSqWubw3n3xV+wAmr XIDABjfTqDz7dm6HXiJPxmuiaM5UOEDgp8e6j/x0dZ+oQYPqAIdcUDbXUjIsthJ2qJl/ oZDGOSTOrJuPQTkwlMZHDQlH4Tc54FrXHQN8UDnn/gOL5AH/F32ccLOjnrztg5VPUktS NbeXrwPfZxa0wRSMwTHnzmWDKeNXXxEWJ7iTU6iox2nLxXYBWJKQ1BBdEDp0TSDyE93L OJvsXWJkbwIN0evh0LWy+Zy/Io1CveslhPwMSgHD2bdLALDJl2hyJVNh7Sm3xJnJqfEC zdhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160757; x=1704765557; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cKA7tvrOkGtPLWpEPatX1MbkSLxefO/Qsp6i6MEPEuU=; b=aKfbOYW0FiW/KK3rRopA79Ck1zq3vWO77wF+W2Ix0r0CWaXNSOqpvQeV/6/YhLczqw 6Rz5bTghYFYLiehAluHFnNeGgVYNbIiFniKMwjpK0iFpWIRfxG1n5TCdr2s+2Ckpc4ss jftcbm0mWC9UwLDYKNFt4uZCE2MnDaSRfWpGqA+kIDcQRgh7TaaDWRDT+t+Tw3202Aet u7w13oYXohlwJ4GvuL3e4Hrb5a14gAf8/CQm5SLE6/ONK429RTF5VCKiUMksRk6rjduR H9NocqlU8ay1auIR2yaugB0ePxjolF0PXcs3quWzAG4SfuC+9yAQsEtEeHSEEVDKcLoA 0Qkg== X-Gm-Message-State: AOJu0YxgfrsEkbtu/K2FUKomz7L2qKjAXg5/u8YwHd7UHjhc4XNlZ2BE pESURMkW5UnjtnYo9G/aSUG2qyikPpWbd8k7C13QO6VfY+4= X-Received: by 2002:a05:6a20:321b:b0:194:228d:c24d with SMTP id hl27-20020a056a20321b00b00194228dc24dmr20490371pzc.42.1704160757558; Mon, 01 Jan 2024 17:59:17 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 31/33] linux-user: Bound mmap_min_addr by host page size Date: Tue, 2 Jan 2024 12:58:06 +1100 Message-Id: <20240102015808.132373-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Bizzarely, it is possible to set /proc/sys/vm/mmap_min_addr to a value below the host page size. Fix that. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ilya Leoshkevich --- linux-user/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index d00a0d7d1f..d5f3fa26c0 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -904,7 +904,7 @@ int main(int argc, char **argv, char **envp) if ((fp = fopen("/proc/sys/vm/mmap_min_addr", "r")) != NULL) { unsigned long tmp; if (fscanf(fp, "%lu", &tmp) == 1 && tmp != 0) { - mmap_min_addr = tmp; + mmap_min_addr = MAX(tmp, host_page_size); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx\n", mmap_min_addr); }