From patchwork Thu Feb 15 06:19:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772846 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680711wre; Wed, 14 Feb 2024 22:22:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVw9snIeTkyVFy6T4Aow1hEZ+20KIOoMes0jtKfg28AcwYIYYcLezSe64roY52jf1rQdqlAd8qBJONLB4N3y3Rp X-Google-Smtp-Source: AGHT+IFV3CxRXvHkEe156Xkk6g4/lJpiospPU/GfpR/PAgkA58X/PQmgpcGFDsb87/LC8NCA6fKo X-Received: by 2002:a05:620a:3956:b0:785:8aed:42a7 with SMTP id qs22-20020a05620a395600b007858aed42a7mr1329882qkn.14.1707978169746; Wed, 14 Feb 2024 22:22:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978169; cv=none; d=google.com; s=arc-20160816; b=beG4aaJ//akl4qT6VHkQm3WrQfSTZdcWx0qaByzOF76LeNjuwaCDMx51NgiPCKumDm dFtVnzAS0fUnBmIHV4lrHE/U8zEL5zvmWKrI0T8kgxWgsARWgrv0s9j4tholBT5iLKCM N+vgmNEODRkrzQ8m1GPcRMfU1GR2wfxiTFY2cqYMXgd6JO1NlOPzS98DAu9TFFZLgKGm RD1Leobft5DJfjkpD43TIdHRzJ+bnUTg1QQQ45VsmNQ6uqMDCts2RFbwOVEOVv+iAYNq Ghhz6aMgGdrkowT+j7UIIObMETyApZYPeJ+pc6vdWzDNMCRsMgpopsXXgM2QiPUysTVV jO/g== 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=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=oc/+WLFzPdOkn/iB+G4ctNVLYQsptvyy0FUJ6yHbIQcEejWY8RomgZUXjnkON9O8i1 YERlCCJsm7l3cbOgRsX5kI6YliTsSeH77b6EceBWBSgp23yAHNR/xDQ4ydfouRssyzBY bEr9BqpA1UYhEByQzDnMythlPW5jTd/OfLT/KOFCF5+z+MJfIQDTTl4zgQXYQUiL3/fO wv2Y+q/CfsE/uRadoHgIZXi9I3BqoY8WYBTKLgt7HPyXqjy+i4FoymKbv0PyIPAFWHA2 dxgzGO0pY9PvunKUN8M75TvHfZes10goRZD5RxmosQ2kMauVMSkpEMR6mKZDYsAUDDsP j83Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C6DB3DVd; 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 o2-20020a05620a110200b00785ae603d88si815362qkk.88.2024.02.14.22.22.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:22:49 -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=C6DB3DVd; 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 1raV6i-0002FC-8B; Thu, 15 Feb 2024 01:20: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 1raV6f-0002EP-Lo for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:25 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6d-0005Iw-NR for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:25 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d94323d547so4406855ad.3 for ; Wed, 14 Feb 2024 22:20:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978022; x=1708582822; 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=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; b=C6DB3DVdqm8erd2cdHDnzlaYP2qpWWt6WKBakXN8i/AJjN0jbwsTbqKsKf5yi9jOsl /8i2dLgpltV7XfxCfk4cwDaoUrSmx/pwC3rF66Qv22gRMEmUX4ov4r6UMPuYdimiGOxY AFq9/ZluAFf1KdhlgikeZD34EzTi3w16hwjHPgvnEY+w/0MBe5O9lnIQUOlr1DC8CDP2 lFbvgpaCF3BHKd2FjeLfYa/bdIQjUmx9SnnLwfFSzR1mT3+KoklEXI2FYnHBrRipsb3v eay9yIK8//E0kR2HVJUXVZF/EzdfjjzfWFK5UpsHL+gpDz8/hG5YyWVjLRBCqZK4M441 ht4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978022; x=1708582822; 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=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; b=hovhhSIz5n8aKP1FMwb0UDKNgKvYwKEKyBOIrEYGh7b53JOSS2xD6ib3jUNxOhj+9e HDbdEj9EhJeKtIe21IxgosX06M3CSKSEOKId5X64ZMXZJxI6+fosFFEuREbcJDy+XvUk nMA6FlFHUTOIXdvaplj2g3u5zRFZTvcUB5HghjV1L+JBK90hMUxIjjW8t9rs4y+XcKIg hrHMrqzjWcE+O3JeRpLlQibIk6bDLpFIhNBgH6sH+8jNyk9z3SyN927/9/ZtPTch2yK0 /SSJMooz7fohuAcCzll0UkRbPA90r3rrSyJu/rEg+s7u1jQjZ/ZNLEwkqFddr7fkONz+ 5ePQ== X-Gm-Message-State: AOJu0Yxh7+/pKcYbFpzIOWU7016287+/h7vFkZ2k67I8PNpRpHjw7RQY Q5cZe9T3AfAlQnBknJuQXfpvlZQ6ir8iunc+rXmU4BrBH9pv7oPHGUVQ3v1OicLNNLfv6RgCrGF B X-Received: by 2002:a17:902:bb16:b0:1db:8f3d:d48d with SMTP id im22-20020a170902bb1600b001db8f3dd48dmr150517plb.22.1707978022425; Wed, 14 Feb 2024 22:20:22 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 01/36] accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect Date: Wed, 14 Feb 2024 20:19:43 -1000 Message-Id: <20240215062018.795056-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-2-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:19: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: 772853 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681284wre; Wed, 14 Feb 2024 22:24:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUYyVMgOoE4JELs1C+UdDTj3ClRKrR2D8Pbuef6lj3YLk229CmnlKcZdUCI1GIk3j8zNeQcKsL4SWdu+OX9tQC6 X-Google-Smtp-Source: AGHT+IEFuxsgPqeSpiyI33+d2Y2n0fbQEFv+Wy5qGaVffJRDkViqQmht8wxtgLHH7rzxUDBPui// X-Received: by 2002:a0c:f58b:0:b0:68f:6be:9f94 with SMTP id k11-20020a0cf58b000000b0068f06be9f94mr762062qvm.12.1707978294777; Wed, 14 Feb 2024 22:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978294; cv=none; d=google.com; s=arc-20160816; b=OlhHrljZCXqEB4gm6ehpLLFb40dbdtudyXLEf3KL6/jvVeqYYh8Y4/EwXcyoQITY3O TfIES2Cpq+uLHQOWdwwWXFGkVRg8S1g6n2eF7BOPj0xiH0TsgVcJvJHssKp3IqfSbQuE i1BH9B1uRKJeWohzSbPvXq1/323PQnt5Y1sOOelsVt8/JdxrNY5QxLGRN3ToJI6dNgu9 gjc/xXBdkSaEDLuNSXa1ebete0lAaTB6E7hzfK5VBfLGobKYf34wap3O3clGhg0gyWNj UndkZ2aO896kiijWqM61I2JBgonlOwVch1d2NTuUVmOULwdIxfs7dcAuCZorH2Pc+Y+h shRg== 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; fh=v7v6q89OJlq+NxHejbJ/ziw7VE+fSww09twjGPM2dQM=; b=abH5QsZws4gzIyAHDMDw3udRUH6WIqTptOzAOhqlkyO2p/fvyVSlhiG7Z5HjxnKkuq okO4dvAPYyjyznlRYwiDM0+0C+mt7Do0A2sMaHA3CAhaqfdLwPUx+on/5xXN3YpWVQva zKQR5x51FjsJXTYZ888/ujXlpY33ZSVhPQyKA8Xz8HsjrT6Cl+2krzQqFU0wFM8zcbXz N/Jed14WVEW4oB9t6UUOCM/lr8IS6XI0wxRfIQ/sp2VoPat4F2qNFaCk5GPpVEWunsiy Mm+0650bg5qc6QF+7068wKLlw2VjFZSsfV/F8xpAY7PoKLajMm8/ZwhcBvE56za559ZO 2Ydw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=df1jQ9nn; 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 8-20020a056214202800b0068cdb0ede35si829164qvf.399.2024.02.14.22.24.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24: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=df1jQ9nn; 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 1raV6j-0002FR-CV; Thu, 15 Feb 2024 01:20: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 1raV6h-0002En-0J for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:27 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6f-0005JP-7v for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:26 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d94323d547so4406915ad.3 for ; Wed, 14 Feb 2024 22:20:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978024; x=1708582824; 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=df1jQ9nn0h3aSO6nnsYW1nF1/3ECGV8+AhgrhIomokIQnflH0KW+3wgGMX/1FEaDl0 pBGf3EPTOKMG6MRauKwpmcnU/la1Sj9ULKATrkyJ3/kle/jTbRx5Hrr1Etir5OZLeqSC /rNdiEAda6G9GqDVCh6gPcSbs7OWkYhkQadRCKRcxiuUQMgic1NYhroNiydabPYwlnZX okwkCg6g1HuYeFRSltY17Us9jy99JOLsOtLeO+6QeX3iAJCVqNPKVdac/KxiQGL0KDUk 48P6qnKhLMZ3NceHPmDEg2J7J5dBYLpuIzZKOjwHOYR11GcKEfnxp7u81b/3cjo9Lhok g+NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978024; x=1708582824; 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=DB4cq9lgvR61yl7kIsOWkQCJ07z7T2dHJNaEx+e385rnPb4uyayD7lv9hSQorPstGb +IyEjxc8r+YO8Umje4CtFVq3vpgo874IpmcBxADz5TY5TaGY0r4OrCn1P7gpmK4eb0m+ GqbyNEskx0fGszWjfgqsSS3p2xGhrOCu15GD5cQPexspHP9K9k21n1vN7L44LExah8Wu /g7gBI51ZYh6dV3Qm9NGBYpVYoYWSECMNsdg+jbjhMAZbG53brVLwb9SaYER7sdk+o2E onzyhrjxmoLPFWxsTQ8ytP+HmBw3+3gAYiTyLUBtmDFpWVxynLPIeCmtbT0RO5JXTxiO IXwA== X-Gm-Message-State: AOJu0YzRfPfrZ7zuuW1IBLBALPNNtLaNMBgWmSYwbt2eyLWhnRW1Z93T hpDUFjrHlbR/HgYTLj/0Eqo2dZUzqpTSbfOJxhaD+Mxv3oOYC9b/ELZn6UJU6XEzOhVYDrNubXS 4 X-Received: by 2002:a17:903:18e:b0:1d7:88de:cffa with SMTP id z14-20020a170903018e00b001d788decffamr1095734plg.19.1707978023844; Wed, 14 Feb 2024 22:20:23 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 02/36] linux-user: Adjust SVr4 NULL page mapping Date: Wed, 14 Feb 2024 20:19:44 -1000 Message-Id: <20240215062018.795056-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-3-richard.henderson@linaro.org> Reviewed-by: Alex Bennée --- 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 b8eef893d0..e918a13748 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3912,8 +3912,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 Thu Feb 15 06:19: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: 772848 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681123wre; Wed, 14 Feb 2024 22:24:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX30xNsBg5ImSifwOFmQhRXCF6XO2a0wdD7lqmI8Tk4TMz4yEIsdscFHxHFUiSQ9e/OdI6JeU8nVTxPtis0g4W9 X-Google-Smtp-Source: AGHT+IH1jUIW6yQw3sDTuC6kwyg7ChXQQVF39orERctTao2yS7887gj9qdoaBqtOhwTF+IUkVRMp X-Received: by 2002:a05:6214:d6f:b0:68c:62e2:65bd with SMTP id 15-20020a0562140d6f00b0068c62e265bdmr1409063qvs.46.1707978262431; Wed, 14 Feb 2024 22:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978262; cv=none; d=google.com; s=arc-20160816; b=CMPIrymuBStYZt/XEtaOvG8juEPPkRBe1YdXe2L/4i3K8fo6b1ElufaFwcrDt9PQpq utBHZNm+iQPAFbyCehe4LSPC4LvK6IHZUzybS0BBtIovZTu64C6KYokHg4ragzwBfnQM FG7LvdaYBSKs+t6dEiVv0mkI/5q0sEK1Oqcw/f+OdRkAXMhUK/CKmst7AOqhSmszUYSW epsYfu3z29wlb35VRoxCVYqJEUC/a0dW8XVny68Hx8TUMzbBUtmB5DdQe0491P6ZRZUU O0ROAZ3afR6gI9wKxt1iHWWrTyPvS1KWNSZRWCRSDq1+TQKSAVJZF1+3Un0uigGihvSY fLAA== 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=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; fh=v7v6q89OJlq+NxHejbJ/ziw7VE+fSww09twjGPM2dQM=; b=Ws33qalVQJzpbBA5H0QNk+5mkKz5cefaOLWbv+2yXRFxndhx70C8LD+7HjFI4OEM+h 3XeMBMCFBwygu7cQkak3NK+pEL/Smr/BVsZjl28x93F1lI5XH7obLmJYlTuiqZaLkbNQ +AlRBclIwHH9bc5s5GQ961QuA1mnQCBEKKJ6f8MJBxuqlMnalZSwegsAqbP8McFIRsKI 0hS6Um4XldLWSpIAO09VWY+7v4k2FABHzD8Rkgq4yoVxYnfFF0/xHCqu7RY2D32ufu6g T69e4eQs0G68rRQwaEAtYYnxEJSLUK/fXZmP7Do+jKDc4+wQrzGAGJN0hP/mtMXy55WJ RVJg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cNoxOKoj; 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 if7-20020a0562141c4700b0068f07fbcbffsi800483qvb.43.2024.02.14.22.24.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24: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=cNoxOKoj; 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 1raV6k-0002Fe-49; Thu, 15 Feb 2024 01:20:30 -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 1raV6i-0002FE-BE for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:28 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6g-0005KJ-Nv for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:28 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d95d67ff45so3822795ad.2 for ; Wed, 14 Feb 2024 22:20:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978025; x=1708582825; 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=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; b=cNoxOKojC4UzF4AI7na1FxJY3m+K4nHX7XgnBCbuMD6ROJIsL87b5JC5wJQHTVuTOu 1vbHxKLb+Jx3fivdH/YzcnFTaNzLE6Q9HSIxEuLvhERzFCur+qqCJLo9rbuRhsUhmMZG akU7NT5PbdDenhOlQaDqhW0uINQuoJ9pmAKp2fZ9uMOqQj24w7M3UOlD8WLQLZU7j1u4 YPcnRkst3Dh31yU2H07Mhn/Mk7v3S2p246opv5g6l2Av9V33ihg9CtSsViiozHwhioWc uIloU01jvGekARzCtVv5+CknWYl5v06ou7b5kICQCdd1JYHCnSLheKILsiLtBad2P05K rYlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978025; x=1708582825; 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=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; b=ZwLsXbXtiBjXYQrXDWUJzWVpYLh7ineZEglHxiRO+WNF0Evbnx3CurFN1rl4an4VFC 4n7QJOx/fBlvD1vlMQsotYvypCvwgzydmA+/OO4rdFILNtNs7Mxr0Aon+kYHCcEoLII0 TzZ+SgrMVihvTPHZMUf9aM8h/pgHY7sRqvKrI4Fh4ODmOXSnBk25Cg9I0YPgSCNANlmx 0OxGGGdixqa1mYKduZ66HM3qi5JebUNe7Kg1zDIlnLlcb30hVnv0s4+K96Qd9RedORLL LKNUY/QJUOVz6Pd8p/Vr7CikxyBM0xTfnh22CThJiUUcafG+otlaqjjJrMFCfGTNa45p maDA== X-Gm-Message-State: AOJu0YwoGFWgUq8iGS7DKboDwWFtsi+yz0uAIrgP9TnFRQZU/7trk5ug g/YUOFUgOEVkO7Jt8J6Hx6EaYzfIED4SVnTkUmN+PZBxDZUD9vD4OMxrq7lbiAnSonaff1+i5uk F X-Received: by 2002:a17:903:183:b0:1d9:d300:a670 with SMTP id z3-20020a170903018300b001d9d300a670mr1083474plg.15.1707978025383; Wed, 14 Feb 2024 22:20:25 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 03/36] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base Date: Wed, 14 Feb 2024 20:19:45 -1000 Message-Id: <20240215062018.795056-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-4-richard.henderson@linaro.org> --- 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 e918a13748..e84a201448 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2893,7 +2893,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_mask(); ga->bounds[n][1] = HI_COMMPAGE + TARGET_PAGE_SIZE - 1; n++; } @@ -3075,7 +3075,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 Thu Feb 15 06:19: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: 772862 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681446wre; Wed, 14 Feb 2024 22:25:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWwC3/M9bLgTHZSLqhlxdClplcvHADC9vwvoVna0FmatJnDImD0+wQ48DO7VVVuxxf3O4aoy+mjYLJVC9bLFDXg X-Google-Smtp-Source: AGHT+IGMdoUVWgut2ooRhzbsUbv9JJrrLosHarqAWYaKqdHg6I6KWt+LAj2yqDVWugXaciVGo5SF X-Received: by 2002:a05:620a:10a5:b0:785:c02d:9762 with SMTP id h5-20020a05620a10a500b00785c02d9762mr6636151qkk.19.1707978336575; Wed, 14 Feb 2024 22:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978336; cv=none; d=google.com; s=arc-20160816; b=LtdYmINFXy+s9144DhsFvyjE5n+099qkGppgHv+ZfBKQM6YuDu7jvoAdLsXzKW96xT hkXARe8PrQ//sHDj12b9VDjQlOJVTQXnuQV6jKX6wxtL+0q4SavYFlUZoRVGvZYkmwOr SaXPBGTMupyNeM0VhPZrBIO+yi9hsQj1PfiKAHLUhNFaTgdzKn81mJXAH4oXan+WpWaN 43VCD/TQoS7uO22t1+YhNn5fdZUIUzZ/9Q9tp2T6sv0kK+xcQGz5432/LD6C69b/dPX6 fc4vVMA4qkeKKu0STGrI48puck/XHJbNCS6qwydffRxv4maFkAS/+aMmlm9+5cPoiLpQ xPZQ== 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=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; fh=v7v6q89OJlq+NxHejbJ/ziw7VE+fSww09twjGPM2dQM=; b=FRS4YyobhzYwd8s/tPT7yj93NP7qi8pB6hvuFurXbgvWnKO686NOJwfN1/+kEO2iaZ rRs6B3o0gOXwidSNoXrEj5I85S+EtPp5qYHsr7AE7DVuen3hY+mjB+cPfvX8tnAne0f6 TEgnFrtGAGdOo52jEVmy0PpxtdLI6fT3erUQ37X5sG7ckBlcQgbJFloLXh6+ricq3/c6 O+wPkS+L086zQUT/4vlcYTxt/oxglxUwgd0SeuaceuPRgOdCxrOevUt3cdT5trxwmaBc h4JX84ZlyTo+BiTq7e1+7ywrHKqF/jRuLVWPRJJoyiUpHeUlTrEwsHTRTcAwiRqdK3+8 MgAw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PoZHd75W; 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 l24-20020ac84a98000000b0042a09d5d0aesi663771qtq.788.2024.02.14.22.25.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:36 -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=PoZHd75W; 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 1raV6n-0002I0-13; Thu, 15 Feb 2024 01:20: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 1raV6j-0002FT-Jt for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:29 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6h-0005Kv-VT for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:29 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d9b2400910so4240035ad.0 for ; Wed, 14 Feb 2024 22:20:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978027; x=1708582827; 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=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; b=PoZHd75WBc6LC2ahvP1zKctqUDqlM0VsZrH1A84+kemCZRB1g8khlO934k9XwgkzjK nOmeKsZm+NNxKsodDpKTbHjCaZbzgC0HZWlNwuL92/tPIHrSNIzkKufJ81CxPWHxRQZ7 eWZR12OfdrF5PK5NvcnYfwXv1WLw60Q0k7+JzsNoYRyGv3Y7Tf0QzRPA3IyeFLSzOEUB 2ZEVQFLJ8c0L1Jy/wolIK0VsJeCbtakOzGshEZgtycTDcckzZbZfWutTu9IH/cubGIw0 mI/Okzz2Sm7uOZNSM7afHYLHIbnE3HCt3CKzqlAz/asaTOwO68WgwfVbapRsOqPqx9TH 2eFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978027; x=1708582827; 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=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; b=fIH1ths7PoO4pAt3puGuSPGJrKqIcfCMP4F6Yw3FIrVztewwBqPkbCG93E2nAi/nK9 r//+zPf+HsTjduWiLGU+DKU653/MNXmsWeia+FJ+feSdpX9KJQeS2Q8t7RHMGo2VQtSq iWVtkqXm6cW/ReDJeTKxFUkbUV1Oq4rFyWWZutkjBMKq9eHvJLJN5OXWjK5vVDUTJmCY vvSRcxWWoPfTO1mTl20B9+2ZKFbaG3DHq2OBka/pkODI4ZjCSwi6UomumFCoa6rZLclo lDVUV85A0ikEtGqD4b019jgSHPqIupqKOo0p2y5IjHAHRMXOvaGYcQBkUc5FQZUb7lDe UQNA== X-Gm-Message-State: AOJu0Yym2N8XVAPRMR4EWxyHK0lrrSYWAZn0nBgl72Bi4oItT7ihwSv1 vsb9W6wjaUXXPGVNOiLp2l/iPssQEU5kb2x/ziBqVFKv0Iy1DEXgxeqxyTJo0X7SyTd8nts6vQG X X-Received: by 2002:a17:902:d549:b0:1da:2b5e:6728 with SMTP id z9-20020a170902d54900b001da2b5e6728mr1600826plf.21.1707978026750; Wed, 14 Feb 2024 22:20:26 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 04/36] linux-user: Remove qemu_host_page_size from create_elf_tables Date: Wed, 14 Feb 2024 20:19:46 -1000 Message-Id: <20240215062018.795056-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-5-richard.henderson@linaro.org> --- 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 e84a201448..dfb152bfcb 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2679,13 +2679,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 Thu Feb 15 06:19:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772841 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680329wre; Wed, 14 Feb 2024 22:21:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVsHq8Ct2y7k/08WCjnrVBUilJcRmDLGnMmg/2ZrhWE3tuZDZNG+NSnVz2GDxub6ngbe3HI671rsDMjVBf5MW/t X-Google-Smtp-Source: AGHT+IEaNyCaAYkFmRFpNci3gTva5vw4qS80AtGoxrLCTWkUQOUdw5GZxmYKdpmpyIRpvcxHw5A3 X-Received: by 2002:a0c:ca92:0:b0:68e:facf:fe4 with SMTP id a18-20020a0cca92000000b0068efacf0fe4mr912071qvk.22.1707978091880; Wed, 14 Feb 2024 22:21:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978091; cv=none; d=google.com; s=arc-20160816; b=wXY41qRG1H/8Qba+uOSCko+HrkP+qefW6fAyr6ZFp1l+M+iQMK5L5fkAI4ZxnHRxdo 6MkSmr4Ct5agAnqpAdDH869L9cy5VKQvno7Sq/d7BfVNR9c/wjS+iDyHMNc0QxZF/wNB /oZDpXGfJV8szGsIqREPgs5kprnQN80mApW2arc0jXHfBnMKJ/AJ9+Nmytrcg0+GStbN tkvwfs9sgZnqx4LXna6tcIad2+dFXyh7l6aE8dentbi1nXyUlW9acTTmtFG8toMAsQ/v 9wFnsMzZk13TGcFzTBZCLVTWQsMShpyoyc/6I0ejC6aa6BYINa++dSL6TXglJK+km/5N lxHg== 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=uxx5dK/27YXkgPeD+x1RoZk9/eUOzf0aYE7Jtcz7VEtmHCiCXh0hEXs/iLPuPZSgFl UmvXa3t5IRwCVxTNmyINCbyp1tqHoza6EONKtSMxd9dDm/byV8PZhVf5WOc6K/DNyfDT lw1s/oPHVa/lKLnDTiUb6Sk07urNp1GXMt0zLM09OQf/0dkXzl1X1Z8/Oi8nAmOak7ad yrgjMRKf9FnBHdW+EPQSoXwCLrTpqu+OPQCTadG7JeDLM3QxB07eidziHkrucZf8pgsw d64XKdICDb+jf6dF6TKa2HafiuVwadGnFriMPmVWxC2v+JFxmD9nsx6fjkOFGqXoSzYs 6uMg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zJFJ/SjX"; 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 pt3-20020a056214048300b0068cb07848a0si756288qvb.477.2024.02.14.22.21.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:21:31 -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="zJFJ/SjX"; 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 1raV6o-0002Id-MS; Thu, 15 Feb 2024 01:20: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 1raV6l-0002G7-4F for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:31 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6j-0005M4-GC for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:30 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d8ef977f1eso4469275ad.0 for ; Wed, 14 Feb 2024 22:20:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978028; x=1708582828; 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=zJFJ/SjXHE7Sqn4HUoCS/MuJRdx0bQFgr0XiEu6NKwX9V1tOOdkiIxYMukF1MJ3x1T xDl0bbVyhVwiwmeGwePBg8sJSMUodD6prl/HOM8ymn7Dkb/X0qZ3LsbZuTqosbgYsVMQ E4LQTqOtLYYtTBE4g5kE8MYQbDk6o/ieEJP5Eu1M1428qfnLBpam1IqQN2nsUM30ikoO shPccr5YcRFe5wve94Db2OWqNlBfZqCQDSfpsW41Dvvq2QNqEBawqcKxLoXUgReYWrlc Fq1EvqhbdqDbrniThsFqi0IRp4R5UwZhys7sdsHKr8aXoQ1bCJ97LW10EkA2o6elJX3o vTIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978028; x=1708582828; 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=Vdf80zVwVCgJ9qclKmSSQkKtGyU6nj/m0n0HEV3aKBEiW7Xhs2Rn9TKcotbkBzP1TF vR3WMVX/X1f9o4y2P2BT2GVfaEIo3aw+r2YErluJ5vF/EmpDg4mtxIYsx3qxT02dJYzK Q5negPj3Z4wotkQTuGQQXNGM4gluOgv6hdiw5IPwU5dDDCbUc1VZlaTNCxEySj6s0PwB SSUKLhINAQP1jdcItlbnfwr0PzaCq92UtVbMYlqxT7iNsBYwUMhMBppF47pEasEUSOK5 eE9uV4jUGf129i5vZzn7QeKCHrXwsj6AODfu2YutIrkCQHfccN9aayvj1tWd8NHbyjGa rwnQ== X-Gm-Message-State: AOJu0YwfkccT+6yl2kf6R6SS2U4GGIlkOuW2vmpVPZoQlpN6ScMdkYgk TcEuYh8/i7aEjm2za2NXSCth+nvh8goCQ5S6sadMRmf0Hhn0Eu7tis8Mzea8lKM3ipuocFrJ4/D k X-Received: by 2002:a17:902:654d:b0:1d9:6dc6:6616 with SMTP id d13-20020a170902654d00b001d96dc66616mr769027pln.68.1707978028155; Wed, 14 Feb 2024 22:20:28 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 05/36] linux-user/hppa: Simplify init_guest_commpage Date: Wed, 14 Feb 2024 20:19:47 -1000 Message-Id: <20240215062018.795056-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-6-richard.henderson@linaro.org> --- linux-user/elfload.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index dfb152bfcb..1893b3c192 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1970,16 +1970,20 @@ 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) { + 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, TARGET_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 Thu Feb 15 06:19:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772861 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681441wre; Wed, 14 Feb 2024 22:25:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWLi4gZ8u4PBVGfmGh4AmqbKf6BkMdy/cqlvYKhMXma924oweXx2yaaPIxcgBZiLzh/eg4K7Ja+nHir7kz4GxV9 X-Google-Smtp-Source: AGHT+IHVIPMZ6GtKfL9WjeOkcTL8JhcodXfVLy2SknYeOr3glotAInYEyIAl4v43e0W2X0xDUKLR X-Received: by 2002:a05:620a:669:b0:785:d3e4:c91a with SMTP id a9-20020a05620a066900b00785d3e4c91amr1098442qkh.20.1707978334635; Wed, 14 Feb 2024 22:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978334; cv=none; d=google.com; s=arc-20160816; b=nzC2cQgK3CuqWF8wZLHkE2JRdF8CSKZVCtfPvmewXSdCxNEAk8B9iRsI8YeiV1XCeH 8JS7bWD1mALSOoGTD0sD1zlLlzyH7HwnBPjCqOMJsTiX45JH4qGjuxCxWl3kkB8rF2SF m1NcCf76CC8b4RFk0Zme2/7Foia4bUNW+89DsOUmVDSHygUHjNbU9YmLu0jqj4//IAqS vzHC27VgaODm++DHezXlw+oQhpxtWgls9J9ddJoISNwj6sjoaNifjgtMt6UFU8XOqaKI 15HCcBKXHK+qAUbnxYLi5vLBNjIOTJPXBBrEAvYQTFxJ/zbI1UBRAbXTsvs3fsNJNtEf R0Jg== 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=OKdk0BbdGK0hofFW0ag2mR0RhbLRYWZz2UWHA1c+u82Gjk4JCJUmtK5V8//6g70sfW udnwzDOOlKR/Nemo9z6rokO2pHSDx2UjiLeoG/KcAMCgXaKf0tQ8RCdH0ciZXOnAxX22 z5S5a0JbgZX10q20tvvwkN/QZSsaOw47PCRHdq0BFvw+H/5olwRnvQz5l+FDG/jWYK4j Se8Ev1Jj39rHpcEPJAT4Q4682Z9UhxxNVvZoJbX3+XVZnztZhUokjKXHgrbw/8RJX76A 6JdEq4Vz/LrM1O8NZx5rky6KObfjuWYCZ243hkb+qyeLDEIlj6vVZODdQYIxicJDg4lr wf+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="oks/L9Gr"; 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 t13-20020a05620a450d00b00785c0c8579fsi899398qkp.632.2024.02.14.22.25.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:34 -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="oks/L9Gr"; 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 1raV6q-0002J6-Q6; Thu, 15 Feb 2024 01:20:36 -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 1raV6m-0002Ht-Pe for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:32 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6l-0005Mt-2x for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:32 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d9b2400910so4240335ad.0 for ; Wed, 14 Feb 2024 22:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978030; x=1708582830; 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=oks/L9GrJ2CpPAMuCaYTWC7zE9nJVed3jyX4EV7asGzUGTOmU6vIjY+VVGrc40FrQU Rt59eRdkrXZt7Iu53MXeiJkN31JB2qnCXGNEy9lCrw70F0A7FYsDK/dUZTbAdTii73GL 1VnM3wD7pn+pfJ7W5ZOUBNwAfeOYJFU5uLgUXyb3RAC6TPHOOEdWjeYQbVVG0g7HKO1n Gme5gL+dIVzGihRYfAzH584qO21Nsu7+NXFDNv3iYtpSsoyU9ZOJu7ADPap3Y5dX8YAr VtC1YhNckpUBl/P4mNYOGNMO/fn83V1juoiX5QT+ib/sB7ZrmxEhFih7rTX7HOHOfIEY aT1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978030; x=1708582830; 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=I2XdY6qaKERi232JiahYlbJI1930JIKeQRu54lUpOjqKFUdbDy2GVIBJ8GKSQv3aH1 2fiAfKnMXzAZ02ZyQM4ltCAwUDGaFziMn5VUWHTBaS9CmcvhY7aNN+3eoeaEZyla5+Mv 22k3JMbnYMutjoFIz2TwukS5wppJdq8JFSAevZZlasTLNgZY9h9EKGxoMGjPZ7DJZhL+ ES8JRV9g30TH5Xsb5LAjyAuphfxibxyPpgfIINFOjQXphKGSYvc/5NmbQ99k3yuQQSyw x9A8rQcrJlF2xEnz31hi2wshh98fHe23SO50f3AqYHsRzOOA97Ol9+0qQyXQSRaHhZiR EVDA== X-Gm-Message-State: AOJu0YxmpFiIPGkj9A54YBkVsTrkIkO7hXr/8vfIcdN63gsZ73tkr0r/ V5wyH0M7/CUU18z/J5k4i/V+yDu52oEGvXYnru93apU4TDX9t1kdTwRtXfWGs/sCbD3frbr5ykC d X-Received: by 2002:a17:902:ce8e:b0:1da:1fe7:cacf with SMTP id f14-20020a170902ce8e00b001da1fe7cacfmr1519807plg.25.1707978029794; Wed, 14 Feb 2024 22:20:29 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 06/36] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Wed, 14 Feb 2024 20:19:48 -1000 Message-Id: <20240215062018.795056-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-7-richard.henderson@linaro.org> --- 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 1893b3c192..a9f1077861 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1532,10 +1532,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); @@ -1544,9 +1548,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 Thu Feb 15 06:19: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: 772849 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681125wre; Wed, 14 Feb 2024 22:24:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVeskMq2W6wdagayF9/WrOOzAxqS9P0Zo889swPVd/LHiujv1Qw4tNehMYTtmSGhF74eBjC+hAYxAPa/wEDIjV9 X-Google-Smtp-Source: AGHT+IFtU2XWL1MsVREbhqArmAIJFcUoz8qbrxrCd02KdwJfynI0udE9jq7JVFLgBfL6r2XIGXGO X-Received: by 2002:a67:cd93:0:b0:46d:30af:ed32 with SMTP id r19-20020a67cd93000000b0046d30afed32mr937666vsl.10.1707978262681; Wed, 14 Feb 2024 22:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978262; cv=none; d=google.com; s=arc-20160816; b=WVOGGftxhJEFcMGorgokMq2BAuQ7WjcMYvPH/h5Ud44cxCi8ZzArOOuEYTYupiGBBa d9ZABDD0KisRThSX8yIfY9HkKqyJp9TNwfvtlg0+6xDZvsR62QTijOSdCLxTQC5Mg4MH Ry+2i5g4s9ZHTIKZ7OSzmQPW0DVUDivj0bPVnuKZ/MIjYlwtPpuUS8C+UIhrhrb6yB86 VGZfTwpyrZhv2cSUXbCpSM6ulORLOJSdP4KEsvWrVi1lQPvMRWJoaG4zo2fAtePAopyu pOsVBTSmxRxR+qWLRLYXuvKINbpylGNekiwIYPN2kmjox7SF7dnAb4eYzKt/wycr2/gC zwQg== 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=BZCd0gVgBvCfVWEu7FirPopdh5NjzUm7ETlYoCEa8aJfbxOAdUHmmh95hKnPjDmwHi tC0xyys28JqPaxObGDBovxNDtZvmPOxReXttS6/vC0XZMAADdnfQDhsFhQY0rAM8/vgj 6/qVUPit3yCvXQi63Dqn1cUTaPPYlIea3ZIGmGSLAPEicHbQrznRAeSgWNM78o+vzvhF NE5KZ7Fk6KasQqmMoanvdIGnvNMI6msD4szkc606NSa4qR94SlvcORpP+D9Suzzdby9N zgp20ZA9dkRQCs9QD1bZP+C9GvI4pojUVlLwkWWYz7rjW6TX2+MX6Rdo1NNKeA0IvTFD +8lg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=brLrEsIZ; 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 q16-20020ac84510000000b0042db24b2660si684386qtn.307.2024.02.14.22.24.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24: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=brLrEsIZ; 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 1raV6s-0002JL-GB; Thu, 15 Feb 2024 01:20:38 -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 1raV6o-0002If-4L for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:34 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6m-0005OA-Ca for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:33 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d934c8f8f7so4643605ad.2 for ; Wed, 14 Feb 2024 22:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978031; x=1708582831; 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=brLrEsIZtnVmD+npeC2nKkYX1gQbDbr//W+t1wYWPhextsakKtpAapyxbEZZX5khM2 MXa1l/kjVOBYFk5Gwz3HiGPzLZT9i3qATzbIm/KHSf6LGbJXWkXtdl95OzXwPVF+nxKU yHOGC8koBnJUWhOjfK8fiGixINQU0YcM7w3DAdort9T4rPM23lzV0yMVEFgBMDok1zLc FqO1Eq5+vEZ59isSatGIqcmSRjNUQwtw/cSSQ1oY/xHRTHtZY/Ifgc8RvqTHFiP432uT zyUDbWF1cXwEp/yNFYQ6mrw0MNqHNz9/VsFFTP9bnUEeTzjbwbUXQLqQPNXA/Fwa4Q4O Hdvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978031; x=1708582831; 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=cm+6vxFIKR19ZVkamPSThA9cpGrEU2rfX7W46hiDCNw/PDQ4C0JT7FbFKRwxjAXyht sW2xNu8GVzVXeYuDmq/u7HJ0oscjD6/IxnmbcXVTntF+gycBwjoqpGqRhUxqokUpGXkj pBe3ibVDO7SeN5hqzrRR1Aa1O4onANySrHiXGEUbr980Ppq5o2siun34J2Xz7JvYXs0Q xFTNmKhglJWhV/hVFWjKfW6WMzcJry05uUj8ECBCsSyCS0Uy//wJX9gbmJdeRvuBDV8w LDT7JrxxHbjgmXuaFOS57fTDEXKINUHVjIGhhXx6mxSOWMfxRGP7PCg335Zs4CaXnkb3 tzTw== X-Gm-Message-State: AOJu0YyilzGZZ2N087cVZMo3SaP6zVP1BRNzYuSK60sn26XCxIf9KQAP GONUm80ziF5IYA1uiCPQ6RVzhxQBcEJbDQ69qrgEKDO7H851EaacsMJJ+Qq3Vc7Y6H0tZ1uhs31 J X-Received: by 2002:a17:902:e5c8:b0:1db:3592:a6a2 with SMTP id u8-20020a170902e5c800b001db3592a6a2mr844246plf.12.1707978031127; Wed, 14 Feb 2024 22:20:31 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 07/36] linux-user/arm: Remove qemu_host_page_size from init_guest_commpage Date: Wed, 14 Feb 2024 20:19:49 -1000 Message-Id: <20240215062018.795056-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-8-richard.henderson@linaro.org> --- 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 a9f1077861..f3f1ab4f69 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -460,6 +460,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; @@ -472,10 +473,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"); @@ -488,12 +491,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 Thu Feb 15 06:19:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772858 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681389wre; Wed, 14 Feb 2024 22:25:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUQQR6RxIgask4Bf0jW9FJNOgXEFXLnsb08mIGXV2yoM8pDJw6VPndusuJDxOWkAVjXDulWPxQTWpNdU6Q4NDOO X-Google-Smtp-Source: AGHT+IHb9cJHu8jq/ja0OQ0irw+7KuQnosIE2VNACeVxnChe1D4zZDAW9yb5J2+yjI8xq4eC/RPq X-Received: by 2002:ac8:5911:0:b0:42c:4e93:ac03 with SMTP id 17-20020ac85911000000b0042c4e93ac03mr1325283qty.44.1707978316345; Wed, 14 Feb 2024 22:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978316; cv=none; d=google.com; s=arc-20160816; b=O2T7dBW34vncblsHqUO/SPbfNj5bMiQgiDfK/J6Pmr6fAVIjJHEQ83KYU1cg5g5fYi IgyJPP4oogmkpNwF6HEwNb0ChzQE43CvwVWFhndTxP04aax4IMmyVhTg/W+JIsekeEyJ 8iImV5eu0d6zH+ESheYINsX1PXqzB9gpkRpSR42DtP1D41Qb0cydAvO9EWFIPJQEgx/4 2TXt7oFhqdOtiZUP5h4cCsXakHU27qbo1psjUlyN8qQpwJragq14h1BXyJESUTXzOtcR pYMr6xPDYQcSJYCeM4t/LtrjVG6vP5rd0k54yht4qjaFPt2yYclFeS0QM9qLJNZuE40v F/jQ== 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=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; fh=v7v6q89OJlq+NxHejbJ/ziw7VE+fSww09twjGPM2dQM=; b=A+zhIsunSkrsVHZOzjwIlgvwApWuaqUUvh+amEbwfhmE4rUaueg6Me8mrTzodtS4E0 0k+Vf9/RjAfhI7Q3ZRNu7FIW7S4XYnzk/xbgp2RfsHnktFucJAmqCIa0V1376ET8yDiB qooxfCEA5HYN/m4pOsboVm4OGUXbWTBcOaho2S3v6qPQuVogS1JS9sgJap/6umacay5R TY/7rfnahxMlDp44kuABhY/cq4T4KCXSrJfJFUjedhWNNdq0qV7z6BOS1tXscIZUaNYW k2+TaHT680gT/4bbZzCMHa9yFU/BBbmpRrFQuwlZhECQnfzVDolON3e0mApk1yDbtpnE DWsg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HiZUsGsX; 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 t37-20020a05622a182500b0042c7e0e8055si752526qtc.414.2024.02.14.22.25.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:16 -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=HiZUsGsX; 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 1raV72-0002MB-VH; Thu, 15 Feb 2024 01:20: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 1raV6q-0002J7-PP for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:36 -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 1raV6n-0005S7-W7 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:36 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6e0aa4bb62fso311105b3a.1 for ; Wed, 14 Feb 2024 22:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978032; x=1708582832; 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=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; b=HiZUsGsXbAtdEqzv/Os4T9VrVa0yu+xpnlfE4xlXWLopnliaEpL82eKTOBqewQ2yY4 7uHcPQ6U3FdCCd/EV+Q7OeRyVQRyZtfC0jPUrhpreDPVb2KTuSmvWHlXaAiKZALhyjxk PqCeDtvk2VcEIN2dUmgBsB7bSIbbbs0uO3ycHl+xL+S6azxMR6JLQVYNFQCXyyNB/b1t mL/kOVllON2Yhuznb8jkKIaGwdnXcxEkRldIPrTrO37/d5nW8166vY//ZaMBTt5i9HIW 1ExZBJXjvOp5qlocicISW+TUHVEloeDkkTXsB/H3/KAoB7rgUh9+6aZ+P6Z3CzXKRrGd qnKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978032; x=1708582832; 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=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; b=me/jKj7Y69vZvCKLxrusvFobHXIsb3cKoB6LnFGuieAU3cSK9v7Na7cqm6lHizDqqe wW1upSFWIjguyP8K+4P9UFejCWyDEq2xWQ7JJTWiAC4bCGjNWL10GgIlt5aL7mm2PbUd 9lfUH3XRFZ1Kc2COK8O3jlIuDGRSo8GOAbNWLbQHNoIfby5NhUguMQOpFAXY7WGdDIGh YzoDX87a8D1QGbqEVm/Z+ldRdc6IsKId2s28Aedsdm6vqh+CXhFzN6DjfIlaBE16Sv1i zIzTM/TPHzI5rD25LimLoq2L1L7CJ7RsmYPBo28BMctxuioFCA5JytzhxOiIGhlvfmHg a1fA== X-Gm-Message-State: AOJu0Yxm0p5zIFXTCD6LIumbNaZqdrq4kERzHItxh0gS9pdVJQ9HYgAN hVm3BnvIJUHYj7fP51v8eouQDdP6l7xEpT565RbqzMH6jy8QHzcRdt0+efjNCKp0S10OM0oFy9n 0 X-Received: by 2002:a17:902:d48b:b0:1db:8181:9d04 with SMTP id c11-20020a170902d48b00b001db81819d04mr876527plg.38.1707978032587; Wed, 14 Feb 2024 22:20:32 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 08/36] linux-user: Remove qemu_host_page_{size, mask} from mmap.c Date: Wed, 14 Feb 2024 20:19:50 -1000 Message-Id: <20240215062018.795056-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-9-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:19: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: 772837 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680267wre; Wed, 14 Feb 2024 22:21:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW3NaDwCgkCVsPwjZLrKOEtHsgKT7UiYhlpKlRh82afTBF1yUnEYLRf3JQe88lDyM1KSg25uVsddcfmuBOiVJQc X-Google-Smtp-Source: AGHT+IE1m3t6jtCbJKWisuG/G8KSqaMgCNyxFwo1A1PgKpoRDuH/JzZG7J6ZgM6BImUOZ0d2T8u4 X-Received: by 2002:a0c:e24b:0:b0:68d:1347:77dc with SMTP id x11-20020a0ce24b000000b0068d134777dcmr1028492qvl.65.1707978073840; Wed, 14 Feb 2024 22:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978073; cv=none; d=google.com; s=arc-20160816; b=WpT65RP8lkPG5bgYhJU8TTGdoP+j5Gmu203TX5Nkx2xj79I4VAvmUACnfgNVv32Hxl P9v1NTUp3MAC5vH+C65JHhbehFFQjQZ90xB7LQITlwj8XDG0isGTH4CiHh2SXyB9XjyQ eGEC6ErBmQ5S8rypf6jMGWqZLWsTd/Sx62au2KQsxxvaNUup4FdimkAgq7kLyKk9/Xn+ e8pX7yzpmp2ADBwz5K9lhMo9zdqGP5fq79Q1QNfEmu5aZ1Wvc2y8bdwRm+imXF8ituTo 0HSt3i2ltOmWo1xwfyw83PtueAwO+pnju+fQphhFTSMs3Gcp7jX9joDWroOAxyytK9cV eXow== 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=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=EcusOjJYg62dkamGRanu5OpuasNFfd26Q5i97/qbQCVo8u1iL3wTgWt5QfAWGxFf2o QXZkDW8sc4KWzKU5sZ3ft/szmf5rM6IC0+V/t3RTRJOsWFkpmedg89pvEDwFq9v6Wjir nPto1Xfxp8DtKdPvg0iGtw9i5/6aYemnUSixqWn8oBVN4LnMcWfn0mRltYRDJduf3VwY p1zS2b1kvkv9awlRqTAYcXcYL2V4IENdzISrD5SdoHFhuhI5fc0WTdxQFHW0rC35+xpj wiWpfMDmJpdzSZF7h4vLYq6v4GDdGUtycOSpQvKoysWOsGE2Ll9Tg/jeTr3+KksMSQx3 CbbQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u++Z0SWJ; 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 jp13-20020ad45f8d000000b0068f01e212dcsi757385qvb.324.2024.02.14.22.21.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:21: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=u++Z0SWJ; 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 1raV6y-0002KF-B2; Thu, 15 Feb 2024 01:20: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 1raV6s-0002JJ-5U for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:38 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6q-0005SV-GL for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:37 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1db562438e0so4115615ad.3 for ; Wed, 14 Feb 2024 22:20:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978034; x=1708582834; 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=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; b=u++Z0SWJyJ/Qkfh/aAowtDc8Yiyd3wOUOnq6/Y0U9OY662wVzjZI5XdCkLfdMW25sj ibcS0e9H0akrR6JaVnt32Z2/5gs66TK1Rjlc8upbiUXZdMiuR1qdPq3pEGmBrjj/QKlg k914j1vHQPBaQ7LGy4imfcv4jMuCNgyxKjG7Jf3zUJeZKEKBGN4rwcWo+2kSgcpwlZqy gqp9eKLLEgIQW7Y64q7r4KOfPJEiMqyVHiXK51ZjW4LTeYn3u2V3bQo3xkJaxvCPIvwr OIj9iW5ojMOcqvZ23JEzx1R3io5iS+j8gW3wFPzZmjfpXS8R4e7olBzcMz/1ZIHbNBBz PwBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978034; x=1708582834; 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=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; b=oFhizmgKcOj/TsvQ00Y6oinMjpvO7a2S+GIJEnf5sd4CinkQFjbRmvqrkAiw9XzIEw kkQo9OFxCZv3ZGKug1xRnRQxHFhFRnHqDrj7twBlJr3x6dDSz7+7GKpgRfUuyNPgkCDE ioBcxz0suMnlTNYpnaEUmso6L+Cfr/Bc8FBwVyEkIF0BfC2Ndwn639aUJBU+Rqsis6X0 ddo5zpYOQjS3Z8AXcrQdD1HAmRO8SXtPL9gN8/pa9mScDkJGX+5/ev5UJNmxLJR9vctM yg5MEWEhxxKRO3thGIroPpiNVaS3MDItjX5/E4I1ituvV4sY5uyaHIxAGBiCJJS/r8Wz aQlw== X-Gm-Message-State: AOJu0YyeZeKN1+ij0x0+MR7fujRW13kh982Nq5y+RGQ7SQvAk3shpqT0 Z3barSwBnIrP7kbEvv8nadUtFIY8i2a5iRUh0eicRqDolQbNC8VdvC/scBFHaFqt8hFohvirCb3 2 X-Received: by 2002:a17:902:e551:b0:1d9:5ef2:abdd with SMTP id n17-20020a170902e55100b001d95ef2abddmr1119429plf.0.1707978034007; Wed, 14 Feb 2024 22:20:34 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 09/36] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c Date: Wed, 14 Feb 2024 20:19:51 -1000 Message-Id: <20240215062018.795056-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-10-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:19:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772845 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680671wre; Wed, 14 Feb 2024 22:22:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWifSeGG4M3kT6VI0i/8oge2A9kIi2khiO6uETyCKrEzXIVBeSGCNjwqmEE+XSnRyS20zWHDmHFnlqSuTGVsUL7 X-Google-Smtp-Source: AGHT+IEwHiu0M63+U3yHkHSGa/bxRJdbZUPJVN3v2hDv0jol9qDkUULmqbhhIeRmuw/Cq19myE3Y X-Received: by 2002:ac8:7d81:0:b0:42c:14b7:b603 with SMTP id c1-20020ac87d81000000b0042c14b7b603mr888527qtd.36.1707978160864; Wed, 14 Feb 2024 22:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978160; cv=none; d=google.com; s=arc-20160816; b=xmRph7PS8AvY98qI3ykm4x8lIxVprskO/zUVHjxTzfy+fskHGh5wDAY+lYnydpCoq8 FxBZGBWq9V6l9sU7klJVYhR3GvPKRDkvnfLgN45q9ju8gjmm/GDzLCHx0Pt1s6VQZ0jn PBGzd2iufqxxCZvt63mEz5X2pkfjWvh9niM//QJtRSZthy6oe/81uEzHO27e9+ElOQ24 B45gGIB3WHcDWbOCulwqYdcGw6Fj+cy+iiFVRwofPb4xA4ia0AIiLfReJhuCLYyFp+Xr VUJpCrS69DcD0Eu+1wyI7zrrNm72evYZb42gzdTF5ll4yDlc9jsZ7QH21XYRqIL0dK8i W/og== 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=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=Y9+aJQQiQVfKqVK3/aOpEk93mq1g/4bFqACfmfF28Wl6v3Vw+JtyIeVlyBG7bPUcdJ 9ruORBjB+2mF2tbaRmNRq6xrZ1KoZg61aih7DIQBV14YzPYbb7jBlowQ+nUNVgML1bp1 6n1A0nWdtD0kioGnpbqpw+i2+HnCimDi/STPtkYZR9evHsaDntQePy06IApxGiL9u5TP 06xAnuDlUoo+1so+bDMkosuyOloSwRFgvu6E6hIrtna1RRpMgyjCRUyTWI6F4ieh1tw2 dA9AU/pKa5+FZAjt7wTijB6JJ3YEylXumy1GdJ3r0XnBEyOFLQ8v80S4k+PMwOrShAWu C+ng==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cDdGRQUz; 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 l11-20020a05622a174b00b0042a7092de67si752084qtk.42.2024.02.14.22.22.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:22:40 -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=cDdGRQUz; 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 1raV72-0002Le-D2; Thu, 15 Feb 2024 01:20: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 1raV6s-0002JW-L0 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:39 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6q-0005Sm-Qr for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:38 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d7881b1843so4655405ad.3 for ; Wed, 14 Feb 2024 22:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978035; x=1708582835; 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=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; b=cDdGRQUz26fPfj8B/+35MOCl7Bal9svozW2JK3ehIkjqbEvMEw2W0GwlUfF9EXs26y vUuLgw/zU9V3zWDkhHiZU9sfseC1cHi7cTwcdZCNl8zILCNXU3f98I8mvVTjK5FKBznU cXz9D2C7ifYpNBbo+o1ffzyrJUQtwTHCoPWBHcVLB3BYKUvoCnzQUavZYeX+dvvpC3S6 j7S/ylpYbFrMVNRQvRSrGSLIQ+KB0paZtooM+U28+rDEOlcq+uORAqQITTnoo7YLlcWS a6EdF9R1e2Kflfpba/yb4eQU6sSH67vTWKlnFa2NL9muVIaLpNwlZ7MbXbE5BIHWeC/B g65g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978035; x=1708582835; 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=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; b=oFXDcz8f4a/xZCi8pRPcdeaoXKV3YATWfN4XRHd6fI/oCZJvseJ1Zpiq6tSpKubV1n hDSjlvCFTiG/urmevKx7QLAbUFAOze+BFykaE5/9B2xwO6vGsos08k6EJKf3aVznXgK9 qacrvJBib6GgNg2EtAmhH5tAP9Zdi692BxOCZRaWVEGAMaV9Z/Uv+FDAbquQsU3xV4x9 FJHW87h4I8xc6/4bWZRHWxYWruDanMJtlbrz+T9qH3pna4zA0VqYxEjhQUDbBZVuwAEJ m7qSamlrhCzX9gOWmapkeds9XtG9va3qWRnNxUlqO6sRjAzmRf9prwOzPhHa4TQ+lA3H 5ziw== X-Gm-Message-State: AOJu0YwJbxxU/l5UFebInWd9zdVWivEJYvk0ON8lCEpfHeebsr6QKdmc 8TWRZtEdc8WB/CnB5GuaKPYhT94LZ2FIzDzDz97WUcR6Pjh/aay66l6Medf7F6B8HRMXNX6MU30 0 X-Received: by 2002:a17:902:f7d6:b0:1d9:7095:7e4e with SMTP id h22-20020a170902f7d600b001d970957e4emr723723plw.27.1707978035381; Wed, 14 Feb 2024 22:20:35 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 10/36] linux-user: Remove HOST_PAGE_ALIGN from mmap.c Date: Wed, 14 Feb 2024 20:19:52 -1000 Message-Id: <20240215062018.795056-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-11-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:19: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: 772871 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681580wre; Wed, 14 Feb 2024 22:26:07 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVfZVbYqIRVLTr8m+svg01FT276gYOfujxsGR78s7lU/i8/Che3itKX8dMuPIqSD6+vdkiPfe9ohjKFO56Gzkuj X-Google-Smtp-Source: AGHT+IFONMa42ZsgqGzFUDspE5c/iSLODFFTlR6+f2VqnA0miHimq2Lm7dybT47qaJ4n9IbopRMi X-Received: by 2002:a0c:f2c1:0:b0:68c:6824:3413 with SMTP id c1-20020a0cf2c1000000b0068c68243413mr969927qvm.49.1707978367751; Wed, 14 Feb 2024 22:26:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978367; cv=none; d=google.com; s=arc-20160816; b=igROZPZGgZGkkvM2IadUIqZSZWmjgn7OlwjNUl2zu4FpuKbwQy8xze77gA+0YwG3w8 cobtGa/FxI11B+0SO3xNkrrmcvcwswCjkDXOQ+1/REgQm5owarUwUOAY259wbhZQcwED gAox506LZ5m1xVNzHdNJt+r5WsmAb+YG0HEA0BvWsYSeafZoko7cYqWK9osohjCq5o9V +CTIuM/JfPiJ2gmNv8zslNd65cnxCbpxLSNHIahTmBlOi6Xl4OvPcJncNWiiKP92FTrE Iy74x2NL3Sk6pub12tiAjcXl5gLPTakF14EfS4kT7ScNiaq+VnnbMveQolayLPmFA/BX UX4A== 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=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; fh=v7v6q89OJlq+NxHejbJ/ziw7VE+fSww09twjGPM2dQM=; b=QE7rbg/S84+GmtFYXSxriwFWfs9JwrqeM/JPihEa9PXYcfC1yaNCSuuhCb0cZOlNQG HuRj5Y5djzI3CXW5BmzK6A5haDzoHPfIEbAvzN9oiSmU+IQc7QKsKGPu/WBMdGH8NjU4 Uzs0NfSU+98CiFiC+ywkMLzLC1qIq7MnX1Bd7sPiZtr0kJ1xaw08xy8wHEadmVmmHGru RsymvC0/0famRJUAhFBm9ra8kQazeu+0rC5jDGNb72iVPPDLrzdAYE+eyM1mnXDnFe+n Mp0RZbZU+O/yGZ5B+84b2HORy/JnPw/7dv+d1tXjv0JsyhJloxOAczs3QNvuzo2+aJHz Lwjg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kyE+u9nV; 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 q14-20020ad4574e000000b0068cc3b10b84si771291qvx.275.2024.02.14.22.26.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:26:07 -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=kyE+u9nV; 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 1raV74-0002Ml-FB; Thu, 15 Feb 2024 01:20: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 1raV6t-0002Jb-UZ for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:40 -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 1raV6s-0005TB-8t for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:39 -0500 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5ce6b5e3c4eso398238a12.2 for ; Wed, 14 Feb 2024 22:20:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978037; x=1708582837; 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=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; b=kyE+u9nVvw+xMyRJ9BwM+rq86mWks7j+fwgHWUFj3SD1sFd6VTJPxTFkstVkmRNkgr Zz6Mn75ODKSZoBp+0mqRH+PKrLc3KZaHeoZ5z7gn89UIk4DSk/CrzoHKwsqJain9aIkD vF9oo/EgDlcDktVDzmJiFFaSjDAIaF6a1NVkec7qmXDyQB2R4O3VRN/ENQ561WAkFvuc +a+DaTfQD9mFiwmNDoGaJCmDIPXzCixUVceTx+7k0YMrEpiJKRQw8Puz99iiiSagYy9W 0CLwC3ibMykqJap4HIbDTnWc6ppXDd1e74Umc4MRU7x8Sy9mFe2+g54ylarsURluR1ei 9d5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978037; x=1708582837; 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=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; b=PnYJD4AWTRJVkkYhN4nR8DWVGsfMJAVfg8Y7ZyRLMyORxcudU7vzrKEc4Y0At9epjz copYxIxXydgWLt5BBIhI5glIsQigQ/45tVtPJ15vLqgXBDIG+6ofHhqfn+D/A7yAXRXZ UAcdfBTEktpQDb6XLmiW8HkLoaS72V4/Kr5zIRQxk7EU97rB+yZDTCgqrxyEZrsgd1Jz iWwFZq/3gjRiO2esHA80HaFo7/pa1NgMgZdDFr8+pnkwiVCGCvnlDiN3qXSGMzAMAk7K i5JPN3xkkRB6+cA9SDCK0Ig2nz9dIlRvc7+VpBtFSY80cZJjuHJjALab2U4bBowuL4jH 8cfg== X-Gm-Message-State: AOJu0YzhkeC0H+9jboERXC0GETQFSmGr0Axxny+WWuIC1XYkOUJZTVWq hlOYO0Ja3/Qaozp0MJGFl11cvRVZzrQ3RpIadgPHnY5xocsPH4i/uF6OCavg5xaCg9oOpxVCpPC s X-Received: by 2002:a05:6a21:1519:b0:19e:9aec:ba1d with SMTP id nq25-20020a056a21151900b0019e9aecba1dmr1442595pzb.47.1707978036792; Wed, 14 Feb 2024 22:20:36 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 11/36] migration: Remove qemu_host_page_size Date: Wed, 14 Feb 2024 20:19:53 -1000 Message-Id: <20240215062018.795056-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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 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: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-12-richard.henderson@linaro.org> --- migration/ram.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 4649a81204..61c1488352 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2935,7 +2935,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; @@ -2950,6 +2950,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); @@ -2958,8 +2964,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()) { @@ -3792,6 +3798,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); @@ -3809,9 +3816,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 Thu Feb 15 06:19: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: 772872 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681586wre; Wed, 14 Feb 2024 22:26:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXsjROoUQ0v9MC8qbXNc8L6dgBEcRGbjt7we6igmQYf6pmVQiTzE19GguIgx4F3hucsBRwkz3+t/THNTySIpEso X-Google-Smtp-Source: AGHT+IFczxiy5iDLrjExd4sWLgqj+jmwTXz3vp6KC1gAGVJgj7ffAZHmCXULZvblEnwK5hhlvGIp X-Received: by 2002:a05:622a:1911:b0:42d:c742:3664 with SMTP id w17-20020a05622a191100b0042dc7423664mr1133463qtc.26.1707978368503; Wed, 14 Feb 2024 22:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978368; cv=none; d=google.com; s=arc-20160816; b=LcZmQw3rywEy6Y4UlQG6Ov3rxoWhqAe0zdRyZqcnsldDaf2bMAjel8G+q+iyC5bwMx 6m89yKF2ZR+IZ1gUBnzzemQb9uvQ8fd/Gdi4w1hTnDugMbsLVW9YvKGfVJfPOxKhaOsb LeqUfeLWTHsyTZq6a2DYvX1L4lQ9gmtdaIEnxvpe1oso1NlGMOPDB02Bz1senelNUQFj FwHeJVICKcB3+45M0jyTLiu0XAsPj0JvHPATzPCcfnC8ilfPe7SRcBDeJjhNZMAKgDvC mNKMk0PzOE8fkPyOGf94J171EBatTO0tJUr1MznULGd3Wy1x10lnCyh5A1saf+QnLox6 PCSQ== 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=8e59UVGjA+rf7vDiYDlVPV0vb6j37PsuKcjN1UFSiz0=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=lULHjhaFq4Mxt8mUD7fyAB7vVt8l52ZZDgyu37iurpZxUOszyyy5/xnmBxTbo8h//M fqswuigEFmm7hVVqOdcND4Jshq49k1dA/ipkR7RmH6FZ812nchH6HrGAt3TR6MlSLJ/K +0QrNPZCs+mJ+ZVheCTMZpNxqSCkThq3uG+Tl4laecvo7xUwLdbZpGQ1VR9B1c6czXCS b9FoqmXPBCgUuj6YgbUvY5gBcLxWp+BN0Q8guHzfwxEzQ7Z/VVs2SgtfDHUeccjowlqJ +rGa3pNQDGGOhH3EdPC61SOeZV+JLIFN+WdpIBTECIhCFBfUB7arP5eBRvq0OVDLE7jP 0ruQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m6dM743n; 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 v39-20020a05622a18a700b0042c6e8d73dcsi730427qtc.779.2024.02.14.22.26.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:26:08 -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=m6dM743n; 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 1raV75-0002NI-C3; Thu, 15 Feb 2024 01:20:51 -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 1raV6v-0002Jv-28 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:42 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6t-0005Td-G8 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:40 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d8aadc624dso4184415ad.0 for ; Wed, 14 Feb 2024 22:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978038; x=1708582838; 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=8e59UVGjA+rf7vDiYDlVPV0vb6j37PsuKcjN1UFSiz0=; b=m6dM743nvCBONtmpXoTrg98ube4wBIS/1gKtxfx3gVz5jGnSFjMZcvEIX90u6Bi40b NKgfUan9q6KpdckTTYBQiWxy57lFN6i0eSK1gXCuNFSpBwqf8oKEzEmsUa1F2DIghhws cSBN7Vlh1b7GAXIxmu+OZPrC5Ej5wQzYw6B933EYhl7KYxwHezKHXQRrnWe3LKGmCm2l z3b5uGHq8Nk3kArITyPE0bKIKi/qPoy+kELXwgxF8chmc50ldy6KgD7qlMUB4pStrkip uPCF735JclVbccypzr8B0f9GLr/knPKdB55iNph3kTZDBPhDXSe20JfQiYgYrJ4GdcqE MNAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978038; x=1708582838; 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=8e59UVGjA+rf7vDiYDlVPV0vb6j37PsuKcjN1UFSiz0=; b=kj98B+e4kgiaCzZL/H7RlcoQB1WRyIW5cGL69L9uFUfPZvO/f9vjvYB6a2SoOigxo7 vF/2sJsCZ9znI+Bav5N08gSqygvjyR9cq8GXitRfzWAOdn28oWMmE0Z1CLYuZuQvLrZu 3L0zzDwAv8lCKCa9iWSW+d2/IibCukAMcIdrCK7Yab8usI8KLLgFepP+2TK3xjhaUmUT ceh1nYKHtyqHSAqngDMGXYxDcwSwDvgODYGab08+KDeOD0Q29APtjZTk4HdgZkwtunl3 FQYxjWjJy/UgQfF41GfTO94gH34+mCV0Rh7mxNzBFJCTa6Utx6ZGE1Z3qRGILPurfsU+ v97w== X-Gm-Message-State: AOJu0YwewvCyWBucBV1D7AwDkMMjNVleLdbV0m2j2X8GXSVN26qxP18b 0WbL8sc7EjG9cu+0HZwmSu1umzsCwflC27XdH9AfZIDiMFD5Fygx3Pp5Q9RWP12vMEQY2yocmYO 9 X-Received: by 2002:a17:902:c40c:b0:1db:5093:5e23 with SMTP id k12-20020a170902c40c00b001db50935e23mr1026511plk.28.1707978038374; Wed, 14 Feb 2024 22:20:38 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 12/36] hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init Date: Wed, 14 Feb 2024 20:19:54 -1000 Message-Id: <20240215062018.795056-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-13-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:19:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772860 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681438wre; Wed, 14 Feb 2024 22:25:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWzRMiDw0XLoJhf764ZoQbnwK7KVd6Gt51SLN62l52XEz0P+FQgzI0j/l/kZAc5hpRWhRd0hlmsNFg7VoGAdoP9 X-Google-Smtp-Source: AGHT+IGRW6jOPgtuP9UPx7v3fVoJDoYg/Zd89mcjTD+HFyOgoT+g17N1SimRKsUXvUa0CTmoLXnx X-Received: by 2002:ac8:7d81:0:b0:42d:c9e6:4b5a with SMTP id c1-20020ac87d81000000b0042dc9e64b5amr1187424qtd.47.1707978334083; Wed, 14 Feb 2024 22:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978334; cv=none; d=google.com; s=arc-20160816; b=MRnR3WPsdQT9HNzigqUyoOJCjJ13lPqSe5rZNByRT2HE8a0QON27FKo6t7wiAP36w1 9an7oa3uXnB89Scd8s2Lc14BqH/JL0xyLY7ZUMYBfX9G+NQHG09E9o38J+b28u3HoMJ0 haD8GvP7U2fqEl5CD3yxbCgnbKQIPfeTDmKagACmBvghM4m686uQz5j9O2sosMIuxYah S3PP/HkWFjcgRiHUSbEg+KMY0sicHtDa4N9jVvqTGBfb8a06LAGRxnVz2PyJx9alFfSQ 5iW9zHEHVcZPe1Ovess1u9ilkyk94Di5PtJuG83q/6GTHUdAgNMH/mXFbGyfTTCw86a1 KdSQ== 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=wG9KSOs67vbPNFTw70Lf+VF+Rn5tDSL+goWS2BCj7Lk=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=OWONHlU35SDK/onj3FZw608rXhuB/x1C4b9VQRgtaG5DvL2rSSsBmB7KpUG3Rcjdhp wFqYmYvCYmPAXARH9it7mQSQ4eYrBGxPtK1/o9NhKtQY236YO5Fy9qsw1BN/abUED9gu m7laCplRjbw6Qp/dhgE5AbeqvGFd6CC93agAoi14ShxxxUUAkOD00uMJMTdAKo7hZkeo csW+Tz/rPPuh19aJGAPP1wCRCv0td+ILVetvPvAuzbbxfejcrtLbMYW7u56mPniQyKSy qThKHjtOw1hliOBLUKttRlfgD8W9wdhQNmF118zDcADslvhqVt7R66WGDqbTu105lb63 NYmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kXTSRTuI; 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 j11-20020ac874cb000000b0042c64b00ef3si688554qtr.127.2024.02.14.22.25.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:34 -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=kXTSRTuI; 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 1raV73-0002MJ-T1; Thu, 15 Feb 2024 01:20:49 -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 1raV6w-0002KC-PK for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:43 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6v-0005U5-7d for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:42 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d93edfa76dso4049215ad.1 for ; Wed, 14 Feb 2024 22:20:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978040; x=1708582840; 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=wG9KSOs67vbPNFTw70Lf+VF+Rn5tDSL+goWS2BCj7Lk=; b=kXTSRTuI6o2qStHv1sX7oBbUcD3km1U2ZKlxRiJXf+TJ7o28pZ9Sg0OT1+poWJH6I4 ZvwBVYE2LtO3SDU+C5EmaMsXjsD9BONrylWEp65XdLoaM+CP8hm3zj0bWCr7YF3OEiwk 2cmEazCVd9VDhuwk52/hV2kfe6l7Ds5U6GFMRm0NHJnlJQgZtnu2r9E9VpkLE4XYMB1K Qx5w9aNl2M2dsraGoPtRB9Tn7z20W69yAmwrAsKnilYd9KDBuVOVbJBomC2z6Jkm0Yk6 JE7rQSvarkiMmXAXFeC41VmKVZKJkBv/Plrloy/dbiOPx1pDsojHxhVrEOK3Q/BzBjqU IE7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978040; x=1708582840; 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=wG9KSOs67vbPNFTw70Lf+VF+Rn5tDSL+goWS2BCj7Lk=; b=E++tJJCE5u3wrKxmqLXiAThuLfVyWZjrGdzJv/bLdQtUv2FuOvOJm9MsSJUsrFj/Ts dHn42Lt+z0uYymaGDTrv9raj+zLN1BaMeYMjvl8r7t7Gc2QjoDrYmSVF+Eox3Mlrhqai AmP97wmDYUDm8U0g0tjHUEd4ddRk+ok1Dt+wbyo4Aa6wqzGSZESPmc9VET/XWbK84A8R HRGpgbjOF44BAQXcvhYxIEZAF/6WaEZtwXgfGThpZulOcVh5WZbAY4w8+gnLK7BOYx9/ 7GmNpQgWiSj913dNOxgSpHmPLC/SfWDMJdieXF2+6MKVlJlTiAmMAvD44Da+fjUWjPtf AfZg== X-Gm-Message-State: AOJu0Yy2L63zNWBnL8B3WwRuxKC4NjHVrC2AoQDwmBKvACpq9wdrsHMW DuIsHBHeUmm+tGpFaPQytzUgF2Zd+PipA24/h8ZpMRiRgYjYiot0SqknxwnJFHesEkWYOQAhH+P E X-Received: by 2002:a17:903:183:b0:1db:6a20:24ca with SMTP id z3-20020a170903018300b001db6a2024camr1062036plg.5.1707978039823; Wed, 14 Feb 2024 22:20:39 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 13/36] softmmu/physmem: Remove qemu_host_page_size Date: Wed, 14 Feb 2024 20:19:55 -1000 Message-Id: <20240215062018.795056-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-14-richard.henderson@linaro.org> --- system/physmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/physmem.c b/system/physmem.c index 5e66d9ae36..508dcb7494 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3515,7 +3515,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 Thu Feb 15 06:19: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: 772867 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681530wre; Wed, 14 Feb 2024 22:25:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUqZAot0jhSid/sZPhbGiLFz/DGzCujXpuSGPk88hbVBo4QmTImaWg6VJzdmqIGqMKZqVRvCwq978YdcRe/N/1g X-Google-Smtp-Source: AGHT+IFS76gvQyDILCH954uXSCB4yFQF5OBSWs4FQrHp2yr9mzPa7WtX25DkhlTeITy1UZC3Mhu4 X-Received: by 2002:ac8:5acd:0:b0:42c:7ea2:42e5 with SMTP id d13-20020ac85acd000000b0042c7ea242e5mr1092143qtd.4.1707978358686; Wed, 14 Feb 2024 22:25:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978358; cv=none; d=google.com; s=arc-20160816; b=KhCT+AcCKSgli8apoVm4Y25V62KeqJmMeg2UrV1pT4pEb1NHMQr82QyjrolUEEukqd xSjYcCpC3sdp1PzFfIrk7Fl09hvUfU4VHkg0mNv4wXQTRfNb2I9xS5I24pmaawU8sgAB v2pgVLUj2fwYRM7Eum6THWBv9eFDRtiOiAZ4Q4MXR6mexR0rAyBS7CP6RPMHykfDeGrS TIXix0nTDyeXC2L+UaZlgvIxX38YGrrHpQBAiuNYg7V/ovbisfYkUEzJ11FAFLULJMx2 KAC//tOt/qU2GC7g/SC2fzAY522nEtCrV1+sIDhHO0xzyJ2YlqROk+3xG48X8Bx/OajP rJlw== 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=xf7vdSAvh/ZeTBRvXJBUTE4ih7Lx/NEC7LNkf984wzI=; fh=v7v6q89OJlq+NxHejbJ/ziw7VE+fSww09twjGPM2dQM=; b=wKNDP8KbQWo/m1nbtBTaa7OJTgB0egBIOPujWXpmYWFhU28HqvPyHAWocggAWFrIhv 7G6+J875yz9ZqMf15yJlBPFXHuluJEZv88dwmNd0M2kzPFSJlEAdCO1p4jKHPejzSx+7 kzYXxyUVzt3s0RblItG0Uaq3iTX5HYlRCYE8YB+RfbsZKxuou/zY8peAk3KOsHKwMLNe 5LWuYvGHKuLp57lyisyRrnSQlEBgd/WBOQJbqQjE/gjsX4ejvKsFayfrR4BwxN0nNPqz HeO4Ydent4X8RNSh6tue7PyF/PGvmIT6Zt6KO9RkyZejSmN717xZ2e6n4GwXOS+hpREM Ciwg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="b5/s+50j"; 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 s3-20020ac87583000000b0042db23b5002si670719qtq.348.2024.02.14.22.25.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25: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="b5/s+50j"; 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 1raV75-0002NH-7n; Thu, 15 Feb 2024 01:20:51 -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 1raV6x-0002KX-VU for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:44 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6w-0005UT-CK for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:43 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1db5212e2f6so3915055ad.1 for ; Wed, 14 Feb 2024 22:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978041; x=1708582841; 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=xf7vdSAvh/ZeTBRvXJBUTE4ih7Lx/NEC7LNkf984wzI=; b=b5/s+50jnCvU47HaumMDOWrixy55mYqUwuR/6/oF8ZQh98ljwurwbGyaUJpWEeBiQI zJezHEtpBOsPxXYxLtr+vX4OOvMok2YfDATUmCLrdm0OBK4frbaQlykTQuBlRjWSweu2 9ZR3U82t7EJkjTadc+hfBFjOr9b+20MMPwMTqQ3HROvo8MYClsIZVFOaIKYFUCQiE4CI yPKJ7JMENxmklh6Hm5IhJaypXHHMMPphmCWGx58g5DP4+QrrsUruxOkOB1nFOgpYm/bn c26MCpjMBQ0wX3NAKttexun9VrCuldaixBOYQ9l8tttNS1Fyn8TcXTAzqyNehQFaV4yU JqBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978041; x=1708582841; 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=xf7vdSAvh/ZeTBRvXJBUTE4ih7Lx/NEC7LNkf984wzI=; b=NQB30TGLvCnykAgZOXOpmMrURX03AFVn0M2KfIdbH/J9t1Bv1EPp3ebvOnj+ZW+59H wj3Csa55aycXYbpj5KSXIachBABKlY/RXywxWNiK/0gWCoE4+AsXHFW2JrxnnB+KgC0G nccYHmT4LXQNlxj26HGgfPl7wua7/tjy3N3B606kIXjeAR6Lyk+FkN+t1ZBtlGqmeOxA Iqu8EXhumNFOksD5lX33MkkDTPIEn6tXYq86amRHeILJ+74PPcVzloSJ2WlB2qZMLWJZ 0bbO/OWC5U4XIhB4c3ZDN7vIk37bUguh7fKRiBn2TrXgJWFAAH5p9h9Q1IUaPG2GBg8c c4gA== X-Gm-Message-State: AOJu0Yx8XCyOQrIo991lrBuLB+es6dG/cgo1gLuktYXNVSPxXMb5Q8T6 HNHJWiCySRqQOn6GGsHBRzeIP1k0xyg2Q9lnwMwUXDMrJTExKxguaSbF+0kfUKkSd4Sw2x7ZK+u G X-Received: by 2002:a17:902:d2d2:b0:1da:2128:eb3b with SMTP id n18-20020a170902d2d200b001da2128eb3bmr6822345plc.28.1707978041161; Wed, 14 Feb 2024 22:20:41 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 14/36] softmmu/physmem: Remove HOST_PAGE_ALIGN Date: Wed, 14 Feb 2024 20:19:56 -1000 Message-Id: <20240215062018.795056-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-15-richard.henderson@linaro.org> --- system/physmem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 508dcb7494..6b7c5747da 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 Thu Feb 15 06:19:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772843 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680409wre; Wed, 14 Feb 2024 22:21:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXmvgZiKwnewIjng6GAjJO7v/MuuPjsSR0DsNKzLh6CRQUehT+SIbQknm1GdyhWwAHDXI8L+3zqoqa+03Ng4XPF X-Google-Smtp-Source: AGHT+IE1yvUO5M+GN2GX+OU4ARp7Sm8VvHF+TsxlqUpDQX14AYYZSZnKasRjICPIDdlLrCAvZ2Si X-Received: by 2002:ac8:7d81:0:b0:42d:c9e6:4b5a with SMTP id c1-20020ac87d81000000b0042dc9e64b5amr1181351qtd.47.1707978106438; Wed, 14 Feb 2024 22:21:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978106; cv=none; d=google.com; s=arc-20160816; b=wyH2ucL8vu1JO+d3EHuH4HipYHzIbiE2hwzoHwzDGizBYmTZ77/PLzDbh0/VvPRw68 PJuFd1RB4PmqbwEwMARIsZzqOfmS+FbeDNb/xZJsiEl2KQBuSl4EeWuFhaiZVnXWbqQa 5tE5v9AEYC65/6/oCotWy1BPxDO2QlgMizcugZHujPnJKr/jY+cHA7u4un5DDuxSl8Ys 9OUCa8wgocDHcmPt8tZVSRRs+8ZI8U1xMJFw87jLLMRK6VebNhzVORf9xqybuHt5i3CX 1dm4NZVSJ5FUICyNr1wyB/UIMO6LIJeqODHBKKkDumIMPZNPNWwaabjBgQg/xTZawH1A br5g== 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=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=M3cN2VPGB/2rYbIZM7HXz+zwGoj9NbZoDgit3eNIwMeJFaJJCW0x0gS+zlGqvDmtCD v1j06wdzSyoVpRGGbwPNBZS/gl7zayCE0ntUT5vwGJawn0W7uaglM8GL4n0pJ9/1HUHO zaEbmYLUfZEkQT/UcCOQQfc+lYHGMnfcRAMUQPfkrJ40hDWqzwdEt6u87Q6CPDpZACj8 W/pyj1TohpHxrLCSqiGyG8mB/RbevniT3wn4q68Hp5M6MoTJ21wabV9rDPuVvGmOr+up WXvEWBIXMStQp8FwfoIt636bN+JkDTpNgUMD5VRCIl7aOPooeM+WqWVVxT6PgGpMLa7s CKqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b6PaTaZm; 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 i18-20020ac871d2000000b0042dac61b365si698634qtp.212.2024.02.14.22.21.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:21:46 -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=b6PaTaZm; 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 1raV76-0002Nd-So; Thu, 15 Feb 2024 01:20:52 -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 1raV6z-0002L7-Ay for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:45 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6x-0005Uy-N3 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:45 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d93edfa76dso4049355ad.1 for ; Wed, 14 Feb 2024 22:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978042; x=1708582842; 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=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; b=b6PaTaZmEC5BKo0TzRJqcR8Cp5VsAbyS39upUhfg2IimeDdId6ntz1ONy+W1OVqAvW 3gzaurdQmMLKMf6tMPIoOktjX7rYtWSqngNSY0kVAZA/xgo6ufJ9RZOj1FcuVzF9i1Rl 0GSPo68/qUGiawA3VcgOE4sZc+vFWAM55qFX4E2CDaJJp0ObEeO7Jy6UW3kGiZMzAc8e hua+R/A7Ilu7HGjRHokL5PuUtkclONNp/0JMV7I0sCebwzFhcauVtgDIXw1coRGaHSOt fea6B+qUT1cuv8iRTHTszmGcIJCotkAiPzi9r1h4QafFR7VA8IZykOV7De1QKeni9un8 JUGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978042; x=1708582842; 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=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; b=urk8PXqZzKAygUPbyDKYkiXuxU0cpMQKFItCo+AHeWQiBh8P0nVAtknDFlpUm7i1M7 iDWLEQ8fpzYanItaEzRgV2xvRsDNGelRPf0ZSeFwccMqQUVXhrmHKlkDPkOBES4+bv3M 5fG5omYsal2KFntuS15Jqyp+LKu3xXWu59AXRZnuHbAjsYFNzrQyCG9oWAU5ChfOBAFa +OFOFYfFwibZIEA8CvnwMW+3GI5Q/HN/DG9g1oHGtjAmk10j55wjx/cb7R/RUep6kmDg /CVGlbwvr8gg9K2tuRI8siNo1ZYzHDtGkK3oPknGF3FkDXr4fce+nk/veSKCiMKRantL xXaQ== X-Gm-Message-State: AOJu0YwDVFh1qDe6msU13dGubEqBlMK/pT5mNxnpQQxuLsqQO6taLky6 KWlFX+IXCllgeT5FQx1isR6bhvqRhWBtoDgCVaiOrY0uEdXPgQMcokJqqPS5lrfZcfE8p7Vf1Fl T X-Received: by 2002:a17:902:6502:b0:1db:65a3:e17f with SMTP id b2-20020a170902650200b001db65a3e17fmr698708plk.6.1707978042587; Wed, 14 Feb 2024 22:20:42 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 15/36] linux-user: Remove qemu_host_page_size from main Date: Wed, 14 Feb 2024 20:19:57 -1000 Message-Id: <20240215062018.795056-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-16-richard.henderson@linaro.org> --- 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 74b2fbb393..e540acb84a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -781,7 +781,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); @@ -804,8 +804,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); @@ -902,7 +904,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 Thu Feb 15 06:19:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772864 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681469wre; Wed, 14 Feb 2024 22:25:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXhN4obljvM8b66/OE/wL0jZ5oiZwFzb5POKvEOSB1repHLNNBG2qJ8gYvWTwRJqGI1psKGrKE5FKvN5oZkVwf1 X-Google-Smtp-Source: AGHT+IE9BwvjrRDoMw8NtY2ZrYnYnjRRz9oQVtVFELuIdZ9iwvRrjOgb0IL+7E+RTRS+XaNQuofw X-Received: by 2002:a81:b71b:0:b0:604:3ee2:f258 with SMTP id v27-20020a81b71b000000b006043ee2f258mr860913ywh.45.1707978345504; Wed, 14 Feb 2024 22:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978345; cv=none; d=google.com; s=arc-20160816; b=e5FTZRm1GiZsHJbB6GrgBs6/9C+UXia3s21xf5wF9pYuxHnkjfjIuhjq19TGf63GNd Hu+BETbr/pAHEtA5UHuZ9Oalrt2ku7NRJL37dIDhp8a2iSfY+Ar3AgFRwlSa+fWNJ6Bl DhCaAepNAvF5lBAhcO5BJBmbg6WBK6mzGr+XflQH8bgVAWPrCshaNZECkSdUkoFcwGdy e9g8yNO1TviiBQhumQmDGvkGjNnWdXkLTkv2U0QHJ4iLKXfAbC08qECgVaf0PB0UPonD PRgbC8rGC7kXDTWwfEzON0NAWV5bwhYf3gJmAo3m4UTGJij8RLWeCEm1RlM+o1Xt9BPv avKA== 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=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; fh=3DhLlFzAZ2wDtINCbhCKz6cI2CK+co2YCXCK+aMgx2I=; b=k5rzmOO4WL2TT6z2gdJRASycWW+/QwSs+PDMI2pReCGqjZ/rea7usxQMXBFQ0mjlmM dfnyLAXwus5a4CDN8NV8WGyT1e1LrDJLh3dItJOJefk/V+UUEpx4qls/HAY7y3EnM2kK nlynKtaSRVgpYokhUE6y5on9b0BP84t3U40wRjCt3PLzKiCV+iLq91abUij1DwIUT7SO go/lrs54tpz/dmHmV07xsaEh8E21FeelR9XAkLOsWSXkDBvOY7FCRItqGfcvnE7LJdmw XtXipeVUwUmH/a+6SmmdFI8wrteCkwLgY8y9dr5Mq03dSK9W2/ETE9PPtvXhenca5L4V UMdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hMX3/dye"; 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 t15-20020ac8588f000000b0042c7f5297fasi747381qta.215.2024.02.14.22.25.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:45 -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="hMX3/dye"; 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 1raV78-0002OK-25; Thu, 15 Feb 2024 01:20:54 -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 1raV71-0002LP-KO for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:47 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6z-0005VQ-M2 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:47 -0500 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5cddc5455aeso411631a12.1 for ; Wed, 14 Feb 2024 22:20:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978044; x=1708582844; 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=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; b=hMX3/dye6Y3L1T1eAPoMuzPYU25ae4CvShnW2sBb1A99JSfxkzdqbqj7Eeeo1dm0yr SxGgxpoBIJKYNNZMK3Y7yYSOScwEneTuUHdokco+PpCAP538rC02O81ZTTMZm8ABUAdt KWc7xz87Moz7T7Djefvw3meWfkF8ouLDe2H1BpFNy3/J5sRVqYSHE4aqxBHKAaZYLjuM PULxN33iivAgbrw8IxIPqw017lIuf/b5iNdOypgi4EPK2TCMdDdxQUj/kMYNQCt6Q1wJ UqkyaUcOXdUn+8A90nxDR6qdKh6BVMUTJpPHb2JXbwfx9FXR9GkGt51RRN0b2c+PDbIt B5Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978044; x=1708582844; 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=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; b=SPXXMkqPrITOxv+lYGohi4RgIrXhqVr5x6cm50wBL8ZSx/OhdKj+1443PODDzG8ykT YBj/3poWAniEDWlvi38epfOFMF/KW6ysx3UK3/ATUdn4uuysTJLCu9arHr8XCl7DaVuq sM5dC94BbjogQD0/RdR0Ss/B9kRVb2L18GsTQTNKyRq7fsldoqPWvh0SwrIEuMaPjBfm 5lJVHvL/UWbm40LYZ6Icw3tZFNYcBL6cXNSqVos6chGJfXQc2hQH9tOZdOsWrUoMJsIr EqFx+WtsU3VqE451den0oirC6T8YrHDRVfmQgrLkL0nQJI91DmArmu88S7CdNVkjucVS YcfQ== X-Gm-Message-State: AOJu0Yx4LoIx6IuarlpxWhbbuwjw/WP2gsNPDVtiRKEF8m1HThT4YDK6 ZL6jyZywdWZC/wGrAxof51XBZJlTRTfLWixCM+mIW3ZFX1vwffxKayDDbxXF7mcrXFxdCrfcba7 x X-Received: by 2002:a17:90a:dd41:b0:296:6a37:c528 with SMTP id u1-20020a17090add4100b002966a37c528mr789257pjv.24.1707978044222; Wed, 14 Feb 2024 22:20:44 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 16/36] linux-user: Split out target_mmap__locked Date: Wed, 14 Feb 2024 20:19:58 -1000 Message-Id: <20240215062018.795056-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-17-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:19:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772865 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681488wre; Wed, 14 Feb 2024 22:25:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUj8Q/ULNH2falu+qRmARAJ3kRvXbYcl0LfbduwKfFCC5O4VjkzCJDp5gc1gnODDwz3X1acH6BM2YWwjOvMefzs X-Google-Smtp-Source: AGHT+IEeJW1nTOnbI3hxY72EfED7qkqn19nVV9tFnxK+GdZjSpoVK6+6xBl4n8wyvCv3dWlMI6Nu X-Received: by 2002:a05:6214:4104:b0:68d:1220:2e42 with SMTP id kc4-20020a056214410400b0068d12202e42mr1039998qvb.62.1707978349761; Wed, 14 Feb 2024 22:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978349; cv=none; d=google.com; s=arc-20160816; b=xL/dV2CS9S3tuGo5QsLOn+t4YNayE3ZFTYjiOMg4MfWnUXfGnhOFUOLYZ1oDAV9fIs buwYHNSBY5PV/QwoODwuF00w4tx1a176OfUf/+Ru29Qw1ZJj+IMC0uRGZyT+XBeJKg+Y 7bPds8JVkmF+eXdFOEUpG2urINV8KeZmifonxdFigovt4A8pcd9oLtBXp9rJtD7xF9m0 Qs86r1m34Ni1rYeeYySMuZ2AblYOlTz+BR2VOHCZgu7JqhWfDeKuNfB/avRIkGi+z9Y2 z3NVFxrhx1jdbCrb1xE5O4xG2J7v+3y+pG07ISLk7uCmEwfdFiKiHSw98Qn7VP3t0f+W oLCQ== 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=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=LBD2JDW8zzdV9p+hlmZfZ0AEE5wXu4wrdqVyoUrEhayqR7Tqalb66aHjKQt+nfbM8i knj3jqK8KFrGKAj73UAOZDIZ+26kN4yIDbcoXqh2Udtl2wlkNKZdB9XSINfK6U1Sv1OQ swCORhHwJNfwTjObjPkSS4W3eyT8s4JSPeoAFwDyC8e+tztXjYU886/KINfgOKJV5Alu wnYQO+qTciNLU638umaFROmRaTIJLm2n7CbmVlZa/t+0xAc4AXQq6qr8t5dzGAOg/3xr JsKgtBcdvbjEMnqKjT2+Ds8ys6LsDJOEzg3zZ/UQluMj6OjZn8SsqBc0F2Z4yB6K9ih8 HGUw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nKHdF8kE; 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 ed11-20020ad44eab000000b0068f13883818si760990qvb.279.2024.02.14.22.25.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:49 -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=nKHdF8kE; 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 1raV77-0002Nm-GD; Thu, 15 Feb 2024 01:20: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 1raV73-0002MV-TC for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:49 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV72-0005Vk-0K for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:49 -0500 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so450889a12.0 for ; Wed, 14 Feb 2024 22:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978045; x=1708582845; 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=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; b=nKHdF8kErZf2byCR7DRDfZpbofKhm30+gsI8hj4nUR3fzHMKx2NysXuoDpGfzqJOT/ jrUCVHxTJIAQRYVrHgAFHqRgCAEnjzk2vmPTTGbOCcKcUk3OUPa+Lk+LG5LBhrWksnqN 2rNzD+bbaY5hsaQkiSMAGgCTpwCOkwF4FQ1HldOxZKp7lfNFKJvHr0cBvfZGa3jiqR78 aK4OcWPGN+3g6VuAnzBwYyF59qS0sTKH/CINuJSvUxHIF5XkH+KN+3A2qO8t7kuJ3H7K 8D6jqf8eg6vA9G9Y/eB8qtMx7xE73CadVeW8JmNz528ZcU0Jh2ZpO91jEnqp9EnapS5M 1nAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978045; x=1708582845; 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=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; b=kmog/E9os/wqap/S406U2Gal8Z/yQLNUgj/1f2gbN+bstqPzhEdV4vafT68YhiEFRD knR3TKRsUUGK6OtdyxTRg8i0qyX2ncoL9uS34O5teHDsiiK5d9qK6/eUESPonlx6cboj rDEtMz3pHIfKq/bNv3jH8dVvzc8XqBUoEoo8UrbKjEfpBpm3VAf/m1z6XzQs9QDhRCaH LRlRHzOhadUQctaGNyFSak6HqkMsR/jACslzU9vcti1/g2cdS4bVA+ASjJMXQmb3ebRl Bd57ZqJDO+NBdy/wLsSkTpHe00aD6ikIeXzAuWeFga+M281e3xNqUqVQsMV2YNMsWzxy SzfA== X-Gm-Message-State: AOJu0YyoB1JodZJqah+cu/JhnRB/XoxYXr+UDU1iVThrJVaOyHTYZIwL WRg6X4NbIzqYlN4zWOGqMZjZ0HrX5Ws/nEfanUp1PUnsl03kTGzJZBYjgyZm/qcLNg/QKht0PWV n X-Received: by 2002:a05:6a20:6683:b0:19d:9089:9ca6 with SMTP id o3-20020a056a20668300b0019d90899ca6mr924655pzh.32.1707978045675; Wed, 14 Feb 2024 22:20:45 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 17/36] linux-user: Move some mmap checks outside the lock Date: Wed, 14 Feb 2024 20:19:59 -1000 Message-Id: <20240215062018.795056-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-18-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:20:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772839 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680299wre; Wed, 14 Feb 2024 22:21:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXC76VcK6vddxD011VMCi+vcqCziU0VhJoXwMC/x4rHzX7KDnofEeTbq+RVWbX9iINxI431C3gg3Q89CWMdGFKT X-Google-Smtp-Source: AGHT+IHGEJiT994gqeqPRbch151nXAeNj3f8wECrh4xgLuZym2cE3i3Dn0+euqxwgyLmwWBmtDm3 X-Received: by 2002:a0d:d842:0:b0:607:ce8f:ec84 with SMTP id a63-20020a0dd842000000b00607ce8fec84mr995643ywe.2.1707978084563; Wed, 14 Feb 2024 22:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978084; cv=none; d=google.com; s=arc-20160816; b=FsfpVgS6aW0HEzRAxDAHMEdJOd38GHk27VuMCsJjlS0Sq21e9U78sDKRD4tVaCfGht 0mNbldonSDuZfPUsRmx5/376AZPVqKnnJgHTs3PlCDteaivjkHge43EdiylN1ZUS052d 6YHuajDRVi4SHFfK7JLBprPoqWNG8fDz79X0WTZ0/DjmLbrjNb91XZ3pvBZaQsiFSbAV U9bFxItqVRdqnvnhHusE4lRHTTnfvmCPqPVqexk7studvMiXi2nagouKwNbw+8L7vJF5 CmMJe8maffdLCwKpScmQxVIhs0vp4lNfMEG/FvpLj13gti4R/+QAN/fbabv9jJN0gKpn MmyQ== 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=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=RKogqgrox/d/m4utigvAhNs7KspmyzA0eVneEV8Hl9SxDsiesYlFI32MGpkupE/A94 JDg7Vc9O9k5Os9DNH3M7MK/8dck864KG9gxM8/kzhTveKmxMz6nyYCylkzyR1lV6UA6r ReOf96b+YjffrdNYNekjoQGlDMm/vq1XS8M38KzkM+Ffv6p6ryPunoWul+5xrdXRgErl er591nRljNsAyIU05GBljyW68pZl6vdlzsvRqxwezKSavutz6/9jElCb07Ayf5Gd6ftN 3R7VOjfjKOpBj09LCMuGMC8H5DTJ5hJDOmls4iaLc4nTGlph1CPaJLHLjVFw31VPz5Ld Bnaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pIQjbg2c; 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 t21-20020ac87615000000b0042c4b0cc3afsi652816qtq.642.2024.02.14.22.21.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:21: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=pIQjbg2c; 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 1raV76-0002Nc-Sc; Thu, 15 Feb 2024 01:20:52 -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 1raV74-0002Mt-76 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:50 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV72-0005W8-G4 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:49 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d8aadc624dso4185245ad.0 for ; Wed, 14 Feb 2024 22:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978047; x=1708582847; 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=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; b=pIQjbg2ctySqn2luCY29UoF3D7Eo0f3GZnKh47ONb5ajptfCAX7GADqWJcT+nFbldb 0crTD6fhIFkzDJZA9mwS8se2u1WpMVBtf+fTmjUyk9ymF1zXm3l+neUZvKH9J6BKVSqr OP0K0Js++tKj5zyDokjBgbfFmSDezIJjQ28n29guvxLTZn90ZOTkBABGM0K4qbGX9TF3 UMtwZjagFinRnYP9cl8YclzysmXN+DrusY+dpm8PV6LCUjdZMaL4rWG4rH1n7aXunYXy 6aSIU0i4R1VmCY7h/B2TNxjxHRM7LdjE4bLuzn6loHwvZVf6elMi/C3+1qohCpvdErLM fEzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978047; x=1708582847; 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=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; b=bSZreLYcJM8gcaSfZPApJVS3Cd+2Wxjm6KUMmjkIRiPze5Rg14/F3jkflf3c1ii+sb UzLB7tIReJmKOZWeqxAmSn8vgcYQZmlWA/sHAeW8WPbDrmvWuXEUtuiKjQKoQBaZhjyE rfjWhdauJHUC168E0IYP3dAA9cfe9pHDOlwYWyRAekQpEVwesszI60JNC58vu0ISKHek tJA583lBZAizcauWlPDY4qQqa0+qinKa7uy234OdGLvRNoLkVog3O3u5BWZcLpsJRaEa 1UfNF7E6O/1EP+4b0lT0Yr8aonD7n7Ss06z5aBOBVpij67NZGMVItKrB5myx5WW73W4C gZ2w== X-Gm-Message-State: AOJu0YwH8fUNNmWFBaOV6Oqpt0umoQGFbET0kJerO6r9wpYTmN/0PMmI UQqm1MKFnNvKZifPWlSB9xel+OW5qEELdE5KZvSwdWuKOQ+7YvIwWm6P53q3FneYo6HAL6SRIt+ V X-Received: by 2002:a17:902:d2c9:b0:1da:2a2c:90da with SMTP id n9-20020a170902d2c900b001da2a2c90damr894717plc.12.1707978047312; Wed, 14 Feb 2024 22:20:47 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 18/36] linux-user: Fix sub-host-page mmap Date: Wed, 14 Feb 2024 20:20:00 -1000 Message-Id: <20240215062018.795056-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-19-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:20: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: 772866 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681527wre; Wed, 14 Feb 2024 22:25:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXtpJjqGlDXQ2lHwbZEiaIG9cEQnSP96ddHKxhCm68EzpXJYegQx5zmPRUSYpBAa5i18UMNb78aF4NmEwK/Kb6G X-Google-Smtp-Source: AGHT+IGMWzPfw56MIpgqG8aSKVOAC7nzc1y3GT/akLTrvo90PElwkbhOQvr6QnW+j7vwWejZtfe4 X-Received: by 2002:a0d:d88b:0:b0:607:9d64:d68e with SMTP id a133-20020a0dd88b000000b006079d64d68emr852097ywe.26.1707978357959; Wed, 14 Feb 2024 22:25:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978357; cv=none; d=google.com; s=arc-20160816; b=AIyqhsKqTHag/zmNViQx+XL6lMi5xzMfukgPlVokeFkuJKsYJ0tquh8PAKkCweevFu bkhwE+Qodiw9hiq39bl+VwYF4ShdgBZG8E5NxoEsoC+vQHb/Wk7TmgXOxHyiVRkPMIxI WNUnE4NMI/fOI+TtxuDhmMweOiM73EIPqAitvYTdp5Ew7Tn41v9oFWb4Gp1VdlBwksvY aTqlDyJsPPH8go808V93Xp3jvnU1kc9TUS8SzqDTztjua4wJR6exjoW3mIurGXPIxpVX Ui9t+WeEXjaiU6huNOoin+tVC+BWAs3KkUNHCNDSsENon7lTHDY8xU1n2TBekkHSFhpp OBsw== 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=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=yapMB/ZWC6aHy9rOfD9su36/HH2Q1vcr8WLaPyQxAcV/5xLt0YbxOarc35aW/TbR1O eDm9KRZf+1ZX3Q+exBfqAswXPdlOeaRo/5GNM09zAoqvlZZO1icwpE+wKbovPDZjZT9U kjU4On0znmy+C1Zp3M31+r9gbmE8/ud+3sWbqywb+003jVBFpVO+XN2GONunyWJqc834 hnTkDoV2VADzX558Lx4K7nu4SR4xwTzYwbJbTNCKH1PO8O2DwGH4nBVoMOK/vcyKc33q MMsvRrbsxKe4/SPCynwXzplhyY8vIe7EJcf4gUTxO9Hpkqwc672xj6GR5IcFIg/iQnAN AwNg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YLx2hBbN; 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 a2-20020a05622a02c200b0042c4b0882dbsi734669qtx.701.2024.02.14.22.25.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:57 -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=YLx2hBbN; 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 1raV78-0002Oa-7p; Thu, 15 Feb 2024 01:20:54 -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 1raV75-0002NK-W5 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:52 -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 1raV74-0005WV-0o for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:51 -0500 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so472684a12.1 for ; Wed, 14 Feb 2024 22:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978049; x=1708582849; 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=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; b=YLx2hBbNTAcc2lkKvVj7S/7psvZupK5l5Idvj8nUz1B6eK6uS3jg33zMykD9YxPIlS O7RWo69eldz6OBG0A+/8/U1Me9lOxVe7ehFNnK/I8tATvIkAVfjJKJVW0zBE4IvqWoE8 fFrz8objzloX6GHOQF13dK9UCh/kPiBGPCCKHdS360X9+9pAdaoRAl6H42NDCZsapk5y 6qjTIqD76VyjEnCkVdrn+RIk7YYUNV0VW60+grOgL3uVgUp08icXnIi/I9wFF5g4dGak aeheE6zLB0vWefsLY3EQHgIxOmFTlOD5/aS7mmMrkv/uz1R+GehIKVhQFsV+NUR59kSO dW7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978049; x=1708582849; 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=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; b=ZZaEFlPgDcscVFOpJ/46zdSxJHdmFj1+mR/S0YKkYGKVFhjAKlZz+uDYUPAqCDx4F6 9UfXQnoI6A3fIpf7a5V0NrAbyyaRms/WU2tOggsz9FJMvztiu+SEwIm/501oYctNBuJ4 TjIKaWTNwAAwoZNl0azxhQNAQDTZo1C2LvRm4473l9w7aFJfL87MHaHvBHD7YYxn/EvM DHcRFR7GGMC9/fLFODKTSd/Cv8ZAjWfBz0sZAAZYwuXBafS4qCoF5oIoFthpiF2lUHt4 Mr8JRo3CM+zdx3p8KGN8FTIE+oznlDu59K4IZeuSnjxhzwq2yoQtokkF2vS8x5dfsOaw H3DA== X-Gm-Message-State: AOJu0YyifhHRhWgmNRT1UYwjbx2c3of8WQOJFb17n7HVYqQMqZ68+nI9 G0+AK0eWT0m66eBHDazhlv4WCvqeI0VXoiFDRSoeaa0UOwyQgrgeh8Ij1ltLgvlLb4uGmVKvZ9n c X-Received: by 2002:a17:90a:d301:b0:296:2afe:25e with SMTP id p1-20020a17090ad30100b002962afe025emr892906pju.32.1707978048754; Wed, 14 Feb 2024 22:20:48 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 19/36] linux-user: Split out mmap_end Date: Wed, 14 Feb 2024 20:20:01 -1000 Message-Id: <20240215062018.795056-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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 a subroutine instead of a goto within target_mmap__locked. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-20-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:20:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772840 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680322wre; Wed, 14 Feb 2024 22:21:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXUiC4YHv1OV0qM5sjQkaLQVYHr5tNZtuSD+qYn65fjO7+dqIOX4Hz1a4DaMBOi+V+I9gwdo8g3BbkcCqCfdhsb X-Google-Smtp-Source: AGHT+IHVsIjNZwwg0L2jUXnqhiRnGwbs+cnuIeEx/o/aIvZB5jrZCxD30V+ZwKysHbtCbTI2xW7q X-Received: by 2002:a05:620a:112f:b0:787:1660:b927 with SMTP id p15-20020a05620a112f00b007871660b927mr819432qkk.53.1707978090590; Wed, 14 Feb 2024 22:21:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978090; cv=none; d=google.com; s=arc-20160816; b=ArHOarm4LCl4r1CiQkSFDlljN/Fw16v9mIhbwqmVqZQNH6NBwez/2IBEWNUL3ZWsl5 393MVO8zkmRNVbX4mR3kIyRl/GCiiSdh/r0G1TBWnbQcS+TWZlQKlqUnbVYJCYJZ2cZn 8ECWNe++4Vka30IPEnEIWsM5sj0Hmx0JZ8WTmFh95k4DImHTM5PGjD/zUbmz//xvqmap VG4EsA8vqYzyFea8CEDQOKDbvDRuO1J8Tqqi3A5oKq0EcAuzk7nG915vDcTupTzwQNAO B6ypPuAUfmepsd2WYFrGlKVIwSiOalB9y0Zvz/gDAGi1UmQPKFKoZlC0rFpxbFGE4kF5 uaoQ== 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=dkfZSmxPTGWihMRCcBHtXFfNWyQBsqDDkSJNQnurwT+rxudB0OQhSpRPnh/rWQM7+c amR1PYY0owuEknGV1Cas0cDC/YbiFBylz7/JNHqW8KrOgDZLg52DupPwe62/P3DuJFNB +p2yeIakeitV01CYF6Qjx1r3ljeZw/n1/5bAJLJHEiVdamZ7k2/NPtkPFbXuumO3Mo6u 6fNqEj4ESPrTkzbtZqQVwki2v9JQLjcS4r00+Z9TitpdLGJZVsPZMaCuK+YlDCUkbyFB DjwruMN0GrNUoow5kAn21AglT8LymS9BqoHjhj6GC5pmBpemD/0JaHVVhGjrLJFV2IuY 06Gw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t03gNKuX; 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 m18-20020ae9e712000000b0078727f14a18si815850qka.94.2024.02.14.22.21.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:21:30 -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=t03gNKuX; 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 1raV79-0002Pj-VC; Thu, 15 Feb 2024 01:20:55 -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 1raV77-0002No-CH for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:53 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV75-0005X5-MD for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:53 -0500 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5d8b519e438so479237a12.1 for ; Wed, 14 Feb 2024 22:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978050; x=1708582850; 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=t03gNKuXKadnS+julro7m84XhQpYQKueLooIhn09u8b9wHv2uWVtGqzQFpWVgREywF pNyWAeZAv76g7Zua+Iw+GPWdz1Bfw28htCubvzLGxk4L4qMesezHaWOHE1UQax3vdRS/ ntiTUJutmlzWagt2DVHYuJZ2o827pQUCxOho4p9o6pZcV1bfpMUN0w0FhJ+PoBkXy2fw H8DNfmHQUnRJjtgNBpavJT02DHmbvwACJX/X+kvfavjgX+o39TcY8iNnWy5XjuOsIYnq AL72/l2C1h5u7uW0MfOKm8R1F/OeRU0lk3/qKDUoZJ2VdFtvBIC0vXMOmzUqbpdHHZDv trtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978050; x=1708582850; 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=WL+S5rlLRRnndFl4pjmXC3liKprjTfannbDg8GSkDP8w2gm8pN45UFDXi9SnBg6ZgL cF2EM2ETX/29eA4HK+r6BwS2ypLDAhER3gH08vnFR8nIiZiBEgUFcaJVzgI+Fhaq7PRH YQ5upW/R1xnEtT7buF5qmIyr3OZB3K6de35+uU4afqWkbtNvS+VknTB+KVsQMaTJKlxW Wnww5WQQHb/0/sBq8shXTb6v1rmMZBa2xM/pppigsmri/iqq3vpfa9oHaeejgQnKt9u2 /KR40kh9zyCS5EslRcFdC0oj/yg75OshpHSmbUZ50/uX40Dv8DIa7JXHf7RbtroNPnl2 llhg== X-Gm-Message-State: AOJu0YwB5Dwn6a2bcgYctNjMgc5TOf/o/JfMvVdQ8fwjR0TIBfTFGksF wgKpR2vEg0pRXVsDQ86WsBl7m48O+/38lRDNqiH+QO4jUMHiXcg6aeA9XiwriO4bKFFxr9xNf0H Y X-Received: by 2002:a17:90a:8c13:b0:298:b523:1c7f with SMTP id a19-20020a17090a8c1300b00298b5231c7fmr797175pjo.40.1707978050262; Wed, 14 Feb 2024 22:20:50 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 20/36] linux-user: Do early mmap placement only for reserved_va Date: Wed, 14 Feb 2024 20:20:02 -1000 Message-Id: <20240215062018.795056-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-21-richard.henderson@linaro.org> --- 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..1bbfeb25b1 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 suitable 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 Thu Feb 15 06:20: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: 772842 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680372wre; Wed, 14 Feb 2024 22:21:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWi75zZHMN7UVeDWT2lnz4JZb5jzLOZ5JyfO9dzYyKcDqcysul/ckq0r3qGXuw5wdhBYTbYIUxiW38UvlomVfpf X-Google-Smtp-Source: AGHT+IGdVPckMzPKbA3Rz4sPBHhTYwVu8WDY2w6fRpa1k7QxcZkbmV90boPBd/eXGopSXbQy4652 X-Received: by 2002:a05:6214:4884:b0:68d:131f:c61f with SMTP id pc4-20020a056214488400b0068d131fc61fmr1129206qvb.30.1707978101638; Wed, 14 Feb 2024 22:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978101; cv=none; d=google.com; s=arc-20160816; b=sBEVc087Tt9HYh1TZK0uEJXd73JhnAwgDM9T5bMqeua++N0pgSoiEbSAAiCTnuinD5 nlxU4BmD1W6Ohuh1VbyBbionoV67th/uaW7LvdMclh6GsH3r0uzNWhCjSIo9hhh6i/AG qebahDZmL08gtIEMM1g2CGcw1+QpTEn/E2z/C1eeP7YaGUk0WpXORpf2JzD8vem3pStj 6XuxMVO0cL55grWcfoYVnKAyZXlxwtnRmCZoXtPm6eZDO/8+2r4nXhF7bcKNTwPybDB7 sY9OEAoFjx7Je+WoX70mOnmLL60d/fGC4cS8FbqQghGrdarGLeuVmP+hLd6Lx565FGaW sirQ== 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=TGuf+a6g23AtWTGblDkFBLls1ueawrHAWFF+h5sCkhk=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=QgAmieYGBBpXaTIWCHv/LwqMtzinPg5zMZziWBWwtzNZTgQ1Zf3eFqh9CjfMtKk2xQ EzEIGRDl0SfVlp0Se+dMuIvk6hOcB3qeZlgTQ8uPZp0+eYfCH6aTUJ7uRuC1MN17xM6D XMPsdIjzOTjpSTMD2qO2WTTf54qPZEc9mAsWr3gzchm5Lekr395USO5ChcUO1r4V2SrH KQqm+adOvFvcYu07eXxAoIUXcT8gC/ep4iHcVOcwGGVl/DHvKGK9m8TvIddUa1ekMtC8 q5w8kG4WW4ZWVOrqc86KtmgjPp4xjYfdhI2SxwvNxC+jPC0OvvYKzcG2e8wZV5XIH3iO vXBg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tpR5nYOg; 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 g7-20020a0562140ac700b0068efc012d4esi808794qvi.517.2024.02.14.22.21.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:21: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=tpR5nYOg; 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 1raV79-0002Pc-Oo; Thu, 15 Feb 2024 01:20:55 -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 1raV78-0002On-Bl for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:54 -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 1raV76-0005XP-OC for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:54 -0500 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5dca1efad59so492088a12.2 for ; Wed, 14 Feb 2024 22:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978051; x=1708582851; 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=TGuf+a6g23AtWTGblDkFBLls1ueawrHAWFF+h5sCkhk=; b=tpR5nYOgElZM/Euo9/P6G6KR0BvQfyMiAElmNckxbSguAykYGJymFrjl9OazvABNlG 8OR1HqatIENtX4BsRoEq4Woa8fM4o0M/SCY1lPT+8zJibjn1Ks0zcx9gsFgHV7hKNjDs Qyw7M4ieltW5HVdeMPsBhW8gMpxhZ23aZf2wJziVbrWaYp/iSPvAi9rNRo/lzo2YIiZs J+0ccheS5+I0S8QiqZidxmLKMz8fWKxXx0LVFtQ+Qd64OycVOtpStlVNgxj+SDwNGGN8 Sfpy0rpPkTJQzRwZifTC+NDJZ9PTf/7UVkMSlWHNaG4O/ZCXPUG4nFvRCJJkPoImKsPN 1AoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978051; x=1708582851; 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=TGuf+a6g23AtWTGblDkFBLls1ueawrHAWFF+h5sCkhk=; b=pfkpvqlNNOZiOpCduHq9p9K56QeidXrkdtqqxi6brX0tpxkT8PpBwWJpyUBHZl3hZf fLmdROyY4WLkkHOgu0pn6wHe2s/VoIYv/3Wx3YK2wRwV0F+SfC4UONmLZPHUZgq1Xv95 1RdfWR+YghXJ3UCrJgFoH1BcAWDoGd8evHODwwvK/JdtVWfHPgKS7XO+Ef8EQKm17R8b 7cXy3i22dFhkTziBxfFVrWcjnpaemR3kCsB1MMkH5en1kEK1uamO0jmmS/QkxkIrZWuh h0dDF23Lu2TG8T0p8zG+N5ViRtvyZW0DNFaCC5wncTWpw8SIFmzraIjBbm9lV1pNvMSD 2KQw== X-Gm-Message-State: AOJu0Yw4mCclFaxx/OjnkMYaSO8zhRdSWc/nQiAFIdOanXclsFHhmpfL 0cASvxfFoXDHdqSulAQEmJQxNywi2CpKg1MuAvhnknkigPm44eHsTHqc+04eJW6fN4/1b27IBMp T X-Received: by 2002:a05:6a21:3416:b0:1a0:5841:6740 with SMTP id yn22-20020a056a21341600b001a058416740mr1061256pzb.14.1707978051409; Wed, 14 Feb 2024 22:20:51 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 21/36] linux-user: Split out do_munmap Date: Wed, 14 Feb 2024 20:20:03 -1000 Message-Id: <20240215062018.795056-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/mmap.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 1bbfeb25b1..8ebcca4444 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -267,6 +267,21 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) return ret; } +/* + * Perform munmap on behalf of the target, with host parameters. + * If reserved_va, we must replace the memory reservation. + */ +static int do_munmap(void *addr, size_t len) +{ + if (reserved_va) { + void *ptr = mmap(addr, len, PROT_NONE, + MAP_FIXED | MAP_ANONYMOUS + | MAP_PRIVATE | MAP_NORESERVE, -1, 0); + return ptr == addr ? 0 : -1; + } + return munmap(addr, len); +} + /* map an incomplete host page */ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, int prot, int flags, int fd, off_t offset) @@ -854,13 +869,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) real_len = real_last - real_start + 1; host_start = g2h_untagged(real_start); - if (reserved_va) { - void *ptr = mmap(host_start, real_len, PROT_NONE, - MAP_FIXED | MAP_ANONYMOUS - | MAP_PRIVATE | MAP_NORESERVE, -1, 0); - return ptr == host_start ? 0 : -1; - } - return munmap(host_start, real_len); + return do_munmap(host_start, real_len); } int target_munmap(abi_ulong start, abi_ulong len) From patchwork Thu Feb 15 06:20: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: 772870 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681576wre; Wed, 14 Feb 2024 22:26:06 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVrNFwqF+Eg7o6/XQI3YNRvzJXC9UygD6PzKaY/gu6mVf3id8Wj83T9Lgx1m8P3qgBvY7b5s5yz7m7AXPa7+cUU X-Google-Smtp-Source: AGHT+IFUshOPODb+xjSy8GGfdc6qvXAlQcP9uaWN6tGs3CJDErQIOhKyZuX8ZtoPctE5A8wsxJI4 X-Received: by 2002:a05:6214:5009:b0:686:acd2:4afc with SMTP id jo9-20020a056214500900b00686acd24afcmr1026408qvb.17.1707978365771; Wed, 14 Feb 2024 22:26:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978365; cv=none; d=google.com; s=arc-20160816; b=bwu9FFR6xIKjclV1eh8d0jZIqongsCBn5qM+AClrtU2Yxe7IcE7WcP8GbzKKMujCUN KwG33KqzcvEUxck0v5qGidNOVsXEUdha/PPor+e37kZjLo5kjMrjqv9ggMUkqbGTl870 M0yU4ZV8YcQ0xO59cPR1eqoGOWHW5cUqKUHfUzObln8BgAKg6eZMnLrrrzvfuwGGGTU9 C/KbOaJFFkFnX6blOkPsw2K9gtqxaIJsNrzJf7/UmkpU59rv1eYjzvglwCu3Q5HeZUNt jexrAu/Vc5kJeEKNRzEm7a58oMdk4Bv3mKLVn1lrY9+Aqa7VDuNDaeKzl4NxoaNnnEwm U+zw== 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=mDHtjMX+mEQb+/p7zJ9SmZdTAU/DfY9CF76Jhj+l68I=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=p1EzucOx239IDcPBCpL65rzbamddx1tVQEwnS4DvbGBdMFGdQfytMFBgcXjHnsOxKT 6LGR1gSq3snJcRc4wplpLE00Eglumgh4Wct4KLzvevcrmUF8xlq0vgKSN7d2hrqz0nHU 9KtIIgP1eM+nCHXD3dYi84CzcoCptRHB3XoCSxUD/t1rQRca/0qvRpirmQ+RGC22KNZX evrj9bb4wN51JCgeUBSA8p57PpBzscIixN+fwm5l9o4TEvgyVSSxIiQoelk03yAckquF rqJBzx9nOcKkKMQaetEocJHLSFnoCgTr5AQ5gzrHw755m2UaHGuVP8NL7tFaWmdFe6w1 aPFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u3ei+nhA; 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 r11-20020a0562140c4b00b0068ef4e6d020si766476qvj.295.2024.02.14.22.26.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:26: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=u3ei+nhA; 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 1raV7A-0002Pt-Bm; Thu, 15 Feb 2024 01:20:56 -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 1raV79-0002PS-6B for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:55 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV77-0005Xl-Nf for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:54 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d7881b1843so4656725ad.3 for ; Wed, 14 Feb 2024 22:20:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978052; x=1708582852; 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=mDHtjMX+mEQb+/p7zJ9SmZdTAU/DfY9CF76Jhj+l68I=; b=u3ei+nhA06wfOBKGdy1US7qnEUWsIj27qpj41UgMieXqcybrSn0krIXS1S0nBRA5et t/iYFG6SOibMqOzH6RWwMzeA/Wf0UiZXciaDzE+MYSyKOnOer4OV7wYX9MBV03q6/jo2 3iZXZQp0aYjEjSd5EOlGSGDq74VAST3RRM3uifA/vJffWJYYJjSOpvUpAlJyf34hrLsT zHdJpLmnB9+U6uKbleh4zgHo6kPdpzu1aXmxLnIHxU/IVP+eN85EnxgVsyAnWmf7WXHE +r53WJ1kvwNTVmO3U1zoGdUEb112ZedOpO2HagG7rD3Lfl8cpZM0Z8hwMcob3Ky4rqdO +jAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978052; x=1708582852; 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=mDHtjMX+mEQb+/p7zJ9SmZdTAU/DfY9CF76Jhj+l68I=; b=JVyINRQWecGTMjFZqj00ipWTyWCjPIjIU5YkSkj4DFzHxGB1cerZ3V1bDIKyB6c3Au UoJYghNEFc6ptewYgEA2cY0Xey6fO4USCcUGNv32moCQ/srVvXYh7JxDYbzzrGtMpp1O Ka9Lh8ycqxeRh2T4NLnUIH3dBGkUdPQr6Hq3Akv8ILyQsG7IQmc/hWeQALTyfu/xKrWZ HIgxwsnLRbeycmNd6hEZvglN2EyCcbCDeJeFE1hSnq1IrTojwqMBzyvy5kicgoHg1ju1 DUCI/d5QC0iTAZ+CpQdJl+0u111cwqL6T6jDNDCiF9NLu/Ou32F7s2qIid4XaGl0NsTr ozGg== X-Gm-Message-State: AOJu0Yz7pJjB82QweHFjKtdz0YtNlwL4QXJCo9LGZWz3F1fTAsE+//QA SicUbRpc9xdKCwjKmTxX4G4zAxQUcEazKOgEa9afJeWzec3lEZ8jKpp8utOycLKmkwuTnMFC9L+ A X-Received: by 2002:a17:902:f68e:b0:1d8:aada:a7f5 with SMTP id l14-20020a170902f68e00b001d8aadaa7f5mr850946plg.11.1707978052467; Wed, 14 Feb 2024 22:20:52 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 22/36] linux-user: Use do_munmap for target_mmap failure Date: Wed, 14 Feb 2024 20:20:04 -1000 Message-Id: <20240215062018.795056-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 the cases for which the host mmap succeeds, but does not yield the desired address, use do_munmap to restore the reserved_va memory reservation. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/mmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 8ebcca4444..cbcd31e941 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -326,7 +326,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, flags | MAP_ANONYMOUS, -1, 0); if (p != host_start) { if (p != MAP_FAILED) { - munmap(p, host_page_size); + do_munmap(p, host_page_size); errno = EEXIST; } return false; @@ -622,7 +622,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, p = mmap(g2h_untagged(start), len, host_prot, flags | MAP_FIXED, fd, host_offset); if (p == MAP_FAILED) { - munmap(g2h_untagged(start), host_len); + do_munmap(g2h_untagged(start), host_len); return -1; } host_start += offset - host_offset; @@ -735,7 +735,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, flags, fd, offset1); if (p != want_p) { if (p != MAP_FAILED) { - munmap(p, len1); + do_munmap(p, len1); errno = EEXIST; } return -1; From patchwork Thu Feb 15 06:20: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: 772852 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681201wre; Wed, 14 Feb 2024 22:24:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWst3Nqc8gADvjeKLOTvMtIIO+4AA9lsLxWdMm7hcd0PUJGPfKbjsOZ9lf6Mo1M/pLAlk0YA8aMbaZNrlRd1fKt X-Google-Smtp-Source: AGHT+IFZoxjpccmnmMt1BeqioBy2mPXErzMGyaNESbHpwn5HenvgPzj+zdE+Gl1qJEhnpWX0kKuy X-Received: by 2002:a05:6902:2504:b0:dc7:5a17:6c3 with SMTP id dt4-20020a056902250400b00dc75a1706c3mr808509ybb.53.1707978279655; Wed, 14 Feb 2024 22:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978279; cv=none; d=google.com; s=arc-20160816; b=DaqrTThqcauBH6PRAiDFWjH7dzOSsuWjkKVJT3gcOSL8Z+DgvE8naNiwNj2E+bq8Xs P77HGvvEqogzynyzditrsaui2dFKnA/8VlHgtwJpqaMb09Lq9BWx8KINUVQYVS+v1iJ+ 2zJxc2tw2Vsd9MqpjB1KEVjWPbBVG3BplDR2H1+W6zAJuAuq59Bnh7PykEW2japg3t+F vFaWpdl113q6NBj/tkY9shFBRRdFEicUNJQYQ8sLYfqu8G4JNJGlteOHEYJskfImvhdF bffr3lLQEwrCtPdqPh7yx97rkzhVzxbbHh+dtlEslxBq/j6hdJFIqQHjByrR4PeAXv2K NkWQ== 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=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=zvPzSQUqCmc4V3G8xuamP2hb59oQpD5SYembUdU9t5nQyJqcmfmQTlD2LigJYHrBjy iuQYR1rNs7xaBPDhyivozMGH0Nh+lE6LjnPpeLqKrnoU/OFKaXAuVCAK5rpOFwzR5p2P fZrtvvKhfik/Q6hq0eqRjZOIASyzqG0+JYjKpDsCmuU5aP0PcnBoPcTV82CVqPRnZ0F/ MSvhuqCxgXxMgCV21IwUAFtsHYrtuEo9qUyC2k2pSazW4+9tt84l//3mhwDUF+g08R5d DlzyG6EKAievkqh8DTXeN49br3VNLIzpy0djIHrB6eKigkgSGYt0dAMOu+njWpJZTs4Z P4oQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I1gJsuOM; 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 u30-20020a05622a199e00b0042dd0754ff0si216900qtc.529.2024.02.14.22.24.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24: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=I1gJsuOM; 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 1raV7D-0002Qy-2V; Thu, 15 Feb 2024 01:20:59 -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 1raV7B-0002Q3-21 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:57 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV79-0005YH-Cd for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:56 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d8ef977f1eso4471285ad.0 for ; Wed, 14 Feb 2024 22:20:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978054; x=1708582854; 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=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; b=I1gJsuOM7IPHx7yaCrH9hBzyJsXrjcnTa1LQ952KwH31emA65soTeAAjjS0sxMjhco ER4P9OOLh2VWboDUJKZ8xlQi7/K3/P3Zhk29MoEF6yq1r7doNQcUPuGRtmq9lY2UJPUe P4MlAhaoGhnSGYZrW4VqpQh+HOe/ioOzgSe9CBcxagRWKrsJAMGSq3FdQ8CkVg+e9lL3 X/lL5GYtXbq27Nycc3cjo2qyv2D4CiqMdB06CAmj2K2Z7edbE/GB5NWW7m9aoessFEj8 s7mY1Dr0+oeDytn+MFQVMaW1zX3kmp5TIZ+UjmXlNTAuZNx99x0IAFJecqjBBnCrF9Of A88A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978054; x=1708582854; 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=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; b=oiuQaki6IYr7oTRV83IjMpuk34g/M+QmXIfBamFx/swj4N2VnQufzuwE4PdnMWkRfJ bEy2Hj3SFESF0+qyMLt3UJ6wFb4uIL3oU96iSeRqywI15vlgXo2LVmbmDQFeDpjRS1k9 T5sNHaeWrhrRjlwxo0ktFW0zXQfUvIhAiLfDUDJ2kcEvvPbEilMtgQDTc3QbqFt243Rm a7yNjKHKgldE9UnDTmJtgFBVlulPDF8E4xs8EygyBFMbvv1yAJ1k8FmieiRa4Eb7mysU u9IZt6eZRpCauJCNf87HaJNI1zcLX2GbULevEoOAJS3RZbR6G9IaQSeCIkdC80qR7XVo 2XUw== X-Gm-Message-State: AOJu0YztmzDBpPeqYepqtX2T3FFACKZc1QbOwrFyLv2dcvO1d9qeOLAz HuN1S+ivXJP3avH3h6OFDu4na9lJJr6OcNKwhCMyIRyHKeChJnJdMOWraSdMLHwrpUqmDaXTIJS q X-Received: by 2002:a17:902:d584:b0:1db:8a13:81c0 with SMTP id k4-20020a170902d58400b001db8a1381c0mr648959plh.49.1707978054034; Wed, 14 Feb 2024 22:20:54 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 23/36] linux-user: Split out mmap_h_eq_g Date: Wed, 14 Feb 2024 20:20:05 -1000 Message-Id: <20240215062018.795056-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-22-richard.henderson@linaro.org> --- linux-user/mmap.c | 68 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index cbcd31e941..d3556bcc14 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -542,6 +542,33 @@ 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 the host kernel does not support MAP_FIXED_NOREPLACE, emulate. */ + if ((flags & MAP_FIXED_NOREPLACE) && p != want_p) { + do_munmap(p, len); + 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) @@ -550,6 +577,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; @@ -558,16 +586,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 suitable 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); } /* @@ -603,12 +648,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, @@ -731,8 +774,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) { do_munmap(p, len1); From patchwork Thu Feb 15 06:20:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772859 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681422wre; Wed, 14 Feb 2024 22:25:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUM4T0FrPK2K55dDlk4DhFOmjPtw6sbUYELnxKExxI3e0r7FNFAr/PQJZePvbtECnEpt8LfleGzPSP3UbGIoXjH X-Google-Smtp-Source: AGHT+IEeHP6xb4gK2aBgaWsAfqUQ6QJgYv1F3xl64DvH/mAdVHMT6FXYxhfNRymBNkbch8ddpiPX X-Received: by 2002:ac8:5ad3:0:b0:42d:b5fd:3fca with SMTP id d19-20020ac85ad3000000b0042db5fd3fcamr915321qtd.31.1707978325677; Wed, 14 Feb 2024 22:25:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978325; cv=none; d=google.com; s=arc-20160816; b=nVapOg+0ciA83SlkVNl83FQ36lIvOiwZethFeZgLBC1g+1HlVQ6sKa7bS0To8evbWV h4npsnoSXpm1/t+N9KB1R9WEICO5LVisCzxMhR/L6fN9bCPbK07lo8PcW2/7mKjD6wod 2XF6JlEmjG/hLulZm1fyMUucLWlvm+YNBEqlIChYWNMeTEpd3ED+XykoqCLYAd/cCdoV CDPt6yo4PeY747XZZwpp++8rAHDbu/r2Vb9H3UquCLGTSltM/+n1XfhbXC4fKMwDe22Z C1GTpz98wT74Iyoe3sCHr/yQ5U4h8HJJL5kqn64fRBaXN3LjKTkAw0vFmt88512oW1so ElwQ== 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=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=GEl+4JQU3EuSH0ZBE7htURExRNYY61Q2YCTciq1/dX1m1k3aGbRV0YuAdC4uWixOLb g4Zbj3lQOfa4IGUaQUibRqo7SNxm+eZDoLjRD19RQb3QL+NWjVYTAW/Lp5ouDw9c/c0d v0E4vKtJ/EgiOToeI/UCpT8PPJ7YNTioSErqf02Mei7wM+cKilZKcMT+bnMgU+Li6Zog l7g55Y6XJ3Umxb7VNPN9+IAAIeD40ygcg/LqkidZMxTQlgr5nsZo8s1WFhjHCscSpI3h k4nXqCuyswwqLUMZmHjD0JIJxd3HlwUJ89yvqZ2FtWthH6Ykqp3/ZYRxNwTN1wTH86Pf TG4g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=spbn2g2r; 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 y12-20020a05622a164c00b0042bf4b5caf6si750181qtj.480.2024.02.14.22.25.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:25 -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=spbn2g2r; 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 1raV7E-0002RT-Lg; Thu, 15 Feb 2024 01:21: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 1raV7C-0002Qs-Vv for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:59 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7A-0005Yh-Vz for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:58 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e104196e6eso589664b3a.0 for ; Wed, 14 Feb 2024 22:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978055; x=1708582855; 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=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; b=spbn2g2ridnxUXGHIRkCCg7x6ZhigMrvldB7oasOxrOpEJrXYQ/lIlKH5TmY1K5Qjt 31DLqunvlyd/ozWczQ+0FEb/lv0+5JkQU4Iyp1HXYrY0fzk07vSKVULkCuI/VQX4rhGI OFLgri7ou0nIHjrMhPLUuCoMGJRrYCAsT4+/zeGevd4NW0EQkYA+8J+GsaEVWsdNzQkg CbUSm9ov38kAaxNCr/5Jb8FaIndMk6Cpj7opEk8x9jP1I/k8+0v0RjaytnS8OhsmPcPm lwEAtFe8woLlgo6fv6vcbNb/BN9lzj7wkpTLQiAJjPf93VemO4OcJcu4dGbdnXuWVUMT G52A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978055; x=1708582855; 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=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; b=D+1Eiz0x48QseJxpXTahsKO9c4MCvzX6AbPO23R/PizXd7o8ajo/WpZSc3Y9r/37AY Yb8P3woNKMJsgS0kIXBra4tMoy+cfEH2wy1Vp0AEIPiwwUxUl1qHo0IYP6LztpHtgkHG Jh04Yx2LxrrioOAIW33Hg/cK9vBXW3V0fz7qkCTNZ0q63E4FFb7opA6DQgNJRZZ7noeq Pj55xTHR/w9Gb9vxQED1UNHJVSJY49ql+63/Bk0snqwtTXoeXR0zalPyRF+6LWPWpYet ESQ6zTgVE69DWqyKgxxxb13jfxGH9et8Ee3zv/NpKMSLLDf+TV0Y/C3i7cKfLqoHH2i7 Q6Iw== X-Gm-Message-State: AOJu0YwtlzpqZCVhHRDncZe1OFpWWwm1h/q/QWij1kMX4UdjeseO2t7f ZNs+O299kFj5D2mOhdTnbVI9ItQh6V0HK+mSdJy/KBQ4zar9a3sCEe30VS18oXHnyL7maca8CUL T X-Received: by 2002:a05:6a21:3a41:b0:19e:cf1a:5372 with SMTP id zu1-20020a056a213a4100b0019ecf1a5372mr1415150pzb.34.1707978055622; Wed, 14 Feb 2024 22:20:55 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 24/36] linux-user: Split out mmap_h_lt_g Date: Wed, 14 Feb 2024 20:20:06 -1000 Message-Id: <20240215062018.795056-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-23-richard.henderson@linaro.org> --- linux-user/mmap.c | 184 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 153 insertions(+), 31 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d3556bcc14..ff8f9f7ed0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -569,6 +569,156 @@ 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) { + /* Host does not support MAP_FIXED_NOREPLACE: emulate. */ + do_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); + + if (t == MAP_FAILED) { + int save_errno = errno; + + /* + * We failed a map over the top of the successful anonymous + * mapping above. The only failure mode is running out of VMAs, + * and there's nothing that we can do to detect that earlier. + * If we have replaced an existing mapping with MAP_FIXED, + * then we cannot properly recover. It's a coin toss whether + * it would be better to exit or continue here. + */ + if (!(flags & MAP_FIXED_NOREPLACE) && + !page_check_range_empty(start, start + len - 1)) { + qemu_log("QEMU target_mmap late failure: %s", + strerror(save_errno)); + } + + do_munmap(want_p, len); + errno = save_errno; + return -1; + } + } + } 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; + do_munmap(p, part_len); + p += part_len; + host_len -= part_len; + } + if (len < host_len) { + do_munmap(p + len, host_len - len); + } + + if (!(flags & MAP_ANONYMOUS)) { + void *t = mmap(p, len - fileend_adj, host_prot, + flags | MAP_FIXED, fd, offset); + + if (t == MAP_FAILED) { + int save_errno = errno; + do_munmap(p, len); + errno = save_errno; + return -1; + } + } + + 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) @@ -613,37 +763,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 Thu Feb 15 06:20:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772847 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680910wre; Wed, 14 Feb 2024 22:23:35 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXp7pDjdrG4+tXRcMvmMAPhg7rGid38IvsNagDhs2GOB0Dl+Ty8J/RO0MqkhwlDsfC88HuFAc9e/ChpJKtj8GJp X-Google-Smtp-Source: AGHT+IEP5U3w3ajeGvOM4NmL6DdO9druRNmrPVZJxc8eJ3joWihNu7VgSdvHup8uPhzsVPnMoyVj X-Received: by 2002:a05:620a:4403:b0:783:bd4b:d617 with SMTP id v3-20020a05620a440300b00783bd4bd617mr1204618qkp.5.1707978215133; Wed, 14 Feb 2024 22:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978215; cv=none; d=google.com; s=arc-20160816; b=R2gRouCo4/gKpKSJn4Zy1CmBwELfcBWDGoDSHxw2o5S1Z6vMgTLGxKsglmVhxpj2IN spQU1TYMQyiju9YoMjcR+4r/Xe0U7kUBPNMvsMSfBMOaxlyYyiZ0YwDRiHHoE1QJNb5n zhaWBFWtCp+NW+VE4RQJJoxHtIB+QDZYsdzjVS55FYUxNXY7w8YweGY53guZk0jA0rM1 OPAuaehRsoTUqoEX/Xhc2VEQ3BkJADmqUjN89J/SYJ3FefRS8BMFtCtEdP9ReNtnw62U ZdVuJY7+aafmfeMPQIMJADmdOFAk2mhAXV/ffFo0BmqqIoKFv0uK4yjHMk891CtL+Nqd 4JbA== 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=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=orsmTfBX9T1nGUQM7KzmW9vXX/Xu5IYunhV/hCFZt6nQDlToWpiUgiwYjNnZulVcwZ wcXild9vz8VdBnaXKYNxVjeEifvRSNhcNSiiO486TUtOA5qD4PK+/0HK1BLkyNJiEqEv hZKx6kNDSS4k0ptsjlC8zGraE0BdVPywULfklcmM2XTp5sHTFjdKCwuNC2WhbOH2juOm PIk+lR2PVsgsl3FhmeHQJqEPiU3GdjslDiIm8vyipUfMq0phWzyUhi285vKAN2f+DiJO dULlsiCcC81sXWbgh3zHZ+nHgVsXXe7Qk/mYNca0xGYfOwpGb0lQSuxwxnNJmq2YhVfw CoyQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ggR8pGkj; 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 p6-20020a05620a112600b007871d41a880si798168qkk.644.2024.02.14.22.23.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:23: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=pass header.i=@linaro.org header.s=google header.b=ggR8pGkj; 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 1raV7F-0002Rh-Nf; Thu, 15 Feb 2024 01:21:01 -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 1raV7E-0002RQ-H3 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:00 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7C-0005Z7-9W for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:00 -0500 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6e0fc87fc2dso319093b3a.3 for ; Wed, 14 Feb 2024 22:20:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978057; x=1708582857; 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=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; b=ggR8pGkjR1B6vTGOEjtUQ1fs05e+g8EIgIIplPv9FCbddxZiGNsrEzUYMY8kuL/+ML 5LL9va3wiD4LWDn+hbW35nl4qF2Y8cOE4t2ZvbAYwWVPSsGtB7p2TE4yiy+Bp2fDnkN0 heLhYzstlQHDdeMiOisk7iiY08JjPs0o7CZs7GTrhhEPNiLnX3rHvV1ai0dJLrJuzTtU BwWj0kl2omui1vxA0+dABMJUeWAWQIn5gfPG51jLw8s0k69GKNlR8fyHLkHCD9f1WqXD dZbkaUHQGOIMiUL7Gjdiem3hm8BSsxgp+qZ9XKCMQ7WuPcOFdhNFcWikliFRi8z38cL/ WNgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978057; x=1708582857; 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=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; b=w+XKtyOBqXFGWTBe69UdAm3sTqN7mtwLfc1Rur/1gCHV8gYiq5Hl23smz8v4u65SxK uAxqLr3bo+eFFzTQSztaLaR3M4zMVCPN0jf28pCEGiI0VvMNx/SqfKIZU04zObT175Mh 40VEyElqDhAQJWsO611n2lQf5Qgcw/bgAy0ddObNk6JVmVFqmXTyEVvkP8TBz9D65LTw VAdDSwT58X9T7BDvqG6S7nQHqTu4hRy4qa7Rw4H4hv0HGpGxczeUAYggvmttMI2pk2it qxhnRWIUG5xoS9vjlMPRDCq4Wf1+4QxFUXfJYFmqRATyM5K6iZeJVJVzM1egxUBfp6/2 XBnA== X-Gm-Message-State: AOJu0Yw8+VW3OmblKRu6YeASpr6cDzIraP+p7OwjkO36h3dhr33QNOOi 2m+QcL8RuVlEasMeYxB9a6eKf6yrD0xiw1WmpjlRn0v16p7Eu9MoAeSw5vx1PQmu9m/NVzNFwG+ f X-Received: by 2002:a17:903:22c6:b0:1db:35dc:e24d with SMTP id y6-20020a17090322c600b001db35dce24dmr1093620plg.10.1707978056954; Wed, 14 Feb 2024 22:20:56 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 25/36] linux-user: Split out mmap_h_gt_g Date: Wed, 14 Feb 2024 20:20:07 -1000 Message-Id: <20240215062018.795056-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-24-richard.henderson@linaro.org> --- 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 ff8f9f7ed0..82f4026283 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -282,7 +282,16 @@ static int do_munmap(void *addr, size_t len) return munmap(addr, len); } -/* 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) { @@ -719,19 +728,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) { + do_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) { + do_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 suitable hole and convert to MAP_FIXED. @@ -745,6 +873,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); @@ -766,150 +896,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) { - do_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) { - do_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 Thu Feb 15 06:20: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: 772854 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681291wre; Wed, 14 Feb 2024 22:24:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX7YIK2pZYmbTKEJS6JHpejS9HQHGEh4k0rHpdaLQ8C/0962PxRdPNlTL1FSL6NmGVmrSVG1BarzXr1JOQm7mug X-Google-Smtp-Source: AGHT+IFIC24nH8ZhTv7yqxeBMHaQgTZMvmiW6jpST6xiEgMcerL26MiHe00Uo9I6JuyJIcgDqVX4 X-Received: by 2002:a05:620a:531a:b0:787:284b:3044 with SMTP id oo26-20020a05620a531a00b00787284b3044mr931006qkn.77.1707978296778; Wed, 14 Feb 2024 22:24:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978296; cv=none; d=google.com; s=arc-20160816; b=BVRIiucSGKtNNekPmLs3S4i4aGOS6yjGbAnqcp/sNvDeLAhP3sfQhPKR0/U3f8y7Fb fiDMFjWPMxuGm9rVYkv7wINjFP0stJH7hwMmVccOGaSCiDNwXMksq/S+b6CmWl/I3msC BdvT8tE+F2Zu2GwgK/D0NwlYzqDrj8eGqpsyKf4KvrfK5UHZTKvRNeM5oImyLLZVcgHi SgHBAtl8AQ3TIRVVyoEgyaqUNi+sbO9a7o8E7r29mLWsy8u3XHJqESEoTy9JERKU7jYg RPHTllUgAjvXZK+UJb8Qyuf45+yhd8gfKfDVD/x14hX6kMuys1TIhCiN0JpxPmlj2Qf8 Yj+A== 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=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=Vgpl/R+TMLrVEgAGfW1aJLCk7LpvCvbLkfgoETBK8ODCAFI1IQzkS2kxft6KPTyDiA aLjNJmlP3LsECblCCXVAnHJM1CBn+eswrEAQxq/pcaboJZQo4SE0IX+5Dmzx7vfrtcz9 TAUtxq5rw55LU9+CDlZpvNrjS5/UDDbPFvk3pWGP2AZhYRgvVRzk1MW7tMTaryvgsMJe JA1WIEzFPyFjds//Zemi6w+vAEIjrRmKJT5vKSMpQV0ZFvJaTTdHK+BTIjF1VUaxCGCz /1MXzYUOuC0iPhan4iaiMZngvSLaKUi7Xh7xzCE7mr5SHlFizzaCnPPlCmBAETbqAsrb zPVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NWxi5h2S; 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 u10-20020ae9c00a000000b00786d37e82casi862234qkk.137.2024.02.14.22.24.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24: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=NWxi5h2S; 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 1raV7H-0002SN-Il; Thu, 15 Feb 2024 01:21:03 -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 1raV7F-0002Rj-Rh for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:01 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7D-0005ZR-JG for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:01 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d8ef977f1eso4471555ad.0 for ; Wed, 14 Feb 2024 22:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978058; x=1708582858; 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=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; b=NWxi5h2SJG9ja0acmKfI8WNKcewDyTPIvLjtCE9piJ85++m9uOjyOW6z+hcZmy9doZ wBPlf5ARZ30lfWayfT/Dqn8MxhukVY18ARinrjLTLTOy++6Vae5+DtztQcrQ1iwvZ2/7 6FjFWHyI4fF9rKT99gX/fccGeJnZrJXtreaniDsrwdQ0U85j4mrAQEdJ2cev4eljrXwx Sph8VNLgtLdCjDrAAiRju2T0tKd3o9qcEJNGOQYD0aeeTBaNTSRz93uc7pW8hhV52B8u dD58eMGIsNjH52f+HvgRX8Zp5PJT3Zw2z0mt3zQSxpnTi8ytV4aXqPA24SsWton2ZP0p jTJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978058; x=1708582858; 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=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; b=MKB0b2HAs0sIV8PdptHmQ5P1jsg1GRNEVfmsxyJIDXLu7Oc7c1dRIY/y51dGYaJjGt eM6vkJgkUQzl7qgBPyK08/XpXdXgjdYl4HWllg+oWXw8FrA9vCsDjTH8WioNLRA/lA9q 8GvF7Zb2sCJk1ootR7gUBXcID7faYJDct6jxhvXwAMLenXIdjU9n5UHSsR+9J1Fih9sq jElmfTMcZkLCdey+iuYfCtwSW5tlZlUFGzJP+AMshi/D3tGsPcy3UlMPbfdJg/fzTqQv LwMwguuVJb3X6CwbWQzFDZ0e+QzpqZ7kOXgRuGjMUkUB/KbPu5vUjXr0gdss+C/HI/Gz 7c8A== X-Gm-Message-State: AOJu0YyCgymHJVzs/odHxsEc45fzX1u/mnaezgGzT1qsNQ4TXqxNi9Iv ZC2N5y7lJdZAcbWVAKArSyrTzvah4uyANeqPZ9Oz+F+kB81IQo4e+DN9+YbGXdjjYIct1Hl+Zp4 j X-Received: by 2002:a17:902:ce82:b0:1d9:63a3:e962 with SMTP id f2-20020a170902ce8200b001d963a3e962mr1007444plg.6.1707978058361; Wed, 14 Feb 2024 22:20:58 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 26/36] tests/tcg: Remove run-test-mmap-* Date: Wed, 14 Feb 2024 20:20:08 -1000 Message-Id: <20240215062018.795056-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-25-richard.henderson@linaro.org> --- 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 9906f9e116..bbe2c44b2a 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 e10951a801..f11f3b084d 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 Thu Feb 15 06:20:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772836 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680264wre; Wed, 14 Feb 2024 22:21:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXdw9hwHrd6PA4acikW2+RI5RTdLkFAWttPSvRs5sTCbDoOx6YohCrRN85SaR8rOyURuZmNb8wls4EIj5QG21no X-Google-Smtp-Source: AGHT+IEF3OmzNQMqJ692bOKNR7SLQZGgw0RtgrpD4JwssFGYEwnPKCVsqWLP6MpH3IyZaKw61J/z X-Received: by 2002:a0c:e3d3:0:b0:68e:e37d:a38 with SMTP id e19-20020a0ce3d3000000b0068ee37d0a38mr1000429qvl.7.1707978073483; Wed, 14 Feb 2024 22:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978073; cv=none; d=google.com; s=arc-20160816; b=ux0g9MHGxvgOVwNGJ13zFdqonupMxfZfw5GMR8a/QLChTrvbO6g4K0zMZMi67sC3t4 lybLoNDxkWUzHKd1sqVh0EPvfxrFKFjfLC1P2xlXk0Un/dUX2i6YNOqc9QpVPmAUm1nM wVjm67BtwLLRYYGe7MJXA73J0UUzZfJao42FzSWhleffshswW6XF2rDbRFgpZFj6zOwz 0yZwJi11vK7zc9flLC/PwXomAbh/Z527AixNmmzSfgi7gSKL48AXgEY6E1Z6wurPq1iQ kq45p2jO4ij7sNW1CSLafUDRSedsUqUPGOPiygKqfHBd9mYp3uaPy6RyJa0DHppyI2oK CKVQ== 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=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=d8aUvwv+qLeZIb+raCaTIn9J/pztjpVtoErv/zJlVmxgFQhX6qU2k7g61MTk5OdAF4 RGNXH6JgjqWAN4t/BPweLKGgH9YvC6mjK61FYjEaGK7q70CcuDwHBuCsbUbtZblI1I1o rUuvZPnjCoYFP3KO5BHgRL662GOkYLuolZZ1A/Jum9vEJ6Bzv5Hgk1Bdes2hKaL9SZs1 6VqL3szbJwn3I+bf6Fg7QwY46WLe0MknLGc2Yzgs53DJ435cMMXcoiGnmN+4CPAJ1ItH e8Fbbu8gZjQa6/fLoYe820Qn3zTpcWItuXo1iH78y5389rInuhg+07hhNrhr5Ku8dBfn vd9g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jocrHhZX; 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 2-20020a0562140dc200b0068efa34d039si786159qvt.69.2024.02.14.22.21.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:21: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=jocrHhZX; 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 1raV7J-0002WL-EB; Thu, 15 Feb 2024 01:21:05 -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 1raV7G-0002SA-SQ for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:02 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7F-0005Zk-64 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:02 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e0aa4bb62fso311220b3a.1 for ; Wed, 14 Feb 2024 22:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978060; x=1708582860; 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=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; b=jocrHhZXXPVXVOKXM8tf6O7U7e4f8XwGD5NfISYkl7L+JBquBlR8OOPE0Veo0DIpzg EQsMO4OmhDSyfiV+8V0u2f6SzEbmSR0A0qo5jKImc5xC7GHNdpp7nWgbrZOo1oQM3//8 PFUYGWBZkMdUJjuKyuZdunF1cBI/z2lBOUCFyHPPmsRZWJzsLCOlX5qc0Ie/MnM/KPtA BoYhEXbWf31pYkzlMtx0l2hO94xTjjODg2YkFz9ZtVIR66xQsl9bXnPeaavHvheVFXf6 wlw3FK8ZheX1K71wwbViAidcRh3zszGfxs7DSuPAerevO6CLffmI1IsUEkrZ2IYJsmuO 5DYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978060; x=1708582860; 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=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; b=a8rTCODNJRUTZ8d/40bxX11mNR55kQbO4LHOAIgkDeBhlg84fPlHOWnVaIC93gdNrp ekGWZ+UaBCWqkROKX99H5bn26at2Q1VOzduBLnzAZhR0zCdWIBLfkrjuuTpkUwqwS9+f ThIlqw68ruqapOPiFntxr+Dz4MUBTfw5ySDDVz1jHMmj7+zy8BoMa7cdUK4U5pO1kDyV 6qDJ8dA62/Q4Ut09ISgzSvWTW/jhJOU/fwtjGJJI9dhqTyZxDVWtk0hus7E2m4yYC4nB ho9YX40JpOzNQbp8+vZL6ttMXHFtp4M3LXSrhJkH1DNJVSNiIyVaINqmwTqR1XTczpEs 92JQ== X-Gm-Message-State: AOJu0YxpbaE8yIQ9lYfAv14tC9vsOPnqM5/jbaz6Qlnorom5vli5bsqs WwWE/4enEcuti39YyZxHHD9/CqIw17uxdeiew0BzZYRZJ/0tHZSVXSZvFU9lDIagmWIBuZMhucb 5 X-Received: by 2002:a17:903:445:b0:1db:917f:5a42 with SMTP id iw5-20020a170903044500b001db917f5a42mr75351plb.3.1707978059832; Wed, 14 Feb 2024 22:20:59 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 27/36] tests/tcg: Extend file in linux-madvise.c Date: Wed, 14 Feb 2024 20:20:09 -1000 Message-Id: <20240215062018.795056-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-26-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:20:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772844 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680606wre; Wed, 14 Feb 2024 22:22:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXXh7WnVlc6fF9fFgFLNu8bO7vOqLS/ES8P0SbfvTgMD7gD63hM2eo/hg7HOr8Z35+9miHLNh/x8DW4476NujQz X-Google-Smtp-Source: AGHT+IFFprn+k1QjLWjkfeMgjv3sjUfvCREoV341VF3+nPo9VTbegyygZgnBHbd/9U42F2pOOU07 X-Received: by 2002:a0c:e08f:0:b0:68c:5c8a:41b6 with SMTP id l15-20020a0ce08f000000b0068c5c8a41b6mr866130qvk.13.1707978147057; Wed, 14 Feb 2024 22:22:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978147; cv=none; d=google.com; s=arc-20160816; b=pSmzN0Hwn6Ok7VXwY3FxKsa0J87JgdfoB0uDw4aiEFOoHFZFgnwe13YUpKJ13UfS/9 zd39qwvgzVl3qP6OPFIab0Pk+iEMDcsFtUyFNj0l/D1boANhaxY0mKwDxKNzaP0zFK+A 3mJ3vejXeY6qyDilVGHt26iHJRgneejiAiCIdukOZan/LnDqKDSueAfc31fgWyZGuqAf J4OVkcQKm26B4+kU5BtKBZ8XTqOazzsHrtl2aSbeWAjkVqpCFh25/RpQgtYMVFc2tBtZ rWAi9AY94N1Mg1h80+W4UlwADE5n7wdkAH0gEN6ypQSOrY/tkyPLGUKxvFqO90kGoQpA 0emw== 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=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; fh=s58Awvj7EeyV94muHEDuIYugSku1j/jQQ3a3hOlVvqQ=; b=I+RBZ4DIc3ZiZP8oCWtHK41cD7lYODes3fxX0KAT8DP+o8j/Th1Lolhn9PqV8a+w30 IUbcrqhKez2NNFEVwIZhJncfCmQtKHyxrNj2Es476jHukSfYsmmTTR0Cf7pfXO4NRYaY F+6bUxAolOfrJsMyAqzih6Q/FVK8Qaevt1Tunv+jHZ1Q0S6dd1BLdzbQKkxTZXufr85K sOspWmaqLXNQ794+v5NoryKwerxqI5W1BVFpU6w009MpDAxYNO64xp+svta0nBUeVayi HzF+rNltmtV8trsMKmXOePaBKZ1TRi1YH+JDMvvYdUTcpbtfwaAO+Ec4OU5w/WET7n8r KG9Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iAVlYPA3; 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 3-20020a056214202300b0068cd7c873e4si786879qvf.511.2024.02.14.22.22.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:22:27 -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=iAVlYPA3; 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 1raV7M-0002jO-Dg; Thu, 15 Feb 2024 01:21:08 -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 1raV7J-0002aB-FP for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:05 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7H-0005aE-4q for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:04 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d91397bd22so3785535ad.0 for ; Wed, 14 Feb 2024 22:21:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978062; x=1708582862; 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=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; b=iAVlYPA3IK6ae7rQCI5dUhoCxdHv87BIiZR6rzuLU0BCkBApD2gktnpMnHlyol+P3U C9tMWKRcpHto4GSN81BqvnMPjrEAwHU5lxMYP8ulg+w33Hy+Fe394w49BWsUPzrs2eP/ Picgqp6If7zZ3yUqMDgYKySdb5mt+oFk9ngduUf/fAEn3acHudRx9RLjTDTlopoTySxW ApdibbJHEtLzUTTTIoFN5bH4Crgt45+qyGk24TvdVRmk/Xypp3yN1ycTSa7L+9hi4jVP 4TmZG6MyztUD3vAzcoBDbXeoo7qWZDV0HjQjKVyKk9i+WYC7WnEWA90knuIGt7AXxGte r/XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978062; x=1708582862; 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=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; b=w7VeyvVbyGcbd9RNk88qTTPzRHu2sXTG4PeO0GiS//v9OL02mG5V4XNwXT7p9Ykata x2fqR/JNluKcot89bEOSfMQYhoY/yviDdJogedCNFINoIFAtvUz/6+fyYce4Czpg9CtP APxoKjT6LYCdvOPTiAeJ08EHB8Rsb5ROL1m6EHtYOCbDCb5I4OUyMx4L1DQ9lO2xow1B 9GTJRI5xLN+zkAXZ/IFkmfAsgWjiSJiKKpq7G7+ZuNNjrTDjLUtYU4Vaix3rgWA3BMOH cj9YvPJrsbaw1VbB+XMD9YihoGj5VwaxnfJYkVaA7JW2HpTi7Y9uY7zGkDt0zEWWh4Ld pVoA== X-Gm-Message-State: AOJu0YyBPZCoGx61tHmwhtAIeIwY7GyL7/L8ZbLWpY/EKqYWG/ORT9OG /LVQx4ZJx1Q1EzEdMKbQ0VKuizQFsrFWcdAykEXYzM6uizNboI7L5xTfyxsLS97jNmf5JScSXA6 9 X-Received: by 2002:a17:902:b686:b0:1d9:8f6e:86e8 with SMTP id c6-20020a170902b68600b001d98f6e86e8mr729039pls.69.1707978061977; Wed, 14 Feb 2024 22:21:01 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Helge Deller Subject: [PATCH v4 28/36] *-user: Deprecate and disable -p pagesize Date: Wed, 14 Feb 2024 20:20:10 -1000 Message-Id: <20240215062018.795056-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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é Acked-by: Helge Deller Message-Id: <20240102015808.132373-27-richard.henderson@linaro.org> --- docs/about/deprecated.rst | 10 ++++++++++ docs/user/main.rst | 3 --- bsd-user/main.c | 10 +++++----- linux-user/main.c | 12 ++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 5a2305ccd6..3074303b9c 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -63,6 +63,16 @@ as short-form boolean values, and passed to plugins as ``arg_name=on``. However, short-form booleans are deprecated and full explicit ``arg_name=on`` form is preferred. +User-mode emulator command line arguments +----------------------------------------- + +``-p`` (since 9.0) +'''''''''''''''''' + +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. + QEMU Machine Protocol (QMP) commands ------------------------------------ diff --git a/docs/user/main.rst b/docs/user/main.rst index 7e7ad07409..d5fbb78d3c 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 e5efb7b845..521b58b880 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -364,11 +364,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"); - exit(1); + unsigned size, want = qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size != want) { + warn_report("Deprecated page size option cannot " + "change host page size (%u)", want); } } else if (!strcmp(r, "g")) { gdbstub = g_strdup(argv[optind++]); diff --git a/linux-user/main.c b/linux-user/main.c index e540acb84a..bad03f06d3 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -332,11 +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"); - exit(EXIT_FAILURE); + unsigned size, want = qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size != want) { + warn_report("Deprecated page size option cannot " + "change host page size (%u)", want); } } @@ -496,7 +496,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 Thu Feb 15 06:20:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772868 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681532wre; Wed, 14 Feb 2024 22:25:59 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUMzteUVPUoEctr20kjsp1TG+UkUoat1maBIAaEHunXP9iTx73M1piu9n5TRgnaxVhhRIwW1okfvupP6lKAgDbp X-Google-Smtp-Source: AGHT+IHf1IfuYdtdkIIOAWdjkGUZpejA4S+SpcoKeN1+erLfMmgWRIAa8q6tETcqnddlH4DG8Nf1 X-Received: by 2002:a05:6214:2b96:b0:68c:c8ce:3228 with SMTP id kr22-20020a0562142b9600b0068cc8ce3228mr7397781qvb.29.1707978359149; Wed, 14 Feb 2024 22:25:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978359; cv=none; d=google.com; s=arc-20160816; b=WkWGCUtVZcVsttaeBrh1SE/FN8g3xs1F4Oi2ZkfMOYqM0KYcfE/LTqTmkeUJW7umNC JSkwn8Rwb2X2fwaswUWq7OSJK5Lnf81QhLKLR1VQANmHkyAfmvUsN/E9ycaJ4VXf/Ehl gHpkOnRqfP39lftbViskwGBkWTQU3+6SVvPz0ZT89kHfmwvlgoze+Z6pnWr3xA3dKx1r MAznQ3OqRiRjla5x8h+xkR8TBcgh8hKVgRgFwpzMFjOqGgelyRuEtisuZ9ivm4V0pzI8 KOitgUmO9/pe4QN5gOyB/SumyDhnZ7slFCK7ZQi0jgAw8qbmSAsYrJhTxqyC8RLHwQsv 5ROg== 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=qOkw1UdDHHqYlRltK3URYQYAqp5e8MWyuYN33RTPWmw=; fh=/b6muhdHFTPGDEv1d8xYfSbM3v1A3Ow/UiHlQW4DIq0=; b=Y+j2SVE24fBGWd3Nvx9hYZEs8C4cAgwP4O6luWJWhIVSRHe2uoIFgITUQBxs+F4d1f Qy50bwnzDGLQQ0xq6HSLjR3Sywj99hm636a4zMqBVmbIiHhGglIo5KNI2j1+R7yfIVem JpuU26UKF7h/u2j+PtauVhScAm4jpgZANm8J6qR6gpLwdU7SzUu0wecpchWc8xOoTtyy VNYkgYF7NkoM76GmXngW1qF5EU4v/yggEkk8rVxDg9KSzMm5UX2IbxUcie0ED4HAKZq0 hhIteDF9t7VZlaQI42YjaAfqBoUBEajcx0W569Oz1PMzH6F8WTVZ39AXvVGLZpy1orr8 Mx2w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="KT/Fat/p"; 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 m26-20020ac8445a000000b0042c7c51f74asi662053qtn.726.2024.02.14.22.25.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25: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="KT/Fat/p"; 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 1raV7Q-0002yt-CQ; Thu, 15 Feb 2024 01:21:12 -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 1raV7O-0002vR-Od for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:10 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7J-0005ad-FJ for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:10 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1da0cd9c0e5so12118335ad.0 for ; Wed, 14 Feb 2024 22:21:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978064; x=1708582864; 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=qOkw1UdDHHqYlRltK3URYQYAqp5e8MWyuYN33RTPWmw=; b=KT/Fat/paPsu7JQycT3mvV7cqCjgub23ewMPLvtwuIG9ftOZ7iXQTjkUCoaUClsbVH 8Xq9HzM5AtiCi7FpFvIuTNJTCXRlqr9yV5SSWNVx3gTA6VMt+aqSDRY51AAANCc61ArZ UCrfDmb6gh06ZmsHbGbgjaQ+gDonU2cgH+nJg8Er6Rl/0hi8ncSzMuWYWt6TAmpIyq01 ao8xIw0zF2Gbkwmhu/NQBi0dMatUqenJZFn6pcp+3XnYpmJuNEBlayPVIuCGsp7f4AEZ 0fEFpIXqwtCYqp7XRu6G/THwks7s4Ov7zxNiHDrKqXXD5zjBTAD1oTwqEND2DOQml5wG dTAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978064; x=1708582864; 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=qOkw1UdDHHqYlRltK3URYQYAqp5e8MWyuYN33RTPWmw=; b=aOX41UeVyxSq80GaX1HLy/mgdDqIoLOUV4vVPJDMWHFPUF0ggGFUtvfHgie8Xny7Gh T1/03xprm/KTc0hHE+WmDvTkuQV/QwaxDYe6IZfShYiUERR8/eGTF4iKdqP82Ab7nVeE TJ1/KP7c6KmIj1qr3OU30iNDr0pXic/DFbU32e+U6kzkeW5YimrQQ6RZx+d7ksmDtOWq B0X4cWeSvWTmtKD7UPcLE+UJscjUx+5whmhLS/NOB0v9jRMYlfROHGB2Tai5EMWFccL4 kULLAFE8LSpgUo1pdpfCKxqNFgh72vIEv2ChW23wh26RIyKP1+0H7pTDmQec/wHidhLo QFEg== X-Gm-Message-State: AOJu0YxzSfflC9cQnfvWzz5Nlz2D8dHsVv4eylhM8I9vktBgeNJ2OqV0 7LmjeJKeu8AIbSXX009hUNG1uORi4aBVKOSG+H9jQOSpH3vmC7iDBz/2YaEbytsTf0oVD8FJiCh w X-Received: by 2002:a17:902:ce8a:b0:1d9:5923:c247 with SMTP id f10-20020a170902ce8a00b001d95923c247mr6291819plg.29.1707978063708; Wed, 14 Feb 2024 22:21:03 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 29/36] cpu: Remove page_size_init Date: Wed, 14 Feb 2024 20:20:11 -1000 Message-Id: <20240215062018.795056-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-28-richard.henderson@linaro.org> --- 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 9ead1be100..6346df17ce 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -20,13 +20,6 @@ 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 4385ce54c9..5c2d55f6d2 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1179,8 +1179,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 1c695efe02..c1f57e894a 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 521b58b880..4d6ce59af4 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; @@ -307,6 +314,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); @@ -403,6 +413,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 86444cc2c6..8763da51ee 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -474,16 +474,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 a82555ae15..3a2586a04d 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2118,7 +2118,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 Thu Feb 15 06:20:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772850 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681185wre; Wed, 14 Feb 2024 22:24:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWxnshdlnJigkpm6Qvgi+3Yhl4/WXZd1w6FLKUZUGWU0TkwTMCoalzW5yv+EJwQ9qA6i9cuAi5cUftt2N6wxsfa X-Google-Smtp-Source: AGHT+IHqqCb8Ku2FmMoSVRkXsB4ixJHcJ16xy/o1IjXHDr3rGYh91uM9tT8c7bkWPx87Xt+jRnZM X-Received: by 2002:a0c:e487:0:b0:68c:67aa:c056 with SMTP id n7-20020a0ce487000000b0068c67aac056mr951702qvl.39.1707978277272; Wed, 14 Feb 2024 22:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978277; cv=none; d=google.com; s=arc-20160816; b=L4Ju+tuDt48RKEost5isbKVawcmFc2FaxC2VE1i3Kui/1APFZjIUAncWt6AjJBSncq zlNZtO8jSjBqi08TAh/1KOJUK3GRoqVgp8uy6d4ZRcXSr1hkOHI6b7yZmrlIjBe4tbaa DdYjvm3THuNfgNpj5lnplPUW626g6M4SG7Q6Do6BfeP3JAA70Jkw5tnsIKS5kN4og75B 56HfQZcjq5GRrxOwecZiBu7Gkjxb4xp+X68LZwbwDEwmvZAQwsX+ryn37JciK9cTG9se fZ8ksKsKG0+IgHxhufuyX7ogf8XaNW61K8U3w3Q90aKHVsbDgwNFctDivIUj/gr5JzL+ Yjzg== 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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=E7qLEUgmbuvD97/RGlo23JUvwR3nso6R+8ioi+UXjUMrjOsUg7R9Em6W0Ovo7DexGG cFTgk/y69yk0zUFTFtEbD4m+1wlXGEzLOAQps9Qxnki6NZAKxUxCCvNFMPy6nWfDEW0g 6QrfwKjXm7AUWc43jRDKs5PfJsNjxU/z9FpS/SD55YDrYVmcZzFZ8dS0fxq8H1m2lNFm nQA6+60yljn4NexbKx6PDZoQUALG95hhLXfttuTDDWSqpak470Q0LghrOZLxIFpA5Pw/ t5cZZuMPtuo4+bK+KE8o4NH67XMHKUNRXaaDzZYUh/JItxwNtezlkznedPPgFXUCOQg9 qblg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ON0vDx1j; 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 jq12-20020ad45fcc000000b0068c879eb37esi762355qvb.438.2024.02.14.22.24.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24:37 -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=ON0vDx1j; 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 1raV7P-0002wn-OE; Thu, 15 Feb 2024 01:21:11 -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 1raV7N-0002o1-GV for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:09 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7L-0005av-Oo for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:09 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1db51e55023so2969545ad.1 for ; Wed, 14 Feb 2024 22:21:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978065; x=1708582865; 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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=ON0vDx1jfOO6XNXhgRG2bwbv9GCJZfaIHvQ0gRfZ/3ZBCT2LAboGCvSn/9+olyqgwb DGy9s8tD/N2dii9MXRJu33ZtLpKVNZybb5edCSBgJFgs4kWBbiyySu3wlgcPgvn4zGkd Y46i3EFX85mwaCnhbKxcIGDIiOWI6Yp7jK5sOiJ9Rg9vw3aPlOj7G//q0GnzqFwdAQZI +6sQPH2zFHBdXn47qwmeAbf7i0p2ip2kDJchghD82dClha0DrFiejjaTN+SuMEMNPEPI bD82pw0eBIp2Dm00ukt4OLzTj05gDRfThmMTIIuCqpFhzunTAmfriHBsj5Edi5dT9Xxk m6mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978065; x=1708582865; 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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=pCZyrwXDLTFxWHuD4+6PasWKwaTZyTHEEabfplUYI7oSACDzijMR2bM5kW5Cp02DvK phzb0mkZR2Psy385O5Ttdbb26KvCUasvcn3xYbtx1zVuj8yXwum68hAhs6MJsNRf7Xf7 rN4bay1zJNcAxnCnQ+T8GpvKs1+4dKXomVJxYPob7tMrjwi/yenYE8zcIvJoO+ufoxfs BpuzN0cS2I9zPxdCcR5iyFH5IIQ+BvH/Jnr56NZb+f/kriWDMomIN0MyvJjHL6nInq6Q 3++3OMw8GVyvV7r+qwNiNNOXIcsyjC2G+K0strkkN5EYk1Hml9Q+b73dxpZr++p49JRf 9/Gw== X-Gm-Message-State: AOJu0YyCUyGnxGCmfmh50tvBCpCMU2jAsucDur3gkSXViqH+4TODnCYT M60mwFk6olrHGb5D3JmRIy9gzUHMEQBYlH2tJmrQEHOLA25C+EVbb0pGzktJnxL/cGsv+a4SFEz B X-Received: by 2002:a17:903:1cc:b0:1da:15c5:bc06 with SMTP id e12-20020a17090301cc00b001da15c5bc06mr1195475plh.58.1707978065257; Wed, 14 Feb 2024 22:21:05 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 30/36] accel/tcg: Disconnect TargetPageDataNode from page size Date: Wed, 14 Feb 2024 20:20:12 -1000 Message-Id: <20240215062018.795056-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-29-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:20:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772863 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681456wre; Wed, 14 Feb 2024 22:25:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUvJP+4TKYjggl3t0AUujvcTHzEWOmac/HHTVYHaA/au7xlXDJfR1zNaSVVfPxz1w1EOOyy1LycrRm9KN5+yBs3 X-Google-Smtp-Source: AGHT+IHYY5KkytyGYPYqTxNtnopS+mun6IDqUqJVd+Qx7K5I4/g9VQDKIjVQOQ2C3LnoKV2fyYgt X-Received: by 2002:ac8:5c0d:0:b0:42c:9e27:ee41 with SMTP id i13-20020ac85c0d000000b0042c9e27ee41mr1238621qti.56.1707978341832; Wed, 14 Feb 2024 22:25:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978341; cv=none; d=google.com; s=arc-20160816; b=M1qwKojZVv9DQxKCBEJrr93h53acIM1GIhQoSk6VTXrPD3/T6bwX4MT9ZJMa3I3gLL 6PPrAZggI8PfnMgMr/mCrlJJGi/1eTz6a5IhN+a4rmtsnmZ4OyetDLKNV+XTjPHdTvNb Af65TtSHp8QRy2PgUYPr6vQo6JSzns+Yt5vAucH0tpxv7wF7NbTD7xrj5aBsioG32F8z LQVgPipuTb/eSWV9eo0nmQWj4mstUYmiKHyFj1rRBVxtIR60T58oQEhutf7DrR6uaIYm 0ezAfZBYQg28P5iOZgulqZOSrlttO5nmszzjO6IpQ178YcGYUqVkwrcw2CP20+Ky1qN4 KhsQ== 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=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; fh=G0NodtoLUMhKR6pPncKXd0kw6+54AeSvXTR8kR6ypiY=; b=wXC6OcOd22oGy1nngKbquOOi1q+MsP8hxIxSNitpvbgsghTYJn4Ro5fM6WipPcuA+/ jTF9xxXR+7OuWvIC57J1yH4ZLgqpaD+LFHFUCr5iI/PolSTDXWvYdcMMwP4W5dlp+o2W DdO0o8kJt/2f8G/zF9RRysebNSuZKjYZ244EZJ1hr805sKrNzdi4lQBsSEybcLBgVU1n moE4skF2AncQx4SP9s8+igm8IRCPBI6SFgC7MmeXTfvFBGcaa8RUd5arQUR2cD2UZo4B M66CLkNBH/4ei+L3L0XiQRijoln2Ji01hVu+iaz5a7q+c+YsdcIjjXxEP0GPpGsK1RKe X+bg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v4wd6VKy; 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 l4-20020ac848c4000000b0042db2599576si675335qtr.700.2024.02.14.22.25.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25: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=v4wd6VKy; 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 1raV7R-00036l-Il; Thu, 15 Feb 2024 01:21: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 1raV7P-0002w9-2a for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:11 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7L-0005b6-Pu for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:10 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d91397bd22so3785925ad.0 for ; Wed, 14 Feb 2024 22:21:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978066; x=1708582866; 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=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; b=v4wd6VKy5O2IRTProYWFR0Vcv+WPssRe5SK74jjAA2yPm6ASPm6m6kzj4ZE8ogpUFi fsSXfdqzQt9xgKcnUGQPgUEaRKvoJu/B0VIN7/GYhI86gbWiVauGD1o4c396AvTVV2BG sW58FAOp1qqxbIrgFHPusCAu7FF7Z1McXjiQL/KtNQ6cKKsD2pHTYd3RuvUQb7UKXr6/ IHVM0KCMLeBYIv0xMzMuUgxQC4bUjJJpezU0uZCvkg6+ikuEZbUhE0g0sQJUgdNernYK 3cDJv8eIa7qdzMDA8PufduinmecsefyLeCT272b2DmEy6FlgYTmKziUIDm51bsx9lShQ Qhiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978066; x=1708582866; 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=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; b=cZC1e7gq9OMOAa4Veq62nzlN0UkcZK/TyE9Q6tTJMdLhrmFHryFcop23iKb7qNfH3n Yw5GG6rHwQeW4FBQuNXbqyV042eblhsch4y+O5peWQFsmf5K8ahi0G8GzW+l7p5KPRHm I2NNG3cUBhq2nEXoTUeFJKa6+PIIrX5c83wZa5u+FIQ5aQ4q0Yjsy6vAjOyKWQ7kC/Dy GLv+AHABepgkCcp6i/CTLnWiexdo6XhnfLWJonngsK7nhUGfbGqycvUvB6DGJEc5WM2E scnzSBw4l+jJX6JooCcQ7/zjfVr68MI/z8GspALI98qeaKPunUF85sJ580MkI1rzdDfv XM2A== X-Gm-Message-State: AOJu0YyyoNitrWmZtdfIgCvWrSvZU543IOPDQ6fkQ6fZiKUBXyWYSkRJ Oekeu/CHRBS+tDagK6sWvdV7Ji0kYBfktnEbBIcIYz5K+d8hqikXFjia+0LJp33n4W6kTVJNOgo v X-Received: by 2002:a17:902:f7c3:b0:1db:75aa:7f6a with SMTP id h3-20020a170902f7c300b001db75aa7f6amr751041plw.20.1707978066567; Wed, 14 Feb 2024 22:21:06 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Helge Deller Subject: [PATCH v4 31/36] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Wed, 14 Feb 2024 20:20:13 -1000 Message-Id: <20240215062018.795056-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-30-richard.henderson@linaro.org> --- 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 bad03f06d3..12bb839982 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -55,6 +55,7 @@ #include "loader.h" #include "user-mmap.h" #include "tcg/perf.h" +#include "exec/page-vary.h" #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h" @@ -680,6 +681,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; @@ -791,6 +793,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); @@ -804,8 +816,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); @@ -904,7 +914,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 Thu Feb 15 06:20:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772869 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681574wre; Wed, 14 Feb 2024 22:26:05 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWEa0GTrIWounMly36JlsnD4h/QEv3sW/J6h5nxiDkt88AQdENkKHgIuqn0R/VakyH9THzlcuVUZnNsX1jcbXgU X-Google-Smtp-Source: AGHT+IE/+OOGf4UkYBBC5/kV1wWsqoeyDsG3jNPUOeupIFNn26qJo84EyZrbVXkbQ3e2HnrISUza X-Received: by 2002:ac8:5f4b:0:b0:42c:51fb:4dd3 with SMTP id y11-20020ac85f4b000000b0042c51fb4dd3mr884162qta.3.1707978365575; Wed, 14 Feb 2024 22:26:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978365; cv=none; d=google.com; s=arc-20160816; b=Xpd32d7/Vfuy3o7zZwvsB93acFZkyASkv1TbJCkLCdSqB4Y6KT5mUguNpifm7yS/pu zwpJiI6uk5bVjOKLGUeFBF2hKK6Ot4dT4xIn4OsStKJAUqzE30PpZu3HIgueg6lEuVw4 JJ4+hWFt2NMbq3NchZi6rQ6g0yk/yzE+UyXy/395vUyf3qPt59c30yKYfEta+CEIeTXa klsJu+cKcuhNMRLPAK7XPfFrtHSjoJYX9FJy9LU4PaPPiZsTk8BFWl41rULe6FoW6ztt d5B4XCSPPMP4Mq1xcuaUG/1p7xsnJC6yveV+V9Tsk7dIKTSNDiYcm19Us5eLdK19rGSP l5Xw== 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=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=yVPO0zNZjGt8Bwo0Qpeb6ftgz8njDf9YFO1bySSXY5GNvHljHOdtyLHZyAiWv1WfUq ukSXT4B9d3R/qZCEnSzOPu7hGdTIbFuAfVqdKOPVKIHof7vMRAFzvE9WMINu7wbdQ/Jm DxUpzBBMN+HQ9LcIeIMkyTe8gd9HqKzr4YbU0UMSBqogEZW8cbhMbfo2001Push03YlQ gQa1uraxCl4akeKZmxX1nSyyj081803fyZnz34o7SYRZf+Gf8SSEdgPDQiHZmMUq6B5A LRovpT6fSqtSfGobsYpRAiJD9RZqdFYJvUQe3dElZzJyzIyv9ColjS0pC9HKNsHnPvXU L6ag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fednZYHj; 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 j16-20020ac85f90000000b0042dd0754fe9si226913qta.705.2024.02.14.22.26.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:26: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=fednZYHj; 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 1raV7R-00032M-6x; Thu, 15 Feb 2024 01:21: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 1raV7P-0002ww-DH for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:11 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7N-0005bQ-ES for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:11 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d94b222a3aso4607945ad.2 for ; Wed, 14 Feb 2024 22:21:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978068; x=1708582868; 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=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; b=fednZYHjNTaq6wbLI8smTVXFlwEDTUgaM+pKT871n49izPOZ2/I3JYyQ0L6uCz99O+ co3FYzvumfdaGjpUwVgAzoz0RLVmPB2v07QwzvM9rfsFh0B5xOeCJlqK2+m8lQ/YAM1Q D4p8K9BCbwUm20d4mbRW1AfX4B5Ez9IX3OT4ae/nk7Gj9OzWQaCnmmaa7SDzj6VdpkpQ i2q4XZiH/j5PTpSxDZ2hg7NOg8N1H2lzD+Gu2UD6R7uHKgQJ9k/ItFW4bP4f9C6hKVA1 90SbzT899xHTqVbpOkcBMqcBOwCJKyWg24IxiQx/gdgyeoQzJ80ZHbkx1QRRsouQi862 7/9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978068; x=1708582868; 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=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; b=q2bEoOQ8vPvS6Af/EXsqUTUO1TTo9WKV8iblc7YF6+QIestSu1m4A/FIIyWirVPfT+ R7CiklC7cYWmzQJd5U6a+clssvGXeCz/jhPjFVvPoWyo18sIP3MxE9Q4LsDiXUH0mBIq vkCDYU+Cc6+wDjiSsfBr2mvnNc4oQR3+caiBmjvX54HmTnJ5ENBvXKVoT0PbuwqJ3oRB UtMIyIjP4QrZvmu38FlC7qKAroUZpUZPrIKRaZSjIfobhC2gJ1jghufjP+1L4oRDgT0u KfrIjp0j6imX+o6X9etLVF4nwa00a5eMbizPbilEL8aXy3xhG+jyubFmWRWAOMxmXVv9 Irrg== X-Gm-Message-State: AOJu0YxoVBHaLQ5LVZDK2Th8aYG9yBN8On5IE06iDhVdbzhz+Nuv93a7 N7/4iLyDPS4bYIzWvD0mN7twlcJCp7cXxgnsRo+81Wp+MLVnK2RqjLSXfui/6Kk82EzV7JoXVo3 S X-Received: by 2002:a17:902:aa0b:b0:1d9:5371:bc with SMTP id be11-20020a170902aa0b00b001d9537100bcmr798940plb.37.1707978067971; Wed, 14 Feb 2024 22:21:07 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 32/36] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only Date: Wed, 14 Feb 2024 20:20:14 -1000 Message-Id: <20240215062018.795056-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-31-richard.henderson@linaro.org> --- 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 5fa86bc8d5..2325d4007f 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1809,7 +1809,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; #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) @@ -2100,28 +2099,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 Thu Feb 15 06:20:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772857 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681382wre; Wed, 14 Feb 2024 22:25:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUhsEz7ZGR1RTsBP2VtNzDquDVU21pZ4MDLAlP7IHHaK8oVRxNb6c515/M4/pWK1TQT99J/vyGNL7LeKbiish2Y X-Google-Smtp-Source: AGHT+IHjpkRJqDR5PH8AoqwNopj0YjeJ6YNiOyjDn7kQPPll+uLzVezw+LhElQf5hccBowDqjVc0 X-Received: by 2002:a0c:cb8b:0:b0:68e:eb0e:fd18 with SMTP id p11-20020a0ccb8b000000b0068eeb0efd18mr691399qvk.40.1707978313966; Wed, 14 Feb 2024 22:25:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978313; cv=none; d=google.com; s=arc-20160816; b=mS6x1CY4HvWrl+XhKD/1fA8vNFynC+qIVvl/kES2DwN9OYGQBm2taqSztx7gKEc7rd IYl0ZCKgn3qxi564u+6ov1EL8czMC2YIYdfTsAYUAZbUjT3F0NF1k+PMuLovreNCl0Bu WbPZJDVeP6vbfrFP3stGXvSJVXX7Wt/eSvOkOxDMIytSEJcgLYK0tbirk/DKZ4u6BKb3 +dbTEqLHItuTJ6K5IqaecED1GfzJZpkmdpEL1KG2/Epv29YsAubsDiPSynWBVIdL+5A7 thBMQxnhHlIs66kiCd70X6Qt/iv0rJdHkbp5qoHDNAzg1y8BM1LHx0vbhhwyMAfVOo3l sT0Q== 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=e+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=tsU+tD2f4s+ZmiI7ZrGxq/2XvVPI10AW5kTAbLpR3DRT+qBE8wqCHD7sc0Mvn5e5Kj PLYfE0CLn+M5aya+JKyh/UZ7o+n14rRbhaK/IzhQkN8AV2HiwTlytb6olYzH0N2S6faf SI5YyAWpgI6BI2OgUlhZJzCuCE8Su61ENNKViUetQGuFFwX8SX+/pu8rgc+TTI8pzYAS xvYBZ0QloCB4tP/SJImb7tW0OcIy/5S3bsaw2HlC/YvKQ0YdKXNG7XPsLDZ1RA1KT5Ph dBrQG7Mk5gpSWpI9x1Th6DgU56UKBw6tkM+KJjOTLFj+WTNQ1UySsrQwFmmL3Hd3uvR3 NFXg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZKKbMeDr; 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 gu10-20020a056214260a00b0068d034d08b1si780741qvb.305.2024.02.14.22.25.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25: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=ZKKbMeDr; 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 1raV7U-0003Es-O9; Thu, 15 Feb 2024 01:21: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 1raV7Q-0002zh-Hv for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:12 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7O-0005bp-Sv for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:12 -0500 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-290da27f597so413910a91.2 for ; Wed, 14 Feb 2024 22:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978069; x=1708582869; 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=e+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; b=ZKKbMeDrMzEYzqVTYfXnb0dqw4ImR5L3YY2JHrGAmKx6W+nEcEDxLmRWrEKQEIKpdA WvF/ZUB0PcVoYx/q6VCzs1ClGfmIXIzkzclcvckkPRVYLfKvMk2TgqJJWfTudywh8w5o Ag+O4O+4ENtY8GEdlvoSrb7vyFSj/J+zzApJawOPrFoRLHc7vsYitfllLzFeRZivAI57 lMrvBcW7mqBLElvrQBPgF9OV+xUO+WhOhZFb/ezrRhLegjsW4yA2bXchu+gr6yZluNki zk6ZD8rBQOrBLE9sfHSDsovmL6iXzJaRRQFvlFZ5owSWagPgiBkNE5OGL7lzP4W7YH2l yD7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978069; x=1708582869; 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=e+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; b=Z9WWISlzwyEQWJyuZUUTotT5WIOVJnkbAhV1Zm3P2xxHjE9WMxVnS1EDHBH6zJMTUN dLX4zmmXSFaQiU+pGk8SJ/usRpgW4kHCC61Q6tsGhksJjxCU+Rbj+4kZ551L0uSQLwyu UZouW4OfvUDxrWWNJ/1vfjTAoNRKhIPyqD7EmN9JA8ulUnyTcWjcoyLpYjpdnRvut+Zd 57c0KhB0NXFCj5JllNXaqhMr6tcj9rBvf2RZrV1AqsJjSA+lxOm0mp3UbR+NlkelyhlA MuYX/YwkaT1wJB1cNe5j8KGJJT5Fbc1SMfDuCqZ+aya3iPXXHT2/XnXPr9mscbVS6jLQ efsg== X-Gm-Message-State: AOJu0YxRQyR0Mxs1kesv8mPt1CD7G04c/qd//7UDsiJLAVORpUt2Bh/I 0feW1eCnrFjbsQAK3515tep2Q4J9vG+7JFJeCnH2z5590UDmBmPhomuiRr7URwOkAYLlpQX3jvY 8 X-Received: by 2002:a17:90b:2308:b0:298:d43b:812e with SMTP id mt8-20020a17090b230800b00298d43b812emr882435pjb.7.1707978069512; Wed, 14 Feb 2024 22:21:09 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 33/36] linux-user: Bound mmap_min_addr by host page size Date: Wed, 14 Feb 2024 20:20:15 -1000 Message-Id: <20240215062018.795056-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-32-richard.henderson@linaro.org> --- 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 12bb839982..551acf1661 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -901,7 +901,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 Thu Feb 15 06:20:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772851 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681189wre; Wed, 14 Feb 2024 22:24:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXAESdM7QZ1lgasYWamLimy9Z6DJr1wxR0Xa64XPbeFRqTm6v550h/J7xkHhItojd4TfYlSSGt5lmWVJp0eOzjn X-Google-Smtp-Source: AGHT+IGoOGPlQEG8RxIDJU6yjVx2d6wVADeN7V9MiM/qOmFW6ULMwLYfyC7QyPOrHcqWLVLJjULb X-Received: by 2002:a0c:f50d:0:b0:68f:11e7:4749 with SMTP id j13-20020a0cf50d000000b0068f11e74749mr851437qvm.34.1707978278011; Wed, 14 Feb 2024 22:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978277; cv=none; d=google.com; s=arc-20160816; b=msT+Ak+Jj9cOV3pXnF3Kf9/no0azvZw+p6zUV1By2NL3kEIryvqWUVahezzvact/HU Q8jZAlt1jqCosbixED5xUWzghB3zwVyKS+ueh6XS3qwHgUq+2nQL106c7WkIaEgXIlRP hb04Yx58O6J9mq80gImobPNY6yuBNTjAnye46Uo0vxnxSMZP3N+1kUsyHzmppbuUrR3g c0z0s80lF0XQfbOjnvBeXFFG5KTj5HWUxHJiYSbwq/a4u8GSJZDOgmny/vz71zq27kdQ uZir7ShKRs0HXq8VtCXXZnaGaiIVHZOnzludFGbU8/3g3/KQJP9mxrue1OxCLCaDo9/n iFRA== 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=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=ZwFftSHEUE8u4mcCNgknImBX0NAWKbagB4UccqUWodpSyBwee73fU6S61DxI71iYYR vSDP1zUxh8SkkATE9NuMI52E03N4ZdO9MKmO+HQ54Kn9O7+Rrga5t3wuk1nScLyqNYZD URmmgwuV4iZXhJCV/Mfusuz0NiGL9P6CvCXOFwOnM/K29f4IWkvHh+AqFMVmMXmt7PqI DEP9++Z91veSRdAr1CLFgg9Ky1ujNQjU5YD+bWlENnjarJL5RCz3tvzCAIcokx4am5cA TBvyUIMcNAQXQ3XgD7kLgBqIMQU55C2ZDl89rO3WcTVpanXDhx+uE1ASAbssRPNSdxIs 9XOw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KAar5FC8; 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 jz11-20020a0562140e6b00b0067f8393c2adsi730855qvb.560.2024.02.14.22.24.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24:37 -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=KAar5FC8; 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 1raV7U-0003Ek-GY; Thu, 15 Feb 2024 01:21: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 1raV7S-000399-75 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:14 -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 1raV7Q-0005cP-Eg for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:13 -0500 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c6bd3100fcso366417a12.3 for ; Wed, 14 Feb 2024 22:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978071; x=1708582871; 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=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; b=KAar5FC8e9We9YfaelMA8tDRcPvZrvRLb91Q7YnxlfG21E82bxIs0aT1KYJaPJfexu 8+Ujq92RpoW+TxTuTqANBiMVA2ym7gryIL9x6jS9tY8t/yTGi/rJ72OVgy6nApq33cik mhVgpL+oCin0KctKIhlVJmmw3OWh1exiJcIMZDT9ue7rIfRblvQNSrpY9Dutg6hOWuKa l3V0yPqPUvnRKqTH6CGTQXjYLTyvSTPqvgb+yryCSGMJvOajF/uC3UOvMF7nFC5ZXyNl ukaNLAtsUNbrnS0mpZNMComLlo+hSuCTwZdSDL2HE7J4T6wqoUCEwwqS2Ec9joytFV69 7Zfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978071; x=1708582871; 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=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; b=bpcCsqGA37z1AMmG0FcWUgOoSVruRKvJMak9DYD+7zzo4MzwEz3M8kpaprOmWQb+Mz GXllTzknm3vKqiuWdFXKe0WeGCNo8QMFQDP565P2UzDc+xEyPHYgcI31aWWMGDNdn3Ci juwoPIXp1npNuVVMxUaWx4gtNb1D4iNQDdKZsbFY4DjtQy3oslF/b8yw2f/g1kOXnwj7 +QdMgCbvuD7xJzH9VtIUXprqQ5CPlr9C8IsYsJJ9UmxZZD1yEvffq9KBWNjhYRwxUzp2 mkm+OdcHLUHfC0nkoRKEKucCL1Vnr8xMQpZgxFAEHEU6z1DbwIFGcj1fqrOMMLxELbi9 z+KA== X-Gm-Message-State: AOJu0YzLxfnYOO2p6cmg8JuHO7dJzRZaW6xkOWhRo8z44Pkz+Ywd1RmQ AP51DVZHtpTITo1U7Io+hMz/sbQNFz7F0MdQKi3x2yqlNWAxnF708Pr3gAom2dGwYUYnwVvc3oX c X-Received: by 2002:a17:90a:cc12:b0:298:a449:d3d0 with SMTP id b18-20020a17090acc1200b00298a449d3d0mr697976pju.47.1707978070971; Wed, 14 Feb 2024 22:21:10 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 34/36] target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only Date: Wed, 14 Feb 2024 20:20:16 -1000 Message-Id: <20240215062018.795056-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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 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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-33-richard.henderson@linaro.org> --- 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 Thu Feb 15 06:20:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772855 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681339wre; Wed, 14 Feb 2024 22:25:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUKmGduqZprkqxDtwKxCt23/KvfbXgfD1lcnD7Qc6fSKEobFkd4n4Mm9i/ZOMue+I6l2Bt6kUs0T+k9ZBC7CGro X-Google-Smtp-Source: AGHT+IHbAVdJw5+dWymHDQVOSIeZjgLaIHn/KLBbL6TTs1yAQWRvlwhriKA8nHJ8ZRVwmq84Kfnk X-Received: by 2002:a05:622a:1653:b0:42d:a920:e046 with SMTP id y19-20020a05622a165300b0042da920e046mr1241902qtj.52.1707978307793; Wed, 14 Feb 2024 22:25:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978307; cv=none; d=google.com; s=arc-20160816; b=eCF9rKHAJj7JvdDj1MtG7Y/H/D2lc64ai4P5wrra2+3yyozWHuLDrp6akbkoNs7jn6 7uSdOlZTzrYYbn3ZC5yT6bEpIEpQGD7v5DpDquM2nHSO40OVzwDt76xAyT2B0VM0yRSY TJerCKMQkF/Zst4OqsthtpdOCek2N7+yyUOs5D2NFI7hIFTza2HAai7nJN/+Gu82xGk4 tVem8GZdLZXtXsqzlh7rG2eKdxDS7yqkbbXCG1J1GCZVf87/F83ZtrDrVeuFOOfplfRl 7K510oJHWlw02MlOtXA6G4o3xsAsCkHzHcDUywUb5BM7K1EoLLnbrue8nW8nv0rEeyAT TQcA== 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=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=iboVsGDcywm3yrNrOOKkq4woMJokooIAzZy8/BQDDRPgXKsN6FUe/U9E7OSTHz2rfG 3hb7MIjCBdIsfFZbJpFPI/0Y3qaOSf4HT4n4ix2+1JvbMzveqnNTG0oahkaFSTVJOMOG RpGFQ1ZV/eVJGRYJoi/80CgBzZpdfaH2D9mZmOLiQTKDksI6KUpLEVYitATWWziw9OPz 6b/ovx/l/LWXZADse5wwza2ISnVvruFGz2x3dNYBSRrQE2mVI+qw5pIww/TbCwlD7doj GrTxN3ezpoj60Uj8tSmf8OOlXdNoQDwweoxVmGl8LrkrDxxer0933dPr1BS+4mIoNd2U BB+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FFVbwpqQ; 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 g2-20020ac85d42000000b0042c30f068c9si775947qtx.452.2024.02.14.22.25.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:07 -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=FFVbwpqQ; 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 1raV7W-0003G2-FH; Thu, 15 Feb 2024 01:21: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 1raV7T-0003Cl-Fc for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:15 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7R-0005cs-PN for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:15 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d932f6ccfaso4502535ad.1 for ; Wed, 14 Feb 2024 22:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978072; x=1708582872; 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=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; b=FFVbwpqQ0IeZ/QNmDAsgitY8l2ck6762cD5sSFyvDLX/UssGgnDZcxrSfmz7CVGyIJ mjx2X/ef30VrZyHSbCxdopbWxIbbP/6VrJc7MJzmy2zxDli3IfRFOqhNQ/7wCyGgTpwF lUPHqkicMPqMCQ5Ad5RWJdBQPO/a0L0o3IFNc13Rc1IMCcjmOGM777xx0Lx+JruuVACv c/7duZ0gLXWUvj8/d++Cz4r2PUrRL7AWGV0u6ET0tW0qb/uayzZ8uBY0VojojGeU/TNe LpK3DGsP+NCLfR+zBN7sUlcBd1vXITriOyPvKqWWHuHGmuaZaHv5lvl6LMERri/4oJbB So4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978072; x=1708582872; 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=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; b=IozPfgDiMC9J2zRYO67u1vlxsI3b6vHmxSrDrrFFhpTUpa4VxHC/ejLjE73N34uUvA i7153d3eVgVKzy5Oaz2gbdsso+7soI9fUmrgb0F2tAVA1Df3jmb2mkAo9rSFxEzd5RF1 3wL9YWML6XWxuQoHLff2VDdpuBoFUZwBMTffgoMeSNYOfis2QwXd4kIPSVF/E4fSSqdm cQcxJCjLedKqO7yHy9YLqYW5MfmfHlLwadykpGrnF4FlJfuXHJIrpLvv4UShLZ9CANdt yvhZXSa4cmnfPqFdv+2NDsBWx+9Ys03qdTtSr41uEEe75qxTHl6/r07HzCj1IBAB1+rI bCRA== X-Gm-Message-State: AOJu0YzV2hFY/+lUoNXvwEBrNDSu9XkF8yvoq9WQHpjxse1X7ZMZbmLP k5r2MEunZZbfQ4avCb5Ii8oVQjQ+f07BisfpqupGXImSsBeQ2pb/tr65OBdl8cfsszyQAs5V3J9 y X-Received: by 2002:a17:902:b609:b0:1d7:2e86:fb2a with SMTP id b9-20020a170902b60900b001d72e86fb2amr891899pls.65.1707978072391; Wed, 14 Feb 2024 22:21:12 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 35/36] target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only Date: Wed, 14 Feb 2024 20:20:17 -1000 Message-Id: <20240215062018.795056-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 Acked-by: Helge Deller Message-Id: <20240102015808.132373-34-richard.henderson@linaro.org> --- 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 From patchwork Thu Feb 15 06:20:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772856 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681369wre; Wed, 14 Feb 2024 22:25:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXbIJeUmZCrFDAjUEt0gok7wAfEQxYTGr+lkbcikcLl85F13izhppTvxWcUPQqxp3NM8JQiIC8h3BS9YhpoC3Bg X-Google-Smtp-Source: AGHT+IGESOekkdNgUD1Yw0mKsaFjeSV/nAgNmwaLR1ptSpzo8IRtSo3GTGFfSoKsnjKA+BwNS11b X-Received: by 2002:a05:622a:194:b0:42c:810f:5f4b with SMTP id s20-20020a05622a019400b0042c810f5f4bmr7595873qtw.13.1707978312680; Wed, 14 Feb 2024 22:25:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978312; cv=none; d=google.com; s=arc-20160816; b=bvbAsTGTB2lUxNv5l80P7SkZ53vE8cL+80Nlk4rRWFbGuhBgnzSit9ZD5ZM0gPcJCc bIwkngUCZbFfwrjKYHEGvnQ2Fsv1cJkp0dAj7kEsosdY9PZjhafl9wkYh0npkLduf2YX ss+avVtQhOJiAd6gqW6BDtsuaBwS8UWpXt/mlh2+oARBXI8w8l0G5eVVwAYke1SikYFy 85X2uQiqEZZ2C5hg/5nDck+OUZtgvuGZZJb/F4ft3G5G9ZubilWBlby/tbm17gkg6clp ES7nRKX5jDTaZ5bj9xLKP19/IYo3Ur5HZaZxRTfr3yWU6q0bueOdD48f3KLov80R8unp JJqA== 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=lIw0HHLdL2NvcxZjQjlv25wKknGxFlW0JytLKiI4Hg4=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=NYTvOmseAR3KGqrQWTMNPYRHtgIuMrl3v8WVFaPj8JP4dXgb9wkoMDmZk8OY78ERd8 Gpb/MtPKzl3O4FV2fKKwb9QKLcaDzCATbRdihkj0zvRlhH92u4NKQ0fMPPkIh2VTLSBV zWUySynpK8mrUIYf0TUPEoLNWBozbnF6zpwkmTr/VMOmbSBtiX5aF49sFVDxgXIojk/Y r8Q9lSq9pyjwaMIHDlctOmOvt4Au0fWjOwB4JKP3D7MrlKP754npMofqF/c1qbW3ie2D IbETGGMIv5kqvo9pb3QrHyu89+8j7T+H16ihzCQlZQOZ3LRVzn1GXjwxcz4LphNNEzf4 4KUg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dH0yOKfy; 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 d8-20020ac85ac8000000b0042c68ba44d7si709206qtd.803.2024.02.14.22.25.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:12 -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=dH0yOKfy; 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 1raV7W-0003GN-NP; Thu, 15 Feb 2024 01:21: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 1raV7V-0003FG-0n for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:17 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7T-0005dC-5q for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:16 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d9b2400910so4243865ad.0 for ; Wed, 14 Feb 2024 22:21:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978073; x=1708582873; 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=lIw0HHLdL2NvcxZjQjlv25wKknGxFlW0JytLKiI4Hg4=; b=dH0yOKfydA5ddESUduAoVM7n9d0LlyuJ0nlvDYKueG69KsA2mysm4C+DnRnX2lBe3p nHQ+CD5MgW6dRClMjvlYnXWRCs6KMEOavWXp3F6jzE5y9/vNZfX7bWEjbiAQm6l3aMU9 NCH0nofJg644ohKJ4UumrkgGt/Z7HpR1FYb4n6w0N6j8FzJ+U3djZMf6czSIr+2C4dZK l+8BwFt+u9rUl2O+LoLiAETCAIi+2nbSANetiw2bOW6oU0hoFiMUBO37hZkv8uOwG2dd GampUL6G929La6FGo2oCorpQ/bb0RAhgYHCI3Gf4q/RUaVIy81bTLbKW0Ogb+HPnzWdU wSBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978073; x=1708582873; 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=lIw0HHLdL2NvcxZjQjlv25wKknGxFlW0JytLKiI4Hg4=; b=woHePOW2YEVh2/qyLkOwKVxZIXgOaLtlHZz6G+wZi9f4fcqijFkwZa1ho3IERNuK5i F8N7vn6wfgGtzXeEN4n3o5/fDHJ+cCmD8GGcxQHdHalgRWzDYT4trbvWwXrk4UEqu1F3 ltLOJG2Ub3/IrxhH1WLVCHWY7ty/1cdx8Hz3FGRJQvmh654Xvv7G7B3oOEJ/P8IRyaGV huswzjLrt5KIvHy1IIOwiuRb8QS5BpVF6/qYtItwjKlPw6S46P1Rb+cBG39BbNasYFeu iNzR37TftlNZCkX37C8sQBLfddN8OSl/uJkVTUI7mD67dwp93zv5QWK7En2BA1sv4qKk gBFw== X-Gm-Message-State: AOJu0YzN2QnKXepdRT4OmK42Ln4uuKpnCfyJqYS9iK6gjmXcZdnrxWkP kBI2VWNBdyxZAd6Ii/ZhEswwJZpj324iEds0yRwmwQXIfHyEr8Wya5FeauPcmtZFOy6ID67QNeP 1 X-Received: by 2002:a17:902:ec8a:b0:1db:28c0:3ec4 with SMTP id x10-20020a170902ec8a00b001db28c03ec4mr1443472plg.7.1707978073608; Wed, 14 Feb 2024 22:21:13 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 36/36] linux-user: Remove pgb_dynamic alignment assertion Date: Wed, 14 Feb 2024 20:20:18 -1000 Message-Id: <20240215062018.795056-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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 assertion was never correct, because the alignment is a composite of the image alignment and SHMLBA. Even if the alignment didn't match the image an assertion would not be correct -- more appropriate would be an error message about an ill formed image. But the image cannot be held to SHMLBA under any circumstances. Fixes: ee94743034b ("linux-user: completely re-write init_guest_space") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2157 Signed-off-by: Richard Henderson Reported-by: Alexey Sheplyakov Reviewed-by: Philippe Mathieu-Daudé --- linux-user/elfload.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f3f1ab4f69..d92d66ca1e 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3022,8 +3022,6 @@ static void pgb_dynamic(const char *image_name, uintptr_t guest_loaddr, uintptr_t brk, ret; PGBAddrs ga; - assert(QEMU_IS_ALIGNED(guest_loaddr, align)); - /* Try the identity map first. */ if (pgb_addr_set(&ga, guest_loaddr, guest_hiaddr, true)) { brk = (uintptr_t)sbrk(0);