From patchwork Tue Jan 2 01:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759342 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856224wrw; Mon, 1 Jan 2024 17:59:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLWvzRMYvjv+UVkZ092YejetIGtfPWJ8MeHsvfM+ZGh0ZTl7jrHdWmWvzAgcmrP+MA0Vus X-Received: by 2002:ac8:5a46:0:b0:428:1915:57f8 with SMTP id o6-20020ac85a46000000b00428191557f8mr4977264qta.121.1704160791524; Mon, 01 Jan 2024 17:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160791; cv=none; d=google.com; s=arc-20160816; b=lORLHaK/tJcRBSORyPK/RRQZJWLKo1zemhIJDySlu4Hxs5Sk/j99eGewBHs9vV1BRS oXd/4C+w0qOhibHePByp5oBGRn86hrYLovB1EWKtNtmM7TKyQGxka0yUM84SFOHXs6s3 cqNVdclMYx6cSlWFfAAJinS8IFg2kQsyqPfi2yGpI8GwrhwZZZMT81WPUckq9cGU2hrG R5pgqyUeotE5Ad1la3nZfu9XkK09gV5BONItFzZ3SLj3YrO9SjNhJbWkl+FgSRulkAnW XANRtEUppG8y6JgtiT+5PbPVCJfoREpYHC29QcB9zicaDKG4mrOGGaMQc7WWQks7m33H J70g== 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=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=qG88rcWMaed1u0MUMi+x0Lf8UkdX0DkhoANmKKzu5M3PG3qx/KwVs95yGiiK1o/Wbo WSZAL7wgzqDZ+B5XS2r4545SVBagETRPqIeb92UB9TS6XAuYu2hxfvbV1Y2URFSHPv6G c/zsvqfMdhNZsPMQLpe4yObMAy5dwaaORj13G6GjOmTieP9K/jPqbHshW4oCaUKrwXKH wtSlblfNRUgaRm1cy2sMx00NRloSoPl9hLyvYFfobigSZEiRCkyFtrH88If+J9L0mK2L EpvPK0xiC3xmCuJduoDfijd9xcDahoQ8ix1h6LOxQpJJKPhzdb3X2i5C3m/GsI/l5Gxf fx+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GwM1sn00; 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 n1-20020ac85a01000000b00427913eb778si26379230qta.749.2024.01.01.17.59.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:51 -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=GwM1sn00; 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 1rKU2t-0003Do-NI; Mon, 01 Jan 2024 20:58:19 -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 1rKU2t-0003DM-37 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:19 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2r-0006yI-IH for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:18 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6da55cc8e78so1691795b3a.0 for ; Mon, 01 Jan 2024 17:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160696; x=1704765496; 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=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; b=GwM1sn00+uFANYpDwleArGWWQbKqb+x2Ye8uELpxezt6ly8lDViscHGf9GLmTboUnL IZg+/ZPrF7HxqwANSXE6SNHe+X29hKHKy8Z38DIV79ry+DGppCeesqdHLq8eHiAJLd2Z ybZBziNa8SDpM0KVHQ3Ck8ZfvzUfeLdCjfLHZlC3StYzWyF1QyVhRMWU4FtRGOTwcGv5 cQ3rgLRdHtvxR5GB2oFpX7VaR73saI5OxTKViJwJiFl3i4KNP+a8hlf6Yc/VuFQJzO9I ZxvuCyprDe6yF8Mj7ChPn0JaEpOGzltnLKDtcoPwPNb/F9GbCDBhM0zoCcTxio7pBoXd /4cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160696; x=1704765496; 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=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; b=xRLLyMUnEdIBmoTBxLlntkS+dBkeWBLq5GqG93Uootsk+pV7bdrQ3+KNLGc2WpFp5i Q47kg3anNqHsJFQO957a4JO3U3C41Eem88oTZ7duzzyJxnBZX3IZji88c5Csr7CfoPYr qK924bpYbHJ35ykSt3iu+Y4CjHa37ga3QVIYwobsDtCz2/rB9cdTQ2QQLY9ly3CpSHo7 u8aY9ayv1kQvTBcJ1D5LCOX69sdGLtk/0Pm/boI1swjlUUZ0sHFck2LEM2Ad3R41SD90 WC80RNVcgZ78a10FDxi6vHOoTVqJHdi/OktlN51dQWbZuBUDb6NU4ZQ7fGQkT8o86gbu KBPg== X-Gm-Message-State: AOJu0Ywahs/kArV8N7G/v6MEpw9J3/YjwqgfzPSrzsmmqLf2sZn2xnwF llPCSOqBUbH6s/Jl1WY9G26Bq8IGtJyEky8ljsO56Wi6Kvg= X-Received: by 2002:a05:6a00:6a04:b0:6d9:9277:b702 with SMTP id hy4-20020a056a006a0400b006d99277b702mr15270836pfb.1.1704160696186; Mon, 01 Jan 2024 17:58:16 -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.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/33] accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect Date: Tue, 2 Jan 2024 12:57:36 +1100 Message-Id: <20240102015808.132373-2-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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 Use qemu_real_host_page_size instead. Except for the final mprotect within page_protect, we already handled host < target page size. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 68b252cb8e..69b7429e31 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -651,16 +651,17 @@ void page_protect(tb_page_addr_t address) { PageFlagsNode *p; target_ulong start, last; + int host_page_size = qemu_real_host_page_size(); int prot; assert_memory_lock(); - if (qemu_host_page_size <= TARGET_PAGE_SIZE) { + if (host_page_size <= TARGET_PAGE_SIZE) { start = address & TARGET_PAGE_MASK; last = start + TARGET_PAGE_SIZE - 1; } else { - start = address & qemu_host_page_mask; - last = start + qemu_host_page_size - 1; + start = address & -host_page_size; + last = start + host_page_size - 1; } p = pageflags_find(start, last); @@ -671,7 +672,7 @@ void page_protect(tb_page_addr_t address) if (unlikely(p->itree.last < last)) { /* More than one protection region covers the one host page. */ - assert(TARGET_PAGE_SIZE < qemu_host_page_size); + assert(TARGET_PAGE_SIZE < host_page_size); while ((p = pageflags_next(p, start, last)) != NULL) { prot |= p->flags; } @@ -679,7 +680,7 @@ void page_protect(tb_page_addr_t address) if (prot & PAGE_WRITE) { pageflags_set_clear(start, last, 0, PAGE_WRITE); - mprotect(g2h_untagged(start), qemu_host_page_size, + mprotect(g2h_untagged(start), last - start + 1, prot & (PAGE_READ | PAGE_EXEC) ? PROT_READ : PROT_NONE); } } @@ -725,18 +726,19 @@ int page_unprotect(target_ulong address, uintptr_t pc) } #endif } else { + int host_page_size = qemu_real_host_page_size(); target_ulong start, len, i; int prot; - if (qemu_host_page_size <= TARGET_PAGE_SIZE) { + if (host_page_size <= TARGET_PAGE_SIZE) { start = address & TARGET_PAGE_MASK; len = TARGET_PAGE_SIZE; prot = p->flags | PAGE_WRITE; pageflags_set_clear(start, start + len - 1, PAGE_WRITE, 0); current_tb_invalidated = tb_invalidate_phys_page_unwind(start, pc); } else { - start = address & qemu_host_page_mask; - len = qemu_host_page_size; + start = address & -host_page_size; + len = host_page_size; prot = 0; for (i = 0; i < len; i += TARGET_PAGE_SIZE) { From patchwork Tue Jan 2 01:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759358 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857566wrw; Mon, 1 Jan 2024 18:03:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzH7S7P/z1Gt6cqDuM5T21EJddW/yb/ubv13AvhYfMC6akiZfXb8EcsY31G4+NtCl14YvU X-Received: by 2002:ae9:e70e:0:b0:77f:604b:b269 with SMTP id m14-20020ae9e70e000000b0077f604bb269mr17188273qka.156.1704161013449; Mon, 01 Jan 2024 18:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704161013; cv=none; d=google.com; s=arc-20160816; b=UjvbfWm7Ed96nXWv+khwHYF3PXvYeBC1myS5CNUw939UObon/mE5um8hwMX7tXElGX vk/wLS7w0qrMZDLBFTkOS2EKLj0LT8P1kPlrE7XmuV13uUqNBttc0/AaWOtO0zhSjXMs BR4P5remEdbpajlOFGpjZiefhcVBz4/S7Qe6pCDlkPNC5TXP+8NMTs/JpAbvjWNdw3fJ mpuvIzTX92pYD005Nz5gWnJnhTupT8SpoRx3aAF564+wvZH77/l9PG0VWwd84IyXtWCu P9PKMEBoXSGwCXDHWueP+lsw/E/yVQpMU4iDMDFmib6FN+Jx1UtarHJjUQ9Hia8X728B J3UA== 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=l62Z9VXoyvTMtkttPIPmMaK8R/9tk3/QfUP+wlVNz/k=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=b3G27dbpxlK32GN4AqWp1vq9aAWG5k9qIrYpIvSU9x5eGEASO3UNehd/+mwx0vH4sW VQ16uW0KVlgeMkJQbRgfw0bsU+foNKZpTZZKSZYjDcu5XEwsTHjI7JEaoxoaQBAvs8PF eHH8DQsQFvtmA4Z0Ph3hjBYi/WjsmUQnc+flo5ARi9uLI4rIn0A1Xd29JtLQIUKhVXYm 7x+4sy7fe0siDGhUzZO1e1Ei9SRbfY8RL22UNGOhNNxPHxP5yOstvR4F+oqadcJ8Bj7+ LQfqMmYYtMrm/QYjbbjnCCkoctfLUgLapjSlvG8DQqN0qenMQOdvzirJgzp5eFFq34zo KWGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y4Amshy1; 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 s10-20020a05620a254a00b00781b518af18si5010586qko.709.2024.01.01.18.03.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:03:33 -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=y4Amshy1; 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 1rKU2x-0003Ea-9K; Mon, 01 Jan 2024 20:58:23 -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 1rKU2v-0003E5-UB for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:21 -0500 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2u-0006yU-Dp for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:21 -0500 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-35feb61c91fso30808955ab.3 for ; Mon, 01 Jan 2024 17:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160698; x=1704765498; 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=l62Z9VXoyvTMtkttPIPmMaK8R/9tk3/QfUP+wlVNz/k=; b=y4Amshy1Hp9nkLEcpNUUAsO/SoCyVfNmgYVZhmpwtW0lxL1xesQwmKsR5ZMf0lOgMz hWKVHDFBuT/R28bpz9WGHRtOdwDMn6XDNbBS15C+iM9SUUpY9gvtlt8s33ro2jsJO/I/ EN+tl1wIfFEv7IYun6REkwyLiLWE3XHfy2DPAVuOdwOZ3BuLUmXBToAF+ge1RgEjUAg0 gHlIcyc8txcKXHClJbPqxwQCNZzi+KWuiVww085DTeJ3Ao71ma/OzXMB5/9hBSJKHR+m zr1b03jjd2wKemSnTyDxb1ZvdKS6L+N1B8kZoktF0k17ANmINzW/O9tnd0q12oSqNe8H 8uFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160698; x=1704765498; 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=l62Z9VXoyvTMtkttPIPmMaK8R/9tk3/QfUP+wlVNz/k=; b=DVIjhloKMzMWCkGRZgWr3z0oEdVZYhOGYCa77uXeoIVUTx2791/DdUg9RDijclPLoD ruYL4JGrjftiRiZuRgKmQ+hYKCfdeZZfWZ0yLbLyRL3GlTb0xWk2vh2tE0WqjLISM6rn EILzqPDkgYVcXsXkdJD/nLWgrLCye2g1SX1B3i7V41AnoBCWJw4KmW9bosQVkKqssq9F 9/lIaVpv2LuG8WD3iA6ZF2BbcfaIkuP0q7S6AfWHRpISkOwAHSzivUPnz7gPRSCl8jGu Q/CcclMucMBls8exWXMgaZAypn+TrRLN4QCEd0LW/CWRztrIrkn+OOb8tPYJvxSTnmwQ 0iZg== X-Gm-Message-State: AOJu0YzemjoDqrJuzJ9+RwE5kj9GeQFp2b8nKz/ac78wTry3SCXvRcQT 7MSycHJd7unJCom2FDr1zbTjeo+kRikFKWOFTJqUGFbpaJg= X-Received: by 2002:a05:6e02:1c4e:b0:35f:d727:1dba with SMTP id d14-20020a056e021c4e00b0035fd7271dbamr14346991ilg.63.1704160698152; Mon, 01 Jan 2024 17:58:18 -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.58.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/33] linux-user: Adjust SVr4 NULL page mapping Date: Tue, 2 Jan 2024 12:57:37 +1100 Message-Id: <20240102015808.132373-3-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::136; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x136.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 Use TARGET_PAGE_SIZE and MAP_FIXED_NOREPLACE. We really should be attending to this earlier during probe_guest_base, as well as better detection and emulation of various Linux personalities. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/elfload.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index cf9e74468b..f3c1e0fb64 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3911,8 +3911,9 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) and some applications "depend" upon this behavior. Since we do not have the power to recompile these, we emulate the SVr4 behavior. Sigh. */ - target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + target_mmap(0, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC, + MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0); } #ifdef TARGET_MIPS info->interp_fp_abi = interp_info.fp_abi; From patchwork Tue Jan 2 01:57:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759339 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856135wrw; Mon, 1 Jan 2024 17:59:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVwFPy/ZdurEMhRQWgepriOl+K8t7Ccild1iCbS5tp0aQTOoadgJgVHc2NnH1TzRUUXGET X-Received: by 2002:a05:622a:249:b0:428:1e58:fbc5 with SMTP id c9-20020a05622a024900b004281e58fbc5mr4516707qtx.125.1704160775463; Mon, 01 Jan 2024 17:59:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160775; cv=none; d=google.com; s=arc-20160816; b=JgRjJxOmmJYLAwyQniagAmjSRn5guRSzictnI7KSqO4DQRdmDRwgnk/f1XfaDpMoSI qZvZAZ8s8PqvKs+CmAkNcEnP1+pHYWJ2f2ghccnqKWwi6OLmUPQZc6jXO7TOK6n5AEYO WgsIcXiPArB3Bim92TsSVLH0uTViLhsh1hJyEUtYdM+dVNhXHWF/MJG+enk9gSPrq2fr ubd1dqhR0G1vczag8c35xLwOK/oeIRWuv0DPFuHZObgCzqpJShdc+RHOH3tvAtqfzDsd USz+oVVDIkHQxwqPaXHLoB+S9Mx013PdZMts8YmCWtO2wMwy+ug57ej39zrGN7GpU87I QELw== 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=3V4UcCieB3zB1M+n0kFdLlq+X9hWVNWezL6ktHMn9HU=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=ujdtnTzY1Zb3IbJJBWpG0GD4Lbdgla46EZDlUJzY/9dOONxyYGC3AKvhdWGaQbZwA0 1CYlfL0SI59cxJ8QsygNR9fAPRJZ/uc6Bg3LZrOAuRm+iTl5pPlGRmuZpO/2BqdCglfj CVg+ytGDMaqhWC4vcNdikZBUn9Rex5OzG3ct9B2JWc9NQlepA8dI+1jtLvqDlf+9DRlo UCb2KRQsDtqo97as/ZvhCbaEGWE2ZMU+rJ5dX++whKCqXpTEsqpFF3ko86W6oIS7M6he vBQkPPScfqm4iL7+NRXKbZWY9STl8L5kaxA6N1hTEECh9rw4wQbrjOOrlmeLIzyNVZod lOXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="QOJ1/peM"; 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=fail (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 u18-20020a05622a14d200b00407dd1bbbf5si26688489qtx.368.2024.01.01.17.59.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:35 -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=fail header.i=@linaro.org header.s=google header.b="QOJ1/peM"; 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=fail (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 1rKU2y-0003Eu-Dk; Mon, 01 Jan 2024 20:58:24 -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 1rKU2w-0003EG-P3 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:22 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2v-0006yh-9w for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:22 -0500 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3bb53e20a43so7596303b6e.1 for ; Mon, 01 Jan 2024 17:58:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160700; x=1704765500; 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=3V4UcCieB3zB1M+n0kFdLlq+X9hWVNWezL6ktHMn9HU=; b=QOJ1/peMffkk8WtK+wkUiIdjqz7Ix6/gRwd2bpcT/+pTwGm4tuGhQXlni/F1ZmKxn/ VmoqK4TMEt2hCQYfGVFlWNuginiWMM1FWd4AtYpC8RSSBx/rhcHreS3+weO3DepDTQ26 nAJu53DLDbwhh2mzQcGQV90sU+ZDSBbjkf5kOKCTTD41ibaS10sgPsIPzr1edv8DB2Fp ppQR5w/uG15CiZWxf8+DxO0nw01Enec+x9mjU5A3wR1Cgp5V2+JQmJh464aKkVtquuEg JKxabwoa3dc3gwZv6S2ob3CShOCV9xteUIW3jXXZcX2jdB/tyS/J8GcAZmEHhU3muVQM DO1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160700; x=1704765500; 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=3V4UcCieB3zB1M+n0kFdLlq+X9hWVNWezL6ktHMn9HU=; b=BSw7t6Kjt3XOMjrF54aDNzqxlGR0gK9Z6mU3MkubQbmCA+AGE6LFWXp9mn4jhHy/m6 coQcPLYQ4tilw58sbeSZiTup6GKiE/5uHKJH0C28tuxbTXYb1CNEx2pJJlaSyJr1cAm0 GeZi1FNUy429dZz31WGZdO7pCqz/v8RBCR62CDtz6WH0nTNrEgO5YX49ef5kO4vdUTlD x4vxOBr+AFh+Aw2z1TMMA4/oiiPPubxTNfbzV9pa3L0xIPmRU9MQ7qQMCXmxq8jj0Qyz 2RDKn7qCVekS6nOXx5rtA78owJp3p++sr0QeL+RhXxCC6VbNHcTIVRbZWfGRTPA1CzYt o5RQ== X-Gm-Message-State: AOJu0Yyper52RGbxBWo/Palq1AMlOhOYxDowx/2E92p69O5WAtVncBWU 3v2Hwz2AasTQ2oB9/BwW21IUTfNRU8aG4xuy0M3NAPlzmd0= X-Received: by 2002:a05:6808:171b:b0:3bb:e8c2:e29a with SMTP id bc27-20020a056808171b00b003bbe8c2e29amr6900189oib.101.1704160700071; Mon, 01 Jan 2024 17:58:20 -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.58.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/33] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base Date: Tue, 2 Jan 2024 12:57:38 +1100 Message-Id: <20240102015808.132373-4-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::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.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 The host SHMLBA is by definition a multiple of the host page size. Thus the remaining component of qemu_host_page_size is the target page size. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/elfload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f3c1e0fb64..4df565d64b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2892,7 +2892,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr, /* Add any HI_COMMPAGE not covered by reserved_va. */ if (reserved_va < HI_COMMPAGE) { - ga->bounds[n][0] = HI_COMMPAGE & qemu_host_page_mask; + ga->bounds[n][0] = HI_COMMPAGE & -qemu_real_host_page_size(); ga->bounds[n][1] = HI_COMMPAGE + TARGET_PAGE_SIZE - 1; n++; } @@ -3074,7 +3074,7 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr, abi_ulong guest_hiaddr) { /* In order to use host shmat, we must be able to honor SHMLBA. */ - uintptr_t align = MAX(SHMLBA, qemu_host_page_size); + uintptr_t align = MAX(SHMLBA, TARGET_PAGE_SIZE); /* Sanity check the guest binary. */ if (reserved_va) { From patchwork Tue Jan 2 01:57:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759333 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5855992wrw; Mon, 1 Jan 2024 17:58:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSUOSsOgAMjfZ8d3o3MBdD//qpoD0UkU1doCk153/o7JCGdt7rtJO6AWqW1aSY3rwPfqbK X-Received: by 2002:a05:622a:11d0:b0:428:24b5:3af9 with SMTP id n16-20020a05622a11d000b0042824b53af9mr2336699qtk.90.1704160738627; Mon, 01 Jan 2024 17:58:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160738; cv=none; d=google.com; s=arc-20160816; b=FsGbzXF+vUg7sqIhx4MYfuoCF4Vs5HS2gZD0gmSv0pYZ9rvr15dsx1kODlprN/uVS8 ObBoD5tpRQc9iHwNjOKqbRaHWEqwtnvmbXWaoGxE/Tgr42V0BrONJCYDnahODAC1WcrV ncXFP7Oa8zZXZ8bFaghsh6JOBk8h60f7SOBcXsFte2RV5Z1FyPYenAPE3Kqt9Q647hP8 C6be+50AneRLz+xSMhtEV35NsgmwMso3S2r7GN4aTlVmARWj3Hwy4cK1tVRWJ7chfIqN DtbWbUqTA8dYnZoqfZ94w3asPtRIt3qUnX/NPk40lA5Df6FmhTDLNNHG/W9yln74oGHg AI0Q== 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=HPXK9kHV+jGx1v/PMtKU+RQr0a5HO3R80iapTrtjCrM=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=g4HUTPFZkUWz0shcnFVFczyLVWk9rqgE+yaH22X3InMXDEnzSFKL5FmpDtCknTdu8r +is9G4xKwJ4Po6jdeohFT8z1cx4c37Fj/WHV1xECi1dta589EPvJW5G5yih0c3t57SeQ WF7KAXVUYQysEjhS4UgE6Eb0O8D1yttLoIHXeTmOpYCRjkGHre83etG3lQKhu28EdJRu L48xf4XQKBmopWCr6qYtjA/zojDpgJw6ZwaAaJ9eQQ5jbo1rsO6QAKHDGGD90bOvdWm9 h09Jptw0HPoSriqfAkOPcK7fdpVJ34q4f9PwI2ZnY/j2/7q6DFq029ImuEVVq8YfVJnE Y5nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wAZ29ia+; 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 w22-20020a05622a135600b004280f8b8129si6606992qtk.609.2024.01.01.17.58.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:58:58 -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=wAZ29ia+; 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 1rKU2z-0003F6-Vs; Mon, 01 Jan 2024 20:58:26 -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 1rKU2y-0003Ex-HP for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:24 -0500 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2x-0006ys-2p for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:24 -0500 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-7bae735875bso422555039f.2 for ; Mon, 01 Jan 2024 17:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160701; x=1704765501; 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=HPXK9kHV+jGx1v/PMtKU+RQr0a5HO3R80iapTrtjCrM=; b=wAZ29ia+o28Vbk/E3+aA8CMLwPSNXlbbEDb1V3okaFDhoB8N9SlcWu/kvA5TSloPsl goEYU2rhQGf9n1oxznHMvEREwrV8TzjCoo0hKHPSQLQCAK/R85m3F1d6wztQmKTb4NZP T4sB4w51fTahoSPBkCLvzKXqhbqZPDM4iNeZ0JwBGwxdMFJZ3BsKcawLepWTcQHyPlWn IFdcJ4XlpZSK6fxbGt3QwVezxc5w0GpvLArGC7+CLu3xQa3xBJeViVXujgarrSWUOMzd UMBKXSc0ptz5EYQVTGbrDeVvFtEX4zD6Z54OwNjIEawWk8m4u7CDI6bSkQIxWizJ6YWB yCSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160701; x=1704765501; 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=HPXK9kHV+jGx1v/PMtKU+RQr0a5HO3R80iapTrtjCrM=; b=Y/SAWzu8iRrv1k3ysmNvlRl69XMdocijaI3r3Uml1kHHYf+HTa1qgeekbrPCA9cQd9 XKFpxx9jd/kcCjdSHJku1rhJvu3bh7RV490XVQtKowUXnNP21yPk0hkntZ46D9KashOm uJ1bgkEoFW7UfGZ63rXlOmGHKqrR8djgCso9xN3qsDfW8fZsPzQ1FFYjwZLFVvB76LPE HBMHr2W1Hqxz893rAAKlmPG1Y6L40fGaSy1CkGg56tr79TDa6aSBImcaGVwCUu4r1kFu RkGVmIT+TldKXFigtHa9FFO3MddP9LKZyI2HbPQFwvyG+jHhPHCuGwLDTZxn4t4qUVrp kBPA== X-Gm-Message-State: AOJu0Yxk8uAAeyi7imHe1m9SHaE39Jp0GrOtkoMhOvfry2ixWgiK0A+U aa5bFKaGgzbl5llYK4IiZpbMMoRE3vcyiwBVuLigWdqk5VY= X-Received: by 2002:a05:6e02:1847:b0:35f:b93e:6a7 with SMTP id b7-20020a056e02184700b0035fb93e06a7mr28136922ilv.58.1704160701787; Mon, 01 Jan 2024 17:58:21 -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.58.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/33] linux-user: Remove qemu_host_page_size from create_elf_tables Date: Tue, 2 Jan 2024 12:57:39 +1100 Message-Id: <20240102015808.132373-5-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::d2f; envelope-from=richard.henderson@linaro.org; helo=mail-io1-xd2f.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 AT_PAGESZ is supposed to advertise the guest page size. The random adjustment made here using qemu_host_page_size does not match anything else within linux-user. The idea here is good, but should be done more systemically via adjustment to TARGET_PAGE_SIZE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/elfload.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 4df565d64b..c166faabab 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2678,13 +2678,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff)); NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr))); NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum)); - if ((info->alignment & ~qemu_host_page_mask) != 0) { - /* Target doesn't support host page size alignment */ - NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); - } else { - NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(MAX(TARGET_PAGE_SIZE, - qemu_host_page_size))); - } + NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_info ? interp_info->load_addr : 0)); NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0); NEW_AUX_ENT(AT_ENTRY, info->entry); From patchwork Tue Jan 2 01:57:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759329 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5855966wrw; Mon, 1 Jan 2024 17:58:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9ekh93ro/pFo2Ak+99vukN/XTndNhA3uRm6ag3ccHJ0qQsqxUG7IvtZsGrW4HyBaSs7SQ X-Received: by 2002:a0c:c247:0:b0:67f:9538:4eb3 with SMTP id w7-20020a0cc247000000b0067f95384eb3mr18434331qvh.82.1704160732075; Mon, 01 Jan 2024 17:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160732; cv=none; d=google.com; s=arc-20160816; b=S8zKmKndPGTxSsCyftxw03yJ/4+1nknwkFWShlSRmakP62SHzaYLINi36xlWxESVz5 13+rf/AwvyGZgopff5jvoqUxLw2yNtAr8k/0lh3Mmil3EmB/BSPJWGhyhW6f5K3UwYc1 EvPJelkKKBfNjEpXlxPn+6RTByoJiyVtuWAKlUygmYNVE3d/GEdVgR9y3d4z2lo6bAhy zfYjUu4v39halZMIT7KZTUxgMUv34Egar4/rwPW8oeOLhQdbJF4xxsXbaD1cueWB50El r7bM9xWuP8IWv4RxWcYeJAZPfHfxYdfpSJ22ZfFPMF/IXiuCC73EM4CljWd3eBcceo8k Pd3g== 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=78dfRtxu5FZmtTcGt9x+K6ObYYej+Dd79lpS+g2uV20=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=AznHwIljc7mqxWh8g6GaWuBDEBCKx3yr7UEBjgM2CIEPyXSVEovdd+CuMcFWNJ7sjh v0QgCSnX8m0oRx3K9PzuRGSK2rseRZibWMHTwmfzh6VMPL8A/bSFVvPAPOfMrYnEF8kE Lji1nLetMR584ZETUMvV4WYooomB3ZK2D84ZrAJ/tqQEtX4NUV6cwPuM1S2t81NcHXi9 p0wZ9aba1mrtaUHEmTujjbRDcy8WFjW9neQuP8jclm2WY91rUqlB+be8UnkSw+BUuTdc BxaEVO5oNkunxIksDHHcrYpdDfe6mDybS8ORIAAMKlgfybUwMP6HfotP97wA43l+RyLA AB7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KoPkmBNn; 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 a16-20020a05620a103000b007814ea41d08si15836274qkk.182.2024.01.01.17.58.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:58:52 -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=KoPkmBNn; 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 1rKU32-0003FU-Nu; Mon, 01 Jan 2024 20:58:28 -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 1rKU30-0003FB-DK for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:26 -0500 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2y-0006zi-Vw for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:26 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-204a16df055so4590524fac.0 for ; Mon, 01 Jan 2024 17:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160704; x=1704765504; 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=78dfRtxu5FZmtTcGt9x+K6ObYYej+Dd79lpS+g2uV20=; b=KoPkmBNn3fsTzzfZDDBD4glny9XDdl280EzeqRlta+qii6RVGKRu2WVo59pwr0vGLS TyguKSLoNiKXI0Zj0v7YxptX0FXycyZ/qAs1GVY2cZFYKX7KcKOkivlcKXODD5pnRSgR zxr51xGeDa/xSkiuRndef+WN2/iSb5GClkA/FS8a8borZNyqf/4qKWxWivWT29VIZQ3x ehJGQiqcmsaP7LPSHbElyHJz5utRwix0Nle4P0JIJ68Izm7GRjJhI7l5oJOhxDyOoztZ YF6FrRByE35gO7dcwO7Cx16FNIFoSaaMryZoEuCw5/3wdEINRVQKkcD4jjK478AA8cLP YyCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160704; x=1704765504; 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=78dfRtxu5FZmtTcGt9x+K6ObYYej+Dd79lpS+g2uV20=; b=qH1SS7e8mJ/mPH4sLG+fnOT/WPzIi57Lj1zzVXREl+2MrSCW2Qx+jyeRWVzljMusZI n1Cx5uqR1D/T7d6mTSAMApQHVQjUxjpDz1/nQJZG0uYmD0/z+KjHJtGiUpRQtDQUrpqa tJjUx7vQK2mfsOoWnYVeJpkvByjCCDBo+EGYMUTy4u+9o5UMeal5Ek8OfFM7O6PJSQex kZDLnFgODJ0+TdaMbYLT0sxJdDU+NuJYPyp+trR0+6dK/ko0RrEKAf4Bdh1wCuVHbnTH YM1m+unoZ5nqpG8qO50K7OGY5L8XrQ+ehpQwtE1TX3zy2gKwH58jnLMjeGBjBGXGMufd 9HSg== X-Gm-Message-State: AOJu0YwOSp3IYIE6odHEXqltDx2XhaGZa0yAie9SvTqD+xWEz8BfdjoM f0tAnKb0S5fzmYeGgcAx2z26+hb1OAcf9xsITQSHBiUTgTQ= X-Received: by 2002:a05:6870:558c:b0:1fb:e34:e31c with SMTP id qj12-20020a056870558c00b001fb0e34e31cmr21828007oac.37.1704160703516; Mon, 01 Jan 2024 17:58:23 -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.58.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/33] linux-user/hppa: Simplify init_guest_commpage Date: Tue, 2 Jan 2024 12:57:40 +1100 Message-Id: <20240102015808.132373-6-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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.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 If reserved_va, then we have already reserved the entire guest virtual address space; no need to remap page. If !reserved_va, then use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/elfload.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c166faabab..96d8d4f84c 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1969,16 +1969,21 @@ static inline void init_thread(struct target_pt_regs *regs, static bool init_guest_commpage(void) { - void *want = g2h_untagged(LO_COMMPAGE); - void *addr = mmap(want, qemu_host_page_size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + /* If reserved_va, then we have already mapped 0 page on the host. */ + if (!reserved_va) { + int host_page_size = qemu_real_host_page_size(); + void *want, *addr; - if (addr == MAP_FAILED) { - perror("Allocating guest commpage"); - exit(EXIT_FAILURE); - } - if (addr != want) { - return false; + want = g2h_untagged(LO_COMMPAGE); + addr = mmap(want, host_page_size, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0); + if (addr == MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); + } + if (addr != want) { + return false; + } } /* From patchwork Tue Jan 2 01:57:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759353 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857332wrw; Mon, 1 Jan 2024 18:02:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKaXUrC0RIWCRyr4zvbzStrbIrx31OBZHGEtQYz0FhivCfpDo/3s9h+yau5UWJEnFjCec2 X-Received: by 2002:a05:620a:29c9:b0:781:5e3a:4d85 with SMTP id s9-20020a05620a29c900b007815e3a4d85mr11716674qkp.60.1704160974083; Mon, 01 Jan 2024 18:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160974; cv=none; d=google.com; s=arc-20160816; b=MIcOsADSObAr/FLyk7kGeHz+waERyax5pxKnsodRdVWpw1JHm0goXUWUgaJSkvBMfV FCjf1/NUqwUiLin3wMaQPHrgF/F8yaVgLCDeYCs7NoChfKz1HddZsMER2efvpXeN8Qjd uBBdZEswDYTLvySGEM+wrLg0MQbMDtr/KR3RpREJJNDLunxU+jgAbMpMwHIxkJaqzlMn QRxyxVdmE7bohhoQL9RDIdgBpEyxBU9zT8MZU3rwKCaA2DcZXDlDoq64JnBcMek/xK/9 NpF67J1oBn8Ar5YX6osno/i9/JhqkNLc7SvGzHlcC6CCZ/1YJZc+Q9OLlKUBQGTyMU4n 1sJA== 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=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=tYmxsT+qBpaxtMULyezON19oCgKYY3qS4rS0z7lClXQzbB/une9+fHpISIH7tZnLt+ 7RiZma/OCTec49TWogCbImVBwgbBiZf0+l+Ju2sleCVR41hQ/NBP9MkTmJjl5UeO4kRZ tb067ONQNeVu8ANpa9I8b5/A0j146a/s152cisctp/YyJkZTNp4Zm2gH6RsTCwhYwrfg mbOVWMdPlYCgK25BJH6aZjHTWzKl9Y+gk4qIpkw7XDInHQd0EWEVUGC761NUqdd5FWJa Noz8c3gnI37GCa4uxmdkN6MIycxtNAM2pbPee4C/wH3EzEgnREa4vks50xcv+RUdvtpx ZmKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iliY3WQO; 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 r6-20020a05620a298600b007811461931csi26675490qkp.160.2024.01.01.18.02.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:54 -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=iliY3WQO; 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 1rKU33-0003GO-MR; Mon, 01 Jan 2024 20:58:29 -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 1rKU32-0003Fj-N4 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:28 -0500 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU31-0006zz-9g for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:28 -0500 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-203fed05a31so7078298fac.0 for ; Mon, 01 Jan 2024 17:58:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160705; x=1704765505; 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=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; b=iliY3WQORQojL66bodB69O5hvrV+cAO2r9GuP4k77jVbyDV+zU+LBkfaFtzHo8Eb6o nTJb3t8kx3+UzJmCXDYv9nElccOaaKojTFvfgvgicZGLP5GftFB7SWmspzZZFR3G8sbP EzOgYRdBCxRPvTRe63Mh324Me3SDiBSfIwbtNqCFuFtHCfH1Hceh0ISOoPPyon31y0+C wI6S5C0oGMNIIiZbV5wjH2s2KrjYzm4sWIlSLNM+ny/9XssmquWp9d0BQJDb0/rEpaKb PlZbrsLHYQ1nAr+bD5eFfjcnDlOQcIbjhrQ92EFOg7K8m6wDULdnkkL2yOduZYAWj66U W+XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160705; x=1704765505; 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=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; b=N6zzk2d9laBlkO7CnuyV4gDpCmcIDJSTlNBIK0piLyUEez0rOz8RlsIMANXcbx8NHo 0YYW6Wsh0Jwro5E7rf0M0fCAMEVghsoKplSFsrzR8FX29rSfo38vheYSInI13p0nsNNy uk+28eKacVOl703LShIRNACWqNYgGdoNh4gPQSN0h+XrYPj0q5+lJnyN3ZPV3YDp5MJ1 6kuEThe1IqnnaSPD0O6Yzi30ysM3j0X3fzyWt1CIbgIpnwNDOKb7KEMuIfBSe1RNvxyD Be7Xl3sU96IB2YOy0rpOXVdShv5xYVVtf5jhHm8fkV78Wsx0GY0BTExt8lFkldFmbcZN DJiA== X-Gm-Message-State: AOJu0YzTsCwSbHsHBuX9w+Tt9e5mzYktEbYo2L6St6ePdQzcUKpx424T CtOSLFdziMwn0gn+rvc6ZRosw1J0pPL25ABcTWiImzgEmA0= X-Received: by 2002:a05:6870:e38d:b0:204:2bc4:87c9 with SMTP id x13-20020a056870e38d00b002042bc487c9mr18563179oad.86.1704160705491; Mon, 01 Jan 2024 17:58:25 -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.58.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/33] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Tue, 2 Jan 2024 12:57:41 +1100 Message-Id: <20240102015808.132373-7-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=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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 Use qemu_real_host_page_size. If !reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/elfload.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 96d8d4f84c..4fcc490ce6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1531,10 +1531,14 @@ static bool init_guest_commpage(void) 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ }; - void *want = g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); - void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + int host_page_size = qemu_real_host_page_size(); + void *want, *addr; + want = g2h_untagged(LO_COMMPAGE & -host_page_size); + addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr == MAP_FAILED) { perror("Allocating guest commpage"); exit(EXIT_FAILURE); @@ -1543,9 +1547,9 @@ static bool init_guest_commpage(void) return false; } - memcpy(addr, kuser_page, sizeof(kuser_page)); + memcpy(g2h_untagged(LO_COMMPAGE), kuser_page, sizeof(kuser_page)); - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } From patchwork Tue Jan 2 01:57:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759335 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856083wrw; Mon, 1 Jan 2024 17:59:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5jIdwQYx0vEn98OCnvjMLaIe4m9NUS2GYlvO68nsyTyabVl9pKzUoSCDUNBreuz892J4J X-Received: by 2002:a05:6358:724a:b0:172:ae6e:bdd4 with SMTP id i10-20020a056358724a00b00172ae6ebdd4mr18109586rwa.7.1704160762162; Mon, 01 Jan 2024 17:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160762; cv=none; d=google.com; s=arc-20160816; b=vBjWu/aK6vBkjKNenJYBb7ovCbZ7MQZpiEdUCze6M66opwGTCj+0rK2hQlb7myUyof Gkk9ivB7PngOLnyG4lpIGBfJfwjVNJ/B6ekSTWhlh+ozbrmpvOryHzyKRnUTm7xiI3ot z9UmGl2DPVTgErmfDBmi449TharQUJ1b6802yuQpvozTfVB8AWdjxjtuzQCvLb+P9Qbs LUv9axCadyUdO/Dfm6F8Pd1ebE4bs4qGslaPGSqRDYkkX/iZmSEuAk9lBSHvfe5aTy5H FBbMnknp1j5kVNum0AgnjnQ/Rvp/g1mlU7HJyIHbdO/lLJDlFnroz92u0XWH17PlzHG2 rsxw== 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=ZDwDZzgZPSCJA7Iemq6JqoeDjmqj1wl0Di9VaTuvxi8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=IwqueveAxUBwrN0hTo2TgMNymUwA6sMWhbtLMBov6PZpYLiuJWlHBcLMrH7zD1rAts Dd7ZaEn9+uBzP0JaJyjN2itHAUk4ld72N7p2UpEnEnWYnRyCJduPm0T1kko3pzGrd7Il 5MzLZhUVk16SeHMFGoUd5NmZBb87jjzzoP9YTCg5F2SRgNLe1b5J+PJbV8zH6YRP929I l+a26/7MIZg5G1yUtHttw821fu9FWaGeH+OEUlkHTgf6ySFTyLgwSBeJ4JGPKKOeOP+V TLDxffq3Gm+eBC00EBq4FWpBFjIid1oPXM7H8fl3JOyy1TPLb8DpfZEx5JEqPe+TW+Dg BVEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k+BMJAhj; 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 n19-20020a05622a11d300b004281a12a0d8si4659476qtk.280.2024.01.01.17.59.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:22 -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=k+BMJAhj; 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 1rKU37-0003Gz-8W; Mon, 01 Jan 2024 20:58:33 -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 1rKU34-0003GZ-Ds for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:30 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU32-00070B-Uv for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:30 -0500 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5c21e185df5so6727821a12.1 for ; Mon, 01 Jan 2024 17:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160708; x=1704765508; 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=ZDwDZzgZPSCJA7Iemq6JqoeDjmqj1wl0Di9VaTuvxi8=; b=k+BMJAhji4QtB6AlWIpbaNLh3A+Z1M+I4MDVRDlhV0r4IQGCdQFX4MBXTdUCN99il6 BDLKdN/PZrizXIYQQ6HQng2grRIjJ50ngsXg8xRsGZomChe+O9Kd++vAoj2sM5pDxY2Z azbC8D3gyqwlQC0SG23u9MInKDxS/a74V8qDOK4alY0zXduV/E5pKBXmMMtuZFrNjQY1 VWywLsaOPZIQCDXH/DRuuxTGQctUakDX2BAVeoBpqWzGs8cqptQTboilrk7ME4dUeluV BvkXrZbpbegJi1B9EveU+DKLVLvn04qHsAefMQkiThfFqUxum5gBiFrWgsnzgGPeISoU Mrcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160708; x=1704765508; 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=ZDwDZzgZPSCJA7Iemq6JqoeDjmqj1wl0Di9VaTuvxi8=; b=vMPOWj1LF204snVDetuRNIboGB6fZTSTYpGnDh0tsc8x8a/FI0gSa6iHY3mdT8ymp5 N+TgwRU+GZ1GY7DcZQMjpQnH7HldyHPNJ9GdIO05CB0jBN4d7RJ6knd8S0BIjnhaC9EC 1TomD2ekqbmMqdqivb/79f1Stp8BLyEH4E4A9FMx8WcZXNwMEfsswlQNAi87kz1/EAxx ewIxM7mrybO0VCaHaDjPX8NV9MUymxgckjpHIayGzMTvmXTtffrYmsFuJfwL5w7eN4G1 ZhBixHSERbBDgLli4lV6ulW1b58lrs7h1JbprOv9YcFtjI4p7fv3cDUw2Zt4/2hK5sLx N4jw== X-Gm-Message-State: AOJu0YxkYBpwpsWrnnSUO3W0D9L38I6tKDZyH0Kn37dgPrjxqlDX7opj kyrNPPQzCrvkRLNZAeGx+KgLAL4lMWUjMgGSXblPEUTP4Hc= X-Received: by 2002:a05:6a21:1a9:b0:195:d8d9:a193 with SMTP id le41-20020a056a2101a900b00195d8d9a193mr14856787pzb.77.1704160707759; Mon, 01 Jan 2024 17:58:27 -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.58.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/33] linux-user/arm: Remove qemu_host_page_size from init_guest_commpage Date: Tue, 2 Jan 2024 12:57:42 +1100 Message-Id: <20240102015808.132373-8-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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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 Use qemu_real_host_page_size. If the commpage is not within reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/elfload.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 4fcc490ce6..2e2b1b0784 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -459,6 +459,7 @@ enum { static bool init_guest_commpage(void) { ARMCPU *cpu = ARM_CPU(thread_cpu); + int host_page_size = qemu_real_host_page_size(); abi_ptr commpage; void *want; void *addr; @@ -471,10 +472,12 @@ static bool init_guest_commpage(void) return true; } - commpage = HI_COMMPAGE & -qemu_host_page_size; + commpage = HI_COMMPAGE & -host_page_size; want = g2h_untagged(commpage); - addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (commpage < reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr == MAP_FAILED) { perror("Allocating guest commpage"); @@ -487,12 +490,12 @@ static bool init_guest_commpage(void) /* Set kernel helper versions; rest of page is 0. */ __put_user(5, (uint32_t *)g2h_untagged(0xffff0ffcu)); - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } - page_set_flags(commpage, commpage | ~qemu_host_page_mask, + page_set_flags(commpage, commpage | (host_page_size - 1), PAGE_READ | PAGE_EXEC | PAGE_VALID); return true; } From patchwork Tue Jan 2 01:57:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759337 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856095wrw; Mon, 1 Jan 2024 17:59:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1ARfOKVth2ki4r2vhtEtidY1hj/jVZhKOLlTWWaKq97reUTKfGfQ3fG6QFL8vhzH2lqRS X-Received: by 2002:a05:622a:14d0:b0:423:a4f6:9a90 with SMTP id u16-20020a05622a14d000b00423a4f69a90mr24889028qtx.2.1704160763447; Mon, 01 Jan 2024 17:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160763; cv=none; d=google.com; s=arc-20160816; b=oD0ctmaSHFv8j4f4XqnXAY2A1a7d3LxHa+3/UMni81326uzAH5JxWf8IwNZjc/dQbp n3EzmKEcOpWvm33XOP0m/E5GyWmEcY9YNV7iEF8RYt3kMGM1bdHl2C0hE7DRL5d2S+8A eOsDnkTy+xIXZ3N8vx6WrvFO/4mKh+YNye67SlyPSkQdgHln04TDo442QTVqs7xFhmEA Y98nDo2w1mwxKMP5NbKRwVP3MDhU+WA2aq7++pWghzuUaunOUvkYD6socYm+TEXpN7XL 1ssn9OT5McofSrqZ1qMaJCo3UG06tF6l0ui71KtcFmGiF8qD/4f0xcVSaSvuKqZBwwud AZNg== 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=6oj7N0j8k7lH/G5CYw2mFZpUqD7q71OK17K96jHMboM=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=w/ZJyCm3RGb2uSLMs/TxMaylQdmy1LuE49fe71SbygyrjlqVfuNn6kVgHRjzJV1SFT hBYO4CTg8kHDROkBhVyncxD79QXa7e8I6V8gbdGPdZfzCUkAjHJ4nHXDnjqn2eLwLIpy sHs1wQtaG793Zhe2osXA9Z7HZ4LpKYzTs2tm8yebbsaCE0kNob8WiRgpRWWYNs9vD3Q4 yUvXYbe5MxvD5Y8ag2LxzAeK2NBJlmFpSKMW73MreskhdPRvyxHFez2f6RZobUR8VlaN WVHeGtdz6t622ZjWYomnzSq0HAS2aofLSoJzzf0ZnaTxzO8FQ6Wx/53RHylOtrDx+nN6 pfRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DPHKoT8r; 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=fail (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 u1-20020a05622a198100b0042370a65e34si25749556qtc.572.2024.01.01.17.59.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:23 -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=fail header.i=@linaro.org header.s=google header.b=DPHKoT8r; 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=fail (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 1rKU38-0003H7-82; Mon, 01 Jan 2024 20:58:34 -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 1rKU37-0003Gy-6D for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:33 -0500 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU35-00070T-4w for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:32 -0500 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-2043e721daaso6235288fac.2 for ; Mon, 01 Jan 2024 17:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160710; x=1704765510; 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=6oj7N0j8k7lH/G5CYw2mFZpUqD7q71OK17K96jHMboM=; b=DPHKoT8rnWBxAgUSCLcjcYa5CuZPks/hdsO3sbK3TiH3am8DygSaNTV4xYynZnbLkW nIXISsOd9P/pJ/DKHBcyBQS+UfAdePuIeTNgejEYMcs0LHpfxFxemp9eQkLZ1UzkdZlH v3Qp3YfDMWmini6tHQIyRXWihFJ0A1OLcCNVjj1z6wGPYbtuMWN4NIOOlrPcqJbq2dZu tKRGhSuluEB/VB7aCSYLIzrQnnXVm+qTLgOytH+1H35SlEx0LJFyMWZy6VQFF/MEptbU dSbyCr7K7eSBsaerc1uZp+PHEbBcJ8SsejmrehinTU8aInmd6qFHtI+lUzoAs1AhPFoy VukA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160710; x=1704765510; 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=6oj7N0j8k7lH/G5CYw2mFZpUqD7q71OK17K96jHMboM=; b=Y7n2Bv+49Y4LSXU2cKgPBxP3+gMe5+7O15WaSx1+iW7RQu1xWtWvawkYmH6aNwxVPG VHLzAhed6hjmuVVD6oPaGR0I/s3KhkmMgTjoim4PBDoX1mJrKf4JK5JFUOXt5Rt95+DY x6Hek4Matxflm1zOirFgA/TCHkyPNGR8F1WDEtNCf2YsnrGiNVo7O/mpeXEcL/rUo/dM rX2is6QXbeKGOcblH+6oiyqO1oXLkyi7dnZUkOegC0nQ01FpgKfBdTIwD+9SSouAdn81 MvhYeJHLGKg0k+TPVZDwIihYxGyJgSvm22dc4s+YPM8NYfOOa29MkFXItAqNG6HAtG8d Ahkw== X-Gm-Message-State: AOJu0YxE83KuHGdNPJqyACt7x/uujY+vaEym3CGJxvC48V422PRVcehl zY998mgdU4H1av8wiZE6+Cz9eGSGsLJHnLLTn5/F+Lt1o0A= X-Received: by 2002:a05:6871:588:b0:204:3f62:a8a0 with SMTP id u8-20020a056871058800b002043f62a8a0mr18792889oan.71.1704160709915; Mon, 01 Jan 2024 17:58:29 -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.58.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/33] linux-user: Remove qemu_host_page_{size, mask} from mmap.c Date: Tue, 2 Jan 2024 12:57:43 +1100 Message-Id: <20240102015808.132373-9-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=2001:4860:4864:20::33; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x33.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 Use qemu_real_host_page_size instead. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/mmap.c | 66 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 96c9433e27..4d3c8717b9 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -165,6 +165,7 @@ static int target_to_host_prot(int prot) /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { + int host_page_size = qemu_real_host_page_size(); abi_ulong starts[3]; abi_ulong lens[3]; int prots[3]; @@ -189,13 +190,13 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) } last = start + len - 1; - host_start = start & qemu_host_page_mask; + host_start = start & -host_page_size; host_last = HOST_PAGE_ALIGN(last) - 1; nranges = 0; mmap_lock(); - if (host_last - host_start < qemu_host_page_size) { + if (host_last - host_start < host_page_size) { /* Single host page contains all guest pages: sum the prot. */ prot1 = target_prot; for (abi_ulong a = host_start; a < start; a += TARGET_PAGE_SIZE) { @@ -205,7 +206,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) prot1 |= page_get_flags(a + 1); } starts[nranges] = host_start; - lens[nranges] = qemu_host_page_size; + lens[nranges] = host_page_size; prots[nranges] = prot1; nranges++; } else { @@ -218,10 +219,10 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) /* If the resulting sum differs, create a new range. */ if (prot1 != target_prot) { starts[nranges] = host_start; - lens[nranges] = qemu_host_page_size; + lens[nranges] = host_page_size; prots[nranges] = prot1; nranges++; - host_start += qemu_host_page_size; + host_start += host_page_size; } } @@ -233,9 +234,9 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) } /* If the resulting sum differs, create a new range. */ if (prot1 != target_prot) { - host_last -= qemu_host_page_size; + host_last -= host_page_size; starts[nranges] = host_last + 1; - lens[nranges] = qemu_host_page_size; + lens[nranges] = host_page_size; prots[nranges] = prot1; nranges++; } @@ -270,6 +271,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, int prot, int flags, int fd, off_t offset) { + int host_page_size = qemu_real_host_page_size(); abi_ulong real_last; void *host_start; int prot_old, prot_new; @@ -286,7 +288,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, return false; } - real_last = real_start + qemu_host_page_size - 1; + real_last = real_start + host_page_size - 1; host_start = g2h_untagged(real_start); /* Get the protection of the target pages outside the mapping. */ @@ -304,12 +306,12 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, * outside of the fragment we need to map. Allocate a new host * page to cover, discarding whatever else may have been present. */ - void *p = mmap(host_start, qemu_host_page_size, + void *p = mmap(host_start, host_page_size, target_to_host_prot(prot), flags | MAP_ANONYMOUS, -1, 0); if (p != host_start) { if (p != MAP_FAILED) { - munmap(p, qemu_host_page_size); + munmap(p, host_page_size); errno = EEXIST; } return false; @@ -324,7 +326,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, /* Adjust protection to be able to write. */ if (!(host_prot_old & PROT_WRITE)) { host_prot_old |= PROT_WRITE; - mprotect(host_start, qemu_host_page_size, host_prot_old); + mprotect(host_start, host_page_size, host_prot_old); } /* Read or zero the new guest pages. */ @@ -338,7 +340,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, /* Put final protection */ if (host_prot_new != host_prot_old) { - mprotect(host_start, qemu_host_page_size, host_prot_new); + mprotect(host_start, host_page_size, host_prot_new); } return true; } @@ -373,17 +375,18 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size, */ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) { + int host_page_size = qemu_real_host_page_size(); void *ptr, *prev; abi_ulong addr; int wrapped, repeat; - align = MAX(align, qemu_host_page_size); + align = MAX(align, host_page_size); /* If 'start' == 0, then a default start address is used. */ if (start == 0) { start = mmap_next_start; } else { - start &= qemu_host_page_mask; + start &= -host_page_size; } start = ROUND_UP(start, align); @@ -492,6 +495,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, off_t offset) { + int host_page_size = qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start = -1, passthrough_last = 0; int page_flags; @@ -537,8 +541,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, } } - real_start = start & qemu_host_page_mask; - host_offset = offset & qemu_host_page_mask; + real_start = start & -host_page_size; + host_offset = offset & -host_page_size; /* * If the user is asking for the kernel to find a location, do that @@ -567,8 +571,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, * may need to truncate file maps at EOF and add extra anonymous pages * up to the targets page boundary. */ - if ((qemu_real_host_page_size() < qemu_host_page_size) && - !(flags & MAP_ANONYMOUS)) { + if (host_page_size < TARGET_PAGE_SIZE && !(flags & MAP_ANONYMOUS)) { struct stat sb; if (fstat(fd, &sb) == -1) { @@ -595,11 +598,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, host_len = HOST_PAGE_ALIGN(host_len); host_prot = target_to_host_prot(target_prot); - /* - * Note: we prefer to control the mapping address. It is - * especially important if qemu_host_page_size > - * qemu_real_host_page_size. - */ + /* Note: we prefer to control the mapping address. */ p = mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { @@ -665,7 +664,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, * aligned, so we read it */ if (!(flags & MAP_ANONYMOUS) && - (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { + (offset & (host_page_size - 1)) != (start & (host_page_size - 1))) { /* * msync() won't work here, so we return an error if write is * possible while it is a shared mapping @@ -694,7 +693,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, /* handle the start of the mapping */ if (start > real_start) { - if (real_last == real_start + qemu_host_page_size - 1) { + if (real_last == real_start + host_page_size - 1) { /* one single host page */ if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { @@ -703,21 +702,21 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, goto the_end1; } if (!mmap_frag(real_start, start, - real_start + qemu_host_page_size - 1, + real_start + host_page_size - 1, target_prot, flags, fd, offset)) { goto fail; } - real_start += qemu_host_page_size; + real_start += host_page_size; } /* handle the end of the mapping */ if (last < real_last) { - abi_ulong real_page = real_last - qemu_host_page_size + 1; + abi_ulong real_page = real_last - host_page_size + 1; if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { goto fail; } - real_last -= qemu_host_page_size; + real_last -= host_page_size; } /* map the middle (easier) */ @@ -784,6 +783,7 @@ fail: static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) { + int host_page_size = qemu_real_host_page_size(); abi_ulong real_start; abi_ulong real_last; abi_ulong real_len; @@ -793,7 +793,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) int prot; last = start + len - 1; - real_start = start & qemu_host_page_mask; + real_start = start & -host_page_size; real_last = HOST_PAGE_ALIGN(last) - 1; /* @@ -802,7 +802,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) * The single page special case is required for the last page, * lest real_start overflow to zero. */ - if (real_last - real_start < qemu_host_page_size) { + if (real_last - real_start < host_page_size) { prot = 0; for (a = real_start; a < start; a += TARGET_PAGE_SIZE) { prot |= page_get_flags(a); @@ -818,14 +818,14 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) prot |= page_get_flags(a); } if (prot != 0) { - real_start += qemu_host_page_size; + real_start += host_page_size; } for (prot = 0, a = last; a < real_last; a += TARGET_PAGE_SIZE) { prot |= page_get_flags(a + 1); } if (prot != 0) { - real_last -= qemu_host_page_size; + real_last -= host_page_size; } if (real_last < real_start) { From patchwork Tue Jan 2 01:57:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759330 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5855965wrw; Mon, 1 Jan 2024 17:58:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdGc9rAEq1r+CzqT7xRy1+4hdW/yESVTCOVDwFh3uW18BJp8XDIM9Ex7y85GCWkkX+oYGc X-Received: by 2002:a05:620a:3788:b0:781:84ad:26d5 with SMTP id pi8-20020a05620a378800b0078184ad26d5mr8081011qkn.129.1704160732107; Mon, 01 Jan 2024 17:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160732; cv=none; d=google.com; s=arc-20160816; b=PyYz4chBmuzCucFOqq5Emj39zh9wqMk2PTi+aKqenKefNMmrZJXXjI4jDxyo0w6ng0 UmG/qv42Ff8+W9ZuqiTIM+U0ocdgolxAuqFaUxW5pNXgRJB0CubSMSTPiD15YJrTvW/S MWqIHpqY0YYEh6VXvRdT7tQDs3l5mfpqIgXAb1STNw8T7/iBQR1s5Ll29/qVQQKidB4K Z7bK6NlAfKZiM3phcrz5DTPYcJhs0kQuUZf2VSTBfr8Gly5aO5iHtSKOcqDzLL4QKSHV UbLhNUmfqe6vbFDr2MogzTyw+3wjpBFNLqI60cP0YmkGEmFQXBni20gNWoi3GD7LyCwX OtIg== 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=7qyMzlpzWlHoGSx0bplKdPfg7TJkUYYgysQjBpEEncg=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=gGfdcId2OJfmo+fUQ0UEh+4TrTBPq68t4Gu1IF5YHMzCjS7zv+fCYNRuScDVut90Zs 3g+wuujqG8t7jnL29zqYZlgadoeS5kYoS3xVJREQt2fVkCiuRJqA/IXGAAPRtLzqcfTx s9+YW7Gq3y1wMEGzFpRV1KJjaarPbMXF3ZaXnOSk8zeswDwthp0/FA5QRY+lX49Y5gMY YfW3rNFWkU1BMwDEzoGXpG7KY7LwH3XNU3XJazFF02DXqCtMPZtOliIuL9hkhQlPFnh8 dtPjp1orRu1fJfH/BxonzmLy5Bubb0zw1hoTge3ZJTvOKufPYprsuxMhlgJa43xQK1d8 NJhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wCrmBHiQ; 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 bm31-20020a05620a199f00b0078114c142bcsi27387067qkb.292.2024.01.01.17.58.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:58:52 -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=wCrmBHiQ; 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 1rKU39-0003Hb-Rv; Mon, 01 Jan 2024 20:58:35 -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 1rKU38-0003HO-Qd for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:34 -0500 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU37-00070a-97 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:34 -0500 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-20400d5b54eso7076022fac.1 for ; Mon, 01 Jan 2024 17:58:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160712; x=1704765512; 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=7qyMzlpzWlHoGSx0bplKdPfg7TJkUYYgysQjBpEEncg=; b=wCrmBHiQBmvk9tFIhNgjBNYnvBQ2v9j5Occ7+z4qOupkZyPqGIeiILuSFzaJhnM/Sl ffTVI1GH/uzK3XAZBXhwsdSt7+mhCGsKKd1sw63EI44R2hj0d96Dx1GJfs/JYVkOIymj tIwibiFbrN5yMh+Z0swkLcFwp9UvkIsXjzObyeXLy4Q3fNYRy50dLXXKmnLbWvOkFbop EUR3vpF/wbMerOxM/2B5TA4oxVwIIpVBAQSVYrncE+5ZuqRDAJTdCYP3XVUqivSxJ9F6 STBTglV+Ie7aXXiMc+l3TMaAsgI4Jp5gJM1UR8doZJY1hjViWJumWETp821F5FpywWwl 1+vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160712; x=1704765512; 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=7qyMzlpzWlHoGSx0bplKdPfg7TJkUYYgysQjBpEEncg=; b=f+4hfvxu9Xvryp/jLfrC7ZiGtG9YsIxrpSIhGaFSYi2NZ5SJEiugxdEYSj+K7gPlSz lBdd/H1CPp/nuTx5F+Ii65py04wQnqjauYdogkWaoYuq7jt+0Fyrx4uxxm8JOWtusg/c ue3/kuIswi3Aksw3u/YQU1WX7r1UIHtxVBge1J63zrXwQMDlR8rqUg0Z+sXhuhYgTDRH TrfRYHrdKPlaFA7qsHBC3gHujX7VwfpUToFq7JY6EldCPZLO0RAZ3u/Is6J8q3o5+mdV /TShTn1ImhuC69lCfUgd6G2yUM049rfVLcPRFo5DdO1T/7dXdK+c0LLsC943eIzayIyq tCXg== X-Gm-Message-State: AOJu0YyD+w0J+1QoS59w/JJDuSfSXhH+v7sBJ0vun2DaX2wFqXXLTUmG dEt9opAuuJ+QLh0zkSIwt4GFS8YodsW8alWPPrsZwk4vtdg= X-Received: by 2002:a05:6871:5228:b0:1fa:dac9:1cd2 with SMTP id ht40-20020a056871522800b001fadac91cd2mr19439525oac.27.1704160712082; Mon, 01 Jan 2024 17:58:32 -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.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 09/33] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c Date: Tue, 2 Jan 2024 12:57:44 +1100 Message-Id: <20240102015808.132373-10-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=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.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 We already have qemu_real_host_page_size() in a local variable. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 4d3c8717b9..53e5486cc8 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -585,7 +585,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, * the hosts real pagesize. Additional anonymous maps * will be created beyond EOF. */ - len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset); + len = ROUND_UP(sb.st_size - offset, host_page_size); } } From patchwork Tue Jan 2 01:57:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759355 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857386wrw; Mon, 1 Jan 2024 18:03:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZ+r6EOQJK2BvWFIA2YlauMPradtYcxVRgyH4FWjC0VxYmlZ6mVXagqZ8bI+S+E1wtRBRv X-Received: by 2002:ad4:5f47:0:b0:680:c080:1f1 with SMTP id p7-20020ad45f47000000b00680c08001f1mr857753qvg.112.1704160980141; Mon, 01 Jan 2024 18:03:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160980; cv=none; d=google.com; s=arc-20160816; b=df/eeKEBRBEcWbzNeRmVvuNAP9RYpnF7DrAHUh5sWyQGGCmu6zk4v4DsJTjmm+Z9p1 YbA+zwzg33PWnuodb1X2ex4XM+WTTtMDHO6NNrTJtfFT1Pvt+NovdlH3x34mf9suVikC gcCghdZ4xZheIWpg142kb2b7i5uV0wWXKojtKRe7/Nuq16wI0PBDKSbikZUKYAhZzkUK CA3D9lvmCjIeJAYK/GdwHek9wndqAbfaQR+sgbXRXV8/ja6fi6HJBxQq754TpEMh7SQj zdmL6O8QELO7mY1AfIHUbmU7e0Kzb6F7xcS6Q2B7EipeFm4FD2thTr55Kftt3IYeOOgD 7Ewg== 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=m5E6L9ef0SVPlAxhBuGX4coZacolJ6Ms5EPcHyzN0k4=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=OjRaAOOIWYDdjhtVFJx1stbiD518nPzdzyxozjA+nJ8+z+NHGMeT9w+Fnmqxa/jNzn z2wxRH6sdvaUpGlWNyj7SBSgEtZP/ABAZR/ENwvcp8IoOux9aCxHnd8MJQ5r6F755J38 53evhwyUt13e+PEASirZgRGfBCaMYwuIBO7N4nkMt48C24NNlm19Mk1W7p7MWRPfGr7G 4Wg+Mbe0NF3cHwqskdqSWp5XPovNuokq7oalouNkURMp0riGjUwVMD1PISapiBFS8kJN hE/vH5frkciaZiy87JWT6PFuOxnvLXEZNF0s043LHzf0UgGrCrl41QACYqKzW4oulBuv 0kHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v8RG6yId; 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 j3-20020a0cf503000000b0067a9b3d05b8si25453973qvm.110.2024.01.01.18.03.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:03:00 -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=v8RG6yId; 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 1rKU3D-0003Ik-BC; Mon, 01 Jan 2024 20:58:39 -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 1rKU3B-0003I2-Rp for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:37 -0500 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3A-00070m-9v for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:37 -0500 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso7046983a12.3 for ; Mon, 01 Jan 2024 17:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160714; x=1704765514; 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=m5E6L9ef0SVPlAxhBuGX4coZacolJ6Ms5EPcHyzN0k4=; b=v8RG6yId8v8SBxspgXrUD3q43RL/Ekkcs9gQdYpa0lXhej13t+tZ6rU/mRgh9AURgn CvEBEfSpsJGlJvVoiFDfc45rLKJHRovxguVDLJxk8+2Kz2zKIZhGlH2/Bix+ZIF/DVTl YaN4lU5HEp5XpAZysJqYab65BmeWMq3Ctmbjia6cep0Tqndbvg0hvkmsrbLJ+Ww5E1Ln nPphpBPrggTUezLPwdbrnLtZFZPWeSf+SRrz68QFrFAV95DgVh7EuX69YNE6W91bhJqG znw9iiPovJRR7AofpO9s6ESZO2tCETvO0EgEbJfObz6s2AYbA9dFgBkv+RWwguI4pt+U 0LPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160714; x=1704765514; 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=m5E6L9ef0SVPlAxhBuGX4coZacolJ6Ms5EPcHyzN0k4=; b=YjwRkTMhcYpMZZj476D+KUV2O6OZ8nRyW7HGa19FrQWilaAslgSGr+PtwReJL6vtrQ 5qmkVY1GZtOTORnQ1SXtVeGdBbev5w6g7aPYZQEisDf/bdh0ObcKg9dfjRMjKpkqcCrM 6IYSWn5KLCjDnfMnQTdudE3C3J1XkSfCIxFEI1AEFgBaIiPVtDQh770u/IFTx8wCHV18 HtyLTEp5Gy6MFJdWTfmbIs0uzPLxUx1B6mqPpv/wOtqUD5JhOH3MACiFD7qb4VrcJDMl t72ntleJosBjqtePkayJ4ElZpSRndEc93dcMvG1r7qIiIQ97mkvotj0jrJbcg8n8gecS c0Sg== X-Gm-Message-State: AOJu0YwQZTocKHmpfvk33Zr34gx+dIHmu0WN1T6weDHl7YMho1hnWW2v +NqN2lUQn0+HZQeJrYWbHmgM0q69Kfn+AhZ8yh1w9ajKrlM= X-Received: by 2002:a05:6a20:9149:b0:197:d2d:1c0f with SMTP id x9-20020a056a20914900b001970d2d1c0fmr3019289pzc.87.1704160714045; Mon, 01 Jan 2024 17:58:34 -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.58.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/33] linux-user: Remove HOST_PAGE_ALIGN from mmap.c Date: Tue, 2 Jan 2024 12:57:45 +1100 Message-Id: <20240102015808.132373-11-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::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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 This removes a hidden use of qemu_host_page_size, using instead the existing host_page_size local within each function. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/mmap.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 53e5486cc8..d11f758d07 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -191,7 +191,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) last = start + len - 1; host_start = start & -host_page_size; - host_last = HOST_PAGE_ALIGN(last) - 1; + host_last = ROUND_UP(last, host_page_size) - 1; nranges = 0; mmap_lock(); @@ -389,8 +389,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) start &= -host_page_size; } start = ROUND_UP(start, align); - - size = HOST_PAGE_ALIGN(size); + size = ROUND_UP(size, host_page_size); if (reserved_va) { return mmap_find_vma_reserved(start, size, align); @@ -550,7 +549,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, */ if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len = len + offset - host_offset; - host_len = HOST_PAGE_ALIGN(host_len); + host_len = ROUND_UP(host_len, host_page_size); start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start == (abi_ulong)-1) { errno = ENOMEM; @@ -595,7 +594,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, void *p; host_len = len + offset - host_offset; - host_len = HOST_PAGE_ALIGN(host_len); + host_len = ROUND_UP(host_len, host_page_size); host_prot = target_to_host_prot(target_prot); /* Note: we prefer to control the mapping address. */ @@ -625,7 +624,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, goto fail; } last = start + len - 1; - real_last = HOST_PAGE_ALIGN(last) - 1; + real_last = ROUND_UP(last, host_page_size) - 1; /* * Test if requested memory area fits target address space @@ -794,7 +793,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) last = start + len - 1; real_start = start & -host_page_size; - real_last = HOST_PAGE_ALIGN(last) - 1; + real_last = ROUND_UP(last, host_page_size) - 1; /* * If guest pages remain on the first or last host pages, From patchwork Tue Jan 2 01:57:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759332 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5855973wrw; Mon, 1 Jan 2024 17:58:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFN45CeIEUzmqs1f9wNQiN/lHBNxS8kG755UcNZeT3RpgrDjAQfsqMq/WswzQioIMC7DuqP X-Received: by 2002:ac8:5945:0:b0:427:9efa:b81d with SMTP id 5-20020ac85945000000b004279efab81dmr24582515qtz.126.1704160735342; Mon, 01 Jan 2024 17:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160735; cv=none; d=google.com; s=arc-20160816; b=eBVL6LOU1RMEklN6SvoDA75zu/+uYotL9lUsyRfWPEY+nYMySyzVtQypIvMzzCiHTi MM6t1bbRLZIH9kJSomw245d4xZzBHBZASgFT5mVSR+qovj67g3SOLZ14bR1kw6pZL9ta 7xICttb/o2QggmBMzEfAqZghcAhARJYHJUM+jjePFqhG/ByWqBRtKVk1sCyVFKOZLhyB hPLOTyR1WARgexL7u/Lw7gb7Aqs0kgk9aPpsW02emLqAEdyBo/h6XvUsk5ZmdSOoPsYC ZeOHniu1sQevUH0TS+2nYbfvdBUQU3WwLfp+GYftFQxG6huOCRwTIrVRPz7mAWSX6LZ1 mOTg== 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=IenBg9AYpQ9l8BWTXQNXUpU41uv7QpRC4SvYweV2rAA=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=OKaFThLMgBi5rPlLjMi0qwPl/h80swCxHASozOkfJ7ZEN7a7xu2/X3XF6zVnC9N7g2 3hV+qRrLR0J9KsuvIb9baUOrD2oGcfreIvGJ271GVdg9Js22BoNP6IjTL03SEZBF+Wz8 P2CUvL6pG8UOkRkFB78N8FopR85aT+W6n7hv8ktTfCVcMYpLwOPo5vNji/GYYUGU1B7x +aScSg1xZgpmwxgzo1ub8nmvUgy84DAh2ZEYP3wSkG7YBaN8o91DFxI+/i3d577+RYXF 5QcXgu6PPyFc9oLVMX8IIgjoCWBHrN/cEaAlggo+BRP+WhJC8GmFIVvqtkAwK8mrr5Z0 tiRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aHzGquAa; 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 t18-20020ac85892000000b0042827000d50si2055973qta.418.2024.01.01.17.58.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:58:55 -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=aHzGquAa; 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 1rKU3E-0003JV-TT; Mon, 01 Jan 2024 20:58:40 -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 1rKU3C-0003IQ-Uu for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:38 -0500 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3B-00070z-Cg for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:38 -0500 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6dc36e501e1so2061727a34.1 for ; Mon, 01 Jan 2024 17:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160716; x=1704765516; 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=IenBg9AYpQ9l8BWTXQNXUpU41uv7QpRC4SvYweV2rAA=; b=aHzGquAaP6EDXNCYSTqyeVL+f302JMwrg8MA6cvZGw2VP1HBpIQaUmWnOO5JHzaqfP VELLgej4Pa1QR88LyjvsCkrGovmtKJVCH1TglKVXTxgKiH71e5rB4FyqXw03I7/RqjsD MkkpTezNZ/Lvl/QAeIeTiehnM8fsX0UyR3UJJwlR2IiUu4YI8JL+tEG73r8V8A2SnL8w rbvv0V6CYR21yArDUVd/g3NjvwFSabD0WSI2OcaMnOnETc4y2BE0CBrgoTG5usqH1xeA LqAcByKLGlErVFMv4ykchM2oUJSdB526h9KzMOielUES32JbkiQ2t61pmcAXDxUosR/+ UcXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160716; x=1704765516; 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=IenBg9AYpQ9l8BWTXQNXUpU41uv7QpRC4SvYweV2rAA=; b=CBziCHg9ag/wBbw+ei5rGEsXKntA6wy7HjE2WtVh3dLfwR0BhStWlYnTnr3oqYotkr HVSWSjj/EZFAGT/0gNSFxCC4QjZzznbh0X7oYJ04iRGaqvWXJ2EKHiXEHKOAzd/JNlf9 aB5ZDZ0ptwMCmWZnTQpoDEFvK39cpDguHvKOxWDuGGfKnc/G9R6QOSlAtmbpENCZvzwQ YiQvZl9ZPnT0LwsYRgANLZsiyNXGoWYL/0wZpkjLRQF8EcCGskhl8KmffACgdUQnMt8A xhEEe8oyjGxFqLPlYQzwqWQTDXujB3S9aAncJgvYHO/NfgIWNx8tJ8vc6tDFK33TlnOF rDeg== X-Gm-Message-State: AOJu0YyIzWS/o04zT6MQhHv6/B0dphhdHEk4flBobfQyqeqosGzj3bbq 6nq5xGV4oaRGW+mJwcZPGDLhEJu8P7VV21pDHLe2a3vAJMY= X-Received: by 2002:a9d:4b16:0:b0:6dc:54:f52a with SMTP id q22-20020a9d4b16000000b006dc0054f52amr8654884otf.4.1704160716169; Mon, 01 Jan 2024 17:58:36 -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.58.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/33] migration: Remove qemu_host_page_size Date: Tue, 2 Jan 2024 12:57:46 +1100 Message-Id: <20240102015808.132373-12-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::32c; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32c.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 Replace with the maximum of the real host page size and the target page size. This is an exact replacement. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- migration/ram.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 8c7886ab79..aa3109fca3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2936,7 +2936,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) { RAMState **rsp = opaque; RAMBlock *block; - int ret; + int ret, max_hg_page_size; if (compress_threads_save_setup()) { return -1; @@ -2951,6 +2951,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel = f; + /* + * ??? Mirrors the previous value of qemu_host_page_size, + * but is this really what was intended for the migration? + */ + max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + WITH_RCU_READ_LOCK_GUARD() { qemu_put_be64(f, ram_bytes_total_with_ignored() | RAM_SAVE_FLAG_MEM_SIZE); @@ -2959,8 +2965,8 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr)); qemu_put_be64(f, block->used_length); - if (migrate_postcopy_ram() && block->page_size != - qemu_host_page_size) { + if (migrate_postcopy_ram() && + block->page_size != max_hg_page_size) { qemu_put_be64(f, block->page_size); } if (migrate_ignore_shared()) { @@ -3794,6 +3800,7 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length) int ret = 0; /* ADVISE is earlier, it shows the source has the postcopy capability on */ bool postcopy_advised = migration_incoming_postcopy_advised(); + int max_hg_page_size; assert(block); @@ -3811,9 +3818,16 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length) return ret; } } + + /* + * ??? Mirrors the previous value of qemu_host_page_size, + * but is this really what was intended for the migration? + */ + max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + /* For postcopy we need to check hugepage sizes match */ if (postcopy_advised && migrate_postcopy_ram() && - block->page_size != qemu_host_page_size) { + block->page_size != max_hg_page_size) { uint64_t remote_page_size = qemu_get_be64(f); if (remote_page_size != block->page_size) { error_report("Mismatched RAM page size %s " From patchwork Tue Jan 2 01:57:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759345 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857151wrw; Mon, 1 Jan 2024 18:02:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8nXmh2vpRjOKJvF+xPPdgoUJjZWEOwdXRBHN/B8A9ekytKVMDRjYukZuaE0syyGjd09mL X-Received: by 2002:ad4:4ea7:0:b0:67a:cf30:dc22 with SMTP id ed7-20020ad44ea7000000b0067acf30dc22mr27524119qvb.4.1704160941093; Mon, 01 Jan 2024 18:02:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160941; cv=none; d=google.com; s=arc-20160816; b=q0EETk0u4Nxp153BWYA7lUFefhnHZndwPW0oglrOQdFj7H1ssk4o89NKoWtwfRzf8w Yyg9H3Wf2eiqvlqEeoaGiAju7htCwp5jZp9J6jA2bitsNeFvm8OTX31tG7YFvMhwqw9N IiOknGt4Wh/43uWG0khdcIiMJABal25nx/MUAV6qpLNyqzAEAobRoN7BNZgq4Sm2hcin UEHXEnrxk0mgr/A1PFin5AqzpMAQkR5HB/Zy8Zziuaa6Pp6CQSDi+5Re28VFt/ZSwje0 CMHJdUrCJPGk1UumhMGYkMIwlx0tSadwY4/cT0MccqkHGYjuyN3oB2cagsEUZir/qoSY egTA== 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=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=D8ZcFD1TQBmuS2gNOzz2uctTmHiDg0MDDgpEydcbE+M16a+nv6WArodloWr4yZsObo I7qf5NALbf5Wp4UElq3ZEkR5bRIYOkWe/yZrUbXbW3c5atcY7ZGRAXo0+30NlMWUEvWJ IZFyn8cZjs8LmR35pZ9Zr6dL9AOe9xZqyxN+X2r5T5HJtboLXuX6zE7ZKH/SptZ2rWyt CZtLydUQL5UbyCCTC8VyOtPa7klRP56EIhPofMTiq61xeW9GE0r7gNnCXEN0QjQwtN6O Sk7DgMGzEGei+ehhe98t9LymHwSBBbOL8oZ/gMB/3HFtr99793KqEIPRa/W8RH6LIy1n ff2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uDF82imL; 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 x27-20020a0cb21b000000b006809d5461a6si7095612qvd.510.2024.01.01.18.02.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:21 -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=uDF82imL; 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 1rKU3H-0003Jo-75; Mon, 01 Jan 2024 20:58:43 -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 1rKU3F-0003JY-Ls for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:41 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3E-00071D-6a for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:41 -0500 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3bbd1f9e0b8so2631243b6e.0 for ; Mon, 01 Jan 2024 17:58:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160718; x=1704765518; 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=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=uDF82imLYBepCEfXFvcLfB9u9YqZe0xZYwaeE+0prisb2eFGZSGK69IUPIctCA7F7k /4ELreAyE8RdFdPEVwJlKXInwvMbv0+KYRv2oI93gihL+j6vkVMV2ytAYoZQi2I1m3zE T6pNU4H4H4X9W9gP7NmKd2iWLlJHzRAMraXeHHsayD5Mna6MqlbhCPFUVBcRdRnpF+oo NS7vFoN0nUffQBPOuonk+Nu1NGRxXLFhzvAKRKygAWS5t2yt922c6kXxyXblNo1kesOP KnL1F0JNEFLaK+ux5ufLD3DW6SADwUvSTtGwSzgx0GgY6Zc4ejFX6HEO6T3z2pnt3Omk Pj5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160718; x=1704765518; 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=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=qnsjyXLwEDWjySbV0MzvI3iep7Y/QM88b181R12gAMWLc2JLCRB7qyninIOwBG1G0M hs2mWMHyRVXgOqFJrY33aJFFdjzPH7RxGQLTsePo4bm77vLinn3FRaOWPiwZnJrV1ZhT eP+yd+LWeKYfujK88sJ6vwjohIGzbKALYRgf90thXxV4m3tNWi2s297MzolByHnK63A4 NnTOw48qqJnZI6KcS2McLlhK0x0/dDKlwXZaRTvR14RMBrGuUuTRlhOeDoRZFWA3LCbu 8WjuefFFNmA+9Nvw75dCg1Wljid2tSwEp35GcfS8r0sPDARU729fVYIM4KneRuk2vF4E ++Zg== X-Gm-Message-State: AOJu0Yw4ohRealh++vsIw8xrX8P0BwuuNPHAa+8emU837uXtw+4kwjtB BuuYobc/EHD2Za1i277AwLFYVBqMrH9iEqimyxHCXM2G2ZU= X-Received: by 2002:a05:6808:148b:b0:3bb:cc89:3fa9 with SMTP id e11-20020a056808148b00b003bbcc893fa9mr8869508oiw.43.1704160717985; Mon, 01 Jan 2024 17:58:37 -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.58.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/33] hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init Date: Tue, 2 Jan 2024 12:57:47 +1100 Message-Id: <20240102015808.132373-13-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::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.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 The size of the allocation need not match the alignment. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ilya Leoshkevich --- hw/tpm/tpm_ppi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c index 7f74e26ec6..91eeafd53a 100644 --- a/hw/tpm/tpm_ppi.c +++ b/hw/tpm/tpm_ppi.c @@ -47,8 +47,7 @@ void tpm_ppi_reset(TPMPPI *tpmppi) void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m, hwaddr addr, Object *obj) { - tpmppi->buf = qemu_memalign(qemu_real_host_page_size(), - HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE)); + tpmppi->buf = qemu_memalign(qemu_real_host_page_size(), TPM_PPI_ADDR_SIZE); memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi", TPM_PPI_ADDR_SIZE, tpmppi->buf); vmstate_register_ram(&tpmppi->ram, DEVICE(obj)); From patchwork Tue Jan 2 01:57:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759357 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857457wrw; Mon, 1 Jan 2024 18:03:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRDJIHZpIoC0UsMS7VKeC/12ty9DN2AcUbX3P1Lnh0qBaDMr8gD3K3gGh8aqdxudVr+dXm X-Received: by 2002:a05:620a:3721:b0:781:8c62:5edf with SMTP id de33-20020a05620a372100b007818c625edfmr7484724qkb.3.1704160993296; Mon, 01 Jan 2024 18:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160993; cv=none; d=google.com; s=arc-20160816; b=KU9/zcCEUtcoBEafhjAHaKBzRkNu7hmsJ/VpR1UPX8hBpv2VnvdAhyEokZ+dx5mkEx P8dwu6q8abiX+86TZ4tBw+EPco24O343NiZ/TKgAAJWf0CrJaAVwdw9A91o7Prkkh8GS SMb5ZAZzN+8ymACi98/HQ29fiA+/3N+AyxW/Od6XVqHIlqZxamAo2hwG7ae27Fi91WoP Ts8kO2yTB8hSeayxKsyo/bh0dLEOzH1AdROl3m7cw7GbAGhFEJNa/jQ6RdAyirPAHWTI KwSknITlL9XbAiTGN9XOnXVYCmyMz8nllSmGRfMw+A99rqcvDLO2/RkgWjIb50UR/Fa8 BPbw== 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=7M01tA40HhYtf6OFCfsrnOQ6yOhmNiUUj7BsAbVg9so=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=EUFSTN+rdoii2p19l1qbOBZQXVW9zqDNSINRBuFpvI/RoaYY5IGaUZ4FNU6gbnZ5oH kc5kx2Qm8sHciPdfFQIX+gIStUjoZC/a8SykuzMf+yPKZZKGI/krlh80/c/gGE71itOg gfzdd5sQXdKei7HWWPru8/iLxwVStrFj3C/6EiKusR7lfwHomd9AqXjjgDhpLdxYbi5a nN7k6+qNZ5R5WANjgO5lF+YrnEpzNPe/JhMJDqAU+aENzJNVw6VIbNbFMq/9SYSGjqRd M2WKAqRJau3BbPMPFClomWauOR5YjWDhnpFJaQSvvbxA6OZrWJxBFxXpumcIqU2sHClr fwbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Pmg3ki/r"; 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 wa5-20020a05620a4d0500b00781bac0816fsi4168679qkn.205.2024.01.01.18.03.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:03:13 -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="Pmg3ki/r"; 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 1rKU3I-0003KB-Cr; Mon, 01 Jan 2024 20:58:44 -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 1rKU3G-0003Jg-ND for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:42 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3F-00071R-5N for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:42 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6d98ce84e18so6562281b3a.3 for ; Mon, 01 Jan 2024 17:58:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160720; x=1704765520; 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=7M01tA40HhYtf6OFCfsrnOQ6yOhmNiUUj7BsAbVg9so=; b=Pmg3ki/r0FoBGQ69BDCW0COvKbsNHewTFo3uLo8OuMCMujCD37ybqFiiGi08UCKBWx VxHnNXJD217OKVDZzvA37Yh1kj4pr9TvcTcoc2d89laPO83yU96+iuMOe/roMmSLjRrB SA75gxlZZqk/eX3a7reNkFzuMB+nrGXYPzWdAMLp6brRbshAvOsPkTpeqxJ2uVxCHesF 0IQDBCpdyLlJz+bADuiWXm+NTu4cXs91Nb8mSx/2w+RBwhttbe4E5nuq73T3ejXhE0XJ qxXQh1YXYhittZQWfbWQ8RgokKpup4xC09d2zf7TcabTyKfugm0HalDGixq8GCXpbKbJ z7BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160720; x=1704765520; 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=7M01tA40HhYtf6OFCfsrnOQ6yOhmNiUUj7BsAbVg9so=; b=hU061zzcY1Kqpof2ZBPupBeM2sy/Iu85ClpjHDD33NP2ufQxg31lBP5wNLhX7YWxmh Z6EtQiX+KzkazRUeWfpUE6Ujll1Q8DGHh6Kwy5EzmPtR4YK8K1eDuHn29JHD6AFW44UC nrT0OlvyfzLB+F0VhP1F1E5Iq360QChMAGYB8FOh2u1bYGniKXfcmaQ5EYE7pCFnB/QH 5OMAKrz9L4eW/s7Beji2PhSDHcehz2xud5IxJ2WILHWgYIHDWyFjNKv9xwaMlKJ6Ausn cW+qPDvdo+fkWXJSj43hihS1GJNjoB5gnA+FrzNuyxVsg58iN4t2lVeZ27WBM2fxdVr3 GQeg== X-Gm-Message-State: AOJu0YyZZufnxwRllrtfN6cyiTM4aadQSCAgmpE0Q8QEVI/uWgNK30sG W5uuPvQT40NiMAuSQNNWcs2YBwMUdwAEL77KybT2DfsC9jY= X-Received: by 2002:a05:6a20:4e16:b0:196:52a5:e2c9 with SMTP id gk22-20020a056a204e1600b0019652a5e2c9mr6859811pzb.40.1704160719806; Mon, 01 Jan 2024 17:58:39 -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.58.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/33] softmmu/physmem: Remove qemu_host_page_size Date: Tue, 2 Jan 2024 12:57:48 +1100 Message-Id: <20240102015808.132373-14-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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 Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ilya Leoshkevich --- system/physmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/physmem.c b/system/physmem.c index a63853a7bc..c09953270f 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3520,7 +3520,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) * fallocate works on hugepages and shmem * shared anonymous memory requires madvise REMOVE */ - need_madvise = (rb->page_size == qemu_host_page_size); + need_madvise = (rb->page_size == qemu_real_host_page_size()); need_fallocate = rb->fd != -1; if (need_fallocate) { /* For a file, this causes the area of the file to be zero'd From patchwork Tue Jan 2 01:57:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759360 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857628wrw; Mon, 1 Jan 2024 18:03:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpoY+uN0uT+q8bydUkE1yYRY4tWE5Ja3yOWagYb/hXp3HfjEsO6qoFjTo+A0Kpw9yIbDKb X-Received: by 2002:a05:620a:28c8:b0:781:5bd6:2cd8 with SMTP id l8-20020a05620a28c800b007815bd62cd8mr13465177qkp.3.1704161027167; Mon, 01 Jan 2024 18:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704161027; cv=none; d=google.com; s=arc-20160816; b=SAwUME/fF3B4FLegucmk9NRQTEykrptEvDeaXRuxVK9a1t3XsWAiSuDz/hTAN39L2K ekTPeATbl3w7vuqWnpqSGefRW1fOj9Zl4N3ls5nmT2wwRIyfzrXFNp/l/cI4IhYprspu 5OUV2Hzd7SJQw5fKFrblgjdkOdo1nhr7pHqXTBHN0at8q0BMEr3Dr9O89Y2CnATmK590 4ztlUNPILEnL29UMclzm8NPVye/kC6d18db+GNsjMa8pThcexO/jGbN7hLmJNumQinvq Krit8SUk9AjXRmqU2zIIZzigEKIe5M6O8rIBg2JheSDYqdH72Zpd1l+MvOneuEs7P+R5 mbAw== 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=SjN83cVYCiop/vN+SdqqhBrpQ2lAiZ7szn5smiP5b+Q=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=Eo5ycFGOBdGiLGC6BeVb7kLP9nCR1OtLnrFFTYLk/CVl719GaeSDereJI908FUNtqV d6Ysk/3CDZ9NUrtZMCwqjZJyyD8HEJCx04YzB2tPbse0MuXjOqGAJD38Bx0VhMR7rxD7 RxccFbiCltSh0xmxuIh3KZ9K9ZKBi7U+JKGAYarvb6A/h+BE2VQeG0P9UrMwlcrG585z zssxnIaxcAuDDyoKf0/RNoI95i8I4LeYZ/1AULBP4PzhrZP8HJWCMDSEAdWAk1yOD6Dl XFCHDLN31NqnFfsvcirw8ry6MxuFNpdaJdOsXOAWi/BdCGvw5Mmuydri94vojL2apLGt JsFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sbaovuYR; 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 n4-20020a05620a294400b007810c541f20si26871319qkp.274.2024.01.01.18.03.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:03:47 -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=sbaovuYR; 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 1rKU3I-0003KY-TU; Mon, 01 Jan 2024 20:58:44 -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 1rKU3I-0003K5-9y for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:44 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3G-00071g-RW for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:44 -0500 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3bbd6e377ceso3057820b6e.1 for ; Mon, 01 Jan 2024 17:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160721; x=1704765521; 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=SjN83cVYCiop/vN+SdqqhBrpQ2lAiZ7szn5smiP5b+Q=; b=sbaovuYRX985LPidP+U2lfMs8Y5PZ9ZgvqEEWAFQtNbaFIBlS1YS0y6odAF/kWEOuF fOqyMJXg2y3xyjYyVe3vYdmph/44jF7l0wUPvmEUPBc3c9YEjXYMp24jt1rMu2k0g3fy V9zxY3lu1YvivS3ltdousGJEl0gc+QUwmikZ1sn69b+8tPwfk4bIUwDW/mxiP+LLiuR+ hFzH2ONXIGom9exAaVO6Asulzk+1O5gC1B+WC/5V1NwKSCC/RJ+RdfAmxU2u7D/MIi0n uh2CnF00BDgMPwethy1x4aILx1dZQSx/3gYede5VzVGpNFd1d/H+65+DNmbkglUb1Nul HDhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160721; x=1704765521; 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=SjN83cVYCiop/vN+SdqqhBrpQ2lAiZ7szn5smiP5b+Q=; b=FgEOi3yembWsQ17O5NdJYnEQPq+VnJseG/iwp92rEcBeuPHPtTLvuu5eY8+FY4s/24 t/Rg+iFzB6BCaEpd/RYSTwFMICbucObL4stpfEM4BuQ9als8dda6H9QEkivIOQC0otd4 xrg82cc1K8nNGtGTH16JFtEHKO1fu7I70B0ZhwgDN6xFWmsZoWYdV/5/wFy06+sojwjh 86RNzhvU8l3fvnifap+fSSik3ZhOkUi+Gk0vfOFe3ZLpm/qPtdTa3ghhD96n95hfLtAY 6Lq/sUSLWt3Phb/UnZVMfFJfk26UaBbOI5p0CORjjJoEAS0HrJmdSRvyukqBzXVKkdwG z8Hg== X-Gm-Message-State: AOJu0YzD5zATeToHwptX2R3Y0P0uyFGz0EN0BKxS3R+fnkVPlqTbvp8A r4zrDlKb4oBDtD0CSu2P11GtlBT50Ea5WSOcNjjI4ai4CDs= X-Received: by 2002:a05:6808:208e:b0:3bb:f5f4:e5ce with SMTP id s14-20020a056808208e00b003bbf5f4e5cemr4818747oiw.41.1704160721692; Mon, 01 Jan 2024 17:58:41 -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.58.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/33] softmmu/physmem: Remove HOST_PAGE_ALIGN Date: Tue, 2 Jan 2024 12:57:49 +1100 Message-Id: <20240102015808.132373-15-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::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.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 Align allocation sizes to the maximum of host and target page sizes. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- system/physmem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index c09953270f..c1e48dfb6a 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1680,7 +1680,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) { /* @@ -1916,7 +1917,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 @@ -2014,13 +2017,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; From patchwork Tue Jan 2 01:57:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759334 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856017wrw; Mon, 1 Jan 2024 17:59:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXZolbMUoCXTJJ1ALHZP2Jnswu9+vkN2TK3Qleq/RbJmjyy98fr/8wgExifwcU9AvX62Gr X-Received: by 2002:a05:6870:a108:b0:203:9d13:5e97 with SMTP id m8-20020a056870a10800b002039d135e97mr16921248oae.37.1704160745079; Mon, 01 Jan 2024 17:59:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160745; cv=none; d=google.com; s=arc-20160816; b=BS21YmPS/K+V2wNyHVMfJbKcLWDg9rpmCaulYlrvibmIeBQ0O67fJrDKXTTn2wDVXL FJgoy0FtJdme6VA7zRpDXsYCQ5+Dii9UAYXB3mDG0AImcU94S7/Z/8r2UKkrbKG2v69T +/s7eZQBPsCtndu6vhf2rskO6+BzvGjwN3QfztzoSNYrGxscageyZwVq9e3BtCW/biUx WKc2Xi2pVaaGTs6ZPdd9gIySv6LTHECOYFeot9FccAmwAFFFVrutpcs0RVg+4GvtBrz8 WDbEGllX+NabnJZV2jWAKhImW6sH1MCgJ4YoZOz9SVCa3GyfQzqoA+aloXuDBtdoEyWm xHtA== 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=bGbmvk3+bB4juRZKIWkw0J9XlNF5J8UzTPZ/yNXv5VY=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=QOxQYOTTuRUY0Kt52GTqBf8onQnmVeDpWQsExk/6EexS50o8VLFrmtPSZUw3KG/7uU cLtMzwu4U3sVDT5JxcBSf879EX1Nrfd2rhYSPsl6Buz6CghPfX9nCeXnR1TPl9XV43n8 75qIXn6S6fEMGt7ZINa82uwDghV6k/0n1YnJBeA3PNhSMJ6RkoDn3lpNnGapRQ4G7Qjk 26ihLZ43Z+u3D1ZXzGs3kMGvZ5raTViE7VOIIAUulG/EgwJrnWlgFEcW8jG3sJFZNzf+ Kr6H67l/S6q/etSNMo3k6fdGh/O4+K+daFMRNsaUwnh2rT8nDPPSDsM23Pma9qFXvXib YjjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XQJ9ASJb; 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 k21-20020a05620a0b9500b00781613c7d9csi11840061qkh.719.2024.01.01.17.59.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:05 -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=XQJ9ASJb; 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 1rKU3M-0003LC-NQ; Mon, 01 Jan 2024 20:58:48 -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 1rKU3K-0003Kp-Ac for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:46 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3I-00072D-TF for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:46 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6d9af1f12d5so5211405b3a.3 for ; Mon, 01 Jan 2024 17:58:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160724; x=1704765524; 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=bGbmvk3+bB4juRZKIWkw0J9XlNF5J8UzTPZ/yNXv5VY=; b=XQJ9ASJb+HSGq8F+KtKQyb4Gi6vTlxQCOwxtwbaUkaU6VjmmdNF07qHoHN+fJ8znd2 WzlDdwHkvIYGKaosDG2rxsAiFbp80Z4KYsh21VWaOBVEVsrHXlxlNFc4bX9JBXCYiSQ4 j4vnguviUCHlqMlp0pjffckfgxXQ8ulHZVxr3TOAu5ZyJ5H+vbKby4suMfhwOiFDSFXM cdq6WgCksfV2bx1jgYuMr6w4oFI+r0Tx4mL1s/qdhCyVCq4GvRTSNNiuHHZEco2GrOSa c3rE3B9Py8NwyAZjf3MEhn/LpSoK8dOEkE4uEGxytVECyfAFnwPqfwYX1ITg2OeHUC8B ynZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160724; x=1704765524; 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=bGbmvk3+bB4juRZKIWkw0J9XlNF5J8UzTPZ/yNXv5VY=; b=isf4yx8eqlyX3zpYhSpNwvE8feed9llp9sfHMG/jShKlOQLLS9gbHKmRjkYu+Msq9d aP0vcyuoaQ3JBb9Y0UilLR0mW4OLyqYtjWeN8r8Xjk7oTESp2q9wmDnw1hAGdKvHcnVw 0zuUnX6YjAw1c+uG6BVmpp2Nf8yfn2g4pnm/nWSRCvc/0QLVTqhIzv5LJeaFukORzNZi 5maYXr/x/14TEMrmiAEeveLPmvMFTPHJGvDq8y/3awV0kYu9ylnZRAm1gVQvH96S13HF ac7Ln0n/yo+KC5DB5+ff2e9E4xBsrTI4bevvOHaPlFvdQVcugA3OeDcjcodBYNgAYatq n4LA== X-Gm-Message-State: AOJu0YwFhvT2IgphgvuKVesmHEOrrU+WqAiypZoLa/3i+Wd9Dnc3/Y18 RZCy66lPRB4Yd92QfvOKGxFAOS6S7n0V1ZPc3G4M1SuZDKg= X-Received: by 2002:a05:6a00:17a9:b0:6d9:b320:94c9 with SMTP id s41-20020a056a0017a900b006d9b32094c9mr17630407pfg.33.1704160723757; Mon, 01 Jan 2024 17:58:43 -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.58.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/33] linux-user: Remove qemu_host_page_size from main Date: Tue, 2 Jan 2024 12:57:50 +1100 Message-Id: <20240102015808.132373-16-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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 Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ilya Leoshkevich --- linux-user/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 0cdaf30d34..5f217cc2a8 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -783,7 +783,7 @@ int main(int argc, char **argv, char **envp) } cpu_type = parse_cpu_option(cpu_model); - /* init tcg before creating CPUs and to get qemu_host_page_size */ + /* init tcg before creating CPUs */ { AccelState *accel = current_accel(); AccelClass *ac = ACCEL_GET_CLASS(accel); @@ -806,8 +806,10 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va = MAX_RESERVED_VA(cpu); if (reserved_va != 0) { - if ((reserved_va + 1) % qemu_host_page_size) { - char *s = size_to_str(qemu_host_page_size); + int host_page_size = qemu_real_host_page_size(); + + if ((reserved_va + 1) % host_page_size) { + char *s = size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s); g_free(s); exit(EXIT_FAILURE); @@ -904,7 +906,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr == 0) { - mmap_min_addr = qemu_host_page_size; + mmap_min_addr = qemu_real_host_page_size(); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx (fallback)\n", mmap_min_addr); From patchwork Tue Jan 2 01:57:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759349 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857153wrw; Mon, 1 Jan 2024 18:02:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8w7uNbhFdXdhQWE9WxfYnbiGAKnoe2bQr1HZeUeCNvctf09SzOQf+PcBI37BSuPQJeaBJ X-Received: by 2002:a05:620a:1488:b0:781:5881:aa6a with SMTP id w8-20020a05620a148800b007815881aa6amr11347401qkj.1.1704160941159; Mon, 01 Jan 2024 18:02:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160941; cv=none; d=google.com; s=arc-20160816; b=Tpfk0ZEe3m1BGARaf3EVHhSLmHqamr7MQ8ulb5UliFLWqNNLLhJR2at5qCl/WAKZoJ 89ie4RCWn8c8z2DbRc5M0luxTMAYAd2zN+GS2ggB+4YS9nfeDEP+jmSzLd/jSRPm9x26 jEJFNPaYufCbUXDW4Fk6qZIpGsqx2aKOyOMezijn8m0c73f+MADE1Dm2Xx4Vfc90fNce WggBbtkxnIAkCjYcA3SI/71x7ihPKX1fk+cpPOeiMUTuks+76+X5ay+mLIy7jlJiGWXJ JxzVjKpo//7ZMbvvXBHHXYEeLUEwLAY8D5+wKYGZu4L5KVMWviaPsROQ+0VOI11IiA1t uEMw== 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=TCVGxN0fnWUc6maO2wa7dwEI9dVIrhQYXz7yUCQwr68=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=GrMoAwMcxgmltZJ0mVNoNGcd7XdxDU1FkebmrM8fusuhT0tCaUUBbMleIXLtSMmGD0 QcLQVZ8UQ8fVrxuTH89o2k/8vv2kwzFL2RCoiVhmYL9NmypaffiZ4Wfa0wg871M7DVdK zIRqq6EHWm9r0JkIImXbhoOBhMednLRRH24fWkoEY6bbpGhd1LwVhBRB10PhDsSL4E2c UIPKHi1SIIerPaFm3RvjK9cEHLgQa9nkPDN2jyZwGyCf4k58cdEKnxjES8IomvB95ZEG qo6b/kdXxMVGpO742VOACcjeFDyqovnQGSHZl5o0fetpcp3qwQaXaqek3vARhuLMDECX bhPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gk9qLQmx; 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 i29-20020a0cab5d000000b00680bb9364f6si1345029qvb.84.2024.01.01.18.02.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:21 -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=Gk9qLQmx; 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 1rKU3O-0003Lh-99; Mon, 01 Jan 2024 20:58:50 -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 1rKU3M-0003LD-U9 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:48 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3L-00072X-4O for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:48 -0500 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3bbd6f87959so2438372b6e.1 for ; Mon, 01 Jan 2024 17:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160726; x=1704765526; 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=TCVGxN0fnWUc6maO2wa7dwEI9dVIrhQYXz7yUCQwr68=; b=Gk9qLQmxGv4qKw8p86XCfG4z+OwjmQuWyHIBOSx3Htu4N0q3gZII+kZFHZZWQ16IEo GB2BpgHcxrI+kzcFEizQmMHxps4Bm8PxgI5b/pVwB9ph/0qza+ZxVsG2VrSgV3E2tLhK RtkVmQcMen+jUC9k7ByYsrMc3qqCTKKh8UNdT1i9jXdcWLBBnZVxLUUy6ZWUGMqp4y8y lba7JnVNMDCGTZuKVnTxTWm3hALGY09t6K3zl8f8kASeEGLuubBpSOmlO5iNa7GZPJmd G5HLgAiLEeVP9HENIDHq1XB7Xd+4HRu2nxc/P4mRTuuQjxOL7SsGZCwNY90hYpPa+1Qf ev7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160726; x=1704765526; 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=TCVGxN0fnWUc6maO2wa7dwEI9dVIrhQYXz7yUCQwr68=; b=wDn9lVbb/PkTTR28Bf1YswB2T4n1jTx7cUNqpLex7hb37e/Kfhnpa1bSoez982xwOK Sw8eMPzlHBp78SozLnyHHU8+TY+jLQ+uegB1WV2Je1SfwwHmSOQRwOylLDi9iCXx4V2A RGgIFzjGEkMm+zZxo13mbpcMyiUKD/m4uRbQkqBG2pLynt252vJ4q5o6ZBPJaX0Ucs0g UBzIa604wFFtpjNoIi1ATEHi+gy6Oa6EIHNZg3vw1SOr4cbHxblRuvmyjZUoH9B/ORP2 CMUXt0v42ZpF/j4lFffsgsbW90hqeb4TYSK11LYLWnzZ2YJMHyJCsBk3I6sQEH95QUTa 2dzw== X-Gm-Message-State: AOJu0Yzb4RT0Hlq9aPFAI1mV455ELay7ID7pljUgA1r2aAdt2VKFyxBl 1e81I08H1dTeUXmdQptILlNRqj96fKiR3u2PSypQk5kfH3s= X-Received: by 2002:a05:6808:159e:b0:3bc:18d8:d208 with SMTP id t30-20020a056808159e00b003bc18d8d208mr317011oiw.30.1704160725851; Mon, 01 Jan 2024 17:58:45 -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.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 16/33] linux-user: Split out target_mmap__locked Date: Tue, 2 Jan 2024 12:57:51 +1100 Message-Id: <20240102015808.132373-17-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::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.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 All "goto fail" may be transformed to "return -1". Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/mmap.c | 62 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d11f758d07..b4c3cc65aa 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -490,9 +490,9 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) } } -/* NOTE: all the constants are the HOST ones */ -abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, - int flags, int fd, off_t offset) +static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, + int target_prot, int flags, + int fd, off_t offset) { int host_page_size = qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; @@ -500,30 +500,27 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int page_flags; off_t host_offset; - mmap_lock(); - trace_target_mmap(start, len, target_prot, flags, fd, offset); - if (!len) { errno = EINVAL; - goto fail; + return -1; } page_flags = validate_prot_to_pageflags(target_prot); if (!page_flags) { errno = EINVAL; - goto fail; + return -1; } /* Also check for overflows... */ len = TARGET_PAGE_ALIGN(len); if (!len) { errno = ENOMEM; - goto fail; + return -1; } if (offset & ~TARGET_PAGE_MASK) { errno = EINVAL; - goto fail; + return -1; } /* @@ -553,7 +550,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start == (abi_ulong)-1) { errno = ENOMEM; - goto fail; + return -1; } } @@ -574,7 +571,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, struct stat sb; if (fstat(fd, &sb) == -1) { - goto fail; + return -1; } /* Are we trying to create a map beyond EOF?. */ @@ -601,7 +598,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, p = mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { - goto fail; + return -1; } /* update start so that it points to the file position at 'offset' */ host_start = (uintptr_t)p; @@ -610,7 +607,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, flags | MAP_FIXED, fd, host_offset); if (p == MAP_FAILED) { munmap(g2h_untagged(start), host_len); - goto fail; + return -1; } host_start += offset - host_offset; } @@ -621,7 +618,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, } else { if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; - goto fail; + return -1; } last = start + len - 1; real_last = ROUND_UP(last, host_page_size) - 1; @@ -633,14 +630,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, */ if (last < start || !guest_range_valid_untagged(start, len)) { errno = ENOMEM; - goto fail; + return -1; } if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { errno = EEXIST; - goto fail; + return -1; } /* @@ -671,17 +668,17 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if ((flags & MAP_TYPE) == MAP_SHARED && (target_prot & PROT_WRITE)) { errno = EINVAL; - goto fail; + return -1; } retaddr = target_mmap(start, len, target_prot | PROT_WRITE, (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr == -1) { - goto fail; + return -1; } if (pread(fd, g2h_untagged(start), len, offset) == -1) { - goto fail; + return -1; } if (!(target_prot & PROT_WRITE)) { ret = target_mprotect(start, len, target_prot); @@ -696,14 +693,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, /* one single host page */ if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { - goto fail; + return -1; } goto the_end1; } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, target_prot, flags, fd, offset)) { - goto fail; + return -1; } real_start += host_page_size; } @@ -713,7 +710,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { - goto fail; + return -1; } real_last -= host_page_size; } @@ -739,7 +736,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, munmap(p, len1); errno = EEXIST; } - goto fail; + return -1; } passthrough_start = real_start; passthrough_last = real_last; @@ -773,11 +770,22 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, qemu_log_unlock(f); } } - mmap_unlock(); return start; -fail: +} + +/* NOTE: all the constants are the HOST ones */ +abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, + int flags, int fd, off_t offset) +{ + abi_long ret; + + trace_target_mmap(start, len, target_prot, flags, fd, offset); + mmap_lock(); + + ret = target_mmap__locked(start, len, target_prot, flags, fd, offset); + mmap_unlock(); - return -1; + return ret; } static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) From patchwork Tue Jan 2 01:57:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759336 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856085wrw; Mon, 1 Jan 2024 17:59:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IExc8Visq6VCYPH+3wU2sU1IDj9u+9fD56QwFFZ71SnfzddNWmKs+p9ms4/jXOKyxSOhA4+ X-Received: by 2002:a05:620a:1474:b0:781:7239:ae4e with SMTP id j20-20020a05620a147400b007817239ae4emr8368958qkl.79.1704160762430; Mon, 01 Jan 2024 17:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160762; cv=none; d=google.com; s=arc-20160816; b=eRO7zFTb0xzUmIBIorLbK2fcdyUgLYE73D3oc9vOWzW8MdHGtfNjhsMhgA3YEem2Ms yo3dUW1jl6vBNAqHpWtJeXqgRvFOtE0QBJTCFIMgvQzohsikZVBIskYBXsp9nFiLcL8b T1Fe7jzLtQvKf4FSOj0wy5Ynsk8CklnBrwutCYB0wAISiKyaWuBdau9AXjpmX/87EHli 4E7IJ6X38WhV15n7h3X4QrMtQIB5jXBABmp5330/7SksZgvzRMJ0HTPyH7XVk2MwrZGq LDIBm7sGux7ZPQ+kakRRzoMrjwtCpUGRfUcuNx2TUtk114SfgneV5FEOX3ITR5QxMN3z 2oIQ== 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=tnSJisjhmOEPjG/usSlqH7jpNx1heRPl0XkUSpAoUU4=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=TQX7vCO48MFmf59L5yG6X2p8a9BS1ywZ8IBilOm7HanTAs1JQbfZ3a2FEsklufuVvs mMc+nbBko5+x5mDoJlzoCZcvIud5+Qt/bfYYDbaQnUSB07uUnq5MBkawT2gCn4wNLCWS JinA2dFlRdneFTjXAZ5J7Hj04YupjSnbtGP/qx3I8GFjueeIqTHr+plcvOuwcWYBc+2Y BooBaj9nvWU/fxw2C5I7+WqucrWf4DnN9Yfc8z+s5D90SrX5GHOFNWrJmPZ3MO2IvHIq 8XPHd8x53BONjsdzAoEUCYNGEE90/t8FoBUfIcfX4PrYi7hx52wpHrJJ2EROSa1LNmyg SzKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aDr1PqNl; 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 bl13-20020a05620a1a8d00b0078170866e89si11612160qkb.479.2024.01.01.17.59.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:22 -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=aDr1PqNl; 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 1rKU3R-0003VH-K2; Mon, 01 Jan 2024 20:58:53 -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 1rKU3P-0003Lj-7U for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:51 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3N-00072u-Hi for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:50 -0500 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6d9bba6d773so4527187b3a.1 for ; Mon, 01 Jan 2024 17:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160728; x=1704765528; 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=tnSJisjhmOEPjG/usSlqH7jpNx1heRPl0XkUSpAoUU4=; b=aDr1PqNlVmx4prsdKZJYRIm1vVLFrlbT6SY+3REZiZoWHYh3Oj+ALdajLfoNkPsZh7 PUx6vukihpxMCfj0LC0oRtdffGQukkr80+Egwfr6iE8lzzLGYtjqlKy6vNGA01kyF7Tg RyzeiFyIClFuFE97n/IymEcNvGUmBlIUR+hmNzAcj6WfVP+7om1Bvfm2ODNkrZUP/Goy rxd9w8cUPUl+pAMHEGyOA6/C6rP/AMhq0TCLUDBpMP1vuy9QOc1dLcZ2v1loOFhasIpo G1Yj0MVvUGy6np5T0Eof3ZI82ryXuFCYhbSZarF2GJyQzy2tNNa/KrbGF1hJo3dCGzhd MvrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160728; x=1704765528; 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=tnSJisjhmOEPjG/usSlqH7jpNx1heRPl0XkUSpAoUU4=; b=MEB1pD6rQCL/PwJDuhOsNwFhns2lJ2ZkJIrLxq432uvz3jj+Mx1wAZit4SR1eF9jZf vRl0bXcz6k2panp6KnG0uSIQ54SgFN9Fww7vebqQYhk38+9Pp1dH87oF++J8HyISsg4g QWmy71O+7hcmo1/tYfb2webZwEByx9B1xdpxTg288oot5prnsmk57OSARQ64JvhiQvOK 4Ou+K5cwlDRfg1gshaYsRplqJ+zdqvZJf5b20epDobtJYPp/Lkp/XbgJMTbBuGxGOVl4 4D0i1lHUOfJYxs2xy94BJo1Dn3Aqyg4Yb7hzeESXOsHDt0cCbaJ3vbCSCsXFA8cagwaV Qbag== X-Gm-Message-State: AOJu0Yz40f9+oiqNHmSysAPvqJuGXeV69CriohRRvGsB3IwFCZBPAD/5 VchgXQ3pkEMs80ATrPt4o0VosRi5PtMcIB/aNr4FrS8p/2w= X-Received: by 2002:a05:6a00:1d96:b0:6d9:af31:293b with SMTP id z22-20020a056a001d9600b006d9af31293bmr17005737pfw.61.1704160728179; Mon, 01 Jan 2024 17:58:48 -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.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 17/33] linux-user: Move some mmap checks outside the lock Date: Tue, 2 Jan 2024 12:57:52 +1100 Message-Id: <20240102015808.132373-18-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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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 Basic validation of operands does not require the lock. Hoist them from target_mmap__locked back into target_mmap. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- linux-user/mmap.c | 107 +++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index b4c3cc65aa..fbaea832c5 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -491,52 +491,14 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) } static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, - int target_prot, int flags, + int target_prot, int flags, int page_flags, int fd, off_t offset) { int host_page_size = qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start = -1, passthrough_last = 0; - int page_flags; off_t host_offset; - if (!len) { - errno = EINVAL; - return -1; - } - - page_flags = validate_prot_to_pageflags(target_prot); - if (!page_flags) { - errno = EINVAL; - return -1; - } - - /* Also check for overflows... */ - len = TARGET_PAGE_ALIGN(len); - if (!len) { - errno = ENOMEM; - return -1; - } - - if (offset & ~TARGET_PAGE_MASK) { - errno = EINVAL; - return -1; - } - - /* - * If we're mapping shared memory, ensure we generate code for parallel - * execution and flush old translations. This will work up to the level - * supported by the host -- anything that requires EXCP_ATOMIC will not - * be atomic with respect to an external process. - */ - if (flags & MAP_SHARED) { - CPUState *cpu = thread_cpu; - if (!(cpu->tcg_cflags & CF_PARALLEL)) { - cpu->tcg_cflags |= CF_PARALLEL; - tb_flush(cpu); - } - } - real_start = start & -host_page_size; host_offset = offset & -host_page_size; @@ -616,23 +578,9 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, passthrough_start = start; passthrough_last = last; } else { - if (start & ~TARGET_PAGE_MASK) { - errno = EINVAL; - return -1; - } last = start + len - 1; real_last = ROUND_UP(last, host_page_size) - 1; - /* - * Test if requested memory area fits target address space - * It can fail only on 64-bit host with 32-bit target. - * On any other target/host host mmap() handles this error correctly. - */ - if (last < start || !guest_range_valid_untagged(start, len)) { - errno = ENOMEM; - return -1; - } - if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { @@ -778,13 +726,64 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, off_t offset) { abi_long ret; + int page_flags; trace_target_mmap(start, len, target_prot, flags, fd, offset); + + if (!len) { + errno = EINVAL; + return -1; + } + + page_flags = validate_prot_to_pageflags(target_prot); + if (!page_flags) { + errno = EINVAL; + return -1; + } + + /* Also check for overflows... */ + len = TARGET_PAGE_ALIGN(len); + if (!len || len != (size_t)len) { + errno = ENOMEM; + return -1; + } + + if (offset & ~TARGET_PAGE_MASK) { + errno = EINVAL; + return -1; + } + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (start & ~TARGET_PAGE_MASK) { + errno = EINVAL; + return -1; + } + if (!guest_range_valid_untagged(start, len)) { + errno = ENOMEM; + return -1; + } + } + mmap_lock(); - ret = target_mmap__locked(start, len, target_prot, flags, fd, offset); + ret = target_mmap__locked(start, len, target_prot, flags, + page_flags, fd, offset); mmap_unlock(); + + /* + * If we're mapping shared memory, ensure we generate code for parallel + * execution and flush old translations. This will work up to the level + * supported by the host -- anything that requires EXCP_ATOMIC will not + * be atomic with respect to an external process. + */ + if (ret != -1 && (flags & MAP_TYPE) != MAP_PRIVATE) { + CPUState *cpu = thread_cpu; + if (!(cpu->tcg_cflags & CF_PARALLEL)) { + cpu->tcg_cflags |= CF_PARALLEL; + tb_flush(cpu); + } + } + return ret; } From patchwork Tue Jan 2 01:57:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759338 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856099wrw; Mon, 1 Jan 2024 17:59:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHufXmkXxHlxiwa5SVsdjH/Iy7ClI15FoezJx/JSXWAQ4gYrXy1enKjdbvWndQSz9kZGM4J X-Received: by 2002:a05:6214:238b:b0:680:b342:72c0 with SMTP id fw11-20020a056214238b00b00680b34272c0mr3737431qvb.76.1704160764227; Mon, 01 Jan 2024 17:59:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160764; cv=none; d=google.com; s=arc-20160816; b=vKKiBNohBUBO5uwm55Co7/V90WzKjmRvzEYyS2YHOugEaqjwCDNhIYWi8+lTWrGHvu WGk3Ggcl4sqLj6KZXwXJ8x2n96jUw1vUtTBm3b9JxcA/MQsKFSxTgQ75wXNR5lpPzBNs TFBpyj70io9dJeiSdIHUzC940thxOgJ+k4fJYWS+c0svbmV7VO9XnMsfhwyTRSkERgKy nobM8QpYim4U5IEGjRdl7salGK+5dtSbbTqWF2I+RejjRYVYDrjET4o53zD+NSJjHu92 IT8YR0Icy4NUW0tXa5lFudf+KGmCpwTFgcirHgX3v9ylRyvf50TpfgL5GQn/fvTwzYuf vXYw== 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=/pDTiX/W/3uE1ebfbK0jDL+RrICwab7UesIidaqTDMQ=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=PI8rppCHmmyIVvD/s180dFYw0XzZ37pHRNAfe743XgffvCss/wkoq8kxr5LEks1M2d OPZ14JnlzKHTOpa9JC645pL+N9VuNgvyZEuGcsNlI1984kqonffLHNw4gTiz3byEADan eulcyAXDWsHUYZrFDDOuXQgkjhfOxeGY04dIAf6aY+x4Flb4zpExNq9nm3Iorpbr/E+p YajOEitulaffLcofU3ErIRlzZ8iAmxXaZ4F6udDGi5iZqKIZan6gXFPKl6tNeD9Ff0YB UCxiu6DWboVBlyp87G2f6loYBAoNYUs2txahs2WPNNHfN3zFxfMBoaDPLHEIW4ZjNI7S ujKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mta5MaAf; 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 s15-20020a0ce30f000000b0067f87ec5939si24708251qvl.324.2024.01.01.17.59.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:24 -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=mta5MaAf; 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 1rKU3V-0003Ze-So; Mon, 01 Jan 2024 20:58:57 -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 1rKU3Q-0003UZ-W0 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:53 -0500 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3P-00073E-Df for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:52 -0500 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-2045bedb806so6360451fac.3 for ; Mon, 01 Jan 2024 17:58:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160730; x=1704765530; 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=/pDTiX/W/3uE1ebfbK0jDL+RrICwab7UesIidaqTDMQ=; b=mta5MaAf8zmWkyZMiZx/Ho8mpo4jStj/WSBz183q2UusqAb4BpLik6lyTV5wkSs/lr 4oRWj+lpe/ZCWPKH0xCSbFXgf45Y+09x83c+3WfR0MtRm5g5A8Qzz7MT+bbzmouoI9cT WUKlMg9kltbAfvoece6yjlc/R7W3nskLZoamB23eZneWyGm3kgLvGayyfwK/fPVoZl1I 6x8NEfEh+RE01vwgZJYrB6Fb68hPyeOOVSLKc53RtK/X5ftROUEhqCPPZoEyKvhiNlJg PirrintzKyuYtQSxqtq5+K60SWM3M+oWbCq4RGfLe1XRYzpVZGLDtrOPEvcHw2mTv7IG 39Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160730; x=1704765530; 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=/pDTiX/W/3uE1ebfbK0jDL+RrICwab7UesIidaqTDMQ=; b=Go6kUORICTiyfVqJ1qk2h5rcDa++AVj0DldbvztvJ8TtogiFYzd7k5tsGaANaID1Ua GB0xNBtCY5ctyt5KJscuGWlxvUsErvmtmRZIxpZU1a0RZiDj9a+j9wxe/ELaa1NVKOhV 8mL7v8CzkKDij564bg8G9UomSGysgAqlDOmT3FZzi4Pk2OxBe9ACPcX+UkVt4KU2MfEX WUZPv8EVUCpqa97VPdYs6ZWvJVbDyEXa55J9M7czsqSBN3dzPgFnB6OqEx82m+qzik0v CL+n3Cd/rwC1ZH9XmqTujqcC9N9Xo8uP5NQ6SxsuaJj9EwwNcy7NzjKn7qOw59IPFPdW FSqA== X-Gm-Message-State: AOJu0YzNasW9FLPUUSyiTeRNbSDi0NRVoze+u9TO2DmOMUXHCYgK6/Hy Wr5KF90xyAOFqx+cvuEvvVB5kr5O/kEjFushyLa/ruIqe78= X-Received: by 2002:a05:6871:606:b0:204:c23:8831 with SMTP id w6-20020a056871060600b002040c238831mr21960222oan.37.1704160730184; Mon, 01 Jan 2024 17:58:50 -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.58.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/33] linux-user: Fix sub-host-page mmap Date: Tue, 2 Jan 2024 12:57:53 +1100 Message-Id: <20240102015808.132373-19-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=2001:4860:4864:20::29; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x29.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 We cannot skip over the_end1 to the_end, because we fail to record the validity of the guest page with the interval tree. Remove "the_end" and rename "the_end1" to "the_end". Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/mmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index fbaea832c5..48fcdd4a32 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -643,7 +643,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, target_prot, flags, fd, offset)) { return -1; } - goto the_end1; + goto the_end; } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, @@ -690,7 +690,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, passthrough_last = real_last; } } - the_end1: + the_end: if (flags & MAP_ANONYMOUS) { page_flags |= PAGE_ANON; } @@ -708,7 +708,6 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, } } shm_region_rm_complete(start, last); - the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { FILE *f = qemu_log_trylock(); From patchwork Tue Jan 2 01:57:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759347 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857152wrw; Mon, 1 Jan 2024 18:02:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEicyXArPX9d8VwQDLUt+Gg41oMjtjhLyqbT8l/I9n02G2moDNqJLyBFo0w34/FEYpdGJRt X-Received: by 2002:ad4:58d1:0:b0:67f:ba18:7d59 with SMTP id dh17-20020ad458d1000000b0067fba187d59mr13264221qvb.104.1704160941245; Mon, 01 Jan 2024 18:02:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160941; cv=none; d=google.com; s=arc-20160816; b=JnFAGJH79Mh8mbrPLn9yXncEub772ohS6rmruNe7ZQ7iDMsJtusu8xz+4b4C3D5pkf sOeOZskUweWUyebtzPGpHjxe71Dkbtz8MbvQa1SS5E3QnqaJAh1momS22Rpf5CLoM6R4 Y98HDHijK1Wn2HREMmUI/8nnKp5XCJcnNmR5lI4xIWZNq/A57coTvmheXPrJsH9fr3CJ QBbHPHOzY+vG9t1o+C1Q9V2EZM9qH+RJNG+VkeirOtTOnWV+51cxkKzkMqoa2FbBoWaO 3Up0+hG4LfA9ARRe5E2tARcw5BNRTtTLmqQb5rVe6ndCAWiVcm93hiDlE4RsPk9rYql7 Tgew== 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=bKRPPYNauFVdl96BCtCoGjZgyH5GMNCuP4SDa2Vhch0=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=VpgeNNJgnyMsFYRl6zLMgMkXxdhBafcZ7LGtFmTfuKLs94uC7MPTfvxBLBpa+22Ayr fFJYOWFYtJFoXudCDrrFKsjJmeyGhAyivN9wjfPTERGK6vVIWHDuHk3SwqqJ82Q4cqqV zE2RvgfrS7/HVu2HbIDhmFOUdVBwq2b6QF0g0By31oNM9TNuyjqqvHs+F2uUCIht375T r4ya207gZSTkSvDsumsSmEpah4B48ddbJ+PTo+1/g/tSyq2HhKmS6dkt8JRBmNBIvdb/ IyMEOCeB/oeU4eZOuC78lef+PigBcIuzmiPdKJXUIlsIVxicbAUibWOpX1Ks8JBInBjj MOVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hGjqh8EQ; 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 gw8-20020a0562140f0800b00680286f1075si17659254qvb.308.2024.01.01.18.02.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:21 -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=hGjqh8EQ; 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 1rKU3Y-0003dc-9b; Mon, 01 Jan 2024 20:59:00 -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 1rKU3T-0003XI-6D for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:55 -0500 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3R-00073e-Ix for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:54 -0500 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6dc02ab3cc9so3595964a34.3 for ; Mon, 01 Jan 2024 17:58:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160732; x=1704765532; 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=bKRPPYNauFVdl96BCtCoGjZgyH5GMNCuP4SDa2Vhch0=; b=hGjqh8EQtDOqDomytn/TRuQYx0vKuasDwt8jikwaUu0ZkrdnYOB8W/bV1K3ANlBXhM 6yyB1jbgZxQvbUKpEfbNXasvBDKHblgB7KTkkRznPUbShaHKC4TpAonQVgdbsq6m0SJo hwDunXp2fpP0KiMvOKOgElHIAf8AHsq8uCcHie6wgIAMMNi08W125TmE6OjhVcjh2pOX VcaA9DcLnjHWuI5/sBWvUx6CUFr0HG3HBKUBb32A5m/46L2nLXYMJsztPU1b0705Jo5N VhCDrwOj8rNYEKn5+QBEQOJokngIUSDN4NEDzg1/Q4gRMOClRtkqhqLx0fO5DXfTwNQt L0tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160732; x=1704765532; 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=bKRPPYNauFVdl96BCtCoGjZgyH5GMNCuP4SDa2Vhch0=; b=S6cG/HrdvyxwLKOHilwJoAsZWlxF/zeZ5qUPWta9SZ9tS9TIAmCQD5sklzpNp48UaT 1CoeEvY2b/tNCkDycavOurEK4YHgWbCacOGJwH3de4Tw4Lu/bm3TGDlQe5+0rfbuXtiY 4V+qP/nMPUKVFtmnzytr7eVLT4VPZlleoSSRc685ynbGRX6rYTl/d/5aPc9fkgpObccJ 7vvuRA0rLfWixBaVglzaOs3kMymhygbC1SH1QchMV7EueM+Gjj8cdZ+b4oSJlTW9P4/H I/8OGY5s1raN/woFSkwzt06F5KCidfSNOsL1DisA5upPuaR8bF0efm67qtdMGrBC2ohW YtjQ== X-Gm-Message-State: AOJu0YzE2ZQhcLJ/yYN9Hi2gw+3/oBBZExiIIblYvcu4yIs+cXpqkvsX P3LmExbiw4k7DJEVYSR4TMbT1JE/gsrHaBMRUTiEBnilw4g= X-Received: by 2002:a05:6808:6543:b0:3bb:d7ff:982d with SMTP id fn3-20020a056808654300b003bbd7ff982dmr9579468oib.98.1704160732598; Mon, 01 Jan 2024 17:58:52 -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.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 19/33] linux-user: Split out mmap_end Date: Tue, 2 Jan 2024 12:57:54 +1100 Message-Id: <20240102015808.132373-20-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::32c; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32c.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 Use a subroutine instead of a goto within target_mmap__locked. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- linux-user/mmap.c | 71 +++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 48fcdd4a32..cc983bedbd 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -490,6 +490,43 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) } } +/* + * Record a successful mmap within the user-exec interval tree. + */ +static abi_long mmap_end(abi_ulong start, abi_ulong last, + abi_ulong passthrough_start, + abi_ulong passthrough_last, + int flags, int page_flags) +{ + if (flags & MAP_ANONYMOUS) { + page_flags |= PAGE_ANON; + } + page_flags |= PAGE_RESET; + if (passthrough_start > passthrough_last) { + page_set_flags(start, last, page_flags); + } else { + if (start < passthrough_start) { + page_set_flags(start, passthrough_start - 1, page_flags); + } + page_set_flags(passthrough_start, passthrough_last, + page_flags | PAGE_PASSTHROUGH); + if (passthrough_last < last) { + page_set_flags(passthrough_last + 1, last, page_flags); + } + } + shm_region_rm_complete(start, last); + trace_target_mmap_complete(start); + if (qemu_loglevel_mask(CPU_LOG_PAGE)) { + FILE *f = qemu_log_trylock(); + if (f) { + fprintf(f, "page layout changed following mmap\n"); + page_dump(f); + qemu_log_unlock(f); + } + } + return start; +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) @@ -632,7 +669,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, ret = target_mprotect(start, len, target_prot); assert(ret == 0); } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } /* handle the start of the mapping */ @@ -643,7 +680,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, target_prot, flags, fd, offset)) { return -1; } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, @@ -690,34 +727,8 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, passthrough_last = real_last; } } - the_end: - if (flags & MAP_ANONYMOUS) { - page_flags |= PAGE_ANON; - } - page_flags |= PAGE_RESET; - if (passthrough_start > passthrough_last) { - page_set_flags(start, last, page_flags); - } else { - if (start < passthrough_start) { - page_set_flags(start, passthrough_start - 1, page_flags); - } - page_set_flags(passthrough_start, passthrough_last, - page_flags | PAGE_PASSTHROUGH); - if (passthrough_last < last) { - page_set_flags(passthrough_last + 1, last, page_flags); - } - } - shm_region_rm_complete(start, last); - trace_target_mmap_complete(start); - if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - FILE *f = qemu_log_trylock(); - if (f) { - fprintf(f, "page layout changed following mmap\n"); - page_dump(f); - qemu_log_unlock(f); - } - } - return start; + return mmap_end(start, last, passthrough_start, passthrough_last, + flags, page_flags); } /* NOTE: all the constants are the HOST ones */ From patchwork Tue Jan 2 01:57:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759346 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857149wrw; Mon, 1 Jan 2024 18:02:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGItYHQ822VnmI+bpAwaDVMFPMljSZmiVbJQNAOtCPSgK3IxfEGXyMuQf8a5L1xP5RwQ69b X-Received: by 2002:a05:6830:3a8a:b0:6dc:38cf:3585 with SMTP id dj10-20020a0568303a8a00b006dc38cf3585mr2841556otb.30.1704160940997; Mon, 01 Jan 2024 18:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160940; cv=none; d=google.com; s=arc-20160816; b=aMm0W1z9+MmGSWqENMJhEtk9hiVzwnBp0DKg/cTFore+odUdjAA2wIs+fEPfHhb7KX pExQxI1S2Ic7MKADf81yaxuABacgRgEQALZ/HUENN2nMGs+0nqfChZCNhOHapv792S7O Gx1IK6Nlp1JgkXswnGeAYD25/k16UlMqc6g1HBS1u9LjgrcO+4BR+WTi78i4QlEc28yV xazV0aVMPcpjo82yKv8Y+rFmvQutPIwsHEu2VlYq+o5DEQ3hzCSCMRbElioVDoDYnFJ7 7aJYqxPlrt8jCz4a9XAgcONZiF48OWJ/spzp8gvGBUE0ZYBAL+9j0Rnk3znZbaKUlTFZ g7rg== 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=ON4YI1y2oDMx99Q4aY169Mgist3E8ZTpYrSmG7+E5s0=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=XDhbNTu0S2ARy/F/FfZID+w4wdINkdf4qxnbRRJlsQ3/hJrss+WhBkB9IKefhuDd/A yxQDEYGzsPbd6x2ts/5TKqnmXKnMqpOa6/DGpJmd6l5wOOHNT1QvBea8scaCbQCkEhRb ZFOs9hw/o0lAgyQAhGhzwD5DFt6GBDSVlbNhHv99i3B/rPszf1XXQ3tjBHr1Pw/HU0/f jMv29jx8nvJXtidxCC5U2x3CPVEaoE5I6m/kQZBp1Ir1Dqg1ATObVusBCTLsqNhjCReW ryTWxt/4iiw0211KWwYlKJRDLPbJcCPVGfvqyhtSmFfbUSQZvVKlfsXsaja0EBvS4x2M +ViQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tb4xDMgs; 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 cf15-20020a05622a400f00b004283016d2f1si218400qtb.44.2024.01.01.18.02.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:20 -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=Tb4xDMgs; 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 1rKU3c-0003f2-GC; Mon, 01 Jan 2024 20:59:06 -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 1rKU3V-0003ZL-4m for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:57 -0500 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3T-00073z-Jl for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:56 -0500 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-7baa8097064so369441439f.3 for ; Mon, 01 Jan 2024 17:58:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160734; x=1704765534; 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=ON4YI1y2oDMx99Q4aY169Mgist3E8ZTpYrSmG7+E5s0=; b=Tb4xDMgsQUE+5uE/iEygMpjqTaA1PBZBNfE73lM0RsI2oJjm1uO4S2vnAuyAwjkFFS H5DLnNpeWD8n7Ln43ABMuAeBgv4M9T0jH1MJL4NyZrdKU30la3CHHC6fExh4GkubCR9T a3zTtY65pNhsnZt2DKotiHv/qIGQ1qx3izQu7UzQ0rPCho8QjSsnNNFS90nNr2FHZkTT PIij2kTppHK6s1OJnz2ShhOPaSzwVYApuJWMRwks9+Zt/vad+jBq+Ify6+q3vWqdjBHf m41L4mTlfrc+J5Dg350JfuoaAGQb/QsiBp6NjLDhHRGJwbKRd2WwXGiEvVAnNAWHhWId cKGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160734; x=1704765534; 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=ON4YI1y2oDMx99Q4aY169Mgist3E8ZTpYrSmG7+E5s0=; b=WvCKrCQEKxwBFKzahdEKHqZS+0JVOXnkAUAFLpaFJlGEovurhd5MAl891LxBhzEi5p cGLDT0fS0wph1cu+TKqYHoLp9V2CwKTt5DaQnuECCt/xJ9bmU4Ot09GS3zvStKFN1k/p jmBIQV/1lhtrKFuwuccygxgDehshFqVbCR89EkX0PTofsHbnOhzjs93z8+DP9c2dLN6W YCzMQTPNAw6qsyl5rICHyvtQV0l6lrAUm5pe8qT5kYB+eE8llZKpjZGY2u9Prxfm7Bqe ByixvmZzOayrdpiDSUm0DXVtpylRuVDgUduvBhC57vnIzJRlDFNHZTVDFgR/yM9Cnwam HXyA== X-Gm-Message-State: AOJu0YyoJg9p0G+4BrTN30DG1hFEiJBDrPDzY1vju4uoOSRN0Yy6fmIR 0jMISMASMRYIpQnVMR4rCeM7+TOymlfSUXrBzde/LuZGDjg= X-Received: by 2002:a05:6e02:17c6:b0:360:16c7:2d6a with SMTP id z6-20020a056e0217c600b0036016c72d6amr12526230ilu.48.1704160734489; Mon, 01 Jan 2024 17:58:54 -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.58.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/33] linux-user: Do early mmap placement only for reserved_va Date: Tue, 2 Jan 2024 12:57:55 +1100 Message-Id: <20240102015808.132373-21-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::d34; envelope-from=richard.henderson@linaro.org; helo=mail-io1-xd34.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 For reserved_va, place all non-fixed maps then proceed as for MAP_FIXED. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- linux-user/mmap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index cc983bedbd..42eb3eb2b4 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -540,17 +540,19 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, host_offset = offset & -host_page_size; /* - * If the user is asking for the kernel to find a location, do that - * before we truncate the length for mapping files below. + * For reserved_va, we are in full control of the allocation. + * Find a suitible hole and convert to MAP_FIXED. */ - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len = len + offset - host_offset; - host_len = ROUND_UP(host_len, host_page_size); - start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); + start = mmap_find_vma(real_start, host_len, + MAX(host_page_size, TARGET_PAGE_SIZE)); if (start == (abi_ulong)-1) { errno = ENOMEM; return -1; } + start += offset - host_offset; + flags |= MAP_FIXED; } /* From patchwork Tue Jan 2 01:57:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759348 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857154wrw; Mon, 1 Jan 2024 18:02:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZYuEVIW1sOIfxc5TrbLyCCt5uYcHsiOBPkt2mgue8Y2RtNePAWZYZG0na1mFiBnuVAn4m X-Received: by 2002:a05:6214:da1:b0:67f:2f9e:5184 with SMTP id h1-20020a0562140da100b0067f2f9e5184mr28967498qvh.15.1704160941378; Mon, 01 Jan 2024 18:02:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160941; cv=none; d=google.com; s=arc-20160816; b=AmAwln4HmJGsCEjreNnEE22E8lnPbFHoGMmP4kfGIcvnK6VrzklmzNXup6YVAX0u54 1E7IWHcHiqAL9CfM03qcXZvRxTQlu6zhbCMCHOsObC8mM7w6rsVIksT0NobEbvm3/LXP 8XEq92IIFNWEkvQEsVKifLnhrE2An8i4Zc4TqBQwt+OBTS0+8YSe6cni6DTeIhfbuIDO MfrTQU7xJss4f4WoRYK2NyoJ7Ln0UfKID98orpB4lGDLqkdY5S0sF/qnS7Py4P02mNvF Zx44w5RtH8roNhW+EKD3t6hWpbU1VHhJ1Z7G7dlXwGoiAMFPWzQrdIyj7Jt/NhnRi1Q8 rcww== 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=Agx2bj5+PO3H0m/DZ+WXfvcf7Vu2LJVqySA/YVtXeLI=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=YfRi1zX/G//4rkfmbM0myLCSfRuPvrRfbfH5gbnMgIowF7ZGsET0GOxrDCX2S9G442 uO7L55Uzo99CzB/cq/9PtbfAufPnxqAw/pjUFyANT4wPrfe3C/GrpKCA8OFKqW9qPLFs 3Vo21Q3Sb4twapAI1qWYS99fni4J2wMr0cxWea+unsVOYOt7ViE0icWH2ZYRGIY/8/jx nIBASbU49S8q6cgJYKzInUnkUHF6NjDaKrZTc52tUnRVjf4poCxXhuvSdszLYONY0QyZ 0QqtaZ/P0FfvMEtri+b4EWXHeTLke5OhnyurJcC8EA52RqJSiPlEfm6eev26iuk+aqDH MFSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MJ21oOH6; 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 t20-20020a0cb394000000b0068080216cafsi9781293qve.369.2024.01.01.18.02.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:21 -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=MJ21oOH6; 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 1rKU3e-0003h0-Fy; Mon, 01 Jan 2024 20:59:06 -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 1rKU3X-0003ca-V1 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:59 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3V-00074J-P8 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:59 -0500 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-28c467446f0so3839128a91.0 for ; Mon, 01 Jan 2024 17:58:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160736; x=1704765536; 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=Agx2bj5+PO3H0m/DZ+WXfvcf7Vu2LJVqySA/YVtXeLI=; b=MJ21oOH6KOGyz7Jwk2LdJrOs+delovfo2tJApoUL7RsNSLn0oEohvF4s4Wzm30E9Rn UHSCRBmbGYSaDPpOo4cYUi9DaDoQYCPfuXAFURFeKwpFBtwYQx9HV3Hn5UhGfVp/WN4g boiSXGmYkBIKTtwXqEHJI3TJaYLWEvfq3tv3PZb6NTtWMRAIsMiNPmv2wlzUKgzF0d+S XlE4M6XbXjUOzKsZrElWbHOS79ePgpO8+lGZ4/2RKoJxSLOb94pKsZ18/eVYFv3KgtTv PSCA1Nhjj6sD8bHGyrMhkha5rCopwcI9GtPtX3OZVDjV2abfmjdivJMxyrB/RpKRLk77 GXHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160736; x=1704765536; 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=Agx2bj5+PO3H0m/DZ+WXfvcf7Vu2LJVqySA/YVtXeLI=; b=YnvpT7Hlz9kqXyLhnEHVwSV74/2QzIFfcmWDAGdW/guUL+Jtap757nsw/Eve3OsQDd zYf0Dnzno+mmQOo/Rdpzmlz0sWq/rHc0fksgt3OhNMoJFIn/cZSYyBzLywuy1jRrLfca dKZ8an1+9bWIfCCawvN1G+xrs/q0MMFAcDiTmBH+hgj1EL05mUdckSzT5LUg6DdIbfCt Vo60RYjjJCLuizC9wUyqoAUPZ6uxSuhSdP+cyqQ53RmDyzVnJZ8/uaaZHNh48RQr7V66 5MGrekkVr0gEmjzhibk4Qs8f8OhTOQAASt30grjbF1ZZHD2SgJkLnXe9PxLoJ3SdZAva Tdyg== X-Gm-Message-State: AOJu0YxfKThpOcUOd+TuassZHMfpYa3wVzY3UoNznDTHO9OgpTLL1kSc RnG/nRg0/IKf0OZ7wWzXOJe2E94m0Wry96Y8O3on/4gD944= X-Received: by 2002:a17:90a:de04:b0:28b:bd9d:8d50 with SMTP id m4-20020a17090ade0400b0028bbd9d8d50mr19527276pjv.13.1704160736445; Mon, 01 Jan 2024 17:58:56 -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.58.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/33] linux-user: Split out mmap_h_eq_g Date: Tue, 2 Jan 2024 12:57:56 +1100 Message-Id: <20240102015808.132373-22-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::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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 Move the MAX_FIXED_NOREPLACE check for reserved_va earlier. Move the computation of host_prot earlier. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/mmap.c | 66 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 42eb3eb2b4..00003b8329 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -527,6 +527,31 @@ static abi_long mmap_end(abi_ulong start, abi_ulong last, return start; } +/* + * Special case host page size == target page size, + * where there are no edge conditions. + */ +static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len, + int host_prot, int flags, int page_flags, + int fd, off_t offset) +{ + void *p, *want_p = g2h_untagged(start); + abi_ulong last; + + p = mmap(want_p, len, host_prot, flags, fd, offset); + if (p == MAP_FAILED) { + return -1; + } + if ((flags & MAP_FIXED_NOREPLACE) && p != want_p) { + errno = EEXIST; + return -1; + } + + start = h2g(p); + last = start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) @@ -535,6 +560,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start = -1, passthrough_last = 0; off_t host_offset; + int host_prot; real_start = start & -host_page_size; host_offset = offset & -host_page_size; @@ -543,16 +569,33 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, * For reserved_va, we are in full control of the allocation. * Find a suitible hole and convert to MAP_FIXED. */ - if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - host_len = len + offset - host_offset; - start = mmap_find_vma(real_start, host_len, - MAX(host_page_size, TARGET_PAGE_SIZE)); - if (start == (abi_ulong)-1) { - errno = ENOMEM; - return -1; + if (reserved_va) { + if (flags & MAP_FIXED_NOREPLACE) { + /* Validate that the chosen range is empty. */ + if (!page_check_range_empty(start, start + len - 1)) { + errno = EEXIST; + return -1; + } + flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; + } else if (!(flags & MAP_FIXED)) { + size_t real_len = len + offset - host_offset; + abi_ulong align = MAX(host_page_size, TARGET_PAGE_SIZE); + + start = mmap_find_vma(real_start, real_len, align); + if (start == (abi_ulong)-1) { + errno = ENOMEM; + return -1; + } + start += offset - host_offset; + flags |= MAP_FIXED; } - start += offset - host_offset; - flags |= MAP_FIXED; + } + + host_prot = target_to_host_prot(target_prot); + + if (host_page_size == TARGET_PAGE_SIZE) { + return mmap_h_eq_g(start, len, host_prot, flags, + page_flags, fd, offset); } /* @@ -588,12 +631,10 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { uintptr_t host_start; - int host_prot; void *p; host_len = len + offset - host_offset; host_len = ROUND_UP(host_len, host_page_size); - host_prot = target_to_host_prot(target_prot); /* Note: we prefer to control the mapping address. */ p = mmap(g2h_untagged(start), host_len, host_prot, @@ -716,8 +757,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, len1 = real_last - real_start + 1; want_p = g2h_untagged(real_start); - p = mmap(want_p, len1, target_to_host_prot(target_prot), - flags, fd, offset1); + p = mmap(want_p, len1, host_prot, flags, fd, offset1); if (p != want_p) { if (p != MAP_FAILED) { munmap(p, len1); From patchwork Tue Jan 2 01:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759343 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856652wrw; Mon, 1 Jan 2024 18:00:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPrFNyqS8qxwZuyesIuZtRDwBO64wgEBmqHH7XW5LUfVb1RKEl6UhPpcQTnFoZjh1zDQrm X-Received: by 2002:a05:620a:4903:b0:781:b736:f03d with SMTP id vy3-20020a05620a490300b00781b736f03dmr3559405qkn.101.1704160856924; Mon, 01 Jan 2024 18:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160856; cv=none; d=google.com; s=arc-20160816; b=MeEv8MPoxRRGezUmTYS4jwb7VBm9OGeKL+R8KTsUiCgGiT2j3oAK83zhkyBplB9uIg d5E76eZzphdx4YNruU2M3GTgEoVlGfTUkqby/iw+AP0haHmlwJAiY+rY+wipfxF347Uf 1rolix9rDWwdr3FUtjAifzjKnCFOF7vApdOLcff2ZJvoO1/x0QpqRXVMSW/O0DNQ+gPy KNl/FSwlozhBaMwpJQ0pjoHfeZbiOVufzhs6MJevFXfAJoD2OiCALRvtQImAkba7VsAq udRRx70p7SbbncpSglBOpxcJSqwBdBvnya4l9+Aqond11xhqYlxVJKf6PARat8zvknVc PTYw== 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=qA2a/PTKZLcZg5cbX228JZnmG9F2Eb0mEU1DFgp6lOI=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=lDnVLWhMJdCRTv40QNWMKeIwLkU4JbeuVAb1xuD3MdITc3uN6y/+1XvxV3FMvNOiRS Zkz/Gbu7VRRGkcMsVEmyDdBc2/ZPtMNJFTB0GwqxX64se8Uo2stJ38SgsTW/xyihrG6Q T1p+OPwoENmXX0Cj5zh1EcKV72FRa2NP8L9q3TFAIKrjo7gu35TpcTZD3ejw7wRKPJg1 pIrH+4wtQ4SBYhQiJADhfMn6txGnsKhrcws9LEvuV9rRFPXortTvRTAuFXfXMu5GGyIV vpLTNzNFyPISWilbxsVlX7YvjGfqJLDWfnc8FPeE61ZUdm84vitkf+YMmpfdg17BgtyV 6A3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tXc2OJRC; 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 b26-20020a05620a089a00b0078154cbc43dsi14786840qka.652.2024.01.01.18.00.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:00:56 -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=tXc2OJRC; 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 1rKU3l-0003kr-Ow; Mon, 01 Jan 2024 20:59:13 -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 1rKU3Z-0003eP-Gl for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:02 -0500 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3X-00074b-NB for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:01 -0500 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6dc018228b4so3062009a34.0 for ; Mon, 01 Jan 2024 17:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160738; x=1704765538; 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=qA2a/PTKZLcZg5cbX228JZnmG9F2Eb0mEU1DFgp6lOI=; b=tXc2OJRCBlQorvRvX/hn7/nUSOktcroMzwn7shw9Ag9QDegfsFDZL9vh7pP7BDY7c9 eWkvxNHJwGNUEmNHcnsg4HTkQBsYMDYnuxj8ejlLAkdhyyCkfE3+5R+fLg7PU0kthK9p pHHI+CgX5sJa/qSONH7mzWCpXkX9p/l+m3iqCE0JhSwx3fLDAMkMUJhey0DN8o19n/8K 75rGkVfBNqQwBT/r5xU+3GqNKjmr+vMoryFe5OKqDCMzPFuwGE30M50MqoedJkdAcpxg JJMKTATANwZ0BS4mTmZdS2HFQSwAagMwdzKkweq5Y28ERjRG5PnfTsRjSWnDpodXjr+6 Szfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160738; x=1704765538; 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=qA2a/PTKZLcZg5cbX228JZnmG9F2Eb0mEU1DFgp6lOI=; b=ltEru97ggWBl4JCiDGqeucl2+tdK3q1ukBpAR26kyLnI9k0VlFycTOPYi6jQrhTXm5 zr24f47eCJbGYiIdb3BonG9BdYcF5+ktMfTsIN2CZ92daCnzgeHol9QDu6pq3kZLyMoQ iM3Cpa3RS+mULl1MwgcW7N1Mpwxf2c6IidGoxldjzm4BoQoo1yBrmQBj1ukfP06CJoxh mxff6yj122w6Sdutg1mCqsTG7ERwOGn6Z8yYCEvACUhC4k/EzEG9/F6JUXYo2ODvlam6 H3aMMakjoOb76QsolGhJFniqfJcfVdSjmhRDudqjGJfAWljWCcW5k4j6fagw/xt6GX/H ZmYw== X-Gm-Message-State: AOJu0YwAi/PH4bFFRHXunPr82S96hvvz7zpHYlE3oP6ZxiJqK5OQftqK pZFJXQgvtJ1kHggVN++dugSGn3rMRpSqs0qiExkgMa4moe0= X-Received: by 2002:a05:6808:238e:b0:3bb:e1bb:3546 with SMTP id bp14-20020a056808238e00b003bbe1bb3546mr6643355oib.44.1704160738363; Mon, 01 Jan 2024 17:58:58 -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.58.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 22/33] linux-user: Split out mmap_h_lt_g Date: Tue, 2 Jan 2024 12:57:57 +1100 Message-Id: <20240102015808.132373-23-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::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.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 Work much harder to get alignment and mapping beyond the end of the file correct. Both of which are excercised by our test-mmap for alpha (8k pages) on any 4k page host. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/mmap.c | 156 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 31 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 00003b8329..8b0a26e50d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -552,6 +552,128 @@ static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len, return mmap_end(start, last, start, last, flags, page_flags); } +/* + * Special case host page size < target page size. + * + * The two special cases are increased guest alignment, and mapping + * past the end of a file. + * + * When mapping files into a memory area larger than the file, + * accesses to pages beyond the file size will cause a SIGBUS. + * + * For example, if mmaping a file of 100 bytes on a host with 4K + * pages emulating a target with 8K pages, the target expects to + * be able to access the first 8K. But the host will trap us on + * any access beyond 4K. + * + * When emulating a target with a larger page-size than the hosts, + * we may need to truncate file maps at EOF and add extra anonymous + * pages up to the targets page boundary. + * + * This workaround only works for files that do not change. + * If the file is later extended (e.g. ftruncate), the SIGBUS + * vanishes and the proper behaviour is that changes within the + * anon page should be reflected in the file. + * + * However, this case is rather common with executable images, + * so the workaround is important for even trivial tests, whereas + * the mmap of of a file being extended is less common. + */ +static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong len, int host_prot, + int mmap_flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p = g2h_untagged(start); + off_t fileend_adj = 0; + int flags = mmap_flags; + abi_ulong last, pass_last; + + if (!(flags & MAP_ANONYMOUS)) { + struct stat sb; + + if (fstat(fd, &sb) == -1) { + return -1; + } + if (offset >= sb.st_size) { + /* + * The entire map is beyond the end of the file. + * Transform it to an anonymous mapping. + */ + flags |= MAP_ANONYMOUS; + fd = -1; + offset = 0; + } else if (offset + len > sb.st_size) { + /* + * A portion of the map is beyond the end of the file. + * Truncate the file portion of the allocation. + */ + fileend_adj = offset + len - sb.st_size; + } + } + + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (fileend_adj) { + p = mmap(want_p, len, host_prot, flags | MAP_ANONYMOUS, -1, 0); + } else { + p = mmap(want_p, len, host_prot, flags, fd, offset); + } + if (p != want_p) { + if (p != MAP_FAILED) { + munmap(p, len); + errno = EEXIST; + } + return -1; + } + + if (fileend_adj) { + void *t = mmap(p, len - fileend_adj, host_prot, + (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED, + fd, offset); + assert(t != MAP_FAILED); + } + } else { + size_t host_len, part_len; + + /* + * Take care to align the host memory. Perform a larger anonymous + * allocation and extract the aligned portion. Remap the file on + * top of that. + */ + host_len = len + TARGET_PAGE_SIZE - host_page_size; + p = mmap(want_p, host_len, host_prot, flags | MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) { + return -1; + } + + part_len = (uintptr_t)p & (TARGET_PAGE_SIZE - 1); + if (part_len) { + part_len = TARGET_PAGE_SIZE - part_len; + munmap(p, part_len); + p += part_len; + host_len -= part_len; + } + if (len < host_len) { + munmap(p + len, host_len - len); + } + + if (!(flags & MAP_ANONYMOUS)) { + void *t = mmap(p, len - fileend_adj, host_prot, + flags | MAP_FIXED, fd, offset); + assert(t != MAP_FAILED); + } + + start = h2g(p); + } + + last = start + len - 1; + if (fileend_adj) { + pass_last = ROUND_UP(last - fileend_adj, host_page_size) - 1; + } else { + pass_last = last; + } + return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) @@ -596,37 +718,9 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, if (host_page_size == TARGET_PAGE_SIZE) { return mmap_h_eq_g(start, len, host_prot, flags, page_flags, fd, offset); - } - - /* - * When mapping files into a memory area larger than the file, accesses - * to pages beyond the file size will cause a SIGBUS. - * - * For example, if mmaping a file of 100 bytes on a host with 4K pages - * emulating a target with 8K pages, the target expects to be able to - * access the first 8K. But the host will trap us on any access beyond - * 4K. - * - * When emulating a target with a larger page-size than the hosts, we - * may need to truncate file maps at EOF and add extra anonymous pages - * up to the targets page boundary. - */ - if (host_page_size < TARGET_PAGE_SIZE && !(flags & MAP_ANONYMOUS)) { - struct stat sb; - - if (fstat(fd, &sb) == -1) { - return -1; - } - - /* Are we trying to create a map beyond EOF?. */ - if (offset + len > sb.st_size) { - /* - * If so, truncate the file map at eof aligned with - * the hosts real pagesize. Additional anonymous maps - * will be created beyond EOF. - */ - len = ROUND_UP(sb.st_size - offset, host_page_size); - } + } else if (host_page_size < TARGET_PAGE_SIZE) { + return mmap_h_lt_g(start, len, host_prot, flags, + page_flags, fd, offset, host_page_size); } if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { From patchwork Tue Jan 2 01:57:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759352 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857262wrw; Mon, 1 Jan 2024 18:02:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsVNJnXt7MJB5QupvWSohOSj43KSnxH0ziD4AObiGBpWvRNdwin+UOudiyjOLFAAYtXj4s X-Received: by 2002:ac8:5e53:0:b0:428:5d4:23f2 with SMTP id i19-20020ac85e53000000b0042805d423f2mr11524361qtx.88.1704160961737; Mon, 01 Jan 2024 18:02:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160961; cv=none; d=google.com; s=arc-20160816; b=RiH31Qi0rj2tFimBkTv/dANeRqrrRQ2zu5bO5LaJFZM3KSAG3BizsDeoZRn4NS+Tlk CH61qYJESvW6kSpPEh5sS5hk00USL5S5FTbsrFuLIASpVqh/d2WgNormJDQMjTz+FiUF txj9jJ4dLi5XIhajFAw4zkbMf5Yl06MP1UeCvXR3S+PSxsFN8zobYt3lqsRb5kdI4SlW QC8Lv23q9czTH2MhCMUjHvQrLAYKv99eDDHc0MHWd2Pdr4A0Sk7fAzW9EkAnfrl/7fnf cn6yQVMb6COxhoO9BQ5+y8nZo7Vvn/U222dauckKLtJHt374E15iKngIO4IhDmkXv3LK URQg== 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=91iOKn1k81Cro3s73UIymmbxi5Yza4EKTI5xgt9Gnn0=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=eJ9VEMSwZWTue/f+wOPomDUwibino0Hs68xZEdUm8sVVcg8kXMZWr0wpuJ4eAMyio8 +eUfpexQyv9KzvkC86nSRLWoX+oNWh8hnnqgVf4EoRTRPd/ZD4OXFiAKaBO/A2A1tqM/ 6vCir2eQM7W8bfk65SiaH+eYHBJOggx6rnIoZ5yQg0fulE18zZNXpmxfs80iT17IhJl+ tI/h21SZ/BHNG3nEWCDrNtLEakvy9qUTTeGLBACE5wqWnrNUoK4SKiGeHjrEHxY4jdih rbhJ8Kqhd0FtTzWybLp+fPsTSMDXXSIgmR0TQ/8eXkzR2NevdWUVcU1u41hL9fJfPd5U /BIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OldZWGLk; 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 ga17-20020a05622a591100b00427f8a608b3si11202972qtb.356.2024.01.01.18.02.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:41 -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=OldZWGLk; 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 1rKU3m-0003m5-Gi; Mon, 01 Jan 2024 20:59:14 -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 1rKU3b-0003eV-Sy for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:04 -0500 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3Z-000750-T0 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:03 -0500 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-2053f5e97b2so986358fac.3 for ; Mon, 01 Jan 2024 17:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160740; x=1704765540; 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=91iOKn1k81Cro3s73UIymmbxi5Yza4EKTI5xgt9Gnn0=; b=OldZWGLkhKhYvSqCuv2XATUwEtFySavBMHQlSRyBGMXaoqtkujjEegVCniQccg1vNJ w7auVqEd+p34eSDT78iR2NIERR4yhHQg24UgYaMhQ2x20D14ja1en2XAQZs3fLkU/fkj oluK9ujK5zfzYAROdyQCzmr4GOK/RziIZkQs9sYnUmkH+9JlpHQzvfWQwlnnnwscHdIW 72IvlZwVUreRYJ//abw8MLApq3IC66eQ/qcb4zoKPktWOBsH04XmX/WytFdahJLVi2If MwpnI4WDddNoSKuM2pZNFCTxiabVWSFApfiVuIpQD99MxwnK6z8PIv1FNWZykEssZpLP asEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160741; x=1704765541; 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=91iOKn1k81Cro3s73UIymmbxi5Yza4EKTI5xgt9Gnn0=; b=dxk5YCqVlfeMyKzm0kqFooASeugkzotoJeV6B9oPVRt82eKbiMQ0GlyTsTJzPI0AW6 d3V9VS9vt/AJGcslNyPD0hrZ56m0Nn1tOWNokEDo+A0yLDnEMLzZcZoejeadqH6Jdv+1 FXnhX0hYKPxd25IjgX4knufzon3hlEge2byIk6PIqKLgISQxVVfk3301SZUoMxOCIhpG qwyqkvirosPcEtO20UU5G1oKOG5TNUSjpNa84L60joyHWtdb/wcUIsoQV12kmZSvGWJ1 eWelvW7B1r7mY/BUzBGE7hJtFDTZyxiCACJLJU0do1aYQMiQe55IqWmF/9cpJHLPtVw+ F8xw== X-Gm-Message-State: AOJu0Yylo3IlMsUpaBDW9D/Yjq74U1uVzts2wDFNA0WtjvtVr5GhcMXB eoMkDi5z5CREeEDz6LMgs6LDvP5zF55rEpjojo3GtJwTHOc= X-Received: by 2002:a05:6870:ac26:b0:203:7dc:6f26 with SMTP id kw38-20020a056870ac2600b0020307dc6f26mr20833991oab.63.1704160740652; Mon, 01 Jan 2024 17:59:00 -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.58.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/33] linux-user: Split out mmap_h_gt_g Date: Tue, 2 Jan 2024 12:57:58 +1100 Message-Id: <20240102015808.132373-24-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=2001:4860:4864:20::31; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x31.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 Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/mmap.c | 288 ++++++++++++++++++++++------------------------ 1 file changed, 139 insertions(+), 149 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 8b0a26e50d..552656edd4 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -267,7 +267,16 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) return ret; } -/* map an incomplete host page */ +/* + * Map an incomplete host page. + * + * Here be dragons. This case will not work if there is an existing + * overlapping host page, which is file mapped, and for which the mapping + * is beyond the end of the file. In that case, we will see SIGBUS when + * trying to write a portion of this page. + * + * FIXME: Work around this with a temporary signal handler and longjmp. + */ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, int prot, int flags, int fd, off_t offset) { @@ -674,19 +683,138 @@ static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong len, int host_prot, return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); } +/* + * Special case host page size > target page size. + * + * The two special cases are address and file offsets that are valid + * for the guest that cannot be directly represented by the host. + */ +static abi_long mmap_h_gt_g(abi_ulong start, abi_ulong len, + int target_prot, int host_prot, + int flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p = g2h_untagged(start); + off_t host_offset = offset & -host_page_size; + abi_ulong last, real_start, real_last; + bool misaligned_offset = false; + size_t host_len; + + if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + /* + * Adjust the offset to something representable on the host. + */ + host_len = len + offset - host_offset; + p = mmap(want_p, host_len, host_prot, flags, fd, host_offset); + if (p == MAP_FAILED) { + return -1; + } + + /* Update start to the file position at offset. */ + p += offset - host_offset; + + start = h2g(p); + last = start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); + } + + if (!(flags & MAP_ANONYMOUS)) { + misaligned_offset = (start ^ offset) & (host_page_size - 1); + + /* + * The fallback for misalignment is a private mapping + read. + * This carries none of semantics required of MAP_SHARED. + */ + if (misaligned_offset && (flags & MAP_TYPE) != MAP_PRIVATE) { + errno = EINVAL; + return -1; + } + } + + last = start + len - 1; + real_start = start & -host_page_size; + real_last = ROUND_UP(last, host_page_size) - 1; + + /* + * Handle the start and end of the mapping. + */ + if (real_start < start) { + abi_ulong real_page_last = real_start + host_page_size - 1; + if (last <= real_page_last) { + /* Entire allocation a subset of one host page. */ + if (!mmap_frag(real_start, start, last, target_prot, + flags, fd, offset)) { + return -1; + } + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + if (!mmap_frag(real_start, start, real_page_last, target_prot, + flags, fd, offset)) { + return -1; + } + real_start = real_page_last + 1; + } + + if (last < real_last) { + abi_ulong real_page_start = real_last - host_page_size + 1; + if (!mmap_frag(real_page_start, real_page_start, last, + target_prot, flags, fd, + offset + real_page_start - start)) { + return -1; + } + real_last = real_page_start - 1; + } + + if (real_start > real_last) { + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + /* + * Handle the middle of the mapping. + */ + + host_len = real_last - real_start + 1; + want_p += real_start - start; + + if (flags & MAP_ANONYMOUS) { + p = mmap(want_p, host_len, host_prot, flags, -1, 0); + } else if (!misaligned_offset) { + p = mmap(want_p, host_len, host_prot, flags, fd, + offset + real_start - start); + } else { + p = mmap(want_p, host_len, host_prot | PROT_WRITE, + flags | MAP_ANONYMOUS, -1, 0); + } + if (p != want_p) { + if (p != MAP_FAILED) { + munmap(p, host_len); + errno = EEXIST; + } + return -1; + } + + if (misaligned_offset) { + /* TODO: The read could be short. */ + if (pread(fd, p, host_len, offset + real_start - start) != host_len) { + munmap(p, host_len); + return -1; + } + if (!(host_prot & PROT_WRITE)) { + mprotect(p, host_len, host_prot); + } + } + + return mmap_end(start, last, -1, 0, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) { int host_page_size = qemu_real_host_page_size(); - abi_ulong ret, last, real_start, real_last, retaddr, host_len; - abi_ulong passthrough_start = -1, passthrough_last = 0; - off_t host_offset; int host_prot; - real_start = start & -host_page_size; - host_offset = offset & -host_page_size; - /* * For reserved_va, we are in full control of the allocation. * Find a suitible hole and convert to MAP_FIXED. @@ -700,6 +828,8 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, } flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; } else if (!(flags & MAP_FIXED)) { + abi_ulong real_start = start & -host_page_size; + off_t host_offset = offset & -host_page_size; size_t real_len = len + offset - host_offset; abi_ulong align = MAX(host_page_size, TARGET_PAGE_SIZE); @@ -721,150 +851,10 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, } else if (host_page_size < TARGET_PAGE_SIZE) { return mmap_h_lt_g(start, len, host_prot, flags, page_flags, fd, offset, host_page_size); - } - - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - uintptr_t host_start; - void *p; - - host_len = len + offset - host_offset; - host_len = ROUND_UP(host_len, host_page_size); - - /* Note: we prefer to control the mapping address. */ - p = mmap(g2h_untagged(start), host_len, host_prot, - flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); - if (p == MAP_FAILED) { - return -1; - } - /* update start so that it points to the file position at 'offset' */ - host_start = (uintptr_t)p; - if (!(flags & MAP_ANONYMOUS)) { - p = mmap(g2h_untagged(start), len, host_prot, - flags | MAP_FIXED, fd, host_offset); - if (p == MAP_FAILED) { - munmap(g2h_untagged(start), host_len); - return -1; - } - host_start += offset - host_offset; - } - start = h2g(host_start); - last = start + len - 1; - passthrough_start = start; - passthrough_last = last; } else { - last = start + len - 1; - real_last = ROUND_UP(last, host_page_size) - 1; - - if (flags & MAP_FIXED_NOREPLACE) { - /* Validate that the chosen range is empty. */ - if (!page_check_range_empty(start, last)) { - errno = EEXIST; - return -1; - } - - /* - * With reserved_va, the entire address space is mmaped in the - * host to ensure it isn't accidentally used for something else. - * We have just checked that the guest address is not mapped - * within the guest, but need to replace the host reservation. - * - * Without reserved_va, despite the guest address check above, - * keep MAP_FIXED_NOREPLACE so that the guest does not overwrite - * any host address mappings. - */ - if (reserved_va) { - flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; - } - } - - /* - * worst case: we cannot map the file because the offset is not - * aligned, so we read it - */ - if (!(flags & MAP_ANONYMOUS) && - (offset & (host_page_size - 1)) != (start & (host_page_size - 1))) { - /* - * msync() won't work here, so we return an error if write is - * possible while it is a shared mapping - */ - if ((flags & MAP_TYPE) == MAP_SHARED - && (target_prot & PROT_WRITE)) { - errno = EINVAL; - return -1; - } - retaddr = target_mmap(start, len, target_prot | PROT_WRITE, - (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) - | MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0); - if (retaddr == -1) { - return -1; - } - if (pread(fd, g2h_untagged(start), len, offset) == -1) { - return -1; - } - if (!(target_prot & PROT_WRITE)) { - ret = target_mprotect(start, len, target_prot); - assert(ret == 0); - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - - /* handle the start of the mapping */ - if (start > real_start) { - if (real_last == real_start + host_page_size - 1) { - /* one single host page */ - if (!mmap_frag(real_start, start, last, - target_prot, flags, fd, offset)) { - return -1; - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - if (!mmap_frag(real_start, start, - real_start + host_page_size - 1, - target_prot, flags, fd, offset)) { - return -1; - } - real_start += host_page_size; - } - /* handle the end of the mapping */ - if (last < real_last) { - abi_ulong real_page = real_last - host_page_size + 1; - if (!mmap_frag(real_page, real_page, last, - target_prot, flags, fd, - offset + real_page - start)) { - return -1; - } - real_last -= host_page_size; - } - - /* map the middle (easier) */ - if (real_start < real_last) { - void *p, *want_p; - off_t offset1; - size_t len1; - - if (flags & MAP_ANONYMOUS) { - offset1 = 0; - } else { - offset1 = offset + real_start - start; - } - len1 = real_last - real_start + 1; - want_p = g2h_untagged(real_start); - - p = mmap(want_p, len1, host_prot, flags, fd, offset1); - if (p != want_p) { - if (p != MAP_FAILED) { - munmap(p, len1); - errno = EEXIST; - } - return -1; - } - passthrough_start = real_start; - passthrough_last = real_last; - } + return mmap_h_gt_g(start, len, target_prot, host_prot, flags, + page_flags, fd, offset, host_page_size); } - return mmap_end(start, last, passthrough_start, passthrough_last, - flags, page_flags); } /* NOTE: all the constants are the HOST ones */ From patchwork Tue Jan 2 01:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759344 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857145wrw; Mon, 1 Jan 2024 18:02:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGROtrP1eNOtKanTtV2jMqVK47hwQQLGoqxUmI9nAISm+cJ9usyRkeTMldAmX6nP75SSyri X-Received: by 2002:a05:622a:144d:b0:428:1423:5c63 with SMTP id v13-20020a05622a144d00b0042814235c63mr8557250qtx.103.1704160940783; Mon, 01 Jan 2024 18:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160940; cv=none; d=google.com; s=arc-20160816; b=Smk0CfyKTdP1L2x/K3Qh+XKiNO+F/u8oLaS21BY5C//ybVNEbTqCctXeV2HqMzRfEU b7uCXGwb5JJxBSxCZ2/cHaDEN8CqyXEQpRneEVwPv7rheam1YoEKCFupqis72zwXFFS6 1soSJTdQB0KfaQS5NsXqlRsbYr/ONsa/HHX2ld0yxx26fMWVFWvUJGN3XgZskV2rHbNg FQydIHq3GRsgQGoEYElMGO6bXUSgxJ1l/VGuYTaz3G6hiXmT/aB2KUivoz2XPf/kHUQc 1tSwn96H7dnLjhJ00CAVH32KWMjIs1A9utpWmDPxfKCac2bBjTTwSPHAPjjnbx+4c5M0 NiqA== 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=bvIqJJvCSw/W2rsjpUyM+grSiLNxzontPEfDkoi+BAY=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=td5IHbr3YAII5mZ+E1cANZuNnxpVBg0LmaJBDKDkNOZSLMw4x83ciG7WYLIdMgl1L8 wZjw+3L+BmOylyfwszgUOpWwpfJq4OIiNc9QS0cc+MfSX+nKELbscLJlDrq3QR0f4prZ TxpgpyLM0g8PXLi+e6y4kJ3VAwYgq3VDVd6OESoS3srhX1WsPSEQ1L6PosSvRoexKNgI YORClqX40hsKlDODWllujEwxdIu4CWYHfPn+2+Hm1w+QDDKKpnvDQLw/xRXeU5Gda0vJ bfAf2vLJBD6emb1pewibfXp+cupkkBsf6RJst6EaR51OsAj0HjL2hCTdEfbcE8nQNo9F jhwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JRk9mckA; 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 w22-20020a05622a135600b004280f8b8129si6613887qtk.609.2024.01.01.18.02.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:20 -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=JRk9mckA; 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 1rKU3l-0003ks-Om; Mon, 01 Jan 2024 20:59:13 -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 1rKU3e-0003h6-98 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:06 -0500 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3c-00075G-8E for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:05 -0500 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5ca29c131ebso7061097a12.0 for ; Mon, 01 Jan 2024 17:59:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160742; x=1704765542; 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=bvIqJJvCSw/W2rsjpUyM+grSiLNxzontPEfDkoi+BAY=; b=JRk9mckAbx0Gpo8a8kue4mqgn766jHX06a0Cm+FmT23Hg1JBs7tF6+EQy0vYA9p/3r Zi2i21MbQsw+wisPvsRgEtlWlDTyRQC3Ecjpb6mLPdy0wgemdBdI3e85wEbq4SBvn9at XZX/XhQioDKieZPAiFDuta1IRwSMQUtxZGxaPEOjy/AcwzFLGBbT25EfaiACIfME2uQI 35vMmPfGD58cIztEZbJ67kyLL5Rh/dpnaWczLsk01k3XbJf9s098jaP69b+rsMuTq/26 rGYi2d0I0oEhq0DOwHU1JadPGNldv32/ZjEO3UmVC/8lhHCGa3iPsdFLm2sr1ZEpqA6a 7peQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160742; x=1704765542; 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=bvIqJJvCSw/W2rsjpUyM+grSiLNxzontPEfDkoi+BAY=; b=slzA+5vzppHWz5fEs5xRyw0lZlCEpKyFBTzjdkkQBRqBCJf3LKuHb0+gwkWDaXK3cW c9H7jOUTOQCGIq6K7r0syKTBI0oFH0yQ3EAYPA4/xhIyG9XnSiD81ecNXxymxKbpNvFt 8vlX6gNlnGjxKuPGiC/GpaGxcwk/I4y39YC8OK7X9oL9FsBifVhAFZvBCe/IZ3ose2mw xExNHHh+4TB437/JM2LjyoQVc7ji2RJQFwQz3X6J/6YkRHxE6NhN85Ad0C9WOAehBazA VNukUr35DJ+8FTEa/eLHlHTZ5NyO3O33+SDePFW9kIVvX4pHWP/8dVX8vi7wo1Hyd4e6 RhFA== X-Gm-Message-State: AOJu0YzJpHedoujS04BJgpvGYRhW1/ejhYHyWyUouDH0X0QF86DCdvgY XWVUQ4LxzAE0CfghjPxaI9/01PfDpFvmAjZhp+s051C0iE0= X-Received: by 2002:a05:6a20:54a5:b0:197:2fae:794e with SMTP id i37-20020a056a2054a500b001972fae794emr1559210pzk.70.1704160742526; Mon, 01 Jan 2024 17:59:02 -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.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 24/33] tests/tcg: Remove run-test-mmap-* Date: Tue, 2 Jan 2024 12:57:59 +1100 Message-Id: <20240102015808.132373-25-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::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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 These tests are confused, because -p does not change the guest page size, but the host page size. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- tests/tcg/alpha/Makefile.target | 3 --- tests/tcg/arm/Makefile.target | 3 --- tests/tcg/hppa/Makefile.target | 3 --- tests/tcg/i386/Makefile.target | 3 --- tests/tcg/m68k/Makefile.target | 3 --- tests/tcg/multiarch/Makefile.target | 9 --------- tests/tcg/ppc/Makefile.target | 12 ------------ tests/tcg/sh4/Makefile.target | 3 --- tests/tcg/sparc64/Makefile.target | 6 ------ 9 files changed, 45 deletions(-) delete mode 100644 tests/tcg/ppc/Makefile.target delete mode 100644 tests/tcg/sparc64/Makefile.target diff --git a/tests/tcg/alpha/Makefile.target b/tests/tcg/alpha/Makefile.target index b94500a7d9..fdd7ddf64e 100644 --- a/tests/tcg/alpha/Makefile.target +++ b/tests/tcg/alpha/Makefile.target @@ -13,6 +13,3 @@ test-cmov: test-cond.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) run-test-cmov: test-cmov - -# On Alpha Linux only supports 8k pages -EXTRA_RUNS+=run-test-mmap-8192 diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 3473f4619e..0a1965fce7 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -79,6 +79,3 @@ sha512-vector: sha512.c ARM_TESTS += sha512-vector TESTS += $(ARM_TESTS) - -# On ARM Linux only supports 4k pages -EXTRA_RUNS+=run-test-mmap-4096 diff --git a/tests/tcg/hppa/Makefile.target b/tests/tcg/hppa/Makefile.target index cdd0d572a7..ea5ae2186d 100644 --- a/tests/tcg/hppa/Makefile.target +++ b/tests/tcg/hppa/Makefile.target @@ -2,9 +2,6 @@ # # HPPA specific tweaks - specifically masking out broken tests -# On parisc Linux supports 4K/16K/64K (but currently only 4k works) -EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-16384 run-test-mmap-65536 - # This triggers failures for hppa-linux about 1% of the time # HPPA is the odd target that can't use the sigtramp page; # it requires the full vdso with dwarf2 unwind info. diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index 3dec7c6c42..53540ac96a 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -71,9 +71,6 @@ endif I386_TESTS:=$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS)) TESTS=$(MULTIARCH_TESTS) $(I386_TESTS) -# On i386 and x86_64 Linux only supports 4k pages (large pages are a different hack) -EXTRA_RUNS+=run-test-mmap-4096 - sha512-sse: CFLAGS=-msse4.1 -O3 sha512-sse: sha512.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/tcg/m68k/Makefile.target b/tests/tcg/m68k/Makefile.target index 6ff214e60a..33f7b1b127 100644 --- a/tests/tcg/m68k/Makefile.target +++ b/tests/tcg/m68k/Makefile.target @@ -5,6 +5,3 @@ VPATH += $(SRC_PATH)/tests/tcg/m68k TESTS += trap denormal - -# On m68k Linux supports 4k and 8k pages (but 8k is currently broken) -EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-8192 diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index d31ba8d6ae..313f7417ba 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -51,18 +51,9 @@ run-plugin-vma-pthread-with-%: vma-pthread $(call skip-test, $<, "flaky on CI?") endif -# We define the runner for test-mmap after the individual -# architectures have defined their supported pages sizes. If no -# additional page sizes are defined we only run the default test. - -# default case (host page size) run-test-mmap: test-mmap $(call run-test, test-mmap, $(QEMU) $<, $< (default)) -# additional page sizes (defined by each architecture adding to EXTRA_RUNS) -run-test-mmap-%: test-mmap - $(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages)) - ifneq ($(GDB),) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py diff --git a/tests/tcg/ppc/Makefile.target b/tests/tcg/ppc/Makefile.target deleted file mode 100644 index f5e08c7376..0000000000 --- a/tests/tcg/ppc/Makefile.target +++ /dev/null @@ -1,12 +0,0 @@ -# -*- Mode: makefile -*- -# -# PPC - included from tests/tcg/Makefile -# - -ifneq (,$(findstring 64,$(TARGET_NAME))) -# On PPC64 Linux can be configured with 4k (default) or 64k pages (currently broken) -EXTRA_RUNS+=run-test-mmap-4096 #run-test-mmap-65536 -else -# On PPC32 Linux supports 4K/16K/64K/256K (but currently only 4k works) -EXTRA_RUNS+=run-test-mmap-4096 #run-test-mmap-16384 run-test-mmap-65536 run-test-mmap-262144 -endif diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 47c39a44b6..16eaa850a8 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -3,9 +3,6 @@ # SuperH specific tweaks # -# On sh Linux supports 4k, 8k, 16k and 64k pages (but only 4k currently works) -EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-8192 run-test-mmap-16384 run-test-mmap-65536 - # This triggers failures for sh4-linux about 10% of the time. # Random SIGSEGV at unpredictable guest address, cause unknown. run-signals: signals diff --git a/tests/tcg/sparc64/Makefile.target b/tests/tcg/sparc64/Makefile.target deleted file mode 100644 index 408dace783..0000000000 --- a/tests/tcg/sparc64/Makefile.target +++ /dev/null @@ -1,6 +0,0 @@ -# -*- Mode: makefile -*- -# -# sparc specific tweaks - -# On Sparc64 Linux support 8k pages -EXTRA_RUNS+=run-test-mmap-8192 From patchwork Tue Jan 2 01:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759361 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857642wrw; Mon, 1 Jan 2024 18:03:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGidYfGzI3Gw5Pfzj/zCG3TNNWQYViThHg6wKCZAPWujd2bHH28cCvNGXDv+tcjDztXWzW/ X-Received: by 2002:a05:620a:2441:b0:781:b186:d52b with SMTP id h1-20020a05620a244100b00781b186d52bmr3061972qkn.155.1704161031110; Mon, 01 Jan 2024 18:03:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704161031; cv=none; d=google.com; s=arc-20160816; b=W2PisOUrkiJJFhkEBw+EcfwBQRlgK2OecoGKG3/Wrx0mu/VfnTth9rWQdqDEbpneu5 lplQPWH0JvLIe2oTPlDeTGZAHBtN5rRaDqK2zu36uKAR0T8VQJldMJhUEt+MTh7O2Sm5 BgJUQtgB1ILBkhbPJ3SJTmxcFc4ifxnj6+6M8NsiKK2DIdZaC6BGjjEOUbxDxviAc5uD LRKe38Qv1mrhptBwAmXKPe4rcJIzoTPYHcXEaGzxJyuCcIFDN+cvA3cbN7rifQ3ddGWu fvemnSkJPYUYHqitWz17B4XQHpMpDx5XGq4WX3rz7V8u38I+qY/bVe0RjibxgvxWtzz9 LOrA== 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=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=uur1ofPIJC7K2kBA4XtCPh19ARPDjmpnzjmQQRAF8A21Yaf8M4k6Hux2qrZJnTi20T iL4gqleT6gt1Y+OC+1/8/X8wEttOk7ObVFXJNTOYoV/mYnHq/tgG/4RvdN/MFRgDmWGk vq5TYAp2IosE+KNEcT3IhkHv6nrgKQ73r0Gm9VaR7dFXrNkMLLnl3YFv1cSgLW73qNxd IvNHlGpPEmQ+1WYJsbVlMBrwPxeEgh7ct4gPk2t13uxY5f6boA7uMr5vFEK13lJoT/+h xIXb7WcuzYqymE5YFLDZe3R8q1ng929K2+NhA6dyeHUd3c+MAYkpb47bvO9HXjQ1QOR6 1tSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MPckM0Yu; 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 v19-20020a05620a123300b00781240e468dsi23699658qkj.362.2024.01.01.18.03.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:03:51 -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=MPckM0Yu; 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 1rKU3n-0003mI-Dg; Mon, 01 Jan 2024 20:59:15 -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 1rKU3f-0003i5-Iu for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:10 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3e-00075W-2P for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:07 -0500 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c21e185df5so6728040a12.1 for ; Mon, 01 Jan 2024 17:59:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160744; x=1704765544; 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=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; b=MPckM0YuV/jFqFQXkL4L3ij7UFn8w2pCpZEHmpn+IL2RfR5jbjDktgy5t4Z6Wy1MtL wONNQiuRd4U9nyiJxrxq7rexQeBT01y29735acTYma7+OvbXFXo1Vkl2FRtYhMbHJYCp XpNmb/3yjJWeKZsnkqwbGEikK9nBEOzVbIHJNeGYjuqN4d4c1fRQNFZngH4Qqr/Q5pVT i02PEQ7CC4b0YBaC93mcqT5FNSAiGXa3cftdBFS14IXVk5pPs8mU1WhjpUboe2m/tygN VogTsoOCAHXbAPXvNbzTRWLWpH4ZkrvVZk6kbMr9XpoT5NS/375NcWa/tAEDQfBLxPzD ppMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160744; x=1704765544; 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=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; b=iYHo4d6TtDC/OcAGHk0W2McCOVL7KyDnJaQknabJqWwvIQ/xOk0m6anW2EWa8jSgmo 9wz6BZ8WS/sia9HN2Biwh6nVYClO0spf2JECy9s4diAOXTlNEL/6P9uAnzJdXJyRneVR 2tCgswJ03ofsfmDg1L06FP4m4mllQYDloHoXhMTw37uS4n5zlXgfwqyCvrHVBXusM+Ns 25FltSO7UVnviyRTQJg3E71sqAFUuKI9/q24S3UmFlPXmHqxH/9KteDFEfghT5Hu26GP ZH3HTB/Dr9wQu+CQSZSk9MD41lemfbqrSIUzVqUP6/XA5cEE0oMC4H2XAb6ne+zhcF6G BoSw== X-Gm-Message-State: AOJu0Yzbc0B8ErW0ajTtGiI9eVD04LyqBa5bTgf7qeI8owIVWBFjd3rv W1fe9QZj3nrzQvkQ+KPidl7s1vKVu0oSaTPs6Ov1CHcdjGI= X-Received: by 2002:a05:6a20:3791:b0:194:ae7b:3847 with SMTP id q17-20020a056a20379100b00194ae7b3847mr16474705pze.34.1704160744753; Mon, 01 Jan 2024 17:59:04 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 25/33] tests/tcg: Extend file in linux-madvise.c Date: Tue, 2 Jan 2024 12:58:00 +1100 Message-Id: <20240102015808.132373-26-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::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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 When guest page size > host page size, this test can fail due to the SIGBUS protection hack. Avoid this by making sure that the file size is at least one guest page. Visible with alpha guest on x86_64 host. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- tests/tcg/multiarch/linux/linux-madvise.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tcg/multiarch/linux/linux-madvise.c b/tests/tcg/multiarch/linux/linux-madvise.c index 29d0997e68..539fb3b772 100644 --- a/tests/tcg/multiarch/linux/linux-madvise.c +++ b/tests/tcg/multiarch/linux/linux-madvise.c @@ -42,6 +42,8 @@ static void test_file(void) assert(ret == 0); written = write(fd, &c, sizeof(c)); assert(written == sizeof(c)); + ret = ftruncate(fd, pagesize); + assert(ret == 0); page = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, 0); assert(page != MAP_FAILED); From patchwork Tue Jan 2 01:58:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759359 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857600wrw; Mon, 1 Jan 2024 18:03:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDLmb31qgVGsq/Bnqh68BeudRU42pLFXVkE/Rka6fAyFY7o/0JFkmkXhOEE8XT82v1TfiS X-Received: by 2002:a05:6214:d64:b0:67f:8030:11b6 with SMTP id 4-20020a0562140d6400b0067f803011b6mr24960383qvs.1.1704161022107; Mon, 01 Jan 2024 18:03:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704161022; cv=none; d=google.com; s=arc-20160816; b=eQ5NVY9mof1TtZb4dmzKKWdJYfTAefDaRrJdijsoLD+cbrHhZuOcBzZlC7b3tOqCut 0N9hxFW2AipkBKsEiCnV6wv3NrfwQEIvauDMpU/26EpOslqiehKCd/8xQL/s65YNtapW 5EOZJZQW6cWwwAn0+jskcNUD0Ndrl9CipPFPYZ1zTALPVNmuORhmzK6hZoBiL3Qlw5rv vhBPpCtQFGY4FcZHBw65hyHrUFPSnzhbL8zOmDsQKvVaaFYW3+ys3u7H9n0o9Cmw3/56 TAwnz/NLat8cXXFyZXOlCYBdMlLqu5xrlJfZ+bCpXlXv0kjeACZCTjOC7ttcJmAi/Wrh eQeA== 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=/LV9BWeIPWKBGrvgXFvetwVNAgJ38p+dzeW1kf+TIio=; fh=w99H43AuLEXkXF6K9XChyAWZqT6Vik7Rl9rXblYP1oo=; b=0Ppw/xMLu7qqqsPxg91NxywVKqv/SXCIYeXXtW++T8pmTOOoBmXl36JgwRcnh36nkN VBOKdKtLaJc2VxPwy34ceokkScIpkBPNJdqt2UwZlv993A4qiSPvjcnsd1HaY7WShNme xSSuUXIfJ1zj7fQwD28g4UK8M+aQ2TiEiRsVpTIVxIo9DRL/EYB19vJGbU93eXe19O9T CoGeQHEhTLZmXwsM5ssSvohmzlYzZUg229Y4NR6a9mB6SHS2AUuQ+ePRlr0vQpQ1ExkQ Vs4BrvNZP2ey9/2V6TS2dCADpBrrg7baKE8wWcGRFs2AKuO4S5TkxouwQdmaZm4Z5cQL Tjqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SG/N1pj7"; 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 a13-20020a0ce34d000000b0067eb7b6cad0si25787177qvm.400.2024.01.01.18.03.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:03:42 -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="SG/N1pj7"; 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 1rKU3o-0003ms-Bp; Mon, 01 Jan 2024 20:59:16 -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 1rKU3i-0003j9-Lg for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:10 -0500 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3g-00075j-Ed for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:09 -0500 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6dc076e9e59so2729515a34.2 for ; Mon, 01 Jan 2024 17:59:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160747; x=1704765547; 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=/LV9BWeIPWKBGrvgXFvetwVNAgJ38p+dzeW1kf+TIio=; b=SG/N1pj7BXKzF/Ss96QBChs2jsUHiYT36UCi15Nq2XipIoKNbt/2YezgIJaPfw0bra BlP1EmDs8zROAWZ1roYgjjN+YMQ0aS1hRS+3uFNirjnRsN9hd3QM+36AGx3b5SObvs9a BHafrX1wr0VeF3UI5P83Wo8LrhH4uoKk/zDCl+AhM9ns+Gk9+0gOkECD83cmYOM74O1H 0n2RwdDzLpSwU0c7ratI9DEYP6bfWGwwMhR6sklbg6VR3n4HLEy/FH0PcqoAbmokE2xQ 4B1acsgztcpxXplbMDhzFi1/TADHZbe5oWkb2QM1vIUyPuYDmGjGOI5hX6JsHrDmtseQ ROXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160747; x=1704765547; 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=/LV9BWeIPWKBGrvgXFvetwVNAgJ38p+dzeW1kf+TIio=; b=A5CEy12flEhTOAG529tvN+CKFBoAbv5Hll6h5iF5otvkuSv3QPVmVSBiF5yAKAMVUr i9rXjTz/eVy+iiJDNQmUS/WDQd6ZWaDQ/9vKMbmYnoiAeTTAQ6Pk7b8XQEf40kb3htzW +TxjP8adzMyHRRnkKTQ9atVtBYpGtujmcQgX8unceYnq29GCSZaV59MJ9WENMa1tf1/T pAOY7AOWOECOLteFE1foj+OEtzVRBQhQIjmtwfwWMxwa+ICIt61rkOUsOmby/n/ocjSL Gv/DC/8iJP7+EU8JwQciRUF1VHiHrZGNF13R8G5Ejqnb58xg7ko1q2c5guH8oCHFDL6q hGtg== X-Gm-Message-State: AOJu0YxoCBpqI5j2OOR8M/4bqQS7u5qo15XGKprR2aNzccKwEVC1+Yqg MEVkzavcYDWQfhSIGS62q8OZNqLdKe06J3zmrb7qutoy9rg= X-Received: by 2002:a9d:7659:0:b0:6dc:48c1:3e4c with SMTP id o25-20020a9d7659000000b006dc48c13e4cmr1888122otl.57.1704160746868; Mon, 01 Jan 2024 17:59:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh Subject: [PATCH v3 26/33] *-user: Deprecate and disable -p pagesize Date: Tue, 2 Jan 2024 12:58:01 +1100 Message-Id: <20240102015808.132373-27-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::333; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x333.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 This option controls the host page size. From the mis-usage in our own testsuite, this is easily confused with guest page size. The only thing that occurs when changing the host page size is that stuff breaks, because one cannot actually change the host page size. Therefore reject all but the no-op setting as part of the deprecation process. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- docs/about/deprecated.rst | 7 +++++++ docs/user/main.rst | 3 --- bsd-user/main.c | 9 +++++---- linux-user/main.c | 11 ++++++----- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 2e15040246..a499583a62 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -95,6 +95,13 @@ Use ``-accel tcg,one-insn-per-tb=on`` instead. User-mode emulator command line arguments ----------------------------------------- +``-p`` (since 8.2) +'''''''''''''''''' + +The ``-p`` option pretends to control the host page size. However, +it is not possible to change the host page size, and using the +option only causes failures. + ``-singlestep`` (since 8.1) ''''''''''''''''''''''''''' diff --git a/docs/user/main.rst b/docs/user/main.rst index f478635396..3a07be1278 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -87,9 +87,6 @@ Debug options: Activate logging of the specified items (use '-d help' for a list of log items) -``-p pagesize`` - Act as if the host page size was 'pagesize' bytes - ``-g port`` Wait gdb connection to port diff --git a/bsd-user/main.c b/bsd-user/main.c index e6014f517e..ba159d2984 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -365,10 +365,11 @@ int main(int argc, char **argv) } else if (!strcmp(r, "L")) { interp_prefix = argv[optind++]; } else if (!strcmp(r, "p")) { - qemu_host_page_size = atoi(argv[optind++]); - if (qemu_host_page_size == 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { - fprintf(stderr, "page size must be a power of two\n"); + unsigned size, want = qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size != want) { + error_report("Deprecated page size option cannot " + "change host page size (%u)", want); exit(1); } } else if (!strcmp(r, "g")) { diff --git a/linux-user/main.c b/linux-user/main.c index 5f217cc2a8..9ba4dc5872 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -332,10 +332,11 @@ static void handle_arg_ld_prefix(const char *arg) static void handle_arg_pagesize(const char *arg) { - qemu_host_page_size = atoi(arg); - if (qemu_host_page_size == 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { - fprintf(stderr, "page size must be a power of two\n"); + unsigned size, want = qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size != want) { + error_report("Deprecated page size option cannot " + "change host page size (%u)", want); exit(EXIT_FAILURE); } } @@ -496,7 +497,7 @@ static const struct qemu_argument arg_table[] = { {"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename, "logfile", "write logs to 'logfile' (default stderr)"}, {"p", "QEMU_PAGESIZE", true, handle_arg_pagesize, - "pagesize", "set the host page size to 'pagesize'"}, + "pagesize", "deprecated change to host page size"}, {"one-insn-per-tb", "QEMU_ONE_INSN_PER_TB", false, handle_arg_one_insn_per_tb, "", "run with one guest instruction per emulated TB"}, From patchwork Tue Jan 2 01:58:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759354 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857379wrw; Mon, 1 Jan 2024 18:02:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEW8X5m8DX1KPMPmK3xsEMpg3IU6DrOdhbtVP8ZWZo3r9cArMqvZ8vNVDWUbHmZLneilOwI X-Received: by 2002:a05:620a:c:b0:77e:fba3:a1f8 with SMTP id j12-20020a05620a000c00b0077efba3a1f8mr18673200qki.82.1704160979607; Mon, 01 Jan 2024 18:02:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160979; cv=none; d=google.com; s=arc-20160816; b=CEBBae49XYF2mhoPp8xk/p8cOeX9VvNspJ/QMXaJm3WKUqktEJTFxcksPE6W/qVYEx tKidwEiKY73LF4U8VsNEKKNKz4xDIxriYCbQiNG4HfDkxPqGWQRMI/vy2gb4EJHO3Ypa EwjlcOOrtY/ektGQWVs1Ra0XGUUZyh70QH4YM4dmhhKmSBVVr6cZgW+RvQk605NP7o9M 9GAkMR/MX0ipvTZRFhrpnqhwstPEjFFbnvsgCL8sqlxzAjs7B8YYc83LQRocNUqEahFp CGhQvs3XgxJGVdgdDsEZMmBC8ZXKcrWOUDsI/bsbh4IVO4xpg35C/2caw72/pOS6/r7v +Mmw== 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=niLg9Fo3ohbp8xRcoT4yGSYdzX+fXCYm2yVgdAWEpSM=; fh=ElMjLXQ0RlMVadh1anWpItyZCyOUMTD1DqESpsn8mL0=; b=1Gm8l/OvIVsrxiAwzlTMfcYYyfaRkme/9nJO4LB9KQ7qXkeF8aP1zYSEfODF2Iicg8 xf8/WYiGc0tYEzQ9Nw+uwCHznCD+UvOEsB1YK/lOmCvr/Ut7XPndqMCkAlXc2KrS68gS ITue46SzXTGGd/jTKaP1XM0jqiGI1/I0R1qfUBARAf/Aq03xmi5TarEayTwaOkPRIDmQ Vxmy5h1r8oLfTJ5bUW1f9T0bG+DG7yYO7EMKjKJwLGeB1g0NTQf1C3+FmK74/RtsHQpV sot+k4QVSHl+SfDsIhoDh1qPYTKtkBtEB9H236Z+9s5pI3X+BrOU50RSFJO1ZoXYcZXp gyjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Kbrn/QI2"; 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 27-20020a05620a049b00b00781afb71476si5351518qkr.409.2024.01.01.18.02.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:59 -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="Kbrn/QI2"; 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 1rKU3o-0003mP-5I; Mon, 01 Jan 2024 20:59:16 -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 1rKU3l-0003ku-10 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:13 -0500 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3i-000765-EX for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:12 -0500 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-2044d093b3fso6010981fac.3 for ; Mon, 01 Jan 2024 17:59:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160749; x=1704765549; 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=niLg9Fo3ohbp8xRcoT4yGSYdzX+fXCYm2yVgdAWEpSM=; b=Kbrn/QI2g285S3RS6kAJu/uo8GbEm/zQgRL5rSjWbXC7mEUkZX3yTGUTJiKfWAsDRA s6Ov2mOagUz5K1zCvoHmYmS6ggvce9z9s1F4vO98WMXBDDJiwoP6IpeXxXdjCjag5FUp /XggRl8Yb0WnDPeLHa41djmSIkXa5JbPqPLCAcTNZNBcYX5QBeCYOgJwB8k1oThAFncC be2oPHGSRXvF7NY+XDjsArZk2qpFJ8AsS22cgSWd2BOnumAnwX939lvsC8m2+gBfoOHB 76RJ/gu1j/8xm7wyrVt1dgt9bhB/OlQr63lPvaQkviyIkgFo7XW5XR6MeSS4te9USKrO XGDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160749; x=1704765549; 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=niLg9Fo3ohbp8xRcoT4yGSYdzX+fXCYm2yVgdAWEpSM=; b=OpjQx4VGmyzjFPV39KS+icm53gtZRj59UPvW0WjUqqCfLXefQs5CKczND8C7eT3l3C mECSLzmV3inttILaQsB1zu8QcQXNUtY7+6545X7bUSKFo7Y2RKCtjs6Ezbb7snWw4ayk mejrfW0o4JhpNxd1SHe86jjZf9jrQNfwwyWOH5X5Cdn24Jk89rq/WkmDot1FlnPzWLPP hT8qdR1sKd1+icgLh1PmJ+lJzb/Hz4/NdCnO8LVYqe1nel40kzb7Nal6DT1qv+4+7UrZ JDfDtRHnUuXklSuJfjQYOjo6JteQ6XciusgPe1FuTlDLZVHT0zdyJ3b0fgZ5qz8FpYQx bpKQ== X-Gm-Message-State: AOJu0YzpYEO6K6HHYtNYy2cjVJeACV0e4gEAp0wlcP+2vYgpQ55IDSPD rwJVGArlxARPEmqnCFsAIKmImZAX/ug2JK/aotr7CbFAbEo= X-Received: by 2002:a05:6870:b1c5:b0:204:7385:31d2 with SMTP id x5-20020a056870b1c500b00204738531d2mr16338388oak.117.1704160749372; Mon, 01 Jan 2024 17:59:09 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 27/33] cpu: Remove page_size_init Date: Tue, 2 Jan 2024 12:58:02 +1100 Message-Id: <20240102015808.132373-28-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=2001:4860:4864:20::33; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x33.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 Move qemu_host_page_{size,mask} and HOST_PAGE_ALIGN into bsd-user. It should be removed from bsd-user as well, but defer that cleanup. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Tested-by: Ilya Leoshkevich --- bsd-user/qemu.h | 7 +++++++ include/exec/cpu-common.h | 7 ------- include/hw/core/cpu.h | 2 -- accel/tcg/translate-all.c | 1 - bsd-user/main.c | 12 ++++++++++++ cpu-target.c | 13 ------------- system/vl.c | 1 - 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index dc842fffa7..c05c512767 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -39,6 +39,13 @@ extern char **environ; #include "qemu/clang-tsa.h" #include "qemu-os.h" +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +extern uintptr_t qemu_host_page_size; +extern intptr_t qemu_host_page_mask; +#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) + /* * This struct is used to hold certain information about the image. Basically, * it replicates in user space what would be certain task_struct fields in the diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 41115d8919..e5b4e062ae 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -29,13 +29,6 @@ typedef uint64_t vaddr; void cpu_exec_init_all(void); void cpu_exec_step_atomic(CPUState *cpu); -/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even - * when intptr_t is 32-bit and we are aligning a long long. - */ -extern uintptr_t qemu_host_page_size; -extern intptr_t qemu_host_page_mask; - -#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) #define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size()) /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c0c8320413..61bc88a0a3 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1169,8 +1169,6 @@ bool target_words_bigendian(void); const char *target_name(void); -void page_size_init(void); - #ifdef NEED_CPU_H #ifndef CONFIG_USER_ONLY diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 79a88f5fb7..7c29dd97b2 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -256,7 +256,6 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data) void page_init(void) { - page_size_init(); page_table_config_init(); } diff --git a/bsd-user/main.c b/bsd-user/main.c index ba159d2984..184d94b0a4 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -49,6 +49,13 @@ #include "host-os.h" #include "target_arch_cpu.h" + +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +uintptr_t qemu_host_page_size; +intptr_t qemu_host_page_mask; + static bool opt_one_insn_per_tb; uintptr_t guest_base; bool have_guest_base; @@ -308,6 +315,9 @@ int main(int argc, char **argv) (void) envlist_setenv(envlist, *wrk); } + qemu_host_page_size = getpagesize(); + qemu_host_page_size = MAX(qemu_host_page_size, TARGET_PAGE_SIZE); + cpu_model = NULL; qemu_add_opts(&qemu_trace_opts); @@ -408,6 +418,8 @@ int main(int argc, char **argv) } } + qemu_host_page_mask = -qemu_host_page_size; + /* init debug */ { int mask = 0; diff --git a/cpu-target.c b/cpu-target.c index 508013e23d..ee04baae7b 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -411,16 +411,3 @@ const char *target_name(void) { return TARGET_NAME; } - -void page_size_init(void) -{ - /* NOTE: we can always suppose that qemu_host_page_size >= - TARGET_PAGE_SIZE */ - if (qemu_host_page_size == 0) { - qemu_host_page_size = qemu_real_host_page_size(); - } - if (qemu_host_page_size < TARGET_PAGE_SIZE) { - qemu_host_page_size = TARGET_PAGE_SIZE; - } - qemu_host_page_mask = -(intptr_t)qemu_host_page_size; -} diff --git a/system/vl.c b/system/vl.c index 6b87bfa32c..d4f5a42075 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2108,7 +2108,6 @@ static void qemu_create_machine(QDict *qdict) } cpu_exec_init_all(); - page_size_init(); if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version); From patchwork Tue Jan 2 01:58:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759351 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857220wrw; Mon, 1 Jan 2024 18:02:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjKNL6ntsSeSOFoUrKNTLKsZ4sv93fqVxayYc2ft6WvKHsV9TJdu6if2fOajrrI8gDNpjH X-Received: by 2002:a37:ef16:0:b0:781:5b99:3a67 with SMTP id j22-20020a37ef16000000b007815b993a67mr10033334qkk.31.1704160953635; Mon, 01 Jan 2024 18:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160953; cv=none; d=google.com; s=arc-20160816; b=JZJu95xf8rIfpx/3G7t7r037s3309yJvfU/CjC3Y9yLG6qBtzrGjcHOvuG2HhlU04n 8hTnHwPpVJ4KLgiqfDoa+rXGsctdjWIxAI5TNHRkTMUiT7C+P9bFsUhyOMYwSbAKhRUk LIrpOzNgujS2EJSS/1N+Lmjcv/76aAh1H6lrVxPxV8Ca1YECFsJR32RYCYxXx+7zwo/8 VDmgRCYkPk0R1iE0QTLpYmAjEzGxkPKTEaO8yXAnje8Utaxclom3XOPOZ2nyoCx/5K6o j1K+B8ZTwKhHXYgrnXS1nAo6JpavP0W2U64iiKYoNFO3B8EVhut62++gudtON12tW0dh dTWg== 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=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=Fs/16vEv3y6mzvYeKFw5dK3Dr+WXj7125mBc/AlYr9Zy70KLms7HEE8q/IX2qJbFJB 8VGq+q643aD+IciSbMvelCwRKj+KaGHhN8N19mX22/5EUaGhEmMafOMroR784QH/q7Yv h/r0Rge9CSySFccRem9kmjkptePFciigZNqNov5ae+4jttHPu/8f5G4F7DDWUA528hGX 7PkqUs0y0CW+wjF/9irFQYbyt/FlhgW+qAMN+8vR7HkC8GMHNrnTh7y9GUEqEd64tCwF 1rSJTs8gIpEMHAmhLPzQ2kXEg+gSQyw05n1cdNfKx/7y72vmTu4dOY5A0U4U5aE/VzAB yx7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C6ST8qIz; 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 a20-20020a05620a439400b0077fbe2de1bbsi28226738qkp.518.2024.01.01.18.02.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:33 -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=C6ST8qIz; 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 1rKU3q-0003uR-ED; Mon, 01 Jan 2024 20:59:18 -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 1rKU3n-0003mQ-Hh for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3l-00076K-2f for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:14 -0500 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6da16ec9be4so2960039b3a.1 for ; Mon, 01 Jan 2024 17:59:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160752; x=1704765552; 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=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; b=C6ST8qIzbaU42A9lEtS7ekxef0XwDsuruGRnmCpEB0JjOgKDeNkSaMWiZ57Akwf+4e 7im0+1R86pa71KK+ism5m4vu8juewvFB/d9qrxPtRjSrBKUct5PyUpk1Jjm0oYA6RbCV Ii/NcEaC9WRYT1LTjUHd4oZLF9+OqSwMmPvOXEH+f9qLV9DaBxhvi7ZpGlSx0sFZv555 Vcyh2pxt5wx6Yw6iWXlmRb8rhTSCzThAgvZ97dCvPi+reRR9kQNORtc0K7hn8SvM5C9c rWGU8JQXpwwlyQamBuNl08kwsYTE1IUF2Yo1nrd7y4EdobMc502WUxbHrUJmZAoYiMcb 2jig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160752; x=1704765552; 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=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; b=qC+uwnpxE8I3eemnOM//osKQ067qzp3/MVa+3CvOs42vHwO8PHE71Ek6hRkBXje+4Y fzkM6w/2m/eWWdcqJHzVxeoYdoGcya3Y6TaLnyri4NSCYzZ2tp/NeMDsc+NsnFVZTyck LJZT8ddrLX8UA0a/0IU7rZk6SyAyrcF89geY3HmLwDBw8SbOttpS0VL9n+hzJpMERW7m Nl0KTYN52JsyUppbhgVeed4xS2oBdOCWlde6c3Xl8VpZh69Rwe2niYC2wRi3ENSqoK2n 6DW/ke9x9r+vpdyxHFGZJXYJOADqFndoH1bY+aAy/HavjQIKIpShmY7+g7DDINrxh0GF T7Vw== X-Gm-Message-State: AOJu0YyxKNWOlXP6UzH5ZiHMHbZrKJGjkiqo25SSYr2ZRhb3IXpgXX1b +0TDRfjsmeSlN6BChRczKccsVyy8IDcgs4i8YtKE7GQegRE= X-Received: by 2002:a62:8455:0:b0:6d9:8f56:106b with SMTP id k82-20020a628455000000b006d98f56106bmr14876576pfd.39.1704160751781; Mon, 01 Jan 2024 17:59:11 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 28/33] accel/tcg: Disconnect TargetPageDataNode from page size Date: Tue, 2 Jan 2024 12:58:03 +1100 Message-Id: <20240102015808.132373-29-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::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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 Dynamically size the node for the runtime target page size. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 69b7429e31..3cac3a78c4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -864,7 +864,7 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr, typedef struct TargetPageDataNode { struct rcu_head rcu; IntervalTreeNode itree; - char data[TPD_PAGES][TARGET_PAGE_DATA_SIZE] __attribute__((aligned)); + char data[] __attribute__((aligned)); } TargetPageDataNode; static IntervalTreeRoot targetdata_root; @@ -902,7 +902,8 @@ void page_reset_target_data(target_ulong start, target_ulong last) n_last = MIN(last, n->last); p_len = (n_last + 1 - n_start) >> TARGET_PAGE_BITS; - memset(t->data[p_ofs], 0, p_len * TARGET_PAGE_DATA_SIZE); + memset(t->data + p_ofs * TARGET_PAGE_DATA_SIZE, 0, + p_len * TARGET_PAGE_DATA_SIZE); } } @@ -910,7 +911,7 @@ void *page_get_target_data(target_ulong address) { IntervalTreeNode *n; TargetPageDataNode *t; - target_ulong page, region; + target_ulong page, region, p_ofs; page = address & TARGET_PAGE_MASK; region = address & TBD_MASK; @@ -926,7 +927,8 @@ void *page_get_target_data(target_ulong address) mmap_lock(); n = interval_tree_iter_first(&targetdata_root, page, page); if (!n) { - t = g_new0(TargetPageDataNode, 1); + t = g_malloc0(sizeof(TargetPageDataNode) + + TPD_PAGES * TARGET_PAGE_DATA_SIZE); n = &t->itree; n->start = region; n->last = region | ~TBD_MASK; @@ -936,7 +938,8 @@ void *page_get_target_data(target_ulong address) } t = container_of(n, TargetPageDataNode, itree); - return t->data[(page - region) >> TARGET_PAGE_BITS]; + p_ofs = (page - region) >> TARGET_PAGE_BITS; + return t->data + p_ofs * TARGET_PAGE_DATA_SIZE; } #else void page_reset_target_data(target_ulong start, target_ulong last) { } From patchwork Tue Jan 2 01:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759341 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856168wrw; Mon, 1 Jan 2024 17:59:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEj4f3uLewgPzXHlsm0EDWEPOaD8nTO7pyniaAt93lKErYAlyvkIrDBY6LTZjtG2vXQroHy X-Received: by 2002:ad4:4eef:0:b0:680:b7a0:a53 with SMTP id dv15-20020ad44eef000000b00680b7a00a53mr3137179qvb.80.1704160781155; Mon, 01 Jan 2024 17:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160781; cv=none; d=google.com; s=arc-20160816; b=dLEHE4EytvpRnKE5qsOYRiag5WYhQ298ahwhu0J4iYbw1+EtjNnGIfIUxNxL6/5Jdu xd19+ltARfwzeEpEj9aL5RlhTnjp8PXDSEBp4r+C7q8UterG+cybbDvtDfI3hm6ARuje 0kDSff41ol/qGljOlEcEuOU7PmkMTluYk5jPr54oLWfhVsDVlbLlQSyMm4kQcxb2At9B gcJNs2iRDsuH6q9zJuFB2djp/NkaX5+eiy1bt6ncgaZMx5xI2qWihDMEtCkc/UsKFG+w iaMfsjS02s3KEXewrr2LsvsEOD9TUElp/pPVX90N+tMprLLRFCmVSz7XBef8hwIMrdaS NJsw== 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=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=nLNW2vMbIO1a30raSdSshRyPpl6YUq+JKaZknUP4a7k71wGm80ZuOrBPxkqTaNIYDV FJDJS3EeblwKpxzfLy0qvNWkmwYwCfRNpENoOeaGDwLk3GTuEvM1NXM8AnrRNgLWTXvf IxQfnJs+GJBZhY0+DeKZ0UCH2Op+ZIVOj4MvTB3Pxlkzr8BhYmKLmQdQl59sVFqncGxY oDJuiK6C5YceBeEInDt2Ssvia/3uRx90+1x+Oy+BrunM29hDOQCg2etNasd/cGKq5kmn +yc8lNDRGhT4qu++9On6Qn0KGsCqh8qQrNJB13q7ru0ZBo/3hEQtFT+5Kc4WFz3VljtL 2pbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z0nnq+/b"; 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 gy13-20020a056214242d00b0068059cc9998si14090459qvb.481.2024.01.01.17.59.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:41 -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="Z0nnq+/b"; 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 1rKU3q-0003wz-TC; Mon, 01 Jan 2024 20:59:18 -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 1rKU3o-0003nJ-Rw for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3n-00076e-Az for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -0500 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3bb53e20a43so7596606b6e.1 for ; Mon, 01 Jan 2024 17:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160754; x=1704765554; 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=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; b=Z0nnq+/b1pW4yKSicEQF9GaDRiXWh+0hlcENiwZ/kShnZpxvRe0wt/b5DN6RS/McI3 vVhImIxmWesfn/+k1CVCiXQZtsMnAaavU/+DaUbGCeplS7gHngGTCk5BDcen+g7yY+YE 3f79uChMAitwr/OlAxKvA178ds1cb6uxsskKvDn8ZufNObxnEjQ5c7eMozcbI1BgJerA 7U4hbEfMGV9maDzE9kUVdbqmEf4epQHiDWy8+toctbxJG7S43yNcRDqEkhM9pgHifchR JSTYknfuxS9ImascdbN83vp0AC+UafEXtHmPBVTM4gm3yAKCLM+kcxu8X3YJFvjngy2j w95g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160754; x=1704765554; 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=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; b=q5GHnplpMxD4d+LBTH8TVoFAsUe4l45N98lTVMrkKZp7sRTZAEFW14j2r5QFUWfljD n2/uHIUdLq8Zb/Xj/FGiA899tPm6SONyXpv/aCLA1c4bEWk/NYmMoqrraZLM5eFS6TQg +Fr8CUvJ3Y+Si6NoDNzW0PUgK6W6PMk7zpMJbke9SU/sT7zLSoRezsbHSKu5fznrBNZJ jdH60BNo0eX+eROAOynSXird13zFVbfa/6FxORuHt6u6OkibcK46FZoOO0zrE9EQZY/d mw52rD5TVvnnLiVaqG7IJuFO5LnLkqNwjcSRs+kuKeROCqw1zN09+25lW7lmDSEOyzXF TIyQ== X-Gm-Message-State: AOJu0Yxca5SbZaqSph+MgV4BQwuQUfp4IDJJs7Y3/N6i7q10znkB4wQ5 NSLsYt+Wac+mSU85+tjhwCex9eDFUmaK67RAUPXxXOw0YVQ= X-Received: by 2002:a05:6808:130e:b0:3b9:dcf0:63b9 with SMTP id y14-20020a056808130e00b003b9dcf063b9mr20258295oiv.23.1704160753974; Mon, 01 Jan 2024 17:59:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 29/33] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Tue, 2 Jan 2024 12:58:04 +1100 Message-Id: <20240102015808.132373-30-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::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.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 If set, match the host and guest page sizes. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 9ba4dc5872..d00a0d7d1f 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -55,6 +55,7 @@ #include "loader.h" #include "user-mmap.h" #include "accel/tcg/perf.h" +#include "exec/page-vary.h" #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h" @@ -683,6 +684,7 @@ int main(int argc, char **argv, char **envp) int i; int ret; int execfd; + int host_page_size; unsigned long max_reserved_va; bool preserve_argv0; @@ -794,6 +796,16 @@ int main(int argc, char **argv, char **envp) opt_one_insn_per_tb, &error_abort); ac->init_machine(NULL); } + + /* + * Finalize page size before creating CPUs. + * This will do nothing if !TARGET_PAGE_BITS_VARY. + * The most efficient setting is to match the host. + */ + host_page_size = qemu_real_host_page_size(); + set_preferred_target_page_bits(ctz32(host_page_size)); + finalize_target_page_bits(); + cpu = cpu_create(cpu_type); env = cpu_env(cpu); cpu_reset(cpu); @@ -807,8 +819,6 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va = MAX_RESERVED_VA(cpu); if (reserved_va != 0) { - int host_page_size = qemu_real_host_page_size(); - if ((reserved_va + 1) % host_page_size) { char *s = size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s); @@ -907,7 +917,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr == 0) { - mmap_min_addr = qemu_real_host_page_size(); + mmap_min_addr = host_page_size; qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx (fallback)\n", mmap_min_addr); From patchwork Tue Jan 2 01:58:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759340 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856159wrw; Mon, 1 Jan 2024 17:59:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhxjRfwteRJipuCXwhJiTOURJ+DUomaRpurH1RUJ9AulC31Bpskdm5JgKZ/klaAzflqcAR X-Received: by 2002:a05:6214:260b:b0:67f:f92:2a05 with SMTP id gu11-20020a056214260b00b0067f0f922a05mr25993630qvb.25.1704160779817; Mon, 01 Jan 2024 17:59:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160779; cv=none; d=google.com; s=arc-20160816; b=W2R9+QbBckgl/I6qURuvKk9GDa6N5fH9WanqWV4WAgwo0eNTzWg1O+CK6Cj8h++NLY SiCP0wLnHvn9MpGEKYqHp5ILoL+nNbcb8N9JNwhJp+YkhoUyB/YMi6BK6nfwNtI8KChn Dc55bvhOn0p5vl6husCMc1p8C0QgcjPow9unOIrag+ZaJwvkqdlo6NsXKpMw98pdb0Zx gze1oqwJOX9OXo940RmOrtgHYWDI3pw1/BuyeRpWyzHNkYKHZhgLRbqTLBVK/wKeUXKe rRHlGvtCXaFan8w4IBaQZT2SjKZtpYJr8ZnXjXLjE7gZ7P+957sPZZCEvNUQXFcsaaQS LJ3A== 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=X/nN0RXer0FvEyJPG6YS7iKCkVjd2CoiUqtQ4iddbsQ=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=nkzcjofBKXtJldGGlf112RYDZ6lBToVnV9SMU6hWr88X4SDL9H+El0FPAUwKW+MIUJ 1mEeUC1wxESmjmH+sIAlu8FFfiEsqS6LZPz1qi1o1/a0riDI5n+TFgZUPKu1hEgBZTpc zAWAyRxs0wPaakUfy7TX1i1/JQQu9Dz2MB6TMS/XaV0UpeSIhbVtSgGQak4h/LKkxCDO Ijz9sBb84o/dMKi526pYb9fOCa+kfWoY54UuxzhKkYn/f892p8g6sKS+MUX80bNxRZwv RhK7KcLaJiZJyZNmcvX05yRWk65WFOFkkvQ+wsbTOtUjXkJUoKo59vz2XpU5QNERi0O4 FqmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rE10QV9n; 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 k15-20020a05622a03cf00b00427b2719319si22234170qtx.546.2024.01.01.17.59.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:39 -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=rE10QV9n; 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 1rKU3t-0004AV-U5; 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 1rKU3q-0003xF-UO for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:18 -0500 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3p-00076o-4b for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:18 -0500 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-59496704246so3342563eaf.2 for ; Mon, 01 Jan 2024 17:59:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160756; x=1704765556; 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=X/nN0RXer0FvEyJPG6YS7iKCkVjd2CoiUqtQ4iddbsQ=; b=rE10QV9nUKPqCnlX7wjLmse7lSVX3maC9G0l0JF1p4/0RHPb9IXfANd2vl+0XhY/pT zCgahY3GHzR1TzZso3ftmfxUOqJ61iPNtL7TISnEfhah98mKacnG3Lt0VfoS7CaadKb4 paoEfeL1xEkszqO/KgVP2ZsCUtnXVhR+KYsdG4+cMo+RFNqVkjbMYfKLq9lfFkzySIBm SMgEInj7qK1sLJn6P+pHnqo+0esqoVXDBcLym/uDWwU+9lKaBTQVi/cqDx2MwfBeB/m8 2HgDAhPV1T0eyEugMdj7HNPzHmO9b+2oRaqAAOcx9F/n45G9xCL/AtfiT3NXrDyxusHB c9QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160756; x=1704765556; 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=X/nN0RXer0FvEyJPG6YS7iKCkVjd2CoiUqtQ4iddbsQ=; b=QYCsnSWIDZpPY2Q/r8Jb1nGMXcJocmwYOJs6eT9AS7AAQ+r+JnlsXZ9glxn1gM+/nq 3lMnYVsb3vBABc73rEdzpQa9mdz374qDxaMtGIj5DQpzu9GoqsIgIKQ9ZvKkbYK+w7Fz nBttpaHKR+fBCi7cGQzPkJxwjCxbAxDlB1qadxDS/922l3nA47DLxAS4ZYq/x2F7JNku 1mHRJiH5sPuTpkihdWVmcJbQAo7jUWASzXUu3J+H9A4ucdhXmj1cmRa8WMJvxuTdYdWb jgovKSHnpOMeyEffvxIHDgNt28BJYUmoyC5QTktLsDd8RAmJCc69TB6Q9pYSlJMHamKK Wq2w== X-Gm-Message-State: AOJu0YzpuTVPp2Wgd8OYnrw72VSThM7BkUPXfo2sT9zMG+ImGfV6DQB6 uZVTiHzFBfSM67ttpDkYOi56wH+xOqo5oalgXZ7e28QgqVA= X-Received: by 2002:a05:6870:2254:b0:1fb:75a:de6f with SMTP id j20-20020a056870225400b001fb075ade6fmr20876889oaf.93.1704160755855; Mon, 01 Jan 2024 17:59:15 -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.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 30/33] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only Date: Tue, 2 Jan 2024 12:58:05 +1100 Message-Id: <20240102015808.132373-31-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::c36; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc36.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 Since aarch64 binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpu-param.h | 6 ++++- target/arm/cpu.c | 51 ++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index f9b462a98f..da3243ab21 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -19,9 +19,13 @@ #endif #ifdef CONFIG_USER_ONLY -#define TARGET_PAGE_BITS 12 # ifdef TARGET_AARCH64 # define TARGET_TAGGED_ADDRESSES +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# else +# define TARGET_PAGE_BITS 12 # endif #else /* diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 650e09b29c..55c2888f2c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1788,7 +1788,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) ARMCPU *cpu = ARM_CPU(dev); ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev); CPUARMState *env = &cpu->env; - int pagebits; Error *local_err = NULL; /* Use pc-relative instructions in system-mode */ @@ -2079,28 +2078,36 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) !cpu_isar_feature(aa32_vfp_simd, cpu) || !arm_feature(env, ARM_FEATURE_XSCALE)); - if (arm_feature(env, ARM_FEATURE_V7) && - !arm_feature(env, ARM_FEATURE_M) && - !arm_feature(env, ARM_FEATURE_PMSA)) { - /* v7VMSA drops support for the old ARMv5 tiny pages, so we - * can use 4K pages. - */ - pagebits = 12; - } else { - /* For CPUs which might have tiny 1K pages, or which have an - * MPU and might have small region sizes, stick with 1K pages. - */ - pagebits = 10; - } - if (!set_preferred_target_page_bits(pagebits)) { - /* This can only ever happen for hotplugging a CPU, or if - * the board code incorrectly creates a CPU which it has - * promised via minimum_page_size that it will not. - */ - error_setg(errp, "This CPU requires a smaller page size than the " - "system is using"); - return; +#ifndef CONFIG_USER_ONLY + { + int pagebits; + if (arm_feature(env, ARM_FEATURE_V7) && + !arm_feature(env, ARM_FEATURE_M) && + !arm_feature(env, ARM_FEATURE_PMSA)) { + /* + * v7VMSA drops support for the old ARMv5 tiny pages, + * so we can use 4K pages. + */ + pagebits = 12; + } else { + /* + * For CPUs which might have tiny 1K pages, or which have an + * MPU and might have small region sizes, stick with 1K pages. + */ + pagebits = 10; + } + if (!set_preferred_target_page_bits(pagebits)) { + /* + * This can only ever happen for hotplugging a CPU, or if + * the board code incorrectly creates a CPU which it has + * promised via minimum_page_size that it will not. + */ + error_setg(errp, "This CPU requires a smaller page size " + "than the system is using"); + return; + } } +#endif /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will override it. * We don't support setting cluster ID ([16..23]) (known as Aff2 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); } From patchwork Tue Jan 2 01:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759356 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857444wrw; Mon, 1 Jan 2024 18:03:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqUXk42LV39KeGKt6xIY1LcwuLCwTytV0BkY1ggVCC5yoAIln5O17JA41t0OPzJvbMe6ZQ X-Received: by 2002:a05:620a:14a9:b0:77f:8c54:da15 with SMTP id x9-20020a05620a14a900b0077f8c54da15mr20627012qkj.40.1704160991179; Mon, 01 Jan 2024 18:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160991; cv=none; d=google.com; s=arc-20160816; b=raKJDn4P6nFz6Wvb2kmLqQewtoR9U1auH+x17ZgJfi4SNTtQrNMS60itnFviBqUfm2 leB1Coq6ja2fdF/EMR14NL0Q4boeyex5rBL6odEKgsNf+JjTFfV1e7+d5Ie7xxWwOavK SxBd8L/bU55Gz4C1oML4Qz/WOK3eCKv4n6DobsO48q3GPXHLmV3HIwurNpHg3ArQHpOU +6yfkRPFnmkYxWn5nJRPTyrRFhwqjldtGtN4h1mlL+wNVERlNoeEBgl6Q2zQG+bz7IWE yQpYnpxaB8M+EBPuEu8ZtC6szo9mrqcA8qwat7wZAarkD4CEPwQaGVi8sIz7DGkE80eV /RnA== 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=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=HW2nGcE5yxBz5tQeJry7GWZpLYJFS9M1lsP3bZ0S25GUBUEF+cq3g4/4mGFiSFTWYn PrBsoYgjn58Gqzw2hs9ZrgrI174qWJLqdwHSRJcOdK4r0YrfQErub6HXNpUUY9cVtM1K Ajir99kQ2s6X8gBsVXn1kgXKgbC1gQqpRp1Kvl6Hd3bjC3aBW6pZxAfHZCuJhoZz/6Tg g4+e/A4xSJK7mI1GIzafuO/TNJFuyO0x7qUbUA0knFlm8LtlRgqQFjZ852ROveLSqrmT BWGeNLJaFNbaXUBWIQ7IGNZQ1ANMxRVgQzY5EqCVw7fEqo/9BpBGk9m1NuLIeXSyQpiK BAOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VO745913; 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 u17-20020a05620a023100b00780f8f53c87si26006929qkm.695.2024.01.01.18.03.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:03:11 -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=VO745913; 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 1rKU41-0004lj-7H; Mon, 01 Jan 2024 20:59:29 -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 1rKU3z-0004ib-GM for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:27 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3s-00077B-O2 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:27 -0500 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3bbbf5a59b7so4339660b6e.3 for ; Mon, 01 Jan 2024 17:59:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160759; x=1704765559; 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=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; b=VO745913dsuHX2SLsDvYLQNo6hJS46AwNkxsfMcQmrlkBf2kpVCNV/9X7Ksml++tXH kTDHSWDHItq8t3YPlFjPCGiLFGJrmoTbco5gtvZClfilow6S+1rpazuXlaev1neXFduP RPyJSBoP/If2rRyCelysW+NL4hmnB7LbMZqAqpZWBsH4rZZIMJkSYaTsvZ5Bj6dWwxwW Tr+Xi3fROCD00hBIFa502xxZdYCVQyuc7QaWiUusEWBOwT/qH7jTT2bt6cF2cTusR7SL ZSxlUtuOQw6lPsmytOkH5wG+zKKp5SL9bX27xAFmUDx78BrWZwL2DTc/yCbPXQ1Gq4xf eGBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160759; x=1704765559; 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=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; b=WfuQXhSpILCIG06tvq4kGfwkWIDJnyZG36nldmbcknUF/PBzfgPgTq7m9UdovqFtUC rLpM+i3W4IDuIfc2A257Pg8TlBHF97K+evQRyuifxXd+QKsIk17CgMMYxmhL/S+xQIJ3 Yu3R/1JaIhgvpn3HLvhFF22dQUJ+rgO8Dz5mKTCv83sxLar7htAGuYnkQGjyGU7/IBad +H8aMs/3Vo7OPtcgSJ0ghExhp6IsToZR0ucK6s5Vvp2/9FKsMqXYSaTXLLGg1k/byn+2 glXew30KmCZOUms49QOHtqctQVr9SPB7rLujq8x7BaYUCMQ96hTb/S7wRdR/NSRSQSU6 iRWw== X-Gm-Message-State: AOJu0Yycfm71EoX7sphSVHpEBYfeQ7IsQ5LPl/ClgCeY1mIPwybxtAY+ drTKaYRhykGczQho0GBn2hAT4tG1EX27o/7b6wVVvPEY2cc= X-Received: by 2002:a05:6808:16a3:b0:3bb:d7e8:d8e9 with SMTP id bb35-20020a05680816a300b003bbd7e8d8e9mr8161374oib.109.1704160759687; Mon, 01 Jan 2024 17:59:19 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 32/33] target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only Date: Tue, 2 Jan 2024 12:58:07 +1100 Message-Id: <20240102015808.132373-33-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::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.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, 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 Since ppc binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- target/ppc/cpu-param.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/ppc/cpu-param.h b/target/ppc/cpu-param.h index 0a0416e0a8..b7ad52de03 100644 --- a/target/ppc/cpu-param.h +++ b/target/ppc/cpu-param.h @@ -31,6 +31,13 @@ # define TARGET_PHYS_ADDR_SPACE_BITS 36 # define TARGET_VIRT_ADDR_SPACE_BITS 32 #endif -#define TARGET_PAGE_BITS 12 + +#ifdef CONFIG_USER_ONLY +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +#else +# define TARGET_PAGE_BITS 12 +#endif #endif From patchwork Tue Jan 2 01:58:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759350 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857168wrw; Mon, 1 Jan 2024 18:02:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkenJi6A+lvNhU39dHyvWNIgo36kRnG6nDsRp0Op0wPl5oMsLNMrlFFdvGfZFSMsma8v3c X-Received: by 2002:a05:6214:4002:b0:680:a521:c57 with SMTP id kd2-20020a056214400200b00680a5210c57mr7398122qvb.52.1704160944025; Mon, 01 Jan 2024 18:02:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160944; cv=none; d=google.com; s=arc-20160816; b=I6P7uEeOdBOmZkZZn8tNfusgUTmtjY/n0r6DdgycNcTvJr6Kl4QQ9X6avSclGBqxL8 bmZXTYsDGN+VhVG+K6wwCXpZ1FRWV7N5DsGqAeqynmDmmf/FzUeOnOE9oO1sZmLlxHbp gHs39Y40cjX3q+jAE+S+1StcYHcRkJwQ7SCcjqigCRJrdruH//6qzdFAQUJbsWyKldaA 4oAnKaVRl5RL1BJeMnM2zmPjMvMEce27IYuk9OLyhve8lUuyoIUSBMo1UlnnDGmcKJoX bpt/70EbiqTu5YSp+AuobHbf9RQZlR1jpubK0uLcNnE8lDQDYezapoQbnY/Jdv97GHoD cJsw== 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=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=NWD2GcsVuTNApiXOaGtCXvjTpOwgwr1Vpkyrj1WL8kOsL9qMjNXH3Q+XvjHtwXX2xG DwyNfdS+ha4gBGziAgUxA6cZxGEvhWaIHAKoR+WmB0SWlzmEzfJQy90fDNmxxUGhBg3W KWoEiM5xVkrm24kBZNwisu0YOx6L8ymBjURLiLoGnOBgeGPeF2Zqfjv7y7vprKqUY5zd BCirVH3IVB13DpeVaBQNnnghjeSJqW/F7SX7E9qBZ+cJYkBYwsMqJMDx6YfKsdXiSqqP eExiDhpyAjYImN83ty4Nj3dsF5qZnIFt2nlqWBAA4+Uy2KeaVnu+doOqUd2XPqKx8bSV 4xgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JmG/eE9x"; 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 r12-20020a0cb28c000000b0067f7b751d1esi20919285qve.389.2024.01.01.18.02.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:24 -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="JmG/eE9x"; 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 1rKU3y-0004cG-DW; Mon, 01 Jan 2024 20:59:26 -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 1rKU3w-0004Sf-5X for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:25 -0500 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3u-00077M-Ki for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:23 -0500 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6dbdbf680d6so3213197a34.0 for ; Mon, 01 Jan 2024 17:59:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160761; x=1704765561; 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=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=JmG/eE9xS4jfimcftYUo7w61UlVwPRi+yzdC9gArNjlg2EM/XBQB+YGLbKcbtkskl9 JXrEfywIQIhWs3nwxZWiGYTi9jeCptG0dYedLgFUZ8YyuLHkr2LhQqetCRHYDIZ+aSqg 42zMxwvltjih5PKXnqzhPLpwLqN59d0Uk7dLnLE8xYcgN/3KORQAcVB9PNs8qitLz6ZB z5iZgnIv3jpMjknnywEO4nLno+fP5OVm7TvYfEmeCjbRH3fuGX5uDwrIT/8tNOGdd/kB YJ/h0/eS5GbF9cnFL9k8nnu9GFRhGlzcOnKZrZzlAXwU6DPT21LoUpZ+95btYPqw5bd7 Igiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160761; x=1704765561; 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=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=S4fKHbZyBklG7Z8/5YrjUq3ISuy8J96m4O/TQQR0/Igb3nu/zZ9NdtixPKczRvlXAo rIEtAhLh1fMtgLSn88A3UHqZvFZIApDmO1OgUFdEGX+sTEW3hW34XIKY+mspkuVHyBJ8 6/57kFRfBbQBSVTSwbJ2TVwtlmx97Lmn84E4Bk8yKq6mhBr3F+LzUwTcLMuHpMs4dygk 4A1hirDgd62OUinavk8QhQUV40Oa4EeYtm0T2h6AtI8vCdS29S70LSiNmY/vcSEtz/j7 x29b9sDmMqFGbSeNNiTT3TP0Okw1NQZYTNV5GNxxLUWMTH4m8qiLm3XJOEo7JW7okpWW ar/g== X-Gm-Message-State: AOJu0YyX+GBg+a8EznqALmhI+CuGBJD/xg0/EO+y+v7efcSvtCs+FfUQ HJVXTBv9sz6QhAzSSmHVcTjnKuZWoMJevvIXEiL8RBt7FSw= X-Received: by 2002:a05:6808:13c5:b0:3bc:1169:d467 with SMTP id d5-20020a05680813c500b003bc1169d467mr1140810oiw.65.1704160761612; Mon, 01 Jan 2024 17:59:21 -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.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 33/33] target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only Date: Tue, 2 Jan 2024 12:58:08 +1100 Message-Id: <20240102015808.132373-34-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::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.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 Since alpha binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich --- target/alpha/cpu-param.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/target/alpha/cpu-param.h b/target/alpha/cpu-param.h index 68c46f7998..c969cb016b 100644 --- a/target/alpha/cpu-param.h +++ b/target/alpha/cpu-param.h @@ -9,10 +9,22 @@ #define ALPHA_CPU_PARAM_H #define TARGET_LONG_BITS 64 -#define TARGET_PAGE_BITS 13 /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44. */ #define TARGET_PHYS_ADDR_SPACE_BITS 44 -#define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) + +#ifdef CONFIG_USER_ONLY +/* + * Allow user-only to vary page size. Real hardware allows only 8k and 64k, + * but since any variance means guests cannot assume a fixed value, allow + * a 4k minimum to match x86 host, which can minimize emulation issues. + */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# define TARGET_VIRT_ADDR_SPACE_BITS 63 +#else +# define TARGET_PAGE_BITS 13 +# define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) +#endif #endif